[Swfdec-commits] 15 commits - configure.ac doc/Makefile.am doc/swfdec.types libswfdec/compiler.c libswfdec/.gitignore libswfdec-gtk/.gitignore libswfdec-gtk/Makefile.am libswfdec-gtk/swfdec-gtk.h libswfdec-gtk/swfdec_gtk_keys.c libswfdec-gtk/swfdec_gtk_keys.h libswfdec-gtk/swfdec_gtk_loader.c libswfdec-gtk/swfdec_gtk_loader.h libswfdec-gtk/swfdec_gtk_player.c libswfdec-gtk/swfdec_gtk_player.h libswfdec-gtk/swfdec_gtk_socket.c libswfdec-gtk/swfdec_gtk_socket.h libswfdec-gtk/swfdec_gtk_widget.c libswfdec-gtk/swfdec_gtk_widget.h libswfdec-gtk/swfdec_playback_alsa.c libswfdec-gtk/swfdec_playback.h libswfdec-gtk/swfdec_playback_none.c libswfdec-gtk/swfdec_playback_oss.c libswfdec-gtk/swfdec_playback_pa.c libswfdec-gtk/swfdec_source.c libswfdec-gtk/swfdec_source.h libswfdec/jpeg libswfdec/Makefile.am libswfdec/swfdec_accessibility.c libswfdec/swfdec_amf.c libswfdec/swfdec_amf.h libswfdec/swfdec_as_array.c libswfdec/swfdec_as_array.h libswfdec/swfdec_as_boolean.c libswfdec/swfdec_as_boolean.h libswfdec/swfdec_asbroadcaster.c libswfdec/swfdec_as_context.c libswfdec/swfdec_as_context.h libswfdec/swfdec_as_date.c libswfdec/swfdec_as_date.h libswfdec/swfdec_as_debugger.c libswfdec/swfdec_as_debugger.h libswfdec/swfdec_as_frame.c libswfdec/swfdec_as_frame.h libswfdec/swfdec_as_frame_internal.h libswfdec/swfdec_as_function.c libswfdec/swfdec_as_function.h libswfdec/swfdec_as_initialize.as libswfdec/swfdec_as_initialize.h libswfdec/swfdec_as_internal.h libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_interpret.h libswfdec/swfdec_as_math.c libswfdec/swfdec_as_native_function.c libswfdec/swfdec_as_native_function.h libswfdec/swfdec_as_number.c libswfdec/swfdec_as_number.h libswfdec/swfdec_as_object.c libswfdec/swfdec_as_object.h libswfdec/swfdec_as_script_function.c libswfdec/swfdec_as_script_function.h libswfdec/swfdec_as_stack.c libswfdec/swfdec_as_stack.h libswfdec/swfdec_as_string.c libswfdec/swfdec_as_string.h libswfdec/swfdec_as_strings.c libswfdec/swfdec_as_super.c libswfdec/swfdec_as_super.h libswfdec/swfdec_as_types.c libswfdec/swfdec_as_types.h libswfdec/swfdec_audio.c libswfdec/swfdec_audio_event.c libswfdec/swfdec_audio_event.h libswfdec/swfdec_audio_flv.c libswfdec/swfdec_audio_flv.h libswfdec/swfdec_audio.h libswfdec/swfdec_audio_internal.h libswfdec/swfdec_audio_stream.c libswfdec/swfdec_audio_stream.h libswfdec/swfdec_bevel_filter.c libswfdec/swfdec_bitmap_data.c libswfdec/swfdec_bitmap_filter.c libswfdec/swfdec_bits.c libswfdec/swfdec_bits.h libswfdec/swfdec_blur_filter.c libswfdec/swfdec_buffer.c libswfdec/swfdec_buffer.h libswfdec/swfdec_button.c libswfdec/swfdec_button.h libswfdec/swfdec_button_movie_as.c libswfdec/swfdec_button_movie.c libswfdec/swfdec_button_movie.h libswfdec/swfdec_cache.c libswfdec/swfdec_cached.c libswfdec/swfdec_cached.h libswfdec/swfdec_cache.h libswfdec/swfdec_camera.c libswfdec/swfdec_character.c libswfdec/swfdec_character.h libswfdec/swfdec_codec_adpcm.c libswfdec/swfdec_codec_audio.c libswfdec/swfdec_codec_audio.h libswfdec/swfdec_codec_ffmpeg.c libswfdec/swfdec_codec_gst.c libswfdec/swfdec_codec_mad.c libswfdec/swfdec_codec_screen.c libswfdec/swfdec_codec_video.c libswfdec/swfdec_codec_video.h libswfdec/swfdec_codec_vp6_alpha.c libswfdec/swfdec_color_as.c libswfdec/swfdec_color.c libswfdec/swfdec_color.h libswfdec/swfdec_color_matrix_filter.c libswfdec/swfdec_color_transform.c libswfdec/swfdec_convolution_filter.c libswfdec/swfdec_debug.c libswfdec/swfdec_debugger.c libswfdec/swfdec_debugger.h libswfdec/swfdec_debug.h libswfdec/swfdec_decoder.c libswfdec/swfdec_decoder.h libswfdec/swfdec_displacement_map_filter.c libswfdec/swfdec_draw.c libswfdec/swfdec_draw.h libswfdec/swfdec_drop_shadow_filter.c libswfdec/swfdec_event.c libswfdec/swfdec_event.h libswfdec/swfdec_external_interface.c libswfdec/swfdec_file_loader.c libswfdec/swfdec_file_loader.h libswfdec/swfdec_file_reference.c libswfdec/swfdec_file_reference_list.c libswfdec/swfdec_filter_as.c libswfdec/swfdec_filter.c libswfdec/swfdec_filter.h libswfdec/swfdec_flv_decoder.c libswfdec/swfdec_flv_decoder.h libswfdec/swfdec_font.c libswfdec/swfdec_font.h libswfdec/swfdec_function_list.c libswfdec/swfdec_function_list.h libswfdec/swfdec_glow_filter.c libswfdec/swfdec_gradient_filter.c libswfdec/swfdec_gradient_pattern.c libswfdec/swfdec_gradient_pattern.h libswfdec/swfdec_graphic.c libswfdec/swfdec_graphic.h libswfdec/swfdec_graphic_movie.c libswfdec/swfdec_graphic_movie.h libswfdec/swfdec.h libswfdec/swfdec_image.c libswfdec/swfdec_image_decoder.c libswfdec/swfdec_image_decoder.h libswfdec/swfdec_image.h libswfdec/swfdec_initialize.as libswfdec/swfdec_initialize.h libswfdec/swfdec_internal.h libswfdec/swfdec_interval.c libswfdec/swfdec_interval.h libswfdec/swfdec_key_as.c libswfdec/swfdec_keys.h libswfdec/swfdec_loader.c libswfdec/swfdec_loader.h libswfdec/swfdec_loader_internal.h libswfdec/swfdec_load_object_as.c libswfdec/swfdec_load_object.c libswfdec/swfdec_load_object.h libswfdec/swfdec_loadvars_as.c libswfdec/swfdec_local_connection.c libswfdec/swfdec_marshal.list libswfdec/swfdec_microphone.c libswfdec/swfdec_morph_movie.c libswfdec/swfdec_morph_movie.h libswfdec/swfdec_morphshape.c libswfdec/swfdec_morphshape.h libswfdec/swfdec_mouse_as.c libswfdec/swfdec_movie_as_drawing.c libswfdec/swfdec_movie_asprops.c libswfdec/swfdec_movie.c libswfdec/swfdec_movie_clip_loader.c libswfdec/swfdec_movie_clip_loader.h libswfdec/swfdec_movie.h libswfdec/swfdec_net_connection.c libswfdec/swfdec_net_connection.h libswfdec/swfdec_net_stream_as.c libswfdec/swfdec_net_stream.c libswfdec/swfdec_net_stream.h libswfdec/swfdec_path.c libswfdec/swfdec_path.h libswfdec/swfdec_pattern.c libswfdec/swfdec_pattern.h libswfdec/swfdec_player_as.c libswfdec/swfdec_player.c libswfdec/swfdec_player.h libswfdec/swfdec_player_internal.h libswfdec/swfdec_player_scripting.c libswfdec/swfdec_player_scripting.h libswfdec/swfdec_policy_file.c libswfdec/swfdec_policy_file.h libswfdec/swfdec_print_job.c libswfdec/swfdec_rectangle.c libswfdec/swfdec_rectangle.h libswfdec/swfdec_rect.c libswfdec/swfdec_rect.h libswfdec/swfdec_resource.c libswfdec/swfdec_resource.h libswfdec/swfdec_ringbuffer.c libswfdec/swfdec_ringbuffer.h libswfdec/swfdec_sandbox.c libswfdec/swfdec_sandbox.h libswfdec/swfdec_script.c libswfdec/swfdec_script.h libswfdec/swfdec_script_internal.h libswfdec/swfdec_selection.c libswfdec/swfdec_shape.c libswfdec/swfdec_shape.h libswfdec/swfdec_shape_parser.c libswfdec/swfdec_shape_parser.h libswfdec/swfdec_shared_object.c libswfdec/swfdec_socket.c libswfdec/swfdec_socket.h libswfdec/swfdec_sound.c libswfdec/swfdec_sound.h libswfdec/swfdec_sound_object.c libswfdec/swfdec_sound_object.h libswfdec/swfdec_sprite.c libswfdec/swfdec_sprite.h libswfdec/swfdec_sprite_movie_as.c libswfdec/swfdec_sprite_movie.c libswfdec/swfdec_sprite_movie.h libswfdec/swfdec_stage_as.c libswfdec/swfdec_stream.c libswfdec/swfdec_stream.h libswfdec/swfdec_stream_target.c libswfdec/swfdec_stream_target.h libswfdec/swfdec_stroke.c libswfdec/swfdec_stroke.h libswfdec/swfdec_style_sheet.c libswfdec/swfdec_style_sheet.h libswfdec/swfdec_swf_decoder.c libswfdec/swfdec_swf_decoder.h libswfdec/swfdec_system_as.c libswfdec/swfdec_system.c libswfdec/swfdec_system.h libswfdec/swfdec_system_ime.c libswfdec/swfdec_system_security.c libswfdec/swfdec_tag.c libswfdec/swfdec_tag.h libswfdec/swfdec_text.c libswfdec/swfdec_text_field.c libswfdec/swfdec_text_field.h libswfdec/swfdec_text_field_movie_as.c libswfdec/swfdec_text_field_movie.c libswfdec/swfdec_text_field_movie.h libswfdec/swfdec_text_field_movie_html.c libswfdec/swfdec_text_format.c libswfdec/swfdec_text_format.h libswfdec/swfdec_text.h libswfdec/swfdec_text_renderer.c libswfdec/swfdec_text_snapshot.c libswfdec/swfdec_transform.c libswfdec/swfdec_types.h libswfdec/swfdec_url.c libswfdec/swfdec_url.h libswfdec/swfdec_utils.c libswfdec/swfdec_utils.h libswfdec/swfdec_video.c libswfdec/swfdec_video.h libswfdec/swfdec_video_movie_as.c libswfdec/swfdec_video_movie.c libswfdec/swfdec_video_movie.h libswfdec/swfdec_xml.c libswfdec/swfdec_xml.h libswfdec/swfdec_xml_node.c libswfdec/swfdec_xml_node.h libswfdec/swfdec_xml_socket.c libswfdec/swfdec_xml_socket.h Makefile.am player/swfdec_debug_script.h player/swfdec_debug_scripts.c player/swfdec_debug_scripts.h player/swfdec_debug_stack.c player/swfdec_player_manager.c player/swfdec_player_manager.h player/swfplay.c README swfdec/compiler.c swfdec/.gitignore swfdec-gtk/.gitignore swfdec-gtk/Makefile.am swfdec-gtk/swfdec-gtk.h swfdec-gtk/swfdec_gtk_keys.c swfdec-gtk/swfdec_gtk_keys.h swfdec-gtk/swfdec_gtk_loader.c swfdec-gtk/swfdec_gtk_loader.h swfdec-gtk/swfdec_gtk_player.c swfdec-gtk/swfdec_gtk_player.h swfdec-gtk/swfdec_gtk_socket.c swfdec-gtk/swfdec_gtk_socket.h swfdec-gtk/swfdec_gtk_widget.c swfdec-gtk/swfdec_gtk_widget.h swfdec-gtk/swfdec_playback_alsa.c swfdec-gtk/swfdec_playback.h swfdec-gtk/swfdec_playback_none.c swfdec-gtk/swfdec_playback_oss.c swfdec-gtk/swfdec_playback_pa.c swfdec-gtk/swfdec_source.c swfdec-gtk/swfdec_source.h swfdec/jpeg swfdec/Makefile.am swfdec/swfdec_accessibility.c swfdec/swfdec_amf.c swfdec/swfdec_amf.h swfdec/swfdec_as_array.c swfdec/swfdec_as_array.h swfdec/swfdec_as_boolean.c swfdec/swfdec_as_boolean.h swfdec/swfdec_asbroadcaster.c swfdec/swfdec_as_context.c swfdec/swfdec_as_context.h swfdec/swfdec_as_date.c swfdec/swfdec_as_date.h swfdec/swfdec_as_debugger.c swfdec/swfdec_as_debugger.h swfdec/swfdec_as_frame.c swfdec/swfdec_as_frame.h swfdec/swfdec_as_frame_internal.h swfdec/swfdec_as_function.c swfdec/swfdec_as_function.h swfdec/swfdec_as_initialize.as swfdec/swfdec_as_initialize.h swfdec/swfdec_as_internal.h swfdec/swfdec_as_interpret.c swfdec/swfdec_as_interpret.h swfdec/swfdec_as_math.c swfdec/swfdec_as_native_function.c swfdec/swfdec_as_native_function.h swfdec/swfdec_as_number.c swfdec/swfdec_as_number.h swfdec/swfdec_as_object.c swfdec/swfdec_as_object.h swfdec/swfdec_as_script_function.c swfdec/swfdec_as_script_function.h swfdec/swfdec_as_stack.c swfdec/swfdec_as_stack.h swfdec/swfdec_as_string.c swfdec/swfdec_as_string.h swfdec/swfdec_as_strings.c swfdec/swfdec_as_super.c swfdec/swfdec_as_super.h swfdec/swfdec_as_types.c swfdec/swfdec_as_types.h swfdec/swfdec_audio.c swfdec/swfdec_audio_event.c swfdec/swfdec_audio_event.h swfdec/swfdec_audio_flv.c swfdec/swfdec_audio_flv.h swfdec/swfdec_audio.h swfdec/swfdec_audio_internal.h swfdec/swfdec_audio_stream.c swfdec/swfdec_audio_stream.h swfdec/swfdec_bevel_filter.c swfdec/swfdec_bitmap_data.c swfdec/swfdec_bitmap_filter.c swfdec/swfdec_bits.c swfdec/swfdec_bits.h swfdec/swfdec_blur_filter.c swfdec/swfdec_buffer.c swfdec/swfdec_buffer.h swfdec/swfdec_button.c swfdec/swfdec_button.h swfdec/swfdec_button_movie_as.c swfdec/swfdec_button_movie.c swfdec/swfdec_button_movie.h swfdec/swfdec_cache.c swfdec/swfdec_cached.c swfdec/swfdec_cached.h swfdec/swfdec_cache.h swfdec/swfdec_camera.c swfdec/swfdec_character.c swfdec/swfdec_character.h swfdec/swfdec_codec_adpcm.c swfdec/swfdec_codec_audio.c swfdec/swfdec_codec_audio.h swfdec/swfdec_codec_ffmpeg.c swfdec/swfdec_codec_gst.c swfdec/swfdec_codec_mad.c swfdec/swfdec_codec_screen.c swfdec/swfdec_codec_video.c swfdec/swfdec_codec_video.h swfdec/swfdec_codec_vp6_alpha.c swfdec/swfdec_color_as.c swfdec/swfdec_color.c swfdec/swfdec_color.h swfdec/swfdec_color_matrix_filter.c swfdec/swfdec_color_transform.c swfdec/swfdec_convolution_filter.c swfdec/swfdec_debug.c swfdec/swfdec_debugger.c swfdec/swfdec_debugger.h swfdec/swfdec_debug.h swfdec/swfdec_decoder.c swfdec/swfdec_decoder.h swfdec/swfdec_displacement_map_filter.c swfdec/swfdec_draw.c swfdec/swfdec_draw.h swfdec/swfdec_drop_shadow_filter.c swfdec/swfdec_event.c swfdec/swfdec_event.h swfdec/swfdec_external_interface.c swfdec/swfdec_file_loader.c swfdec/swfdec_file_loader.h swfdec/swfdec_file_reference.c swfdec/swfdec_file_reference_list.c swfdec/swfdec_filter_as.c swfdec/swfdec_filter.c swfdec/swfdec_filter.h swfdec/swfdec_flv_decoder.c swfdec/swfdec_flv_decoder.h swfdec/swfdec_font.c swfdec/swfdec_font.h swfdec/swfdec_function_list.c swfdec/swfdec_function_list.h swfdec/swfdec_glow_filter.c swfdec/swfdec_gradient_filter.c swfdec/swfdec_gradient_pattern.c swfdec/swfdec_gradient_pattern.h swfdec/swfdec_graphic.c swfdec/swfdec_graphic.h swfdec/swfdec_graphic_movie.c swfdec/swfdec_graphic_movie.h swfdec/swfdec.h swfdec/swfdec_image.c swfdec/swfdec_image_decoder.c swfdec/swfdec_image_decoder.h swfdec/swfdec_image.h swfdec/swfdec_initialize.as swfdec/swfdec_initialize.h swfdec/swfdec_internal.h swfdec/swfdec_interval.c swfdec/swfdec_interval.h swfdec/swfdec_key_as.c swfdec/swfdec_keys.h swfdec/swfdec_loader.c swfdec/swfdec_loader.h swfdec/swfdec_loader_internal.h swfdec/swfdec_load_object_as.c swfdec/swfdec_load_object.c swfdec/swfdec_load_object.h swfdec/swfdec_loadvars_as.c swfdec/swfdec_local_connection.c swfdec/swfdec_marshal.list swfdec/swfdec_microphone.c swfdec/swfdec_morph_movie.c swfdec/swfdec_morph_movie.h swfdec/swfdec_morphshape.c swfdec/swfdec_morphshape.h swfdec/swfdec_mouse_as.c swfdec/swfdec_movie_as_drawing.c swfdec/swfdec_movie_asprops.c swfdec/swfdec_movie.c swfdec/swfdec_movie_clip_loader.c swfdec/swfdec_movie_clip_loader.h swfdec/swfdec_movie.h swfdec/swfdec_net_connection.c swfdec/swfdec_net_connection.h swfdec/swfdec_net_stream_as.c swfdec/swfdec_net_stream.c swfdec/swfdec_net_stream.h swfdec/swfdec_path.c swfdec/swfdec_path.h swfdec/swfdec_pattern.c swfdec/swfdec_pattern.h swfdec/swfdec_player_as.c swfdec/swfdec_player.c swfdec/swfdec_player.h swfdec/swfdec_player_internal.h swfdec/swfdec_player_scripting.c swfdec/swfdec_player_scripting.h swfdec/swfdec_policy_file.c swfdec/swfdec_policy_file.h swfdec/swfdec_print_job.c swfdec/swfdec_rectangle.c swfdec/swfdec_rectangle.h swfdec/swfdec_rect.c swfdec/swfdec_rect.h swfdec/swfdec_resource.c swfdec/swfdec_resource.h swfdec/swfdec_ringbuffer.c swfdec/swfdec_ringbuffer.h swfdec/swfdec_sandbox.c swfdec/swfdec_sandbox.h swfdec/swfdec_script.c swfdec/swfdec_script.h swfdec/swfdec_script_internal.h swfdec/swfdec_selection.c swfdec/swfdec_shape.c swfdec/swfdec_shape.h swfdec/swfdec_shape_parser.c swfdec/swfdec_shape_parser.h swfdec/swfdec_shared_object.c swfdec/swfdec_socket.c swfdec/swfdec_socket.h swfdec/swfdec_sound.c swfdec/swfdec_sound.h swfdec/swfdec_sound_object.c swfdec/swfdec_sound_object.h swfdec/swfdec_sprite.c swfdec/swfdec_sprite.h swfdec/swfdec_sprite_movie_as.c swfdec/swfdec_sprite_movie.c swfdec/swfdec_sprite_movie.h swfdec/swfdec_stage_as.c swfdec/swfdec_stream.c swfdec/swfdec_stream.h swfdec/swfdec_stream_target.c swfdec/swfdec_stream_target.h swfdec/swfdec_stroke.c swfdec/swfdec_stroke.h swfdec/swfdec_style_sheet.c swfdec/swfdec_style_sheet.h swfdec/swfdec_swf_decoder.c swfdec/swfdec_swf_decoder.h swfdec/swfdec_system_as.c swfdec/swfdec_system.c swfdec/swfdec_system.h swfdec/swfdec_system_ime.c swfdec/swfdec_system_security.c swfdec/swfdec_tag.c swfdec/swfdec_tag.h swfdec/swfdec_text.c swfdec/swfdec_text_field.c swfdec/swfdec_text_field.h swfdec/swfdec_text_field_movie_as.c swfdec/swfdec_text_field_movie.c swfdec/swfdec_text_field_movie.h swfdec/swfdec_text_field_movie_html.c swfdec/swfdec_text_format.c swfdec/swfdec_text_format.h swfdec/swfdec_text.h swfdec/swfdec_text_renderer.c swfdec/swfdec_text_snapshot.c swfdec/swfdec_transform.c swfdec/swfdec_types.h swfdec/swfdec_url.c swfdec/swfdec_url.h swfdec/swfdec_utils.c swfdec/swfdec_utils.h swfdec/swfdec_video.c swfdec/swfdec_video.h swfdec/swfdec_video_movie_as.c swfdec/swfdec_video_movie.c swfdec/swfdec_video_movie.h swfdec/swfdec_xml.c swfdec/swfdec_xml.h swfdec/swfdec_xml_node.c swfdec/swfdec_xml_node.h swfdec/swfdec_xml_socket.c swfdec/swfdec_xml_socket.h test/rtmp test/sound test/swfdec_test.c test/swfdec_test_function.h test/swfdec_test_global.c test/swfdec_test_image.h test/swfdec_test_test.c test/swfdec_test_test.h test/various tools/crashfinder.c tools/dump.c tools/swfdec-extract.c tools/swfdec_out.h tools/swfedit_file.c tools/swfedit_file.h tools/swfedit_tag.c tools/swfedit_tag.h tools/swfedit_token.c tools/swfedit_token.h tools/swfscript.c vivified/core vivified/ui
Benjamin Otte
company at kemper.freedesktop.org
Fri Jan 25 09:37:07 PST 2008
Makefile.am | 4
README | 10
configure.ac | 14
doc/Makefile.am | 16
doc/swfdec.types | 4
libswfdec-gtk/.gitignore | 14
libswfdec-gtk/Makefile.am | 45
libswfdec-gtk/swfdec-gtk.h | 29
libswfdec-gtk/swfdec_gtk_keys.c | 77
libswfdec-gtk/swfdec_gtk_keys.h | 30
libswfdec-gtk/swfdec_gtk_loader.c | 230 --
libswfdec-gtk/swfdec_gtk_loader.h | 44
libswfdec-gtk/swfdec_gtk_player.c | 343 ---
libswfdec-gtk/swfdec_gtk_player.h | 57
libswfdec-gtk/swfdec_gtk_socket.c | 220 -
libswfdec-gtk/swfdec_gtk_socket.h | 42
libswfdec-gtk/swfdec_gtk_widget.c | 683 ------
libswfdec-gtk/swfdec_gtk_widget.h | 69
libswfdec-gtk/swfdec_playback.h | 35
libswfdec-gtk/swfdec_playback_alsa.c | 360 ---
libswfdec-gtk/swfdec_playback_none.c | 38
libswfdec-gtk/swfdec_playback_oss.c | 265 --
libswfdec-gtk/swfdec_playback_pa.c | 350 ---
libswfdec-gtk/swfdec_source.c | 183 -
libswfdec-gtk/swfdec_source.h | 34
libswfdec/.gitignore | 19
libswfdec/Makefile.am | 372 ---
libswfdec/compiler.c | 92
libswfdec/jpeg/.gitignore | 14
libswfdec/jpeg/Makefile.am | 20
libswfdec/jpeg/cogcompat.h | 14
libswfdec/jpeg/jpeg.c | 1126 ---------
libswfdec/jpeg/jpeg.h | 190 -
libswfdec/jpeg/jpeg_bits.c | 154 -
libswfdec/jpeg/jpeg_bits.h | 32
libswfdec/jpeg/jpeg_huffman.c | 168 -
libswfdec/jpeg/jpeg_huffman.h | 37
libswfdec/jpeg/jpeg_markers.h | 44
libswfdec/jpeg/jpeg_rgb_decoder.c | 352 ---
libswfdec/jpeg/jpeg_rgb_decoder.h | 18
libswfdec/jpeg/jpeg_tables.c | 54
libswfdec/swfdec.h | 48
libswfdec/swfdec_accessibility.c | 50
libswfdec/swfdec_amf.c | 225 -
libswfdec/swfdec_amf.h | 59
libswfdec/swfdec_as_array.c | 1399 ------------
libswfdec/swfdec_as_array.h | 84
libswfdec/swfdec_as_boolean.c | 103
libswfdec/swfdec_as_boolean.h | 52
libswfdec/swfdec_as_context.c | 1461 ------------
libswfdec/swfdec_as_context.h | 143 -
libswfdec/swfdec_as_date.c | 1162 ----------
libswfdec/swfdec_as_date.h | 60
libswfdec/swfdec_as_debugger.c | 82
libswfdec/swfdec_as_debugger.h | 80
libswfdec/swfdec_as_frame.c | 895 -------
libswfdec/swfdec_as_frame.h | 63
libswfdec/swfdec_as_frame_internal.h | 106
libswfdec/swfdec_as_function.c | 279 --
libswfdec/swfdec_as_function.h | 61
libswfdec/swfdec_as_initialize.as | 100
libswfdec/swfdec_as_initialize.h | 175 -
libswfdec/swfdec_as_internal.h | 78
libswfdec/swfdec_as_interpret.c | 3268 -----------------------------
libswfdec/swfdec_as_interpret.h | 150 -
libswfdec/swfdec_as_math.c | 149 -
libswfdec/swfdec_as_native_function.c | 395 ---
libswfdec/swfdec_as_native_function.h | 95
libswfdec/swfdec_as_number.c | 121 -
libswfdec/swfdec_as_number.h | 52
libswfdec/swfdec_as_object.c | 1773 ---------------
libswfdec/swfdec_as_object.h | 190 -
libswfdec/swfdec_as_script_function.c | 154 -
libswfdec/swfdec_as_script_function.h | 61
libswfdec/swfdec_as_stack.c | 200 -
libswfdec/swfdec_as_stack.h | 101
libswfdec/swfdec_as_string.c | 914 --------
libswfdec/swfdec_as_string.h | 62
libswfdec/swfdec_as_strings.c | 491 ----
libswfdec/swfdec_as_super.c | 217 -
libswfdec/swfdec_as_super.h | 59
libswfdec/swfdec_as_types.c | 677 ------
libswfdec/swfdec_as_types.h | 139 -
libswfdec/swfdec_asbroadcaster.c | 84
libswfdec/swfdec_audio.c | 346 ---
libswfdec/swfdec_audio.h | 47
libswfdec/swfdec_audio_event.c | 330 --
libswfdec/swfdec_audio_event.h | 74
libswfdec/swfdec_audio_flv.c | 227 --
libswfdec/swfdec_audio_flv.h | 66
libswfdec/swfdec_audio_internal.h | 77
libswfdec/swfdec_audio_stream.c | 205 -
libswfdec/swfdec_audio_stream.h | 65
libswfdec/swfdec_bevel_filter.c | 226 --
libswfdec/swfdec_bitmap_data.c | 306 --
libswfdec/swfdec_bitmap_filter.c | 43
libswfdec/swfdec_bits.c | 760 ------
libswfdec/swfdec_bits.h | 75
libswfdec/swfdec_blur_filter.c | 82
libswfdec/swfdec_buffer.c | 641 -----
libswfdec/swfdec_buffer.h | 85
libswfdec/swfdec_button.c | 302 --
libswfdec/swfdec_button.h | 83
libswfdec/swfdec_button_movie.c | 320 --
libswfdec/swfdec_button_movie.h | 54
libswfdec/swfdec_button_movie_as.c | 108
libswfdec/swfdec_cache.c | 164 -
libswfdec/swfdec_cache.h | 63
libswfdec/swfdec_cached.c | 123 -
libswfdec/swfdec_cached.h | 65
libswfdec/swfdec_camera.c | 89
libswfdec/swfdec_character.c | 42
libswfdec/swfdec_character.h | 62
libswfdec/swfdec_codec_adpcm.c | 186 -
libswfdec/swfdec_codec_audio.c | 284 --
libswfdec/swfdec_codec_audio.h | 57
libswfdec/swfdec_codec_ffmpeg.c | 317 --
libswfdec/swfdec_codec_gst.c | 615 -----
libswfdec/swfdec_codec_mad.c | 235 --
libswfdec/swfdec_codec_screen.c | 134 -
libswfdec/swfdec_codec_video.c | 320 --
libswfdec/swfdec_codec_video.h | 75
libswfdec/swfdec_codec_vp6_alpha.c | 111
libswfdec/swfdec_color.c | 299 --
libswfdec/swfdec_color.h | 75
libswfdec/swfdec_color_as.c | 181 -
libswfdec/swfdec_color_matrix_filter.c | 53
libswfdec/swfdec_color_transform.c | 206 -
libswfdec/swfdec_convolution_filter.c | 197 -
libswfdec/swfdec_debug.c | 78
libswfdec/swfdec_debug.h | 65
libswfdec/swfdec_debugger.c | 617 -----
libswfdec/swfdec_debugger.h | 108
libswfdec/swfdec_decoder.c | 103
libswfdec/swfdec_decoder.h | 92
libswfdec/swfdec_displacement_map_filter.c | 197 -
libswfdec/swfdec_draw.c | 190 -
libswfdec/swfdec_draw.h | 85
libswfdec/swfdec_drop_shadow_filter.c | 233 --
libswfdec/swfdec_event.c | 231 --
libswfdec/swfdec_event.h | 77
libswfdec/swfdec_external_interface.c | 228 --
libswfdec/swfdec_file_loader.c | 137 -
libswfdec/swfdec_file_loader.h | 53
libswfdec/swfdec_file_reference.c | 139 -
libswfdec/swfdec_file_reference_list.c | 33
libswfdec/swfdec_filter.c | 124 -
libswfdec/swfdec_filter.h | 60
libswfdec/swfdec_filter_as.c | 47
libswfdec/swfdec_flv_decoder.c | 595 -----
libswfdec/swfdec_flv_decoder.h | 83
libswfdec/swfdec_font.c | 457 ----
libswfdec/swfdec_font.h | 89
libswfdec/swfdec_function_list.c | 132 -
libswfdec/swfdec_function_list.h | 50
libswfdec/swfdec_glow_filter.c | 162 -
libswfdec/swfdec_gradient_filter.c | 243 --
libswfdec/swfdec_gradient_pattern.c | 129 -
libswfdec/swfdec_gradient_pattern.h | 67
libswfdec/swfdec_graphic.c | 71
libswfdec/swfdec_graphic.h | 78
libswfdec/swfdec_graphic_movie.c | 113 -
libswfdec/swfdec_graphic_movie.h | 51
libswfdec/swfdec_image.c | 710 ------
libswfdec/swfdec_image.h | 84
libswfdec/swfdec_image_decoder.c | 131 -
libswfdec/swfdec_image_decoder.h | 59
libswfdec/swfdec_initialize.as | 1521 -------------
libswfdec/swfdec_initialize.h | 2196 -------------------
libswfdec/swfdec_internal.h | 68
libswfdec/swfdec_interval.c | 193 -
libswfdec/swfdec_interval.h | 80
libswfdec/swfdec_key_as.c | 83
libswfdec/swfdec_keys.h | 126 -
libswfdec/swfdec_load_object.c | 253 --
libswfdec/swfdec_load_object.h | 76
libswfdec/swfdec_load_object_as.c | 141 -
libswfdec/swfdec_loader.c | 506 ----
libswfdec/swfdec_loader.h | 97
libswfdec/swfdec_loader_internal.h | 51
libswfdec/swfdec_loadvars_as.c | 46
libswfdec/swfdec_local_connection.c | 57
libswfdec/swfdec_marshal.list | 6
libswfdec/swfdec_microphone.c | 74
libswfdec/swfdec_morph_movie.c | 133 -
libswfdec/swfdec_morph_movie.h | 54
libswfdec/swfdec_morphshape.c | 96
libswfdec/swfdec_morphshape.h | 53
libswfdec/swfdec_mouse_as.c | 51
libswfdec/swfdec_movie.c | 1815 ----------------
libswfdec/swfdec_movie.h | 306 --
libswfdec/swfdec_movie_as_drawing.c | 456 ----
libswfdec/swfdec_movie_asprops.c | 484 ----
libswfdec/swfdec_movie_clip_loader.c | 127 -
libswfdec/swfdec_movie_clip_loader.h | 51
libswfdec/swfdec_net_connection.c | 186 -
libswfdec/swfdec_net_connection.h | 57
libswfdec/swfdec_net_stream.c | 644 -----
libswfdec/swfdec_net_stream.h | 98
libswfdec/swfdec_net_stream_as.c | 187 -
libswfdec/swfdec_path.c | 273 --
libswfdec/swfdec_path.h | 67
libswfdec/swfdec_pattern.c | 559 ----
libswfdec/swfdec_pattern.h | 75
libswfdec/swfdec_player.c | 2873 -------------------------
libswfdec/swfdec_player.h | 173 -
libswfdec/swfdec_player_as.c | 367 ---
libswfdec/swfdec_player_internal.h | 252 --
libswfdec/swfdec_player_scripting.c | 39
libswfdec/swfdec_player_scripting.h | 62
libswfdec/swfdec_policy_file.c | 350 ---
libswfdec/swfdec_policy_file.h | 65
libswfdec/swfdec_print_job.c | 130 -
libswfdec/swfdec_rect.c | 223 -
libswfdec/swfdec_rect.h | 51
libswfdec/swfdec_rectangle.c | 203 -
libswfdec/swfdec_rectangle.h | 55
libswfdec/swfdec_resource.c | 684 ------
libswfdec/swfdec_resource.h | 98
libswfdec/swfdec_ringbuffer.c | 125 -
libswfdec/swfdec_ringbuffer.h | 59
libswfdec/swfdec_sandbox.c | 303 --
libswfdec/swfdec_sandbox.h | 83
libswfdec/swfdec_script.c | 316 --
libswfdec/swfdec_script.h | 38
libswfdec/swfdec_script_internal.h | 95
libswfdec/swfdec_selection.c | 75
libswfdec/swfdec_shape.c | 387 ---
libswfdec/swfdec_shape.h | 63
libswfdec/swfdec_shape_parser.c | 675 -----
libswfdec/swfdec_shape_parser.h | 48
libswfdec/swfdec_shared_object.c | 82
libswfdec/swfdec_socket.c | 99
libswfdec/swfdec_socket.h | 58
libswfdec/swfdec_sound.c | 558 ----
libswfdec/swfdec_sound.h | 107
libswfdec/swfdec_sound_object.c | 340 ---
libswfdec/swfdec_sound_object.h | 54
libswfdec/swfdec_sprite.c | 217 -
libswfdec/swfdec_sprite.h | 100
libswfdec/swfdec_sprite_movie.c | 883 -------
libswfdec/swfdec_sprite_movie.h | 76
libswfdec/swfdec_sprite_movie_as.c | 891 -------
libswfdec/swfdec_stage_as.c | 246 --
libswfdec/swfdec_stream.c | 399 ---
libswfdec/swfdec_stream.h | 68
libswfdec/swfdec_stream_target.c | 136 -
libswfdec/swfdec_stream_target.h | 67
libswfdec/swfdec_stroke.c | 361 ---
libswfdec/swfdec_stroke.h | 76
libswfdec/swfdec_style_sheet.c | 366 ---
libswfdec/swfdec_style_sheet.h | 57
libswfdec/swfdec_swf_decoder.c | 487 ----
libswfdec/swfdec_swf_decoder.h | 98
libswfdec/swfdec_system.c | 315 --
libswfdec/swfdec_system.h | 76
libswfdec/swfdec_system_as.c | 347 ---
libswfdec/swfdec_system_ime.c | 79
libswfdec/swfdec_system_security.c | 123 -
libswfdec/swfdec_tag.c | 628 -----
libswfdec/swfdec_tag.h | 121 -
libswfdec/swfdec_text.c | 133 -
libswfdec/swfdec_text.h | 67
libswfdec/swfdec_text_field.c | 198 -
libswfdec/swfdec_text_field.h | 93
libswfdec/swfdec_text_field_movie.c | 1627 --------------
libswfdec/swfdec_text_field_movie.h | 160 -
libswfdec/swfdec_text_field_movie_as.c | 1539 -------------
libswfdec/swfdec_text_field_movie_html.c | 777 ------
libswfdec/swfdec_text_format.c | 1274 -----------
libswfdec/swfdec_text_format.h | 101
libswfdec/swfdec_text_renderer.c | 94
libswfdec/swfdec_text_snapshot.c | 109
libswfdec/swfdec_transform.c | 121 -
libswfdec/swfdec_types.h | 63
libswfdec/swfdec_url.c | 553 ----
libswfdec/swfdec_url.h | 65
libswfdec/swfdec_utils.c | 74
libswfdec/swfdec_utils.h | 40
libswfdec/swfdec_video.c | 302 --
libswfdec/swfdec_video.h | 61
libswfdec/swfdec_video_movie.c | 197 -
libswfdec/swfdec_video_movie.h | 77
libswfdec/swfdec_video_movie_as.c | 94
libswfdec/swfdec_xml.c | 940 --------
libswfdec/swfdec_xml.h | 90
libswfdec/swfdec_xml_node.c | 1113 ---------
libswfdec/swfdec_xml_node.h | 103
libswfdec/swfdec_xml_socket.c | 245 --
libswfdec/swfdec_xml_socket.h | 56
player/swfdec_debug_script.h | 2
player/swfdec_debug_scripts.c | 2
player/swfdec_debug_scripts.h | 2
player/swfdec_debug_stack.c | 2
player/swfdec_player_manager.c | 8
player/swfdec_player_manager.h | 4
player/swfplay.c | 52
swfdec-gtk/.gitignore | 14
swfdec-gtk/Makefile.am | 45
swfdec-gtk/swfdec-gtk.h | 29
swfdec-gtk/swfdec_gtk_keys.c | 77
swfdec-gtk/swfdec_gtk_keys.h | 30
swfdec-gtk/swfdec_gtk_loader.c | 215 +
swfdec-gtk/swfdec_gtk_loader.h | 42
swfdec-gtk/swfdec_gtk_player.c | 318 ++
swfdec-gtk/swfdec_gtk_player.h | 69
swfdec-gtk/swfdec_gtk_socket.c | 224 +
swfdec-gtk/swfdec_gtk_socket.h | 42
swfdec-gtk/swfdec_gtk_widget.c | 683 ++++++
swfdec-gtk/swfdec_gtk_widget.h | 69
swfdec-gtk/swfdec_playback.h | 35
swfdec-gtk/swfdec_playback_alsa.c | 360 +++
swfdec-gtk/swfdec_playback_none.c | 38
swfdec-gtk/swfdec_playback_oss.c | 265 ++
swfdec-gtk/swfdec_playback_pa.c | 350 +++
swfdec-gtk/swfdec_source.c | 183 +
swfdec-gtk/swfdec_source.h | 34
swfdec/.gitignore | 19
swfdec/Makefile.am | 373 +++
swfdec/compiler.c | 92
swfdec/jpeg/.gitignore | 14
swfdec/jpeg/Makefile.am | 20
swfdec/jpeg/cogcompat.h | 14
swfdec/jpeg/jpeg.c | 1126 +++++++++
swfdec/jpeg/jpeg.h | 190 +
swfdec/jpeg/jpeg_bits.c | 154 +
swfdec/jpeg/jpeg_bits.h | 32
swfdec/jpeg/jpeg_huffman.c | 168 +
swfdec/jpeg/jpeg_huffman.h | 37
swfdec/jpeg/jpeg_markers.h | 44
swfdec/jpeg/jpeg_rgb_decoder.c | 352 +++
swfdec/jpeg/jpeg_rgb_decoder.h | 18
swfdec/jpeg/jpeg_tables.c | 54
swfdec/swfdec.h | 48
swfdec/swfdec_accessibility.c | 50
swfdec/swfdec_amf.c | 225 +
swfdec/swfdec_amf.h | 59
swfdec/swfdec_as_array.c | 1399 ++++++++++++
swfdec/swfdec_as_array.h | 84
swfdec/swfdec_as_boolean.c | 103
swfdec/swfdec_as_boolean.h | 52
swfdec/swfdec_as_context.c | 1461 ++++++++++++
swfdec/swfdec_as_context.h | 143 +
swfdec/swfdec_as_date.c | 1162 ++++++++++
swfdec/swfdec_as_date.h | 60
swfdec/swfdec_as_debugger.c | 82
swfdec/swfdec_as_debugger.h | 80
swfdec/swfdec_as_frame.c | 895 +++++++
swfdec/swfdec_as_frame.h | 63
swfdec/swfdec_as_frame_internal.h | 106
swfdec/swfdec_as_function.c | 279 ++
swfdec/swfdec_as_function.h | 61
swfdec/swfdec_as_initialize.as | 100
swfdec/swfdec_as_initialize.h | 175 +
swfdec/swfdec_as_internal.h | 78
swfdec/swfdec_as_interpret.c | 3268 +++++++++++++++++++++++++++++
swfdec/swfdec_as_interpret.h | 150 +
swfdec/swfdec_as_math.c | 149 +
swfdec/swfdec_as_native_function.c | 395 +++
swfdec/swfdec_as_native_function.h | 95
swfdec/swfdec_as_number.c | 121 +
swfdec/swfdec_as_number.h | 52
swfdec/swfdec_as_object.c | 1773 +++++++++++++++
swfdec/swfdec_as_object.h | 190 +
swfdec/swfdec_as_script_function.c | 154 +
swfdec/swfdec_as_script_function.h | 61
swfdec/swfdec_as_stack.c | 200 +
swfdec/swfdec_as_stack.h | 101
swfdec/swfdec_as_string.c | 914 ++++++++
swfdec/swfdec_as_string.h | 62
swfdec/swfdec_as_strings.c | 491 ++++
swfdec/swfdec_as_super.c | 217 +
swfdec/swfdec_as_super.h | 59
swfdec/swfdec_as_types.c | 677 ++++++
swfdec/swfdec_as_types.h | 139 +
swfdec/swfdec_asbroadcaster.c | 84
swfdec/swfdec_audio.c | 346 +++
swfdec/swfdec_audio.h | 47
swfdec/swfdec_audio_event.c | 330 ++
swfdec/swfdec_audio_event.h | 74
swfdec/swfdec_audio_flv.c | 227 ++
swfdec/swfdec_audio_flv.h | 66
swfdec/swfdec_audio_internal.h | 77
swfdec/swfdec_audio_stream.c | 205 +
swfdec/swfdec_audio_stream.h | 65
swfdec/swfdec_bevel_filter.c | 226 ++
swfdec/swfdec_bitmap_data.c | 306 ++
swfdec/swfdec_bitmap_filter.c | 43
swfdec/swfdec_bits.c | 760 ++++++
swfdec/swfdec_bits.h | 75
swfdec/swfdec_blur_filter.c | 82
swfdec/swfdec_buffer.c | 641 +++++
swfdec/swfdec_buffer.h | 85
swfdec/swfdec_button.c | 302 ++
swfdec/swfdec_button.h | 83
swfdec/swfdec_button_movie.c | 320 ++
swfdec/swfdec_button_movie.h | 54
swfdec/swfdec_button_movie_as.c | 108
swfdec/swfdec_cache.c | 164 +
swfdec/swfdec_cache.h | 63
swfdec/swfdec_cached.c | 123 +
swfdec/swfdec_cached.h | 65
swfdec/swfdec_camera.c | 89
swfdec/swfdec_character.c | 42
swfdec/swfdec_character.h | 62
swfdec/swfdec_codec_adpcm.c | 186 +
swfdec/swfdec_codec_audio.c | 284 ++
swfdec/swfdec_codec_audio.h | 57
swfdec/swfdec_codec_ffmpeg.c | 317 ++
swfdec/swfdec_codec_gst.c | 615 +++++
swfdec/swfdec_codec_mad.c | 235 ++
swfdec/swfdec_codec_screen.c | 134 +
swfdec/swfdec_codec_video.c | 320 ++
swfdec/swfdec_codec_video.h | 75
swfdec/swfdec_codec_vp6_alpha.c | 111
swfdec/swfdec_color.c | 299 ++
swfdec/swfdec_color.h | 75
swfdec/swfdec_color_as.c | 181 +
swfdec/swfdec_color_matrix_filter.c | 53
swfdec/swfdec_color_transform.c | 206 +
swfdec/swfdec_convolution_filter.c | 197 +
swfdec/swfdec_debug.c | 78
swfdec/swfdec_debug.h | 65
swfdec/swfdec_debugger.c | 617 +++++
swfdec/swfdec_debugger.h | 108
swfdec/swfdec_decoder.c | 103
swfdec/swfdec_decoder.h | 93
swfdec/swfdec_displacement_map_filter.c | 197 +
swfdec/swfdec_draw.c | 190 +
swfdec/swfdec_draw.h | 85
swfdec/swfdec_drop_shadow_filter.c | 233 ++
swfdec/swfdec_event.c | 231 ++
swfdec/swfdec_event.h | 77
swfdec/swfdec_external_interface.c | 228 ++
swfdec/swfdec_file_loader.c | 98
swfdec/swfdec_file_loader.h | 52
swfdec/swfdec_file_reference.c | 139 +
swfdec/swfdec_file_reference_list.c | 33
swfdec/swfdec_filter.c | 124 +
swfdec/swfdec_filter.h | 60
swfdec/swfdec_filter_as.c | 47
swfdec/swfdec_flv_decoder.c | 595 +++++
swfdec/swfdec_flv_decoder.h | 83
swfdec/swfdec_font.c | 457 ++++
swfdec/swfdec_font.h | 89
swfdec/swfdec_function_list.c | 132 +
swfdec/swfdec_function_list.h | 50
swfdec/swfdec_glow_filter.c | 162 +
swfdec/swfdec_gradient_filter.c | 243 ++
swfdec/swfdec_gradient_pattern.c | 129 +
swfdec/swfdec_gradient_pattern.h | 67
swfdec/swfdec_graphic.c | 71
swfdec/swfdec_graphic.h | 78
swfdec/swfdec_graphic_movie.c | 113 +
swfdec/swfdec_graphic_movie.h | 51
swfdec/swfdec_image.c | 710 ++++++
swfdec/swfdec_image.h | 84
swfdec/swfdec_image_decoder.c | 131 +
swfdec/swfdec_image_decoder.h | 59
swfdec/swfdec_initialize.as | 1521 +++++++++++++
swfdec/swfdec_initialize.h | 2196 +++++++++++++++++++
swfdec/swfdec_internal.h | 68
swfdec/swfdec_interval.c | 193 +
swfdec/swfdec_interval.h | 80
swfdec/swfdec_key_as.c | 83
swfdec/swfdec_keys.h | 126 +
swfdec/swfdec_load_object.c | 259 ++
swfdec/swfdec_load_object.h | 76
swfdec/swfdec_load_object_as.c | 141 +
swfdec/swfdec_loader.c | 443 +++
swfdec/swfdec_loader.h | 97
swfdec/swfdec_loader_internal.h | 47
swfdec/swfdec_loadvars_as.c | 46
swfdec/swfdec_local_connection.c | 57
swfdec/swfdec_marshal.list | 6
swfdec/swfdec_microphone.c | 74
swfdec/swfdec_morph_movie.c | 133 +
swfdec/swfdec_morph_movie.h | 54
swfdec/swfdec_morphshape.c | 96
swfdec/swfdec_morphshape.h | 53
swfdec/swfdec_mouse_as.c | 51
swfdec/swfdec_movie.c | 1820 ++++++++++++++++
swfdec/swfdec_movie.h | 306 ++
swfdec/swfdec_movie_as_drawing.c | 456 ++++
swfdec/swfdec_movie_asprops.c | 484 ++++
swfdec/swfdec_movie_clip_loader.c | 127 +
swfdec/swfdec_movie_clip_loader.h | 51
swfdec/swfdec_net_connection.c | 186 +
swfdec/swfdec_net_connection.h | 57
swfdec/swfdec_net_stream.c | 662 +++++
swfdec/swfdec_net_stream.h | 99
swfdec/swfdec_net_stream_as.c | 187 +
swfdec/swfdec_path.c | 273 ++
swfdec/swfdec_path.h | 67
swfdec/swfdec_pattern.c | 559 ++++
swfdec/swfdec_pattern.h | 75
swfdec/swfdec_player.c | 3033 ++++++++++++++++++++++++++
swfdec/swfdec_player.h | 177 +
swfdec/swfdec_player_as.c | 367 +++
swfdec/swfdec_player_internal.h | 263 ++
swfdec/swfdec_player_scripting.c | 39
swfdec/swfdec_player_scripting.h | 62
swfdec/swfdec_policy_file.c | 350 +++
swfdec/swfdec_policy_file.h | 65
swfdec/swfdec_print_job.c | 130 +
swfdec/swfdec_rect.c | 223 +
swfdec/swfdec_rect.h | 51
swfdec/swfdec_rectangle.c | 203 +
swfdec/swfdec_rectangle.h | 55
swfdec/swfdec_resource.c | 691 ++++++
swfdec/swfdec_resource.h | 98
swfdec/swfdec_ringbuffer.c | 125 +
swfdec/swfdec_ringbuffer.h | 59
swfdec/swfdec_sandbox.c | 303 ++
swfdec/swfdec_sandbox.h | 83
swfdec/swfdec_script.c | 316 ++
swfdec/swfdec_script.h | 38
swfdec/swfdec_script_internal.h | 95
swfdec/swfdec_selection.c | 75
swfdec/swfdec_shape.c | 387 +++
swfdec/swfdec_shape.h | 63
swfdec/swfdec_shape_parser.c | 675 +++++
swfdec/swfdec_shape_parser.h | 48
swfdec/swfdec_shared_object.c | 82
swfdec/swfdec_socket.c | 98
swfdec/swfdec_socket.h | 61
swfdec/swfdec_sound.c | 558 ++++
swfdec/swfdec_sound.h | 107
swfdec/swfdec_sound_object.c | 340 +++
swfdec/swfdec_sound_object.h | 54
swfdec/swfdec_sprite.c | 217 +
swfdec/swfdec_sprite.h | 100
swfdec/swfdec_sprite_movie.c | 883 +++++++
swfdec/swfdec_sprite_movie.h | 76
swfdec/swfdec_sprite_movie_as.c | 891 +++++++
swfdec/swfdec_stage_as.c | 246 ++
swfdec/swfdec_stream.c | 427 +++
swfdec/swfdec_stream.h | 71
swfdec/swfdec_stream_target.c | 136 +
swfdec/swfdec_stream_target.h | 67
swfdec/swfdec_stroke.c | 361 +++
swfdec/swfdec_stroke.h | 76
swfdec/swfdec_style_sheet.c | 366 +++
swfdec/swfdec_style_sheet.h | 57
swfdec/swfdec_swf_decoder.c | 487 ++++
swfdec/swfdec_swf_decoder.h | 98
swfdec/swfdec_system.c | 315 ++
swfdec/swfdec_system.h | 76
swfdec/swfdec_system_as.c | 347 +++
swfdec/swfdec_system_ime.c | 79
swfdec/swfdec_system_security.c | 123 +
swfdec/swfdec_tag.c | 628 +++++
swfdec/swfdec_tag.h | 121 +
swfdec/swfdec_text.c | 133 +
swfdec/swfdec_text.h | 67
swfdec/swfdec_text_field.c | 198 +
swfdec/swfdec_text_field.h | 93
swfdec/swfdec_text_field_movie.c | 1627 ++++++++++++++
swfdec/swfdec_text_field_movie.h | 160 +
swfdec/swfdec_text_field_movie_as.c | 1539 +++++++++++++
swfdec/swfdec_text_field_movie_html.c | 777 ++++++
swfdec/swfdec_text_format.c | 1274 +++++++++++
swfdec/swfdec_text_format.h | 101
swfdec/swfdec_text_renderer.c | 94
swfdec/swfdec_text_snapshot.c | 109
swfdec/swfdec_transform.c | 121 +
swfdec/swfdec_types.h | 63
swfdec/swfdec_url.c | 709 ++++++
swfdec/swfdec_url.h | 69
swfdec/swfdec_utils.c | 74
swfdec/swfdec_utils.h | 40
swfdec/swfdec_video.c | 302 ++
swfdec/swfdec_video.h | 61
swfdec/swfdec_video_movie.c | 197 +
swfdec/swfdec_video_movie.h | 77
swfdec/swfdec_video_movie_as.c | 94
swfdec/swfdec_xml.c | 940 ++++++++
swfdec/swfdec_xml.h | 90
swfdec/swfdec_xml_node.c | 1113 +++++++++
swfdec/swfdec_xml_node.h | 103
swfdec/swfdec_xml_socket.c | 245 ++
swfdec/swfdec_xml_socket.h | 56
test/rtmp/rtmp_server.c | 2
test/sound/sound.c | 21
test/swfdec_test.c | 6
test/swfdec_test_function.h | 2
test/swfdec_test_global.c | 2
test/swfdec_test_image.h | 2
test/swfdec_test_test.c | 7
test/swfdec_test_test.h | 2
test/various/gc.c | 12
test/various/ringbuffer.c | 2
tools/crashfinder.c | 20
tools/dump.c | 34
tools/swfdec-extract.c | 28
tools/swfdec_out.h | 6
tools/swfedit_file.c | 8
tools/swfedit_file.h | 2
tools/swfedit_tag.c | 8
tools/swfedit_tag.h | 4
tools/swfedit_token.c | 6
tools/swfedit_token.h | 2
tools/swfscript.c | 2
vivified/core/vivi_application.c | 10
vivified/core/vivi_application.h | 2
vivified/core/vivi_breakpoint.h | 2
vivified/core/vivi_debugger.c | 2
vivified/core/vivi_debugger.h | 2
vivified/core/vivi_function.h | 2
vivified/core/vivi_ming.h | 2
vivified/core/vivi_player_as.c | 2
vivified/core/vivi_wrap.h | 2
vivified/ui/main.c | 2
vivified/ui/vivi_movie_list.c | 4
vivified/ui/vivi_movies.c | 2
vivified/ui/vivi_player.c | 2
vivified/ui/vivi_widget.h | 2
vivified/ui/vivi_window.h | 2
618 files changed, 74195 insertions(+), 73949 deletions(-)
New commits:
commit 222cb3e42603590d7ca94d6d81aad941cc511c38
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Jan 25 16:53:05 2008 +0100
set varaible before using it
diff --git a/swfdec/swfdec_player.c b/swfdec/swfdec_player.c
index e9e50bc..419a6b8 100644
--- a/swfdec/swfdec_player.c
+++ b/swfdec/swfdec_player.c
@@ -3025,6 +3025,7 @@ swfdec_player_set_variables (SwfdecPlayer *player, const char *variables)
g_return_if_fail (SWFDEC_IS_PLAYER (player));
g_return_if_fail (player->priv->url == NULL);
+ priv = player->priv;
g_free (priv->variables);
priv->variables = g_strdup (variables);
g_object_notify (G_OBJECT (player), "variables");
commit e142c2e56c24ab42a91f9519fd9a8dbfd8cf043e
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Jan 25 14:00:36 2008 +0100
skip events for uninitialized movies
diff --git a/swfdec/swfdec_movie.c b/swfdec/swfdec_movie.c
index 278a067..10662c5 100644
--- a/swfdec/swfdec_movie.c
+++ b/swfdec/swfdec_movie.c
@@ -526,6 +526,11 @@ swfdec_movie_queue_script (SwfdecMovie *movie, SwfdecEventType condition)
if (!SWFDEC_IS_SPRITE_MOVIE (movie) && !SWFDEC_IS_BUTTON_MOVIE (movie))
return;
+ /* can happen for mouse/keyboard events on the initial movie */
+ if (movie->resource->sandbox == NULL) {
+ SWFDEC_INFO ("movie %s not yet initialized, skipping event", movie->name);
+ return;
+ }
switch (condition) {
case SWFDEC_EVENT_INITIALIZE:
commit c3f1a527ce2f222d140bc77554ecec42232010ad
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Jan 25 13:57:25 2008 +0100
use the right private object
Oops, stupid copy/paste errors
diff --git a/swfdec-gtk/swfdec_gtk_player.c b/swfdec-gtk/swfdec_gtk_player.c
index f8f9d5c..42fc01b 100644
--- a/swfdec-gtk/swfdec_gtk_player.c
+++ b/swfdec-gtk/swfdec_gtk_player.c
@@ -149,7 +149,7 @@ swfdec_gtk_player_init (SwfdecGtkPlayer * player)
{
SwfdecGtkPlayerPrivate *priv;
- player->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (player, SWFDEC_TYPE_PLAYER, SwfdecGtkPlayerPrivate);
+ player->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (player, SWFDEC_TYPE_GTK_PLAYER, SwfdecGtkPlayerPrivate);
priv->speed = 1.0;
priv->audio_enabled = TRUE;
commit 5d70b97559f75125f9a310b41360ff350140b5f8
Author: Benjamin Otte <otte at gnome.org>
Date: Fri Jan 25 10:57:46 2008 +0100
initialize url and base-url properties before requesting the first loader
This allows the loader to access these values
diff --git a/swfdec/swfdec_player.c b/swfdec/swfdec_player.c
index 2795d82..e9e50bc 100644
--- a/swfdec/swfdec_player.c
+++ b/swfdec/swfdec_player.c
@@ -2971,13 +2971,15 @@ swfdec_player_set_url (SwfdecPlayer *player, const SwfdecURL *url)
g_object_freeze_notify (G_OBJECT (player));
priv = player->priv;
priv->url = swfdec_url_copy (url);
- loader = swfdec_player_load (player, swfdec_url_get_url (url),
- SWFDEC_LOADER_REQUEST_DEFAULT, NULL);
- priv->resource = swfdec_resource_new (player, loader, priv->variables);
if (priv->base_url == NULL) {
- priv->base_url = swfdec_url_new_parent (swfdec_loader_get_url (loader));
+ priv->base_url = swfdec_url_new_parent (url);
g_object_notify (G_OBJECT (player), "base-url");
}
+ /* we initialize url and base_url before requesting the loader, so the loader
+ * can query them */
+ loader = swfdec_player_load (player, swfdec_url_get_url (url),
+ SWFDEC_LOADER_REQUEST_DEFAULT, NULL);
+ priv->resource = swfdec_resource_new (player, loader, priv->variables);
movie = swfdec_movie_new (player, -16384, NULL, priv->resource, NULL, SWFDEC_AS_STR__level0);
movie->name = SWFDEC_AS_STR_EMPTY;
g_object_unref (loader);
commit 66074294ab0f9d0f4908223ecfaa41f2a3bd6c3d
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jan 24 20:54:58 2008 +0100
make SwfdecGtkPlayer subclassable
diff --git a/swfdec-gtk/swfdec_gtk_player.c b/swfdec-gtk/swfdec_gtk_player.c
index 71ff829..f8f9d5c 100644
--- a/swfdec-gtk/swfdec_gtk_player.c
+++ b/swfdec-gtk/swfdec_gtk_player.c
@@ -27,21 +27,14 @@
#include "swfdec-gtk/swfdec_playback.h"
#include "swfdec-gtk/swfdec_source.h"
-struct _SwfdecGtkPlayer
+struct _SwfdecGtkPlayerPrivate
{
- SwfdecPlayer player;
-
GSource * source; /* source if playing, NULL otherwise */
SwfdecPlayback * playback; /* audio playback object */
gboolean audio_enabled; /* TRUE if audio should be played */
double speed; /* desired playback speed */
};
-struct _SwfdecGtkPlayerClass
-{
- SwfdecPlayerClass player_class;
-};
-
enum {
PROP_0,
PROP_PLAYING,
@@ -78,17 +71,17 @@ static void
swfdec_gtk_player_get_property (GObject *object, guint param_id, GValue *value,
GParamSpec * pspec)
{
- SwfdecGtkPlayer *player = SWFDEC_GTK_PLAYER (object);
+ SwfdecGtkPlayerPrivate *priv = SWFDEC_GTK_PLAYER (object)->priv;
switch (param_id) {
case PROP_PLAYING:
- g_value_set_boolean (value, player->source != NULL);
+ g_value_set_boolean (value, priv->source != NULL);
break;
case PROP_AUDIO:
- g_value_set_boolean (value, player->audio_enabled);
+ g_value_set_boolean (value, priv->audio_enabled);
break;
case PROP_SPEED:
- g_value_set_double (value, player->speed);
+ g_value_set_double (value, priv->speed);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -124,7 +117,7 @@ swfdec_gtk_player_dispose (GObject *object)
SwfdecGtkPlayer *player = SWFDEC_GTK_PLAYER (object);
swfdec_gtk_player_set_playing (player, FALSE);
- g_assert (player->playback == NULL);
+ g_assert (player->priv->playback == NULL);
G_OBJECT_CLASS (swfdec_gtk_player_parent_class)->dispose (object);
}
@@ -134,6 +127,8 @@ swfdec_gtk_player_class_init (SwfdecGtkPlayerClass * g_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+ g_type_class_add_private (g_class, sizeof (SwfdecGtkPlayerPrivate));
+
object_class->dispose = swfdec_gtk_player_dispose;
object_class->get_property = swfdec_gtk_player_get_property;
object_class->set_property = swfdec_gtk_player_set_property;
@@ -152,8 +147,12 @@ swfdec_gtk_player_class_init (SwfdecGtkPlayerClass * g_class)
static void
swfdec_gtk_player_init (SwfdecGtkPlayer * player)
{
- player->speed = 1.0;
- player->audio_enabled = TRUE;
+ SwfdecGtkPlayerPrivate *priv;
+
+ player->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (player, SWFDEC_TYPE_PLAYER, SwfdecGtkPlayerPrivate);
+
+ priv->speed = 1.0;
+ priv->audio_enabled = TRUE;
}
/*** PUBLIC API ***/
@@ -183,17 +182,18 @@ swfdec_gtk_player_new (SwfdecAsDebugger *debugger)
static void
swfdec_gtk_player_update_audio (SwfdecGtkPlayer *player)
{
- gboolean should_play = player->audio_enabled;
+ SwfdecGtkPlayerPrivate *priv = player->priv;
+ gboolean should_play = priv->audio_enabled;
- should_play &= (player->source != NULL);
- should_play &= (player->speed == 1.0);
+ should_play &= (priv->source != NULL);
+ should_play &= (priv->speed == 1.0);
- if (should_play && player->playback == NULL) {
- player->playback = swfdec_playback_open (SWFDEC_PLAYER (player),
+ if (should_play && priv->playback == NULL) {
+ priv->playback = swfdec_playback_open (SWFDEC_PLAYER (player),
g_main_context_default ());
- } else if (!should_play && player->playback != NULL) {
- swfdec_playback_close (player->playback);
- player->playback = NULL;
+ } else if (!should_play && priv->playback != NULL) {
+ swfdec_playback_close (priv->playback);
+ priv->playback = NULL;
}
}
@@ -209,15 +209,18 @@ swfdec_gtk_player_update_audio (SwfdecGtkPlayer *player)
void
swfdec_gtk_player_set_playing (SwfdecGtkPlayer *player, gboolean playing)
{
+ SwfdecGtkPlayerPrivate *priv;
+
g_return_if_fail (SWFDEC_IS_GTK_PLAYER (player));
- if (playing && player->source == NULL) {
- player->source = swfdec_iterate_source_new (SWFDEC_PLAYER (player), player->speed);
- g_source_attach (player->source, NULL);
- } else if (!playing && player->source != NULL) {
- g_source_destroy (player->source);
- g_source_unref (player->source);
- player->source = NULL;
+ priv = player->priv;
+ if (playing && priv->source == NULL) {
+ priv->source = swfdec_iterate_source_new (SWFDEC_PLAYER (player), priv->speed);
+ g_source_attach (priv->source, NULL);
+ } else if (!playing && priv->source != NULL) {
+ g_source_destroy (priv->source);
+ g_source_unref (priv->source);
+ priv->source = NULL;
}
swfdec_gtk_player_update_audio (player);
g_object_notify (G_OBJECT (player), "playing");
@@ -236,7 +239,7 @@ swfdec_gtk_player_get_playing (SwfdecGtkPlayer *player)
{
g_return_val_if_fail (SWFDEC_IS_GTK_PLAYER (player), FALSE);
- return player->source != NULL;
+ return player->priv->source != NULL;
}
/**
@@ -251,9 +254,9 @@ swfdec_gtk_player_set_audio_enabled (SwfdecGtkPlayer *player, gboolean enabled)
{
g_return_if_fail (SWFDEC_IS_GTK_PLAYER (player));
- if (player->audio_enabled == enabled)
+ if (player->priv->audio_enabled == enabled)
return;
- player->audio_enabled = enabled;
+ player->priv->audio_enabled = enabled;
swfdec_gtk_player_update_audio (player);
g_object_notify (G_OBJECT (player), "audio-enabled");
}
@@ -271,7 +274,7 @@ swfdec_gtk_player_get_audio_enabled (SwfdecGtkPlayer *player)
{
g_return_val_if_fail (SWFDEC_IS_GTK_PLAYER (player), FALSE);
- return player->audio_enabled;
+ return player->priv->audio_enabled;
}
/**
@@ -290,10 +293,10 @@ swfdec_gtk_player_set_speed (SwfdecGtkPlayer *player, double speed)
g_return_if_fail (SWFDEC_IS_GTK_PLAYER (player));
g_return_if_fail (speed > 0.0);
- player->speed = speed;
+ player->priv->speed = speed;
swfdec_gtk_player_update_audio (player);
- if (player->source)
- swfdec_iterate_source_set_speed (player->source, player->speed);
+ if (player->priv->source)
+ swfdec_iterate_source_set_speed (player->priv->source, player->priv->speed);
g_object_notify (G_OBJECT (player), "speed");
}
@@ -311,5 +314,5 @@ swfdec_gtk_player_get_speed (SwfdecGtkPlayer *player)
{
g_return_val_if_fail (SWFDEC_IS_GTK_PLAYER (player), FALSE);
- return player->speed;
+ return player->priv->speed;
}
diff --git a/swfdec-gtk/swfdec_gtk_player.h b/swfdec-gtk/swfdec_gtk_player.h
index dd4b51d..4abef90 100644
--- a/swfdec-gtk/swfdec_gtk_player.h
+++ b/swfdec-gtk/swfdec_gtk_player.h
@@ -25,6 +25,7 @@
G_BEGIN_DECLS
typedef struct _SwfdecGtkPlayer SwfdecGtkPlayer;
+typedef struct _SwfdecGtkPlayerPrivate SwfdecGtkPlayerPrivate;
typedef struct _SwfdecGtkPlayerClass SwfdecGtkPlayerClass;
#define SWFDEC_TYPE_GTK_PLAYER (swfdec_gtk_player_get_type())
@@ -34,6 +35,18 @@ typedef struct _SwfdecGtkPlayerClass SwfdecGtkPlayerClass;
#define SWFDEC_GTK_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_GTK_PLAYER, SwfdecGtkPlayerClass))
#define SWFDEC_GTK_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_GTK_PLAYER, SwfdecGtkPlayerClass))
+struct _SwfdecGtkPlayer
+{
+ SwfdecPlayer player;
+
+ SwfdecGtkPlayerPrivate * priv;
+};
+
+struct _SwfdecGtkPlayerClass
+{
+ SwfdecPlayerClass player_class;
+};
+
GType swfdec_gtk_player_get_type (void);
SwfdecPlayer * swfdec_gtk_player_new (SwfdecAsDebugger * debugger);
commit f30a1b7475cdf50938d830926e65cc9e9588874a
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jan 24 16:42:52 2008 +0100
port to libsoup 2.4
diff --git a/configure.ac b/configure.ac
index 2d34a55..02281c7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -107,7 +107,7 @@ dnl
GTK_VER=2.8.0
AC_SUBST(GTK_VER)
if test "$enable_gtk" = "yes"; then
- PKG_CHECK_MODULES(GTK, gtk+-2.0 >= $GTK_VER libsoup-2.2 >= 2.2.0, HAVE_GTK=yes)
+ PKG_CHECK_MODULES(GTK, gtk+-2.0 >= $GTK_VER libsoup-2.4, HAVE_GTK=yes)
AC_DEFINE(HAVE_GTK, 1, [Define if Gtk is enabled])
else
AC_MSG_NOTICE([Gtk support was not enabled.])
diff --git a/swfdec-gtk/swfdec_gtk_loader.c b/swfdec-gtk/swfdec_gtk_loader.c
index 375ca60..ec6d78f 100644
--- a/swfdec-gtk/swfdec_gtk_loader.c
+++ b/swfdec-gtk/swfdec_gtk_loader.c
@@ -68,22 +68,6 @@ struct _SwfdecGtkLoaderClass {
G_DEFINE_TYPE (SwfdecGtkLoader, swfdec_gtk_loader, SWFDEC_TYPE_FILE_LOADER)
static void
-swfdec_gtk_loader_set_size (SwfdecGtkLoader *gtk)
-{
- const char *s = soup_message_get_header (gtk->message->response_headers, "Content-Length");
- unsigned long l;
- char *end;
-
- if (s == NULL)
- return;
-
- errno = 0;
- l = strtoul (s, &end, 10);
- if (errno == 0 && *end == 0 && l <= G_MAXLONG)
- swfdec_loader_set_size (SWFDEC_LOADER (gtk), l);
-}
-
-static void
swfdec_gtk_loader_ensure_open (SwfdecGtkLoader *gtk)
{
char *real_uri;
@@ -92,25 +76,39 @@ swfdec_gtk_loader_ensure_open (SwfdecGtkLoader *gtk)
return;
real_uri = soup_uri_to_string (soup_message_get_uri (gtk->message), FALSE);
- swfdec_gtk_loader_set_size (gtk);
swfdec_loader_set_url (SWFDEC_LOADER (gtk), real_uri);
+ g_free (real_uri);
+ if (soup_message_headers_get_encoding (gtk->message->response_headers) == SOUP_ENCODING_CONTENT_LENGTH) {
+ swfdec_loader_set_size (SWFDEC_LOADER (gtk),
+ soup_message_headers_get_content_length (gtk->message->response_headers));
+ }
swfdec_stream_open (SWFDEC_STREAM (gtk));
gtk->opened = TRUE;
- g_free (real_uri);
}
static void
-swfdec_gtk_loader_push (SoupMessage *msg, gpointer loader)
+swfdec_gtk_loader_free_soup_buffer (unsigned char *data, gpointer chunk)
+{
+ soup_buffer_free (chunk);
+}
+
+static void
+swfdec_gtk_loader_push (SoupMessage *msg, SoupBuffer *chunk, gpointer loader)
{
SwfdecGtkLoader *gtk = SWFDEC_GTK_LOADER (loader);
SwfdecBuffer *buffer;
+ chunk = soup_buffer_copy (chunk);
+
swfdec_gtk_loader_ensure_open (gtk);
- buffer = swfdec_buffer_new_and_alloc (msg->response.length);
- memcpy (buffer->data, msg->response.body, msg->response.length);
+ buffer = swfdec_buffer_new ();
+ buffer->data = (unsigned char *) chunk->data;
+ buffer->length = chunk->length;
+ buffer->priv = chunk;
+ buffer->free = swfdec_gtk_loader_free_soup_buffer;
swfdec_stream_push (loader, buffer);
}
-
+
static void
swfdec_gtk_loader_finished (SoupMessage *msg, gpointer loader)
{
@@ -167,8 +165,8 @@ swfdec_gtk_loader_load (SwfdecLoader *loader, SwfdecPlayer *player,
g_signal_connect (gtk->message, "got-chunk", G_CALLBACK (swfdec_gtk_loader_push), gtk);
g_signal_connect (gtk->message, "finished", G_CALLBACK (swfdec_gtk_loader_finished), gtk);
if (buffer)
- soup_message_set_request (gtk->message, "appliation/x-www-urlencoded",
- SOUP_BUFFER_USER_OWNED, (char *) buffer->data, buffer->length);
+ soup_message_set_request (gtk->message, "appliation/x-www-form-urlencoded",
+ SOUP_MEMORY_COPY, (char *) buffer->data, buffer->length);
g_object_ref (gtk->message);
soup_session_queue_message (klass->session, gtk->message, NULL, NULL);
}
@@ -187,7 +185,7 @@ swfdec_gtk_loader_close (SwfdecStream *stream)
if (!eof) {
SwfdecGtkLoaderClass *klass = SWFDEC_GTK_LOADER_GET_CLASS (gtk);
- soup_session_cancel_message (klass->session, gtk->message);
+ soup_session_cancel_message (klass->session, gtk->message, SOUP_STATUS_CANCELLED);
g_object_unref (gtk->message);
gtk->message = NULL;
}
diff --git a/swfdec-gtk/swfdec_gtk_socket.c b/swfdec-gtk/swfdec_gtk_socket.c
index 03bedd9..8385cf1 100644
--- a/swfdec-gtk/swfdec_gtk_socket.c
+++ b/swfdec-gtk/swfdec_gtk_socket.c
@@ -70,12 +70,12 @@ swfdec_gtk_socket_close (SwfdecStream *stream)
}
static void
-swfdec_gtk_socket_do_connect (SoupSocket *sock, int status, SwfdecGtkSocket *gtk)
+swfdec_gtk_socket_do_connect (SoupSocket *sock, guint status, gpointer gtk)
{
if (SOUP_STATUS_IS_SUCCESSFUL (status))
- swfdec_stream_open (SWFDEC_STREAM (gtk));
+ swfdec_stream_open (gtk);
else
- swfdec_stream_error (SWFDEC_STREAM (gtk), "error connecting");
+ swfdec_stream_error (gtk, "error connecting");
}
@@ -92,10 +92,12 @@ swfdec_gtk_socket_do_read (SoupSocket *sock, SwfdecGtkSocket *gtk)
SwfdecBuffer *buffer;
SoupSocketIOStatus status;
gsize len;
+ GError *error = NULL;
do {
buffer = swfdec_buffer_new_and_alloc (SWFDEC_GTK_SOCKET_BLOCK_SIZE);
- status = soup_socket_read (sock, buffer, SWFDEC_GTK_SOCKET_BLOCK_SIZE, &len);
+ status = soup_socket_read (sock, buffer, SWFDEC_GTK_SOCKET_BLOCK_SIZE,
+ &len, NULL, &error);
buffer->length = len;
switch (status) {
case SOUP_SOCKET_OK:
@@ -107,7 +109,8 @@ swfdec_gtk_socket_do_read (SoupSocket *sock, SwfdecGtkSocket *gtk)
break;
case SOUP_SOCKET_ERROR:
swfdec_buffer_unref (buffer);
- swfdec_stream_error (SWFDEC_STREAM (gtk), "error reading data");
+ swfdec_stream_error (SWFDEC_STREAM (gtk), "%s", error->message);
+ g_error_free (error);
break;
default:
g_warning ("unhandled status code %u from soup_socket_read()", (guint) status);
@@ -121,11 +124,13 @@ swfdec_gtk_socket_do_write (SoupSocket *sock, SwfdecGtkSocket *gtk)
{
SwfdecBuffer *buffer;
SoupSocketIOStatus status;
+ GError *error = NULL;
gsize len;
gtk->sock_writable = TRUE;
while ((buffer = swfdec_buffer_queue_peek_buffer (gtk->queue))) {
- status = soup_socket_write (sock, buffer->data, buffer->length, &len);
+ status = soup_socket_write (sock, buffer->data, buffer->length,
+ &len, NULL, &error);
swfdec_buffer_unref (buffer);
switch (status) {
case SOUP_SOCKET_OK:
@@ -137,8 +142,9 @@ swfdec_gtk_socket_do_write (SoupSocket *sock, SwfdecGtkSocket *gtk)
gtk->sock_writable = FALSE;
break;
case SOUP_SOCKET_ERROR:
- swfdec_stream_error (SWFDEC_STREAM (gtk), "error writing data");
- break;
+ swfdec_stream_error (SWFDEC_STREAM (gtk), "%s", error->message);
+ g_error_free (error);
+ return;
default:
g_warning ("unhandled status code %u from soup_socket_read()", (guint) status);
break;
@@ -156,17 +162,14 @@ swfdec_gtk_socket_connect (SwfdecSocket *sock_, SwfdecPlayer *player,
addr = soup_address_new (hostname, port);
sock->sock = soup_socket_new (
SOUP_SOCKET_FLAG_NONBLOCKING, TRUE,
- /* FIXME: we should set nodelay, no? */
- SOUP_SOCKET_FLAG_NODELAY, TRUE, NULL);
- g_signal_connect (sock->sock, "connect-result",
- G_CALLBACK (swfdec_gtk_socket_do_connect), socket);
+ SOUP_SOCKET_REMOTE_ADDRESS, addr, NULL);
g_signal_connect (sock->sock, "disconnect",
G_CALLBACK (swfdec_gtk_socket_do_disconnect), socket);
g_signal_connect (sock->sock, "readable",
G_CALLBACK (swfdec_gtk_socket_do_read), socket);
g_signal_connect (sock->sock, "writable",
G_CALLBACK (swfdec_gtk_socket_do_write), socket);
- soup_socket_connect (sock->sock, addr);
+ soup_socket_connect_async (sock->sock, NULL, swfdec_gtk_socket_do_connect, sock);
}
static void
commit a61fbe67383e2395da7c3f83c82c5126af326d57
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jan 24 16:02:31 2008 +0100
make SwfdecSocket creation work like SwfdecLoader creation
This allows for better subclassing
diff --git a/swfdec-gtk/swfdec_gtk_socket.c b/swfdec-gtk/swfdec_gtk_socket.c
index 08cbb76..03bedd9 100644
--- a/swfdec-gtk/swfdec_gtk_socket.c
+++ b/swfdec-gtk/swfdec_gtk_socket.c
@@ -146,14 +146,16 @@ swfdec_gtk_socket_do_write (SoupSocket *sock, SwfdecGtkSocket *gtk)
};
}
-static SwfdecSocket *
-swfdec_gtk_socket_create (const char *hostname, guint port)
+static void
+swfdec_gtk_socket_connect (SwfdecSocket *sock_, SwfdecPlayer *player,
+ const char *hostname, guint port)
{
- SwfdecGtkSocket *sock = g_object_new (SWFDEC_TYPE_GTK_SOCKET, NULL);
+ SwfdecGtkSocket *sock = SWFDEC_GTK_SOCKET (sock_);
SoupAddress *addr;
addr = soup_address_new (hostname, port);
- sock->sock = soup_socket_new (SOUP_SOCKET_FLAG_NONBLOCKING, TRUE,
+ sock->sock = soup_socket_new (
+ SOUP_SOCKET_FLAG_NONBLOCKING, TRUE,
/* FIXME: we should set nodelay, no? */
SOUP_SOCKET_FLAG_NODELAY, TRUE, NULL);
g_signal_connect (sock->sock, "connect-result",
@@ -164,8 +166,7 @@ swfdec_gtk_socket_create (const char *hostname, guint port)
G_CALLBACK (swfdec_gtk_socket_do_read), socket);
g_signal_connect (sock->sock, "writable",
G_CALLBACK (swfdec_gtk_socket_do_write), socket);
-
- return SWFDEC_SOCKET (sock);
+ soup_socket_connect (sock->sock, addr);
}
static void
@@ -207,7 +208,7 @@ swfdec_gtk_socket_class_init (SwfdecGtkSocketClass *klass)
stream_class->close = swfdec_gtk_socket_close;
- socket_class->create = swfdec_gtk_socket_create;
+ socket_class->connect = swfdec_gtk_socket_connect;
socket_class->send = swfdec_gtk_socket_send;
}
diff --git a/swfdec/swfdec_player.c b/swfdec/swfdec_player.c
index 5b996ef..2795d82 100644
--- a/swfdec/swfdec_player.c
+++ b/swfdec/swfdec_player.c
@@ -2151,9 +2151,9 @@ swfdec_player_create_socket (SwfdecPlayer *player, const char *hostname, guint p
SWFDEC_INFO ("can't create socket, no socket type set.");
return NULL;
}
- klass = g_type_class_ref (player->priv->socket_type);
- sock = klass->create (hostname, port);
- g_type_class_unref (klass);
+ sock = g_object_new (player->priv->socket_type, NULL);
+ klass = SWFDEC_SOCKET_GET_CLASS (sock);
+ klass->connect (sock, player, hostname, port);
return sock;
}
diff --git a/swfdec/swfdec_socket.c b/swfdec/swfdec_socket.c
index c02c790..19f47aa 100644
--- a/swfdec/swfdec_socket.c
+++ b/swfdec/swfdec_socket.c
@@ -51,10 +51,9 @@
/**
* SwfdecSocketClass:
- * @create: Create a new socket for the given hostname and port. This function
- * must return a new socket, returning %NULL is not allowed. If you
- * encounter an error, create a new socket and call
- * swfdec_stream_error() on it.
+ * @connect: Connect the given newly created socket to the given hostname and
+ * port. If you encounter an error, call swfdec_stream_error(), but
+ * still make sure the socket object does not break.
* @send: Called to send data down the given socket. This function will only be
* called when the socket is open. You get passed a reference to the
* buffer, so it is your responsibility to call swfdec_buffer_unref() on
diff --git a/swfdec/swfdec_socket.h b/swfdec/swfdec_socket.h
index ca750af..6b43f22 100644
--- a/swfdec/swfdec_socket.h
+++ b/swfdec/swfdec_socket.h
@@ -22,6 +22,7 @@
#include <glib-object.h>
#include <swfdec/swfdec_stream.h>
+#include <swfdec/swfdec_player.h>
G_BEGIN_DECLS
@@ -44,7 +45,9 @@ struct _SwfdecSocketClass
{
SwfdecStreamClass stream_class;
- SwfdecSocket * (* create) (const char * hostname,
+ void (* connect) (SwfdecSocket * socket,
+ SwfdecPlayer * player,
+ const char * hostname,
guint port);
void (* send) (SwfdecSocket * socket,
commit 4fe9f9476eb098ae6381e196647d0d00bdda9715
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jan 24 15:38:06 2008 +0100
s/libswfdec/swfdec part 2
I didn't want to do it in 1 part, otherwise the renames wouldn't have been
renames
diff --git a/Makefile.am b/Makefile.am
index d13fae6..012b3e7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
if WITH_GTK
GTK_SUBDIRS = \
- libswfdec-gtk \
+ swfdec-gtk \
doc \
player
else
@@ -14,7 +14,7 @@ VIVI_SUBDIRS =
endif
SUBDIRS= \
- libswfdec \
+ swfdec \
$(GTK_SUBDIRS) \
$(VIVI_SUBDIRS) \
data \
diff --git a/README b/README
index 60130b9..3c51157 100644
--- a/README
+++ b/README
@@ -3,7 +3,7 @@ Swfdec is a decoder/renderer for Macromedia Flash animations. The decoding and
rendering engine is provided in a library that can be used by other
applications.
-An additional library named libswfdec-gtk is provided for easy integration of
+An additional library named swfdec-gtk is provided for easy integration of
Swfdec into Gtk applications. This library is what developers most likely want
to target their applications at. Building this library can be disabled.
@@ -14,8 +14,8 @@ it crashes. If you encounter such a crash however, make sure to file a bug
immediately.
Swfdec contains some applications for testing and debugging the library. These
-are available in the player/ and test/ directory. They are not installed. Most
-of them require the libswfdec-gtk library.
+are available in the player/, test/ and tools/ directories. They are not
+installed. Most of them require the swfdec-gtk library.
The test/ directory contains subdirectories that run automated tests with the
provided SWF files in the directory. See the README files in those directories
@@ -69,7 +69,7 @@ Dependencies:
GStreamer (>= 0.10.11 - optional, required for various audio and video formats)
MAD (>= 0.15.1b - optional, required for MP3 audio format support)
- GTK+ (>= 2.8.0 - used by libswfdec-gtk)
- ALSA (>= 1.0 - used by libswfdec-gtk)
+ GTK+ (>= 2.8.0 - used by swfdec-gtk)
+ ALSA (>= 1.0 - optional, required for sound output by swfdec-gtk)
diff --git a/configure.ac b/configure.ac
index 2690e2f..2d34a55 100644
--- a/configure.ac
+++ b/configure.ac
@@ -97,7 +97,7 @@ AC_SUBST(PANGO_CFLAGS)
AC_ARG_ENABLE(gtk,
AS_HELP_STRING([--enable-gtk],
- [enable build of libswfdec-gtk (default=yes)])],
+ [enable build of swfdec-gtk (default=yes)])],
enable_gtk=$enableval,
enable_gtk="yes")
@@ -287,12 +287,12 @@ AC_SUBST(GLOBAL_CFLAGS)
AC_SUBST(GLOBAL_CFLAGS)
SWFDEC_CFLAGS="-I\$(top_srcdir) $GLIB_CFLAGS $CAIRO_CFLAGS"
-SWFDEC_LIBS="\$(top_builddir)/libswfdec/libswfdec-$SWFDEC_MAJORMINOR.la $GLIB_LIBS $CAIRO_LIBS -lz"
+SWFDEC_LIBS="\$(top_builddir)/swfdec/libswfdec-$SWFDEC_MAJORMINOR.la $GLIB_LIBS $CAIRO_LIBS -lz"
AC_SUBST(SWFDEC_LIBS)
AC_SUBST(SWFDEC_CFLAGS)
SWFDEC_GTK_CFLAGS="$SWFDEC_CFLAGS $GTK_CFLAGS"
-SWFDEC_GTK_LIBS="\$(top_builddir)/libswfdec-gtk/libswfdec-gtk-$SWFDEC_MAJORMINOR.la $SWFDEC_LIBS $GTK_LIBS"
+SWFDEC_GTK_LIBS="\$(top_builddir)/swfdec-gtk/libswfdec-gtk-$SWFDEC_MAJORMINOR.la $SWFDEC_LIBS $GTK_LIBS"
AC_SUBST(SWFDEC_GTK_LIBS)
AC_SUBST(SWFDEC_GTK_CFLAGS)
@@ -325,9 +325,9 @@ data/icons/scalable/Makefile
data/swfdec.pc
data/swfdec-gtk.pc
doc/Makefile
-libswfdec/Makefile
-libswfdec/jpeg/Makefile
-libswfdec-gtk/Makefile
+swfdec/Makefile
+swfdec/jpeg/Makefile
+swfdec-gtk/Makefile
player/Makefile
test/Makefile
test/custom/Makefile
diff --git a/doc/Makefile.am b/doc/Makefile.am
index d7e384b..37f9fb4 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -18,7 +18,7 @@ DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml
# gtk-doc will search all .c & .h files beneath here for inline comments
# documenting the functions and macros.
# e.g. DOC_SOURCE_DIR=../../../gtk
-DOC_SOURCE_DIR=../libswfdec
+DOC_SOURCE_DIR=../swfdec
# Extra options to pass to gtkdoc-scangobj. Not normally needed.
SCANGOBJ_OPTIONS=--type-init-func="swfdec_init();"
@@ -29,7 +29,7 @@ SCAN_OPTIONS=
# Extra options to supply to gtkdoc-mkdb.
# e.g. MKDB_OPTIONS=--sgml-mode --output-format=xml
-MKDB_OPTIONS=--sgml-mode --output-format=xml --source-dir=../libswfdec-gtk
+MKDB_OPTIONS=--sgml-mode --output-format=xml --source-dir=../swfdec-gtk
# Extra options to supply to gtkdoc-mktmpl
# e.g. MKTMPL_OPTIONS=--only-section-tmpl
@@ -42,8 +42,8 @@ FIXXREF_OPTIONS=
# Used for dependencies. The docs will be rebuilt if any of these change.
# e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h
# e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c
-HFILE_GLOB=$(top_srcdir)/libswfdec/*.h $(top_srcdir)/libswfdec-gtk/*.h
-CFILE_GLOB=$(top_srcdir)/libswfdec/*.c $(top_srcdir)/libswfdec-gtk/*.c
+HFILE_GLOB=$(top_srcdir)/swfdec/*.h $(top_srcdir)/swfdec-gtk/*.h
+CFILE_GLOB=$(top_srcdir)/swfdec/*.c $(top_srcdir)/swfdec-gtk/*.c
# Header files to ignore when scanning.
# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h
@@ -146,10 +146,10 @@ IGNORE_HFILES= \
if WITH_GTK
EXTRA_HFILES = \
- ../libswfdec-gtk/swfdec_gtk_keys.h \
- ../libswfdec-gtk/swfdec_gtk_loader.h \
- ../libswfdec-gtk/swfdec_gtk_player.h \
- ../libswfdec-gtk/swfdec_gtk_widget.h
+ ../swfdec-gtk/swfdec_gtk_keys.h \
+ ../swfdec-gtk/swfdec_gtk_loader.h \
+ ../swfdec-gtk/swfdec_gtk_player.h \
+ ../swfdec-gtk/swfdec_gtk_widget.h
else
EXTRA_HFILES =
endif
diff --git a/doc/swfdec.types b/doc/swfdec.types
index c89c6d5..4ef3276 100644
--- a/doc/swfdec.types
+++ b/doc/swfdec.types
@@ -1,5 +1,5 @@
-#include <libswfdec/swfdec.h>
-#include <libswfdec-gtk/swfdec-gtk.h>
+#include <swfdec/swfdec.h>
+#include <swfdec-gtk/swfdec-gtk.h>
swfdec_as_context_get_type
swfdec_as_object_get_type
diff --git a/player/swfdec_debug_script.h b/player/swfdec_debug_script.h
index 7c8bb5e..318a3be 100644
--- a/player/swfdec_debug_script.h
+++ b/player/swfdec_debug_script.h
@@ -21,7 +21,7 @@
#define _SWFDEC_DEBUG_SCRIPT_H_
#include <gtk/gtk.h>
-#include <libswfdec/swfdec_debugger.h>
+#include <swfdec/swfdec_debugger.h>
G_BEGIN_DECLS
diff --git a/player/swfdec_debug_scripts.c b/player/swfdec_debug_scripts.c
index 14471c3..b845f84 100644
--- a/player/swfdec_debug_scripts.c
+++ b/player/swfdec_debug_scripts.c
@@ -22,7 +22,7 @@
#endif
#include "swfdec_debug_scripts.h"
-#include <libswfdec/swfdec_script_internal.h>
+#include <swfdec/swfdec_script_internal.h>
G_DEFINE_TYPE (SwfdecDebugScripts, swfdec_debug_scripts, GTK_TYPE_TREE_VIEW)
diff --git a/player/swfdec_debug_scripts.h b/player/swfdec_debug_scripts.h
index b16dcc8..bfb65ff 100644
--- a/player/swfdec_debug_scripts.h
+++ b/player/swfdec_debug_scripts.h
@@ -21,7 +21,7 @@
#define _SWFDEC_DEBUG_SCRIPTS_H_
#include <gtk/gtk.h>
-#include <libswfdec/swfdec_debugger.h>
+#include <swfdec/swfdec_debugger.h>
G_BEGIN_DECLS
diff --git a/player/swfdec_debug_stack.c b/player/swfdec_debug_stack.c
index fa70b56..452ec0b 100644
--- a/player/swfdec_debug_stack.c
+++ b/player/swfdec_debug_stack.c
@@ -21,7 +21,7 @@
#include "config.h"
#endif
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
#include "swfdec_debug_stack.h"
G_DEFINE_TYPE (SwfdecDebugStack, swfdec_debug_stack, GTK_TYPE_TREE_VIEW)
diff --git a/player/swfdec_player_manager.c b/player/swfdec_player_manager.c
index 7eb1edc..9d67709 100644
--- a/player/swfdec_player_manager.c
+++ b/player/swfdec_player_manager.c
@@ -23,11 +23,11 @@
#include <stdlib.h>
#include <string.h>
-#include <libswfdec/swfdec_debugger.h>
-#include <libswfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_debugger.h>
+#include <swfdec/swfdec_as_object.h>
#include "swfdec_player_manager.h"
-#include <libswfdec/swfdec_script_internal.h>
-#include <libswfdec-gtk/swfdec_source.h>
+#include <swfdec/swfdec_script_internal.h>
+#include <swfdec-gtk/swfdec_source.h>
enum {
PROP_0,
diff --git a/player/swfdec_player_manager.h b/player/swfdec_player_manager.h
index d68ef3e..31e99a4 100644
--- a/player/swfdec_player_manager.h
+++ b/player/swfdec_player_manager.h
@@ -21,8 +21,8 @@
#define _SWFDEC_PLAYER_MANAGER_H_
#include <gtk/gtk.h>
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_debugger.h>
+#include <swfdec/swfdec.h>
+#include <swfdec/swfdec_debugger.h>
G_BEGIN_DECLS
diff --git a/player/swfplay.c b/player/swfplay.c
index 7f98bbe..1db23f3 100644
--- a/player/swfplay.c
+++ b/player/swfplay.c
@@ -22,9 +22,9 @@
#endif
#include <gtk/gtk.h>
#include <math.h>
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
-#include <libswfdec-gtk/swfdec-gtk.h>
+#include <swfdec-gtk/swfdec-gtk.h>
static GMainLoop *loop = NULL;
diff --git a/swfdec-gtk/Makefile.am b/swfdec-gtk/Makefile.am
index 4f724cf..2fdd027 100644
--- a/swfdec-gtk/Makefile.am
+++ b/swfdec-gtk/Makefile.am
@@ -29,7 +29,7 @@ libswfdec_gtk_ at SWFDEC_MAJORMINOR@_la_LDFLAGS = \
-version-info $(SWFDEC_LIBVERSION) \
-export-symbols-regex '^(swfdec_.*)' \
$(GTK_LIBS) $(SWFDEC_LIBS) $(AUDIO_LIBS)
-libswfdec_ at SWFDEC_MAJORMINOR@includedir = $(includedir)/swfdec- at SWFDEC_MAJORMINOR@/libswfdec-gtk
+libswfdec_ at SWFDEC_MAJORMINOR@includedir = $(includedir)/swfdec- at SWFDEC_MAJORMINOR@/swfdec-gtk
libswfdec_ at SWFDEC_MAJORMINOR@include_HEADERS = \
swfdec-gtk.h \
swfdec_gtk_keys.h \
diff --git a/swfdec-gtk/swfdec-gtk.h b/swfdec-gtk/swfdec-gtk.h
index b64cf83..1f5359f 100644
--- a/swfdec-gtk/swfdec-gtk.h
+++ b/swfdec-gtk/swfdec-gtk.h
@@ -20,10 +20,10 @@
#ifndef __SWFDEC_GTK_H__
#define __SWFDEC_GTK_H__
-#include <libswfdec-gtk/swfdec_gtk_keys.h>
-#include <libswfdec-gtk/swfdec_gtk_loader.h>
-#include <libswfdec-gtk/swfdec_gtk_player.h>
-#include <libswfdec-gtk/swfdec_gtk_socket.h>
-#include <libswfdec-gtk/swfdec_gtk_widget.h>
+#include <swfdec-gtk/swfdec_gtk_keys.h>
+#include <swfdec-gtk/swfdec_gtk_loader.h>
+#include <swfdec-gtk/swfdec_gtk_player.h>
+#include <swfdec-gtk/swfdec_gtk_socket.h>
+#include <swfdec-gtk/swfdec_gtk_widget.h>
#endif
diff --git a/swfdec-gtk/swfdec_gtk_keys.h b/swfdec-gtk/swfdec_gtk_keys.h
index d9b985b..f1aa55d 100644
--- a/swfdec-gtk/swfdec_gtk_keys.h
+++ b/swfdec-gtk/swfdec_gtk_keys.h
@@ -20,7 +20,7 @@
#ifndef _SWFDEC_GTK_KEYS_H_
#define _SWFDEC_GTK_KEYS_H_
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
G_BEGIN_DECLS
diff --git a/swfdec-gtk/swfdec_gtk_loader.h b/swfdec-gtk/swfdec_gtk_loader.h
index ccae174..1e82f9f 100644
--- a/swfdec-gtk/swfdec_gtk_loader.h
+++ b/swfdec-gtk/swfdec_gtk_loader.h
@@ -20,7 +20,7 @@
#ifndef _SWFDEC_GTK_LOADER_H_
#define _SWFDEC_GTK_LOADER_H_
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
G_BEGIN_DECLS
diff --git a/swfdec-gtk/swfdec_gtk_player.c b/swfdec-gtk/swfdec_gtk_player.c
index 6d0a0a3..71ff829 100644
--- a/swfdec-gtk/swfdec_gtk_player.c
+++ b/swfdec-gtk/swfdec_gtk_player.c
@@ -21,11 +21,11 @@
#include "config.h"
#endif
-#include "libswfdec-gtk/swfdec_gtk_loader.h"
-#include "libswfdec-gtk/swfdec_gtk_player.h"
-#include "libswfdec-gtk/swfdec_gtk_socket.h"
-#include "libswfdec-gtk/swfdec_playback.h"
-#include "libswfdec-gtk/swfdec_source.h"
+#include "swfdec-gtk/swfdec_gtk_loader.h"
+#include "swfdec-gtk/swfdec_gtk_player.h"
+#include "swfdec-gtk/swfdec_gtk_socket.h"
+#include "swfdec-gtk/swfdec_playback.h"
+#include "swfdec-gtk/swfdec_source.h"
struct _SwfdecGtkPlayer
{
diff --git a/swfdec-gtk/swfdec_gtk_player.h b/swfdec-gtk/swfdec_gtk_player.h
index 3ff77bf..dd4b51d 100644
--- a/swfdec-gtk/swfdec_gtk_player.h
+++ b/swfdec-gtk/swfdec_gtk_player.h
@@ -20,7 +20,7 @@
#ifndef _SWFDEC_GTK_PLAYER_H_
#define _SWFDEC_GTK_PLAYER_H_
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
G_BEGIN_DECLS
diff --git a/swfdec-gtk/swfdec_gtk_socket.h b/swfdec-gtk/swfdec_gtk_socket.h
index 62bb546..c14a488 100644
--- a/swfdec-gtk/swfdec_gtk_socket.h
+++ b/swfdec-gtk/swfdec_gtk_socket.h
@@ -20,7 +20,7 @@
#ifndef _SWFDEC_GTK_SOCKET_H_
#define _SWFDEC_GTK_SOCKET_H_
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
G_BEGIN_DECLS
diff --git a/swfdec-gtk/swfdec_gtk_widget.h b/swfdec-gtk/swfdec_gtk_widget.h
index 86b03fd..370fc20 100644
--- a/swfdec-gtk/swfdec_gtk_widget.h
+++ b/swfdec-gtk/swfdec_gtk_widget.h
@@ -21,7 +21,7 @@
#define _SWFDEC_GTK_WIDGET_H_
#include <gtk/gtk.h>
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
G_BEGIN_DECLS
diff --git a/swfdec-gtk/swfdec_playback.h b/swfdec-gtk/swfdec_playback.h
index 8be67dd..0358293 100644
--- a/swfdec-gtk/swfdec_playback.h
+++ b/swfdec-gtk/swfdec_playback.h
@@ -20,7 +20,7 @@
#ifndef _SWFDEC_PLAYBACK_H_
#define _SWFDEC_PLAYBACK_H_
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
G_BEGIN_DECLS
diff --git a/swfdec-gtk/swfdec_source.h b/swfdec-gtk/swfdec_source.h
index 0c7c383..b75077f 100644
--- a/swfdec-gtk/swfdec_source.h
+++ b/swfdec-gtk/swfdec_source.h
@@ -20,7 +20,7 @@
#ifndef _SWFDEC_SOURCE_H_
#define _SWFDEC_SOURCE_H_
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
G_BEGIN_DECLS
diff --git a/swfdec/Makefile.am b/swfdec/Makefile.am
index dc62604..dccac20 100644
--- a/swfdec/Makefile.am
+++ b/swfdec/Makefile.am
@@ -199,7 +199,8 @@ public_headers = \
swfdec_url.h
libswfdec_ at SWFDEC_MAJORMINOR@_la_LIBADD = jpeg/libjpeg.la
-libswfdec_ at SWFDEC_MAJORMINOR@includedir = $(includedir)/swfdec- at SWFDEC_MAJORMINOR@/libswfdec
+
+libswfdec_ at SWFDEC_MAJORMINOR@includedir = $(includedir)/swfdec- at SWFDEC_MAJORMINOR@/swfdec
libswfdec_ at SWFDEC_MAJORMINOR@include_HEADERS = $(public_headers) swfdec_enums.h
noinst_HEADERS = \
diff --git a/swfdec/swfdec.h b/swfdec/swfdec.h
index e2432eb..1e769b3 100644
--- a/swfdec/swfdec.h
+++ b/swfdec/swfdec.h
@@ -22,27 +22,27 @@
#ifndef __SWFDEC_H__
#define __SWFDEC_H__
-#include <libswfdec/swfdec_as_context.h>
-#include <libswfdec/swfdec_as_debugger.h>
-#include <libswfdec/swfdec_as_frame.h>
-#include <libswfdec/swfdec_as_function.h>
-#include <libswfdec/swfdec_as_native_function.h>
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_script.h>
+#include <swfdec/swfdec_as_context.h>
+#include <swfdec/swfdec_as_debugger.h>
+#include <swfdec/swfdec_as_frame.h>
+#include <swfdec/swfdec_as_function.h>
+#include <swfdec/swfdec_as_native_function.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_script.h>
-#include <libswfdec/swfdec_audio.h>
-#include <libswfdec/swfdec_buffer.h>
-#include <libswfdec/swfdec_enums.h>
-#include <libswfdec/swfdec_file_loader.h>
-#include <libswfdec/swfdec_keys.h>
-#include <libswfdec/swfdec_loader.h>
-#include <libswfdec/swfdec_player.h>
-#include <libswfdec/swfdec_player_scripting.h>
-#include <libswfdec/swfdec_rectangle.h>
-#include <libswfdec/swfdec_socket.h>
-#include <libswfdec/swfdec_stream.h>
-#include <libswfdec/swfdec_system.h>
-#include <libswfdec/swfdec_url.h>
+#include <swfdec/swfdec_audio.h>
+#include <swfdec/swfdec_buffer.h>
+#include <swfdec/swfdec_enums.h>
+#include <swfdec/swfdec_file_loader.h>
+#include <swfdec/swfdec_keys.h>
+#include <swfdec/swfdec_loader.h>
+#include <swfdec/swfdec_player.h>
+#include <swfdec/swfdec_player_scripting.h>
+#include <swfdec/swfdec_rectangle.h>
+#include <swfdec/swfdec_socket.h>
+#include <swfdec/swfdec_stream.h>
+#include <swfdec/swfdec_system.h>
+#include <swfdec/swfdec_url.h>
#endif
diff --git a/swfdec/swfdec_amf.h b/swfdec/swfdec_amf.h
index 0f9c67e..2b493dd 100644
--- a/swfdec/swfdec_amf.h
+++ b/swfdec/swfdec_amf.h
@@ -20,8 +20,8 @@
#ifndef __SWFDEC_AMF_H__
#define __SWFDEC_AMF_H__
-#include <libswfdec/swfdec_as_context.h>
-#include <libswfdec/swfdec_bits.h>
+#include <swfdec/swfdec_as_context.h>
+#include <swfdec/swfdec_bits.h>
typedef enum {
SWFDEC_AMF_NUMBER = 0,
diff --git a/swfdec/swfdec_as_array.h b/swfdec/swfdec_as_array.h
index 4c23a7f..22665a0 100644
--- a/swfdec/swfdec_as_array.h
+++ b/swfdec/swfdec_as_array.h
@@ -21,8 +21,8 @@
#ifndef _SWFDEC_AS_ARRAY_H_
#define _SWFDEC_AS_ARRAY_H_
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_as_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_as_boolean.h b/swfdec/swfdec_as_boolean.h
index 723f076..7206da2 100644
--- a/swfdec/swfdec_as_boolean.h
+++ b/swfdec/swfdec_as_boolean.h
@@ -20,8 +20,8 @@
#ifndef _SWFDEC_AS_BOOLEAN_H_
#define _SWFDEC_AS_BOOLEAN_H_
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_as_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_as_context.h b/swfdec/swfdec_as_context.h
index d5ef066..3b19a7e 100644
--- a/swfdec/swfdec_as_context.h
+++ b/swfdec/swfdec_as_context.h
@@ -21,7 +21,7 @@
#define _SWFDEC_AS_CONTEXT_H_
#include <glib-object.h>
-#include <libswfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_as_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_as_date.h b/swfdec/swfdec_as_date.h
index b095520..77d4eab 100644
--- a/swfdec/swfdec_as_date.h
+++ b/swfdec/swfdec_as_date.h
@@ -21,9 +21,9 @@
#ifndef _SWFDEC_AS_DATE_H_
#define _SWFDEC_AS_DATE_H_
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_script.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_script.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_as_debugger.h b/swfdec/swfdec_as_debugger.h
index 2e2c0e7..3cd4b4f 100644
--- a/swfdec/swfdec_as_debugger.h
+++ b/swfdec/swfdec_as_debugger.h
@@ -20,9 +20,9 @@
#ifndef _SWFDEC_AS_DEBUGGER_H_
#define _SWFDEC_AS_DEBUGGER_H_
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_script.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_script.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_as_frame.h b/swfdec/swfdec_as_frame.h
index 344eaa7..db58580 100644
--- a/swfdec/swfdec_as_frame.h
+++ b/swfdec/swfdec_as_frame.h
@@ -20,8 +20,8 @@
#ifndef _SWFDEC_AS_FRAME_H_
#define _SWFDEC_AS_FRAME_H_
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_as_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_as_frame_internal.h b/swfdec/swfdec_as_frame_internal.h
index 866d1fa..07175a1 100644
--- a/swfdec/swfdec_as_frame_internal.h
+++ b/swfdec/swfdec_as_frame_internal.h
@@ -20,8 +20,8 @@
#ifndef _SWFDEC_AS_FRAME_INTERNAL_H_
#define _SWFDEC_AS_FRAME_INTERNAL_H_
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_script_internal.h>
+#include <swfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_script_internal.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_as_function.h b/swfdec/swfdec_as_function.h
index 534aad5..fbc461d 100644
--- a/swfdec/swfdec_as_function.h
+++ b/swfdec/swfdec_as_function.h
@@ -20,9 +20,9 @@
#ifndef _SWFDEC_AS_FUNCTION_H_
#define _SWFDEC_AS_FUNCTION_H_
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_script.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_script.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_as_internal.h b/swfdec/swfdec_as_internal.h
index 30a556c..7b634d7 100644
--- a/swfdec/swfdec_as_internal.h
+++ b/swfdec/swfdec_as_internal.h
@@ -20,8 +20,8 @@
#ifndef _SWFDEC_AS_INTERNAL_H_
#define _SWFDEC_AS_INTERNAL_H_
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_as_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_as_interpret.h b/swfdec/swfdec_as_interpret.h
index 6b9402b..09201dd 100644
--- a/swfdec/swfdec_as_interpret.h
+++ b/swfdec/swfdec_as_interpret.h
@@ -20,7 +20,7 @@
#ifndef _SWFDEC_AS_INTERPRET_H_
#define _SWFDEC_AS_INTERPRET_H_
-#include <libswfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_as_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_as_native_function.h b/swfdec/swfdec_as_native_function.h
index 88c172d..8089e5b 100644
--- a/swfdec/swfdec_as_native_function.h
+++ b/swfdec/swfdec_as_native_function.h
@@ -20,8 +20,8 @@
#ifndef _SWFDEC_AS_NATIVE_FUNCTION_H_
#define _SWFDEC_AS_NATIVE_FUNCTION_H_
-#include <libswfdec/swfdec_as_function.h>
-#include <libswfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_as_function.h>
+#include <swfdec/swfdec_as_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_as_number.h b/swfdec/swfdec_as_number.h
index 9b6ede0..eeb1c1c 100644
--- a/swfdec/swfdec_as_number.h
+++ b/swfdec/swfdec_as_number.h
@@ -20,8 +20,8 @@
#ifndef _SWFDEC_AS_NUMBER_H_
#define _SWFDEC_AS_NUMBER_H_
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_as_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_as_object.h b/swfdec/swfdec_as_object.h
index 2fe888f..d8fcf32 100644
--- a/swfdec/swfdec_as_object.h
+++ b/swfdec/swfdec_as_object.h
@@ -21,7 +21,7 @@
#define _SWFDEC_AS_OBJECT_H_
#include <glib-object.h>
-#include <libswfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_as_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_as_script_function.h b/swfdec/swfdec_as_script_function.h
index 1972e15..ab04a72 100644
--- a/swfdec/swfdec_as_script_function.h
+++ b/swfdec/swfdec_as_script_function.h
@@ -20,9 +20,9 @@
#ifndef _SWFDEC_AS_SCRIPT_FUNCTION_H_
#define _SWFDEC_AS_SCRIPT_FUNCTION_H_
-#include <libswfdec/swfdec_as_function.h>
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_script.h>
+#include <swfdec/swfdec_as_function.h>
+#include <swfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_script.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_as_stack.h b/swfdec/swfdec_as_stack.h
index 26e66ea..644095c 100644
--- a/swfdec/swfdec_as_stack.h
+++ b/swfdec/swfdec_as_stack.h
@@ -20,7 +20,7 @@
#ifndef _SWFDEC_AS_STACK_H_
#define _SWFDEC_AS_STACK_H_
-#include <libswfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_as_types.h>
G_BEGIN_DECLS
@@ -36,7 +36,7 @@ void swfdec_as_stack_pop_segment (SwfdecAsContext * context);
//#define SWFDEC_MAD_CHECKS
#ifdef SWFDEC_MAD_CHECKS
-#include <libswfdec/swfdec_as_context.h>
+#include <swfdec/swfdec_as_context.h>
static inline SwfdecAsValue *
swfdec_as_stack_peek (SwfdecAsContext *cx, guint n)
{
diff --git a/swfdec/swfdec_as_string.h b/swfdec/swfdec_as_string.h
index c0cd621..915ced0 100644
--- a/swfdec/swfdec_as_string.h
+++ b/swfdec/swfdec_as_string.h
@@ -20,8 +20,8 @@
#ifndef _SWFDEC_AS_STRING_H_
#define _SWFDEC_AS_STRING_H_
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_as_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_as_super.h b/swfdec/swfdec_as_super.h
index ad082e9..a1a8e6a 100644
--- a/swfdec/swfdec_as_super.h
+++ b/swfdec/swfdec_as_super.h
@@ -20,8 +20,8 @@
#ifndef _SWFDEC_AS_SUPER_H_
#define _SWFDEC_AS_SUPER_H_
-#include <libswfdec/swfdec_as_function.h>
-#include <libswfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_as_function.h>
+#include <swfdec/swfdec_as_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_audio_event.h b/swfdec/swfdec_audio_event.h
index 40a0eb6..b2e3d6c 100644
--- a/swfdec/swfdec_audio_event.h
+++ b/swfdec/swfdec_audio_event.h
@@ -22,8 +22,8 @@
#ifndef _SWFDEC_AUDIO_EVENT_H_
#define _SWFDEC_AUDIO_EVENT_H_
-#include <libswfdec/swfdec_audio_internal.h>
-#include <libswfdec/swfdec_sound.h>
+#include <swfdec/swfdec_audio_internal.h>
+#include <swfdec/swfdec_sound.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_audio_flv.h b/swfdec/swfdec_audio_flv.h
index 52ac2a5..91671f7 100644
--- a/swfdec/swfdec_audio_flv.h
+++ b/swfdec/swfdec_audio_flv.h
@@ -20,8 +20,8 @@
#ifndef _SWFDEC_AUDIO_FLV_H_
#define _SWFDEC_AUDIO_FLV_H_
-#include <libswfdec/swfdec_audio_internal.h>
-#include <libswfdec/swfdec_flv_decoder.h>
+#include <swfdec/swfdec_audio_internal.h>
+#include <swfdec/swfdec_flv_decoder.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_audio_internal.h b/swfdec/swfdec_audio_internal.h
index 512f6e7..2332baa 100644
--- a/swfdec/swfdec_audio_internal.h
+++ b/swfdec/swfdec_audio_internal.h
@@ -22,10 +22,10 @@
#ifndef _SWFDEC_AUDIO_INTERNAL_H_
#define _SWFDEC_AUDIO_INTERNAL_H_
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_audio.h>
-#include <libswfdec/swfdec_bits.h>
-#include <libswfdec/swfdec_types.h>
+#include <swfdec/swfdec.h>
+#include <swfdec/swfdec_audio.h>
+#include <swfdec/swfdec_bits.h>
+#include <swfdec/swfdec_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_audio_stream.h b/swfdec/swfdec_audio_stream.h
index 306c9c8..5d7c531 100644
--- a/swfdec/swfdec_audio_stream.h
+++ b/swfdec/swfdec_audio_stream.h
@@ -22,8 +22,8 @@
#ifndef _SWFDEC_AUDIO_STREAM_H_
#define _SWFDEC_AUDIO_STREAM_H_
-#include <libswfdec/swfdec_audio_internal.h>
-#include <libswfdec/swfdec_codec_audio.h>
+#include <swfdec/swfdec_audio_internal.h>
+#include <swfdec/swfdec_codec_audio.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_bits.h b/swfdec/swfdec_bits.h
index c56bc99..36e9a6a 100644
--- a/swfdec/swfdec_bits.h
+++ b/swfdec/swfdec_bits.h
@@ -23,8 +23,8 @@
#define __SWFDEC_BITS_H__
#include <cairo.h>
-#include <libswfdec/swfdec_color.h>
-#include <libswfdec/swfdec_buffer.h>
+#include <swfdec/swfdec_color.h>
+#include <swfdec/swfdec_buffer.h>
typedef struct _SwfdecBits SwfdecBits;
diff --git a/swfdec/swfdec_button.h b/swfdec/swfdec_button.h
index ddf5900..b69ed5a 100644
--- a/swfdec/swfdec_button.h
+++ b/swfdec/swfdec_button.h
@@ -22,8 +22,8 @@
#ifndef _SWFDEC_BUTTON_H_
#define _SWFDEC_BUTTON_H_
-#include <libswfdec/swfdec_graphic.h>
-#include <libswfdec/swfdec_color.h>
+#include <swfdec/swfdec_graphic.h>
+#include <swfdec/swfdec_color.h>
G_BEGIN_DECLS
//typedef struct _SwfdecButton SwfdecButton;
diff --git a/swfdec/swfdec_button_movie.h b/swfdec/swfdec_button_movie.h
index 1f6dfaf..3c3ded4 100644
--- a/swfdec/swfdec_button_movie.h
+++ b/swfdec/swfdec_button_movie.h
@@ -21,8 +21,8 @@
#define _SWFDEC_BUTTON_MOVIE_H_
#include <glib-object.h>
-#include <libswfdec/swfdec_movie.h>
-#include <libswfdec/swfdec_button.h>
+#include <swfdec/swfdec_movie.h>
+#include <swfdec/swfdec_button.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_cache.h b/swfdec/swfdec_cache.h
index 5e58aa4..89b589d 100644
--- a/swfdec/swfdec_cache.h
+++ b/swfdec/swfdec_cache.h
@@ -21,7 +21,7 @@
#ifndef _SWFDEC_CACHE_H_
#define _SWFDEC_CACHE_H_
-#include <libswfdec/swfdec_types.h>
+#include <swfdec/swfdec_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_cached.h b/swfdec/swfdec_cached.h
index bc9a1f7..52365f4 100644
--- a/swfdec/swfdec_cached.h
+++ b/swfdec/swfdec_cached.h
@@ -21,8 +21,8 @@
#define _SWFDEC_CACHED_H_
#include <cairo.h>
-#include <libswfdec/swfdec_cache.h>
-#include <libswfdec/swfdec_character.h>
+#include <swfdec/swfdec_cache.h>
+#include <swfdec/swfdec_character.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_character.h b/swfdec/swfdec_character.h
index 50b577b..e884887 100644
--- a/swfdec/swfdec_character.h
+++ b/swfdec/swfdec_character.h
@@ -23,8 +23,8 @@
#define _SWFDEC_CHARACTER_H_
#include <glib-object.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_rect.h>
+#include <swfdec/swfdec_types.h>
+#include <swfdec/swfdec_rect.h>
G_BEGIN_DECLS
//typedef struct _SwfdecCharacter SwfdecCharacter;
diff --git a/swfdec/swfdec_codec_audio.h b/swfdec/swfdec_codec_audio.h
index 48eb139..6f9e4f9 100644
--- a/swfdec/swfdec_codec_audio.h
+++ b/swfdec/swfdec_codec_audio.h
@@ -21,8 +21,8 @@
#define _SWFDEC_CODEC_H_
#include <glib.h>
-#include <libswfdec/swfdec_audio_internal.h>
-#include <libswfdec/swfdec_buffer.h>
+#include <swfdec/swfdec_audio_internal.h>
+#include <swfdec/swfdec_buffer.h>
typedef struct _SwfdecAudioDecoder SwfdecAudioDecoder;
diff --git a/swfdec/swfdec_codec_video.h b/swfdec/swfdec_codec_video.h
index a7c968a..c58fd03 100644
--- a/swfdec/swfdec_codec_video.h
+++ b/swfdec/swfdec_codec_video.h
@@ -22,7 +22,7 @@
#include <glib.h>
#include <cairo.h>
-#include <libswfdec/swfdec_buffer.h>
+#include <swfdec/swfdec_buffer.h>
#define SWFDEC_VIDEO_CODEC_UNDEFINED 0
#define SWFDEC_VIDEO_CODEC_H263 2
diff --git a/swfdec/swfdec_color.h b/swfdec/swfdec_color.h
index d2ba7a1..188e6dd 100644
--- a/swfdec/swfdec_color.h
+++ b/swfdec/swfdec_color.h
@@ -22,7 +22,7 @@
#ifndef __SWFDEC_COLOR_H__
#define __SWFDEC_COLOR_H__
-#include <libswfdec/swfdec_types.h>
+#include <swfdec/swfdec_types.h>
struct _SwfdecColorTransform {
gboolean mask; /* TRUE if this is a mask - masks are always black */
diff --git a/swfdec/swfdec_debugger.h b/swfdec/swfdec_debugger.h
index 139e93b..00999ba 100644
--- a/swfdec/swfdec_debugger.h
+++ b/swfdec/swfdec_debugger.h
@@ -21,10 +21,10 @@
#define _SWFDEC_DEBUGGER_H_
#include <glib-object.h>
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_player_internal.h>
-#include <libswfdec/swfdec_script.h>
-#include <libswfdec/swfdec_types.h>
+#include <swfdec/swfdec.h>
+#include <swfdec/swfdec_player_internal.h>
+#include <swfdec/swfdec_script.h>
+#include <swfdec/swfdec_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_decoder.h b/swfdec/swfdec_decoder.h
index 3a58015..1dc762c 100644
--- a/swfdec/swfdec_decoder.h
+++ b/swfdec/swfdec_decoder.h
@@ -21,10 +21,10 @@
#define _SWFDEC_DECODER_H_
#include <glib-object.h>
-#include <libswfdec/swfdec_buffer.h>
-#include <libswfdec/swfdec_loader.h>
-#include <libswfdec/swfdec_player.h>
-#include <libswfdec/swfdec_types.h>
+#include <swfdec/swfdec_buffer.h>
+#include <swfdec/swfdec_loader.h>
+#include <swfdec/swfdec_player.h>
+#include <swfdec/swfdec_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_draw.h b/swfdec/swfdec_draw.h
index e56a4ae..a892e47 100644
--- a/swfdec/swfdec_draw.h
+++ b/swfdec/swfdec_draw.h
@@ -22,8 +22,8 @@
#include <glib-object.h>
#include <cairo.h>
-#include <libswfdec/swfdec_swf_decoder.h>
-#include <libswfdec/swfdec_color.h>
+#include <swfdec/swfdec_swf_decoder.h>
+#include <swfdec/swfdec_color.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_event.h b/swfdec/swfdec_event.h
index 4b1ba40..ed13327 100644
--- a/swfdec/swfdec_event.h
+++ b/swfdec/swfdec_event.h
@@ -17,10 +17,10 @@
* Boston, MA 02110-1301 USA
*/
-#include <libswfdec/swfdec_bits.h>
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_player.h>
-#include <libswfdec/swfdec_types.h>
+#include <swfdec/swfdec_bits.h>
+#include <swfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_player.h>
+#include <swfdec/swfdec_types.h>
#ifndef _SWFDEC_EVENT_H_
#define _SWFDEC_EVENT_H_
diff --git a/swfdec/swfdec_file_loader.h b/swfdec/swfdec_file_loader.h
index facd8c5..8350063 100644
--- a/swfdec/swfdec_file_loader.h
+++ b/swfdec/swfdec_file_loader.h
@@ -20,7 +20,7 @@
#ifndef _SWFDEC_FILE_LOADER_H_
#define _SWFDEC_FILE_LOADER_H_
-#include <libswfdec/swfdec_loader.h>
+#include <swfdec/swfdec_loader.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_filter.h b/swfdec/swfdec_filter.h
index 2f39f15..ff0ce72 100644
--- a/swfdec/swfdec_filter.h
+++ b/swfdec/swfdec_filter.h
@@ -20,10 +20,10 @@
#ifndef _SWFDEC_FILTER_H_
#define _SWFDEC_FILTER_H_
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_bits.h>
-#include <libswfdec/swfdec_types.h>
+#include <swfdec/swfdec.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_bits.h>
+#include <swfdec/swfdec_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_flv_decoder.h b/swfdec/swfdec_flv_decoder.h
index 635fea4..0061c02 100644
--- a/swfdec/swfdec_flv_decoder.h
+++ b/swfdec/swfdec_flv_decoder.h
@@ -20,9 +20,9 @@
#ifndef __SWFDEC_FLV_DECODER_H__
#define __SWFDEC_FLV_DECODER_H__
-#include <libswfdec/swfdec_codec_audio.h>
-#include <libswfdec/swfdec_codec_video.h>
-#include <libswfdec/swfdec_decoder.h>
+#include <swfdec/swfdec_codec_audio.h>
+#include <swfdec/swfdec_codec_video.h>
+#include <swfdec/swfdec_decoder.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_font.h b/swfdec/swfdec_font.h
index b9ff5d7..a34eb39 100644
--- a/swfdec/swfdec_font.h
+++ b/swfdec/swfdec_font.h
@@ -23,8 +23,8 @@
#define _SWFDEC_FONT_H_
#include <pango/pangocairo.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_character.h>
+#include <swfdec/swfdec_types.h>
+#include <swfdec/swfdec_character.h>
G_BEGIN_DECLS
//typedef struct _SwfdecFont SwfdecFont;
diff --git a/swfdec/swfdec_gradient_pattern.h b/swfdec/swfdec_gradient_pattern.h
index 6b85608..b025314 100644
--- a/swfdec/swfdec_gradient_pattern.h
+++ b/swfdec/swfdec_gradient_pattern.h
@@ -20,7 +20,7 @@
#ifndef _SWFDEC_GRADIENT_PATTERN_H_
#define _SWFDEC_GRADIENT_PATTERN_H_
-#include <libswfdec/swfdec_pattern.h>
+#include <swfdec/swfdec_pattern.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_graphic.h b/swfdec/swfdec_graphic.h
index 0b48d19..52e0f74 100644
--- a/swfdec/swfdec_graphic.h
+++ b/swfdec/swfdec_graphic.h
@@ -23,9 +23,9 @@
#define _SWFDEC_GRAPHIC_H_
#include <glib-object.h>
-#include <libswfdec/swfdec_character.h>
-#include <libswfdec/swfdec_rect.h>
-#include <libswfdec/swfdec_types.h>
+#include <swfdec/swfdec_character.h>
+#include <swfdec/swfdec_rect.h>
+#include <swfdec/swfdec_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_graphic_movie.h b/swfdec/swfdec_graphic_movie.h
index 4d6e454..ede8a0f 100644
--- a/swfdec/swfdec_graphic_movie.h
+++ b/swfdec/swfdec_graphic_movie.h
@@ -21,8 +21,8 @@
#define _SWFDEC_GRAPHIC_MOVIE_H_
#include <glib-object.h>
-#include <libswfdec/swfdec_movie.h>
-#include <libswfdec/swfdec_graphic.h>
+#include <swfdec/swfdec_movie.h>
+#include <swfdec/swfdec_graphic.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_image.h b/swfdec/swfdec_image.h
index e648e08..8e41db9 100644
--- a/swfdec/swfdec_image.h
+++ b/swfdec/swfdec_image.h
@@ -23,8 +23,8 @@
#define _SWFDEC_IMAGE_H_
#include <cairo.h>
-#include <libswfdec/swfdec_cached.h>
-#include <libswfdec/swfdec_decoder.h>
+#include <swfdec/swfdec_cached.h>
+#include <swfdec/swfdec_decoder.h>
G_BEGIN_DECLS
//typedef struct _SwfdecImage SwfdecImage;
diff --git a/swfdec/swfdec_image_decoder.h b/swfdec/swfdec_image_decoder.h
index b5f3a84..0b3f743 100644
--- a/swfdec/swfdec_image_decoder.h
+++ b/swfdec/swfdec_image_decoder.h
@@ -22,10 +22,10 @@
#include <glib.h>
-#include <libswfdec/swfdec_decoder.h>
-#include <libswfdec/swfdec_bits.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_rect.h>
+#include <swfdec/swfdec_decoder.h>
+#include <swfdec/swfdec_bits.h>
+#include <swfdec/swfdec_types.h>
+#include <swfdec/swfdec_rect.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_internal.h b/swfdec/swfdec_internal.h
index 79d49c1..41d8664 100644
--- a/swfdec/swfdec_internal.h
+++ b/swfdec/swfdec_internal.h
@@ -22,9 +22,9 @@
#ifndef _SWFDEC_INTERNAL_H_
#define _SWFDEC_INTERNAL_H_
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_codec_audio.h>
-#include <libswfdec/swfdec_codec_video.h>
+#include <swfdec/swfdec_types.h>
+#include <swfdec/swfdec_codec_audio.h>
+#include <swfdec/swfdec_codec_video.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_interval.h b/swfdec/swfdec_interval.h
index 48941bf..8e82511 100644
--- a/swfdec/swfdec_interval.h
+++ b/swfdec/swfdec_interval.h
@@ -20,10 +20,10 @@
#ifndef _SWFDEC_INTERVAL_H_
#define _SWFDEC_INTERVAL_H_
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_player_internal.h>
-#include <libswfdec/swfdec_sandbox.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_player_internal.h>
+#include <swfdec/swfdec_sandbox.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_load_object.h b/swfdec/swfdec_load_object.h
index 51b3baa..cd899a9 100644
--- a/swfdec/swfdec_load_object.h
+++ b/swfdec/swfdec_load_object.h
@@ -21,9 +21,9 @@
#ifndef _SWFDEC_LOAD_OBJECT_H_
#define _SWFDEC_LOAD_OBJECT_H_
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_resource.h>
+#include <swfdec/swfdec.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_resource.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_loader.h b/swfdec/swfdec_loader.h
index 3d0ebff..6f15477 100644
--- a/swfdec/swfdec_loader.h
+++ b/swfdec/swfdec_loader.h
@@ -21,10 +21,10 @@
#define _SWFDEC_LOADER_H_
#include <glib-object.h>
-#include <libswfdec/swfdec_buffer.h>
-#include <libswfdec/swfdec_player.h>
-#include <libswfdec/swfdec_stream.h>
-#include <libswfdec/swfdec_url.h>
+#include <swfdec/swfdec_buffer.h>
+#include <swfdec/swfdec_player.h>
+#include <swfdec/swfdec_stream.h>
+#include <swfdec/swfdec_url.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_morph_movie.h b/swfdec/swfdec_morph_movie.h
index c8dd6cc..db19692 100644
--- a/swfdec/swfdec_morph_movie.h
+++ b/swfdec/swfdec_morph_movie.h
@@ -21,8 +21,8 @@
#define _SWFDEC_MORPH_MOVIE_H_
#include <glib-object.h>
-#include <libswfdec/swfdec_movie.h>
-#include <libswfdec/swfdec_morphshape.h>
+#include <swfdec/swfdec_movie.h>
+#include <swfdec/swfdec_morphshape.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_morphshape.h b/swfdec/swfdec_morphshape.h
index e460109..8a5107e 100644
--- a/swfdec/swfdec_morphshape.h
+++ b/swfdec/swfdec_morphshape.h
@@ -20,7 +20,7 @@
#ifndef _SWFDEC_MORPH_SHAPE_H_
#define _SWFDEC_MORPH_SHAPE_H_
-#include <libswfdec/swfdec_shape.h>
+#include <swfdec/swfdec_shape.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_movie.h b/swfdec/swfdec_movie.h
index 623707f..296e495 100644
--- a/swfdec/swfdec_movie.h
+++ b/swfdec/swfdec_movie.h
@@ -21,12 +21,12 @@
#define _SWFDEC_MOVIE_H_
#include <glib-object.h>
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_color.h>
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_event.h>
-#include <libswfdec/swfdec_rect.h>
-#include <libswfdec/swfdec_types.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_color.h>
+#include <swfdec/swfdec.h>
+#include <swfdec/swfdec_event.h>
+#include <swfdec/swfdec_rect.h>
+#include <swfdec/swfdec_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_movie_clip_loader.h b/swfdec/swfdec_movie_clip_loader.h
index 9ef0d1c..5bf7aae 100644
--- a/swfdec/swfdec_movie_clip_loader.h
+++ b/swfdec/swfdec_movie_clip_loader.h
@@ -20,7 +20,7 @@
#ifndef _SWFDEC_MOVIE_CLIP_LOADER_H_
#define _SWFDEC_MOVIE_CLIP_LOADER_H_
-#include <libswfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_as_object.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_net_connection.h b/swfdec/swfdec_net_connection.h
index e7bd3fa..c14daac 100644
--- a/swfdec/swfdec_net_connection.h
+++ b/swfdec/swfdec_net_connection.h
@@ -20,7 +20,7 @@
#ifndef _SWFDEC_NET_CONNECTION_H_
#define _SWFDEC_NET_CONNECTION_H_
-#include <libswfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_as_object.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_net_stream.h b/swfdec/swfdec_net_stream.h
index 943c834..5520d05 100644
--- a/swfdec/swfdec_net_stream.h
+++ b/swfdec/swfdec_net_stream.h
@@ -20,14 +20,14 @@
#ifndef _SWFDEC_NET_STREAM_H_
#define _SWFDEC_NET_STREAM_H_
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_codec_video.h>
-#include <libswfdec/swfdec_net_connection.h>
-#include <libswfdec/swfdec_flv_decoder.h>
-#include <libswfdec/swfdec_player_internal.h>
-#include <libswfdec/swfdec_sandbox.h>
-#include <libswfdec/swfdec_video_movie.h>
+#include <swfdec/swfdec.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_codec_video.h>
+#include <swfdec/swfdec_net_connection.h>
+#include <swfdec/swfdec_flv_decoder.h>
+#include <swfdec/swfdec_player_internal.h>
+#include <swfdec/swfdec_sandbox.h>
+#include <swfdec/swfdec_video_movie.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_path.h b/swfdec/swfdec_path.h
index 502a049..bfe0607 100644
--- a/swfdec/swfdec_path.h
+++ b/swfdec/swfdec_path.h
@@ -21,7 +21,7 @@
#define _SWFDEC_PATH_H_
#include <cairo.h>
-#include <libswfdec/swfdec_rect.h>
+#include <swfdec/swfdec_rect.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_pattern.h b/swfdec/swfdec_pattern.h
index 3fdcf99..811389d 100644
--- a/swfdec/swfdec_pattern.h
+++ b/swfdec/swfdec_pattern.h
@@ -22,8 +22,8 @@
#include <glib-object.h>
#include <cairo.h>
-#include <libswfdec/swfdec_draw.h>
-#include <libswfdec/swfdec_swf_decoder.h>
+#include <swfdec/swfdec_draw.h>
+#include <swfdec/swfdec_swf_decoder.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_player.h b/swfdec/swfdec_player.h
index b3ec5f5..5c32f59 100644
--- a/swfdec/swfdec_player.h
+++ b/swfdec/swfdec_player.h
@@ -22,9 +22,9 @@
#include <glib-object.h>
#include <cairo.h>
-#include <libswfdec/swfdec_as_context.h>
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_url.h>
+#include <swfdec/swfdec_as_context.h>
+#include <swfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_url.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_player_internal.h b/swfdec/swfdec_player_internal.h
index a38b957..453ce3d 100644
--- a/swfdec/swfdec_player_internal.h
+++ b/swfdec/swfdec_player_internal.h
@@ -20,16 +20,16 @@
#ifndef _SWFDEC_PLAYER_INTERNAL_H_
#define _SWFDEC_PLAYER_INTERNAL_H_
-#include <libswfdec/swfdec_player.h>
-#include <libswfdec/swfdec_audio.h>
-#include <libswfdec/swfdec_event.h>
-#include <libswfdec/swfdec_function_list.h>
-#include <libswfdec/swfdec_loader.h>
-#include <libswfdec/swfdec_player_scripting.h>
-#include <libswfdec/swfdec_rect.h>
-#include <libswfdec/swfdec_ringbuffer.h>
-#include <libswfdec/swfdec_socket.h>
-#include <libswfdec/swfdec_system.h>
+#include <swfdec/swfdec_player.h>
+#include <swfdec/swfdec_audio.h>
+#include <swfdec/swfdec_event.h>
+#include <swfdec/swfdec_function_list.h>
+#include <swfdec/swfdec_loader.h>
+#include <swfdec/swfdec_player_scripting.h>
+#include <swfdec/swfdec_rect.h>
+#include <swfdec/swfdec_ringbuffer.h>
+#include <swfdec/swfdec_socket.h>
+#include <swfdec/swfdec_system.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_player_scripting.h b/swfdec/swfdec_player_scripting.h
index 8ad3c8f..03dbbae 100644
--- a/swfdec/swfdec_player_scripting.h
+++ b/swfdec/swfdec_player_scripting.h
@@ -21,7 +21,7 @@
#define _SWFDEC_PLAYER_SCRIPTING_H_
#include <glib-object.h>
-#include <libswfdec/swfdec_player.h>
+#include <swfdec/swfdec_player.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_policy_file.h b/swfdec/swfdec_policy_file.h
index b849562..337e236 100644
--- a/swfdec/swfdec_policy_file.h
+++ b/swfdec/swfdec_policy_file.h
@@ -21,8 +21,8 @@
#ifndef _SWFDEC_FLASH_SECURITY_POLICY_H_
#define _SWFDEC_FLASH_SECURITY_POLICY_H_
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_player.h>
+#include <swfdec/swfdec.h>
+#include <swfdec/swfdec_player.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_rect.h b/swfdec/swfdec_rect.h
index d43cee4..6833b8c 100644
--- a/swfdec/swfdec_rect.h
+++ b/swfdec/swfdec_rect.h
@@ -22,8 +22,8 @@
#ifndef __SWFDEC_RECT_H__
#define __SWFDEC_RECT_H__
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_rectangle.h>
+#include <swfdec/swfdec_types.h>
+#include <swfdec/swfdec_rectangle.h>
struct _SwfdecRect
{
diff --git a/swfdec/swfdec_resource.h b/swfdec/swfdec_resource.h
index fba2f95..3496789 100644
--- a/swfdec/swfdec_resource.h
+++ b/swfdec/swfdec_resource.h
@@ -20,9 +20,9 @@
#ifndef _SWFDEC_RESOURCE_H_
#define _SWFDEC_RESOURCE_H_
-#include <libswfdec/swfdec_player.h>
-#include <libswfdec/swfdec_sandbox.h>
-#include <libswfdec/swfdec_sprite_movie.h>
+#include <swfdec/swfdec_player.h>
+#include <swfdec/swfdec_sandbox.h>
+#include <swfdec/swfdec_sprite_movie.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_sandbox.h b/swfdec/swfdec_sandbox.h
index 6fda9b7..fa5baca 100644
--- a/swfdec/swfdec_sandbox.h
+++ b/swfdec/swfdec_sandbox.h
@@ -20,9 +20,9 @@
#ifndef _SWFDEC_SANDBOX_H_
#define _SWFDEC_SANDBOX_H_
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_url.h>
-#include <libswfdec/swfdec_player.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_url.h>
+#include <swfdec/swfdec_player.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_script.h b/swfdec/swfdec_script.h
index fe90428..0881831 100644
--- a/swfdec/swfdec_script.h
+++ b/swfdec/swfdec_script.h
@@ -20,8 +20,8 @@
#ifndef _SWFDEC_SCRIPT_H_
#define _SWFDEC_SCRIPT_H_
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_buffer.h>
+#include <swfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_buffer.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_script_internal.h b/swfdec/swfdec_script_internal.h
index 23acb0d..8dc4308 100644
--- a/swfdec/swfdec_script_internal.h
+++ b/swfdec/swfdec_script_internal.h
@@ -20,10 +20,10 @@
#ifndef _SWFDEC_SCRIPT_INTERNAL_H_
#define _SWFDEC_SCRIPT_INTERNAL_H_
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_bits.h>
+#include <swfdec/swfdec.h>
+#include <swfdec/swfdec_as_types.h>
+#include <swfdec/swfdec_types.h>
+#include <swfdec/swfdec_bits.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_shape.h b/swfdec/swfdec_shape.h
index 312dc9f..b97189c 100644
--- a/swfdec/swfdec_shape.h
+++ b/swfdec/swfdec_shape.h
@@ -22,13 +22,13 @@
#ifndef _SWFDEC_SHAPE_H_
#define _SWFDEC_SHAPE_H_
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_color.h>
-#include <libswfdec/swfdec_bits.h>
-#include <libswfdec/swfdec_graphic.h>
-#include <libswfdec/swfdec_pattern.h>
-#include <libswfdec/swfdec_stroke.h>
-#include <libswfdec/swfdec_swf_decoder.h>
+#include <swfdec/swfdec_types.h>
+#include <swfdec/swfdec_color.h>
+#include <swfdec/swfdec_bits.h>
+#include <swfdec/swfdec_graphic.h>
+#include <swfdec/swfdec_pattern.h>
+#include <swfdec/swfdec_stroke.h>
+#include <swfdec/swfdec_swf_decoder.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_shape_parser.h b/swfdec/swfdec_shape_parser.h
index 9dccbf0..75e3ee5 100644
--- a/swfdec/swfdec_shape_parser.h
+++ b/swfdec/swfdec_shape_parser.h
@@ -22,8 +22,8 @@
#ifndef _SWFDEC_SHAPE_PARSER_H_
#define _SWFDEC_SHAPE_PARSER_H_
-#include <libswfdec/swfdec_bits.h>
-#include <libswfdec/swfdec_draw.h>
+#include <swfdec/swfdec_bits.h>
+#include <swfdec/swfdec_draw.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_socket.c b/swfdec/swfdec_socket.c
index 723050c..c02c790 100644
--- a/swfdec/swfdec_socket.c
+++ b/swfdec/swfdec_socket.c
@@ -34,7 +34,7 @@
* SwfdecSockets are used to implement TCP streams. These are for example used
* to implement RTMP support or the XMLSocket script class. Backends are
* supposed to provide an implementation for this, as by default this class is
- * unimplemented. However, libswfdec-gtk or other convenience libraries provide
+ * unimplemented. However, swfdec-gtk or other convenience libraries provide
* a socket implementation by default.
*
* The socket implementation used by a #SwfdecPlayer can be set with the
diff --git a/swfdec/swfdec_socket.h b/swfdec/swfdec_socket.h
index 7e062ca..ca750af 100644
--- a/swfdec/swfdec_socket.h
+++ b/swfdec/swfdec_socket.h
@@ -21,7 +21,7 @@
#define _SWFDEC_SOCKET_H_
#include <glib-object.h>
-#include <libswfdec/swfdec_stream.h>
+#include <swfdec/swfdec_stream.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_sound.h b/swfdec/swfdec_sound.h
index 75e917e..cea0a58 100644
--- a/swfdec/swfdec_sound.h
+++ b/swfdec/swfdec_sound.h
@@ -22,10 +22,10 @@
#ifndef _SWFDEC_SOUND_H_
#define _SWFDEC_SOUND_H_
-#include <libswfdec/swfdec_cached.h>
-#include <libswfdec/swfdec_codec_audio.h>
-#include <libswfdec/swfdec_swf_decoder.h>
-#include <libswfdec/swfdec_types.h>
+#include <swfdec/swfdec_cached.h>
+#include <swfdec/swfdec_codec_audio.h>
+#include <swfdec/swfdec_swf_decoder.h>
+#include <swfdec/swfdec_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_sound_object.h b/swfdec/swfdec_sound_object.h
index cdceaeb..c36d12e 100644
--- a/swfdec/swfdec_sound_object.h
+++ b/swfdec/swfdec_sound_object.h
@@ -20,7 +20,7 @@
#ifndef _SWFDEC_SOUND_OBJECT_H_
#define _SWFDEC_SOUND_OBJECT_H_
-#include <libswfdec/swfdec_movie.h>
+#include <swfdec/swfdec_movie.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_sprite.h b/swfdec/swfdec_sprite.h
index 6c9d4b9..cbca787 100644
--- a/swfdec/swfdec_sprite.h
+++ b/swfdec/swfdec_sprite.h
@@ -22,10 +22,10 @@
#ifndef _SWFDEC_SPRITE_H_
#define _SWFDEC_SPRITE_H_
-#include <libswfdec/swfdec_color.h>
-#include <libswfdec/swfdec_event.h>
-#include <libswfdec/swfdec_graphic.h>
-#include <libswfdec/swfdec_types.h>
+#include <swfdec/swfdec_color.h>
+#include <swfdec/swfdec_event.h>
+#include <swfdec/swfdec_graphic.h>
+#include <swfdec/swfdec_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_sprite_movie.h b/swfdec/swfdec_sprite_movie.h
index 093154d..93fe320 100644
--- a/swfdec/swfdec_sprite_movie.h
+++ b/swfdec/swfdec_sprite_movie.h
@@ -20,9 +20,9 @@
#ifndef _SWFDEC_SPRITE_MOVIE_H_
#define _SWFDEC_SPRITE_MOVIE_H_
-#include <libswfdec/swfdec_movie.h>
-#include <libswfdec/swfdec_audio.h>
-#include <libswfdec/swfdec_types.h>
+#include <swfdec/swfdec_movie.h>
+#include <swfdec/swfdec_audio.h>
+#include <swfdec/swfdec_types.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_stream.h b/swfdec/swfdec_stream.h
index f1cb86c..973863d 100644
--- a/swfdec/swfdec_stream.h
+++ b/swfdec/swfdec_stream.h
@@ -21,7 +21,7 @@
#define _SWFDEC_STREAM_H_
#include <glib-object.h>
-#include <libswfdec/swfdec_buffer.h>
+#include <swfdec/swfdec_buffer.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_stream_target.h b/swfdec/swfdec_stream_target.h
index 42b8e16..9f0ddff 100644
--- a/swfdec/swfdec_stream_target.h
+++ b/swfdec/swfdec_stream_target.h
@@ -20,7 +20,7 @@
#ifndef __SWFDEC_STREAM_TARGET_H__
#define __SWFDEC_STREAM_TARGET_H__
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_stroke.h b/swfdec/swfdec_stroke.h
index 8d1e7cd..01c2eba 100644
--- a/swfdec/swfdec_stroke.h
+++ b/swfdec/swfdec_stroke.h
@@ -20,7 +20,7 @@
#ifndef _SWFDEC_STROKE_H_
#define _SWFDEC_STROKE_H_
-#include <libswfdec/swfdec_pattern.h>
+#include <swfdec/swfdec_pattern.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_style_sheet.h b/swfdec/swfdec_style_sheet.h
index 847d7f7..226ff87 100644
--- a/swfdec/swfdec_style_sheet.h
+++ b/swfdec/swfdec_style_sheet.h
@@ -21,10 +21,10 @@
#ifndef _SWFDEC_STYLESHEET_H_
#define _SWFDEC_STYLESHEET_H_
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_script.h>
-#include <libswfdec/swfdec_text_format.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_types.h>
+#include <swfdec/swfdec_script.h>
+#include <swfdec/swfdec_text_format.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_swf_decoder.h b/swfdec/swfdec_swf_decoder.h
index dcd2e16..0566c99 100644
--- a/swfdec/swfdec_swf_decoder.h
+++ b/swfdec/swfdec_swf_decoder.h
@@ -25,10 +25,10 @@
#include <glib.h>
#include <zlib.h>
-#include <libswfdec/swfdec_decoder.h>
-#include <libswfdec/swfdec_bits.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_rect.h>
+#include <swfdec/swfdec_decoder.h>
+#include <swfdec/swfdec_bits.h>
+#include <swfdec/swfdec_types.h>
+#include <swfdec/swfdec_rect.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_text.h b/swfdec/swfdec_text.h
index a590470..867e6f4 100644
--- a/swfdec/swfdec_text.h
+++ b/swfdec/swfdec_text.h
@@ -22,8 +22,8 @@
#ifndef _SWFDEC_TEXT_H_
#define _SWFDEC_TEXT_H_
-#include <libswfdec/swfdec_graphic.h>
-#include <libswfdec/swfdec_color.h>
+#include <swfdec/swfdec_graphic.h>
+#include <swfdec/swfdec_color.h>
G_BEGIN_DECLS
//typedef struct _SwfdecText SwfdecText;
diff --git a/swfdec/swfdec_text_field.h b/swfdec/swfdec_text_field.h
index a321a1c..2ad0414 100644
--- a/swfdec/swfdec_text_field.h
+++ b/swfdec/swfdec_text_field.h
@@ -22,11 +22,11 @@
#define _SWFDEC_TEXT_FIELD_H_
#include <pango/pango.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_color.h>
-#include <libswfdec/swfdec_graphic.h>
-#include <libswfdec/swfdec_player.h>
-#include <libswfdec/swfdec_text_format.h>
+#include <swfdec/swfdec_types.h>
+#include <swfdec/swfdec_color.h>
+#include <swfdec/swfdec_graphic.h>
+#include <swfdec/swfdec_player.h>
+#include <swfdec/swfdec_text_format.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_text_field_movie.h b/swfdec/swfdec_text_field_movie.h
index 8d719d3..07d7a0e 100644
--- a/swfdec/swfdec_text_field_movie.h
+++ b/swfdec/swfdec_text_field_movie.h
@@ -21,10 +21,10 @@
#ifndef _SWFDEC_TEXT_FIELD_MOVIE_H_
#define _SWFDEC_TEXT_FIELD_MOVIE_H_
-#include <libswfdec/swfdec_movie.h>
-#include <libswfdec/swfdec_text_field.h>
-#include <libswfdec/swfdec_style_sheet.h>
-#include <libswfdec/swfdec_text_format.h>
+#include <swfdec/swfdec_movie.h>
+#include <swfdec/swfdec_text_field.h>
+#include <swfdec/swfdec_style_sheet.h>
+#include <swfdec/swfdec_text_format.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_text_format.h b/swfdec/swfdec_text_format.h
index 77dddb4..34e1e5e 100644
--- a/swfdec/swfdec_text_format.h
+++ b/swfdec/swfdec_text_format.h
@@ -21,10 +21,10 @@
#ifndef _SWFDEC_TEXT_FORMAT_H_
#define _SWFDEC_TEXT_FORMAT_H_
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_array.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_script.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_as_array.h>
+#include <swfdec/swfdec_types.h>
+#include <swfdec/swfdec_script.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_video.h b/swfdec/swfdec_video.h
index 585c726..94569f7 100644
--- a/swfdec/swfdec_video.h
+++ b/swfdec/swfdec_video.h
@@ -20,8 +20,8 @@
#ifndef _SWFDEC_VIDEO_H_
#define _SWFDEC_VIDEO_H_
-#include <libswfdec/swfdec_graphic.h>
-#include <libswfdec/swfdec_codec_video.h>
+#include <swfdec/swfdec_graphic.h>
+#include <swfdec/swfdec_codec_video.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_video_movie.h b/swfdec/swfdec_video_movie.h
index 958bc49..9d5af15 100644
--- a/swfdec/swfdec_video_movie.h
+++ b/swfdec/swfdec_video_movie.h
@@ -21,8 +21,8 @@
#define _SWFDEC_VIDEO_MOVIE_H_
#include <glib-object.h>
-#include <libswfdec/swfdec_movie.h>
-#include <libswfdec/swfdec_video.h>
+#include <swfdec/swfdec_movie.h>
+#include <swfdec/swfdec_video.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_xml.h b/swfdec/swfdec_xml.h
index 3be92d5..45c8ee8 100644
--- a/swfdec/swfdec_xml.h
+++ b/swfdec/swfdec_xml.h
@@ -21,10 +21,10 @@
#ifndef _SWFDEC_XML_H_
#define _SWFDEC_XML_H_
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_script.h>
-#include <libswfdec/swfdec_xml_node.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_types.h>
+#include <swfdec/swfdec_script.h>
+#include <swfdec/swfdec_xml_node.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_xml_node.h b/swfdec/swfdec_xml_node.h
index 7135613..49b5d48 100644
--- a/swfdec/swfdec_xml_node.h
+++ b/swfdec/swfdec_xml_node.h
@@ -21,10 +21,10 @@
#ifndef _SWFDEC_XML_NODE_H_
#define _SWFDEC_XML_NODE_H_
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_script.h>
-#include <libswfdec/swfdec_player.h>
+#include <swfdec/swfdec_as_object.h>
+#include <swfdec/swfdec_types.h>
+#include <swfdec/swfdec_script.h>
+#include <swfdec/swfdec_player.h>
G_BEGIN_DECLS
diff --git a/swfdec/swfdec_xml_socket.h b/swfdec/swfdec_xml_socket.h
index 95f19c2..eb751d5 100644
--- a/swfdec/swfdec_xml_socket.h
+++ b/swfdec/swfdec_xml_socket.h
@@ -20,8 +20,8 @@
#ifndef _SWFDEC_XML_SOCKET_H_
#define _SWFDEC_XML_SOCKET_H_
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_as_object.h>
+#include <swfdec/swfdec.h>
+#include <swfdec/swfdec_as_object.h>
G_BEGIN_DECLS
diff --git a/test/rtmp/rtmp_server.c b/test/rtmp/rtmp_server.c
index ec431e8..a5f6362 100644
--- a/test/rtmp/rtmp_server.c
+++ b/test/rtmp/rtmp_server.c
@@ -22,7 +22,7 @@
#endif
#include <libsoup/soup.h>
#include <libsoup/soup-address.h>
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
#include <glib/gprintf.h>
static void
diff --git a/test/sound/sound.c b/test/sound/sound.c
index 332ca12..ab8f566 100644
--- a/test/sound/sound.c
+++ b/test/sound/sound.c
@@ -21,7 +21,7 @@
#include "config.h"
#endif
#include <string.h>
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
/**
* audio_diff:
diff --git a/test/swfdec_test.c b/test/swfdec_test.c
index 957b35b..35e99d1 100644
--- a/test/swfdec_test.c
+++ b/test/swfdec_test.c
@@ -24,10 +24,10 @@
#include <stdlib.h>
#include <string.h>
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
/* FIXME: no internal headers please */
-#include <libswfdec/swfdec_as_array.h>
-#include <libswfdec/swfdec_as_internal.h>
+#include <swfdec/swfdec_as_array.h>
+#include <swfdec/swfdec_as_internal.h>
#include "swfdec_test_function.h"
#include "swfdec_test_initialize.h"
diff --git a/test/swfdec_test_function.h b/test/swfdec_test_function.h
index 08b6c27..a523fcd 100644
--- a/test/swfdec_test_function.h
+++ b/test/swfdec_test_function.h
@@ -17,7 +17,7 @@
* Boston, MA 02110-1301 USA
*/
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
#ifndef _SWFDEC_TEST_FUNCTION_H_
#define _SWFDEC_TEST_FUNCTION_H_
diff --git a/test/swfdec_test_global.c b/test/swfdec_test_global.c
index 6926944..7edd8d2 100644
--- a/test/swfdec_test_global.c
+++ b/test/swfdec_test_global.c
@@ -21,7 +21,7 @@
#include "config.h"
#endif
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
#include "swfdec_test_function.h"
#include "swfdec_test_initialize.h"
diff --git a/test/swfdec_test_image.h b/test/swfdec_test_image.h
index ef5bb2a..6de6ccc 100644
--- a/test/swfdec_test_image.h
+++ b/test/swfdec_test_image.h
@@ -20,7 +20,7 @@
#ifndef _SWFDEC_TEST_IMAGE_H_
#define _SWFDEC_TEST_IMAGE_H_
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
G_BEGIN_DECLS
diff --git a/test/swfdec_test_test.h b/test/swfdec_test_test.h
index fe20221..aac940f 100644
--- a/test/swfdec_test_test.h
+++ b/test/swfdec_test_test.h
@@ -20,7 +20,7 @@
#ifndef _SWFDEC_TEST_TEST_H_
#define _SWFDEC_TEST_TEST_H_
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
G_BEGIN_DECLS
diff --git a/test/various/gc.c b/test/various/gc.c
index cb21202..6f485b6 100644
--- a/test/various/gc.c
+++ b/test/various/gc.c
@@ -21,9 +21,9 @@
#include "config.h"
#endif
-#include "libswfdec/swfdec_as_context.h"
-#include "libswfdec/swfdec_as_object.h"
-#include "libswfdec/swfdec_as_strings.h"
+#include "swfdec/swfdec_as_context.h"
+#include "swfdec/swfdec_as_object.h"
+#include "swfdec/swfdec_as_strings.h"
#define ERROR(...) G_STMT_START { \
g_printerr ("ERROR (line %u): ", __LINE__); \
diff --git a/test/various/ringbuffer.c b/test/various/ringbuffer.c
index 3f2c4dc..5be9da7 100644
--- a/test/various/ringbuffer.c
+++ b/test/various/ringbuffer.c
@@ -21,7 +21,7 @@
#include "config.h"
#endif
-#include "libswfdec/swfdec_ringbuffer.h"
+#include "swfdec/swfdec_ringbuffer.h"
#define SIZE 5
diff --git a/tools/crashfinder.c b/tools/crashfinder.c
index 5840862..956a5a6 100644
--- a/tools/crashfinder.c
+++ b/tools/crashfinder.c
@@ -22,7 +22,7 @@
#include "config.h"
#endif
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
int
main (int argc, char **argv)
diff --git a/tools/dump.c b/tools/dump.c
index 0ab7d59..1b8d701 100644
--- a/tools/dump.c
+++ b/tools/dump.c
@@ -29,20 +29,20 @@
#include <sys/stat.h>
#include <glib.h>
#include <glib-object.h>
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_button.h>
-#include <libswfdec/swfdec_text_field.h>
-#include <libswfdec/swfdec_font.h>
-#include <libswfdec/swfdec_image.h>
-#include <libswfdec/swfdec_movie.h>
-#include <libswfdec/swfdec_player_internal.h>
-#include <libswfdec/swfdec_sprite.h>
-#include <libswfdec/swfdec_shape.h>
-#include <libswfdec/swfdec_sound.h>
-#include <libswfdec/swfdec_swf_decoder.h>
-#include <libswfdec/swfdec_resource.h>
-#include <libswfdec/swfdec_tag.h>
-#include <libswfdec/swfdec_text.h>
+#include <swfdec/swfdec.h>
+#include <swfdec/swfdec_button.h>
+#include <swfdec/swfdec_text_field.h>
+#include <swfdec/swfdec_font.h>
+#include <swfdec/swfdec_image.h>
+#include <swfdec/swfdec_movie.h>
+#include <swfdec/swfdec_player_internal.h>
+#include <swfdec/swfdec_sprite.h>
+#include <swfdec/swfdec_shape.h>
+#include <swfdec/swfdec_sound.h>
+#include <swfdec/swfdec_swf_decoder.h>
+#include <swfdec/swfdec_resource.h>
+#include <swfdec/swfdec_tag.h>
+#include <swfdec/swfdec_text.h>
static gboolean verbose = FALSE;
diff --git a/tools/swfdec-extract.c b/tools/swfdec-extract.c
index 2c72f3b..b233818 100644
--- a/tools/swfdec-extract.c
+++ b/tools/swfdec-extract.c
@@ -31,17 +31,17 @@
#ifdef CAIRO_HAS_PDF_SURFACE
# include <cairo-pdf.h>
#endif
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_audio_stream.h>
-#include <libswfdec/swfdec_button.h>
-#include <libswfdec/swfdec_graphic.h>
-#include <libswfdec/swfdec_image.h>
-#include <libswfdec/swfdec_player_internal.h>
-#include <libswfdec/swfdec_sound.h>
-#include <libswfdec/swfdec_sprite.h>
-#include <libswfdec/swfdec_sprite_movie.h>
-#include <libswfdec/swfdec_swf_decoder.h>
-#include <libswfdec/swfdec_resource.h>
+#include <swfdec/swfdec.h>
+#include <swfdec/swfdec_audio_stream.h>
+#include <swfdec/swfdec_button.h>
+#include <swfdec/swfdec_graphic.h>
+#include <swfdec/swfdec_image.h>
+#include <swfdec/swfdec_player_internal.h>
+#include <swfdec/swfdec_sound.h>
+#include <swfdec/swfdec_sprite.h>
+#include <swfdec/swfdec_sprite_movie.h>
+#include <swfdec/swfdec_swf_decoder.h>
+#include <swfdec/swfdec_resource.h>
static SwfdecBuffer *
encode_wav (SwfdecBuffer *buffer, SwfdecAudioFormat format)
diff --git a/tools/swfdec_out.h b/tools/swfdec_out.h
index e343f9d..2544f33 100644
--- a/tools/swfdec_out.h
+++ b/tools/swfdec_out.h
@@ -20,9 +20,9 @@
#ifndef __SWFDEC_OUT_H__
#define __SWFDEC_OUT_H__
-#include <libswfdec/swfdec_buffer.h>
-#include <libswfdec/swfdec_color.h>
-#include <libswfdec/swfdec_rect.h>
+#include <swfdec/swfdec_buffer.h>
+#include <swfdec/swfdec_color.h>
+#include <swfdec/swfdec_rect.h>
G_BEGIN_DECLS
diff --git a/tools/swfedit_file.c b/tools/swfedit_file.c
index e257010..22684a3 100644
--- a/tools/swfedit_file.c
+++ b/tools/swfedit_file.c
@@ -23,10 +23,10 @@
#include <zlib.h>
-#include "libswfdec/swfdec_bits.h"
-#include "libswfdec/swfdec_buffer.h"
-#include "libswfdec/swfdec_debug.h"
-#include "libswfdec/swfdec_swf_decoder.h"
+#include "swfdec/swfdec_bits.h"
+#include "swfdec/swfdec_buffer.h"
+#include "swfdec/swfdec_debug.h"
+#include "swfdec/swfdec_swf_decoder.h"
#include "swfdec_out.h"
#include "swfedit_file.h"
#include "swfedit_tag.h"
diff --git a/tools/swfedit_file.h b/tools/swfedit_file.h
index ecd096a..212c7b7 100644
--- a/tools/swfedit_file.h
+++ b/tools/swfedit_file.h
@@ -20,7 +20,7 @@
#ifndef __SWFEDIT_FILE_H__
#define __SWFEDIT_FILE_H__
-#include <libswfdec/swfdec_rect.h>
+#include <swfdec/swfdec_rect.h>
#include "swfedit_token.h"
G_BEGIN_DECLS
diff --git a/tools/swfedit_tag.c b/tools/swfedit_tag.c
index 4a4bf67..868632c 100644
--- a/tools/swfedit_tag.c
+++ b/tools/swfedit_tag.c
@@ -24,10 +24,10 @@
#include <stdlib.h>
#include <gtk/gtk.h>
-#include <libswfdec/swfdec_bits.h>
-#include <libswfdec/swfdec_debug.h>
-#include <libswfdec/swfdec_script_internal.h>
-#include <libswfdec/swfdec_tag.h>
+#include <swfdec/swfdec_bits.h>
+#include <swfdec/swfdec_debug.h>
+#include <swfdec/swfdec_script_internal.h>
+#include <swfdec/swfdec_tag.h>
#include "swfedit_tag.h"
#include "swfdec_out.h"
#include "swfedit_file.h"
diff --git a/tools/swfedit_tag.h b/tools/swfedit_tag.h
index 2f1d231..b148f24 100644
--- a/tools/swfedit_tag.h
+++ b/tools/swfedit_tag.h
@@ -20,8 +20,8 @@
#ifndef __SWFEDIT_TAG_H__
#define __SWFEDIT_TAG_H__
-#include <libswfdec/swfdec_buffer.h>
-#include <libswfdec/swfdec_bits.h>
+#include <swfdec/swfdec_buffer.h>
+#include <swfdec/swfdec_bits.h>
#include "swfdec_out.h"
#include "swfedit_token.h"
diff --git a/tools/swfedit_token.c b/tools/swfedit_token.c
index 34496df..11bedfc 100644
--- a/tools/swfedit_token.c
+++ b/tools/swfedit_token.c
@@ -24,9 +24,9 @@
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
-#include <libswfdec/swfdec_buffer.h>
-#include <libswfdec/swfdec_color.h>
-#include <libswfdec/swfdec_script_internal.h>
+#include <swfdec/swfdec_buffer.h>
+#include <swfdec/swfdec_color.h>
+#include <swfdec/swfdec_script_internal.h>
#include "swfedit_token.h"
/*** CONVERTERS ***/
diff --git a/tools/swfedit_token.h b/tools/swfedit_token.h
index 448f4cb..c46e0ef 100644
--- a/tools/swfedit_token.h
+++ b/tools/swfedit_token.h
@@ -21,7 +21,7 @@
#define __SWFEDIT_TOKEN_H__
#include <gtk/gtk.h>
-#include <libswfdec/swfdec_rect.h>
+#include <swfdec/swfdec_rect.h>
G_BEGIN_DECLS
diff --git a/tools/swfscript.c b/tools/swfscript.c
index 4e2a9e4..71435f4 100644
--- a/tools/swfscript.c
+++ b/tools/swfscript.c
@@ -22,7 +22,7 @@
#endif
#include <gtk/gtk.h>
-#include "libswfdec/swfdec_script_internal.h"
+#include "swfdec/swfdec_script_internal.h"
#include "swfdec_out.h"
#include "swfedit_file.h"
diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c
index ab41662..623e293 100644
--- a/vivified/core/vivi_application.c
+++ b/vivified/core/vivi_application.c
@@ -21,7 +21,7 @@
#include "config.h"
#endif
-#include <libswfdec-gtk/swfdec-gtk.h>
+#include <swfdec-gtk/swfdec-gtk.h>
#include "vivi_application.h"
#include "vivi_debugger.h"
#include "vivi_function.h"
diff --git a/vivified/core/vivi_application.h b/vivified/core/vivi_application.h
index d5d0c2b..0ebe0fd 100644
--- a/vivified/core/vivi_application.h
+++ b/vivified/core/vivi_application.h
@@ -20,7 +20,7 @@
#ifndef _VIVI_APPLICATION_H_
#define _VIVI_APPLICATION_H_
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
G_BEGIN_DECLS
diff --git a/vivified/core/vivi_breakpoint.h b/vivified/core/vivi_breakpoint.h
index 35a8d28..ed9af66 100644
--- a/vivified/core/vivi_breakpoint.h
+++ b/vivified/core/vivi_breakpoint.h
@@ -20,7 +20,7 @@
#ifndef _VIVI_BREAKPOINT_H_
#define _VIVI_BREAKPOINT_H_
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
#include <vivified/core/vivi_application.h>
G_BEGIN_DECLS
diff --git a/vivified/core/vivi_debugger.c b/vivified/core/vivi_debugger.c
index b65392f..98f4466 100644
--- a/vivified/core/vivi_debugger.c
+++ b/vivified/core/vivi_debugger.c
@@ -25,7 +25,7 @@
#include "vivi_application.h"
#include "vivi_marshal.h"
/* FIXME: oops */
-#include "libswfdec/swfdec_player_internal.h"
+#include "swfdec/swfdec_player_internal.h"
enum {
ADD,
diff --git a/vivified/core/vivi_debugger.h b/vivified/core/vivi_debugger.h
index 76873ab..80a6765 100644
--- a/vivified/core/vivi_debugger.h
+++ b/vivified/core/vivi_debugger.h
@@ -20,7 +20,7 @@
#ifndef _VIVI_DEBUGGER_H_
#define _VIVI_DEBUGGER_H_
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
#include <vivified/core/vivi_application.h>
G_BEGIN_DECLS
diff --git a/vivified/core/vivi_function.h b/vivified/core/vivi_function.h
index 2642579..f1d497c 100644
--- a/vivified/core/vivi_function.h
+++ b/vivified/core/vivi_function.h
@@ -17,7 +17,7 @@
* Boston, MA 02110-1301 USA
*/
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
#include <vivified/core/vivi_application.h>
#ifndef _VIVI_FUNCTION_H_
diff --git a/vivified/core/vivi_ming.h b/vivified/core/vivi_ming.h
index 98d3b85..f33eb5a 100644
--- a/vivified/core/vivi_ming.h
+++ b/vivified/core/vivi_ming.h
@@ -17,7 +17,7 @@
* Boston, MA 02110-1301 USA
*/
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
#include <ming.h>
#ifndef _VIVI_MING_H_
diff --git a/vivified/core/vivi_player_as.c b/vivified/core/vivi_player_as.c
index 4552cd4..f2d79e8 100644
--- a/vivified/core/vivi_player_as.c
+++ b/vivified/core/vivi_player_as.c
@@ -24,7 +24,7 @@
#include "vivi_wrap.h"
#include "vivi_application.h"
#include "vivi_function.h"
-#include <libswfdec-gtk/swfdec-gtk.h>
+#include <swfdec-gtk/swfdec-gtk.h>
VIVI_FUNCTION ("player_frame_get", vivi_player_as_frame_get)
void
diff --git a/vivified/core/vivi_wrap.h b/vivified/core/vivi_wrap.h
index 2c551e0..9f0aec0 100644
--- a/vivified/core/vivi_wrap.h
+++ b/vivified/core/vivi_wrap.h
@@ -20,7 +20,7 @@
#ifndef _VIVI_WRAP_H_
#define _VIVI_WRAP_H_
-#include <libswfdec/swfdec.h>
+#include <swfdec/swfdec.h>
#include <vivified/core/vivi_application.h>
G_BEGIN_DECLS
diff --git a/vivified/ui/main.c b/vivified/ui/main.c
index 3462be6..38568ec 100644
--- a/vivified/ui/main.c
+++ b/vivified/ui/main.c
@@ -22,7 +22,7 @@
#endif
#include <gtk/gtk.h>
-#include <libswfdec-gtk/swfdec-gtk.h>
+#include <swfdec-gtk/swfdec-gtk.h>
#include "vivified/core/vivified-core.h"
#include "vivified/dock/vivified-dock.h"
#include "vivi_window.h"
diff --git a/vivified/ui/vivi_movie_list.c b/vivified/ui/vivi_movie_list.c
index 35aa0dd..61a471f 100644
--- a/vivified/ui/vivi_movie_list.c
+++ b/vivified/ui/vivi_movie_list.c
@@ -22,8 +22,8 @@
#endif
#include <gtk/gtk.h>
-#include <libswfdec/swfdec_movie.h>
-#include <libswfdec/swfdec_player_internal.h>
+#include <swfdec/swfdec_movie.h>
+#include <swfdec/swfdec_player_internal.h>
#include "vivi_movie_list.h"
/*** GTK_TREE_MODEL ***/
diff --git a/vivified/ui/vivi_movies.c b/vivified/ui/vivi_movies.c
index a4c8e37..cc88466 100644
--- a/vivified/ui/vivi_movies.c
+++ b/vivified/ui/vivi_movies.c
@@ -21,7 +21,7 @@
#include "config.h"
#endif
-#include <libswfdec-gtk/swfdec-gtk.h>
+#include <swfdec-gtk/swfdec-gtk.h>
#include "vivi_vivi_docklet.h"
#include "vivi_movie_list.h"
diff --git a/vivified/ui/vivi_player.c b/vivified/ui/vivi_player.c
index e8134b2..f456e07 100644
--- a/vivified/ui/vivi_player.c
+++ b/vivified/ui/vivi_player.c
@@ -21,7 +21,7 @@
#include "config.h"
#endif
-#include <libswfdec-gtk/swfdec-gtk.h>
+#include <swfdec-gtk/swfdec-gtk.h>
#include "vivi_vivi_docklet.h"
#include "vivi_widget.h"
diff --git a/vivified/ui/vivi_widget.h b/vivified/ui/vivi_widget.h
index b861ed1..f7d4727 100644
--- a/vivified/ui/vivi_widget.h
+++ b/vivified/ui/vivi_widget.h
@@ -20,7 +20,7 @@
#ifndef _VIVI_WIDGET_H_
#define _VIVI_WIDGET_H_
-#include <libswfdec-gtk/swfdec-gtk.h>
+#include <swfdec-gtk/swfdec-gtk.h>
#include <vivified/core/vivified-core.h>
G_BEGIN_DECLS
diff --git a/vivified/ui/vivi_window.h b/vivified/ui/vivi_window.h
index 80c0b27..7edcd5a 100644
--- a/vivified/ui/vivi_window.h
+++ b/vivified/ui/vivi_window.h
@@ -23,7 +23,7 @@
#include <vivified/dock/vivified-dock.h>
#include <vivified/core/vivified-core.h>
/* FIXME */
-#include <libswfdec/swfdec_movie.h>
+#include <swfdec/swfdec_movie.h>
G_BEGIN_DECLS
commit 8bd46798336662f4167d967791aac394ed1881c6
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jan 24 13:09:46 2008 +0100
rename "libswfdec" to "swfdec" and "libswfdec-gtk" to "swfdec-gtk"
diff --git a/libswfdec-gtk/.gitignore b/libswfdec-gtk/.gitignore
deleted file mode 100644
index cad6c66..0000000
--- a/libswfdec-gtk/.gitignore
+++ /dev/null
@@ -1,14 +0,0 @@
-*~
-CVS
-.cvsignore
-.deps
-.libs
-
-Makefile
-Makefile.in
-*.o
-*.la
-*.lo
-*.loT
-
-swfdec_playback.c
diff --git a/libswfdec-gtk/Makefile.am b/libswfdec-gtk/Makefile.am
deleted file mode 100644
index 4f724cf..0000000
--- a/libswfdec-gtk/Makefile.am
+++ /dev/null
@@ -1,45 +0,0 @@
-# this workaround is needed or autotools don't generate the .deps/*.Plo files correctly
-swfdec_playback.c: swfdec_playback_$(AUDIO_TYPE).c Makefile
- cmp -s $(srcdir)/swfdec_playback_$(AUDIO_TYPE).c swfdec_playback.c \
- || cp $(srcdir)/swfdec_playback_$(AUDIO_TYPE).c swfdec_playback.c
-
-BUILT_SOURCES = swfdec_playback.c
-CLEANFILES = swfdec_playback.c
-
-lib_LTLIBRARIES = libswfdec-gtk- at SWFDEC_MAJORMINOR@.la
-
-libswfdec_gtk_ at SWFDEC_MAJORMINOR@_la_SOURCES = \
- swfdec_playback.c \
- swfdec_source.c \
- swfdec_gtk_keys.c \
- swfdec_gtk_loader.c \
- swfdec_gtk_player.c \
- swfdec_gtk_socket.c \
- swfdec_gtk_widget.c
-
-noinst_HEADERS = \
- swfdec_playback.h \
- swfdec_source.h
-
-libswfdec_gtk_ at SWFDEC_MAJORMINOR@_la_CFLAGS = \
- -I$(top_srcdir) $(GLOBAL_CFLAGS) $(SWFDEC_CFLAGS) $(GTK_CFLAGS) \
- $(AUDIO_CFLAGS) \
- -DG_LOG_DOMAIN=\"Swfdec-Gtk\"
-libswfdec_gtk_ at SWFDEC_MAJORMINOR@_la_LDFLAGS = \
- -version-info $(SWFDEC_LIBVERSION) \
- -export-symbols-regex '^(swfdec_.*)' \
- $(GTK_LIBS) $(SWFDEC_LIBS) $(AUDIO_LIBS)
-libswfdec_ at SWFDEC_MAJORMINOR@includedir = $(includedir)/swfdec- at SWFDEC_MAJORMINOR@/libswfdec-gtk
-libswfdec_ at SWFDEC_MAJORMINOR@include_HEADERS = \
- swfdec-gtk.h \
- swfdec_gtk_keys.h \
- swfdec_gtk_loader.h \
- swfdec_gtk_player.h \
- swfdec_gtk_socket.h \
- swfdec_gtk_widget.h
-
-EXTRA_DIST = \
- swfdec_playback_alsa.c \
- swfdec_playback_oss.c \
- swfdec_playback_pa.c \
- swfdec_playback_none.c
diff --git a/libswfdec-gtk/swfdec-gtk.h b/libswfdec-gtk/swfdec-gtk.h
deleted file mode 100644
index b64cf83..0000000
--- a/libswfdec-gtk/swfdec-gtk.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef __SWFDEC_GTK_H__
-#define __SWFDEC_GTK_H__
-
-#include <libswfdec-gtk/swfdec_gtk_keys.h>
-#include <libswfdec-gtk/swfdec_gtk_loader.h>
-#include <libswfdec-gtk/swfdec_gtk_player.h>
-#include <libswfdec-gtk/swfdec_gtk_socket.h>
-#include <libswfdec-gtk/swfdec_gtk_widget.h>
-
-#endif
diff --git a/libswfdec-gtk/swfdec_gtk_keys.c b/libswfdec-gtk/swfdec_gtk_keys.c
deleted file mode 100644
index 69e0a6e..0000000
--- a/libswfdec-gtk/swfdec_gtk_keys.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "swfdec_gtk_keys.h"
-
-static const guint8 flash_keycodes[] = {
- /* 0 */ 0, 0, 0, 0, 0,
- /* 5 */ 0, 0, 0, 0, SWFDEC_KEY_ESCAPE,
- /* 10 */ SWFDEC_KEY_1, SWFDEC_KEY_2, SWFDEC_KEY_3, SWFDEC_KEY_4, SWFDEC_KEY_5,
- /* 15 */ SWFDEC_KEY_6, SWFDEC_KEY_7, SWFDEC_KEY_8, SWFDEC_KEY_9, SWFDEC_KEY_0,
- /* 20 */ SWFDEC_KEY_MINUS, SWFDEC_KEY_EQUAL, SWFDEC_KEY_BACKSPACE, SWFDEC_KEY_TAB, SWFDEC_KEY_Q,
- /* 25 */ SWFDEC_KEY_W, SWFDEC_KEY_E, SWFDEC_KEY_R, SWFDEC_KEY_T, SWFDEC_KEY_Y,
- /* 30 */ SWFDEC_KEY_U, SWFDEC_KEY_I, SWFDEC_KEY_O, SWFDEC_KEY_P, SWFDEC_KEY_LEFT_BRACKET,
- /* 35 */ SWFDEC_KEY_RIGHT_BRACKET, SWFDEC_KEY_ENTER, SWFDEC_KEY_CONTROL, SWFDEC_KEY_A, SWFDEC_KEY_S,
- /* 40 */ SWFDEC_KEY_D, SWFDEC_KEY_F, SWFDEC_KEY_G, SWFDEC_KEY_H, SWFDEC_KEY_J,
- /* 45 */ SWFDEC_KEY_K, SWFDEC_KEY_L, SWFDEC_KEY_SEMICOLON, SWFDEC_KEY_APOSTROPHE, SWFDEC_KEY_GRAVE,
- /* 50 */ SWFDEC_KEY_SHIFT, SWFDEC_KEY_BACKSLASH, SWFDEC_KEY_Z, SWFDEC_KEY_X, SWFDEC_KEY_C,
- /* 55 */ SWFDEC_KEY_V, SWFDEC_KEY_B, SWFDEC_KEY_N, SWFDEC_KEY_M, 0,
- /* 60 */ 0, SWFDEC_KEY_SLASH, SWFDEC_KEY_SHIFT, SWFDEC_KEY_NUMPAD_MULTIPLY, SWFDEC_KEY_ALT,
- /* 65 */ SWFDEC_KEY_SPACE, 0, SWFDEC_KEY_F1, SWFDEC_KEY_F2, SWFDEC_KEY_F3,
- /* 70 */ SWFDEC_KEY_F4, SWFDEC_KEY_F5, SWFDEC_KEY_F6, SWFDEC_KEY_F7, SWFDEC_KEY_F8,
- /* 75 */ SWFDEC_KEY_F9, SWFDEC_KEY_F10, SWFDEC_KEY_NUM_LOCK, 0, SWFDEC_KEY_NUMPAD_7,
- /* 80 */ SWFDEC_KEY_NUMPAD_8, SWFDEC_KEY_NUMPAD_9, SWFDEC_KEY_NUMPAD_SUBTRACT, SWFDEC_KEY_NUMPAD_4, SWFDEC_KEY_NUMPAD_5,
- /* 85 */ SWFDEC_KEY_NUMPAD_6, SWFDEC_KEY_NUMPAD_ADD, SWFDEC_KEY_NUMPAD_1, SWFDEC_KEY_NUMPAD_2, SWFDEC_KEY_NUMPAD_3,
- /* 90 */ SWFDEC_KEY_NUMPAD_0, SWFDEC_KEY_NUMPAD_DECIMAL, 0, 0, 0,
- /* 95 */ SWFDEC_KEY_F11, SWFDEC_KEY_F12, SWFDEC_KEY_HOME, SWFDEC_KEY_UP, SWFDEC_KEY_PAGE_UP,
- /* 100 */ SWFDEC_KEY_LEFT, 0, SWFDEC_KEY_RIGHT, SWFDEC_KEY_END, SWFDEC_KEY_DOWN,
- /* 105 */ SWFDEC_KEY_PAGE_DOWN, SWFDEC_KEY_INSERT, SWFDEC_KEY_DELETE, SWFDEC_KEY_ENTER, SWFDEC_KEY_CONTROL,
- /* 110 */ 0, 0, SWFDEC_KEY_NUMPAD_DIVIDE, SWFDEC_KEY_ALT, 0,
- /* 115 */ 0, 0, 0, 0, 0
-};
-/*
-SWFDEC_KEY_COMMA 59
-SWFDEC_KEY_DOT 60
-SWFDEC_KEY_SCROLL_LOCK 78
-SWFDEC_KEY_BREAK 110
-SWFDEC_KEY_META 115
-SWFDEC_KEY_META_R 116
-SWFDEC_KEY_MENU 117
-*/
-
-/**
- * swfdec_gtk_keycode_from_hardware_keycode:
- * @hardware_keycode: a hardware keycode sent from the X server
- *
- * Tries to transform an X hardware keycode to the corresponding #SwfdecKey.
- * This is a utility function for cases where key events need to be transformed
- * manually.
- *
- * Returns: the corresponding key code as used in Flash.
- **/
-guint
-swfdec_gtk_keycode_from_hardware_keycode (guint hardware_keycode)
-{
- if (hardware_keycode >= G_N_ELEMENTS (flash_keycodes))
- return 0;
- return flash_keycodes[hardware_keycode];
-}
diff --git a/libswfdec-gtk/swfdec_gtk_keys.h b/libswfdec-gtk/swfdec_gtk_keys.h
deleted file mode 100644
index d9b985b..0000000
--- a/libswfdec-gtk/swfdec_gtk_keys.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_GTK_KEYS_H_
-#define _SWFDEC_GTK_KEYS_H_
-
-#include <libswfdec/swfdec.h>
-
-G_BEGIN_DECLS
-
-guint swfdec_gtk_keycode_from_hardware_keycode (guint hardware_keycode);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec-gtk/swfdec_gtk_loader.c b/libswfdec-gtk/swfdec_gtk_loader.c
deleted file mode 100644
index 375ca60..0000000
--- a/libswfdec-gtk/swfdec_gtk_loader.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <libsoup/soup.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include "swfdec_gtk_loader.h"
-
-/*** GTK-DOC ***/
-
-/**
- * SECTION:SwfdecGtkLoader
- * @title: SwfdecGtkLoader
- * @short_description: advanced loader able to load network ressources
- * @see_also: #SwfdecLoader
- *
- * #SwfdecGtkLoader is a #SwfdecLoader that is intended as an easy way to be
- * access ressources that are not stored in files, such as HTTP. It can
- * however be compiled with varying support for different protocols, so don't
- * rely on support for a particular protocol being available. If you need this,
- * code your own SwfdecLoader subclass.
- */
-
-/**
- * SwfdecGtkLoader:
- *
- * This is the object used to represent a loader. Since it may use varying
- * backends, it is completely private.
- */
-
-struct _SwfdecGtkLoader
-{
- SwfdecLoader loader;
-
- SoupMessage * message; /* the message we're sending */
- gboolean opened; /* set after first bytes of data have arrived */
-};
-
-struct _SwfdecGtkLoaderClass {
- SwfdecLoaderClass loader_class;
-
- SoupSession * session; /* the session used by the loader */
-};
-
-/*** SwfdecGtkLoader ***/
-
-G_DEFINE_TYPE (SwfdecGtkLoader, swfdec_gtk_loader, SWFDEC_TYPE_FILE_LOADER)
-
-static void
-swfdec_gtk_loader_set_size (SwfdecGtkLoader *gtk)
-{
- const char *s = soup_message_get_header (gtk->message->response_headers, "Content-Length");
- unsigned long l;
- char *end;
-
- if (s == NULL)
- return;
-
- errno = 0;
- l = strtoul (s, &end, 10);
- if (errno == 0 && *end == 0 && l <= G_MAXLONG)
- swfdec_loader_set_size (SWFDEC_LOADER (gtk), l);
-}
-
-static void
-swfdec_gtk_loader_ensure_open (SwfdecGtkLoader *gtk)
-{
- char *real_uri;
-
- if (gtk->opened)
- return;
-
- real_uri = soup_uri_to_string (soup_message_get_uri (gtk->message), FALSE);
- swfdec_gtk_loader_set_size (gtk);
- swfdec_loader_set_url (SWFDEC_LOADER (gtk), real_uri);
- swfdec_stream_open (SWFDEC_STREAM (gtk));
- gtk->opened = TRUE;
- g_free (real_uri);
-}
-
-static void
-swfdec_gtk_loader_push (SoupMessage *msg, gpointer loader)
-{
- SwfdecGtkLoader *gtk = SWFDEC_GTK_LOADER (loader);
- SwfdecBuffer *buffer;
-
- swfdec_gtk_loader_ensure_open (gtk);
- buffer = swfdec_buffer_new_and_alloc (msg->response.length);
- memcpy (buffer->data, msg->response.body, msg->response.length);
- swfdec_stream_push (loader, buffer);
-}
-
-static void
-swfdec_gtk_loader_finished (SoupMessage *msg, gpointer loader)
-{
- if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
- swfdec_gtk_loader_ensure_open (loader);
- swfdec_stream_eof (loader);
- } else {
- swfdec_stream_error (loader, "%u %s", msg->status_code, msg->reason_phrase);
- }
-}
-
-static void
-swfdec_gtk_loader_dispose (GObject *object)
-{
- SwfdecGtkLoader *gtk = SWFDEC_GTK_LOADER (object);
-
- if (gtk->message) {
- g_signal_handlers_disconnect_by_func (gtk->message, swfdec_gtk_loader_push, gtk);
- g_signal_handlers_disconnect_by_func (gtk->message, swfdec_gtk_loader_finished, gtk);
- g_object_unref (gtk->message);
- gtk->message = NULL;
- }
-
- G_OBJECT_CLASS (swfdec_gtk_loader_parent_class)->dispose (object);
-}
-
-static void
-swfdec_gtk_loader_load (SwfdecLoader *loader, SwfdecPlayer *player,
- const char *url_string, SwfdecLoaderRequest request, SwfdecBuffer *buffer)
-{
- SwfdecURL *url;
-
- if (swfdec_url_path_is_relative (url_string)) {
- url = swfdec_url_new_relative (swfdec_player_get_base_url (player), url_string);
- } else {
- url = swfdec_url_new (url_string);
- }
-
- if (url == NULL) {
- swfdec_stream_error (SWFDEC_STREAM (loader), "invalid URL %s", url_string);
- return;
- };
- if (!swfdec_url_has_protocol (url, "http") &&
- !swfdec_url_has_protocol (url, "https")) {
- SWFDEC_LOADER_CLASS (swfdec_gtk_loader_parent_class)->load (loader, player,
- url_string, request, buffer);
- } else {
- SwfdecGtkLoader *gtk = SWFDEC_GTK_LOADER (loader);
- SwfdecGtkLoaderClass *klass = SWFDEC_GTK_LOADER_GET_CLASS (gtk);
-
- gtk->message = soup_message_new (request == SWFDEC_LOADER_REQUEST_POST ? "POST" : "GET",
- swfdec_url_get_url (url));
- soup_message_set_flags (gtk->message, SOUP_MESSAGE_OVERWRITE_CHUNKS);
- g_signal_connect (gtk->message, "got-chunk", G_CALLBACK (swfdec_gtk_loader_push), gtk);
- g_signal_connect (gtk->message, "finished", G_CALLBACK (swfdec_gtk_loader_finished), gtk);
- if (buffer)
- soup_message_set_request (gtk->message, "appliation/x-www-urlencoded",
- SOUP_BUFFER_USER_OWNED, (char *) buffer->data, buffer->length);
- g_object_ref (gtk->message);
- soup_session_queue_message (klass->session, gtk->message, NULL, NULL);
- }
- swfdec_url_free (url);
-}
-
-static void
-swfdec_gtk_loader_close (SwfdecStream *stream)
-{
- SwfdecGtkLoader *gtk = SWFDEC_GTK_LOADER (stream);
-
- if (gtk->message) {
- gboolean eof;
-
- g_object_get (stream, "eof", &eof, NULL);
- if (!eof) {
- SwfdecGtkLoaderClass *klass = SWFDEC_GTK_LOADER_GET_CLASS (gtk);
-
- soup_session_cancel_message (klass->session, gtk->message);
- g_object_unref (gtk->message);
- gtk->message = NULL;
- }
- }
-}
-
-static void
-swfdec_gtk_loader_class_init (SwfdecGtkLoaderClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- SwfdecStreamClass *stream_class = SWFDEC_STREAM_CLASS (klass);
- SwfdecLoaderClass *loader_class = SWFDEC_LOADER_CLASS (klass);
-
- object_class->dispose = swfdec_gtk_loader_dispose;
-
- stream_class->close = swfdec_gtk_loader_close;
-
- loader_class->load = swfdec_gtk_loader_load;
-
- klass->session = soup_session_async_new ();
-}
-
-static void
-swfdec_gtk_loader_init (SwfdecGtkLoader *gtk_loader)
-{
-}
-
diff --git a/libswfdec-gtk/swfdec_gtk_loader.h b/libswfdec-gtk/swfdec_gtk_loader.h
deleted file mode 100644
index ccae174..0000000
--- a/libswfdec-gtk/swfdec_gtk_loader.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_GTK_LOADER_H_
-#define _SWFDEC_GTK_LOADER_H_
-
-#include <libswfdec/swfdec.h>
-
-G_BEGIN_DECLS
-
-
-typedef struct _SwfdecGtkLoader SwfdecGtkLoader;
-typedef struct _SwfdecGtkLoaderClass SwfdecGtkLoaderClass;
-
-#define SWFDEC_TYPE_GTK_LOADER (swfdec_gtk_loader_get_type())
-#define SWFDEC_IS_GTK_LOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_GTK_LOADER))
-#define SWFDEC_IS_GTK_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_GTK_LOADER))
-#define SWFDEC_GTK_LOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_GTK_LOADER, SwfdecGtkLoader))
-#define SWFDEC_GTK_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_GTK_LOADER, SwfdecGtkLoaderClass))
-#define SWFDEC_GTK_LOADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_GTK_LOADER, SwfdecGtkLoaderClass))
-
-GType swfdec_gtk_loader_get_type (void);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec-gtk/swfdec_gtk_player.c b/libswfdec-gtk/swfdec_gtk_player.c
deleted file mode 100644
index 6d0a0a3..0000000
--- a/libswfdec-gtk/swfdec_gtk_player.c
+++ /dev/null
@@ -1,315 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "libswfdec-gtk/swfdec_gtk_loader.h"
-#include "libswfdec-gtk/swfdec_gtk_player.h"
-#include "libswfdec-gtk/swfdec_gtk_socket.h"
-#include "libswfdec-gtk/swfdec_playback.h"
-#include "libswfdec-gtk/swfdec_source.h"
-
-struct _SwfdecGtkPlayer
-{
- SwfdecPlayer player;
-
- GSource * source; /* source if playing, NULL otherwise */
- SwfdecPlayback * playback; /* audio playback object */
- gboolean audio_enabled; /* TRUE if audio should be played */
- double speed; /* desired playback speed */
-};
-
-struct _SwfdecGtkPlayerClass
-{
- SwfdecPlayerClass player_class;
-};
-
-enum {
- PROP_0,
- PROP_PLAYING,
- PROP_AUDIO,
- PROP_SPEED
-};
-
-/*** gtk-doc ***/
-
-/**
- * SECTION:SwfdecGtkPlayer
- * @title: SwfdecGtkPlayer
- * @short_description: an improved #SwfdecPlayer
- *
- * The #SwfdecGtkPlayer adds common functionality to the rather barebones
- * #SwfdecPlayer class, such as automatic playback and audio handling. Note
- * that by default, the player will be paused, so you need to call
- * swfdec_gtk_player_set_playing () on the new player.
- *
- * @see_also: SwfdecPlayer
- */
-
-/**
- * SwfdecGtkPlayer:
- *
- * The structure for the Swfdec Gtk player contains no public fields.
- */
-
-/*** SWFDEC_GTK_PLAYER ***/
-
-G_DEFINE_TYPE (SwfdecGtkPlayer, swfdec_gtk_player, SWFDEC_TYPE_PLAYER)
-
-static void
-swfdec_gtk_player_get_property (GObject *object, guint param_id, GValue *value,
- GParamSpec * pspec)
-{
- SwfdecGtkPlayer *player = SWFDEC_GTK_PLAYER (object);
-
- switch (param_id) {
- case PROP_PLAYING:
- g_value_set_boolean (value, player->source != NULL);
- break;
- case PROP_AUDIO:
- g_value_set_boolean (value, player->audio_enabled);
- break;
- case PROP_SPEED:
- g_value_set_double (value, player->speed);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-swfdec_gtk_player_set_property (GObject *object, guint param_id, const GValue *value,
- GParamSpec *pspec)
-{
- SwfdecGtkPlayer *player = SWFDEC_GTK_PLAYER (object);
-
- switch (param_id) {
- case PROP_PLAYING:
- swfdec_gtk_player_set_playing (player, g_value_get_boolean (value));
- break;
- case PROP_AUDIO:
- swfdec_gtk_player_set_audio_enabled (player, g_value_get_boolean (value));
- break;
- case PROP_SPEED:
- swfdec_gtk_player_set_speed (player, g_value_get_double (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-swfdec_gtk_player_dispose (GObject *object)
-{
- SwfdecGtkPlayer *player = SWFDEC_GTK_PLAYER (object);
-
- swfdec_gtk_player_set_playing (player, FALSE);
- g_assert (player->playback == NULL);
-
- G_OBJECT_CLASS (swfdec_gtk_player_parent_class)->dispose (object);
-}
-
-static void
-swfdec_gtk_player_class_init (SwfdecGtkPlayerClass * g_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (g_class);
-
- object_class->dispose = swfdec_gtk_player_dispose;
- object_class->get_property = swfdec_gtk_player_get_property;
- object_class->set_property = swfdec_gtk_player_set_property;
-
- g_object_class_install_property (object_class, PROP_PLAYING,
- g_param_spec_boolean ("playing", "playing", "TRUE if the player is playing (d'oh)",
- FALSE, G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_AUDIO,
- g_param_spec_boolean ("audio-enabled", "audio enabled", "TRUE if automatic audio handling is enabled",
- TRUE, G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_SPEED,
- g_param_spec_double ("speed", "speed", "desired playback speed",
- G_MINDOUBLE, G_MAXDOUBLE, 1.0, G_PARAM_READWRITE));
-}
-
-static void
-swfdec_gtk_player_init (SwfdecGtkPlayer * player)
-{
- player->speed = 1.0;
- player->audio_enabled = TRUE;
-}
-
-/*** PUBLIC API ***/
-
-/**
- * swfdec_gtk_player_new:
- * @debugger: %NULL or a #SwfdecAsDebugger to debug this player
- *
- * Creates a new Swfdec Gtk player.
- * This function calls swfdec_init () for you if it wasn't called before.
- *
- * Returns: The new player
- **/
-SwfdecPlayer *
-swfdec_gtk_player_new (SwfdecAsDebugger *debugger)
-{
- SwfdecPlayer *player;
-
- swfdec_init ();
- player = g_object_new (SWFDEC_TYPE_GTK_PLAYER,
- "loader-type", SWFDEC_TYPE_GTK_LOADER, "socket-type", SWFDEC_TYPE_GTK_SOCKET,
- "debugger", debugger, NULL);
-
- return player;
-}
-
-static void
-swfdec_gtk_player_update_audio (SwfdecGtkPlayer *player)
-{
- gboolean should_play = player->audio_enabled;
-
- should_play &= (player->source != NULL);
- should_play &= (player->speed == 1.0);
-
- if (should_play && player->playback == NULL) {
- player->playback = swfdec_playback_open (SWFDEC_PLAYER (player),
- g_main_context_default ());
- } else if (!should_play && player->playback != NULL) {
- swfdec_playback_close (player->playback);
- player->playback = NULL;
- }
-}
-
-/**
- * swfdec_gtk_player_set_playing:
- * @player: a #SwfdecGtkPlayer
- * @playing: if the player should play or not
- *
- * Sets if @player should be playing or not. If the player is playing, a timer
- * will be attached to the default main loop that periodically calls
- * swfdec_player_advance().
- **/
-void
-swfdec_gtk_player_set_playing (SwfdecGtkPlayer *player, gboolean playing)
-{
- g_return_if_fail (SWFDEC_IS_GTK_PLAYER (player));
-
- if (playing && player->source == NULL) {
- player->source = swfdec_iterate_source_new (SWFDEC_PLAYER (player), player->speed);
- g_source_attach (player->source, NULL);
- } else if (!playing && player->source != NULL) {
- g_source_destroy (player->source);
- g_source_unref (player->source);
- player->source = NULL;
- }
- swfdec_gtk_player_update_audio (player);
- g_object_notify (G_OBJECT (player), "playing");
-}
-
-/**
- * swfdec_gtk_player_get_playing:
- * @player: a #SwfdecGtkPlayer
- *
- * Queries if the player is playing.
- *
- * Returns: %TRUE if the player is playing
- **/
-gboolean
-swfdec_gtk_player_get_playing (SwfdecGtkPlayer *player)
-{
- g_return_val_if_fail (SWFDEC_IS_GTK_PLAYER (player), FALSE);
-
- return player->source != NULL;
-}
-
-/**
- * swfdec_gtk_player_set_audio_enabled:
- * @player: a #SwfdecGtkPlayer
- * @enabled: %TRUE to enable audio
- *
- * Enables or disables automatic audio playback.
- **/
-void
-swfdec_gtk_player_set_audio_enabled (SwfdecGtkPlayer *player, gboolean enabled)
-{
- g_return_if_fail (SWFDEC_IS_GTK_PLAYER (player));
-
- if (player->audio_enabled == enabled)
- return;
- player->audio_enabled = enabled;
- swfdec_gtk_player_update_audio (player);
- g_object_notify (G_OBJECT (player), "audio-enabled");
-}
-
-/**
- * swfdec_gtk_player_get_audio_enabled:
- * @player: a #SwfdecGtkPlayer
- *
- * Queries if audio playback for @player is enabled or not.
- *
- * Returns: %TRUE if audio playback is enabled
- **/
-gboolean
-swfdec_gtk_player_get_audio_enabled (SwfdecGtkPlayer *player)
-{
- g_return_val_if_fail (SWFDEC_IS_GTK_PLAYER (player), FALSE);
-
- return player->audio_enabled;
-}
-
-/**
- * swfdec_gtk_player_set_speed:
- * @player: a #SwfdecGtkPlayer
- * @speed: the new playback speed
- *
- * Sets the new playback speed. 1.0 means the default speed, bigger values
- * make playback happen faster. Audio will only play back if the speed is
- * 1.0. Note that if the player is not playing when calling this function,
- * it will not automatically start.
- **/
-void
-swfdec_gtk_player_set_speed (SwfdecGtkPlayer *player, double speed)
-{
- g_return_if_fail (SWFDEC_IS_GTK_PLAYER (player));
- g_return_if_fail (speed > 0.0);
-
- player->speed = speed;
- swfdec_gtk_player_update_audio (player);
- if (player->source)
- swfdec_iterate_source_set_speed (player->source, player->speed);
- g_object_notify (G_OBJECT (player), "speed");
-}
-
-/**
- * swfdec_gtk_player_get_speed:
- * @player: a #SwfdecGtkPlayer
- *
- * Queries the current playback speed. If the player is currently paused, it
- * will report the speed that it would use if playing.
- *
- * Returns: the current playback speed.
- **/
-double
-swfdec_gtk_player_get_speed (SwfdecGtkPlayer *player)
-{
- g_return_val_if_fail (SWFDEC_IS_GTK_PLAYER (player), FALSE);
-
- return player->speed;
-}
diff --git a/libswfdec-gtk/swfdec_gtk_player.h b/libswfdec-gtk/swfdec_gtk_player.h
deleted file mode 100644
index 3ff77bf..0000000
--- a/libswfdec-gtk/swfdec_gtk_player.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_GTK_PLAYER_H_
-#define _SWFDEC_GTK_PLAYER_H_
-
-#include <libswfdec/swfdec.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecGtkPlayer SwfdecGtkPlayer;
-typedef struct _SwfdecGtkPlayerClass SwfdecGtkPlayerClass;
-
-#define SWFDEC_TYPE_GTK_PLAYER (swfdec_gtk_player_get_type())
-#define SWFDEC_IS_GTK_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_GTK_PLAYER))
-#define SWFDEC_IS_GTK_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_GTK_PLAYER))
-#define SWFDEC_GTK_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_GTK_PLAYER, SwfdecGtkPlayer))
-#define SWFDEC_GTK_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_GTK_PLAYER, SwfdecGtkPlayerClass))
-#define SWFDEC_GTK_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_GTK_PLAYER, SwfdecGtkPlayerClass))
-
-GType swfdec_gtk_player_get_type (void);
-
-SwfdecPlayer * swfdec_gtk_player_new (SwfdecAsDebugger * debugger);
-
-void swfdec_gtk_player_set_playing (SwfdecGtkPlayer * player,
- gboolean playing);
-gboolean swfdec_gtk_player_get_playing (SwfdecGtkPlayer * player);
-void swfdec_gtk_player_set_audio_enabled
- (SwfdecGtkPlayer * player,
- gboolean enabled);
-gboolean swfdec_gtk_player_get_audio_enabled
- (SwfdecGtkPlayer * player);
-void swfdec_gtk_player_set_speed (SwfdecGtkPlayer * player,
- double speed);
-double swfdec_gtk_player_get_speed (SwfdecGtkPlayer * player);
-
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec-gtk/swfdec_gtk_socket.c b/libswfdec-gtk/swfdec_gtk_socket.c
deleted file mode 100644
index 08cbb76..0000000
--- a/libswfdec-gtk/swfdec_gtk_socket.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_gtk_socket.h"
-#include <libsoup/soup.h>
-#include <libsoup/soup-address.h>
-
-/*** GTK-DOC ***/
-
-/**
- * SECTION:SwfdecGtkSocket
- * @title: SwfdecGtkSocket
- * @short_description: a socket implementation integrating into the Gtk main loop
- * @see_also: #SwfdecSocket, #SwfdecGtkPlayer
- *
- * #SwfdecGtkSocket is a #SwfdecSocket that is a socket implementation that
- * uses libsoup and integrates with the Gtk main loop. It is used by default
- * by the #SwfecGtkPlayer.
- */
-
-/**
- * SwfdecGtkSocket:
- *
- * This is the object used to represent a socket. It is completely private.
- */
-
-struct _SwfdecGtkSocket
-{
- SwfdecSocket socket;
-
- SoupSocket * sock; /* libsoup socket we're using */
- gboolean sock_writable; /* FALSE if writing would block */
- SwfdecBufferQueue * queue; /* buffers we still need to push */
-};
-
-struct _SwfdecGtkSocketClass {
- SwfdecSocketClass socket_class;
-};
-
-/*** SwfdecGtkSocket ***/
-
-G_DEFINE_TYPE (SwfdecGtkSocket, swfdec_gtk_socket, SWFDEC_TYPE_SOCKET)
-
-static void
-swfdec_gtk_socket_close (SwfdecStream *stream)
-{
- SwfdecGtkSocket *gtk = SWFDEC_GTK_SOCKET (stream);
-
- soup_socket_disconnect (gtk->sock);
-}
-
-static void
-swfdec_gtk_socket_do_connect (SoupSocket *sock, int status, SwfdecGtkSocket *gtk)
-{
- if (SOUP_STATUS_IS_SUCCESSFUL (status))
- swfdec_stream_open (SWFDEC_STREAM (gtk));
- else
- swfdec_stream_error (SWFDEC_STREAM (gtk), "error connecting");
-
-}
-
-static void
-swfdec_gtk_socket_do_disconnect (SoupSocket *sock, SwfdecGtkSocket *gtk)
-{
- swfdec_stream_eof (SWFDEC_STREAM (gtk));
-}
-
-static void
-swfdec_gtk_socket_do_read (SoupSocket *sock, SwfdecGtkSocket *gtk)
-{
-#define SWFDEC_GTK_SOCKET_BLOCK_SIZE 1024
- SwfdecBuffer *buffer;
- SoupSocketIOStatus status;
- gsize len;
-
- do {
- buffer = swfdec_buffer_new_and_alloc (SWFDEC_GTK_SOCKET_BLOCK_SIZE);
- status = soup_socket_read (sock, buffer, SWFDEC_GTK_SOCKET_BLOCK_SIZE, &len);
- buffer->length = len;
- switch (status) {
- case SOUP_SOCKET_OK:
- swfdec_stream_push (SWFDEC_STREAM (gtk), buffer);
- break;
- case SOUP_SOCKET_WOULD_BLOCK:
- case SOUP_SOCKET_EOF:
- swfdec_buffer_unref (buffer);
- break;
- case SOUP_SOCKET_ERROR:
- swfdec_buffer_unref (buffer);
- swfdec_stream_error (SWFDEC_STREAM (gtk), "error reading data");
- break;
- default:
- g_warning ("unhandled status code %u from soup_socket_read()", (guint) status);
- break;
- }
- } while (status == SOUP_SOCKET_OK);
-}
-
-static void
-swfdec_gtk_socket_do_write (SoupSocket *sock, SwfdecGtkSocket *gtk)
-{
- SwfdecBuffer *buffer;
- SoupSocketIOStatus status;
- gsize len;
-
- gtk->sock_writable = TRUE;
- while ((buffer = swfdec_buffer_queue_peek_buffer (gtk->queue))) {
- status = soup_socket_write (sock, buffer->data, buffer->length, &len);
- swfdec_buffer_unref (buffer);
- switch (status) {
- case SOUP_SOCKET_OK:
- buffer = swfdec_buffer_queue_pull (gtk->queue, len);
- swfdec_buffer_unref (buffer);
- break;
- case SOUP_SOCKET_WOULD_BLOCK:
- case SOUP_SOCKET_EOF:
- gtk->sock_writable = FALSE;
- break;
- case SOUP_SOCKET_ERROR:
- swfdec_stream_error (SWFDEC_STREAM (gtk), "error writing data");
- break;
- default:
- g_warning ("unhandled status code %u from soup_socket_read()", (guint) status);
- break;
- }
- };
-}
-
-static SwfdecSocket *
-swfdec_gtk_socket_create (const char *hostname, guint port)
-{
- SwfdecGtkSocket *sock = g_object_new (SWFDEC_TYPE_GTK_SOCKET, NULL);
- SoupAddress *addr;
-
- addr = soup_address_new (hostname, port);
- sock->sock = soup_socket_new (SOUP_SOCKET_FLAG_NONBLOCKING, TRUE,
- /* FIXME: we should set nodelay, no? */
- SOUP_SOCKET_FLAG_NODELAY, TRUE, NULL);
- g_signal_connect (sock->sock, "connect-result",
- G_CALLBACK (swfdec_gtk_socket_do_connect), socket);
- g_signal_connect (sock->sock, "disconnect",
- G_CALLBACK (swfdec_gtk_socket_do_disconnect), socket);
- g_signal_connect (sock->sock, "readable",
- G_CALLBACK (swfdec_gtk_socket_do_read), socket);
- g_signal_connect (sock->sock, "writable",
- G_CALLBACK (swfdec_gtk_socket_do_write), socket);
-
- return SWFDEC_SOCKET (sock);
-}
-
-static void
-swfdec_gtk_socket_send (SwfdecSocket *sock, SwfdecBuffer *buffer)
-{
- SwfdecGtkSocket *gtk = SWFDEC_GTK_SOCKET (sock);
-
- swfdec_buffer_queue_push (gtk->queue, buffer);
- if (gtk->sock_writable)
- swfdec_gtk_socket_do_write (gtk->sock, gtk);
-}
-
-static void
-swfdec_gtk_socket_dispose (GObject *object)
-{
- SwfdecGtkSocket *gtk = SWFDEC_GTK_SOCKET (object);
-
- if (gtk->sock) {
- g_signal_handlers_disconnect_matched (gtk->sock, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, gtk);
- g_object_unref (gtk->sock);
- gtk->sock = NULL;
- }
- if (gtk->queue) {
- swfdec_buffer_queue_unref (gtk->queue);
- gtk->queue = NULL;
- }
- G_OBJECT_CLASS (swfdec_gtk_socket_parent_class)->dispose (object);
-}
-
-static void
-swfdec_gtk_socket_class_init (SwfdecGtkSocketClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- SwfdecStreamClass *stream_class = SWFDEC_STREAM_CLASS (klass);
- SwfdecSocketClass *socket_class = SWFDEC_SOCKET_CLASS (klass);
-
- object_class->dispose = swfdec_gtk_socket_dispose;
-
- stream_class->close = swfdec_gtk_socket_close;
-
- socket_class->create = swfdec_gtk_socket_create;
- socket_class->send = swfdec_gtk_socket_send;
-}
-
-static void
-swfdec_gtk_socket_init (SwfdecGtkSocket *gtk)
-{
- gtk->sock_writable = TRUE;
- gtk->queue = swfdec_buffer_queue_new ();
-}
-
diff --git a/libswfdec-gtk/swfdec_gtk_socket.h b/libswfdec-gtk/swfdec_gtk_socket.h
deleted file mode 100644
index 62bb546..0000000
--- a/libswfdec-gtk/swfdec_gtk_socket.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_GTK_SOCKET_H_
-#define _SWFDEC_GTK_SOCKET_H_
-
-#include <libswfdec/swfdec.h>
-
-G_BEGIN_DECLS
-
-
-typedef struct _SwfdecGtkSocket SwfdecGtkSocket;
-typedef struct _SwfdecGtkSocketClass SwfdecGtkSocketClass;
-
-#define SWFDEC_TYPE_GTK_SOCKET (swfdec_gtk_socket_get_type())
-#define SWFDEC_IS_GTK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_GTK_SOCKET))
-#define SWFDEC_IS_GTK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_GTK_SOCKET))
-#define SWFDEC_GTK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_GTK_SOCKET, SwfdecGtkSocket))
-#define SWFDEC_GTK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_GTK_SOCKET, SwfdecGtkSocketClass))
-#define SWFDEC_GTK_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_GTK_SOCKET, SwfdecGtkSocketClass))
-
-GType swfdec_gtk_socket_get_type (void);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec-gtk/swfdec_gtk_widget.c b/libswfdec-gtk/swfdec_gtk_widget.c
deleted file mode 100644
index 4836aa0..0000000
--- a/libswfdec-gtk/swfdec_gtk_widget.c
+++ /dev/null
@@ -1,683 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-#include <gdk/gdkkeysyms.h>
-#include "swfdec_gtk_widget.h"
-#include "swfdec_gtk_keys.h"
-
-struct _SwfdecGtkWidgetPrivate
-{
- SwfdecPlayer * player; /* the video we play */
-
- gboolean renderer_set; /* TRUE if a special renderer has been set */
- cairo_surface_type_t renderer; /* the renderer that was set */
- gboolean interactive; /* TRUE if this widget propagates keyboard and mouse events */
-};
-
-enum {
- PROP_0,
- PROP_PLAYER,
- PROP_INTERACTIVE,
- PROP_RENDERER_SET,
- PROP_RENDERER
-};
-
-/*** gtk-doc ***/
-
-/**
- * SECTION:SwfdecGtkWidget
- * @title: SwfdecGtkWidget
- * @short_description: a #GtkWidget for embedding SWF files
- *
- * This is a widget for playing Flash movies rendered with Swfdec in a Gtk
- * application. It supports a lot of advanced features, if you want to use
- * them. If you don't want to use them and just want to embed a movie in
- * your application, swfdec_gtk_widget_new() will probably be the only
- * function you need.
- *
- * @see_also: SwfdecGtkPlayer
- */
-
-/**
- * SwfdecGtkWidget:
- *
- * The structure for the Swfdec Gtk widget contains no public fields.
- */
-
-/*** SWFDEC_GTK_WIDGET ***/
-
-G_DEFINE_TYPE (SwfdecGtkWidget, swfdec_gtk_widget, GTK_TYPE_WIDGET)
-
-static gboolean
-swfdec_gtk_widget_motion_notify (GtkWidget *gtkwidget, GdkEventMotion *event)
-{
- SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (gtkwidget);
- SwfdecGtkWidgetPrivate *priv = widget->priv;
- int x, y;
-
- gdk_window_get_pointer (gtkwidget->window, &x, &y, NULL);
-
- if (priv->interactive && priv->player)
- swfdec_player_mouse_move (priv->player, x, y);
-
- return FALSE;
-}
-
-static gboolean
-swfdec_gtk_widget_leave_notify (GtkWidget *gtkwidget, GdkEventCrossing *event)
-{
- SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (gtkwidget);
- SwfdecGtkWidgetPrivate *priv = widget->priv;
-
- if (priv->interactive && priv->player) {
- swfdec_player_mouse_move (priv->player, event->x, event->y);
- }
- return FALSE;
-}
-
-static gboolean
-swfdec_gtk_widget_button_press (GtkWidget *gtkwidget, GdkEventButton *event)
-{
- SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (gtkwidget);
- SwfdecGtkWidgetPrivate *priv = widget->priv;
-
- if (event->type == GDK_BUTTON_PRESS && event->button <= 32 && priv->interactive && priv->player) {
- swfdec_player_mouse_press (priv->player, event->x, event->y, event->button);
- }
- return FALSE;
-}
-
-static gboolean
-swfdec_gtk_widget_button_release (GtkWidget *gtkwidget, GdkEventButton *event)
-{
- SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (gtkwidget);
- SwfdecGtkWidgetPrivate *priv = widget->priv;
-
- if (event->button <= 32 && priv->interactive && priv->player) {
- swfdec_player_mouse_release (priv->player, event->x, event->y, event->button);
- }
- return FALSE;
-}
-
-static guint
-swfdec_gtk_event_to_keycode (GdkEventKey *event)
-{
- guint ret;
-
- /* we try to match as well as possible to Flash _Windows_ key codes.
- * Since a lot of Flash files won't special case weird Linux key codes and we
- * want the best compatibility possible, we have to do that.
- */
- /* FIXME: I have no clue about non-western keyboards, so if you happen to use
- * such a keyboard, please help out here if it doesn't match.
- */
-
- /* try to match latin keys directly */
- if (event->keyval >= GDK_A && event->keyval <= GDK_Z)
- return event->keyval - GDK_A + SWFDEC_KEY_A;
- if (event->keyval >= GDK_a && event->keyval <= GDK_z)
- return event->keyval - GDK_a + SWFDEC_KEY_A;
-
- /* last resort: try to translate the hardware keycode directly */
- ret = swfdec_gtk_keycode_from_hardware_keycode (event->hardware_keycode);
- if (ret == 0)
- g_printerr ("could not translate key to Flash keycode. HW keycode %u, keyval %u\n",
- event->hardware_keycode, event->keyval);
- return ret;
-}
-
-static gboolean
-swfdec_gtk_widget_key_press (GtkWidget *gtkwidget, GdkEventKey *event)
-{
- SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (gtkwidget);
- SwfdecGtkWidgetPrivate *priv = widget->priv;
-
- if (priv->interactive && priv->player) {
- guint keycode = swfdec_gtk_event_to_keycode (event);
- if (keycode != 0) {
- swfdec_player_key_press (priv->player, keycode,
- gdk_keyval_to_unicode (event->keyval));
- }
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-swfdec_gtk_widget_key_release (GtkWidget *gtkwidget, GdkEventKey *event)
-{
- SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (gtkwidget);
- SwfdecGtkWidgetPrivate *priv = widget->priv;
-
- if (priv->interactive && priv->player) {
- guint keycode = swfdec_gtk_event_to_keycode (event);
- if (keycode != 0) {
- swfdec_player_key_release (priv->player, keycode,
- gdk_keyval_to_unicode (event->keyval));
- }
- return TRUE;
- }
-
- return FALSE;
-}
-
-static cairo_surface_t *
-swfdec_gtk_widget_create_renderer (cairo_surface_type_t type, int width, int height)
-{
- if (type == CAIRO_SURFACE_TYPE_IMAGE) {
- return cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
- } else {
- return NULL;
- }
-}
-
-static gboolean
-swfdec_gtk_widget_expose (GtkWidget *gtkwidget, GdkEventExpose *event)
-{
- SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (gtkwidget);
- SwfdecGtkWidgetPrivate *priv = widget->priv;
- cairo_t *cr;
- cairo_surface_t *surface = NULL;
-
- if (event->window != gtkwidget->window)
- return FALSE;
- if (priv->player == NULL)
- return FALSE;
-
- if (!priv->renderer_set ||
- (surface = swfdec_gtk_widget_create_renderer (priv->renderer,
- event->area.width, event->area.height)) == NULL) {
- cr = gdk_cairo_create (gtkwidget->window);
- } else {
- cr = cairo_create (surface);
- cairo_translate (cr, -event->area.x, -event->area.y);
- }
- swfdec_player_render (priv->player, cr,
- event->area.x, event->area.y, event->area.width, event->area.height);
- cairo_show_page (cr);
- cairo_destroy (cr);
-
- if (surface) {
- cairo_t *crw = gdk_cairo_create (gtkwidget->window);
- cairo_set_source_surface (crw, surface, event->area.x, event->area.y);
- cairo_paint (crw);
- cairo_destroy (crw);
- cairo_surface_destroy (surface);
- }
-
- return FALSE;
-}
-
-static void
-swfdec_gtk_widget_get_property (GObject *object, guint param_id, GValue *value,
- GParamSpec * pspec)
-{
- SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (object);
- SwfdecGtkWidgetPrivate *priv = widget->priv;
-
- switch (param_id) {
- case PROP_PLAYER:
- g_value_set_object (value, priv->player);
- break;
- case PROP_INTERACTIVE:
- g_value_set_boolean (value, priv->interactive);
- break;
- case PROP_RENDERER_SET:
- g_value_set_boolean (value, priv->renderer_set);
- break;
- case PROP_RENDERER:
- g_value_set_uint (value, priv->renderer);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-swfdec_gtk_widget_set_property (GObject *object, guint param_id, const GValue *value,
- GParamSpec *pspec)
-{
- SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (object);
- SwfdecGtkWidgetPrivate *priv = widget->priv;
-
- switch (param_id) {
- case PROP_PLAYER:
- swfdec_gtk_widget_set_player (widget, g_value_get_object (value));
- break;
- case PROP_INTERACTIVE:
- swfdec_gtk_widget_set_interactive (widget, g_value_get_boolean (value));
- break;
- case PROP_RENDERER_SET:
- priv->renderer_set = g_value_get_boolean (value);
- gtk_widget_queue_draw (GTK_WIDGET (widget));
- break;
- case PROP_RENDERER:
- priv->renderer = g_value_get_uint (value);
- if (priv->renderer_set)
- gtk_widget_queue_draw (GTK_WIDGET (widget));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-swfdec_gtk_widget_dispose (GObject *object)
-{
- SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (object);
-
- swfdec_gtk_widget_set_player (widget, NULL);
-
- G_OBJECT_CLASS (swfdec_gtk_widget_parent_class)->dispose (object);
-}
-
-static void
-swfdec_gtk_widget_size_allocate (GtkWidget *gtkwidget, GtkAllocation *allocation)
-{
- SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (gtkwidget);
- SwfdecGtkWidgetPrivate *priv = widget->priv;
-
- gtkwidget->allocation = *allocation;
-
- if (priv->player && swfdec_player_is_initialized (priv->player))
- swfdec_player_set_size (priv->player, allocation->width, allocation->height);
- if (GTK_WIDGET_REALIZED (gtkwidget)) {
- gdk_window_move_resize (gtkwidget->window,
- allocation->x, allocation->y, allocation->width, allocation->height);
- }
-}
-
-static void
-swfdec_gtk_widget_size_request (GtkWidget *gtkwidget, GtkRequisition *req)
-{
- SwfdecGtkWidget * widget = SWFDEC_GTK_WIDGET (gtkwidget);
- SwfdecGtkWidgetPrivate *priv = widget->priv;
-
- if (priv->player == NULL) {
- req->width = req->height = 0;
- } else {
- 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);
- }
-}
-
-static void
-swfdec_gtk_widget_update_cursor (SwfdecGtkWidget *widget)
-{
- GdkWindow *window = GTK_WIDGET (widget)->window;
- GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (widget));
- SwfdecGtkWidgetPrivate *priv = widget->priv;
- SwfdecMouseCursor swfcursor;
- GdkCursor *cursor;
-
- if (window == NULL)
- return;
- if (priv->interactive)
- g_object_get (priv->player, "mouse-cursor", &swfcursor, NULL);
- else
- swfcursor = SWFDEC_MOUSE_CURSOR_NORMAL;
-
- switch (swfcursor) {
- case SWFDEC_MOUSE_CURSOR_NONE:
- {
- GdkBitmap *bitmap;
- GdkColor color = { 0, 0, 0, 0 };
- char data = 0;
-
- bitmap = gdk_bitmap_create_from_data (window, &data, 1, 1);
- if (bitmap == NULL)
- return;
- cursor = gdk_cursor_new_from_pixmap (bitmap, bitmap, &color, &color, 0, 0);
- gdk_window_set_cursor (window, cursor);
- gdk_cursor_unref (cursor);
- g_object_unref (bitmap);
- break;
- }
- case SWFDEC_MOUSE_CURSOR_TEXT:
- cursor = gdk_cursor_new_for_display (display, GDK_XTERM);
- gdk_window_set_cursor (window, cursor);
- gdk_cursor_unref (cursor);
- break;
- case SWFDEC_MOUSE_CURSOR_CLICK:
- cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
- gdk_window_set_cursor (window, cursor);
- gdk_cursor_unref (cursor);
- break;
- case SWFDEC_MOUSE_CURSOR_NORMAL:
- cursor = gdk_cursor_new_for_display (display, GDK_LEFT_PTR);
- gdk_window_set_cursor (window, cursor);
- gdk_cursor_unref (cursor);
- break;
- default:
- g_warning ("invalid cursor %d", (int) swfcursor);
- gdk_window_set_cursor (window, NULL);
- break;
- }
-}
-
-static void
-swfdec_gtk_widget_realize (GtkWidget *widget)
-{
- GdkWindowAttr attributes;
- gint attributes_mask;
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.event_mask = gtk_widget_get_events (widget);
- attributes.event_mask |= GDK_EXPOSURE_MASK |
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_LEAVE_NOTIFY_MASK |
- GDK_POINTER_MOTION_MASK |
- GDK_POINTER_MOTION_HINT_MASK |
- GDK_KEY_PRESS_MASK |
- GDK_KEY_RELEASE_MASK;
-
- attributes_mask = GDK_WA_X | GDK_WA_Y;
-
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
-
- if (SWFDEC_GTK_WIDGET (widget)->priv->player) {
- swfdec_gtk_widget_update_cursor (SWFDEC_GTK_WIDGET (widget));
- }
-}
-
-static void
-swfdec_gtk_widget_class_init (SwfdecGtkWidgetClass * g_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (g_class);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (g_class);
-
- object_class->dispose = swfdec_gtk_widget_dispose;
- object_class->get_property = swfdec_gtk_widget_get_property;
- object_class->set_property = swfdec_gtk_widget_set_property;
-
- g_object_class_install_property (object_class, PROP_PLAYER,
- g_param_spec_object ("player", "player", "player that is displayed",
- SWFDEC_TYPE_PLAYER, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class, PROP_INTERACTIVE,
- g_param_spec_boolean ("interactive", "interactive", "if mouse events are processed",
- TRUE, G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_RENDERER_SET,
- g_param_spec_boolean ("renderer-set", "renderer set", "if an intermediate renderer should be used",
- TRUE, G_PARAM_READWRITE));
- /* FIXME: get an enum for cairo_surface_type_t */
- g_object_class_install_property (object_class, PROP_RENDERER,
- g_param_spec_uint ("renderer", "renderer", "cairo_surface_type_t of intermediate renderer to use",
- 0, G_MAXUINT, CAIRO_SURFACE_TYPE_IMAGE, G_PARAM_READWRITE));
-
- widget_class->realize = swfdec_gtk_widget_realize;
- widget_class->size_request = swfdec_gtk_widget_size_request;
- widget_class->size_allocate = swfdec_gtk_widget_size_allocate;
- widget_class->expose_event = swfdec_gtk_widget_expose;
- widget_class->button_press_event = swfdec_gtk_widget_button_press;
- widget_class->button_release_event = swfdec_gtk_widget_button_release;
- widget_class->motion_notify_event = swfdec_gtk_widget_motion_notify;
- widget_class->leave_notify_event = swfdec_gtk_widget_leave_notify;
- widget_class->key_press_event = swfdec_gtk_widget_key_press;
- widget_class->key_release_event = swfdec_gtk_widget_key_release;
-
- g_type_class_add_private (object_class, sizeof (SwfdecGtkWidgetPrivate));
-}
-
-static void
-swfdec_gtk_widget_init (SwfdecGtkWidget * widget)
-{
- SwfdecGtkWidgetPrivate *priv;
-
- priv = widget->priv = G_TYPE_INSTANCE_GET_PRIVATE (widget, SWFDEC_TYPE_GTK_WIDGET, SwfdecGtkWidgetPrivate);
-
- priv->interactive = TRUE;
- priv->renderer = CAIRO_SURFACE_TYPE_IMAGE;
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
-}
-
-static void
-swfdec_gtk_widget_invalidate_cb (SwfdecPlayer *player, const SwfdecRectangle *extents,
- const SwfdecRectangle *rect, guint n_rects, SwfdecGtkWidget *widget)
-{
- GdkRegion *region;
- guint i;
-
- if (!GTK_WIDGET_REALIZED (widget))
- return;
-
- region = gdk_region_new ();
- for (i = 0; i < n_rects; i++) {
- gdk_region_union_with_rect (region, (GdkRectangle *) &rect[i]);
- }
- gdk_window_invalidate_region (GTK_WIDGET (widget)->window, region, FALSE);
- gdk_region_destroy (region);
-}
-
-static void
-swfdec_gtk_widget_notify_cb (SwfdecPlayer *player, GParamSpec *pspec, SwfdecGtkWidget *widget)
-{
- if (g_str_equal (pspec->name, "mouse-cursor")) {
- swfdec_gtk_widget_update_cursor (widget);
- } else if (g_str_equal (pspec->name, "initialized")) {
- gtk_widget_queue_resize (GTK_WIDGET (widget));
- }
-}
-
-/*** PUBLIC API ***/
-
-/**
- * swfdec_gtk_widget_set_player:
- * @widget: a #SwfdecGtkWidget
- * @player: the #SwfdecPlayer to display or %NULL for none
- *
- * Sets the new player to display in @widget.
- **/
-void
-swfdec_gtk_widget_set_player (SwfdecGtkWidget *widget, SwfdecPlayer *player)
-{
- SwfdecGtkWidgetPrivate *priv = widget->priv;
-
- g_return_if_fail (SWFDEC_IS_GTK_WIDGET (widget));
- g_return_if_fail (player == NULL || SWFDEC_IS_PLAYER (player));
-
- if (priv->player) {
- g_signal_handlers_disconnect_by_func (priv->player, swfdec_gtk_widget_invalidate_cb, widget);
- g_signal_handlers_disconnect_by_func (priv->player, swfdec_gtk_widget_notify_cb, widget);
- g_object_unref (priv->player);
- }
- priv->player = player;
- if (player) {
- g_signal_connect (player, "invalidate", G_CALLBACK (swfdec_gtk_widget_invalidate_cb), widget);
- g_signal_connect (player, "notify", G_CALLBACK (swfdec_gtk_widget_notify_cb), widget);
- g_object_ref (player);
- swfdec_gtk_widget_update_cursor (widget);
- } else {
- if (GTK_WIDGET (widget)->window)
- gdk_window_set_cursor (GTK_WIDGET (widget)->window, NULL);
- }
- gtk_widget_queue_resize (GTK_WIDGET (widget));
- g_object_notify (G_OBJECT (widget), "player");
-}
-
-/**
- * swfdec_gtk_widget_get_player:
- * @widget: a #SwfdecGtkWidget
- *
- * Gets the player that is currently played back in this @widget.
- *
- * Returns: the #SwfdecPlayer or %NULL if none
- **/
-SwfdecPlayer *
-swfdec_gtk_widget_get_player (SwfdecGtkWidget *widget)
-{
- g_return_val_if_fail (SWFDEC_IS_GTK_WIDGET (widget), NULL);
-
- return widget->priv->player;
-}
-
-/**
- * swfdec_gtk_widget_new:
- * @player: a #SwfdecPlayer or %NULL
- *
- * Creates a new #SwfdecGtkWidget to display @player.
- *
- * Returns: the new widget that displays @player
- **/
-GtkWidget *
-swfdec_gtk_widget_new (SwfdecPlayer *player)
-{
- SwfdecGtkWidget *widget;
-
- g_return_val_if_fail (player == NULL || SWFDEC_IS_PLAYER (player), NULL);
-
- widget = g_object_new (SWFDEC_TYPE_GTK_WIDGET, "player", player, NULL);
-
- return GTK_WIDGET (widget);
-}
-
-/**
- * swfdec_gtk_widget_set_interactive:
- * @widget: a #SwfdecGtkWidget
- * @interactive: %TRUE to make the widget interactive
- *
- * Sets the widget to be interactive or not. An interactive widget processes
- * mouse and keyboard events, while a non-interactive widget does not care about
- * user input. Widgets are interactive by default.
- **/
-void
-swfdec_gtk_widget_set_interactive (SwfdecGtkWidget *widget, gboolean interactive)
-{
- g_return_if_fail (SWFDEC_IS_GTK_WIDGET (widget));
-
- widget->priv->interactive = interactive;
- swfdec_gtk_widget_update_cursor (widget);
- g_object_notify (G_OBJECT (widget), "interactive");
-}
-
-/**
- * swfdec_gtk_widget_get_interactive:
- * @widget: a #SwfdecGtkWidget
- *
- * Queries if the @widget is currently interactive. See
- * swfdec_gtk_widget_set_interactive() for details.
- *
- * Returns: %TRUE if the widget is interactive, %FALSE otherwise.
- **/
-gboolean
-swfdec_gtk_widget_get_interactive (SwfdecGtkWidget *widget)
-{
- g_return_val_if_fail (SWFDEC_IS_GTK_WIDGET (widget), FALSE);
-
- return widget->priv->interactive;
-}
-
-/**
- * swfdec_gtk_widget_set_renderer:
- * @widget: a #SwfdecGtkWidget
- * @renderer: a #cairo_surface_type_t for the intermediate renderer
- *
- * Tells @widget to use an intermediate surface for rendering. This is
- * useful for debugging or performance measurements inside swfdec and is
- * probably not interesting for anyone else.
- **/
-void
-swfdec_gtk_widget_set_renderer (SwfdecGtkWidget *widget, cairo_surface_type_t renderer)
-{
- g_return_if_fail (SWFDEC_IS_GTK_WIDGET (widget));
-
- widget->priv->renderer = renderer;
- if (widget->priv->renderer_set == FALSE) {
- widget->priv->renderer_set = TRUE;
- g_object_notify (G_OBJECT (widget), "renderer-set");
- }
- g_object_notify (G_OBJECT (widget), "renderer");
-}
-
-/**
- * swfdec_gtk_widget_unset_renderer:
- * @widget: a #SwfdecGtkWidget
- *
- * Unsets the use of an intermediate rendering surface. See
- * swfdec_gtk_widget_set_renderer() for details.
- **/
-void
-swfdec_gtk_widget_unset_renderer (SwfdecGtkWidget *widget)
-{
- g_return_if_fail (SWFDEC_IS_GTK_WIDGET (widget));
-
- if (widget->priv->renderer_set == FALSE)
- return;
- widget->priv->renderer_set = FALSE;
- g_object_notify (G_OBJECT (widget), "renderer-set");
-}
-
-/**
- * swfdec_gtk_widget_get_renderer:
- * @widget: a #SwfdecGtkWidget
- *
- * Gets the intermediate renderer that is or would be in use by @widget. Use
- * swfdec_gtk_widget_uses_renderer() to check if an intermediate renderer is in
- * use. See swfdec_gtk_widget_set_renderer() for details.
- *
- * Returns: the type of the intermediate renderer
- **/
-cairo_surface_type_t
-swfdec_gtk_widget_get_renderer (SwfdecGtkWidget *widget)
-{
- g_return_val_if_fail (SWFDEC_IS_GTK_WIDGET (widget), CAIRO_SURFACE_TYPE_IMAGE);
-
- return widget->priv->renderer;
-}
-
-/**
- * swfdec_gtk_widget_uses_renderer:
- * @widget: a #SwfdecGtkWidget
- *
- * Queries if an intermediate renderer set via swfdec_gtk_widget_set_renderer()
- * is currently in use.
- *
- * Returns: %TRUE if an intermediate renderer is used.
- **/
-gboolean
-swfdec_gtk_widget_uses_renderer (SwfdecGtkWidget *widget)
-{
- g_return_val_if_fail (SWFDEC_IS_GTK_WIDGET (widget), FALSE);
-
- return widget->priv->renderer_set;
-}
-
diff --git a/libswfdec-gtk/swfdec_gtk_widget.h b/libswfdec-gtk/swfdec_gtk_widget.h
deleted file mode 100644
index 86b03fd..0000000
--- a/libswfdec-gtk/swfdec_gtk_widget.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_GTK_WIDGET_H_
-#define _SWFDEC_GTK_WIDGET_H_
-
-#include <gtk/gtk.h>
-#include <libswfdec/swfdec.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecGtkWidget SwfdecGtkWidget;
-typedef struct _SwfdecGtkWidgetClass SwfdecGtkWidgetClass;
-typedef struct _SwfdecGtkWidgetPrivate SwfdecGtkWidgetPrivate;
-
-#define SWFDEC_TYPE_GTK_WIDGET (swfdec_gtk_widget_get_type())
-#define SWFDEC_IS_GTK_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_GTK_WIDGET))
-#define SWFDEC_IS_GTK_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_GTK_WIDGET))
-#define SWFDEC_GTK_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_GTK_WIDGET, SwfdecGtkWidget))
-#define SWFDEC_GTK_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_GTK_WIDGET, SwfdecGtkWidgetClass))
-
-struct _SwfdecGtkWidget
-{
- GtkWidget widget;
-
- /*< private >*/
- SwfdecGtkWidgetPrivate * priv;
-};
-
-struct _SwfdecGtkWidgetClass
-{
- GtkWidgetClass widget_class;
-};
-
-GType swfdec_gtk_widget_get_type (void);
-
-GtkWidget * swfdec_gtk_widget_new (SwfdecPlayer * player);
-
-void swfdec_gtk_widget_set_player (SwfdecGtkWidget * widget,
- SwfdecPlayer * player);
-SwfdecPlayer * swfdec_gtk_widget_get_player (SwfdecGtkWidget * widget);
-void swfdec_gtk_widget_set_renderer (SwfdecGtkWidget * widget,
- cairo_surface_type_t renderer);
-void swfdec_gtk_widget_unset_renderer (SwfdecGtkWidget * widget);
-cairo_surface_type_t
- swfdec_gtk_widget_get_renderer (SwfdecGtkWidget * widget);
-gboolean swfdec_gtk_widget_uses_renderer (SwfdecGtkWidget * widget);
-void swfdec_gtk_widget_set_interactive (SwfdecGtkWidget * widget,
- gboolean interactive);
-gboolean swfdec_gtk_widget_get_interactive (SwfdecGtkWidget * widget);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec-gtk/swfdec_playback.h b/libswfdec-gtk/swfdec_playback.h
deleted file mode 100644
index 8be67dd..0000000
--- a/libswfdec-gtk/swfdec_playback.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_PLAYBACK_H_
-#define _SWFDEC_PLAYBACK_H_
-
-#include <libswfdec/swfdec.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecPlayback SwfdecPlayback;
-
-SwfdecPlayback *swfdec_playback_open (SwfdecPlayer * player,
- GMainContext * context);
-
-void swfdec_playback_close (SwfdecPlayback * sound);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec-gtk/swfdec_playback_alsa.c b/libswfdec-gtk/swfdec_playback_alsa.c
deleted file mode 100644
index bddd189..0000000
--- a/libswfdec-gtk/swfdec_playback_alsa.c
+++ /dev/null
@@ -1,360 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <alsa/asoundlib.h>
-#include "swfdec_playback.h"
-
-/* Why ALSA sucks for beginners:
- * - snd_pcm_delay is not sample-exact, but period-exact most of the time.
- * Yay for getting told the time every 512 samples when a human notices
- * a delay of 100 samples (oooops)
- * - lots of functions are simply not implemented. So the super-smart idea
- * of using snd_pcm_rewind to avoid XRUNS and still get low latency has
- * some issues when dmix just returns -EIO all of the time. That wouldn't
- * be so bad if there was actually a way to query if it's supported.
- * - But to make up for all this, you have 10 hardware parameters, 10
- * software parameters and 10 configuration parameters. All of this is
- * naturally supported on 10 driver APIs depending on kernel. So if your
- * sound card seems to do weird stuff, that is not my fault.
- * Welcome to Linux sound in the 21st century.
- */
-
-/*** DEFINITIONS ***/
-
-struct _SwfdecPlayback {
- SwfdecPlayer * player;
- GList * streams; /* all Stream objects */
- GMainContext * context; /* context we work in */
-};
-
-typedef struct {
- SwfdecPlayback * sound; /* reference to sound object */
- SwfdecAudio * audio; /* the audio we play back */
- snd_pcm_t * pcm; /* the pcm we play back to */
- GSource ** sources; /* sources for writing data */
- guint n_sources; /* number of sources */
- guint offset; /* offset into sound */
-} Stream;
-
-#define ALSA_TRY(func,msg) G_STMT_START{ \
- int err = func; \
- if (err < 0) \
- g_printerr (msg ": %s\n", snd_strerror (err)); \
-}G_STMT_END
-
-#define ALSA_ERROR(func,msg,retval) G_STMT_START { \
- int err = func; \
- if (err < 0) { \
- g_printerr (msg ": %s\n", snd_strerror (err)); \
- return retval; \
- } \
-}G_STMT_END
-
-/*** STREAMS ***/
-
-static snd_pcm_uframes_t
-write_player (Stream *stream, const snd_pcm_channel_area_t *dst,
- snd_pcm_uframes_t offset, snd_pcm_uframes_t avail)
-{
- /* FIXME: do a long path if this doesn't hold */
- g_assert (dst[1].first - dst[0].first == 16);
- g_assert (dst[0].addr == dst[1].addr);
- g_assert (dst[0].step == dst[1].step);
- g_assert (dst[0].step == 32);
-
- memset ((guint8 *) dst[0].addr + offset * dst[0].step / 8, 0, avail * 4);
- swfdec_audio_render (stream->audio, (gint16 *) ((guint8 *) dst[0].addr + offset * dst[0].step / 8),
- stream->offset, avail);
- //g_print ("rendering %u %u\n", stream->offset, (guint) avail);
- return avail;
-}
-
-static gboolean
-try_write (Stream *stream)
-{
- snd_pcm_sframes_t avail_result;
- snd_pcm_uframes_t offset, avail;
- const snd_pcm_channel_area_t *dst;
-
- while (TRUE) {
- avail_result = snd_pcm_avail_update (stream->pcm);
- ALSA_ERROR (avail_result, "snd_pcm_avail_update failed", FALSE);
- if (avail_result == 0)
- return TRUE;
- avail = avail_result;
- ALSA_ERROR (snd_pcm_mmap_begin (stream->pcm, &dst, &offset, &avail),
- "snd_pcm_mmap_begin failed", FALSE);
- //g_print (" avail = %u\n", (guint) avail);
-
- avail = write_player (stream, dst, offset, avail);
- if (snd_pcm_mmap_commit (stream->pcm, offset, avail) < 0) {
- g_printerr ("snd_pcm_mmap_commit failed\n");
- return FALSE;
- }
- stream->offset += avail;
- //g_print ("offset: %u (+%u)\n", stream->offset, (guint) avail);
- }
- return TRUE;
-}
-
-static void
-swfdec_playback_stream_remove_handlers (Stream *stream)
-{
- guint i;
-
- for (i = 0; i < stream->n_sources; i++) {
- if (stream->sources[i]) {
- g_source_destroy (stream->sources[i]);
- g_source_unref (stream->sources[i]);
- stream->sources[i] = NULL;
- }
- }
-}
-
-static void swfdec_playback_stream_start (Stream *stream);
-static gboolean
-handle_stream (GIOChannel *source, GIOCondition cond, gpointer data)
-{
- Stream *stream = data;
- snd_pcm_state_t state;
-
- state = snd_pcm_state (stream->pcm);
- if (state != SND_PCM_STATE_RUNNING) {
- swfdec_playback_stream_start (stream);
- } else {
- try_write (stream);
- }
- return TRUE;
-}
-
-static void
-swfdec_playback_stream_install_handlers (Stream *stream)
-{
- GIOChannel *channel;
-
- if (stream->n_sources > 0) {
- struct pollfd polls[stream->n_sources];
- guint i, count;
- if (stream->n_sources > 1)
- g_printerr ("attention: more than one fd!\n");
- count = snd_pcm_poll_descriptors (stream->pcm, polls, stream->n_sources);
- for (i = 0; i < count; i++) {
- if (stream->sources[i] != NULL)
- continue;
- channel = g_io_channel_unix_new (polls[i].fd);
- stream->sources[i] = g_io_create_watch (channel, polls[i].events);
- g_source_set_priority (stream->sources[i], G_PRIORITY_HIGH);
- g_source_set_callback (stream->sources[i], (GSourceFunc) handle_stream, stream, NULL);
- g_io_channel_unref (channel);
- g_source_attach (stream->sources[i], stream->sound->context);
- }
- }
-}
-
-static void
-swfdec_playback_stream_start (Stream *stream)
-{
- snd_pcm_state_t state = snd_pcm_state (stream->pcm);
- switch (state) {
- case SND_PCM_STATE_XRUN:
- ALSA_ERROR (snd_pcm_prepare (stream->pcm), "no prepare",);
- //g_print ("XRUN!\n");
- /* fall through */
- case SND_PCM_STATE_SUSPENDED:
- case SND_PCM_STATE_PREPARED:
- stream->offset = 0;
- //g_print ("offset: %u (delay: %ld)\n", sound->offset, delay);
- if (try_write (stream)) {
- ALSA_ERROR (snd_pcm_start (stream->pcm), "error starting",);
- swfdec_playback_stream_install_handlers (stream);
- }
- break;
- case SND_PCM_STATE_OPEN:
- case SND_PCM_STATE_SETUP:
- case SND_PCM_STATE_RUNNING:
- case SND_PCM_STATE_DRAINING:
- case SND_PCM_STATE_PAUSED:
- case SND_PCM_STATE_DISCONNECTED:
- default:
- g_assert_not_reached ();
- }
-}
-
-static void
-swfdec_playback_stream_open (SwfdecPlayback *sound, SwfdecAudio *audio)
-{
- Stream *stream;
- snd_pcm_t *ret;
- snd_pcm_hw_params_t *hw_params;
- guint rate;
- snd_pcm_uframes_t uframes;
-
- /* "default" uses dmix, and dmix ticks way slow, so this thingy here stutters */
- ALSA_ERROR (snd_pcm_open (&ret, "default", SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK),
- "Failed to open sound device", );
-
- snd_pcm_hw_params_alloca (&hw_params);
- if (snd_pcm_hw_params_any (ret, hw_params) < 0) {
- g_printerr ("No sound format available\n");
- return;
- }
- if (snd_pcm_hw_params_set_access (ret, hw_params, SND_PCM_ACCESS_MMAP_INTERLEAVED) < 0) {
- g_printerr ("Failed setting access\n");
- goto fail;
- }
- if (snd_pcm_hw_params_set_format (ret, hw_params, SND_PCM_FORMAT_S16) < 0) {
- g_printerr ("Failed setting format\n");
- goto fail;
- }
- if (snd_pcm_hw_params_set_channels (ret, hw_params, 2) < 0) {
- g_printerr ("Failed setting channels\n");
- goto fail;
- }
- rate = 44100;
- if (snd_pcm_hw_params_set_rate_near (ret, hw_params, &rate, 0) < 0) {
- g_printerr ("Failed setting rate\n");
- goto fail;
- }
- uframes = 16384;
- if (snd_pcm_hw_params_set_buffer_size_near (ret, hw_params, &uframes) < 0) {
- g_printerr ("Failed setting buffer size\n");
- goto fail;
- }
- if (snd_pcm_hw_params (ret, hw_params) < 0) {
- g_printerr ("Could not set hardware parameters\n");
- goto fail;
- }
-#if 0
- {
- snd_output_t *log;
- snd_output_stdio_attach (&log, stderr, 0);
- snd_pcm_hw_params_dump (hw_params, log);
- }
-#endif
- stream = g_new0 (Stream, 1);
- stream->sound = sound;
- stream->audio = g_object_ref (audio);
- stream->pcm = ret;
- stream->n_sources = snd_pcm_poll_descriptors_count (ret);
- if (stream->n_sources > 0)
- stream->sources = g_new0 (GSource *, stream->n_sources);
- sound->streams = g_list_prepend (sound->streams, stream);
- swfdec_playback_stream_start (stream);
- return;
-
-fail:
- snd_pcm_close (ret);
-}
-
-static void
-swfdec_playback_stream_close (Stream *stream)
-{
- ALSA_TRY (snd_pcm_close (stream->pcm), "failed closing");
- swfdec_playback_stream_remove_handlers (stream);
- g_free (stream->sources);
- stream->sound->streams = g_list_remove (stream->sound->streams, stream);
- g_object_unref (stream->audio);
- g_free (stream);
-}
-
-/*** SOUND ***/
-
-static void
-advance_before (SwfdecPlayer *player, guint msecs, guint audio_samples, gpointer data)
-{
- SwfdecPlayback *sound = data;
- GList *walk;
-
- for (walk = sound->streams; walk; walk = walk->next) {
- Stream *stream = walk->data;
- if (audio_samples >= stream->offset) {
- stream->offset = 0;
- } else {
- stream->offset -= audio_samples;
- }
- }
-}
-
-static void
-audio_added (SwfdecPlayer *player, SwfdecAudio *audio, SwfdecPlayback *sound)
-{
- swfdec_playback_stream_open (sound, audio);
-}
-
-static void
-audio_removed (SwfdecPlayer *player, SwfdecAudio *audio, SwfdecPlayback *sound)
-{
- GList *walk;
-
- for (walk = sound->streams; walk; walk = walk->next) {
- Stream *stream = walk->data;
- if (stream->audio == audio) {
- swfdec_playback_stream_close (stream);
- return;
- }
- }
-}
-
-SwfdecPlayback *
-swfdec_playback_open (SwfdecPlayer *player, GMainContext *context)
-{
- SwfdecPlayback *sound;
- const GList *walk;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (context != NULL, NULL);
-
- sound = g_new0 (SwfdecPlayback, 1);
- sound->player = player;
- g_signal_connect (player, "advance", G_CALLBACK (advance_before), sound);
- g_signal_connect (player, "audio-added", G_CALLBACK (audio_added), sound);
- g_signal_connect (player, "audio-removed", G_CALLBACK (audio_removed), sound);
- for (walk = swfdec_player_get_audio (player); walk; walk = walk->next) {
- swfdec_playback_stream_open (sound, walk->data);
- }
- g_main_context_ref (context);
- sound->context = context;
- return sound;
-}
-
-void
-swfdec_playback_close (SwfdecPlayback *sound)
-{
-#define REMOVE_HANDLER_FULL(obj,func,data,count) G_STMT_START {\
- if (g_signal_handlers_disconnect_by_func ((obj), \
- G_CALLBACK (func), (data)) != (count)) { \
- g_assert_not_reached (); \
- } \
-} G_STMT_END
-#define REMOVE_HANDLER(obj,func,data) REMOVE_HANDLER_FULL (obj, func, data, 1)
-
- while (sound->streams)
- swfdec_playback_stream_close (sound->streams->data);
- REMOVE_HANDLER (sound->player, advance_before, sound);
- REMOVE_HANDLER (sound->player, audio_added, sound);
- REMOVE_HANDLER (sound->player, audio_removed, sound);
- g_main_context_unref (sound->context);
- g_free (sound);
-}
-
-
diff --git a/libswfdec-gtk/swfdec_playback_none.c b/libswfdec-gtk/swfdec_playback_none.c
deleted file mode 100644
index 79651d6..0000000
--- a/libswfdec-gtk/swfdec_playback_none.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_playback.h"
-
-/* STUBS ONLY - audio is disabled */
-
-SwfdecPlayback *
-swfdec_playback_open (SwfdecPlayer *player, GMainContext *context)
-{
- return GINT_TO_POINTER (-1);
-}
-
-void
-swfdec_playback_close (SwfdecPlayback *sound)
-{
- g_assert (sound == GINT_TO_POINTER (-1));
-}
diff --git a/libswfdec-gtk/swfdec_playback_oss.c b/libswfdec-gtk/swfdec_playback_oss.c
deleted file mode 100644
index c2eb493..0000000
--- a/libswfdec-gtk/swfdec_playback_oss.c
+++ /dev/null
@@ -1,265 +0,0 @@
-/* Swfdec
- * Copyright © 2006 Benjamin Otte <otte at gnome.org>
- * Copyright © 2007 Eric Anholt <eric at anholt.net>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <sys/soundcard.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "swfdec_playback.h"
-
-/** @file Implements swfdec audio playback by opening /dev/dsp per stream
- * and playing out through that.
- *
- * Allowing multiple access to /dev/dsp is not required by the OSS API spec,
- * but FreeBSD's sound system lets you, which is what this file was written
- * for.
- */
-
-/*** DEFINITIONS ***/
-
-struct _SwfdecPlayback {
- SwfdecPlayer * player;
- GList * streams; /* all Stream objects */
- GMainContext * context; /* context we work in */
-};
-
-typedef struct {
- SwfdecPlayback * sound; /* reference to sound object */
- SwfdecAudio * audio; /* the audio we play back */
- int dsp_fd;
- int fragsize; /* Audio fragment size */
- GSource * source; /* source for writing data */
- guint offset; /* offset into sound */
-} Stream;
-
-/* Size of one of our audio samples, in bytes */
-#define SAMPLESIZE 2
-#define CHANNELS 2
-
-/*** STREAMS ***/
-
-static gboolean
-handle_stream (GIOChannel *source, GIOCondition cond, gpointer data)
-{
- Stream *stream = data;
- char *frag = malloc(stream->fragsize);
-
- if (frag == NULL) {
- g_printerr ("Failed to allocate fragment of size %d\n",
- stream->fragsize);
- return FALSE;
- }
-
- while (TRUE) {
- int ret;
- audio_buf_info spaceinfo;
-
- ret = ioctl(stream->dsp_fd, SNDCTL_DSP_GETOSPACE, &spaceinfo);
- if (ret == -1) {
- g_printerr ("Failed to get output buffer availability\n");
- free(frag);
- return FALSE;
- }
- g_assert(spaceinfo.fragsize == stream->fragsize);
-
- if (spaceinfo.fragments == 0)
- break;
-
- memset (frag, 0, stream->fragsize);
- swfdec_audio_render (stream->audio, (gint16 *)frag, stream->offset,
- stream->fragsize / SAMPLESIZE / CHANNELS);
-
- ret = write (stream->dsp_fd, frag, stream->fragsize);
- if (ret != stream->fragsize) {
- g_printerr ("Failed to write fragment\n");
- free(frag);
- return FALSE;
- }
-
- stream->offset += stream->fragsize / SAMPLESIZE / CHANNELS;
- }
-
- free(frag);
-
- return TRUE;
-}
-
-static void
-swfdec_playback_stream_open (SwfdecPlayback *sound, SwfdecAudio *audio)
-{
- GIOChannel *channel;
- Stream *stream;
- guint rate;
- int dsp_fd, ret, format, channels, fragsize;
-
- dsp_fd = open("/dev/dsp", O_WRONLY);
- if (dsp_fd == -1) {
- g_printerr ("Failed to open /dev/dsp\n");
- return;
- }
-
- format = AFMT_S16_LE;
- ret = ioctl(dsp_fd, SNDCTL_DSP_SETFMT, &format);
- if (ret == -1) {
- g_printerr ("Failed to set sound format\n");
- close(dsp_fd);
- return;
- }
-
- channels = 2;
- ret = ioctl(dsp_fd, SNDCTL_DSP_CHANNELS, &channels);
- if (ret == -1) {
- g_printerr ("Failed to set stereo\n");
- close(dsp_fd);
- return;
- }
-
- rate = 44100;
- ret = ioctl(dsp_fd, SNDCTL_DSP_SPEED, &rate);
- if (ret == -1) {
- g_printerr ("Failed to set rate\n");
- close(dsp_fd);
- return;
- }
-
- ret = ioctl(dsp_fd, SNDCTL_DSP_GETBLKSIZE, &fragsize);
- if (ret == -1) {
- g_printerr ("Failed to get fragment size\n");
- close(dsp_fd);
- return;
- }
-
- stream = g_new0 (Stream, 1);
- stream->sound = sound;
- stream->audio = g_object_ref (audio);
- stream->dsp_fd = dsp_fd;
- stream->fragsize = fragsize;
- sound->streams = g_list_prepend (sound->streams, stream);
-
- channel = g_io_channel_unix_new (stream->dsp_fd);
- stream->source = g_io_create_watch (channel, G_IO_OUT);
- g_source_set_priority (stream->source, G_PRIORITY_HIGH);
- g_source_set_callback (stream->source, (GSourceFunc) handle_stream, stream,
- NULL);
- g_io_channel_unref (channel);
- g_source_attach (stream->source, stream->sound->context);
-
- return;
-}
-
-static void
-swfdec_playback_stream_close (Stream *stream)
-{
- close (stream->dsp_fd);
- g_source_destroy (stream->source);
- g_source_unref (stream->source);
- stream->sound->streams = g_list_remove (stream->sound->streams, stream);
- g_object_unref (stream->audio);
- g_free (stream);
-}
-
-/*** SOUND ***/
-
-static void
-advance_before (SwfdecPlayer *player, guint msecs, guint audio_samples, gpointer data)
-{
- SwfdecPlayback *sound = data;
- GList *walk;
-
- for (walk = sound->streams; walk; walk = walk->next) {
- Stream *stream = walk->data;
- if (audio_samples >= stream->offset) {
- stream->offset = 0;
- } else {
- stream->offset -= audio_samples;
- }
- }
-}
-
-static void
-audio_added (SwfdecPlayer *player, SwfdecAudio *audio, SwfdecPlayback *sound)
-{
- swfdec_playback_stream_open (sound, audio);
-}
-
-static void
-audio_removed (SwfdecPlayer *player, SwfdecAudio *audio, SwfdecPlayback *sound)
-{
- GList *walk;
-
- for (walk = sound->streams; walk; walk = walk->next) {
- Stream *stream = walk->data;
- if (stream->audio == audio) {
- swfdec_playback_stream_close (stream);
- return;
- }
- }
- g_assert_not_reached ();
-}
-
-SwfdecPlayback *
-swfdec_playback_open (SwfdecPlayer *player, GMainContext *context)
-{
- SwfdecPlayback *sound;
- const GList *walk;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (context != NULL, NULL);
-
- sound = g_new0 (SwfdecPlayback, 1);
- sound->player = player;
- g_signal_connect (player, "advance", G_CALLBACK (advance_before), sound);
- g_signal_connect (player, "audio-added", G_CALLBACK (audio_added), sound);
- g_signal_connect (player, "audio-removed", G_CALLBACK (audio_removed), sound);
- for (walk = swfdec_player_get_audio (player); walk; walk = walk->next) {
- swfdec_playback_stream_open (sound, walk->data);
- }
- g_main_context_ref (context);
- sound->context = context;
- return sound;
-}
-
-void
-swfdec_playback_close (SwfdecPlayback *sound)
-{
-#define REMOVE_HANDLER_FULL(obj,func,data,count) G_STMT_START {\
- if (g_signal_handlers_disconnect_by_func ((obj), \
- G_CALLBACK (func), (data)) != (count)) { \
- g_assert_not_reached (); \
- } \
-} G_STMT_END
-#define REMOVE_HANDLER(obj,func,data) REMOVE_HANDLER_FULL (obj, func, data, 1)
-
- while (sound->streams)
- swfdec_playback_stream_close (sound->streams->data);
- REMOVE_HANDLER (sound->player, advance_before, sound);
- REMOVE_HANDLER (sound->player, audio_added, sound);
- REMOVE_HANDLER (sound->player, audio_removed, sound);
- g_main_context_unref (sound->context);
- g_free (sound);
-}
-
-
diff --git a/libswfdec-gtk/swfdec_playback_pa.c b/libswfdec-gtk/swfdec_playback_pa.c
deleted file mode 100644
index 755b033..0000000
--- a/libswfdec-gtk/swfdec_playback_pa.c
+++ /dev/null
@@ -1,350 +0,0 @@
-/* Swfdec
- * Copyright © 2006 Benjamin Otte <otte at gnome.org>
- * Copyright © 2007 Eric Anholt <eric at anholt.net>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "swfdec_playback.h"
-#include "pulse/pulseaudio.h"
-#include "pulse/glib-mainloop.h"
-
-/** @file Implements swfdec audio playback by dumping swfdec streams out
- * using pulseaudio streams.
- */
-
-/*** DEFINITIONS ***/
-
-struct _SwfdecPlayback {
- SwfdecPlayer * player;
- GList * streams; /* all Stream objects */
- GMainContext * context; /* glib context we work in */
- pa_glib_mainloop * pa_mainloop; /* PA to glib mainloop connection */
- pa_context * pa; /* PA context for sound rendering */
-};
-
-typedef struct {
- SwfdecPlayback * sound; /* reference to sound object */
- SwfdecAudio * audio; /* the audio we play back */
- guint offset; /* offset into sound */
- pa_stream * pa; /* PA stream */
- pa_cvolume volume; /* Volume control. Not yet used. */
- gboolean no_more;
-} Stream;
-
-/* Size of one of our audio samples, in bytes */
-#define SAMPLESIZE 2
-#define CHANNELS 2
-
-/*** STREAMS ***/
-
-static void
-stream_write_callback (pa_stream *pa,
- size_t bytes,
- void *data)
-{
- Stream *stream = data;
- char *frag;
- unsigned int samples = bytes / SAMPLESIZE / CHANNELS;
- int err;
-
- if (stream->no_more)
- return;
-
- /* Adjust to our rounded-down number */
- bytes = samples * SAMPLESIZE * CHANNELS;
-
- frag = malloc (bytes);
- if (frag == NULL) {
- g_printerr ("Failed to allocate fragment of size %d\n", (int)bytes);
- return;
- }
-
- /* Set up our fragment and render swfdec's audio into it. The swfdec audio
- * decoder renders deltas from the existing data in the fragment.
- */
- memset (frag, 0, bytes);
- swfdec_audio_render (stream->audio, (gint16 *)frag, stream->offset,
- samples);
-
- /* Send the new fragment out the PA stream */
- err = pa_stream_write (pa, frag, bytes, NULL, 0, PA_SEEK_RELATIVE);
- if (err != 0) {
- g_printerr ("Failed to write fragment to PA stream: %s\n",
- pa_strerror(pa_context_errno(stream->sound->pa)));
- }
-
- /* Advance playback pointer */
- stream->offset += samples;
-
- free(frag);
-}
-
-static void
-stream_drain_complete (pa_stream *pa, int success, void *data)
-{
- Stream *stream = data;
-
- pa_stream_disconnect (stream->pa);
- pa_stream_unref (stream->pa);
- g_object_unref (stream->audio);
- g_free (stream);
-}
-
-static void
-swfdec_playback_stream_close (Stream *stream)
-{
- /* Pull it off of the active stream list. */
- stream->sound->streams = g_list_remove (stream->sound->streams, stream);
-
- /* If we have created a PA stream, defer freeing until we drain it. */
- if (stream->pa != NULL) {
- stream->no_more = 1;
- pa_operation_unref (pa_stream_drain (stream->pa,
- stream_drain_complete,
- stream));
- } else {
- g_object_unref (stream->audio);
- g_free (stream);
- }
-}
-
-static void
-stream_state_callback (pa_stream *pa, void *data)
-{
- switch (pa_stream_get_state(pa)) {
- case PA_STREAM_CREATING:
- case PA_STREAM_TERMINATED:
- case PA_STREAM_READY:
- case PA_STREAM_UNCONNECTED:
- break;
-
- case PA_STREAM_FAILED:
- g_printerr("PA stream failed: %s\n",
- pa_strerror(pa_context_errno(pa_stream_get_context(pa))));
- default:
- break;
- }
-}
-
-static void
-swfdec_playback_stream_open (SwfdecPlayback *sound, SwfdecAudio *audio)
-{
- Stream *stream;
- pa_sample_spec spec = {
- .format = PA_SAMPLE_S16LE,
- .rate = 44100,
- .channels = CHANNELS,
- };
- int err;
-
- stream = g_new0 (Stream, 1);
- stream->sound = sound;
- stream->audio = g_object_ref (audio);
- sound->streams = g_list_prepend (sound->streams, stream);
-
- /* If we failed to initialize the context, don't try to create the stream.
- * We still have to get put in the list, because swfdec_playback.c expects
- * to find it in the list for removal later.
- */
- if (sound->pa == NULL)
- return;
-
- /* Create our stream */
- stream->pa = pa_stream_new(sound->pa,
- "swfdec stream",
- &spec,
- NULL /* Default channel map */
- );
- if (stream->pa == NULL) {
- g_printerr("Failed to create PA stream\n");
- swfdec_playback_stream_close(stream);
- return;
- }
-
- /* Start at default volume */
- pa_cvolume_set(&stream->volume, CHANNELS, PA_VOLUME_NORM);
-
- /* Hook up our stream write callback for when new data is needed */
- pa_stream_set_state_callback(stream->pa, stream_state_callback, stream);
- pa_stream_set_write_callback(stream->pa, stream_write_callback, stream);
-
- /* Connect it up as a playback stream. */
- err = pa_stream_connect_playback(stream->pa,
- NULL, /* Default device */
- NULL /* Default buffering */,
- 0, /* No flags */
- &stream->volume,
- NULL /* Don't sync to any stream */
- );
- if (err != 0) {
- g_printerr ("Failed to connect PA stream: %s\n",
- pa_strerror(pa_context_errno(sound->pa)));
- swfdec_playback_stream_close(stream);
- return;
- }
-}
-
-/*** SOUND ***/
-
-static void
-advance_before (SwfdecPlayer *player, guint msecs, guint audio_samples, gpointer data)
-{
- SwfdecPlayback *sound = data;
- GList *walk;
-
- for (walk = sound->streams; walk; walk = walk->next) {
- Stream *stream = walk->data;
- if (audio_samples >= stream->offset) {
- stream->offset = 0;
- } else {
- stream->offset -= audio_samples;
- }
- }
-}
-
-static void
-audio_added (SwfdecPlayer *player, SwfdecAudio *audio, SwfdecPlayback *sound)
-{
- swfdec_playback_stream_open (sound, audio);
-}
-
-static void
-audio_removed (SwfdecPlayer *player, SwfdecAudio *audio, SwfdecPlayback *sound)
-{
- GList *walk;
-
- for (walk = sound->streams; walk; walk = walk->next) {
- Stream *stream = walk->data;
- if (stream->audio == audio) {
- swfdec_playback_stream_close (stream);
- return;
- }
- }
- g_assert_not_reached ();
-}
-static void
-context_state_callback (pa_context *pa, void *data)
-{
- SwfdecPlayback *sound = data;
-
- switch (pa_context_get_state(pa)) {
- case PA_CONTEXT_FAILED:
- g_printerr ("PA context failed\n");
- pa_context_unref (pa);
- sound->pa = NULL;
- break;
-
- default:
- case PA_CONTEXT_TERMINATED:
- case PA_CONTEXT_UNCONNECTED:
- case PA_CONTEXT_CONNECTING:
- case PA_CONTEXT_AUTHORIZING:
- case PA_CONTEXT_SETTING_NAME:
- case PA_CONTEXT_READY:
- break;
-
- }
-}
-
-SwfdecPlayback *
-swfdec_playback_open (SwfdecPlayer *player, GMainContext *context)
-{
- SwfdecPlayback *sound;
- const GList *walk;
- pa_mainloop_api *pa_api;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (context != NULL, NULL);
-
- sound = g_new0 (SwfdecPlayback, 1);
- sound->player = player;
- g_signal_connect (player, "advance", G_CALLBACK (advance_before), sound);
- g_signal_connect (player, "audio-added", G_CALLBACK (audio_added), sound);
- g_signal_connect (player, "audio-removed", G_CALLBACK (audio_removed), sound);
-
- /* Create our mainloop attachment to glib. XXX: I hope this means we don't
- * have to run the main loop using pa functions.
- */
- sound->pa_mainloop = pa_glib_mainloop_new (context);
- pa_api = pa_glib_mainloop_get_api (sound->pa_mainloop);
-
- sound->pa = pa_context_new (pa_api, "swfdec");
-
- pa_context_set_state_callback (sound->pa, context_state_callback, sound);
- pa_context_connect (sound->pa,
- NULL, /* default server */
- 0, /* default flags */
- NULL /* spawning api */
- );
-
- for (walk = swfdec_player_get_audio (player); walk; walk = walk->next) {
- swfdec_playback_stream_open (sound, walk->data);
- }
- g_main_context_ref (context);
- sound->context = context;
- return sound;
-}
-
-static void
-context_drain_complete (pa_context *pa, void *data)
-{
- pa_context_disconnect (pa);
- pa_context_unref (pa);
-}
-
-void
-swfdec_playback_close (SwfdecPlayback *sound)
-{
- pa_operation *op;
-
-#define REMOVE_HANDLER_FULL(obj,func,data,count) G_STMT_START {\
- if (g_signal_handlers_disconnect_by_func ((obj), \
- G_CALLBACK (func), (data)) != (count)) { \
- g_assert_not_reached (); \
- } \
-} G_STMT_END
-#define REMOVE_HANDLER(obj,func,data) REMOVE_HANDLER_FULL (obj, func, data, 1)
-
- while (sound->streams)
- swfdec_playback_stream_close (sound->streams->data);
- REMOVE_HANDLER (sound->player, advance_before, sound);
- REMOVE_HANDLER (sound->player, audio_added, sound);
- REMOVE_HANDLER (sound->player, audio_removed, sound);
-
- if (sound->pa != NULL) {
- op = pa_context_drain (sound->pa, context_drain_complete, NULL);
- if (op == NULL) {
- pa_context_disconnect (sound->pa);
- pa_context_unref (sound->pa);
- } else {
- pa_operation_unref (op);
- }
- pa_glib_mainloop_free (sound->pa_mainloop);
- }
-
- g_main_context_unref (sound->context);
- g_free (sound);
-}
-
-
diff --git a/libswfdec-gtk/swfdec_source.c b/libswfdec-gtk/swfdec_source.c
deleted file mode 100644
index 471b99b..0000000
--- a/libswfdec-gtk/swfdec_source.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "swfdec_source.h"
-
-static glong
-my_time_val_difference (const GTimeVal *compare, const GTimeVal *now)
-{
- return (compare->tv_sec - now->tv_sec) * 1000 +
- (compare->tv_usec - now->tv_usec) / 1000;
-}
-
-/*** SwfdecIterateSource ***/
-
-typedef struct _SwfdecIterateSource SwfdecIterateSource;
-struct _SwfdecIterateSource {
- GSource source;
- SwfdecPlayer * player; /* player we manage or NULL if player was deleted */
- double speed; /* inverse playback speed (so 0.5 means double speed) */
- gulong notify; /* set for iterate notifications (only valid when player != NULL) */
- GTimeVal last; /* last time */
-};
-
-static glong
-swfdec_iterate_get_msecs_to_next_event (GSource *source_)
-{
- SwfdecIterateSource *source = (SwfdecIterateSource *) source_;
- GTimeVal now;
- glong diff;
-
- g_assert (source->player);
- diff = swfdec_player_get_next_event (source->player);
- if (diff == -1)
- return G_MAXLONG;
- diff *= source->speed;
- g_source_get_current_time (source_, &now);
- /* should really add to source->last instead of subtracting from now */
- g_time_val_add (&now, -diff * 1000);
- diff = my_time_val_difference (&source->last, &now);
-
- return diff;
-}
-
-static gboolean
-swfdec_iterate_prepare (GSource *source, gint *timeout)
-{
- glong diff;
-
- diff = swfdec_iterate_get_msecs_to_next_event (source);
- if (((SwfdecIterateSource *) source)->player == NULL) {
- *timeout = 0;
- return TRUE;
- }
-
- if (diff == G_MAXLONG) {
- *timeout = -1;
- return FALSE;
- } else if (diff <= 0) {
- *timeout = 0;
- return TRUE;
- } else {
- *timeout = diff;
- return FALSE;
- }
-}
-
-static gboolean
-swfdec_iterate_check (GSource *source)
-{
- glong diff;
-
- if (((SwfdecIterateSource *) source)->player == NULL)
- return 0;
- diff = swfdec_iterate_get_msecs_to_next_event (source);
- return diff < 0;
-}
-
-static gboolean
-swfdec_iterate_dispatch (GSource *source_, GSourceFunc callback, gpointer user_data)
-{
- SwfdecIterateSource *source = (SwfdecIterateSource *) source_;
- glong diff;
-
- if (source->player == NULL)
- return FALSE;
- diff = swfdec_iterate_get_msecs_to_next_event (source_);
- if (diff > 0)
- return TRUE;
- diff = swfdec_player_get_next_event (source->player) - diff;
- swfdec_player_advance (source->player, diff);
- return TRUE;
-}
-
-static void
-swfdec_iterate_finalize (GSource *source_)
-{
- SwfdecIterateSource *source = (SwfdecIterateSource *) source_;
-
- if (source->notify && source->player) {
- g_signal_handler_disconnect (source->player, source->notify);
- }
- if (source->player) {
- g_object_remove_weak_pointer (G_OBJECT (source->player), (gpointer) &source->player);
- }
-}
-
-GSourceFuncs swfdec_iterate_funcs = {
- swfdec_iterate_prepare,
- swfdec_iterate_check,
- swfdec_iterate_dispatch,
- swfdec_iterate_finalize
-};
-
-static void
-swfdec_iterate_source_advance_cb (SwfdecPlayer *player, guint msecs,
- guint audio_frames, SwfdecIterateSource *source)
-{
- g_time_val_add (&source->last, msecs * 1000 * source->speed);
-}
-
-GSource *
-swfdec_iterate_source_new (SwfdecPlayer *player, double speed)
-{
- SwfdecIterateSource *source;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (speed > 0.0, NULL);
-
- source = (SwfdecIterateSource *) g_source_new (&swfdec_iterate_funcs,
- sizeof (SwfdecIterateSource));
- source->player = player;
- g_object_add_weak_pointer (G_OBJECT (source->player), (gpointer) &source->player);
- source->speed = 1.0 / speed;
- source->notify = g_signal_connect (player, "advance",
- G_CALLBACK (swfdec_iterate_source_advance_cb), source);
- g_get_current_time (&source->last);
-
- return (GSource *) source;
-}
-
-void
-swfdec_iterate_source_set_speed (GSource *source, double speed)
-{
- /* FIXME: need a return_if_fail if wrong source? */
- g_return_if_fail (speed > 0.0);
-
- ((SwfdecIterateSource *) source)->speed = 1.0 / speed;
-}
-
-guint
-swfdec_iterate_add (SwfdecPlayer *player)
-{
- GSource *source;
- guint id;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), 0);
-
- source = swfdec_iterate_source_new (player, 1.0);
-
- id = g_source_attach (source, NULL);
- g_source_unref (source);
-
- return id;
-}
diff --git a/libswfdec-gtk/swfdec_source.h b/libswfdec-gtk/swfdec_source.h
deleted file mode 100644
index 0c7c383..0000000
--- a/libswfdec-gtk/swfdec_source.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_SOURCE_H_
-#define _SWFDEC_SOURCE_H_
-
-#include <libswfdec/swfdec.h>
-
-G_BEGIN_DECLS
-
-GSource * swfdec_iterate_source_new (SwfdecPlayer * player,
- double speed);
-void swfdec_iterate_source_set_speed (GSource * source,
- double speed);
-guint swfdec_iterate_add (SwfdecPlayer * player);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/.gitignore b/libswfdec/.gitignore
deleted file mode 100644
index 9f923f0..0000000
--- a/libswfdec/.gitignore
+++ /dev/null
@@ -1,19 +0,0 @@
-*~
-CVS
-.cvsignore
-.deps
-.libs
-
-Makefile
-Makefile.in
-*.o
-*.la
-*.lo
-*.loT
-
-swfdec_as_strings.h
-swfdec_asnative.h
-swfdec_enums.[ch]
-swfdec_marshal.[ch]
-
-compiler
diff --git a/libswfdec/Makefile.am b/libswfdec/Makefile.am
deleted file mode 100644
index dc62604..0000000
--- a/libswfdec/Makefile.am
+++ /dev/null
@@ -1,372 +0,0 @@
-SUBDIRS = jpeg
-
-CODECS =
-
-if HAVE_FFMPEG
-CODECS += swfdec_codec_ffmpeg.c
-endif
-if HAVE_GST
-CODECS += swfdec_codec_gst.c
-endif
-if HAVE_MAD
-CODECS += swfdec_codec_mad.c
-endif
-
-lib_LTLIBRARIES = libswfdec- at SWFDEC_MAJORMINOR@.la
-
-# these are files that must be in SRCDIR
-libswfdec_source_files = \
- swfdec_accessibility.c \
- swfdec_as_array.c \
- swfdec_as_boolean.c \
- swfdec_as_context.c \
- swfdec_as_date.c \
- swfdec_as_debugger.c \
- swfdec_as_frame.c \
- swfdec_as_function.c \
- swfdec_as_interpret.c \
- swfdec_as_math.c \
- swfdec_as_native_function.c \
- swfdec_as_number.c \
- swfdec_as_object.c \
- swfdec_as_script_function.c \
- swfdec_as_stack.c \
- swfdec_as_string.c \
- swfdec_as_strings.c \
- swfdec_as_super.c \
- swfdec_as_types.c \
- swfdec_amf.c \
- swfdec_asbroadcaster.c \
- swfdec_audio.c \
- swfdec_audio_event.c \
- swfdec_audio_flv.c \
- swfdec_audio_stream.c \
- swfdec_bevel_filter.c \
- swfdec_bitmap_data.c \
- swfdec_bitmap_filter.c \
- swfdec_bits.c \
- swfdec_blur_filter.c \
- swfdec_buffer.c \
- swfdec_button.c \
- swfdec_button_movie.c \
- swfdec_button_movie_as.c \
- swfdec_cache.c \
- swfdec_cached.c \
- swfdec_camera.c \
- swfdec_character.c \
- swfdec_codec_adpcm.c \
- swfdec_codec_audio.c \
- $(CODECS) \
- swfdec_codec_screen.c \
- swfdec_codec_video.c \
- swfdec_codec_vp6_alpha.c \
- swfdec_color.c \
- swfdec_color_as.c \
- swfdec_color_matrix_filter.c \
- swfdec_color_transform.c \
- swfdec_convolution_filter.c \
- swfdec_debug.c \
- swfdec_decoder.c \
- swfdec_displacement_map_filter.c \
- swfdec_draw.c \
- swfdec_drop_shadow_filter.c \
- swfdec_event.c \
- swfdec_external_interface.c \
- swfdec_file_loader.c \
- swfdec_file_reference.c \
- swfdec_file_reference_list.c \
- swfdec_filter.c \
- swfdec_filter_as.c \
- swfdec_flv_decoder.c \
- swfdec_font.c \
- swfdec_function_list.c \
- swfdec_glow_filter.c \
- swfdec_gradient_filter.c \
- swfdec_gradient_pattern.c \
- swfdec_graphic.c \
- swfdec_graphic_movie.c \
- swfdec_image.c \
- swfdec_image_decoder.c \
- swfdec_interval.c \
- swfdec_key_as.c \
- swfdec_load_object.c \
- swfdec_load_object_as.c \
- swfdec_loader.c \
- swfdec_loadvars_as.c \
- swfdec_local_connection.c \
- swfdec_microphone.c \
- swfdec_morph_movie.c \
- swfdec_morphshape.c \
- swfdec_mouse_as.c \
- swfdec_movie.c \
- swfdec_movie_as_drawing.c \
- swfdec_movie_asprops.c \
- swfdec_movie_clip_loader.c \
- swfdec_net_connection.c \
- swfdec_net_stream.c \
- swfdec_net_stream_as.c \
- swfdec_path.c \
- swfdec_pattern.c \
- swfdec_player.c \
- swfdec_player_as.c \
- swfdec_player_scripting.c \
- swfdec_print_job.c \
- swfdec_policy_file.c \
- swfdec_rect.c \
- swfdec_rectangle.c \
- swfdec_resource.c \
- swfdec_ringbuffer.c \
- swfdec_sandbox.c \
- swfdec_script.c \
- swfdec_selection.c \
- swfdec_shape.c \
- swfdec_shape_parser.c \
- swfdec_shared_object.c \
- swfdec_socket.c \
- swfdec_sound.c \
- swfdec_sound_object.c \
- swfdec_sprite.c \
- swfdec_sprite_movie.c \
- swfdec_sprite_movie_as.c \
- swfdec_stage_as.c \
- swfdec_stream.c \
- swfdec_stream_target.c \
- swfdec_stroke.c \
- swfdec_style_sheet.c \
- swfdec_swf_decoder.c \
- swfdec_system.c \
- swfdec_system_as.c \
- swfdec_system_ime.c \
- swfdec_system_security.c \
- swfdec_tag.c \
- swfdec_text.c \
- swfdec_text_field.c \
- swfdec_text_field_movie.c \
- swfdec_text_field_movie_as.c \
- swfdec_text_field_movie_html.c \
- swfdec_text_format.c \
- swfdec_text_renderer.c \
- swfdec_text_snapshot.c \
- swfdec_transform.c \
- swfdec_url.c \
- swfdec_utils.c \
- swfdec_video.c \
- swfdec_video_movie.c \
- swfdec_video_movie_as.c \
- swfdec_xml_node.c \
- swfdec_xml.c \
- swfdec_xml_socket.c
-
-libswfdec_ at SWFDEC_MAJORMINOR@_la_SOURCES = \
- $(libswfdec_source_files) \
- swfdec_enums.c \
- swfdec_marshal.c
-
-libswfdec_ at SWFDEC_MAJORMINOR@_la_CFLAGS = \
- $(GLOBAL_CFLAGS) $(CAIRO_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) \
- -I$(top_srcdir) -I$(srcdir)/jpeg/ $(LIBOIL_CFLAGS) \
- $(GST_CFLAGS) $(FFMPEG_CFLAGS) $(MAD_CFLAGS) \
- -DG_LOG_DOMAIN=\"Swfdec\"
-libswfdec_ at SWFDEC_MAJORMINOR@_la_LDFLAGS = \
- $(SYMBOLIC_LDFLAGS) \
- -version-info $(SWFDEC_LIBVERSION) \
- -export-symbols-regex '^(swfdec_.*)' \
- $(CAIRO_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) $(LIBOIL_LIBS) -lz \
- $(MAD_LIBS) $(FFMPEG_LIBS) $(GST_LIBS)
-
-public_headers = \
- swfdec.h \
- swfdec_as_array.h \
- swfdec_as_context.h \
- swfdec_as_debugger.h \
- swfdec_as_frame.h \
- swfdec_as_function.h \
- swfdec_as_native_function.h \
- swfdec_as_object.h \
- swfdec_as_types.h \
- swfdec_audio.h \
- swfdec_buffer.h \
- swfdec_file_loader.h \
- swfdec_keys.h \
- swfdec_loader.h \
- swfdec_player.h \
- swfdec_player_scripting.h \
- swfdec_rectangle.h \
- swfdec_script.h \
- swfdec_socket.h \
- swfdec_stream.h \
- swfdec_system.h \
- swfdec_url.h
-
-libswfdec_ at SWFDEC_MAJORMINOR@_la_LIBADD = jpeg/libjpeg.la
-libswfdec_ at SWFDEC_MAJORMINOR@includedir = $(includedir)/swfdec- at SWFDEC_MAJORMINOR@/libswfdec
-libswfdec_ at SWFDEC_MAJORMINOR@include_HEADERS = $(public_headers) swfdec_enums.h
-
-noinst_HEADERS = \
- swfdec_as_boolean.h \
- swfdec_as_frame_internal.h \
- swfdec_as_initialize.h \
- swfdec_as_internal.h \
- swfdec_as_date.h \
- swfdec_as_interpret.h \
- swfdec_as_number.h \
- swfdec_as_script_function.h \
- swfdec_as_stack.h \
- swfdec_as_string.h \
- swfdec_as_strings.h \
- swfdec_as_super.h \
- swfdec_asnative.h \
- swfdec_amf.h \
- swfdec_audio_internal.h \
- swfdec_audio_event.h \
- swfdec_audio_flv.h \
- swfdec_audio_stream.h \
- swfdec_bits.h \
- swfdec_button.h \
- swfdec_button_movie.h \
- swfdec_cache.h \
- swfdec_cached.h \
- swfdec_character.h \
- swfdec_codec_audio.h \
- swfdec_codec_video.h \
- swfdec_color.h \
- swfdec_debug.h \
- swfdec_decoder.h \
- swfdec_draw.h \
- swfdec_text_field.h \
- swfdec_text_field_movie.h \
- swfdec_event.h \
- swfdec_filter.h \
- swfdec_flv_decoder.h \
- swfdec_font.h \
- swfdec_function_list.h \
- swfdec_gradient_pattern.h \
- swfdec_graphic.h \
- swfdec_graphic_movie.h \
- swfdec_image.h \
- swfdec_image_decoder.h \
- swfdec_initialize.h \
- swfdec_internal.h \
- swfdec_interval.h \
- swfdec_load_object.h \
- swfdec_loader_internal.h \
- swfdec_marshal.h \
- swfdec_morph_movie.h \
- swfdec_morphshape.h \
- swfdec_movie.h \
- swfdec_movie_clip_loader.h \
- swfdec_net_connection.h \
- swfdec_net_stream.h \
- swfdec_path.h \
- swfdec_pattern.h \
- swfdec_player_internal.h \
- swfdec_policy_file.h \
- swfdec_rect.h \
- swfdec_resource.h \
- swfdec_ringbuffer.h \
- swfdec_sandbox.h \
- swfdec_script_internal.h \
- swfdec_shape.h \
- swfdec_shape_parser.h \
- swfdec_sound.h \
- swfdec_sound_object.h \
- swfdec_sprite.h \
- swfdec_sprite_movie.h \
- swfdec_swf_decoder.h \
- swfdec_stream_target.h \
- swfdec_stroke.h \
- swfdec_style_sheet.h \
- swfdec_tag.h \
- swfdec_text.h \
- swfdec_text_format.h \
- swfdec_types.h \
- swfdec_utils.h \
- swfdec_video.h \
- swfdec_video_movie.h \
- swfdec_xml_node.h \
- swfdec_xml.h \
- swfdec_xml_socket.h
-
-EXTRA_DIST = \
- compiler.c \
- swfdec_as_initialize.as \
- swfdec_initialize.as \
- swfdec_marshal.list
-
-BUILT_SOURCES = \
- swfdec_asnative.h \
- swfdec_as_strings.h \
- swfdec_enums.c \
- swfdec_enums.h \
- swfdec_marshal.c \
- swfdec_marshal.h
-
-CLEANFILES = \
- $(BUILT_SOURCES)
-
-swfdec_asnative.h: $(libswfdec_source_files)
- (cd $(srcdir) \
- && echo "#include \"swfdec_as_types.h\"" \
- && echo "#define SWFDEC_AS_NATIVE(x,y,func) void func (SwfdecAsContext *cx, \\" \
- && echo " SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret);" \
- && echo "#define SWFDEC_AS_CONSTRUCTOR(x,y,func,type) SWFDEC_AS_NATIVE(x,y,func) GType type (void);" \
- && grep -he "^SWFDEC_AS_CONSTRUCTOR" $(libswfdec_source_files) \
- && grep -he "^SWFDEC_AS_NATIVE" $(libswfdec_source_files) \
- && echo "#undef SWFDEC_AS_CONSTRUCTOR" \
- && echo "#undef SWFDEC_AS_NATIVE" \
- && echo "#define SWFDEC_AS_NATIVE(x,y,func) SWFDEC_AS_CONSTRUCTOR(x,y,func,NULL)" \
- && echo "#define SWFDEC_AS_CONSTRUCTOR(x,y,func,type) { x, y, func, G_STRINGIFY (func), type }," \
- && echo "static const struct { guint x, y; SwfdecAsNative func; const char *name; GType (* get_type) (void); } native_funcs[] = {" \
- && grep -he "^SWFDEC_AS_CONSTRUCTOR" $(libswfdec_source_files) \
- && grep -he "^SWFDEC_AS_NATIVE" $(libswfdec_source_files) \
- && echo " { 0, 0, NULL }" \
- && echo "};" \
- && echo "#undef SWFDEC_AS_CONSTRUCTOR" \
- && echo "#undef SWFDEC_AS_NATIVE" \
- ) >> xgen-san \
- && (cmp -s xgen-san swfdec_asnative.h || cp xgen-san swfdec_asnative.h) \
- && rm -f xgen-san
-
-swfdec_marshal.h: swfdec_marshal.list Makefile
- $(GLIB_GENMARSHAL) --prefix=swfdec_marshal $(srcdir)/swfdec_marshal.list --header >> xgen-smh \
- && (cmp -s xgen-smh swfdec_marshal.h || cp xgen-smh swfdec_marshal.h) \
- && rm -f xgen-smh
-
-swfdec_marshal.c: swfdec_marshal.list swfdec_marshal.h Makefile
- (echo "#include \"swfdec_marshal.h\""; \
- $(GLIB_GENMARSHAL) --prefix=swfdec_marshal $(srcdir)/swfdec_marshal.list --body;) >> xgen-smc \
- && cp xgen-smc swfdec_marshal.c \
- && rm -f xgen-smc
-
-swfdec_enums.h: $(public_headers) Makefile
- ( cd $(srcdir) && $(GLIB_MKENUMS) \
- --fhead "#ifndef __SWFDEC_ENUMS_H__\n#define __SWFDEC_ENUMS_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \
- --fprod "/* enumerations from \"@filename@\" */\n" \
- --vhead "GType @enum_name at _get_type (void) G_GNUC_CONST;\n#define SWFDEC_TYPE_ at ENUMSHORT@ (@enum_name at _get_type())\n" \
- --ftail "G_END_DECLS\n\n#endif /* __SWFDEC_ENUMS_H__ */" \
- $(public_headers) ) >> xgen-seh \
- && (cmp -s xgen-seh swfdec_enums.h || cp xgen-seh swfdec_enums.h ) \
- && rm -f xgen-seh
-
-swfdec_enums.c: $(public_headers) Makefile
- ( cd $(srcdir) && $(GLIB_MKENUMS) \
- --fhead "#include \"swfdec.h\"\n" \
- --fprod "\n/* enumerations from \"@filename@\" */" \
- --vhead "GType\n at enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G at Type@Value values[] = {" \
- --vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
- --vtail " { 0, NULL, NULL }\n };\n etype = g_ at type@_register_static (g_intern_static_string (\"@EnumName@\"), values);\n }\n return etype;\n}\n" \
- $(public_headers) ) > xgen-sec \
- && (cmp -s xgen-sec swfdec_enums.c || cp xgen-sec swfdec_enums.c ) \
- && rm -f xgen-sec
-
-swfdec_as_strings.h: swfdec_as_strings.c
- ( cd $(srcdir) && echo "/* This is a generated file. See swfdec_as_strings.c for details. */" \
- && echo "#ifndef _SWFDEC_AS_STRINGS_H_" \
- && echo "#define _SWFDEC_AS_STRINGS_H_" \
- && echo "extern const char swfdec_as_strings[];" \
- && grep " SWFDEC_AS_CONSTANT_STRING" swfdec_as_strings.c \
- | sed "s/.*(\"\(.*\)\").*/\1/" \
- | $(AWK) '{ if ($$0 == "") name = "EMPTY"; else if ($$0 == ",") name = "COMMA"; else if ($$0 == "/") name = "SLASH"; else name = $$0; gsub("[^a-zA-Z0-9\\$$]","_",name); print "#define SWFDEC_AS_STR_" name " &swfdec_as_strings[" x + 1 "]"; x = x + length ($$0) + 2 }' \
- && echo "#endif" ) > xgen-sas \
- && (cmp -s xgen-sas swfdec_as_strings.h || cp xgen-sas swfdec_as_strings.h ) \
- && rm -f xgen-sas
diff --git a/libswfdec/compiler.c b/libswfdec/compiler.c
deleted file mode 100644
index 5593cec..0000000
--- a/libswfdec/compiler.c
+++ /dev/null
@@ -1,92 +0,0 @@
-//gcc -Wall -Werror `pkg-config --libs --cflags libming glib-2.0` compiler.c -o compiler
-
-#include <glib.h>
-#include <ming.h>
-#include <string.h>
-
-/* This is what is used to compile the Actionscript parts of the source to
- * includable C data that can later be executed.
- * Note that this is pretty much a hack until someone writes a proper
- * Actionscript compiler for Swfdec.
- * Also note that the creation of the include-scripts should probably not be
- * autorun, as we don't want to depend on external bugs, only on internal ones.
- */
-static gboolean
-write_data (guint8 *data, gsize len)
-{
- gsize i;
-
- for (i = 0; i < len; i++) {
- switch (i % 16) {
- case 0:
- if (i == 0)
- g_print (" 0x%02X", data[i]);
- else
- g_print (",\n 0x%02X", data[i]);
- break;
- case 4:
- case 8:
- case 12:
- g_print (", 0x%02X", data[i]);
- break;
- default:
- g_print (", 0x%02X", data[i]);
- break;
- }
- }
- g_print ("\n");
- return TRUE;
-}
-
-static char *
-get_name (const char *filename)
-{
- char *end;
-
- end = strrchr (filename, '/');
- if (end)
- filename = end + 1;
- end = strchr (filename, '.');
- if (end)
- return g_strndup (filename, end - filename);
- else
- return g_strdup (filename);
-}
-
-int
-main (int argc, char **argv)
-{
- SWFAction action;
- char *contents;
- GError *error = NULL;
- guint i;
- gsize len;
- byte *data;
-
- if (argc < 2) {
- g_print ("usage: %s FILE ...\n\n", argv[0]);
- return 1;
- }
-
- Ming_init ();
- Ming_setSWFCompression (-1);
-
- g_print ("/* This file is autogenerated, do not edit! */\n\n");
- for (i = 1; i < argc; i++) {
- if (!g_file_get_contents (argv[1], &contents, NULL, &error)) {
- g_printerr ("%s\n", error->message);
- g_error_free (error);
- error = NULL;
- return 1;
- }
- action = newSWFAction (contents);
- data = SWFAction_getByteCode (action, &len);
- contents = get_name (argv[i]);
- g_print ("/* compiled from %s */\n", argv[i]);
- g_print ("static const unsigned char %s[] = {\n", contents);
- g_free (contents);
- write_data (data, len);
- g_print ("};\n\n");
- }
- return 0;
-}
diff --git a/libswfdec/jpeg/.gitignore b/libswfdec/jpeg/.gitignore
deleted file mode 100644
index 5bb735b..0000000
--- a/libswfdec/jpeg/.gitignore
+++ /dev/null
@@ -1,14 +0,0 @@
-*~
-CVS
-.cvsignore
-.deps
-.libs
-
-Makefile
-Makefile.in
-*.o
-*.la
-*.lo
-
-jpeg_test
-jpeg_rgb_test
diff --git a/libswfdec/jpeg/Makefile.am b/libswfdec/jpeg/Makefile.am
deleted file mode 100644
index d6475cc..0000000
--- a/libswfdec/jpeg/Makefile.am
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-noinst_LTLIBRARIES = libjpeg.la
-
-libjpeg_la_SOURCES = \
- jpeg.c \
- jpeg_bits.c \
- jpeg_huffman.c \
- jpeg_rgb_decoder.c \
- jpeg_tables.c
-
-noinst_HEADERS = \
- cogcompat.h \
- jpeg.h \
- jpeg_bits.h \
- jpeg_huffman.h \
- jpeg_rgb_decoder.h
-
-libjpeg_la_CFLAGS = $(GLOBAL_CFLAGS) $(GLIB_CFLAGS) $(LIBOIL_CFLAGS) -I$(srcdir)/..
-
diff --git a/libswfdec/jpeg/cogcompat.h b/libswfdec/jpeg/cogcompat.h
deleted file mode 100644
index bf2370f..0000000
--- a/libswfdec/jpeg/cogcompat.h
+++ /dev/null
@@ -1,14 +0,0 @@
-
-#ifndef _COG_COMPAT_H_
-#define _COG_COMPAT_H_
-
-#include <swfdec_debug.h>
-
-#define COG_LOG(...) SWFDEC_LOG(__VA_ARGS__)
-#define COG_DEBUG(...) SWFDEC_DEBUG(__VA_ARGS__)
-#define COG_INFO(...) SWFDEC_INFO(__VA_ARGS__)
-#define COG_WARNING(...) SWFDEC_WARNING(__VA_ARGS__)
-#define COG_ERROR(...) SWFDEC_ERROR(__VA_ARGS__)
-
-#endif
-
diff --git a/libswfdec/jpeg/jpeg.c b/libswfdec/jpeg/jpeg.c
deleted file mode 100644
index 52143dc..0000000
--- a/libswfdec/jpeg/jpeg.c
+++ /dev/null
@@ -1,1126 +0,0 @@
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <liboil/liboil.h>
-#include <liboil/liboil-stdint.h>
-#include <cogcompat.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "jpeg.h"
-
-
-extern uint8_t jpeg_standard_tables[];
-extern int jpeg_standard_tables_size;
-
-void jpeg_decoder_define_huffman_tables (JpegDecoder * dec);
-void jpeg_decoder_define_arithmetic_conditioning (JpegDecoder *dec);
-void jpeg_decoder_define_quantization_tables (JpegDecoder *dec);
-void jpeg_decoder_define_restart_interval (JpegDecoder *dec);
-void jpeg_decoder_start_of_frame (JpegDecoder * dec, int marker);
-void jpeg_decoder_start_of_scan (JpegDecoder * dec);
-
-
-/* misc helper function declarations */
-
-static void jpeg_load_standard_huffman_tables (JpegDecoder * dec);
-
-static void jpeg_decoder_verify_header (JpegDecoder *dec);
-static void jpeg_decoder_init_decoder (JpegDecoder *dec);
-
-
-void
-jpeg_decoder_error(JpegDecoder *dec, const char *fmt, ...)
-{
- va_list varargs;
-
- if (dec->error) return;
-
- va_start (varargs, fmt);
-#ifdef HAVE_VASPRINTF
- vasprintf(&dec->error_message, fmt, varargs);
-#else
- dec->error_message = malloc(250);
- vsnprintf(dec->error_message, 250 - 1, fmt, varargs);
- dec->error_message[250 - 1] = 0;
-#endif
- va_end (varargs);
-
- dec->error = TRUE;
-}
-
-#define jpeg_decoder_error(dec, ...) { \
- COG_ERROR("decoder error: "__VA_ARGS__); \
- jpeg_decoder_error (dec, __VA_ARGS__); \
-}
-
-static void
-jpeg_decoder_verify_header (JpegDecoder *dec)
-{
- int max_quant_table = 0;
- int i;
-
- if (dec->sof_type != JPEG_MARKER_SOF_0) {
- COG_ERROR("only handle baseline DCT");
- dec->error = TRUE;
- }
-
- if (dec->width < 1) {
- COG_ERROR("height can't be 0");
- dec->error = TRUE;
- }
-
- switch (dec->sof_type) {
- case JPEG_MARKER_SOF_0:
- /* baseline DCT */
- max_quant_table = 3;
- if (dec->depth != 8) {
- COG_ERROR("depth must be 8 (%d)", dec->depth);
- dec->error = TRUE;
- }
- break;
- case JPEG_MARKER_SOF_1:
- /* extended DCT */
- max_quant_table = 3;
- if (dec->depth != 8 && dec->depth != 12) {
- COG_ERROR("depth must be 8 or 12 (%d)", dec->depth);
- dec->error = TRUE;
- }
- break;
- case JPEG_MARKER_SOF_2:
- /* progressive DCT */
- max_quant_table = 3;
- if (dec->depth != 8 && dec->depth != 12) {
- COG_ERROR("depth must be 8 or 12 (%d)", dec->depth);
- dec->error = TRUE;
- }
- break;
- case JPEG_MARKER_SOF_3:
- /* lossless DCT */
- max_quant_table = 0;
- if (dec->depth < 2 || dec->depth > 16) {
- COG_ERROR("depth must be between 2 and 16 (%d)", dec->depth);
- dec->error = TRUE;
- }
- break;
- default:
- break;
- }
-
- if (dec->n_components < 0 || dec->n_components > 255) {
- COG_ERROR("n_components must be in the range 0-255 (%d)",
- dec->n_components);
- dec->error = TRUE;
- }
- if (dec->sof_type == JPEG_MARKER_SOF_2 && dec->n_components > 4) {
- COG_ERROR("n_components must be <= 4 for progressive DCT (%d)",
- dec->n_components);
- dec->error = TRUE;
- }
-
- for (i = 0; i < dec->n_components; i++) {
- if (dec->components[i].id < 0 || dec->components[i].id > 255) {
- COG_ERROR("component ID out of range");
- dec->error = TRUE;
- break;
- }
- if (dec->components[i].h_sample < 1 || dec->components[i].h_sample > 4 ||
- dec->components[i].v_sample < 1 || dec->components[i].v_sample > 4) {
- COG_ERROR("sample factor(s) for component %d out of range %d %d",
- i, dec->components[i].h_sample, dec->components[i].v_sample);
- dec->error = TRUE;
- break;
- }
- if (dec->components[i].quant_table < 0 ||
- dec->components[i].quant_table > max_quant_table) {
- COG_ERROR("quant table for component %d out of range (%d)",
- i, dec->components[i].quant_table);
- dec->error = TRUE;
- break;
- }
- }
-}
-
-static void
-jpeg_decoder_init_decoder (JpegDecoder *dec)
-{
- int max_h_sample = 0;
- int max_v_sample = 0;
- int i;
-
- /* decoder limitations */
- if (dec->n_components != 3) {
- jpeg_decoder_error(dec, "wrong number of components %d", dec->n_components);
- return;
- }
- if (dec->sof_type != JPEG_MARKER_SOF_0) {
- jpeg_decoder_error(dec, "only handle baseline DCT");
- return;
- }
-
-
-
-
- for (i=0; i < dec->n_components; i++) {
- max_h_sample = MAX (max_h_sample, dec->components[i].h_sample);
- max_v_sample = MAX (max_v_sample, dec->components[i].v_sample);
- }
-
- dec->width_blocks =
- (dec->width + 8 * max_h_sample - 1) / (8 * max_h_sample);
- dec->height_blocks =
- (dec->height + 8 * max_v_sample - 1) / (8 * max_v_sample);
- for (i = 0; i < dec->n_components; i++) {
- int rowstride;
- int image_size;
-
- dec->components[i].h_subsample = max_h_sample /
- dec->components[i].h_sample;
- dec->components[i].v_subsample = max_v_sample /
- dec->components[i].v_sample;
-
- rowstride = dec->width_blocks * 8 * max_h_sample /
- dec->components[i].h_subsample;
- image_size = rowstride *
- (dec->height_blocks * 8 * max_v_sample /
- dec->components[i].v_subsample);
- dec->components[i].rowstride = rowstride;
- dec->components[i].image = malloc (image_size);
- }
-}
-
-#if 0
-static char *
-sprintbits (char *str, unsigned int bits, int n)
-{
- int i;
- int bit = 1 << (n - 1);
-
- for (i = 0; i < n; i++) {
- str[i] = (bits & bit) ? '1' : '0';
- bit >>= 1;
- }
- str[i] = 0;
-
- return str;
-}
-
-static void
-generate_code_table (int *huffsize)
-{
- int code;
- int i;
- int j;
- int k;
- char str[33];
-
- //int l;
-
- code = 0;
- k = 0;
- for (i = 0; i < 16; i++) {
- for (j = 0; j < huffsize[i]; j++) {
- COG_DEBUG ("huffcode[%d] = %s", k,
- sprintbits (str, code >> (15 - i), i + 1));
- code++;
- k++;
- }
- code <<= 1;
- }
-
-}
-#endif
-
-static int
-huffman_table_init_jpeg (JpegDecoder *decoder, HuffmanTable *table, JpegBits * bits)
-{
- int n_symbols;
- int huffsize[16];
- int i, j, k;
- unsigned int symbol;
- int n = 0;
-
- huffman_table_init (table);
-
- /* huffsize[i] is the number of symbols that have length
- * (i+1) bits. Maximum bit length is 16 bits, so there are
- * 16 entries. */
- n_symbols = 0;
- for (i = 0; i < 16; i++) {
- huffsize[i] = jpeg_bits_get_u8 (bits);
- n++;
- n_symbols += huffsize[i];
- }
-
- /* Build up the symbol table. The first symbol is all 0's, with
- * the number of bits determined by the first non-zero entry in
- * huffsize[]. Subsequent symbols with the same bit length are
- * incremented by 1. Increasing the bit length shifts the
- * symbol 1 bit to the left. */
- symbol = 0;
- k = 0;
- for (i = 0; i < 16; i++) {
- for (j = 0; j < huffsize[i]; j++) {
- huffman_table_add (table, symbol, i + 1, jpeg_bits_get_u8 (bits));
- n++;
- symbol++;
- k++;
- }
- /* This checks that our symbol is actually less than the
- * number of bits we think it is. This is only triggered
- * for bad huffsize[] arrays. */
- if (symbol >= (1U << (i + 1))) {
- jpeg_decoder_error (decoder, "bad huffsize[] array");
- return -1;
- }
-
- symbol <<= 1;
- }
-
- huffman_table_dump (table);
-
- return n;
-}
-
-static int
-jpeg_decoder_find_component_by_id (JpegDecoder * dec, int id)
-{
- int i;
-
- for (i = 0; i < dec->n_components; i++) {
- if (dec->components[i].id == id)
- return i;
- }
- COG_DEBUG ("undefined component id %d", id);
- return 0;
-}
-
-int
-jpeg_decoder_application0 (JpegDecoder * dec, JpegBits * bits)
-{
- int length;
-
- COG_DEBUG ("app0");
-
- length = get_be_u16 (bits);
- COG_DEBUG ("length=%d", length);
-
- if (memcmp (bits->ptr, "JFIF", 4) == 0 && bits->ptr[4] == 0) {
- int version;
- int units;
- int x_density;
- int y_density;
- int x_thumbnail;
- int y_thumbnail;
-
- COG_DEBUG ("JFIF");
- bits->ptr += 5;
-
- version = get_be_u16 (bits);
- units = get_u8 (bits);
- x_density = get_be_u16 (bits);
- y_density = get_be_u16 (bits);
- x_thumbnail = get_u8 (bits);
- y_thumbnail = get_u8 (bits);
-
- COG_DEBUG ("version = %04x", version);
- COG_DEBUG ("units = %d", units);
- COG_DEBUG ("x_density = %d", x_density);
- COG_DEBUG ("y_density = %d", y_density);
- COG_DEBUG ("x_thumbnail = %d", x_thumbnail);
- COG_DEBUG ("y_thumbnail = %d", y_thumbnail);
-
- }
-
- if (memcmp (bits->ptr, "JFXX", 4) == 0 && bits->ptr[4] == 0) {
- COG_DEBUG ("JFIF extension (not handled)");
- bits->ptr += length - 2;
- }
-
- return length;
-}
-
-int
-jpeg_decoder_application_misc (JpegDecoder * dec, JpegBits * bits)
-{
- int length;
-
- COG_DEBUG ("appX");
-
- length = get_be_u16 (bits);
- COG_DEBUG ("length=%d", length);
-
- COG_DEBUG ("JPEG application tag X ignored");
- //dumpbits (bits);
-
- bits->ptr += length - 2;
-
- return length;
-}
-
-int
-jpeg_decoder_comment (JpegDecoder * dec, JpegBits * bits)
-{
- int length;
-
- COG_DEBUG ("comment");
-
- length = get_be_u16 (bits);
- COG_DEBUG ("length=%d", length);
-
- //dumpbits (bits);
-
- bits->ptr += length - 2;
-
- return length;
-}
-
-int
-jpeg_decoder_restart_interval (JpegDecoder * dec, JpegBits * bits)
-{
- int length;
-
- COG_DEBUG ("comment");
-
- length = get_be_u16 (bits);
- COG_DEBUG ("length=%d", length);
-
- dec->restart_interval = get_be_u16 (bits);
- COG_DEBUG ("restart_interval=%d", dec->restart_interval);
-
- return length;
-}
-
-int
-jpeg_decoder_restart (JpegDecoder * dec, JpegBits * bits)
-{
- COG_DEBUG ("restart");
-
- return 0;
-}
-
-void
-jpeg_decoder_decode_entropy_segment (JpegDecoder * dec)
-{
- JpegBits * bits = &dec->bits;
- JpegBits b2, *bits2 = &b2;
- short block[64];
- short block2[64];
- unsigned char *newptr;
- int len;
- int maxlen;
- int j;
- int i;
- int go;
- int x, y;
- int n;
- int ret;
-
- len = 0;
- maxlen = jpeg_bits_available (bits) - 1;
- j = 0;
- while (len < maxlen) {
- if (bits->ptr[len] == 0xff && bits->ptr[len + 1] != 0x00) {
- break;
- }
- len++;
- }
- COG_DEBUG ("entropy length = %d", len);
-
- /* we allocate extra space, since the getbits() code can
- * potentially read past the end of the buffer */
- newptr = malloc (len + 2);
- for (i = 0; i < len; i++) {
- newptr[j] = bits->ptr[i];
- j++;
- if (bits->ptr[i] == 0xff)
- i++;
- }
- bits->ptr += len;
-
- bits2->ptr = newptr;
- bits2->idx = 0;
- bits2->end = newptr + j;
- newptr[j] = 0;
- newptr[j + 1] = 0;
-
- dec->dc[0] = dec->dc[1] = dec->dc[2] = dec->dc[3] = 128 * 8;
- go = 1;
- x = dec->x;
- y = dec->y;
- n = dec->restart_interval;
- if (n == 0) n = (1<<26); /* max number of blocks */
- while (go && n-- > 0) {
- for (i = 0; i < dec->scan_list_length; i++) {
- int dc_table_index;
- int ac_table_index;
- int quant_index;
- unsigned char *ptr;
- int component_index;
-
- COG_DEBUG ("%d,%d: component=%d dc_table=%d ac_table=%d",
- x, y,
- dec->scan_list[i].component_index,
- dec->scan_list[i].dc_table, dec->scan_list[i].ac_table);
-
- component_index = dec->scan_list[i].component_index;
- dc_table_index = dec->scan_list[i].dc_table;
- ac_table_index = dec->scan_list[i].ac_table;
- quant_index = dec->scan_list[i].quant_table;
-
- ret = huffman_table_decode_macroblock (dec, block,
- &dec->dc_huff_table[dc_table_index],
- &dec->ac_huff_table[ac_table_index], bits2);
- if (ret < 0) {
- COG_DEBUG ("%d,%d: component=%d dc_table=%d ac_table=%d",
- x, y,
- dec->scan_list[i].component_index,
- dec->scan_list[i].dc_table, dec->scan_list[i].ac_table);
- n = 0;
- break;
- }
-
- COG_DEBUG ("using quant table %d", quant_index);
- oil_mult8x8_s16 (block2, block, dec->quant_tables[quant_index].quantizer,
- sizeof (short) * 8, sizeof(short) * 8, sizeof (short) * 8);
- dec->dc[component_index] += block2[0];
- block2[0] = dec->dc[component_index];
- oil_unzigzag8x8_s16 (block, sizeof (short) * 8, block2,
- sizeof (short) * 8);
- oil_idct8x8_s16 (block2, sizeof (short) * 8, block, sizeof (short) * 8);
- oil_trans8x8_s16 (block, sizeof (short) * 8, block2, sizeof (short) * 8);
-
- ptr = dec->components[component_index].image +
- x * dec->components[component_index].h_sample +
- dec->scan_list[i].offset +
- dec->components[component_index].rowstride * y *
- dec->components[component_index].v_sample;
-
- oil_clipconv8x8_u8_s16 (ptr,
- dec->components[component_index].rowstride,
- block, sizeof (short) * 8);
- }
- x += 8;
- if (x * dec->scan_h_subsample >= dec->width) {
- x = 0;
- y += 8;
- }
- if (y * dec->scan_v_subsample >= dec->height) {
- go = 0;
- }
- }
- dec->x = x;
- dec->y = y;
- free (newptr);
-}
-
-
-
-JpegDecoder *
-jpeg_decoder_new (void)
-{
- JpegDecoder *dec;
-
- oil_init ();
-
- dec = malloc (sizeof(JpegDecoder));
- memset (dec, 0, sizeof(JpegDecoder));
-
- jpeg_load_standard_huffman_tables (dec);
-
- return dec;
-}
-
-void
-jpeg_decoder_free (JpegDecoder * dec)
-{
- int i;
-
- for (i = 0; i < JPEG_LIMIT_COMPONENTS; i++) {
- if (dec->components[i].image)
- free (dec->components[i].image);
- }
-
- if (dec->data)
- free (dec->data);
-
- free (dec);
-}
-
-static int
-jpeg_decoder_get_marker (JpegDecoder *dec, int *marker)
-{
- int a,b;
- JpegBits *bits = &dec->bits;
-
- if (jpeg_bits_available(bits) < 2) {
- return FALSE;
- }
-
- a = jpeg_bits_get_u8(bits);
- if (a != 0xff) {
- jpeg_decoder_error(dec, "expected marker, not 0x%02x", a);
- return FALSE;
- }
-
- do {
- b = jpeg_bits_get_u8 (bits);
- } while (b == 0xff && jpeg_bits_error(bits));
-
- *marker = b;
- return TRUE;
-}
-
-static void
-jpeg_decoder_skip (JpegDecoder *dec)
-{
- int length;
-
- length = jpeg_bits_get_u16_be (&dec->bits);
- jpeg_bits_skip (&dec->bits, length - 2);
-}
-
-int
-jpeg_decoder_decode (JpegDecoder *dec)
-{
- JpegBits *bits;
- int marker;
-
- dec->error = FALSE;
-
- bits = &dec->bits;
-
- /* Note: The spec is ambiguous as to whether fill bytes can come
- * before the first marker. We'll assume yes. */
- if (!jpeg_decoder_get_marker (dec, &marker)) {
- return FALSE;
- }
- if (dec->strict && marker != JPEG_MARKER_SOI) {
- jpeg_decoder_error(dec, "not a JPEG image");
- return FALSE;
- }
-
- /* Interpret markers up to the start of frame */
- while (!dec->error) {
- if (!jpeg_decoder_get_marker (dec, &marker)) {
- return FALSE;
- }
-
- if (marker == JPEG_MARKER_DEFINE_HUFFMAN_TABLES) {
- jpeg_decoder_define_huffman_tables (dec);
- } else if (marker == JPEG_MARKER_DEFINE_ARITHMETIC_CONDITIONING) {
- jpeg_decoder_define_arithmetic_conditioning (dec);
- } else if (marker == JPEG_MARKER_DEFINE_QUANTIZATION_TABLES) {
- jpeg_decoder_define_quantization_tables (dec);
- } else if (marker == JPEG_MARKER_DEFINE_RESTART_INTERVAL) {
- jpeg_decoder_define_restart_interval (dec);
- } else if (JPEG_MARKER_IS_APP(marker)) {
- /* FIXME decode app segment */
- jpeg_decoder_skip (dec);
- } else if (marker == JPEG_MARKER_COMMENT) {
- jpeg_decoder_skip (dec);
- } else if (JPEG_MARKER_IS_START_OF_FRAME(marker)) {
- break;
- } else if (marker == JPEG_MARKER_SOI) {
- if (dec->strict) {
- jpeg_decoder_error (dec, "unexpected SOI");
- return FALSE;
- }
- } else if (marker == JPEG_MARKER_EOI) {
- if (dec->strict) {
- jpeg_decoder_error (dec, "unexpected EOI");
- return FALSE;
- }
- } else {
- jpeg_decoder_error(dec, "unexpected marker 0x%02x", marker);
- return FALSE;
- }
- }
- if (dec->error) {
- return FALSE;
- }
-
- jpeg_decoder_start_of_frame(dec, marker);
-
- jpeg_decoder_verify_header (dec);
- if (dec->error) {
- return FALSE;
- }
-
- jpeg_decoder_init_decoder (dec);
- if (dec->error) {
- return FALSE;
- }
-
- /* In this section, we loop over parse units until we reach the end
- * of the image. */
- while (!dec->error) {
- if (!jpeg_decoder_get_marker (dec, &marker)) {
- return FALSE;
- }
-
- if (marker == JPEG_MARKER_DEFINE_HUFFMAN_TABLES) {
- jpeg_decoder_define_huffman_tables (dec);
- } else if (marker == JPEG_MARKER_DEFINE_ARITHMETIC_CONDITIONING) {
- jpeg_decoder_define_arithmetic_conditioning (dec);
- } else if (marker == JPEG_MARKER_DEFINE_QUANTIZATION_TABLES) {
- jpeg_decoder_define_quantization_tables (dec);
- } else if (marker == JPEG_MARKER_DEFINE_RESTART_INTERVAL) {
- jpeg_decoder_define_restart_interval (dec);
- } else if (JPEG_MARKER_IS_APP(marker)) {
- jpeg_decoder_skip (dec);
- } else if (marker == JPEG_MARKER_COMMENT) {
- jpeg_decoder_skip (dec);
- } else if (marker == JPEG_MARKER_SOS) {
- jpeg_decoder_start_of_scan (dec);
- if (dec->error) {
- return FALSE;
- }
- jpeg_decoder_decode_entropy_segment (dec);
- } else if (JPEG_MARKER_IS_RESET(marker)) {
- jpeg_decoder_decode_entropy_segment (dec);
- } else if (marker == JPEG_MARKER_SOI) {
- if (dec->strict) {
- jpeg_decoder_error (dec, "unexpected SOI");
- return FALSE;
- }
- } else if (marker == JPEG_MARKER_EOI) {
- if (dec->strict) {
- jpeg_decoder_error (dec, "unexpected EOI");
- return FALSE;
- } else {
- break;
- }
- } else {
- jpeg_decoder_error(dec, "unexpected marker 0x%02x", marker);
- return FALSE;
- }
- }
- if (dec->error) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* handle markers */
-
-void
-jpeg_decoder_define_huffman_tables (JpegDecoder * dec)
-{
- JpegBits *bits = &dec->bits;
- int length;
- int tc;
- int th;
- int x;
- HuffmanTable *hufftab;
-
- COG_DEBUG ("define huffman tables");
-
- length = jpeg_bits_get_u16_be (bits);
- if (length < 2) {
- jpeg_decoder_error(dec, "length too short");
- return;
- }
- length -= 2;
-
- while (length > 0) {
- x = jpeg_bits_get_u8 (bits);
- length--;
-
- tc = x >> 4;
- th = x & 0xf;
-
- COG_DEBUG ("huff table type %d (%s) idx %d", tc, tc ? "ac" : "dc", th);
- if (tc > 1 || th > 3) {
- jpeg_decoder_error(dec, "huffman table type or idx out of range");
- return;
- }
-
- if (tc) {
- hufftab = &dec->ac_huff_table[th];
- length -= huffman_table_init_jpeg (dec, hufftab, bits);
- } else {
- hufftab = &dec->dc_huff_table[th];
- length -= huffman_table_init_jpeg (dec, hufftab, bits);
- }
- if (dec->error) {
- return;
- }
- }
- if (length < 0) {
- jpeg_decoder_error(dec, "huffman table overran available bytes");
- return;
- }
-}
-
-void
-jpeg_decoder_define_quantization_tables (JpegDecoder *dec)
-{
- JpegBits *bits = &dec->bits;
- JpegQuantTable *table;
- int length;
- int pq;
- int tq;
- int i;
-
- COG_INFO ("define quantization table");
-
- length = jpeg_bits_get_u16_be (bits);
- if (length < 2) {
- jpeg_decoder_error(dec, "length too short");
- return;
- }
- length -= 2;
-
- while (length > 0) {
- int x;
-
- x = jpeg_bits_get_u8 (bits);
- length--;
- pq = x >> 4;
- tq = x & 0xf;
-
- if (pq > 1) {
- jpeg_decoder_error (dec, "bad pq value");
- return;
- }
- if (tq > 3) {
- jpeg_decoder_error (dec, "bad tq value");
- return;
- }
-
- table = &dec->quant_tables[tq];
- if (pq) {
- for (i = 0; i < 64; i++) {
- table->quantizer[i] = jpeg_bits_get_u16_be (bits);
- length -= 2;
- }
- } else {
- for (i = 0; i < 64; i++) {
- table->quantizer[i] = jpeg_bits_get_u8 (bits);
- length -= 1;
- }
- }
- }
- if (length < 0) {
- jpeg_decoder_error(dec, "quantization table overran available bytes");
- return;
- }
-}
-
-void
-jpeg_decoder_define_restart_interval (JpegDecoder *dec)
-{
- JpegBits *bits = &dec->bits;
- int length;
-
- length = jpeg_bits_get_u16_be (bits);
- if (length != 4) {
- jpeg_decoder_error(dec, "length supposed to be 4 (%d)", length);
- return;
- }
-
- /* FIXME this needs to be checked somewhere */
- dec->restart_interval = jpeg_bits_get_u16_be (bits);
-}
-
-void
-jpeg_decoder_define_arithmetic_conditioning (JpegDecoder *dec)
-{
- /* we don't handle arithmetic coding, so skip it */
- jpeg_decoder_skip (dec);
-}
-
-void
-jpeg_decoder_start_of_frame (JpegDecoder * dec, int marker)
-{
- JpegBits *bits = &dec->bits;
- int i;
- int length;
-
- COG_INFO ("start of frame");
-
- dec->sof_type = marker;
-
- length = jpeg_bits_get_u16_be (bits);
-
- if (jpeg_bits_available(bits) < length) {
- jpeg_decoder_error(dec, "not enough data for start_of_frame (%d < %d)",
- length, jpeg_bits_available(bits));
- return;
- }
-
- dec->depth = jpeg_bits_get_u8 (bits);
- dec->height = jpeg_bits_get_u16_be (bits);
- dec->width = jpeg_bits_get_u16_be (bits);
- dec->n_components = jpeg_bits_get_u8 (bits);
-
- COG_DEBUG (
- "frame_length=%d depth=%d height=%d width=%d n_components=%d", length,
- dec->depth, dec->height, dec->width, dec->n_components);
-
- if (dec->n_components * 3 + 8 != length) {
- jpeg_decoder_error(dec, "inconsistent header");
- return;
- }
-
- for (i = 0; i < dec->n_components; i++) {
- dec->components[i].id = get_u8 (bits);
- dec->components[i].h_sample = getbits (bits, 4);
- dec->components[i].v_sample = getbits (bits, 4);
- dec->components[i].quant_table = get_u8 (bits);
-
- COG_DEBUG (
- "[%d] id=%d h_sample=%d v_sample=%d quant_table=%d", i,
- dec->components[i].id, dec->components[i].h_sample,
- dec->components[i].v_sample, dec->components[i].quant_table);
- }
-}
-
-void
-jpeg_decoder_start_of_scan (JpegDecoder * dec)
-{
- JpegBits *bits = &dec->bits;
- int length;
- int i;
- int spectral_start;
- int spectral_end;
- int approx_high;
- int approx_low;
- int n;
- int tmp;
- int n_components;
-
- COG_DEBUG ("start of scan");
-
- length = jpeg_bits_get_u16_be (bits);
- COG_DEBUG ("length=%d", length);
-
- n_components = jpeg_bits_get_u8 (bits);
- n = 0;
- dec->scan_h_subsample = 0;
- dec->scan_v_subsample = 0;
- for (i = 0; i < n_components; i++) {
- int component_id;
- int dc_table;
- int ac_table;
- int x;
- int y;
- int idx;
- int h_subsample;
- int v_subsample;
- int quant_index;
-
- component_id = jpeg_bits_get_u8 (bits);
- tmp = jpeg_bits_get_u8 (bits);
- dc_table = tmp >> 4;
- ac_table = tmp & 0xf;
- idx = jpeg_decoder_find_component_by_id (dec, component_id);
-
- h_subsample = dec->components[idx].h_sample;
- v_subsample = dec->components[idx].v_sample;
- quant_index = dec->components[idx].quant_table;
-
- for (y = 0; y < v_subsample; y++) {
- for (x = 0; x < h_subsample; x++) {
- dec->scan_list[n].component_index = idx;
- dec->scan_list[n].dc_table = dc_table;
- dec->scan_list[n].ac_table = ac_table;
- dec->scan_list[n].quant_table = quant_index;
- dec->scan_list[n].x = x;
- dec->scan_list[n].y = y;
- dec->scan_list[n].offset =
- y * 8 * dec->components[idx].rowstride + x * 8;
- n++;
- if (n > JPEG_LIMIT_SCAN_LIST_LENGTH) {
- jpeg_decoder_error(dec, "scan list too long");
- return;
- }
- }
- }
-
- dec->scan_h_subsample = MAX (dec->scan_h_subsample, h_subsample);
- dec->scan_v_subsample = MAX (dec->scan_v_subsample, v_subsample);
-
- COG_DEBUG ("component %d: idx=%d dc_table=%d ac_table=%d n=%d",
- component_id, idx, dc_table, ac_table, n);
- }
- dec->scan_list_length = n;
-
-
- spectral_start = jpeg_bits_get_u8 (bits);
- spectral_end = jpeg_bits_get_u8 (bits);
- COG_DEBUG ("spectral range [%d,%d]", spectral_start, spectral_end);
- tmp = jpeg_bits_get_u8 (bits);
- approx_high = tmp >> 4;
- approx_low = tmp & 0xf;
- COG_DEBUG ("approx range [%d,%d]", approx_low, approx_high);
-
- dec->x = 0;
- dec->y = 0;
- dec->dc[0] = dec->dc[1] = dec->dc[2] = dec->dc[3] = 128 * 8;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-int
-jpeg_decoder_addbits (JpegDecoder * dec, unsigned char *data, unsigned int len)
-{
- unsigned int offset;
-
- offset = dec->bits.ptr - dec->data;
-
- dec->data = realloc (dec->data, dec->data_len + len);
- memcpy (dec->data + dec->data_len, data, len);
- dec->data_len += len;
-
- dec->bits.ptr = dec->data + offset;
- dec->bits.end = dec->data + dec->data_len;
-
- return 0;
-}
-
-int
-jpeg_decoder_get_image_size (JpegDecoder * dec, int *width, int *height)
-{
- if (width)
- *width = dec->width;
- if (height)
- *height = dec->height;
-
- return 0;
-}
-
-int
-jpeg_decoder_get_component_ptr (JpegDecoder * dec, int id,
- unsigned char **image, int *rowstride)
-{
- int i;
-
- i = jpeg_decoder_find_component_by_id (dec, id);
- if (image)
- *image = dec->components[i].image;
- if (rowstride)
- *rowstride = dec->components[i].rowstride;
-
- return 0;
-}
-
-int
-jpeg_decoder_get_component_size (JpegDecoder * dec, int id,
- int *width, int *height)
-{
- int i;
-
- /* subsampling sizes are rounded up */
-
- i = jpeg_decoder_find_component_by_id (dec, id);
- if (width)
- *width = (dec->width - 1) / dec->components[i].h_subsample + 1;
- if (height)
- *height = (dec->height - 1) / dec->components[i].v_subsample + 1;
-
- return 0;
-}
-
-int
-jpeg_decoder_get_component_subsampling (JpegDecoder * dec, int id,
- int *h_subsample, int *v_subsample)
-{
- int i;
-
- i = jpeg_decoder_find_component_by_id (dec, id);
- if (h_subsample)
- *h_subsample = dec->components[i].h_subsample;
- if (v_subsample)
- *v_subsample = dec->components[i].v_subsample;
-
- return 0;
-}
-
-#if 0
-int
-jpeg_decoder_parse (JpegDecoder * dec)
-{
- JpegBits *bits = &dec->bits;
- JpegBits b2;
- unsigned int x;
- unsigned int tag;
- int i;
-
- while (bits->ptr < bits->end) {
- x = get_u8 (bits);
- if (x != 0xff) {
- int n = 0;
-
- while (x != 0xff) {
- x = get_u8 (bits);
- n++;
- }
- OIL_DEBUG ("lost sync, skipped %d bytes", n);
- }
- while (x == 0xff) {
- x = get_u8 (bits);
- }
- tag = x;
- OIL_DEBUG ("tag %02x", tag);
-
- b2 = *bits;
-
- for (i = 0; i < n_jpeg_markers - 1; i++) {
- if (tag == jpeg_markers[i].tag) {
- break;
- }
- }
- OIL_DEBUG ("tag: %s", jpeg_markers[i].name);
- if (jpeg_markers[i].func) {
- jpeg_markers[i].func (dec, &b2);
- } else {
- OIL_DEBUG ("unhandled or illegal JPEG marker (0x%02x)", tag);
- dumpbits (&b2);
- }
- if (jpeg_markers[i].flags & JPEG_ENTROPY_SEGMENT) {
- jpeg_decoder_decode_entropy_segment (dec, &b2);
- }
- syncbits (&b2);
- bits->ptr = b2.ptr;
- }
-
- return 0;
-}
-#endif
-
-
-/* misc helper functins */
-
-static void
-jpeg_load_standard_huffman_tables (JpegDecoder * dec)
-{
- JpegBits b, *bits = &b;
-
- bits->ptr = jpeg_standard_tables;
- bits->idx = 0;
- bits->end = jpeg_standard_tables + jpeg_standard_tables_size;
-
- huffman_table_init_jpeg (dec, &dec->dc_huff_table[0], bits);
- huffman_table_init_jpeg (dec, &dec->ac_huff_table[0], bits);
- huffman_table_init_jpeg (dec, &dec->dc_huff_table[1], bits);
- huffman_table_init_jpeg (dec, &dec->ac_huff_table[1], bits);
-}
-
-
-
diff --git a/libswfdec/jpeg/jpeg.h b/libswfdec/jpeg/jpeg.h
deleted file mode 100644
index 6c0ba41..0000000
--- a/libswfdec/jpeg/jpeg.h
+++ /dev/null
@@ -1,190 +0,0 @@
-
-#ifndef _JPEG_DECODER_H_
-#define _JPEG_DECODER_H_
-
-#include <jpeg/jpeg_bits.h>
-
-#include <stdint.h>
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#define JPEG_LIMIT_COMPONENTS 256
-#define JPEG_LIMIT_SCAN_LIST_LENGTH 10
-
-
-typedef struct _JpegDecoder JpegDecoder;
-typedef struct _JpegQuantTable JpegQuantTable;
-typedef struct _HuffmanEntry HuffmanEntry;
-typedef struct _HuffmanTable HuffmanTable;
-
-struct _HuffmanEntry {
- unsigned int symbol;
- unsigned int mask;
- int n_bits;
- unsigned char value;
-};
-
-struct _HuffmanTable {
- int len;
- HuffmanEntry entries[256];
-};
-
-struct _JpegQuantTable {
- int pq;
- int16_t quantizer[64];
-};
-
-struct _JpegDecoder {
- int width;
- int height;
- int depth;
- int n_components;
- JpegBits bits;
- int error;
- int strict;
- char *error_message;
-
- int sof_type;
-
- int width_blocks;
- int height_blocks;
-
- int restart_interval;
-
- unsigned char *data;
- unsigned int data_len;
-
- struct{
- int id;
- int h_sample;
- int v_sample;
- int quant_table;
-
- int h_subsample;
- int v_subsample;
- unsigned char *image;
- int rowstride;
- } components[JPEG_LIMIT_COMPONENTS];
-
- JpegQuantTable quant_tables[4];
- HuffmanTable dc_huff_table[4];
- HuffmanTable ac_huff_table[4];
-
- int scan_list_length;
- struct{
- int component_index;
- int dc_table;
- int ac_table;
- int quant_table;
- int x;
- int y;
- int offset;
- }scan_list[JPEG_LIMIT_SCAN_LIST_LENGTH];
- int scan_h_subsample;
- int scan_v_subsample;
-
- /* scan state */
- int x,y;
- int dc[4];
-};
-
-#define JPEG_MARKER_STUFFED 0x00
-#define JPEG_MARKER_TEM 0x01
-#define JPEG_MARKER_RES 0x02
-
-#define JPEG_MARKER_SOF_0 0xc0
-#define JPEG_MARKER_SOF_1 0xc1
-#define JPEG_MARKER_SOF_2 0xc2
-#define JPEG_MARKER_SOF_3 0xc3
-#define JPEG_MARKER_DEFINE_HUFFMAN_TABLES 0xc4
-#define JPEG_MARKER_SOF_5 0xc5
-#define JPEG_MARKER_SOF_6 0xc6
-#define JPEG_MARKER_SOF_7 0xc7
-#define JPEG_MARKER_JPG 0xc8
-#define JPEG_MARKER_SOF_9 0xc9
-#define JPEG_MARKER_SOF_10 0xca
-#define JPEG_MARKER_SOF_11 0xcb
-#define JPEG_MARKER_DEFINE_ARITHMETIC_CONDITIONING 0xcc
-#define JPEG_MARKER_SOF_13 0xcd
-#define JPEG_MARKER_SOF_14 0xce
-#define JPEG_MARKER_SOF_15 0xcf
-
-#define JPEG_MARKER_RST_0 0xd0
-#define JPEG_MARKER_RST_1 0xd1
-#define JPEG_MARKER_RST_2 0xd2
-#define JPEG_MARKER_RST_3 0xd3
-#define JPEG_MARKER_RST_4 0xd4
-#define JPEG_MARKER_RST_5 0xd5
-#define JPEG_MARKER_RST_6 0xd6
-#define JPEG_MARKER_RST_7 0xd7
-
-#define JPEG_MARKER_SOI 0xd8
-#define JPEG_MARKER_EOI 0xd9
-#define JPEG_MARKER_SOS 0xda
-#define JPEG_MARKER_DEFINE_QUANTIZATION_TABLES 0xdb
-#define JPEG_MARKER_DNL 0xdc
-#define JPEG_MARKER_DEFINE_RESTART_INTERVAL 0xdd
-#define JPEG_MARKER_DHP 0xde
-#define JPEG_MARKER_EXP 0xdf
-#define JPEG_MARKER_APP(x) (0xe0 + (x))
-#define JPEG_MARKER_JPG_(x) (0xf0 + (x))
-#define JPEG_MARKER_COMMENT 0xfe
-
-#define JPEG_MARKER_JFIF JPEG_MARKER_APP(0)
-
-#define JPEG_MARKER_IS_START_OF_FRAME(x) ((x)>=0xc0 && (x) <= 0xcf && (x)!=0xc4 && (x)!=0xc8 && (x)!=0xcc)
-#define JPEG_MARKER_IS_APP(x) ((x)>=0xe0 && (x) <= 0xef)
-#define JPEG_MARKER_IS_RESET(x) ((x)>=0xd0 && (x)<=0xd7)
-
-
-
-JpegDecoder *jpeg_decoder_new(void);
-void jpeg_decoder_free(JpegDecoder *dec);
-int jpeg_decoder_addbits(JpegDecoder *dec, unsigned char *data, unsigned int len);
-int jpeg_decoder_decode (JpegDecoder *dec);
-int jpeg_decoder_get_image_size(JpegDecoder *dec, int *width, int *height);
-int jpeg_decoder_get_component_size(JpegDecoder *dec, int id,
- int *width, int *height);
-int jpeg_decoder_get_component_subsampling(JpegDecoder *dec, int id,
- int *h_subsample, int *v_subsample);
-int jpeg_decoder_get_component_ptr(JpegDecoder *dec, int id,
- unsigned char **image, int *rowstride);
-
-uint32_t *jpeg_decoder_get_argb_image (JpegDecoder *dec);
-int jpeg_decode_argb (uint8_t *data, int length, uint32_t **image,
- int *width, int *height);
-
-void jpeg_decoder_error(JpegDecoder *dec, const char *fmt, ...);
-
-int jpeg_decoder_sof_baseline_dct(JpegDecoder *dec, JpegBits *bits);
-int jpeg_decoder_define_quant_table(JpegDecoder *dec, JpegBits *bits);
-int jpeg_decoder_define_huffman_table(JpegDecoder *dec, JpegBits *bits);
-int jpeg_decoder_sos(JpegDecoder *dec, JpegBits *bits);
-int jpeg_decoder_soi(JpegDecoder *dec, JpegBits *bits);
-int jpeg_decoder_eoi(JpegDecoder *dec, JpegBits *bits);
-int jpeg_decoder_application0(JpegDecoder *dec, JpegBits *bits);
-int jpeg_decoder_application_misc(JpegDecoder *dec, JpegBits *bits);
-int jpeg_decoder_comment(JpegDecoder *dec, JpegBits *bits);
-int jpeg_decoder_restart_interval(JpegDecoder *dec, JpegBits *bits);
-int jpeg_decoder_restart(JpegDecoder *dec, JpegBits *bits);
-void jpeg_decoder_decode_entropy_segment(JpegDecoder *dec);
-
-
-void huffman_table_init(HuffmanTable *table);
-
-void huffman_table_dump(HuffmanTable *table);
-void huffman_table_add(HuffmanTable *table, uint32_t code, int n_bits,
- int value);
-unsigned int huffman_table_decode_jpeg(JpegDecoder *dec, HuffmanTable *tab, JpegBits *bits);
-int huffman_table_decode_macroblock(JpegDecoder *dec, short *block, HuffmanTable *dc_tab,
- HuffmanTable *ac_tab, JpegBits *bits);
-int huffman_table_decode(JpegDecoder *dec, HuffmanTable *dc_tab, HuffmanTable *ac_tab, JpegBits *bits);
-
-
-#endif
-
diff --git a/libswfdec/jpeg/jpeg_bits.c b/libswfdec/jpeg/jpeg_bits.c
deleted file mode 100644
index 87700e9..0000000
--- a/libswfdec/jpeg/jpeg_bits.c
+++ /dev/null
@@ -1,154 +0,0 @@
-
-#include <stdio.h>
-
-#include "jpeg_bits.h"
-
-/* FIXME */
-#define TRUE 1
-#define FALSE 0
-
-int jpeg_bits_error (JpegBits *bits)
-{
- return bits->error;
-}
-
-int jpeg_bits_get_u8 (JpegBits *bits)
-{
- if (bits->ptr < bits->end) {
- return *bits->ptr++;
- }
- bits->error = TRUE;
- return 0;
-}
-
-void jpeg_bits_skip (JpegBits *bits, int n)
-{
- bits->ptr += n;
- if (bits->ptr > bits->end) {
- bits->error = TRUE;
- bits->ptr = bits->end;
- }
-}
-
-int jpeg_bits_get_u16_be (JpegBits *bits)
-{
- int x;
-
- x = jpeg_bits_get_u8 (bits) << 8;
- x |= jpeg_bits_get_u8 (bits);
-
- return x;
-}
-
-int jpeg_bits_available (JpegBits *bits)
-{
- return bits->end - bits->ptr;
-}
-
-int bits_needbits(JpegBits *b, int n_bytes)
-{
- if(b->ptr==NULL)return 1;
- if(b->ptr + n_bytes > b->end)return 1;
-
- return 0;
-}
-
-int getbit(JpegBits *b)
-{
- int r;
-
- r = ((*b->ptr)>>(7-b->idx))&1;
-
- b->idx++;
- if(b->idx>=8){
- b->ptr++;
- b->idx = 0;
- }
-
- return r;
-}
-
-unsigned int getbits(JpegBits *b, int n)
-{
- unsigned long r = 0;
- int i;
-
- for(i=0;i<n;i++){
- r <<=1;
- r |= getbit(b);
- }
-
- return r;
-}
-
-unsigned int peekbits(JpegBits *b, int n)
-{
- JpegBits tmp = *b;
-
- return getbits(&tmp, n);
-}
-
-int getsbits(JpegBits *b, int n)
-{
- unsigned long r = 0;
- int i;
-
- if(n==0)return 0;
- r = -getbit(b);
- for(i=1;i<n;i++){
- r <<=1;
- r |= getbit(b);
- }
-
- return r;
-}
-
-unsigned int peek_u8(JpegBits *b)
-{
- return *b->ptr;
-}
-
-unsigned int get_u8(JpegBits *b)
-{
- return *b->ptr++;
-}
-
-unsigned int get_u16(JpegBits *b)
-{
- unsigned int r;
-
- r = b->ptr[0] | (b->ptr[1]<<8);
- b->ptr+=2;
-
- return r;
-}
-
-unsigned int get_be_u16(JpegBits *b)
-{
- unsigned int r;
-
- r = (b->ptr[0]<<8) | b->ptr[1];
- b->ptr+=2;
-
- return r;
-}
-
-unsigned int get_u32(JpegBits *b)
-{
- unsigned int r;
-
- r = b->ptr[0] | (b->ptr[1]<<8) | (b->ptr[2]<<16) | (b->ptr[3]<<24);
- b->ptr+=4;
-
- return r;
-}
-
-void syncbits(JpegBits *b)
-{
- if(b->idx){
- b->ptr++;
- b->idx=0;
- }
-
-}
-
diff --git a/libswfdec/jpeg/jpeg_bits.h b/libswfdec/jpeg/jpeg_bits.h
deleted file mode 100644
index 90cdcec..0000000
--- a/libswfdec/jpeg/jpeg_bits.h
+++ /dev/null
@@ -1,32 +0,0 @@
-
-#ifndef __BITS_H__
-#define __BITS_H__
-
-typedef struct _JpegBits JpegBits;
-struct _JpegBits {
- unsigned char *ptr;
- int idx;
- unsigned char *end;
- int error;
-};
-
-int jpeg_bits_error (JpegBits *bits);
-int jpeg_bits_get_u8 (JpegBits *bits);
-void jpeg_bits_skip (JpegBits *bits, int n);
-int jpeg_bits_get_u16_be (JpegBits *bits);
-int jpeg_bits_available (JpegBits *bits);
-
-int bits_needbits(JpegBits *b, int n_bytes);
-int getbit(JpegBits *b);
-unsigned int getbits(JpegBits *b, int n);
-unsigned int peekbits(JpegBits *b, int n);
-int getsbits(JpegBits *b, int n);
-unsigned int peek_u8(JpegBits *b);
-unsigned int get_u8(JpegBits *b);
-unsigned int get_u16(JpegBits *b);
-unsigned int get_be_u16(JpegBits *b);
-unsigned int get_u32(JpegBits *b);
-void syncbits(JpegBits *b);
-
-#endif
-
diff --git a/libswfdec/jpeg/jpeg_huffman.c b/libswfdec/jpeg/jpeg_huffman.c
deleted file mode 100644
index d5b7f61..0000000
--- a/libswfdec/jpeg/jpeg_huffman.c
+++ /dev/null
@@ -1,168 +0,0 @@
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <cogcompat.h>
-#include <liboil/liboil.h>
-
-#include <string.h>
-
-#include "jpeg.h"
-
-/* misc helper function definitions */
-
-static char *sprintbits (char *str, unsigned int bits, int n);
-
-
-void
-huffman_table_dump (HuffmanTable * table)
-{
- unsigned int n_bits;
- unsigned int code;
- char str[33];
- int i;
- HuffmanEntry *entry;
-
- COG_DEBUG ("dumping huffman table %p", table);
- for (i = 0; i < table->len; i++) {
- entry = table->entries + i;
- n_bits = entry->n_bits;
- code = entry->symbol >> (16 - n_bits);
- sprintbits (str, code, n_bits);
- COG_DEBUG ("%s --> %d", str, entry->value);
- }
-}
-
-void
-huffman_table_init (HuffmanTable *table)
-{
- memset (table, 0, sizeof(HuffmanTable));
-}
-
-void
-huffman_table_add (HuffmanTable * table, uint32_t code, int n_bits, int value)
-{
- HuffmanEntry *entry = table->entries + table->len;
-
- entry->value = value;
- entry->symbol = code << (16 - n_bits);
- entry->mask = 0xffff ^ (0xffff >> n_bits);
- entry->n_bits = n_bits;
-
- table->len++;
-}
-
-unsigned int
-huffman_table_decode_jpeg (JpegDecoder *dec, HuffmanTable * tab, JpegBits * bits)
-{
- unsigned int code;
- int i;
- char str[33];
- HuffmanEntry *entry;
-
- code = peekbits (bits, 16);
- for (i = 0; i < tab->len; i++) {
- entry = tab->entries + i;
- if ((code & entry->mask) == entry->symbol) {
- code = getbits (bits, entry->n_bits);
- sprintbits (str, code, entry->n_bits);
- COG_DEBUG ("%s --> %d", str, entry->value);
- return entry->value;
- }
- }
- COG_ERROR ("huffman sync lost");
-
- return -1;
-}
-
-int
-huffman_table_decode_macroblock (JpegDecoder *dec, short *block, HuffmanTable * dc_tab,
- HuffmanTable * ac_tab, JpegBits * bits)
-{
- int r, s, x, rs;
- int k;
- char str[33];
-
- memset (block, 0, sizeof (short) * 64);
-
- s = huffman_table_decode_jpeg (dec, dc_tab, bits);
- if (s < 0)
- return -1;
- x = getbits (bits, s);
- if ((x >> (s - 1)) == 0) {
- x -= (1 << s) - 1;
- }
- COG_DEBUG ("s=%d (block[0]=%d)", s, x);
- block[0] = x;
-
- for (k = 1; k < 64; k++) {
- rs = huffman_table_decode_jpeg (dec, ac_tab, bits);
- if (rs < 0) {
- COG_DEBUG ("huffman error");
- return -1;
- }
- if (bits->ptr > bits->end) {
- COG_DEBUG ("overrun");
- return -1;
- }
- s = rs & 0xf;
- r = rs >> 4;
- if (s == 0) {
- if (r == 15) {
- COG_DEBUG ("r=%d s=%d (skip 16)", r, s);
- k += 15;
- } else {
- COG_DEBUG ("r=%d s=%d (eob)", r, s);
- break;
- }
- } else {
- k += r;
- if (k >= 64) {
- jpeg_decoder_error (dec, "macroblock overrun");
- return -1;
- }
- x = getbits (bits, s);
- sprintbits (str, x, s);
- if ((x >> (s - 1)) == 0) {
- x -= (1 << s) - 1;
- }
- block[k] = x;
- COG_DEBUG ("r=%d s=%d (%s -> block[%d]=%d)", r, s, str, k, x);
- }
- }
- return 0;
-}
-
-int
-huffman_table_decode (JpegDecoder *dec, HuffmanTable * dc_tab, HuffmanTable * ac_tab,
- JpegBits * bits)
-{
- int16_t zz[64];
- int ret;
-
- while (bits->ptr < bits->end) {
- ret = huffman_table_decode_macroblock (dec, zz, dc_tab, ac_tab, bits);
- if (ret < 0)
- return -1;
- }
-
- return 0;
-}
-
-/* misc helper functins */
-
-static char *
-sprintbits (char *str, unsigned int bits, int n)
-{
- int i;
- int bit = 1 << (n - 1);
-
- for (i = 0; i < n; i++) {
- str[i] = (bits & bit) ? '1' : '0';
- bit >>= 1;
- }
- str[i] = 0;
-
- return str;
-}
diff --git a/libswfdec/jpeg/jpeg_huffman.h b/libswfdec/jpeg/jpeg_huffman.h
deleted file mode 100644
index 9763e09..0000000
--- a/libswfdec/jpeg/jpeg_huffman.h
+++ /dev/null
@@ -1,37 +0,0 @@
-
-#ifndef _HUFFMAN_H_
-#define _HUFFMAN_H_
-
-#include <liboil/liboil-stdint.h>
-
-#include "jpeg_bits.h"
-
-typedef struct _HuffmanEntry HuffmanEntry;
-typedef struct _HuffmanTable HuffmanTable;
-
-struct _HuffmanEntry {
- unsigned int symbol;
- unsigned int mask;
- int n_bits;
- unsigned char value;
-};
-
-struct _HuffmanTable {
- int len;
- HuffmanEntry entries[256];
-};
-
-
-void huffman_table_init(HuffmanTable *table);
-
-void huffman_table_dump(HuffmanTable *table);
-void huffman_table_add(HuffmanTable *table, uint32_t code, int n_bits,
- int value);
-unsigned int huffman_table_decode_jpeg(HuffmanTable *tab, JpegBits *bits);
-int huffman_table_decode_macroblock(short *block, HuffmanTable *dc_tab,
- HuffmanTable *ac_tab, JpegBits *bits);
-int huffman_table_decode(HuffmanTable *dc_tab, HuffmanTable *ac_tab, JpegBits *bits);
-
-
-#endif
-
diff --git a/libswfdec/jpeg/jpeg_markers.h b/libswfdec/jpeg/jpeg_markers.h
deleted file mode 100644
index 584cb23..0000000
--- a/libswfdec/jpeg/jpeg_markers.h
+++ /dev/null
@@ -1,44 +0,0 @@
-
-#define JPEG_MARKER_STUFFED 0x00
-#define JPEG_MARKER_TEM 0x01
-#define JPEG_MARKER_RES 0x02
-
-#define JPEG_MARKER_SOF_0 0xc0
-#define JPEG_MARKER_SOF_1 0xc1
-#define JPEG_MARKER_SOF_2 0xc2
-#define JPEG_MARKER_SOF_3 0xc3
-#define JPEG_MARKER_DHT 0xc4
-#define JPEG_MARKER_SOF_5 0xc5
-#define JPEG_MARKER_SOF_6 0xc6
-#define JPEG_MARKER_SOF_7 0xc7
-#define JPEG_MARKER_JPG 0xc8
-#define JPEG_MARKER_SOF_9 0xc9
-#define JPEG_MARKER_SOF_10 0xca
-#define JPEG_MARKER_SOF_11 0xcb
-#define JPEG_MARKER_DAC 0xcc
-#define JPEG_MARKER_SOF_13 0xcd
-#define JPEG_MARKER_SOF_14 0xce
-#define JPEG_MARKER_SOF_15 0xcf
-
-#define JPEG_MARKER_RST_0 0xd0
-#define JPEG_MARKER_RST_1 0xd1
-#define JPEG_MARKER_RST_2 0xd2
-#define JPEG_MARKER_RST_3 0xd3
-#define JPEG_MARKER_RST_4 0xd4
-#define JPEG_MARKER_RST_5 0xd5
-#define JPEG_MARKER_RST_6 0xd6
-#define JPEG_MARKER_RST_7 0xd7
-#define JPEG_MARKER_SOI 0xd8
-#define JPEG_MARKER_EOI 0xd9
-#define JPEG_MARKER_SOS 0xda
-#define JPEG_MARKER_DQT 0xdb
-#define JPEG_MARKER_DNL 0xdc
-#define JPEG_MARKER_DRI 0xdd
-#define JPEG_MARKER_DHP 0xde
-#define JPEG_MARKER_EXP 0xdf
-#define JPEG_MARKER_APP(x) (0xe0 + (x))
-#define JPEG_MARKER_JPG_(x) (0xf0 + (x))
-#define JPEG_MARKER_COM 0xfe
-
-#define JPEG_MARKER_JFIF JPEG_MARKER_APP(0)
-
diff --git a/libswfdec/jpeg/jpeg_rgb_decoder.c b/libswfdec/jpeg/jpeg_rgb_decoder.c
deleted file mode 100644
index 3c01914..0000000
--- a/libswfdec/jpeg/jpeg_rgb_decoder.c
+++ /dev/null
@@ -1,352 +0,0 @@
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "jpeg.h"
-
-#include <liboil/liboil.h>
-#include <liboil/liboildebug.h>
-
-#define CLAMP(x,a,b) ((x)<(a) ? (a) : ((x)>(b) ? (b) : (x)))
-#define oil_argb(a,r,g,b) \
- ((oil_clamp_255(a)<<24) | \
- (oil_clamp_255(r)<<16) | \
- (oil_clamp_255(g)<<8) | \
- (oil_clamp_255(b)<<0))
-#define oil_max(x,y) ((x)>(y)?(x):(y))
-#define oil_min(x,y) ((x)<(y)?(x):(y))
-#define oil_clamp_255(x) oil_max(0,oil_min((x),255))
-
-
-static int16_t jfif_matrix[24] = {
- 0, 0, -8192, -8192,
- 16384, 0, 0, 0,
- 0, 16384, 16384, 16384,
- 0, 0, -5638, 29032,
- 0, 22970, -11700, 0,
- 0, 0, 0, 0
-};
-
-
-uint32_t * get_argb_444 (JpegDecoder *dec);
-uint32_t * get_argb_422 (JpegDecoder *dec);
-uint32_t * get_argb_422v (JpegDecoder *dec);
-uint32_t * get_argb_420 (JpegDecoder *dec);
-
-#if 0
-static void imagescale2h_u8 (unsigned char *dest, int d_rowstride,
- unsigned char *src, int src_rowstride, int width, int height);
-static void imagescale2v_u8 (unsigned char *dest, int d_rowstride,
- unsigned char *src, int src_rowstride, int width, int height);
-static void imagescale2h2v_u8 (unsigned char *dest, int d_rowstride,
- unsigned char *src, int src_rowstride, int width, int height);
-static void scanlinescale2_u8 (unsigned char *dest, unsigned char *src,
- int len);
-#endif
-
-
-int jpeg_decode_argb (uint8_t *data, int length, uint32_t **image,
- int *width, int *height)
-{
- JpegDecoder *dec;
- int ret;
-
- dec = jpeg_decoder_new();
-
- jpeg_decoder_addbits (dec, data, length);
- ret = jpeg_decoder_decode(dec);
-
- if (!ret) return FALSE;
-
- jpeg_decoder_get_image_size (dec, width, height);
- *image = (uint32_t *)jpeg_decoder_get_argb_image (dec);
- jpeg_decoder_free (dec);
-
- return TRUE;
-}
-
-uint32_t *
-jpeg_decoder_get_argb_image (JpegDecoder *dec)
-{
-
- if (dec->n_components == 3) {
- if (dec->components[0].h_subsample == 1 &&
- dec->components[0].v_subsample == 1 &&
- dec->components[1].h_subsample == dec->components[2].h_subsample &&
- dec->components[1].v_subsample == dec->components[2].v_subsample) {
- if (dec->components[1].h_subsample == 1 &&
- dec->components[1].v_subsample == 1) {
- return get_argb_444 (dec);
- } else if (dec->components[1].h_subsample == 2 &&
- dec->components[1].v_subsample == 1) {
- return get_argb_422 (dec);
- } else if (dec->components[1].h_subsample == 1 &&
- dec->components[1].v_subsample == 2) {
- return get_argb_422v (dec);
- } else if (dec->components[1].h_subsample == 2 &&
- dec->components[1].v_subsample == 2) {
- return get_argb_420 (dec);
- }
- }
- }
-
- return NULL;
-}
-
-static void
-yuv_mux (uint32_t *dest, uint8_t *src_y, uint8_t *src_u, uint8_t *src_v,
- int n)
-{
- int i;
- for (i = 0; i < n; i++) {
- dest[i] = oil_argb(255, src_y[i], src_u[i], src_v[i]);
- }
-}
-
-static void
-upsample (uint8_t *d, uint8_t *s, int n)
-{
- int i;
-
- d[0] = s[0];
-
- for (i = 0; i < n-3; i+=2) {
- d[i + 1] = (3*s[i/2] + s[i/2+1] + 2)>>2;
- d[i + 2] = (s[i/2] + 3*s[i/2+1] + 2)>>2;
- }
-
- if (n&1) {
- i = n-3;
- d[n-2] = s[n/2];
- d[n-1] = s[n/2];
- } else {
- d[n-1] = s[n/2-1];
- }
-
-}
-
-uint32_t *
-get_argb_444 (JpegDecoder *dec)
-{
- uint32_t *tmp;
- uint32_t *argb_image;
- uint8_t *yp, *up, *vp;
- uint32_t *argbp;
- int j;
-
- tmp = malloc (4 * dec->width * dec->height);
- argb_image = malloc (4 * dec->width * dec->height);
-
- yp = dec->components[0].image;
- up = dec->components[1].image;
- vp = dec->components[2].image;
- argbp = argb_image;
- for(j=0;j<dec->height;j++){
- yuv_mux (tmp, yp, up, vp, dec->width);
- oil_colorspace_argb(argbp, tmp, jfif_matrix, dec->width);
- yp += dec->components[0].rowstride;
- up += dec->components[1].rowstride;
- vp += dec->components[2].rowstride;
- argbp += dec->width;
- }
- free(tmp);
- return argb_image;
-}
-
-uint32_t *
-get_argb_422 (JpegDecoder *dec)
-{
- uint32_t *tmp;
- uint8_t *tmp_u;
- uint8_t *tmp_v;
- uint32_t *argb_image;
- uint8_t *yp, *up, *vp;
- uint32_t *argbp;
- int j;
-
- tmp = malloc (4 * dec->width * dec->height);
- tmp_u = malloc (dec->width);
- tmp_v = malloc (dec->width);
- argb_image = malloc (4 * dec->width * dec->height);
-
- yp = dec->components[0].image;
- up = dec->components[1].image;
- vp = dec->components[2].image;
- argbp = argb_image;
- for(j=0;j<dec->height;j++){
- upsample (tmp_u, up, dec->width);
- upsample (tmp_v, vp, dec->width);
- yuv_mux (tmp, yp, tmp_u, tmp_v, dec->width);
- oil_colorspace_argb(argbp, tmp, jfif_matrix, dec->width);
- yp += dec->components[0].rowstride;
- up += dec->components[1].rowstride;
- vp += dec->components[2].rowstride;
- argbp += dec->width;
- }
- free(tmp);
- free(tmp_u);
- free(tmp_v);
- return argb_image;
-}
-
-uint32_t *
-get_argb_422v (JpegDecoder *dec)
-{
- uint32_t *tmp;
- uint8_t *tmp_u;
- uint8_t *tmp_v;
- uint32_t *argb_image;
- uint8_t *yp, *up, *vp;
- uint32_t *argbp;
- int halfheight;
- int j;
-
- tmp = malloc (4 * dec->width * dec->height);
- tmp_u = malloc (dec->width);
- tmp_v = malloc (dec->width);
- argb_image = malloc (4 * dec->width * dec->height);
-
- yp = dec->components[0].image;
- up = dec->components[1].image;
- vp = dec->components[2].image;
- argbp = argb_image;
- halfheight = (dec->height+1)>>1;
- for(j=0;j<dec->height;j++){
- uint32_t weight = 192 - 128*(j&1);
-
- oil_merge_linear_u8(tmp_u,
- up + dec->components[1].rowstride * CLAMP((j-1)/2,0,halfheight-1),
- up + dec->components[1].rowstride * CLAMP((j+1)/2,0,halfheight-1),
- &weight, dec->width);
- oil_merge_linear_u8(tmp_v,
- vp + dec->components[2].rowstride * CLAMP((j-1)/2,0,halfheight-1),
- vp + dec->components[2].rowstride * CLAMP((j+1)/2,0,halfheight-1),
- &weight, dec->width);
-
- yuv_mux (tmp, yp, tmp_u, tmp_v, dec->width);
- oil_colorspace_argb(argbp, tmp, jfif_matrix, dec->width);
- yp += dec->components[0].rowstride;
- argbp += dec->width;
- }
- free(tmp);
- free(tmp_u);
- free(tmp_v);
- return argb_image;
-}
-
-uint32_t *
-get_argb_420 (JpegDecoder *dec)
-{
- uint32_t *tmp;
- uint8_t *tmp_u;
- uint8_t *tmp_v;
- uint8_t *tmp1;
- uint32_t *argb_image;
- uint8_t *yp, *up, *vp;
- uint32_t *argbp;
- int j;
- int halfwidth;
- int halfheight;
-
- halfwidth = (dec->width + 1)>>1;
- tmp = malloc (4 * dec->width * dec->height);
- tmp_u = malloc (dec->width);
- tmp_v = malloc (dec->width);
- tmp1 = malloc (halfwidth);
- argb_image = malloc (4 * dec->width * dec->height);
-
- yp = dec->components[0].image;
- up = dec->components[1].image;
- vp = dec->components[2].image;
- argbp = argb_image;
- halfheight = (dec->height+1)>>1;
- for(j=0;j<dec->height;j++){
- uint32_t weight = 192 - 128*(j&1);
-
- oil_merge_linear_u8(tmp1,
- up + dec->components[1].rowstride * CLAMP((j-1)/2,0,halfheight-1),
- up + dec->components[1].rowstride * CLAMP((j+1)/2,0,halfheight-1),
- &weight, halfwidth);
- upsample (tmp_u, tmp1, dec->width);
- oil_merge_linear_u8(tmp1,
- vp + dec->components[2].rowstride * CLAMP((j-1)/2,0,halfheight-1),
- vp + dec->components[2].rowstride * CLAMP((j+1)/2,0,halfheight-1),
- &weight, halfwidth);
- upsample (tmp_v, tmp1, dec->width);
-
- yuv_mux (tmp, yp, tmp_u, tmp_v, dec->width);
- oil_colorspace_argb(argbp, tmp, jfif_matrix, dec->width);
- yp += dec->components[0].rowstride;
- argbp += dec->width;
- }
- free(tmp);
- free(tmp_u);
- free(tmp_v);
- free(tmp1);
- return argb_image;
-}
-
-#if 0
-int
-jpeg_rgb_decoder_get_image (JpegRGBDecoder * rgbdec,
- unsigned char **image, int *rowstride, int *width, int *height)
-{
- int i;
-
- jpeg_decoder_get_image_size (rgbdec->dec, &rgbdec->width, &rgbdec->height);
- for (i = 0; i < 3; i++) {
- jpeg_decoder_get_component_ptr (rgbdec->dec, i + 1,
- &rgbdec->component[i].image, &rgbdec->component[i].rowstride);
- jpeg_decoder_get_component_subsampling (rgbdec->dec, i + 1,
- &rgbdec->component[i].h_subsample, &rgbdec->component[i].v_subsample);
- rgbdec->component[i].alloc = 0;
- if (rgbdec->component[i].h_subsample > 1 ||
- rgbdec->component[i].v_subsample > 1) {
- unsigned char *dest;
-
- dest = malloc (rgbdec->width * rgbdec->height);
- if (rgbdec->component[i].v_subsample > 1) {
- if (rgbdec->component[i].h_subsample > 1) {
- imagescale2h2v_u8 (dest,
- rgbdec->width,
- rgbdec->component[i].image,
- rgbdec->component[i].rowstride, rgbdec->width, rgbdec->height);
- } else {
- imagescale2v_u8 (dest,
- rgbdec->width,
- rgbdec->component[i].image,
- rgbdec->component[i].rowstride, rgbdec->width, rgbdec->height);
- }
- } else {
- imagescale2h_u8 (dest,
- rgbdec->width,
- rgbdec->component[i].image,
- rgbdec->component[i].rowstride, rgbdec->width, rgbdec->height);
- }
- rgbdec->component[i].alloc = 1;
- rgbdec->component[i].image = dest;
- rgbdec->component[i].rowstride = rgbdec->width;
- rgbdec->component[i].h_subsample = 1;
- rgbdec->component[i].v_subsample = 1;
- }
- }
-
- rgbdec->image = malloc (rgbdec->width * rgbdec->height * 4);
-
- convert (rgbdec);
-
- if (image)
- *image = rgbdec->image;
- if (rowstride)
- *rowstride = rgbdec->width * 4;
- if (width)
- *width = rgbdec->width;
- if (height)
- *height = rgbdec->height;
-
- return 0;
-}
-#endif
-
-
diff --git a/libswfdec/jpeg/jpeg_rgb_decoder.h b/libswfdec/jpeg/jpeg_rgb_decoder.h
deleted file mode 100644
index 08501ff..0000000
--- a/libswfdec/jpeg/jpeg_rgb_decoder.h
+++ /dev/null
@@ -1,18 +0,0 @@
-
-#ifndef _JPEG_RGB_DECODER_H_
-#define _JPEG_RGB_DECODER_H_
-
-typedef struct jpeg_rgb_decoder_struct JpegRGBDecoder;
-
-
-JpegRGBDecoder *jpeg_rgb_decoder_new(void);
-void jpeg_rgb_decoder_free(JpegRGBDecoder *dec);
-int jpeg_rgb_decoder_addbits(JpegRGBDecoder *dec, unsigned char *data, unsigned int len);
-int jpeg_rgb_decoder_parse(JpegRGBDecoder *dec);
-int jpeg_rgb_decoder_get_image(JpegRGBDecoder *dec,
- unsigned char **image, int *rowstride, int *width, int *height);
-
-
-
-#endif
-
diff --git a/libswfdec/jpeg/jpeg_tables.c b/libswfdec/jpeg/jpeg_tables.c
deleted file mode 100644
index bd2d22a..0000000
--- a/libswfdec/jpeg/jpeg_tables.c
+++ /dev/null
@@ -1,54 +0,0 @@
-
-unsigned char jpeg_standard_tables[] = {
- 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
-
- 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03,
- 0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d,
- 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31,
- 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32,
- 0x81, 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52,
- 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
- 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
- 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45,
- 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57,
- 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
- 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83,
- 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94,
- 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
- 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
- 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
- 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
- 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8,
- 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
- 0xf9, 0xfa,
-
- 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
- 0x0a, 0x0b,
-
- 0x00, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04,
- 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77,
- 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06,
- 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81,
- 0x08, 0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33,
- 0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
- 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27, 0x28,
- 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44,
- 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56,
- 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
- 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
- 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92,
- 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3,
- 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
- 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
- 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
- 0xd7, 0xd8, 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
- 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
- 0xf9, 0xfa,
-};
-
-int jpeg_standard_tables_size = sizeof(jpeg_standard_tables);
-
diff --git a/libswfdec/swfdec.h b/libswfdec/swfdec.h
deleted file mode 100644
index e2432eb..0000000
--- a/libswfdec/swfdec.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef __SWFDEC_H__
-#define __SWFDEC_H__
-
-#include <libswfdec/swfdec_as_context.h>
-#include <libswfdec/swfdec_as_debugger.h>
-#include <libswfdec/swfdec_as_frame.h>
-#include <libswfdec/swfdec_as_function.h>
-#include <libswfdec/swfdec_as_native_function.h>
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_script.h>
-
-#include <libswfdec/swfdec_audio.h>
-#include <libswfdec/swfdec_buffer.h>
-#include <libswfdec/swfdec_enums.h>
-#include <libswfdec/swfdec_file_loader.h>
-#include <libswfdec/swfdec_keys.h>
-#include <libswfdec/swfdec_loader.h>
-#include <libswfdec/swfdec_player.h>
-#include <libswfdec/swfdec_player_scripting.h>
-#include <libswfdec/swfdec_rectangle.h>
-#include <libswfdec/swfdec_socket.h>
-#include <libswfdec/swfdec_stream.h>
-#include <libswfdec/swfdec_system.h>
-#include <libswfdec/swfdec_url.h>
-
-#endif
diff --git a/libswfdec/swfdec_accessibility.c b/libswfdec/swfdec_accessibility.c
deleted file mode 100644
index 46497d2..0000000
--- a/libswfdec/swfdec_accessibility.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (1999, 0, swfdec_accessibility_isActive)
-void
-swfdec_accessibility_isActive (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Accessibility.isActive (static)");
-}
-
-SWFDEC_AS_NATIVE (1999, 1, swfdec_accessibility_sendEvent)
-void
-swfdec_accessibility_sendEvent (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Accessibility.sendEvent (static)");
-}
-
-SWFDEC_AS_NATIVE (1999, 2, swfdec_accessibility_updateProperties)
-void
-swfdec_accessibility_updateProperties (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Accessibility.updateProperties (static)");
-}
diff --git a/libswfdec/swfdec_amf.c b/libswfdec/swfdec_amf.c
deleted file mode 100644
index 688df0a..0000000
--- a/libswfdec/swfdec_amf.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_amf.h"
-#include "swfdec_as_array.h"
-#include "swfdec_debug.h"
-
-typedef gboolean (* SwfdecAmfParseFunc) (SwfdecAsContext *cx, SwfdecBits *bits, SwfdecAsValue *val);
-extern const SwfdecAmfParseFunc parse_funcs[SWFDEC_AMF_N_TYPES];
-
-static gboolean
-swfdec_amf_parse_boolean (SwfdecAsContext *context, SwfdecBits *bits, SwfdecAsValue *val)
-{
- SWFDEC_AS_VALUE_SET_BOOLEAN (val, swfdec_bits_get_u8 (bits) ? TRUE : FALSE);
- return TRUE;
-}
-
-static gboolean
-swfdec_amf_parse_number (SwfdecAsContext *context, SwfdecBits *bits, SwfdecAsValue *val)
-{
- SWFDEC_AS_VALUE_SET_NUMBER (val, swfdec_bits_get_bdouble (bits));
- return TRUE;
-}
-
-static gboolean
-swfdec_amf_parse_string (SwfdecAsContext *context, SwfdecBits *bits, SwfdecAsValue *val)
-{
- guint len = swfdec_bits_get_bu16 (bits);
- char *s;
-
- /* FIXME: the supplied version is likely incorrect */
- s = swfdec_bits_get_string_length (bits, len, context->version);
- if (s == NULL)
- return FALSE;
- SWFDEC_AS_VALUE_SET_STRING (val, swfdec_as_context_give_string (context, s));
- return TRUE;
-}
-
-static gboolean
-swfdec_amf_parse_properties (SwfdecAsContext *context, SwfdecBits *bits, SwfdecAsObject *object)
-{
- guint type;
- SwfdecAmfParseFunc func;
-
- while (swfdec_bits_left (bits)) {
- SwfdecAsValue val;
- const char *name;
-
- if (!swfdec_amf_parse_string (context, bits, &val))
- return FALSE;
- name = SWFDEC_AS_VALUE_GET_STRING (&val);
- type = swfdec_bits_get_u8 (bits);
- if (type == SWFDEC_AMF_END_OBJECT)
- break;
- if (type >= SWFDEC_AMF_N_TYPES ||
- (func = parse_funcs[type]) == NULL) {
- SWFDEC_ERROR ("no parse func for AMF type %u", type);
- goto error;
- }
- swfdec_as_object_set_variable (object, name, &val); /* GC... */
- if (!func (context, bits, &val)) {
- goto error;
- }
- swfdec_as_object_set_variable (object, name, &val);
- }
- /* no more bytes seems to end automatically */
- return TRUE;
-
-error:
- return FALSE;
-}
-
-static gboolean
-swfdec_amf_parse_object (SwfdecAsContext *context, SwfdecBits *bits, SwfdecAsValue *val)
-{
- SwfdecAsObject *object;
-
- object = swfdec_as_object_new (context);
- if (object == NULL)
- return FALSE;
- if (!swfdec_amf_parse_properties (context, bits, object))
- return FALSE;
- SWFDEC_AS_VALUE_SET_OBJECT (val, object);
- return TRUE;
-}
-
-static gboolean
-swfdec_amf_parse_mixed_array (SwfdecAsContext *context, SwfdecBits *bits, SwfdecAsValue *val)
-{
- guint len;
- SwfdecAsObject *array;
-
- len = swfdec_bits_get_bu32 (bits);
- array = swfdec_as_array_new (context);
- if (array == NULL)
- return FALSE;
- if (!swfdec_amf_parse_properties (context, bits, array))
- return FALSE;
- SWFDEC_AS_VALUE_SET_OBJECT (val, array);
- return TRUE;
-}
-
-static gboolean
-swfdec_amf_parse_array (SwfdecAsContext *context, SwfdecBits *bits, SwfdecAsValue *val)
-{
- guint i, len;
- SwfdecAsObject *array;
- guint type;
- SwfdecAmfParseFunc func;
-
- len = swfdec_bits_get_bu32 (bits);
- array = swfdec_as_array_new (context);
- if (array == NULL)
- return FALSE;
- for (i = 0; i < len; i++) {
- SwfdecAsValue tmp;
- type = swfdec_bits_get_u8 (bits);
- if (type >= SWFDEC_AMF_N_TYPES ||
- (func = parse_funcs[type]) == NULL) {
- SWFDEC_ERROR ("no parse func for AMF type %u", type);
- goto fail;
- }
- if (!func (context, bits, &tmp))
- goto fail;
- swfdec_as_array_push (SWFDEC_AS_ARRAY (array), &tmp);
- }
-
- SWFDEC_AS_VALUE_SET_OBJECT (val, array);
- return TRUE;
-
-fail:
- return FALSE;
-}
-
-const SwfdecAmfParseFunc parse_funcs[SWFDEC_AMF_N_TYPES] = {
- [SWFDEC_AMF_NUMBER] = swfdec_amf_parse_number,
- [SWFDEC_AMF_BOOLEAN] = swfdec_amf_parse_boolean,
- [SWFDEC_AMF_STRING] = swfdec_amf_parse_string,
- [SWFDEC_AMF_OBJECT] = swfdec_amf_parse_object,
- [SWFDEC_AMF_MIXED_ARRAY] = swfdec_amf_parse_mixed_array,
- [SWFDEC_AMF_ARRAY] = swfdec_amf_parse_array,
-#if 0
- SWFDEC_AMF_MOVIECLIP = 4,
- SWFDEC_AMF_NULL = 5,
- SWFDEC_AMF_UNDEFINED = 6,
- SWFDEC_AMF_REFERENCE = 7,
- SWFDEC_AMF_END_OBJECT = 9,
- SWFDEC_AMF_ARRAY = 10,
- SWFDEC_AMF_DATE = 11,
- SWFDEC_AMF_BIG_STRING = 12,
- SWFDEC_AMF_RECORDSET = 14,
- SWFDEC_AMF_XML = 15,
- SWFDEC_AMF_CLASS = 16,
- SWFDEC_AMF_FLASH9 = 17,
-#endif
-};
-
-gboolean
-swfdec_amf_parse_one (SwfdecAsContext *context, SwfdecBits *bits,
- SwfdecAmfType expected_type, SwfdecAsValue *rval)
-{
- SwfdecAmfParseFunc func;
- guint type;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), 0);
- g_return_val_if_fail (context->global != NULL, 0);
- g_return_val_if_fail (bits != NULL, FALSE);
- g_return_val_if_fail (rval != NULL, FALSE);
- g_return_val_if_fail (expected_type < SWFDEC_AMF_N_TYPES, FALSE);
-
- type = swfdec_bits_get_u8 (bits);
- if (type != expected_type) {
- SWFDEC_ERROR ("parse object should be type %u, but is %u",
- expected_type, type);
- return FALSE;
- }
- if (type >= SWFDEC_AMF_N_TYPES ||
- (func = parse_funcs[type]) == NULL) {
- SWFDEC_ERROR ("no parse func for AMF type %u", type);
- return FALSE;
- }
- return func (context, bits, rval);
-}
-
-guint
-swfdec_amf_parse (SwfdecAsContext *context, SwfdecBits *bits, guint n_items, ...)
-{
- va_list args;
- guint i;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), 0);
- g_return_val_if_fail (context->global != NULL, 0);
- g_return_val_if_fail (bits != NULL, 0);
-
- va_start (args, n_items);
- for (i = 0; i < n_items; i++) {
- SwfdecAmfType type = va_arg (args, SwfdecAmfType);
- SwfdecAsValue *val = va_arg (args, SwfdecAsValue *);
- if (!swfdec_amf_parse_one (context, bits, type, val))
- break;
- }
- va_end (args);
- return i;
-}
-
diff --git a/libswfdec/swfdec_amf.h b/libswfdec/swfdec_amf.h
deleted file mode 100644
index 0f9c67e..0000000
--- a/libswfdec/swfdec_amf.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef __SWFDEC_AMF_H__
-#define __SWFDEC_AMF_H__
-
-#include <libswfdec/swfdec_as_context.h>
-#include <libswfdec/swfdec_bits.h>
-
-typedef enum {
- SWFDEC_AMF_NUMBER = 0,
- SWFDEC_AMF_BOOLEAN = 1,
- SWFDEC_AMF_STRING = 2,
- SWFDEC_AMF_OBJECT = 3,
- SWFDEC_AMF_MOVIECLIP = 4,
- SWFDEC_AMF_NULL = 5,
- SWFDEC_AMF_UNDEFINED = 6,
- SWFDEC_AMF_REFERENCE = 7,
- SWFDEC_AMF_MIXED_ARRAY = 8,
- SWFDEC_AMF_END_OBJECT = 9,
- SWFDEC_AMF_ARRAY = 10,
- SWFDEC_AMF_DATE = 11,
- SWFDEC_AMF_BIG_STRING = 12,
- /* what is 13? */
- SWFDEC_AMF_RECORDSET = 14,
- SWFDEC_AMF_XML = 15,
- SWFDEC_AMF_CLASS = 16,
- SWFDEC_AMF_FLASH9 = 17,
- /* add more items here */
- SWFDEC_AMF_N_TYPES
-} SwfdecAmfType;
-
-gboolean swfdec_amf_parse_one (SwfdecAsContext * context,
- SwfdecBits * bits,
- SwfdecAmfType expected_type,
- SwfdecAsValue * rval);
-guint swfdec_amf_parse (SwfdecAsContext * context,
- SwfdecBits * bits,
- guint n_items,
- ...);
-
-
-#endif
diff --git a/libswfdec/swfdec_as_array.c b/libswfdec/swfdec_as_array.c
deleted file mode 100644
index 344c087..0000000
--- a/libswfdec/swfdec_as_array.c
+++ /dev/null
@@ -1,1399 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "swfdec_as_array.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_frame_internal.h"
-#include "swfdec_as_function.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_native_function.h"
-#include "swfdec_as_string.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_movie.h"
-#include "swfdec_debug.h"
-
-G_DEFINE_TYPE (SwfdecAsArray, swfdec_as_array, SWFDEC_TYPE_AS_OBJECT)
-
-/**
- * SECTION:SwfdecAsArray
- * @title: SwfdecAsArray
- * @short_description: the array object
- *
- * The array object provides some convenience functions for creating and
- * modifying arrays.
- */
-
-/**
- * SwfdecAsArray
- *
- * This is the type of the array object.
- */
-
-/*
- * Internal helper functions
- */
-
-/* NB: type is important for overflow */
-static inline gint32
-swfdec_as_array_to_index (const char *str)
-{
- char *end;
- gulong l;
-
- g_return_val_if_fail (str != NULL, -1);
-
- l = strtoul (str, &end, 10);
-
- if (*end != 0 || l > G_MAXINT32)
- return -1;
-
- return l;
-}
-
-static gint32
-swfdec_as_array_length_as_integer (SwfdecAsObject *object)
-{
- SwfdecAsValue val;
- gint32 length;
-
- g_return_val_if_fail (object != NULL, 0);
-
- swfdec_as_object_get_variable (object, SWFDEC_AS_STR_length, &val);
- length = swfdec_as_value_to_integer (object->context, &val);
-
- return length;
-}
-
-static gint32
-swfdec_as_array_length (SwfdecAsObject *object)
-{
- gint32 length;
-
- length = swfdec_as_array_length_as_integer (object);
-
- if (length < 0)
- return 0;
-
- return length;
-}
-
-/**
- * swfdec_as_array_get_length:
- * @array: a #SwfdecAsArray
- *
- * Gets the current length of the @array.
- *
- * Returns: Current length of the @array, always >= 0
- **/
-gint32
-swfdec_as_array_get_length (SwfdecAsArray *array)
-{
- return swfdec_as_array_length (SWFDEC_AS_OBJECT (array));
-}
-
-static void
-swfdec_as_array_set_length_object (SwfdecAsObject *object, gint32 length)
-{
- SwfdecAsValue val;
-
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
-
- SWFDEC_AS_VALUE_SET_INT (&val, length);
- swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR_length, &val,
- SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
-}
-
-/**
- * swfdec_as_array_set_length:
- * @array: a #SwfdecAsArray
- * @length: the new length
- *
- * Sets the length of the @array. Values outside the new length will be
- * removed.
- **/
-void
-swfdec_as_array_set_length (SwfdecAsArray *array, gint32 length)
-{
- g_return_if_fail (SWFDEC_IS_AS_ARRAY (array));
- g_return_if_fail (length >= 0);
-
- swfdec_as_array_set_length_object (SWFDEC_AS_OBJECT (array), length);
-}
-
-typedef struct {
- gint32 start_index;
- gint32 num;
-} ForeachRemoveRangeData;
-
-static gboolean
-swfdec_as_array_foreach_remove_range (SwfdecAsObject *object,
- const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
-{
- ForeachRemoveRangeData *fdata = data;
- gint32 idx;
-
- idx = swfdec_as_array_to_index (variable);
- if (idx == -1)
- return FALSE;
-
- if (idx >= fdata->start_index && idx < fdata->start_index + fdata->num)
- return TRUE;
-
- return FALSE;
-}
-
-static void
-swfdec_as_array_remove_range (SwfdecAsArray *array, gint32 start_index,
- gint32 num)
-{
- SwfdecAsObject *object = SWFDEC_AS_OBJECT (array);
-
- g_return_if_fail (SWFDEC_IS_AS_ARRAY (array));
- g_return_if_fail (start_index >= 0);
- g_return_if_fail (num >= 0);
- g_return_if_fail (start_index + num <= swfdec_as_array_length (object));
-
- if (num == 0)
- return;
-
- // to avoid foreach loop, use special case when removing just one variable
- if (num == 1) {
- swfdec_as_object_delete_variable (object,
- swfdec_as_integer_to_string (object->context, start_index));
- } else {
- ForeachRemoveRangeData fdata = { start_index, num };
- swfdec_as_object_foreach_remove (object,
- swfdec_as_array_foreach_remove_range, &fdata);
- }
-}
-
-typedef struct {
- gint32 start_index;
- gint32 num;
- gint32 to_index;
-} ForeachMoveRangeData;
-
-static const char *
-swfdec_as_array_foreach_move_range (SwfdecAsObject *object,
- const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
-{
- ForeachMoveRangeData *fdata = data;
- gint32 idx;
-
- idx = swfdec_as_array_to_index (variable);
- if (idx == -1)
- return variable;
-
- if (idx >= fdata->start_index && idx < fdata->start_index + fdata->num) {
- return swfdec_as_integer_to_string (object->context,
- fdata->to_index + idx - fdata->start_index);
- } else if (idx >= fdata->to_index && idx < fdata->to_index + fdata->num) {
- return NULL;
- } else {
- return variable;
- }
-}
-
-static void
-swfdec_as_array_move_range (SwfdecAsObject *object, gint32 from_index,
- gint32 num, gint32 to_index)
-{
- ForeachMoveRangeData fdata = { from_index, num, to_index };
-
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
- g_return_if_fail (from_index >= 0);
- g_return_if_fail (num >= 0);
- g_return_if_fail (from_index + num <= swfdec_as_array_length (object));
- g_return_if_fail (to_index >= 0);
-
- if (num == 0 || from_index == to_index)
- return;
-
- swfdec_as_object_foreach_rename (object, swfdec_as_array_foreach_move_range,
- &fdata);
-
- // only changes length if it becomes bigger, not if it becomes smaller
- if (to_index + num > swfdec_as_array_length (object))
- swfdec_as_array_set_length_object (object, to_index + num);
-}
-
-static void
-swfdec_as_array_set_range_with_flags (SwfdecAsObject *object,
- gint32 start_index, gint32 num, const SwfdecAsValue *value,
- SwfdecAsVariableFlag flags)
-{
- gint32 i;
- const char *var;
-
- // allow negative indexes
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
- g_return_if_fail (num >= 0);
- g_return_if_fail (num == 0 || value != NULL);
-
- for (i = 0; i < num; i++) {
- var = swfdec_as_integer_to_string (object->context, start_index + i);
- swfdec_as_object_set_variable_and_flags (object, var, &value[i], flags);
- }
-}
-
-static void
-swfdec_as_array_set_range (SwfdecAsObject *object, gint32 start_index,
- gint32 num, const SwfdecAsValue *value)
-{
- swfdec_as_array_set_range_with_flags (object, start_index, num, value, 0);
-}
-
-static void
-swfdec_as_array_append_internal (SwfdecAsObject *object, guint n,
- const SwfdecAsValue *value)
-{
- // allow negative length
- swfdec_as_array_set_range (object,
- swfdec_as_array_length_as_integer (object), n, value);
-}
-
-/**
- * swfdec_as_array_push:
- * @array: a #SwfdecAsArray
- * @value: the value to add
- *
- * Adds the given @value to the @array. This is a macro that just calls
- * swfdec_as_array_append_with_flags().
- */
-
-/**
- * swfdec_as_array_push_with_flags:
- * @array: a #SwfdecAsArray
- * @value: the value to add
- * @flags: the #SwfdecAsVariableFlag flags to use
- *
- * Adds the given @value to the @array with the given @flags. This is a macro
- * that just calls swfdec_as_array_append_with_flags().
- */
-
-/**
- * swfdec_as_array_append:
- * @array: a #SwfdecAsArray
- * @n: number of values to add
- * @values: the values to add
- *
- * Appends the given @values to the @array. This is a macro that just calls
- * swfdec_as_array_append_with_flags().
- **/
-
-/**
- * swfdec_as_array_append_with_flags:
- * @array: a #SwfdecAsArray
- * @n: number of values to add
- * @values: the values to add
- * @flags: the #SwfdecAsVariableFlag flags to use
- *
- * Appends the given @values to the @array using the given @flags.
- **/
-void
-swfdec_as_array_append_with_flags (SwfdecAsArray *array, guint n,
- const SwfdecAsValue *value, SwfdecAsVariableFlag flags)
-{
- g_return_if_fail (SWFDEC_IS_AS_ARRAY (array));
- g_return_if_fail (n == 0 || value != NULL);
-
- // don't allow negative length
- swfdec_as_array_set_range_with_flags (SWFDEC_AS_OBJECT (array),
- swfdec_as_array_length (SWFDEC_AS_OBJECT (array)), n, value, flags);
-}
-
-/**
- * swfdec_as_array_insert:
- * @array: a #SwfdecAsArray
- * @idx: index to insert the value to
- * @value: a #SwfdecAsValue
- *
- * Inserts @value to @array at given index, making room for it by moving
- * elements to bigger indexes if necessary. This is a macro that just calls
- * swfdec_as_array_insert_with_flags().
- **/
-/**
- * swfdec_as_array_insert_with_flags:
- * @array: a #SwfdecAsArray
- * @idx: index to insert the value to
- * @value: a #SwfdecAsValue
- * @flags: the #SwfdecAsVariableFlag flags to use
- *
- * Inserts @value to @array at given index using given @flags, making room for
- * it by moving elements to bigger indexes if necessary.
- **/
-void
-swfdec_as_array_insert_with_flags (SwfdecAsArray *array, gint32 idx,
- const SwfdecAsValue *value, SwfdecAsVariableFlag flags)
-{
- gint32 length;
- SwfdecAsObject *object;
-
- g_return_if_fail (SWFDEC_IS_AS_ARRAY (array));
- g_return_if_fail (idx >= 0);
- g_return_if_fail (SWFDEC_IS_AS_VALUE (value));
-
- object = SWFDEC_AS_OBJECT (array);
- length = swfdec_as_array_length (object);
-
- if (idx < length)
- swfdec_as_array_move_range (object, idx, length - idx, idx + 1);
- swfdec_as_array_set_range_with_flags (object, idx, 1, value, flags);
-}
-
-/**
- * swfdec_as_array_remove:
- * @array: a #SwfdecAsArray
- * @idx: index of the value to remove
- *
- * Removes value at given index from the @array, elements with higher indexes
- * will be moved towards the start of the @array.
- **/
-void
-swfdec_as_array_remove (SwfdecAsArray *array, gint32 idx)
-{
- gint32 length;
- SwfdecAsObject *object;
-
- g_return_if_fail (SWFDEC_IS_AS_ARRAY (array));
- g_return_if_fail (idx >= 0);
-
- object = SWFDEC_AS_OBJECT (array);
- length = swfdec_as_array_length (object);
-
- if (idx >= length)
- return;
-
- swfdec_as_array_move_range (object, idx + 1, length - (idx + 1), idx);
- swfdec_as_array_set_length (array, length - 1);
-}
-
-/**
- * swfdec_as_array_get_value:
- * @array: a #SwfdecAsArray
- * @idx: index of the value to get
- * @value: a pointer to #SwfdecAsValue that will be set
- *
- * Gets a value from given index, if the value doesn't exists an undefined
- * value is set.
- **/
-void
-swfdec_as_array_get_value (SwfdecAsArray *array, gint32 idx,
- SwfdecAsValue *value)
-{
- const char *var;
-
- g_assert (SWFDEC_IS_AS_ARRAY (array));
- g_assert (idx >= 0);
- g_assert (value != NULL);
-
- var = swfdec_as_integer_to_string (SWFDEC_AS_OBJECT (array)->context, idx);
- swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (array), var, value);
-}
-
-/**
- * swfdec_as_array_set_value:
- * @array: a #SwfdecAsArray
- * @idx: index of the value to set
- * @value: a pointer to #SwfdecAsValue
- *
- * Sets a @value to given index. The @array's length will be increased if
- * necessary.
- **/
-void
-swfdec_as_array_set_value (SwfdecAsArray *array, gint32 idx,
- SwfdecAsValue *value)
-{
- const char *var;
-
- g_assert (SWFDEC_IS_AS_ARRAY (array));
- g_assert (idx >= 0);
- g_assert (SWFDEC_IS_AS_VALUE (value));
-
- var = swfdec_as_integer_to_string (SWFDEC_AS_OBJECT (array)->context, idx);
- swfdec_as_object_set_variable (SWFDEC_AS_OBJECT (array), var, value);
-}
-
-typedef struct {
- SwfdecAsObject *object_to;
- gint32 offset;
- gint32 start_index;
- gint32 num;
-} ForeachAppendArrayRangeData;
-
-static gboolean
-swfdec_as_array_foreach_append_array_range (SwfdecAsObject *object,
- const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
-{
- ForeachAppendArrayRangeData *fdata = data;
- gint32 idx;
- const char *var;
-
- idx = swfdec_as_array_to_index (variable);
- if (idx >= fdata->start_index && idx < fdata->start_index + fdata->num) {
- var = swfdec_as_integer_to_string (fdata->object_to->context,
- fdata->offset + (idx - fdata->start_index));
- swfdec_as_object_set_variable (fdata->object_to, var, value);
- }
-
- return TRUE;
-}
-
-static void
-swfdec_as_array_append_array_range (SwfdecAsArray *array_to,
- SwfdecAsObject *object_from, gint32 start_index, gint32 num)
-{
- ForeachAppendArrayRangeData fdata;
-
- g_return_if_fail (SWFDEC_IS_AS_ARRAY (array_to));
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (object_from));
- g_return_if_fail (start_index >= 0);
- g_return_if_fail (
- start_index + num <= swfdec_as_array_length (object_from));
-
- if (num == 0)
- return;
-
- fdata.object_to = SWFDEC_AS_OBJECT (array_to);
- fdata.offset = swfdec_as_array_length (SWFDEC_AS_OBJECT (array_to));
- fdata.start_index = start_index;
- fdata.num = num;
-
- swfdec_as_array_set_length_object (fdata.object_to,
- fdata.offset + fdata.num);
- swfdec_as_object_foreach (object_from,
- swfdec_as_array_foreach_append_array_range, &fdata);
-}
-
-static void
-swfdec_as_array_append_array (SwfdecAsArray *array_to,
- SwfdecAsObject *object_from)
-{
- swfdec_as_array_append_array_range (array_to, object_from, 0,
- swfdec_as_array_length (object_from));
-}
-
-/*
- * Class functions
- */
-
-static void
-swfdec_as_array_set (SwfdecAsObject *object, const char *variable,
- const SwfdecAsValue *val, guint flags)
-{
- char *end;
- gboolean indexvar = TRUE;
- gint32 l = strtoul (variable, &end, 10);
-
- if (*end != 0 || l > G_MAXINT32)
- indexvar = FALSE;
-
- // if we changed to smaller length, destroy all values that are outside it
- if (!strcmp (variable, SWFDEC_AS_STR_length)) {
- gint32 length_old = swfdec_as_array_length (object);
- gint32 length_new = MAX (0,
- swfdec_as_value_to_integer (object->context, val));
- if (length_old > length_new) {
- swfdec_as_array_remove_range (SWFDEC_AS_ARRAY (object), length_new,
- length_old - length_new);
- }
- }
-
- SWFDEC_AS_OBJECT_CLASS (swfdec_as_array_parent_class)->set (object, variable,
- val, flags);
-
- // if we added new value outside the current length, set a bigger length
- if (indexvar) {
- if (++l > swfdec_as_array_length_as_integer (object))
- swfdec_as_array_set_length_object (object, l);
- }
-}
-
-static void
-swfdec_as_array_class_init (SwfdecAsArrayClass *klass)
-{
- SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
-
- asobject_class->set = swfdec_as_array_set;
-}
-
-static void
-swfdec_as_array_init (SwfdecAsArray *array)
-{
-}
-
-/*
- * The rest
- */
-
-/**
- * swfdec_as_array_new:
- * @context: a #SwfdecAsContext
- *
- * Creates a new #SwfdecAsArray.
- *
- * Returns: the new array or %NULL on OOM.
- **/
-SwfdecAsObject *
-swfdec_as_array_new (SwfdecAsContext *context)
-{
- SwfdecAsObject *ret;
- SwfdecAsValue val;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
-
- if (!swfdec_as_context_use_mem (context, sizeof (SwfdecAsArray)))
- return NULL;
-
- ret = g_object_new (SWFDEC_TYPE_AS_ARRAY, NULL);
- swfdec_as_object_add (ret, context, sizeof (SwfdecAsArray));
- swfdec_as_object_get_variable (context->global, SWFDEC_AS_STR_Array, &val);
- if (SWFDEC_AS_VALUE_IS_OBJECT (&val))
- swfdec_as_object_set_constructor (ret, SWFDEC_AS_VALUE_GET_OBJECT (&val));
-
- swfdec_as_array_set_length (SWFDEC_AS_ARRAY (ret), 0);
-
- return ret;
-}
-
-/*** AS CODE ***/
-
-SWFDEC_AS_NATIVE (252, 7, swfdec_as_array_join)
-void
-swfdec_as_array_join (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- int i, length;
- const char *var, *str, *sep;
- SwfdecAsValue val;
-
- if (object == NULL || SWFDEC_IS_MOVIE (object))
- return;
-
- if (argc > 0) {
- sep = swfdec_as_value_to_string (cx, &argv[0]);
- } else {
- sep = SWFDEC_AS_STR_COMMA;
- }
-
- length = swfdec_as_array_length (object);
- if (length > 0) {
- /* FIXME: implement this with the StringBuilder class */
- GString *string;
- swfdec_as_object_get_variable (object, SWFDEC_AS_STR_0, &val);
- str = swfdec_as_value_to_string (cx, &val);
- string = g_string_new (str);
- for (i = 1; i < length; i++) {
- var = swfdec_as_integer_to_string (cx, i);
- swfdec_as_object_get_variable (object, var, &val);
- var = swfdec_as_value_to_string (cx, &val);
- g_string_append (string, sep);
- g_string_append (string, var);
- }
- str = swfdec_as_context_give_string (cx, g_string_free (string, FALSE));
- } else {
- str = SWFDEC_AS_STR_EMPTY;
- }
-
- SWFDEC_AS_VALUE_SET_STRING (ret, str);
-}
-
-SWFDEC_AS_NATIVE (252, 9, swfdec_as_array_toString)
-void
-swfdec_as_array_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (object == NULL || SWFDEC_IS_MOVIE (object))
- return;
-
- swfdec_as_array_join (cx, object, 0, NULL, ret);
-}
-
-SWFDEC_AS_NATIVE (252, 1, swfdec_as_array_do_push)
-void
-swfdec_as_array_do_push (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (object == NULL || SWFDEC_IS_MOVIE (object))
- return;
-
- // if 0 args, just return the length
- // manually set the length here to make the function work on non-Arrays
- if (argc > 0) {
- gint32 length = swfdec_as_array_length_as_integer (object);
- swfdec_as_array_append_internal (object, argc, argv);
- swfdec_as_array_set_length_object (object, length + argc);
- }
-
- SWFDEC_AS_VALUE_SET_INT (ret, swfdec_as_array_length_as_integer (object));
-}
-
-SWFDEC_AS_NATIVE (252, 2, swfdec_as_array_do_pop)
-void
-swfdec_as_array_do_pop (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- gint32 length;
- const char *var;
-
- if (object == NULL || SWFDEC_IS_MOVIE (object))
- return;
-
- // we allow negative indexes here, but not 0
- length = swfdec_as_array_length_as_integer (object);
- if (length == 0)
- return;
-
- var = swfdec_as_integer_to_string (object->context, length - 1);
- swfdec_as_object_get_variable (object, var, ret);
-
- // if Array, the length is reduced by one (which destroys the variable also)
- // else the length is not reduced at all, but the variable is still deleted
- if (SWFDEC_IS_AS_ARRAY (object)) {
- swfdec_as_array_set_length_object (object, length - 1);
- } else {
- swfdec_as_object_delete_variable (object, var);
- }
-}
-
-SWFDEC_AS_NATIVE (252, 5, swfdec_as_array_do_unshift)
-void
-swfdec_as_array_do_unshift (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- gint32 length;
-
- if (object == NULL || SWFDEC_IS_MOVIE (object))
- return;
-
- if (argc) {
- // don't allow negative length
- length = swfdec_as_array_length (object);
- swfdec_as_array_move_range (object, 0, length, argc);
- swfdec_as_array_set_range (object, 0, argc, argv);
- // if not Array, leave the length unchanged
- if (!SWFDEC_IS_AS_ARRAY (object))
- swfdec_as_array_set_length_object (object, length);
- }
-
- SWFDEC_AS_VALUE_SET_INT (ret, swfdec_as_array_length (object));
-}
-
-SWFDEC_AS_NATIVE (252, 4, swfdec_as_array_do_shift)
-void
-swfdec_as_array_do_shift (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- gint32 length;
- const char *var;
-
- if (object == NULL || SWFDEC_IS_MOVIE (object))
- return;
-
- // don't allow negative length
- length = swfdec_as_array_length (object);
- if (length <= 0)
- return;
-
- swfdec_as_object_get_variable (object, SWFDEC_AS_STR_0, ret);
-
- swfdec_as_array_move_range (object, 1, length - 1, 0);
-
- // if not Array, leave the length unchanged, and don't remove the element
- if (SWFDEC_IS_AS_ARRAY (object)) {
- swfdec_as_array_set_length_object (object, length - 1);
- } else {
- // we have to put the last element back, because we used move, not copy
- SwfdecAsValue val;
- if (length > 1) {
- var = swfdec_as_integer_to_string (object->context, length - 2);
- swfdec_as_object_get_variable (object, var, &val);
- } else {
- val = *ret;
- }
- var = swfdec_as_integer_to_string (object->context, length - 1);
- swfdec_as_object_set_variable (object, var, &val);
- }
-}
-
-static const char *
-swfdec_as_array_foreach_reverse (SwfdecAsObject *object, const char *variable,
- SwfdecAsValue *value, guint flags, gpointer data)
-{
- gint32 *length = data;
- gint32 idx;
-
- idx = swfdec_as_array_to_index (variable);
- if (idx == -1 || idx >= *length)
- return variable;
-
- return swfdec_as_integer_to_string (object->context, *length - 1 - idx);
-}
-
-SWFDEC_AS_NATIVE (252, 11, swfdec_as_array_reverse)
-void
-swfdec_as_array_reverse (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- gint32 length;
-
- if (object == NULL || SWFDEC_IS_MOVIE (object))
- return;
-
- length = swfdec_as_array_length (object);
- swfdec_as_object_foreach_rename (object, swfdec_as_array_foreach_reverse,
- &length);
-
- SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
-}
-
-SWFDEC_AS_NATIVE (252, 3, swfdec_as_array_concat)
-void
-swfdec_as_array_concat (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- guint j;
- SwfdecAsObject *object_new;
- SwfdecAsArray *array_new;
- const char *var;
-
- if (object == NULL || SWFDEC_IS_MOVIE (object))
- return;
-
- object_new = swfdec_as_array_new (cx);
- if (object_new == NULL)
- return;
- array_new = SWFDEC_AS_ARRAY (object_new);
-
- swfdec_as_array_append_array (array_new, object);
-
- for (j = 0; j < argc; j++) {
- if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[j]) &&
- SWFDEC_IS_AS_ARRAY (SWFDEC_AS_VALUE_GET_OBJECT (&argv[j])))
- {
- swfdec_as_array_append_array (array_new,
- SWFDEC_AS_VALUE_GET_OBJECT (&argv[j]));
- }
- else
- {
- var = swfdec_as_integer_to_string (object->context,
- swfdec_as_array_length (object_new));
- swfdec_as_object_set_variable (object_new, var, &argv[j]);
- }
- }
-
- SWFDEC_AS_VALUE_SET_OBJECT (ret, object_new);
-}
-
-SWFDEC_AS_NATIVE (252, 6, swfdec_as_array_slice)
-void
-swfdec_as_array_slice (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- gint32 length, start_index, num;
- SwfdecAsArray *array_new;
-
- if (object == NULL || SWFDEC_IS_MOVIE (object))
- return;
-
- length = swfdec_as_array_length (object);
-
- if (argc > 0) {
- start_index = swfdec_as_value_to_integer (cx, &argv[0]);
- if (start_index < 0)
- start_index = length + start_index;
- start_index = CLAMP (start_index, 0, length);
- } else {
- start_index = 0;
- }
-
- if (argc > 1) {
- gint32 endIndex = swfdec_as_value_to_integer (cx, &argv[1]);
- if (endIndex < 0)
- endIndex = length + endIndex;
- endIndex = CLAMP (endIndex, start_index, length);
- num = endIndex - start_index;
- } else {
- num = length - start_index;
- }
-
- array_new = SWFDEC_AS_ARRAY (swfdec_as_array_new (cx));
- if (array_new == NULL)
- return;
-
- swfdec_as_array_append_array_range (array_new, object, start_index, num);
-
- SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (array_new));
-}
-
-SWFDEC_AS_NATIVE (252, 8, swfdec_as_array_splice)
-void
-swfdec_as_array_splice (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- gint32 length, start_index, num_remove, num_add;
- SwfdecAsArray *array_new;
-
- if (object == NULL || SWFDEC_IS_MOVIE (object) || argc == 0)
- return;
-
- length = swfdec_as_array_length (object);
-
- start_index = swfdec_as_value_to_integer (cx, &argv[0]);
- if (start_index < 0)
- start_index = length + start_index;
- start_index = CLAMP (start_index, 0, length);
-
- if (argc > 1) {
- num_remove = CLAMP (swfdec_as_value_to_integer (cx, &argv[1]), 0,
- length - start_index);
- } else {
- num_remove = length - start_index;
- }
-
- num_add = (argc > 2 ? argc - 2 : 0);
-
- array_new = SWFDEC_AS_ARRAY (swfdec_as_array_new (cx));
- if (array_new == NULL)
- return;
-
- swfdec_as_array_append_array_range (array_new, object, start_index,
- num_remove);
- swfdec_as_array_move_range (object, start_index + num_remove,
- length - (start_index + num_remove), start_index + num_add);
- if (num_remove > num_add)
- swfdec_as_array_set_length_object (object, length - (num_remove - num_add));
- if (argc > 2)
- swfdec_as_array_set_range (object, start_index, argc - 2, argv + 2);
-
- SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (array_new));
-}
-
-// Sorting
-
-typedef enum {
- ARRAY_SORT_OPTION_CASEINSENSITIVE = 1,
- ARRAY_SORT_OPTION_DESCENDING = 2,
- ARRAY_SORT_OPTION_UNIQUESORT = 4,
- ARRAY_SORT_OPTION_RETURNINDEXEDARRAY = 8,
- ARRAY_SORT_OPTION_NUMERIC = 16
-} ArraySortOptions;
-
-typedef struct {
- SwfdecAsValue **order;
- gint32 order_size;
- SwfdecAsValue undefined;
- gint32 defined_values;
- gint32 length;
- gint32 options;
- SwfdecAsFunction *compare_custom_func;
- const char ** fields;
- SwfdecAsObject *object_new;
-} ForeachSortData;
-
-// inner function for swfdec_as_array_sort_compare
-static int
-swfdec_as_array_sort_compare_values (SwfdecAsContext *cx,
- const SwfdecAsValue *a, const SwfdecAsValue *b, gint32 options,
- SwfdecAsFunction *fun)
-{
- int retval;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (cx), 0);
- g_return_val_if_fail (SWFDEC_IS_AS_VALUE (a), 0);
- g_return_val_if_fail (SWFDEC_IS_AS_VALUE (b), 0);
- g_return_val_if_fail (SWFDEC_IS_AS_VALUE (b), 0);
- g_return_val_if_fail (fun == NULL || SWFDEC_IS_AS_FUNCTION (fun), 0);
-
- if (fun != NULL)
- {
- SwfdecAsValue argv[2] = { *a, *b };
- SwfdecAsValue ret;
- swfdec_as_function_call (fun, NULL, 2, argv, &ret);
- swfdec_as_context_run (fun->object.context);
- retval = swfdec_as_value_to_integer (cx, &ret);
- }
- else if (options & ARRAY_SORT_OPTION_NUMERIC &&
- (SWFDEC_AS_VALUE_IS_NUMBER (a) ||
- SWFDEC_AS_VALUE_IS_NUMBER (b)) &&
- !SWFDEC_AS_VALUE_IS_UNDEFINED (a) &&
- !SWFDEC_AS_VALUE_IS_UNDEFINED (b))
- {
- if (!SWFDEC_AS_VALUE_IS_NUMBER (a)) {
- retval = 1;
- } else if (!SWFDEC_AS_VALUE_IS_NUMBER (b)) {
- retval = -1;
- } else {
- double an = swfdec_as_value_to_number (cx, a);
- double bn = swfdec_as_value_to_number (cx, b);
- retval = (an < bn ? -1 : (an > bn ? 1 : 0));
- }
- }
- else if (options & ARRAY_SORT_OPTION_CASEINSENSITIVE)
- {
- retval = g_strcasecmp (swfdec_as_value_to_string (cx, a),
- swfdec_as_value_to_string (cx, b));
- }
- else
- {
- retval = strcmp (swfdec_as_value_to_string (cx, a),
- swfdec_as_value_to_string (cx, b));
- }
-
- if (options & ARRAY_SORT_OPTION_DESCENDING) {
- return -retval;
- } else {
- return retval;
- }
-}
-
-static int
-swfdec_as_array_sort_compare (SwfdecAsContext *cx, const SwfdecAsValue *a,
- const SwfdecAsValue *b, gint32 options, SwfdecAsFunction *fun,
- const char **fields)
-{
- int i, retval;
- SwfdecAsValue a_comp, b_comp;
- SwfdecAsObject *object;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (cx), 0);
- g_return_val_if_fail (SWFDEC_IS_AS_VALUE (a), 0);
- g_return_val_if_fail (SWFDEC_IS_AS_VALUE (b), 0);
- g_return_val_if_fail (SWFDEC_IS_AS_VALUE (b), 0);
- g_return_val_if_fail (fun == NULL || SWFDEC_IS_AS_FUNCTION (fun), 0);
- g_return_val_if_fail (fields == NULL || fields[0] != NULL, 0);
-
- if (fields == NULL)
- return swfdec_as_array_sort_compare_values (cx, a, b, options, fun);
-
- i = 0;
- do {
- object = swfdec_as_value_to_object (cx, a);
- if (object) {
- swfdec_as_object_get_variable (object, fields[i], &a_comp);
- } else {
- SWFDEC_AS_VALUE_SET_UNDEFINED (&a_comp);
- }
-
- object = swfdec_as_value_to_object (cx, b);
- if (object) {
- swfdec_as_object_get_variable (object, fields[i], &b_comp);
- } else {
- SWFDEC_AS_VALUE_SET_UNDEFINED (&b_comp);
- }
-
- retval =
- swfdec_as_array_sort_compare_values (cx, &a_comp, &b_comp, options, fun);
- } while (retval == 0 && fields[++i] != NULL);
-
- return retval;
-}
-
-// renames values in the array based on fdata->order values
-static const char *
-swfdec_as_array_foreach_sort_rename (SwfdecAsObject *object,
- const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
-{
- ForeachSortData *fdata = data;
- gint32 idx, i;
- gboolean after_undefined = FALSE;
-
- idx = swfdec_as_array_to_index (variable);
- if (idx == -1 || idx >= fdata->length)
- return variable;
-
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (value))
- return NULL;
-
- for (i = 0; i < fdata->order_size; i++) {
- if (fdata->order[i] == value) {
- fdata->order[i] = NULL;
- // leave room for undefined values
- if (after_undefined)
- i += fdata->length - fdata->defined_values - 1;
- return swfdec_as_integer_to_string (object->context, i);
- }
- if (fdata->order[i] == &fdata->undefined)
- after_undefined = TRUE;
- }
-
- g_assert_not_reached ();
- return NULL;
-}
-
-// fills fdata->object_new array using indexes based on the fdata->order
-static gboolean
-swfdec_as_array_foreach_sort_indexedarray (SwfdecAsObject *object,
- const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
-{
- ForeachSortData *fdata = data;
- SwfdecAsValue val;
- const char *var;
- gint32 idx, i;
- gboolean after_undefined = FALSE;
-
- idx = swfdec_as_array_to_index (variable);
- if (idx == -1 || idx >= fdata->length)
- return TRUE;
-
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (value))
- return TRUE;
-
- for (i = 0; i < fdata->order_size; i++) {
- if (fdata->order[i] == value) {
- fdata->order[i] = NULL;
- // leave room for undefined values, that are filled in afterwards
- if (after_undefined)
- i += fdata->length - fdata->defined_values - 1;
- var = swfdec_as_integer_to_string (object->context, i);
- SWFDEC_AS_VALUE_SET_INT (&val, idx);
- swfdec_as_object_set_variable (fdata->object_new, var, &val);
- return TRUE;
- }
- if (fdata->order[i] == &fdata->undefined)
- after_undefined = TRUE;
- }
-
- g_assert_not_reached ();
- return FALSE;
-}
-
-// sets undefined values in the fdata->object_new array to indexes of undefined
-// values in the object array
-static void
-swfdec_as_array_sort_set_undefined_indexedarray (SwfdecAsObject *object,
- ForeachSortData *fdata)
-{
- SwfdecAsValue val;
- const char *var;
- gint32 idx, i, length, num;
-
- for (idx = 0; idx < fdata->order_size; idx++) {
- if (fdata->order[idx] == &fdata->undefined)
- break;
- }
-
- num = 0;
- length = swfdec_as_array_length (object);
- for (i = 0; i < length - fdata->defined_values; i++) {
- do {
- var = swfdec_as_integer_to_string (object->context, num);
- num++;
- } while (swfdec_as_object_get_variable (object, var, &val) &&
- !SWFDEC_AS_VALUE_IS_UNDEFINED (&val));
- var = swfdec_as_integer_to_string (fdata->object_new->context, idx + i);
- SWFDEC_AS_VALUE_SET_INT (&val, num - 1);
- swfdec_as_object_set_variable (fdata->object_new, var, &val);
- }
-}
-
-// tests if any value in the array is equal to a undefined value
-// (in the sense that sorting compare function returns 0)
-// used by uniquesort when there is exactly one undefined value in the array
-static gboolean
-swfdec_as_array_foreach_sort_compare_undefined (SwfdecAsObject *object,
- const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
-{
- ForeachSortData *fdata = data;
- gint32 idx;
-
- idx = swfdec_as_array_to_index (variable);
- if (idx == -1 || idx >= fdata->length)
- return TRUE;
-
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (value))
- return TRUE;
-
- // when testing for uniquesort the custom compare function is NOT used
- if (swfdec_as_array_sort_compare (object->context, value, &fdata->undefined,
- fdata->options, NULL, fdata->fields) == 0)
- return FALSE;
-
- return TRUE;
-}
-
-// fill fdata->order and fdata->defined_values
-static gboolean
-swfdec_as_array_foreach_sort_populate (SwfdecAsObject *object,
- const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
-{
- ForeachSortData *fdata = data;
- gint32 idx, i;
- gint cval = -1;
-
- idx = swfdec_as_array_to_index (variable);
- if (idx == -1 || idx >= fdata->length)
- return TRUE;
-
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (value))
- return TRUE;
-
- fdata->defined_values++;
-
- // find the position for this value
- for (i = 0; i < fdata->order_size; i++)
- {
- if (fdata->order[i] == NULL ||
- (cval = swfdec_as_array_sort_compare (object->context, value,
- fdata->order[i], fdata->options, fdata->compare_custom_func,
- fdata->fields)) <= 0)
- {
- SwfdecAsValue *tmp2, *tmp;
-
- // if we are doing uniquesort, see if this value is the same as some
- // earlier value
- if (fdata->options & ARRAY_SORT_OPTION_UNIQUESORT &&
- fdata->order[i] != NULL && fdata->order[i] != &fdata->undefined) {
- // when using custom function, uniquesort is still based on the
- // equality given by the normal method, not the custom function
- if (fdata->compare_custom_func != NULL) {
- if (swfdec_as_array_sort_compare (object->context, value,
- fdata->order[i], fdata->options, NULL, fdata->fields) == 0) {
- return FALSE;
- }
- } else {
- if (cval == 0)
- return FALSE;
- }
- }
-
- // move rest of the values forward
- tmp = fdata->order[i];
- fdata->order[i] = value;
- while (tmp != NULL && ++i < fdata->order_size) {
- tmp2 = fdata->order[i];
- fdata->order[i] = tmp;
- tmp = tmp2;
- }
- return TRUE;
- }
- }
-
- g_assert_not_reached ();
- return FALSE;
-}
-
-static void
-swfdec_as_array_do_sort (SwfdecAsObject *object, gint32 options,
- SwfdecAsFunction *custom_compare_func, const char **fields,
- SwfdecAsValue *ret)
-{
- ForeachSortData fdata;
-
- // init foreach data
- fdata.length = swfdec_as_array_length (object);
- // FIXME: limit based on the actual amount of properties?
- fdata.order_size = fdata.length + 1;
- fdata.order = g_new0 (SwfdecAsValue *, fdata.order_size);
- SWFDEC_AS_VALUE_SET_UNDEFINED (&fdata.undefined);
- fdata.order[0] = &fdata.undefined;
- fdata.defined_values = 0;
- fdata.options = options;
- fdata.compare_custom_func = custom_compare_func;
- fdata.fields = fields;
-
- // generate fdata.order which points to the values
- if (!swfdec_as_object_foreach (object, swfdec_as_array_foreach_sort_populate,
- &fdata))
- {
- // uniquesort failed
- SWFDEC_AS_VALUE_SET_INT (ret, 0);
- g_free (fdata.order);
- return;
- }
-
- if (fdata.options & ARRAY_SORT_OPTION_UNIQUESORT &&
- fdata.defined_values + 1 < fdata.length)
- {
- // uniquesort fails, because we have more than one undefined value
- SWFDEC_AS_VALUE_SET_INT (ret, 0);
- g_free (fdata.order);
- return;
- }
-
- if (fdata.options & ARRAY_SORT_OPTION_UNIQUESORT &&
- fdata.defined_values < fdata.length)
- {
- // uniquesort used, and we have exactly one undefined value test if
- // anything equals to that
- if (!swfdec_as_object_foreach (object,
- swfdec_as_array_foreach_sort_compare_undefined, &fdata))
- {
- SWFDEC_AS_VALUE_SET_INT (ret, 0);
- g_free (fdata.order);
- return;
- }
- }
-
- if (fdata.options & ARRAY_SORT_OPTION_RETURNINDEXEDARRAY) {
- // make a new array and fill it with numbers based on the order
- fdata.object_new = swfdec_as_array_new (object->context);
- if (fdata.object_new != NULL) {
- swfdec_as_object_foreach (object,
- swfdec_as_array_foreach_sort_indexedarray, &fdata);
- // we have values that have been set now, fill in the undefined values
- swfdec_as_array_sort_set_undefined_indexedarray (object, &fdata);
- SWFDEC_AS_VALUE_SET_OBJECT (ret, fdata.object_new);
- }
- } else {
- // rename properties based on the new order
- swfdec_as_object_foreach_rename (object,
- swfdec_as_array_foreach_sort_rename, &fdata);
- SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
- }
-
- g_free (fdata.order);
-}
-
-SWFDEC_AS_NATIVE (252, 10, swfdec_as_array_sort)
-void
-swfdec_as_array_sort (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- guint pos;
- gint32 options;
- SwfdecAsFunction *custom_compare_func;
-
- if (object == NULL || SWFDEC_IS_MOVIE (object))
- return;
-
- pos = 0;
- if (argc > 0 && !SWFDEC_AS_VALUE_IS_NUMBER (&argv[0])) {
- SwfdecAsFunction *fun;
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]) ||
- !SWFDEC_IS_AS_FUNCTION (
- fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&argv[0])))
- return;
- custom_compare_func = fun;
- pos++;
- } else {
- custom_compare_func = NULL;
- }
-
- if (argc > pos) {
- options = swfdec_as_value_to_integer (cx, &argv[pos]);
- } else {
- options = 0;
- }
-
- swfdec_as_array_do_sort (object, options, custom_compare_func, NULL, ret);
-}
-
-SWFDEC_AS_NATIVE (252, 12, swfdec_as_array_sortOn)
-void
-swfdec_as_array_sortOn (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char **fields;
- gint32 options;
-
- if (object == NULL || SWFDEC_IS_MOVIE (object))
- return;
-
- if (argc < 1)
- return;
-
- if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[0])) {
- gint32 length, i;
- SwfdecAsValue val;
- SwfdecAsObject *array;
-
- array = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
- if (!SWFDEC_IS_AS_ARRAY (array)) {
- SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
- return;
- }
- length = swfdec_as_array_get_length (SWFDEC_AS_ARRAY (array));
- if (length <= 0) {
- SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
- return;
- }
- fields = g_malloc (sizeof (const char *) * (length + 1));
- for (i = 0; i < length; i++) {
- swfdec_as_array_get_value (SWFDEC_AS_ARRAY (array), i, &val);
- if (SWFDEC_AS_VALUE_IS_OBJECT (&val) &&
- SWFDEC_IS_AS_STRING (SWFDEC_AS_VALUE_GET_OBJECT (&val))) {
- fields[i] =
- SWFDEC_AS_STRING (SWFDEC_AS_VALUE_GET_OBJECT (&val))->string;
- } else {
- fields[i] = swfdec_as_value_to_string (cx, &val);
- }
- }
- fields[i] = NULL;
- } else {
- fields = g_malloc (sizeof (const char *) * 2);
- fields[0] = swfdec_as_value_to_string (cx, &argv[0]);
- fields[1] = NULL;
- }
-
- if (argc > 1) {
- options = swfdec_as_value_to_integer (cx, &argv[1]);
- } else {
- options = 0;
- }
-
- swfdec_as_array_do_sort (object, options, NULL, fields, ret);
-
- g_free (fields);
-}
-
-// Constructor
-
-SWFDEC_AS_CONSTRUCTOR (252, 0, swfdec_as_array_construct, swfdec_as_array_get_type)
-void
-swfdec_as_array_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecAsArray *array;
-
- if (!cx->frame->construct) {
- SwfdecAsValue val;
- if (!swfdec_as_context_use_mem (cx, sizeof (SwfdecAsArray)))
- return;
- object = g_object_new (SWFDEC_TYPE_AS_ARRAY, NULL);
- swfdec_as_object_add (object, cx, sizeof (SwfdecAsArray));
- swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_Array, &val);
- if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
- swfdec_as_object_set_constructor (object,
- SWFDEC_AS_VALUE_GET_OBJECT (&val));
- } else {
- SWFDEC_INFO ("\"Array\" is not an object");
- }
- }
-
- array = SWFDEC_AS_ARRAY (object);
- if (argc == 1 && SWFDEC_AS_VALUE_IS_NUMBER (&argv[0])) {
- int l = swfdec_as_value_to_integer (cx, &argv[0]);
- swfdec_as_array_set_length (array, l < 0 ? 0 : l);
- } else if (argc > 0) {
- swfdec_as_array_append (array, argc, argv);
- } else {
- swfdec_as_array_set_length (array, 0);
- }
-
- SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
-}
diff --git a/libswfdec/swfdec_as_array.h b/libswfdec/swfdec_as_array.h
deleted file mode 100644
index 4c23a7f..0000000
--- a/libswfdec/swfdec_as_array.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AS_ARRAY_H_
-#define _SWFDEC_AS_ARRAY_H_
-
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecAsArrayClass SwfdecAsArrayClass;
-
-#define SWFDEC_TYPE_AS_ARRAY (swfdec_as_array_get_type())
-#define SWFDEC_IS_AS_ARRAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_ARRAY))
-#define SWFDEC_IS_AS_ARRAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_ARRAY))
-#define SWFDEC_AS_ARRAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_ARRAY, SwfdecAsArray))
-#define SWFDEC_AS_ARRAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_ARRAY, SwfdecAsArrayClass))
-#define SWFDEC_AS_ARRAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_ARRAY, SwfdecAsArrayClass))
-
-struct _SwfdecAsArray {
- /*< private >*/
- SwfdecAsObject object;
-};
-
-struct _SwfdecAsArrayClass {
- SwfdecAsObjectClass object_class;
-};
-
-GType swfdec_as_array_get_type (void);
-
-SwfdecAsObject *swfdec_as_array_new (SwfdecAsContext * context);
-
-#define swfdec_as_array_push(array,value) \
- swfdec_as_array_append_with_flags ((array), 1, (value), 0)
-#define swfdec_as_array_push_with_flags(array,value,flags) \
- swfdec_as_array_append_with_flags ((array), 1, (value), (flags))
-#define swfdec_as_array_append(array,n,values) \
- swfdec_as_array_append_with_flags ((array), (n), (values), 0)
-void swfdec_as_array_append_with_flags (SwfdecAsArray * array,
- guint n,
- const SwfdecAsValue * values,
- SwfdecAsVariableFlag flags);
-void swfdec_as_array_insert (SwfdecAsArray * array,
- gint32 idx,
- SwfdecAsValue * value);
-#define swfdec_as_array_insert(array,idx,value) \
- swfdec_as_array_insert_with_flags ((array), (idx), (value), 0)
-void swfdec_as_array_insert_with_flags (SwfdecAsArray * array,
- gint32 idx,
- const SwfdecAsValue * value,
- SwfdecAsVariableFlag flags);
-gint32 swfdec_as_array_get_length (SwfdecAsArray * array);
-void swfdec_as_array_set_length (SwfdecAsArray * array,
- gint32 length);
-void swfdec_as_array_get_value (SwfdecAsArray * array,
- gint32 idx,
- SwfdecAsValue * value);
-void swfdec_as_array_set_value (SwfdecAsArray * array,
- gint32 idx,
- SwfdecAsValue * value);
-void swfdec_as_array_remove (SwfdecAsArray * array,
- gint32 idx);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_as_boolean.c b/libswfdec/swfdec_as_boolean.c
deleted file mode 100644
index b3d81dd..0000000
--- a/libswfdec/swfdec_as_boolean.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-
-#include "swfdec_as_boolean.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_native_function.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-
-G_DEFINE_TYPE (SwfdecAsBoolean, swfdec_as_boolean, SWFDEC_TYPE_AS_OBJECT)
-
-static void
-swfdec_as_boolean_class_init (SwfdecAsBooleanClass *klass)
-{
-}
-
-static void
-swfdec_as_boolean_init (SwfdecAsBoolean *boolean)
-{
-}
-
-/*** AS CODE ***/
-
-SWFDEC_AS_CONSTRUCTOR (107, 2, swfdec_as_boolean_construct, swfdec_as_boolean_get_type)
-void
-swfdec_as_boolean_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- gboolean b;
-
- if (argc > 0) {
- b = swfdec_as_value_to_boolean (object->context, &argv[0]);
- } else {
- b = FALSE;
- }
-
- if (swfdec_as_context_is_constructing (cx)) {
- SWFDEC_AS_BOOLEAN (object)->boolean = b;
- SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
- } else {
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, b);
- }
-}
-
-SWFDEC_AS_NATIVE (107, 1, swfdec_as_boolean_toString)
-void
-swfdec_as_boolean_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecAsBoolean *b;
-
- if (!SWFDEC_IS_AS_BOOLEAN (object))
- return;
- b = SWFDEC_AS_BOOLEAN (object);
-
- SWFDEC_AS_VALUE_SET_STRING (ret, b->boolean ? SWFDEC_AS_STR_true : SWFDEC_AS_STR_false);
-}
-
-SWFDEC_AS_NATIVE (107, 0, swfdec_as_boolean_valueOf)
-void
-swfdec_as_boolean_valueOf (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecAsBoolean *b;
-
- if (!SWFDEC_IS_AS_BOOLEAN (object))
- return;
- b = SWFDEC_AS_BOOLEAN (object);
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, b->boolean);
-}
-
-// only available as ASnative
-SWFDEC_AS_NATIVE (3, 2, swfdec_as_boolean_old_constructor)
-void
-swfdec_as_boolean_old_constructor (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("old 'Boolean' function (only available as ASnative)");
-}
diff --git a/libswfdec/swfdec_as_boolean.h b/libswfdec/swfdec_as_boolean.h
deleted file mode 100644
index 723f076..0000000
--- a/libswfdec/swfdec_as_boolean.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AS_BOOLEAN_H_
-#define _SWFDEC_AS_BOOLEAN_H_
-
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecAsBoolean SwfdecAsBoolean;
-typedef struct _SwfdecAsBooleanClass SwfdecAsBooleanClass;
-
-#define SWFDEC_TYPE_AS_BOOLEAN (swfdec_as_boolean_get_type())
-#define SWFDEC_IS_AS_BOOLEAN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_BOOLEAN))
-#define SWFDEC_IS_AS_BOOLEAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_BOOLEAN))
-#define SWFDEC_AS_BOOLEAN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_BOOLEAN, SwfdecAsBoolean))
-#define SWFDEC_AS_BOOLEAN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_BOOLEAN, SwfdecAsBooleanClass))
-#define SWFDEC_AS_BOOLEAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_BOOLEAN, SwfdecAsBooleanClass))
-
-struct _SwfdecAsBoolean {
- SwfdecAsObject object;
-
- gboolean boolean; /* boolean represented by this boolean object */
-};
-
-struct _SwfdecAsBooleanClass {
- SwfdecAsObjectClass object_class;
-};
-
-GType swfdec_as_boolean_get_type (void);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_as_context.c b/libswfdec/swfdec_as_context.c
deleted file mode 100644
index ccce123..0000000
--- a/libswfdec/swfdec_as_context.c
+++ /dev/null
@@ -1,1461 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-#include <string.h>
-#include <stdlib.h>
-#include "swfdec_as_context.h"
-#include "swfdec_as_array.h"
-#include "swfdec_as_frame_internal.h"
-#include "swfdec_as_function.h"
-#include "swfdec_as_initialize.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_interpret.h"
-#include "swfdec_as_native_function.h"
-#include "swfdec_as_object.h"
-#include "swfdec_as_stack.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_as_types.h"
-#include "swfdec_debug.h"
-#include "swfdec_internal.h" /* for swfdec_player_preinit_global() */
-#include "swfdec_script.h"
-
-/*** GARBAGE COLLECTION DOCS ***/
-
-#define SWFDEC_AS_GC_MARK (1 << 0) /* only valid during GC */
-#define SWFDEC_AS_GC_ROOT (1 << 1) /* for objects: rooted, for strings: static */
-
-/**
- * SECTION:Internals
- * @title: Internals and garbage collection
- * @short_description: understanding internals such as garbage collection
- * @see_also: #SwfdecAsContext
- *
- * This section deals with the internals of the Swfdec Actionscript engine. You
- * should probably read this first when trying to write code with it. If you're
- * just trying to use Swfdec for creating Flash content, you can probably skip
- * this section.
- *
- * First, I'd like to note that the Swfdec script engine has to be modeled very
- * closely after the existing Flash players. So if there are some behaviours
- * that seem stupid at first sight, it might very well be that it was chosen for
- * a very particular reason. Now on to the features.
- *
- * The Swfdec script engine tries to imitate Actionscript as good as possible.
- * Actionscript is similar to Javascript, but not equal. Depending on the
- * version of the script executed it might be more or less similar. An important
- * example is that Flash in versions up to 6 did case-insensitive variable
- * lookups.
- *
- * The script engine starts its life when it is initialized via
- * swfdec_as_context_startup (). At that point, the basic objects are created.
- * After this function has been called, you can start executing code. All code
- * execution happens by creating a new #SwfdecAsFrame and then calling
- * swfdec_as_context_run() to execute it. This function is the single entry
- * point for code execution. Convenience functions exist that make executing
- * code easy, most notably swfdec_as_object_run() and
- * swfdec_as_object_call().
- *
- * It is also easily possible to extend the environment by adding new objects.
- * In fact, without doing so, the environment is pretty bare as it just contains
- * the basic Math, String, Number, Array, Date and Boolean objects. This is done
- * by adding #SwfdecAsNative functions to the environment. The easy way
- * to do this is via swfdec_as_object_add_function().
- *
- * The Swfdec script engine is dynamically typed and knows about different types
- * of values. See #SwfdecAsValue for the different values. Memory management is
- * done using a mark and sweep garbage collector. You can initiate a garbage
- * collection cycle by calling swfdec_as_context_gc() or
- * swfdec_as_context_maybe_gc(). You should do this regularly to avoid excessive
- * memory use. The #SwfdecAsContext will then collect the objects and strings it
- * is keeping track of. If you want to use an object or string in the script
- * engine, you'll have to add it first via swfdec_as_object_add() or
- * swfdec_as_context_get_string() and swfdec_as_context_give_string(),
- * respectively.
- *
- * Garbage-collected strings are special in Swfdec in that they are unique. This
- * means the same string exists exactly once. Because of this you can do
- * equality comparisons using == instead of strcmp. It also means that if you
- * forget to add a string to the context before using it, your app will most
- * likely not work, since the string will not compare equal to any other string.
- *
- * When a garbage collection cycle happens, all reachable objects and strings
- * are marked and all unreachable ones are freed. This is done by calling the
- * context class's mark function which will mark all reachable objects. This is
- * usually called the "root set". For any reachable object, the object's mark
- * function is called so that the object in turn can mark all objects it can
- * reach itself. Marking is done via functions described below.
- */
-
-/*** GTK-DOC ***/
-
-/**
- * SECTION:SwfdecAsContext
- * @title: SwfdecAsContext
- * @short_description: the main script engine context
- * @see_also: SwfdecPlayer
- *
- * A #SwfdecAsContext provides the main execution environment for Actionscript
- * execution. It provides the objects typically available in ECMAScript and
- * manages script execution, garbage collection etc. #SwfdecPlayer is a
- * subclass of the context that implements Flash specific objects on top of it.
- * However, it is possible to use the context for completely different functions
- * where a sandboxed scripting environment is needed. An example is the Swfdec
- * debugger.
- * <note>The Actionscript engine is similar, but not equal to Javascript. It
- * is not very different, but it is different.</note>
- */
-
-/**
- * SwfdecAsContext
- *
- * This is the main object ued to hold the state of a script engine. All members
- * are private and should not be accessed.
- *
- * Subclassing this structure to get scripting support in your own appliation is
- * encouraged.
- */
-
-/**
- * SwfdecAsContextState
- * @SWFDEC_AS_CONTEXT_NEW: the context is not yet initialized,
- * swfdec_as_context_startup() needs to be called.
- * @SWFDEC_AS_CONTEXT_RUNNING: the context is running normally
- * @SWFDEC_AS_CONTEXT_INTERRUPTED: the context has been interrupted by a
- * debugger
- * @SWFDEC_AS_CONTEXT_ABORTED: the context has aborted execution due to a
- * fatal error
- *
- * The state of the context describes what operations are possible on the context.
- * It will be in the state @SWFDEC_AS_CONTEXT_STATE_RUNNING almost all the time. If
- * it is in the state @SWFDEC_AS_CONTEXT_STATE_ABORTED, it will not work anymore and
- * every operation on it will instantly fail.
- */
-
-/*** RUNNING STATE ***/
-
-/**
- * swfdec_as_context_abort:
- * @context: a #SwfdecAsContext
- * @reason: a string describing why execution was aborted
- *
- * Aborts script execution in @context. Call this functon if the script engine
- * encountered a fatal error and cannot continue. A possible reason for this is
- * an out-of-memory condition.
- **/
-void
-swfdec_as_context_abort (SwfdecAsContext *context, const char *reason)
-{
- g_return_if_fail (context);
-
- SWFDEC_ERROR ("%s", reason);
- if (context->state != SWFDEC_AS_CONTEXT_ABORTED) {
- context->state = SWFDEC_AS_CONTEXT_ABORTED;
- g_object_notify (G_OBJECT (context), "aborted");
- }
-}
-
-/*** MEMORY MANAGEMENT ***/
-
-/**
- * swfdec_as_context_use_mem:
- * @context: a #SwfdecAsContext
- * @bytes: number of bytes to use
- *
- * Registers @bytes additional bytes as in use by the @context. This function
- * keeps track of the memory that script code consumes. If too many memory is
- * in use, this function may decide to stop the script engine with an out of
- * memory error.
- *
- * Returns: %TRUE if the memory could be allocated. %FALSE on OOM.
- **/
-gboolean
-swfdec_as_context_use_mem (SwfdecAsContext *context, gsize bytes)
-{
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), FALSE);
- g_return_val_if_fail (bytes > 0, FALSE);
-
- if (context->state == SWFDEC_AS_CONTEXT_ABORTED)
- return FALSE;
-
- context->memory += bytes;
- context->memory_since_gc += bytes;
- SWFDEC_LOG ("+%4"G_GSIZE_FORMAT" bytes, total %7"G_GSIZE_FORMAT" (%7"G_GSIZE_FORMAT" since GC)",
- bytes, context->memory, context->memory_since_gc);
- /* FIXME: Don't foget to abort on OOM */
- return TRUE;
-}
-
-/**
- * swfdec_as_context_unuse_mem:
- * @context: a #SwfdecAsContext
- * @bytes: number of bytes to release
- *
- * Releases a number of bytes previously allocated using
- * swfdec_as_context_use_mem(). See that function for details.
- **/
-void
-swfdec_as_context_unuse_mem (SwfdecAsContext *context, gsize bytes)
-{
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
- g_return_if_fail (bytes > 0);
- g_return_if_fail (context->memory >= bytes);
-
- context->memory -= bytes;
- SWFDEC_LOG ("-%4"G_GSIZE_FORMAT" bytes, total %7"G_GSIZE_FORMAT" (%7"G_GSIZE_FORMAT" since GC)",
- bytes, context->memory, context->memory_since_gc);
-}
-
-/*** GC ***/
-
-static gboolean
-swfdec_as_context_remove_strings (gpointer key, gpointer value, gpointer data)
-{
- SwfdecAsContext *context = data;
- char *string;
-
- string = (char *) value;
- /* it doesn't matter that rooted strings aren't destroyed, they're constant */
- if (string[0] & SWFDEC_AS_GC_ROOT) {
- SWFDEC_LOG ("rooted: %s", (char *) key);
- return FALSE;
- } else if (string[0] & SWFDEC_AS_GC_MARK) {
- SWFDEC_LOG ("marked: %s", (char *) key);
- string[0] &= ~SWFDEC_AS_GC_MARK;
- return FALSE;
- } else {
- gsize len;
- SWFDEC_LOG ("deleted: %s", (char *) key);
- len = (strlen ((char *) key) + 2);
- swfdec_as_context_unuse_mem (context, len);
- g_slice_free1 (len, value);
- return TRUE;
- }
-}
-
-static gboolean
-swfdec_as_context_remove_objects (gpointer key, gpointer value, gpointer debugger)
-{
- SwfdecAsObject *object;
-
- object = key;
- /* we only check for mark here, not root, since this works on destroy, too */
- if (object->flags & SWFDEC_AS_GC_MARK) {
- object->flags &= ~SWFDEC_AS_GC_MARK;
- SWFDEC_LOG ("%s: %s %p", (object->flags & SWFDEC_AS_GC_ROOT) ? "rooted" : "marked",
- G_OBJECT_TYPE_NAME (object), object);
- return FALSE;
- } else {
- SWFDEC_LOG ("deleted: %s %p", G_OBJECT_TYPE_NAME (object), object);
- if (debugger) {
- SwfdecAsDebuggerClass *klass = SWFDEC_AS_DEBUGGER_GET_CLASS (debugger);
- if (klass->remove)
- klass->remove (debugger, object->context, object);
- }
- swfdec_as_object_collect (object);
- return TRUE;
- }
-}
-
-static void
-swfdec_as_context_collect (SwfdecAsContext *context)
-{
- SWFDEC_INFO (">> collecting garbage");
- /* NB: This functions is called without GC from swfdec_as_context_dispose */
- g_hash_table_foreach_remove (context->strings,
- swfdec_as_context_remove_strings, context);
- g_hash_table_foreach_remove (context->objects,
- swfdec_as_context_remove_objects, context->debugger);
- SWFDEC_INFO (">> done collecting garbage");
-}
-
-/**
- * swfdec_as_object_mark:
- * @object: a #SwfdecAsObject
- *
- * Mark @object as being in use. Calling this function is only valid during
- * the marking phase of garbage collection.
- **/
-void
-swfdec_as_object_mark (SwfdecAsObject *object)
-{
- SwfdecAsObjectClass *klass;
-
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
-
- if (object->flags & SWFDEC_AS_GC_MARK)
- return;
- object->flags |= SWFDEC_AS_GC_MARK;
- klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
- g_assert (klass->mark);
- klass->mark (object);
-}
-
-/**
- * swfdec_as_string_mark:
- * @string: a garbage-collected string
- *
- * Mark @string as being in use. Calling this function is only valid during
- * the marking phase of garbage collection.
- **/
-void
-swfdec_as_string_mark (const char *string)
-{
- char *str;
-
- g_return_if_fail (string != NULL);
-
- str = (char *) string - 1;
- if (*str == 0)
- *str = SWFDEC_AS_GC_MARK;
-}
-
-/**
- * swfdec_as_value_mark:
- * @value: a #SwfdecAsValue
- *
- * Mark @value as being in use. This is just a convenience function that calls
- * the right marking function depending on the value's type. Calling this
- * function is only valid during the marking phase of garbage collection.
- **/
-void
-swfdec_as_value_mark (SwfdecAsValue *value)
-{
- g_return_if_fail (SWFDEC_IS_AS_VALUE (value));
-
- if (SWFDEC_AS_VALUE_IS_OBJECT (value)) {
- swfdec_as_object_mark (SWFDEC_AS_VALUE_GET_OBJECT (value));
- } else if (SWFDEC_AS_VALUE_IS_STRING (value)) {
- swfdec_as_string_mark (SWFDEC_AS_VALUE_GET_STRING (value));
- }
-}
-
-static void
-swfdec_as_context_mark_roots (gpointer key, gpointer value, gpointer data)
-{
- SwfdecAsObject *object = key;
-
- if ((object->flags & (SWFDEC_AS_GC_MARK | SWFDEC_AS_GC_ROOT)) == SWFDEC_AS_GC_ROOT)
- swfdec_as_object_mark (object);
-}
-
-static void
-swfdec_as_context_do_mark (SwfdecAsContext *context)
-{
- /* This if is needed for SwfdecPlayer */
- if (context->global) {
- swfdec_as_object_mark (context->global);
- swfdec_as_object_mark (context->Function);
- swfdec_as_object_mark (context->Function_prototype);
- swfdec_as_object_mark (context->Object);
- swfdec_as_object_mark (context->Object_prototype);
- }
- if (context->exception)
- swfdec_as_value_mark (&context->exception_value);
- g_hash_table_foreach (context->objects, swfdec_as_context_mark_roots, NULL);
-}
-
-/**
- * swfdec_as_context_gc:
- * @context: a #SwfdecAsContext
- *
- * Calls the Swfdec Gargbage collector and reclaims any unused memory. You
- * should call this function or swfdec_as_context_maybe_gc() regularly.
- * <warning>Calling the GC during execution of code or initialization is not
- * allowed.</warning>
- **/
-void
-swfdec_as_context_gc (SwfdecAsContext *context)
-{
- SwfdecAsContextClass *klass;
-
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
- g_return_if_fail (context->frame == NULL);
- g_return_if_fail (context->state == SWFDEC_AS_CONTEXT_RUNNING);
-
- if (context->state == SWFDEC_AS_CONTEXT_ABORTED)
- return;
- SWFDEC_INFO ("invoking the garbage collector");
- klass = SWFDEC_AS_CONTEXT_GET_CLASS (context);
- g_assert (klass->mark);
- klass->mark (context);
- swfdec_as_context_collect (context);
- context->memory_since_gc = 0;
-}
-
-static gboolean
-swfdec_as_context_needs_gc (SwfdecAsContext *context)
-{
- return context->memory_since_gc >= context->memory_until_gc;
-}
-
-/**
- * swfdec_as_context_maybe_gc:
- * @context: a #SwfdecAsContext
- *
- * Calls the garbage collector if necessary. It's a good idea to call this
- * function regularly instead of swfdec_as_context_gc() as it only does collect
- * garage as needed. For example, #SwfdecPlayer calls this function after every
- * frame advancement.
- **/
-void
-swfdec_as_context_maybe_gc (SwfdecAsContext *context)
-{
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
- g_return_if_fail (context->state == SWFDEC_AS_CONTEXT_RUNNING);
- g_return_if_fail (context->frame == NULL);
-
- if (swfdec_as_context_needs_gc (context))
- swfdec_as_context_gc (context);
-}
-
-/*** SWFDEC_AS_CONTEXT ***/
-
-enum {
- TRACE,
- LAST_SIGNAL
-};
-
-enum {
- PROP_0,
- PROP_DEBUGGER,
- PROP_RANDOM_SEED,
- PROP_ABORTED,
- PROP_UNTIL_GC
-};
-
-G_DEFINE_TYPE (SwfdecAsContext, swfdec_as_context, G_TYPE_OBJECT)
-static guint signals[LAST_SIGNAL] = { 0, };
-
-static void
-swfdec_as_context_get_property (GObject *object, guint param_id, GValue *value,
- GParamSpec * pspec)
-{
- SwfdecAsContext *context = SWFDEC_AS_CONTEXT (object);
-
- switch (param_id) {
- case PROP_DEBUGGER:
- g_value_set_object (value, context->debugger);
- break;
- case PROP_ABORTED:
- g_value_set_boolean (value, context->state == SWFDEC_AS_CONTEXT_ABORTED);
- break;
- case PROP_UNTIL_GC:
- g_value_set_ulong (value, (gulong) context->memory_until_gc);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-swfdec_as_context_set_property (GObject *object, guint param_id, const GValue *value,
- GParamSpec * pspec)
-{
- SwfdecAsContext *context = SWFDEC_AS_CONTEXT (object);
-
- switch (param_id) {
- case PROP_DEBUGGER:
- context->debugger = SWFDEC_AS_DEBUGGER (g_value_dup_object (value));
- break;
- case PROP_RANDOM_SEED:
- g_rand_set_seed (context->rand, g_value_get_uint (value));
- break;
- case PROP_UNTIL_GC:
- context->memory_until_gc = g_value_get_ulong (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-swfdec_as_context_dispose (GObject *object)
-{
- SwfdecAsContext *context = SWFDEC_AS_CONTEXT (object);
-
- while (context->stack)
- swfdec_as_stack_pop_segment (context);
- swfdec_as_context_collect (context);
- if (context->memory != 0) {
- g_critical ("%zu bytes of memory left over\n", context->memory);
- }
- g_assert (g_hash_table_size (context->objects) == 0);
- g_hash_table_destroy (context->objects);
- g_hash_table_destroy (context->strings);
- g_rand_free (context->rand);
- if (context->debugger) {
- g_object_unref (context->debugger);
- context->debugger = NULL;
- }
-
- G_OBJECT_CLASS (swfdec_as_context_parent_class)->dispose (object);
-}
-
-static void
-swfdec_as_context_class_init (SwfdecAsContextClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->dispose = swfdec_as_context_dispose;
- object_class->get_property = swfdec_as_context_get_property;
- object_class->set_property = swfdec_as_context_set_property;
-
- g_object_class_install_property (object_class, PROP_DEBUGGER,
- g_param_spec_object ("debugger", "debugger", "debugger used in this player",
- SWFDEC_TYPE_AS_DEBUGGER, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class, PROP_RANDOM_SEED,
- g_param_spec_uint ("random-seed", "random seed",
- "seed used for calculating random numbers",
- 0, G_MAXUINT32, 0, G_PARAM_WRITABLE)); /* FIXME: make this readwrite for replaying? */
- g_object_class_install_property (object_class, PROP_ABORTED,
- g_param_spec_boolean ("aborted", "aborted", "set when the script engine aborts due to an error",
- FALSE, G_PARAM_READABLE));
- g_object_class_install_property (object_class, PROP_UNTIL_GC,
- g_param_spec_ulong ("memory-until-gc", "memory until gc",
- "amount of bytes that need to be allocated before garbage collection triggers",
- 0, G_MAXULONG, 8 * 1024 * 1024, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- /**
- * SwfdecAsContext::trace:
- * @context: the #SwfdecAsContext affected
- * @text: the debugging string
- *
- * Emits a debugging string while running. The effect of calling any swfdec
- * functions on the emitting @context is undefined.
- */
- signals[TRACE] = g_signal_new ("trace", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
-
- klass->mark = swfdec_as_context_do_mark;
-}
-
-static void
-swfdec_as_context_init (SwfdecAsContext *context)
-{
- const char *s;
-
- context->version = G_MAXUINT;
-
- context->strings = g_hash_table_new (g_str_hash, g_str_equal);
- context->objects = g_hash_table_new (g_direct_hash, g_direct_equal);
-
- for (s = swfdec_as_strings; *s == '\2'; s += strlen (s) + 1) {
- g_hash_table_insert (context->strings, (char *) s + 1, (char *) s);
- }
- g_assert (*s == 0);
- context->rand = g_rand_new ();
- g_get_current_time (&context->start_time);
-}
-
-/*** STRINGS ***/
-
-static const char *
-swfdec_as_context_create_string (SwfdecAsContext *context, const char *string, gsize len)
-{
- char *new;
-
- if (!swfdec_as_context_use_mem (context, sizeof (char) * (2 + len)))
- return SWFDEC_AS_STR_EMPTY;
-
- new = g_slice_alloc (2 + len);
- memcpy (&new[1], string, len);
- new[len + 1] = 0;
- new[0] = 0; /* GC flags */
- g_hash_table_insert (context->strings, new + 1, new);
-
- return new + 1;
-}
-
-/**
- * swfdec_as_context_get_string:
- * @context: a #SwfdecAsContext
- * @string: a sting that is not garbage-collected
- *
- * Gets the garbage-collected version of @string. You need to call this function
- * for every not garbage-collected string that you want to use in Swfdecs script
- * interpreter.
- *
- * Returns: the garbage-collected version of @string
- **/
-const char *
-swfdec_as_context_get_string (SwfdecAsContext *context, const char *string)
-{
- const char *ret;
- gsize len;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
- g_return_val_if_fail (string != NULL, NULL);
-
- if (g_hash_table_lookup_extended (context->strings, string, (gpointer) &ret, NULL))
- return ret;
-
- len = strlen (string);
- return swfdec_as_context_create_string (context, string, len);
-}
-
-/**
- * swfdec_as_context_give_string:
- * @context: a #SwfdecAsContext
- * @string: string to make refcounted
- *
- * Takes ownership of @string and returns a refcounted version of the same
- * string. This function is the same as swfdec_as_context_get_string(), but
- * takes ownership of @string.
- *
- * Returns: A refcounted string
- **/
-const char *
-swfdec_as_context_give_string (SwfdecAsContext *context, char *string)
-{
- const char *ret;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
- g_return_val_if_fail (string != NULL, NULL);
-
- ret = swfdec_as_context_get_string (context, string);
- g_free (string);
- return ret;
-}
-
-/**
- * swfdec_as_context_is_constructing:
- * @context: a #SwfdecAsConstruct
- *
- * Determines if the contexxt is currently constructing. This information is
- * used by various constructors to do different things when they are
- * constructing and when they are not. The Boolean, Number and String functions
- * for example setup the newly constructed objects when constructing but only
- * cast the provided argument when being called.
- *
- * Returns: %TRUE if the currently executing frame is a constructor
- **/
-gboolean
-swfdec_as_context_is_constructing (SwfdecAsContext *context)
-{
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), FALSE);
-
- return context->frame && context->frame->construct;
-}
-
-/**
- * swfdec_as_context_get_frame:
- * @context: a #SwfdecAsContext
- *
- * This is a debugging function. It gets the topmost stack frame that is
- * currently executing. If no function is executing, %NULL is returned. You can
- * easily get a backtrace with code like this:
- * |[for (frame = swfdec_as_context_get_frame (context); frame != NULL;
- * frame = swfdec_as_frame_get_next (frame)) {
- * char *s = swfdec_as_object_get_debug (SWFDEC_AS_OBJECT (frame));
- * g_print ("%s\n", s);
- * g_free (s);
- * }]|
- *
- * Returns: the currently executing frame or %NULL if none
- **/
-SwfdecAsFrame *
-swfdec_as_context_get_frame (SwfdecAsContext *context)
-{
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
-
- return context->frame;
-}
-
-/**
- * swfdec_as_context_throw:
- * @context: a #SwfdecAsContext
- * @value: a #SwfdecAsValue to be thrown
- *
- * Throws a new exception in the @context using the given @value. This function
- * can only be called if the @context is not already throwing an exception.
- **/
-void
-swfdec_as_context_throw (SwfdecAsContext *context, const SwfdecAsValue *value)
-{
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
- g_return_if_fail (SWFDEC_IS_AS_VALUE (value));
- g_return_if_fail (!context->exception);
-
- context->exception = TRUE;
- context->exception_value = *value;
-}
-
-/**
- * swfdec_as_context_catch:
- * @context: a #SwfdecAsContext
- * @value: a #SwfdecAsValue to be thrown
- *
- * Removes the currently thrown exception from @context and sets @value to the
- * thrown value
- *
- * Returns: %TRUE if an exception was catched, %FALSE otherwise
- **/
-gboolean
-swfdec_as_context_catch (SwfdecAsContext *context, SwfdecAsValue *value)
-{
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), FALSE);
-
- if (!context->exception)
- return FALSE;
-
- if (value != NULL)
- *value = context->exception_value;
-
- context->exception = FALSE;
- SWFDEC_AS_VALUE_SET_UNDEFINED (&context->exception_value);
-
- return TRUE;
-}
-
-/**
- * swfdec_as_context_get_time:
- * @context: a #SwfdecAsContext
- * @tv: a #GTimeVal to be set to the context's time
- *
- * This function queries the time to be used inside this context. By default,
- * this is the same as g_get_current_time(), but it may be overwriten to allow
- * things such as slower or faster playback.
- **/
-void
-swfdec_as_context_get_time (SwfdecAsContext *context, GTimeVal *tv)
-{
- SwfdecAsContextClass *klass;
-
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
- g_return_if_fail (tv != NULL);
-
- klass = SWFDEC_AS_CONTEXT_GET_CLASS (context);
- if (klass->get_time)
- klass->get_time (context, tv);
- else
- g_get_current_time (tv);
-}
-
-/**
- * swfdec_as_context_run:
- * @context: a #SwfdecAsContext
- *
- * Continues running the script engine. Executing code in this engine works
- * in 2 steps: First, you push the frame to be executed onto the stack, then
- * you call this function to execute it. So this function is the single entry
- * point to script execution. This might be helpful when debugging your
- * application.
- * <note>A lot of convenience functions like swfdec_as_object_run() call this
- * function automatically.</note>
- **/
-void
-swfdec_as_context_run (SwfdecAsContext *context)
-{
- SwfdecAsFrame *frame, *last_frame;
- SwfdecScript *script;
- const SwfdecActionSpec *spec;
- const guint8 *startpc, *pc, *endpc, *nextpc, *exitpc;
-#ifndef G_DISABLE_ASSERT
- SwfdecAsValue *check;
-#endif
- guint action, len;
- const guint8 *data;
- guint original_version;
- void (* step) (SwfdecAsDebugger *debugger, SwfdecAsContext *context);
- gboolean check_block; /* some opcodes avoid a scope check */
-
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
-
- if (context->frame == NULL || context->state == SWFDEC_AS_CONTEXT_ABORTED)
- return;
-
- if (context->debugger) {
- SwfdecAsDebuggerClass *klass = SWFDEC_AS_DEBUGGER_GET_CLASS (context->debugger);
- step = klass->step;
- } else {
- step = NULL;
- }
-
- last_frame = context->last_frame;
- context->last_frame = context->frame->next;
- original_version = context->version;
-start:
- g_return_if_fail (context->global); /* check here because of swfdec_sandbox_(un)use() */
- if (!swfdec_as_context_check_continue (context))
- goto error;
- /* setup data */
- frame = context->frame;
- if (frame == context->last_frame)
- goto out;
- if (context->call_depth > 256) {
- /* we've exceeded our maximum call depth, throw an error and abort */
- swfdec_as_context_abort (context, "Stack overflow");
- goto error;
- }
- if (SWFDEC_IS_AS_NATIVE_FUNCTION (frame->function)) {
- SwfdecAsNativeFunction *native = SWFDEC_AS_NATIVE_FUNCTION (frame->function);
- SwfdecAsValue rval = { 0, };
- if (frame->argc >= native->min_args &&
- (native->type == 0 ||
- g_type_is_a (G_OBJECT_TYPE (frame->thisp), native->type))) {
- SwfdecAsValue *argv;
- /* accumulate argv */
- if (frame->argc == 0 || frame->argv != NULL) {
- /* FIXME FIXME FIXME: no casting here please! */
- argv = (SwfdecAsValue *) frame->argv;
- } else {
- SwfdecAsStack *stack;
- SwfdecAsValue *cur;
- guint i;
- if (frame->argc > 128) {
- SWFDEC_FIXME ("allow calling native functions with more than 128 args (this one has %u)",
- frame->argc);
- frame->argc = 128;
- }
- argv = g_new (SwfdecAsValue, frame->argc);
- stack = context->stack;
- cur = context->cur;
- for (i = 0; i < frame->argc; i++) {
- if (cur <= &stack->elements[0]) {
- stack = stack->next;
- cur = &stack->elements[stack->used_elements];
- }
- cur--;
- argv[i] = *cur;
- }
- }
- native->native (context, frame->thisp, frame->argc,
- argv, &rval);
- if (argv != frame->argv)
- g_free (argv);
- }
- swfdec_as_frame_return (frame, &rval);
- goto start;
- }
- g_assert (frame->script);
- g_assert (frame->target);
- script = frame->script;
- context->version = script->version;
- startpc = script->buffer->data;
- endpc = startpc + script->buffer->length;
- exitpc = script->exit;
- pc = frame->pc;
- check_block = TRUE;
-
- while (context->state < SWFDEC_AS_CONTEXT_ABORTED) {
- if (context->exception) {
- swfdec_as_frame_handle_exception (frame);
- if (frame != context->frame)
- goto start;
- pc = frame->pc;
- continue;
- }
- if (pc == exitpc) {
- swfdec_as_frame_return (frame, NULL);
- goto start;
- }
- if (pc < startpc || pc >= endpc) {
- SWFDEC_ERROR ("pc %p not in valid range [%p, %p) anymore", pc, startpc, endpc);
- goto error;
- }
- if (check_block && (pc < frame->block_start || pc >= frame->block_end)) {
- SWFDEC_LOG ("code exited block");
- swfdec_as_frame_pop_block (frame);
- pc = frame->pc;
- if (frame != context->frame)
- goto start;
- }
-
- /* decode next action */
- action = *pc;
- if (action == 0) {
- swfdec_as_frame_return (frame, NULL);
- goto start;
- }
- /* invoke debugger if there is one */
- if (step) {
- frame->pc = pc;
- (* step) (context->debugger, context);
- if (frame != context->frame ||
- frame->pc != pc) {
- goto start;
- }
- }
- /* prepare action */
- spec = swfdec_as_actions + action;
- if (action & 0x80) {
- if (pc + 2 >= endpc) {
- SWFDEC_ERROR ("action %u length value out of range", action);
- goto error;
- }
- data = pc + 3;
- len = pc[1] | pc[2] << 8;
- if (data + len > endpc) {
- SWFDEC_ERROR ("action %u length %u out of range", action, len);
- goto error;
- }
- nextpc = pc + 3 + len;
- } else {
- data = NULL;
- len = 0;
- nextpc = pc + 1;
- }
- /* check action is valid */
- if (!spec->exec) {
- SWFDEC_WARNING ("cannot interpret action %3u 0x%02X %s for version %u, skipping it", action,
- action, spec->name ? spec->name : "Unknown", script->version);
- frame->pc = pc = nextpc;
- check_block = TRUE;
- continue;
- }
- if (script->version < spec->version) {
- SWFDEC_WARNING ("cannot interpret action %3u 0x%02X %s for version %u, using version %u instead",
- action, action, spec->name ? spec->name : "Unknown", script->version, spec->version);
- }
- if (spec->remove > 0) {
- if (spec->add > spec->remove)
- swfdec_as_stack_ensure_free (context, spec->add - spec->remove);
- swfdec_as_stack_ensure_size (context, spec->remove);
- } else {
- if (spec->add > 0)
- swfdec_as_stack_ensure_free (context, spec->add);
- }
- if (context->state > SWFDEC_AS_CONTEXT_RUNNING) {
- SWFDEC_WARNING ("context not running anymore, aborting");
- goto error;
- }
-#ifndef G_DISABLE_ASSERT
- check = (spec->add >= 0 && spec->remove >= 0) ? context->cur + spec->add - spec->remove : NULL;
-#endif
- /* execute action */
- spec->exec (context, action, data, len);
- /* adapt the pc if the action did not, otherwise, leave it alone */
- /* FIXME: do this via flag? */
- if (frame->pc == pc) {
- frame->pc = pc = nextpc;
- check_block = TRUE;
- } else {
- if (frame->pc < pc &&
- !swfdec_as_context_check_continue (context)) {
- goto error;
- }
- pc = frame->pc;
- check_block = FALSE;
- }
- if (frame == context->frame) {
-#ifndef G_DISABLE_ASSERT
- if (check != NULL && check != context->cur) {
- g_error ("action %s was supposed to change the stack by %d (+%d -%d), but it changed by %td",
- spec->name, spec->add - spec->remove, spec->add, spec->remove,
- context->cur - check + spec->add - spec->remove);
- }
-#endif
- } else {
- /* someone called/returned from a function, reread variables */
- goto start;
- }
- }
-
-error:
- while (context->frame != context->last_frame)
- swfdec_as_frame_return (context->frame, NULL);
-out:
- context->last_frame = last_frame;
- context->version = original_version;
- return;
-}
-
-/*** EVAL ***/
-
-static char *
-swfdec_as_slash_to_dot (const char *slash_str)
-{
- const char *cur = slash_str;
- GString *str = g_string_new ("");
-
- if (*cur == '/') {
- g_string_append (str, "_root");
- } else {
- goto start;
- }
- while (cur && *cur == '/') {
- cur++;
-start:
- if (str->len > 0)
- g_string_append_c (str, '.');
- if (cur[0] == '.' && cur[1] == '.') {
- g_string_append (str, "_parent");
- cur += 2;
- } else {
- char *slash = strchr (cur, '/');
- if (slash) {
- g_string_append_len (str, cur, slash - cur);
- cur = slash;
- } else {
- g_string_append (str, cur);
- cur = NULL;
- }
- }
- /* cur should now point to the slash */
- }
- if (cur) {
- if (*cur != '\0')
- goto fail;
- }
- SWFDEC_DEBUG ("parsed slash-notated string \"%s\" into dot notation \"%s\"",
- slash_str, str->str);
- return g_string_free (str, FALSE);
-
-fail:
- SWFDEC_WARNING ("failed to parse slash-notated string \"%s\" into dot notation", slash_str);
- g_string_free (str, TRUE);
- return NULL;
-}
-
-static void
-swfdec_as_context_eval_get_property (SwfdecAsContext *cx,
- SwfdecAsObject *obj, const char *name, SwfdecAsValue *ret)
-{
- if (obj) {
- swfdec_as_object_get_variable (obj, name, ret);
- } else {
- if (cx->frame) {
- swfdec_as_frame_get_variable (cx->frame, name, ret);
- } else {
- SWFDEC_WARNING ("eval called without a frame");
- swfdec_as_object_get_variable (cx->global, name, ret);
- }
- }
-}
-
-static void
-swfdec_as_context_eval_set_property (SwfdecAsContext *cx,
- SwfdecAsObject *obj, const char *name, const SwfdecAsValue *ret)
-{
- if (obj == NULL) {
- if (cx->frame == NULL) {
- SWFDEC_ERROR ("no frame in eval_set?");
- return;
- }
- swfdec_as_frame_set_variable (cx->frame, name, ret);
- } else {
- swfdec_as_object_set_variable (obj, name, ret);
- }
-}
-
-static void
-swfdec_as_context_eval_internal (SwfdecAsContext *cx, SwfdecAsObject *obj, const char *str,
- SwfdecAsValue *val, gboolean set)
-{
- SwfdecAsValue cur;
- char **varlist;
- guint i;
-
- SWFDEC_LOG ("eval called with \"%s\" on %p", str, obj);
- if (strchr (str, '/')) {
- char *work = swfdec_as_slash_to_dot (str);
- if (!work) {
- SWFDEC_AS_VALUE_SET_UNDEFINED (val);
- return;
- }
- varlist = g_strsplit (work, ".", -1);
- g_free (work);
- } else {
- varlist = g_strsplit (str, ".", -1);
- }
- for (i = 0; varlist[i] != NULL; i++) {
- const char *dot = swfdec_as_context_get_string (cx, varlist[i]);
- if (varlist[i+1] != NULL) {
- swfdec_as_context_eval_get_property (cx, obj, dot, &cur);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&cur)) {
- SWFDEC_AS_VALUE_SET_UNDEFINED (&cur);
- break;
- }
- obj = SWFDEC_AS_VALUE_GET_OBJECT (&cur);
- } else {
- if (set) {
- swfdec_as_context_eval_set_property (cx, obj, dot, val);
- } else {
- swfdec_as_context_eval_get_property (cx, obj, dot, &cur);
- }
- goto finish;
- }
- }
- if (obj == NULL) {
- if (cx->frame)
- obj = cx->frame->target;
- else
- obj = cx->global;
- }
- g_assert (obj != NULL);
- SWFDEC_AS_VALUE_SET_OBJECT (&cur, obj);
-
-finish:
- g_strfreev (varlist);
- *val = cur;
-}
-
-/**
- * swfdec_as_context_eval:
- * @context: a #SwfdecAsContext
- * @obj: #SwfdecAsObject to use as source for evaluating or NULL for the
- * current frame's scope
- * @str: The string to evaluate
- * @val: location for the return value
- *
- * This function works like the Actionscript eval function used on @obj.
- * It handles both slash-style and dot-style notation. If an error occured
- * during evaluation, the return value will be the undefined value.
- **/
-void
-swfdec_as_context_eval (SwfdecAsContext *context, SwfdecAsObject *obj, const char *str,
- SwfdecAsValue *val)
-{
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
- g_return_if_fail (obj == NULL || SWFDEC_IS_AS_OBJECT (obj));
- g_return_if_fail (str != NULL);
- g_return_if_fail (val != NULL);
-
- swfdec_as_context_eval_internal (context, obj, str, val, FALSE);
-}
-
-/**
- * swfdec_as_context_eval_set:
- * @context: a #SwfdecAsContext
- * @obj: #SwfdecAsObject to use as source for evaluating or NULL for the
- * default object.
- * @str: The string to evaluate
- * @val: the value to set the variable to
- *
- * Sets the variable referenced by @str to @val. If @str does not reference
- * a valid property, nothing happens.
- **/
-void
-swfdec_as_context_eval_set (SwfdecAsContext *context, SwfdecAsObject *obj, const char *str,
- const SwfdecAsValue *val)
-{
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
- g_return_if_fail (obj == NULL || SWFDEC_IS_AS_OBJECT (obj));
- g_return_if_fail (str != NULL);
- g_return_if_fail (val != NULL);
-
- swfdec_as_context_eval_internal (context, obj, str, (SwfdecAsValue *) val, TRUE);
-}
-
-/*** AS CODE ***/
-
-static void
-swfdec_as_context_ASSetPropFlags_set_one_flag (SwfdecAsObject *object,
- const char *s, guint *flags)
-{
- swfdec_as_object_unset_variable_flags (object, s, flags[1]);
- swfdec_as_object_set_variable_flags (object, s, flags[0]);
-}
-
-static gboolean
-swfdec_as_context_ASSetPropFlags_foreach (SwfdecAsObject *object,
- const char *s, SwfdecAsValue *val, guint cur_flags, gpointer data)
-{
- guint *flags = data;
-
- /* shortcut if the flags already match */
- if (cur_flags == ((cur_flags &~ flags[1]) | flags[0]))
- return TRUE;
-
- swfdec_as_context_ASSetPropFlags_set_one_flag (object, s, flags);
- return TRUE;
-}
-
-SWFDEC_AS_NATIVE (1, 0, swfdec_as_context_ASSetPropFlags)
-void
-swfdec_as_context_ASSetPropFlags (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- guint flags[2]; /* flags and mask - array so we can pass it as data pointer */
- SwfdecAsObject *obj;
-
- if (argc < 3)
- return;
-
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]))
- return;
- obj = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
- flags[0] = swfdec_as_value_to_integer (cx, &argv[2]);
- flags[1] = (argc > 3) ? swfdec_as_value_to_integer (cx, &argv[3]) : 0;
-
- if (flags[0] == 0 && flags[1] == 0) {
- // we should add autosizing length attribute here
- SWFDEC_FIXME ("ASSetPropFlags to set special length attribute not implemented");
- return;
- }
-
- if (SWFDEC_AS_VALUE_IS_NULL (&argv[1])) {
- swfdec_as_object_foreach (obj, swfdec_as_context_ASSetPropFlags_foreach, flags);
- } else {
- char **split =
- g_strsplit (swfdec_as_value_to_string (cx, &argv[1]), ",", -1);
- guint i;
- for (i = 0; split[i]; i++) {
- swfdec_as_context_ASSetPropFlags_set_one_flag (obj,
- swfdec_as_context_get_string (cx, split[i]), flags);
- }
- g_strfreev (split);
- }
-}
-
-SWFDEC_AS_NATIVE (200, 19, swfdec_as_context_isFinite)
-void
-swfdec_as_context_isFinite (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- double d;
-
- if (argc < 1)
- return;
-
- d = swfdec_as_value_to_number (cx, &argv[0]);
- SWFDEC_AS_VALUE_SET_BOOLEAN (retval, isfinite (d) ? TRUE : FALSE);
-}
-
-SWFDEC_AS_NATIVE (200, 18, swfdec_as_context_isNaN)
-void
-swfdec_as_context_isNaN (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- double d;
-
- if (argc < 1)
- return;
-
- d = swfdec_as_value_to_number (cx, &argv[0]);
- SWFDEC_AS_VALUE_SET_BOOLEAN (retval, isnan (d) ? TRUE : FALSE);
-}
-
-SWFDEC_AS_NATIVE (100, 2, swfdec_as_context_parseInt)
-void
-swfdec_as_context_parseInt (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- const char *s;
- char *tail;
- int radix;
- gint64 i;
-
- if (argc < 1)
- return;
-
- s = swfdec_as_value_to_string (cx, &argv[0]);
-
- if (argc >= 2) {
- radix = swfdec_as_value_to_integer (cx, &argv[1]);
-
- if (radix < 2 || radix > 36) {
- SWFDEC_AS_VALUE_SET_NUMBER (retval, NAN);
- return;
- }
-
- // special case, strtol parses things that we shouldn't parse
- if (radix == 16) {
- const char *end = s + strspn (s, " \t\r\n");
- if (end != s && (end[0] == '-' || end[0] == '+'))
- end++;
- if (end != s && end[0] == '0' && (end[1] == 'x' || end[1] == 'X')) {
- SWFDEC_AS_VALUE_SET_NUMBER (retval, 0);
- return;
- }
- }
- } else {
- radix = 0;
- }
-
- // special case, don't allow sign in front of the 0x
- if ((s[0] == '-' || s[0] == '+') && s[1] == '0' &&
- (s[2] == 'x' || s[2] == 'X')) {
- SWFDEC_AS_VALUE_SET_NUMBER (retval, NAN);
- return;
- }
-
- if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) {
- s = s + 2;
- i = g_ascii_strtoll (s, &tail, (radix != 0 ? radix : 16));
- } else if (s[0] == '0' && s[strspn (s, "01234567")] == '\0') {
- i = g_ascii_strtoll (s, &tail, (radix != 0 ? radix : 8));
- } else {
- i = g_ascii_strtoll (s, &tail, (radix != 0 ? radix : 10));
- }
-
- if (tail == s) {
- SWFDEC_AS_VALUE_SET_NUMBER (retval, NAN);
- return;
- }
-
- if (i > G_MAXINT32 || i < G_MININT32) {
- SWFDEC_AS_VALUE_SET_NUMBER (retval, i);
- } else {
- SWFDEC_AS_VALUE_SET_INT (retval, i);
- }
-}
-
-SWFDEC_AS_NATIVE (100, 3, swfdec_as_context_parseFloat)
-void
-swfdec_as_context_parseFloat (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- char *s, *p, *tail;
- double d;
-
- if (argc < 1)
- return;
-
- // we need to remove everything after x or I, since strtod parses hexadecimal
- // numbers and Infinity
- s = g_strdup (swfdec_as_value_to_string (cx, &argv[0]));
- if ((p = strpbrk (s, "xXiI")) != NULL) {
- *p = '\0';
- }
-
- d = g_ascii_strtod (s, &tail);
-
- if (tail == s) {
- SWFDEC_AS_VALUE_SET_NUMBER (retval, NAN);
- } else {
- SWFDEC_AS_VALUE_SET_NUMBER (retval, d);
- }
-
- g_free (s);
-}
-
-static void
-swfdec_as_context_init_global (SwfdecAsContext *context)
-{
- SwfdecAsValue val;
-
- SWFDEC_AS_VALUE_SET_NUMBER (&val, NAN);
- swfdec_as_object_set_variable (context->global, SWFDEC_AS_STR_NaN, &val);
- SWFDEC_AS_VALUE_SET_NUMBER (&val, HUGE_VAL);
- swfdec_as_object_set_variable (context->global, SWFDEC_AS_STR_Infinity, &val);
-}
-
-void
-swfdec_as_context_run_init_script (SwfdecAsContext *context, const guint8 *data,
- gsize length, guint version)
-{
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
- g_return_if_fail (data != NULL);
- g_return_if_fail (length > 0);
-
- if (version > 4) {
- SwfdecBits bits;
- SwfdecScript *script;
- swfdec_bits_init_data (&bits, data, length);
- script = swfdec_script_new_from_bits (&bits, "init", version);
- if (script == NULL) {
- g_warning ("script passed to swfdec_as_context_run_init_script is invalid");
- return;
- }
- swfdec_as_object_run (context->global, script);
- swfdec_script_unref (script);
- } else {
- SWFDEC_LOG ("not running init script, since version is <= 4");
- }
-}
-
-/**
- * swfdec_as_context_startup:
- * @context: a #SwfdecAsContext
- * @version: Flash version to use
- *
- * Starts up the context. This function must be called before any Actionscript
- * is called on @context. The version is responsible for deciding which native
- * functions and properties are available in the context.
- **/
-void
-swfdec_as_context_startup (SwfdecAsContext *context)
-{
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
- g_return_if_fail (context->state == SWFDEC_AS_CONTEXT_NEW);
-
- if (context->cur == NULL &&
- !swfdec_as_stack_push_segment (context))
- return;
- if (context->global == NULL)
- context->global = swfdec_as_object_new_empty (context);
- /* init the two internal functions */
- /* FIXME: remove them for normal contexts? */
- swfdec_player_preinit_global (context);
- /* get the necessary objects up to define objects and functions sanely */
- swfdec_as_function_init_context (context);
- swfdec_as_object_init_context (context);
- /* define the global object and other important ones */
- swfdec_as_context_init_global (context);
-
- /* run init script */
- swfdec_as_context_run_init_script (context, swfdec_as_initialize, sizeof (swfdec_as_initialize), 8);
-
- if (context->state == SWFDEC_AS_CONTEXT_NEW)
- context->state = SWFDEC_AS_CONTEXT_RUNNING;
-}
-
-/**
- * swfdec_as_context_check_continue:
- * @context: the context that might be running too long
- *
- * Checks if the context has been running too long. If it has, it gets aborted.
- *
- * Returns: %TRUE if this player aborted.
- **/
-gboolean
-swfdec_as_context_check_continue (SwfdecAsContext *context)
-{
- SwfdecAsContextClass *klass;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), TRUE);
-
- klass = SWFDEC_AS_CONTEXT_GET_CLASS (context);
- if (klass->check_continue == NULL)
- return TRUE;
- if (!klass->check_continue (context)) {
- swfdec_as_context_abort (context, "Runtime exceeded");
- return FALSE;
- }
- return TRUE;
-}
-
-/**
- * swfdec_as_context_is_aborted:
- * @context: a #SwfdecAsContext
- *
- * Determines if the given context is aborted. An aborted context is not able
- * to execute any scripts. Aborting can happen if the script engine detects bad
- * scripts that cause excessive memory usage, infinite loops or other problems.
- * In that case the script engine aborts for safety reasons.
- *
- * Returns: %TRUE if the player is aborted, %FALSE if it runs normally.
- **/
-gboolean
-swfdec_as_context_is_aborted (SwfdecAsContext *context)
-{
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), TRUE);
-
- return context->state == SWFDEC_AS_CONTEXT_ABORTED;
-}
-
diff --git a/libswfdec/swfdec_as_context.h b/libswfdec/swfdec_as_context.h
deleted file mode 100644
index d5ef066..0000000
--- a/libswfdec/swfdec_as_context.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AS_CONTEXT_H_
-#define _SWFDEC_AS_CONTEXT_H_
-
-#include <glib-object.h>
-#include <libswfdec/swfdec_as_types.h>
-
-G_BEGIN_DECLS
-
-typedef enum {
- SWFDEC_AS_CONTEXT_NEW,
- SWFDEC_AS_CONTEXT_RUNNING,
- SWFDEC_AS_CONTEXT_INTERRUPTED,
- SWFDEC_AS_CONTEXT_ABORTED
-} SwfdecAsContextState;
-
-typedef struct _SwfdecAsContextClass SwfdecAsContextClass;
-
-#define SWFDEC_TYPE_AS_CONTEXT (swfdec_as_context_get_type())
-#define SWFDEC_IS_AS_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_CONTEXT))
-#define SWFDEC_IS_AS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_CONTEXT))
-#define SWFDEC_AS_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_CONTEXT, SwfdecAsContext))
-#define SWFDEC_AS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_CONTEXT, SwfdecAsContextClass))
-#define SWFDEC_AS_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_CONTEXT, SwfdecAsContextClass))
-
-struct _SwfdecAsContext {
- GObject object;
-
- SwfdecAsContextState state; /* our current state */
- SwfdecAsObject * global; /* the global object or NULL if not initialized yet.
- In SwfdecPlayer is NULL unless a sandbox is in use */
- GRand * rand; /* random number generator */
- GTimeVal start_time; /* time this movie started (for GetTime action) */
-
- /* GC properties */
- gsize memory_until_gc;/* amount of memory allocations that trigger a GC */
-
- /* bookkeeping for GC */
- gsize memory; /* total memory currently in use */
- gsize memory_since_gc;/* memory allocated since last GC run */
- GHashTable * strings; /* string=>memory mapping the context manages */
- GHashTable * objects; /* all objects the context manages */
-
- /* execution state */
- unsigned int version; /* currently active version */
- unsigned int call_depth; /* current depth of call stack (equals length of frame list) */
- SwfdecAsFrame * frame; /* topmost stack frame */
- SwfdecAsFrame * last_frame; /* last frame before calling context_run */
- gboolean exception; /* whether we are throwing an exception */
- SwfdecAsValue exception_value; /* value of the exception being thrown, can be anything including undefined */
-
- /* stack */
- SwfdecAsValue * base; /* stack base */
- SwfdecAsValue * end; /* end of stack */
- SwfdecAsValue * cur; /* pointer to current top of stack */
- SwfdecAsStack * stack; /* current stack */
-
- /* magic objects - initialized during swfdec_as_context_startup() */
- SwfdecAsObject * Function; /* Function */
- SwfdecAsObject * Function_prototype; /* Function.prototype */
- SwfdecAsObject * Object; /* Object */
- SwfdecAsObject * Object_prototype; /* Object.prototype */
-
- /* debugging */
- SwfdecAsDebugger * debugger; /* debugger (or NULL if none) */
-};
-
-struct _SwfdecAsContextClass {
- GObjectClass object_class;
-
- /* mark all objects that should not be collected */
- void (* mark) (SwfdecAsContext * context);
- /* overwrite if you want to report a different time than gettimeofday */
- void (* get_time) (SwfdecAsContext * context,
- GTimeVal * tv);
- /* overwrite if you want to abort on infinite loops */
- gboolean (* check_continue) (SwfdecAsContext * context);
-};
-
-GType swfdec_as_context_get_type (void);
-
-void swfdec_as_context_startup (SwfdecAsContext * context);
-
-gboolean swfdec_as_context_is_aborted (SwfdecAsContext * context);
-gboolean swfdec_as_context_is_constructing
- (SwfdecAsContext * context);
-SwfdecAsFrame * swfdec_as_context_get_frame (SwfdecAsContext * context);
-void swfdec_as_context_get_time (SwfdecAsContext * context,
- GTimeVal * tv);
-const char * swfdec_as_context_get_string (SwfdecAsContext * context,
- const char * string);
-const char * swfdec_as_context_give_string (SwfdecAsContext * context,
- char * string);
-
-void swfdec_as_context_abort (SwfdecAsContext * context,
- const char * reason);
-
-void swfdec_as_context_throw (SwfdecAsContext * context,
- const SwfdecAsValue * value);
-gboolean swfdec_as_context_catch (SwfdecAsContext * context,
- SwfdecAsValue * value);
-
-gboolean swfdec_as_context_use_mem (SwfdecAsContext * context,
- gsize bytes);
-void swfdec_as_context_unuse_mem (SwfdecAsContext * context,
- gsize bytes);
-void swfdec_as_object_mark (SwfdecAsObject * object);
-void swfdec_as_value_mark (SwfdecAsValue * value);
-void swfdec_as_string_mark (const char * string);
-void swfdec_as_context_gc (SwfdecAsContext * context);
-void swfdec_as_context_maybe_gc (SwfdecAsContext * context);
-
-void swfdec_as_context_run (SwfdecAsContext * context);
-
-void swfdec_as_context_eval (SwfdecAsContext * context,
- SwfdecAsObject * obj,
- const char * str,
- SwfdecAsValue * val);
-void swfdec_as_context_eval_set (SwfdecAsContext * context,
- SwfdecAsObject * obj,
- const char * str,
- const SwfdecAsValue * val);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_as_date.c b/libswfdec/swfdec_as_date.c
deleted file mode 100644
index 890d274..0000000
--- a/libswfdec/swfdec_as_date.c
+++ /dev/null
@@ -1,1162 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include "swfdec_as_date.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_frame_internal.h"
-#include "swfdec_as_function.h"
-#include "swfdec_as_object.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_native_function.h"
-#include "swfdec_system.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_debug.h"
-
-G_DEFINE_TYPE (SwfdecAsDate, swfdec_as_date, SWFDEC_TYPE_AS_OBJECT)
-
-/*
- * Class functions
- */
-
-static void
-swfdec_as_date_class_init (SwfdecAsDateClass *klass)
-{
-}
-
-static void
-swfdec_as_date_init (SwfdecAsDate *date)
-{
-}
-
-/*** Helper functions ***/
-
-/* Kind of replacement for gmtime_r, timegm that works the way Flash works */
-
-#define MILLISECONDS_PER_SECOND 1000
-#define SECONDS_PER_MINUTE 60
-#define MINUTES_PER_HOUR 60
-#define HOURS_PER_DAY 24
-#define MONTHS_PER_YEAR 12
-
-#define MILLISECONDS_PER_MINUTE 60000
-#define MILLISECONDS_PER_HOUR 3600000
-#define MILLISECONDS_PER_DAY 86400000
-
-static const int month_offsets[2][13] = {
- // Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Total
- { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
- { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
-};
-
-typedef struct {
- int milliseconds;
- int seconds;
- int minutes;
- int hours;
- int day_of_month;
- int month;
- int year;
-
- int day_of_week;
-} BrokenTime;
-
-static int
-swfdec_as_date_days_in_year (int year)
-{
- if (year % 4) {
- return 365;
- } else if (year % 100) {
- return 366;
- } else if (year % 400) {
- return 365;
- } else {
- return 366;
- }
-}
-
-#define IS_LEAP(year) (swfdec_as_date_days_in_year ((year)) == 366)
-
-static double
-swfdec_as_date_days_since_utc_for_year (int year)
-{
- double year_big = year;
-
- return (
- 365 * (year_big - 1970) +
- floor (((year_big - 1969) / 4.0f)) -
- floor (((year_big - 1901) / 100.0f)) +
- floor (((year_big - 1601) / 400.0f))
- );
-}
-
-static int
-swfdec_as_date_days_from_utc_to_year (double days)
-{
- int low, high, pivot;
-
- low = floor ((days >= 0 ? days / 366.0 : days / 365.0)) + 1970;
- high = ceil ((days >= 0 ? days / 365.0 : days / 366.0)) + 1970;
-
- while (low < high) {
- pivot = ((double)low + (double)high) / 2.0;
-
- if (swfdec_as_date_days_since_utc_for_year (pivot) <= days) {
- if (swfdec_as_date_days_since_utc_for_year (pivot + 1) > days) {
- high = low = pivot;
- } else {
- low = pivot + 1;
- }
- } else {
- high = pivot - 1;
- }
- }
-
- return low;
-}
-
-static void
-swfdec_as_date_milliseconds_to_brokentime (double milliseconds,
- BrokenTime *brokentime)
-{
- double remaining;
- int year;
-
- g_assert (brokentime != NULL);
-
- /* special case: hours are calculated from different value */
- if (isfinite (milliseconds)) {
- remaining = floor (milliseconds + 0.5);
- } else {
- remaining = 0;
- }
-
- remaining = floor (remaining / MILLISECONDS_PER_HOUR);
- brokentime->hours = fmod (remaining, HOURS_PER_DAY);
-
- /* hours done, on with the rest */
- if (isfinite (milliseconds)) {
- remaining = milliseconds;
- } else {
- remaining = 0;
- }
-
- brokentime->milliseconds = fmod (remaining, MILLISECONDS_PER_SECOND);
- remaining = floor (remaining / MILLISECONDS_PER_SECOND);
-
- brokentime->seconds = fmod (remaining, SECONDS_PER_MINUTE);
- remaining = floor (remaining / SECONDS_PER_MINUTE);
-
- brokentime->minutes = fmod (remaining, MINUTES_PER_HOUR);
- remaining = floor (remaining / MINUTES_PER_HOUR);
- remaining = floor (remaining / HOURS_PER_DAY);
-
- if (milliseconds < 0) {
- if (brokentime->milliseconds < 0)
- brokentime->milliseconds += MILLISECONDS_PER_SECOND;
- if (brokentime->seconds < 0)
- brokentime->seconds += SECONDS_PER_MINUTE;
- if (brokentime->minutes < 0)
- brokentime->minutes += MINUTES_PER_HOUR;
- if (brokentime->hours < 0)
- brokentime->hours += HOURS_PER_DAY;
- }
-
- // now remaining == days since 1970
-
- if (isfinite (milliseconds)) {
- brokentime->day_of_week = fmod ((remaining + 4), 7);
- if (brokentime->day_of_week < 0)
- brokentime->day_of_week += 7;
- } else {
- // special case
- brokentime->day_of_week = 0;
- }
-
- year = swfdec_as_date_days_from_utc_to_year (remaining);
- brokentime->year = year - 1900;
-
- remaining -= swfdec_as_date_days_since_utc_for_year (year);
- g_assert (remaining >= 0 && remaining <= 365);
-
- brokentime->month = 0;
- while (month_offsets[IS_LEAP (year)][brokentime->month + 1] <= remaining)
- brokentime->month++;
-
- brokentime->day_of_month =
- remaining - month_offsets[IS_LEAP (year)][brokentime->month] + 1;
-}
-
-static double
-swfdec_as_date_brokentime_to_milliseconds (const BrokenTime *brokentime)
-{
- double milliseconds;
- int month, year;
-
- year = 1900 + brokentime->year;
-
- milliseconds = brokentime->milliseconds;
- milliseconds += brokentime->seconds * MILLISECONDS_PER_SECOND;
- milliseconds += brokentime->minutes * MILLISECONDS_PER_MINUTE;
- milliseconds += brokentime->hours * MILLISECONDS_PER_HOUR;
- milliseconds += (double)(brokentime->day_of_month - 1) * MILLISECONDS_PER_DAY;
-
- milliseconds +=
- swfdec_as_date_days_since_utc_for_year (year) * MILLISECONDS_PER_DAY;
-
- for (month = brokentime->month; month < 0; month += MONTHS_PER_YEAR) {
- milliseconds -=
- (double)month_offsets[IS_LEAP (--year)][MONTHS_PER_YEAR] * MILLISECONDS_PER_DAY;
- }
-
- for (month = month; month >= MONTHS_PER_YEAR; month -= MONTHS_PER_YEAR) {
- milliseconds +=
- (double)month_offsets[IS_LEAP (year++)][MONTHS_PER_YEAR] * MILLISECONDS_PER_DAY;
- }
-
- milliseconds += (double)month_offsets[IS_LEAP (year)][month] * MILLISECONDS_PER_DAY;
-
- return milliseconds;
-}
-
-/* Wrappers for swfdec_as_value_to_number because we need both double and int
- * often, and need to generate the right valueOf etc. */
-
-// returns TRUE if d is not Infinite or NAN
-static gboolean
-swfdec_as_date_value_to_number_and_integer_floor (SwfdecAsContext *context,
- const SwfdecAsValue *value, double *d, int *num)
-{
- *d = swfdec_as_value_to_number (context, value);
- if (!isfinite (*d)) {
- *num = 0;
- return FALSE;
- }
-
- *num = floor (*d);
- return TRUE;
-}
-
-// returns TRUE if d is not Infinite or NAN
-static gboolean
-swfdec_as_date_value_to_number_and_integer (SwfdecAsContext *context,
- const SwfdecAsValue *value, double *d, int *num)
-{
- g_assert (d != NULL);
- g_assert (num != NULL);
-
- // undefined == NAN here, even in version < 7
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (value)) {
- *d = NAN;
- } else {
- *d = swfdec_as_value_to_number (context, value);
- }
- if (!isfinite (*d)) {
- *num = 0;
- return FALSE;
- }
-
- if (*d < 0) {
- *num = - (guint) fmod (-*d, 4294967296);
- } else {
- *num = (guint) fmod (*d, 4294967296);
- }
- return TRUE;
-}
-
-/* The functions to query/modify the current time */
-
-// returns TRUE with Infinite and -Infinite, because those values should be
-// handles like 0 that is returned by below functions
-static gboolean
-swfdec_as_date_is_valid (const SwfdecAsDate *date)
-{
- return !isnan (date->milliseconds);
-}
-
-static void
-swfdec_as_date_set_invalid (SwfdecAsDate *date)
-{
- date->milliseconds = NAN;
-}
-
-static double
-swfdec_as_date_get_milliseconds_utc (const SwfdecAsDate *date)
-{
- g_assert (swfdec_as_date_is_valid (date));
-
- if (isfinite (date->milliseconds)) {
- return date->milliseconds;
- } else {
- return 0;
- }
-}
-
-static void
-swfdec_as_date_set_milliseconds_utc (SwfdecAsDate *date, double milliseconds)
-{
- date->milliseconds = milliseconds;
-}
-
-/*static double
-swfdec_as_date_get_milliseconds_local (const SwfdecAsDate *date)
-{
- g_assert (swfdec_as_date_is_valid (date));
-
- if (isfinite (date->milliseconds)) {
- return date->milliseconds + (double) date->utc_offset * 60 * 1000;
- } else {
- return 0;
- }
-}*/
-
-static void
-swfdec_as_date_set_milliseconds_local (SwfdecAsDate *date, double milliseconds)
-{
- date->milliseconds =
- milliseconds - (double) date->utc_offset * 60 * 1000;
-}
-
-static void
-swfdec_as_date_get_brokentime_utc (const SwfdecAsDate *date,
- BrokenTime *brokentime)
-{
- g_assert (swfdec_as_date_is_valid (date));
-
- swfdec_as_date_milliseconds_to_brokentime (date->milliseconds, brokentime);
-}
-
-static void
-swfdec_as_date_set_brokentime_utc (SwfdecAsDate *date, BrokenTime *brokentime)
-{
- date->milliseconds = swfdec_as_date_brokentime_to_milliseconds (brokentime);
-}
-
-static void
-swfdec_as_date_get_brokentime_local (const SwfdecAsDate *date,
- BrokenTime *brokentime)
-{
- g_assert (swfdec_as_date_is_valid (date));
-
- swfdec_as_date_milliseconds_to_brokentime (
- date->milliseconds + date->utc_offset * 60 * 1000, brokentime);
-}
-
-static void
-swfdec_as_date_set_brokentime_local (SwfdecAsDate *date, BrokenTime *brokentime)
-{
- date->milliseconds = swfdec_as_date_brokentime_to_milliseconds (brokentime) -
- date->utc_offset * 60 * 1000;
-}
-
-/* set and get function helpers */
-
-typedef enum {
- FIELD_MILLISECONDS,
- FIELD_SECONDS,
- FIELD_MINUTES,
- FIELD_HOURS,
- FIELD_WEEK_DAYS,
- FIELD_MONTH_DAYS,
- FIELD_MONTHS,
- FIELD_YEAR,
- FIELD_FULL_YEAR
-} field_t;
-
-static int field_offsets[] = {
- G_STRUCT_OFFSET (BrokenTime, milliseconds),
- G_STRUCT_OFFSET (BrokenTime, seconds),
- G_STRUCT_OFFSET (BrokenTime, minutes),
- G_STRUCT_OFFSET (BrokenTime, hours),
- G_STRUCT_OFFSET (BrokenTime, day_of_week),
- G_STRUCT_OFFSET (BrokenTime, day_of_month),
- G_STRUCT_OFFSET (BrokenTime, month),
- G_STRUCT_OFFSET (BrokenTime, year),
- G_STRUCT_OFFSET (BrokenTime, year)
-};
-
-static int
-swfdec_as_date_get_brokentime_value (SwfdecAsDate *date, gboolean utc,
- int field_offset)
-{
- BrokenTime brokentime;
-
- if (utc) {
- swfdec_as_date_get_brokentime_utc (date, &brokentime);
- } else {
- swfdec_as_date_get_brokentime_local (date, &brokentime);
- }
-
- return G_STRUCT_MEMBER (int, &brokentime, field_offset);
-}
-
-static void
-swfdec_as_date_set_brokentime_value (SwfdecAsDate *date, gboolean utc,
- int field_offset, SwfdecAsContext *cx, int number)
-{
- BrokenTime brokentime;
-
- if (utc) {
- swfdec_as_date_get_brokentime_utc (date, &brokentime);
- } else {
- swfdec_as_date_get_brokentime_local (date, &brokentime);
- }
-
- G_STRUCT_MEMBER (int, &brokentime, field_offset) = number;
-
- if (utc) {
- swfdec_as_date_set_brokentime_utc (date, &brokentime);
- } else {
- swfdec_as_date_set_brokentime_local (date, &brokentime);
- }
-}
-
-static void
-swfdec_as_date_set_field (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret, field_t field,
- gboolean utc)
-{
- SwfdecAsDate *date;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_DATE, &date, "");
-
- if (!swfdec_as_date_is_valid (date))
- swfdec_as_value_to_number (cx, &argv[0]); // calls valueOf
-
- if (swfdec_as_date_is_valid (date) && argc > 0)
- {
- gboolean set;
- double milliseconds;
- double d;
- int number;
-
- set = TRUE;
- swfdec_as_date_value_to_number_and_integer (cx, &argv[0], &d, &number);
-
- switch (field) {
- case FIELD_MONTHS:
- if (!isfinite (d)) {
- if (!isnan (d)) {
- swfdec_as_date_set_brokentime_value (date, utc,
- field_offsets[FIELD_YEAR], cx, 0 - 1900);
- }
- swfdec_as_date_set_brokentime_value (date, utc, field_offsets[field],
- cx, 0);
- set = FALSE;
- }
- break;
- case FIELD_YEAR:
- // NOTE: Test against double, not the integer
- if (d >= 100 || d < 0)
- number -= 1900;
- // fall trough
- case FIELD_FULL_YEAR:
- if (!isfinite (d)) {
- swfdec_as_date_set_brokentime_value (date, utc, field_offsets[field],
- cx, 0 - 1900);
- set = FALSE;
- }
- break;
- case FIELD_MILLISECONDS:
- case FIELD_SECONDS:
- case FIELD_MINUTES:
- case FIELD_HOURS:
- case FIELD_WEEK_DAYS:
- case FIELD_MONTH_DAYS:
- if (!isfinite (d)) {
- swfdec_as_date_set_invalid (date);
- set = FALSE;
- }
- break;
- default:
- g_assert_not_reached ();
- }
-
- if (set) {
- swfdec_as_date_set_brokentime_value (date, utc, field_offsets[field], cx,
- number);
- }
-
- if (swfdec_as_date_is_valid (date)) {
- milliseconds = swfdec_as_date_get_milliseconds_utc (date);
- if (milliseconds < -8.64e15 || milliseconds > 8.64e15)
- swfdec_as_date_set_invalid (date);
- }
- }
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret, date->milliseconds);
-}
-
-static void
-swfdec_as_date_get_field (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret, field_t field,
- gboolean utc)
-{
- SwfdecAsDate *date;
- int number;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_DATE, &date, "");
-
- if (!swfdec_as_date_is_valid (date)) {
- SWFDEC_AS_VALUE_SET_NUMBER (ret, NAN);
- return;
- }
-
- number = swfdec_as_date_get_brokentime_value (date, utc,
- field_offsets[field]);
-
- if (field == FIELD_FULL_YEAR)
- number += 1900;
-
- SWFDEC_AS_VALUE_SET_INT (ret, number);
-}
-
-/*** AS CODE ***/
-
-SWFDEC_AS_NATIVE (103, 19, swfdec_as_date_toString)
-void
-swfdec_as_date_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- static const char *weekday_names[] =
- { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
- static const char *month_names[] =
- { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
- SwfdecAsDate *date;
- BrokenTime brokentime;
- char *result;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_DATE, &date, "");
-
- if (!swfdec_as_date_is_valid (date)) {
- SWFDEC_AS_VALUE_SET_STRING (ret, "Invalid Date");
- return;
- }
-
- swfdec_as_date_get_brokentime_local (date, &brokentime);
-
- result = g_strdup_printf ("%s %s %i %02i:%02i:%02i GMT%+03i%02i %i",
- weekday_names[brokentime.day_of_week % 7],
- month_names[brokentime.month % 12],
- brokentime.day_of_month,
- brokentime.hours, brokentime.minutes, brokentime.seconds,
- date->utc_offset / 60, ABS (date->utc_offset % 60),
- 1900 + brokentime.year);
-
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, result));
-}
-
-SWFDEC_AS_NATIVE (103, 16, swfdec_as_date_getTime)
-void
-swfdec_as_date_getTime (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecAsDate *date;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_DATE, &date, "");
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret, date->milliseconds);
-}
-
-SWFDEC_AS_NATIVE (103, 18, swfdec_as_date_getTimezoneOffset)
-void
-swfdec_as_date_getTimezoneOffset (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecAsDate *date;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_DATE, &date, "");
-
- // reverse of utc_offset
- SWFDEC_AS_VALUE_SET_NUMBER (ret, -(date->utc_offset));
-}
-
-// get* functions
-
-SWFDEC_AS_NATIVE (103, 8, swfdec_as_date_getMilliseconds)
-void
-swfdec_as_date_getMilliseconds (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_MILLISECONDS,
- FALSE);
-}
-
-SWFDEC_AS_NATIVE (103, 128 + 8, swfdec_as_date_getUTCMilliseconds)
-void
-swfdec_as_date_getUTCMilliseconds (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_MILLISECONDS,
- TRUE);
-}
-
-SWFDEC_AS_NATIVE (103, 7, swfdec_as_date_getSeconds)
-void
-swfdec_as_date_getSeconds (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_SECONDS, FALSE);
-}
-
-SWFDEC_AS_NATIVE (103, 128 + 7, swfdec_as_date_getUTCSeconds)
-void
-swfdec_as_date_getUTCSeconds (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_SECONDS, TRUE);
-}
-
-SWFDEC_AS_NATIVE (103, 6, swfdec_as_date_getMinutes)
-void
-swfdec_as_date_getMinutes (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_MINUTES, FALSE);
-}
-
-SWFDEC_AS_NATIVE (103, 128 + 6, swfdec_as_date_getUTCMinutes)
-void
-swfdec_as_date_getUTCMinutes (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_MINUTES, TRUE);
-}
-
-SWFDEC_AS_NATIVE (103, 5, swfdec_as_date_getHours)
-void
-swfdec_as_date_getHours (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_HOURS, FALSE);
-}
-
-SWFDEC_AS_NATIVE (103, 128 + 5, swfdec_as_date_getUTCHours)
-void
-swfdec_as_date_getUTCHours (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_HOURS, TRUE);
-}
-
-SWFDEC_AS_NATIVE (103, 4, swfdec_as_date_getDay)
-void
-swfdec_as_date_getDay (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_WEEK_DAYS,
- FALSE);
-}
-
-SWFDEC_AS_NATIVE (103, 128 + 4, swfdec_as_date_getUTCDay)
-void
-swfdec_as_date_getUTCDay (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_WEEK_DAYS,
- TRUE);
-}
-
-SWFDEC_AS_NATIVE (103, 3, swfdec_as_date_getDate)
-void
-swfdec_as_date_getDate (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_MONTH_DAYS,
- FALSE);
-}
-
-SWFDEC_AS_NATIVE (103, 128 + 3, swfdec_as_date_getUTCDate)
-void
-swfdec_as_date_getUTCDate (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_MONTH_DAYS,
- TRUE);
-}
-
-SWFDEC_AS_NATIVE (103, 2, swfdec_as_date_getMonth)
-void
-swfdec_as_date_getMonth (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_MONTHS, FALSE);
-}
-
-SWFDEC_AS_NATIVE (103, 128 + 2, swfdec_as_date_getUTCMonth)
-void
-swfdec_as_date_getUTCMonth (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_MONTHS, TRUE);
-}
-
-SWFDEC_AS_NATIVE (103, 1, swfdec_as_date_getYear)
-void
-swfdec_as_date_getYear (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_YEAR, FALSE);
-}
-
-SWFDEC_AS_NATIVE (103, 128 + 1, swfdec_as_date_getUTCYear)
-void
-swfdec_as_date_getUTCYear (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_YEAR, TRUE);
-}
-
-SWFDEC_AS_NATIVE (103, 0, swfdec_as_date_getFullYear)
-void
-swfdec_as_date_getFullYear (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_FULL_YEAR,
- FALSE);
-}
-
-SWFDEC_AS_NATIVE (103, 128 + 0, swfdec_as_date_getUTCFullYear)
-void
-swfdec_as_date_getUTCFullYear (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_FULL_YEAR,
- TRUE);
-}
-
-// set* functions
-
-SWFDEC_AS_NATIVE (103, 17, swfdec_as_date_setTime)
-void
-swfdec_as_date_setTime (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecAsDate *date;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_DATE, &date, "");
-
- if (argc > 0) {
- swfdec_as_date_set_milliseconds_utc (date,
- swfdec_as_value_to_integer (cx, &argv[0]));
- }
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret, date->milliseconds);
-}
-
-SWFDEC_AS_NATIVE (103, 15, swfdec_as_date_setMilliseconds)
-void
-swfdec_as_date_setMilliseconds (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_MILLISECONDS,
- FALSE);
-}
-
-SWFDEC_AS_NATIVE (103, 128 + 15, swfdec_as_date_setUTCMilliseconds)
-void
-swfdec_as_date_setUTCMilliseconds (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_MILLISECONDS,
- TRUE);
-}
-
-SWFDEC_AS_NATIVE (103, 14, swfdec_as_date_setSeconds)
-void
-swfdec_as_date_setSeconds (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_SECONDS, FALSE);
-}
-
-SWFDEC_AS_NATIVE (103, 128 + 14, swfdec_as_date_setUTCSeconds)
-void
-swfdec_as_date_setUTCSeconds (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_SECONDS, TRUE);
-}
-
-SWFDEC_AS_NATIVE (103, 13, swfdec_as_date_setMinutes)
-void
-swfdec_as_date_setMinutes (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_MINUTES, FALSE);
-}
-
-SWFDEC_AS_NATIVE (103, 128 + 13, swfdec_as_date_setUTCMinutes)
-void
-swfdec_as_date_setUTCMinutes (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_MINUTES, TRUE);
-}
-
-SWFDEC_AS_NATIVE (103, 12, swfdec_as_date_setHours)
-void
-swfdec_as_date_setHours (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_HOURS, FALSE);
-}
-
-SWFDEC_AS_NATIVE (103, 128 + 12, swfdec_as_date_setUTCHours)
-void
-swfdec_as_date_setUTCHours (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_HOURS, TRUE);
-}
-
-SWFDEC_AS_NATIVE (103, 11, swfdec_as_date_setDate)
-void
-swfdec_as_date_setDate (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_MONTH_DAYS,
- FALSE);
-}
-
-SWFDEC_AS_NATIVE (103, 128 + 11, swfdec_as_date_setUTCDate)
-void
-swfdec_as_date_setUTCDate (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_MONTH_DAYS,
- TRUE);
-}
-
-SWFDEC_AS_NATIVE (103, 10, swfdec_as_date_setMonth)
-void
-swfdec_as_date_setMonth (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_MONTHS, FALSE);
-}
-
-SWFDEC_AS_NATIVE (103, 128 + 10, swfdec_as_date_setUTCMonth)
-void
-swfdec_as_date_setUTCMonth (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_MONTHS, TRUE);
-}
-
-SWFDEC_AS_NATIVE (103, 20, swfdec_as_date_setYear)
-void
-swfdec_as_date_setYear (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_YEAR, FALSE);
-}
-
-SWFDEC_AS_NATIVE (103, 9, swfdec_as_date_setFullYear)
-void
-swfdec_as_date_setFullYear (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_FULL_YEAR,
- FALSE);
-}
-
-SWFDEC_AS_NATIVE (103, 128 + 9, swfdec_as_date_setUTCFullYear)
-void
-swfdec_as_date_setUTCFullYear (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_FULL_YEAR,
- TRUE);
-}
-
-// Static methods
-
-SWFDEC_AS_NATIVE (103, 257, swfdec_as_date_UTC)
-void
-swfdec_as_date_UTC (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- guint i;
- int year, num;
- double d;
- BrokenTime brokentime;
-
- // special case: ignore undefined and everything after it
- for (i = 0; i < argc; i++) {
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[i])) {
- argc = i;
- break;
- }
- }
-
- memset (&brokentime, 0, sizeof (brokentime));
-
- if (argc > 0) {
- if (swfdec_as_date_value_to_number_and_integer_floor (cx, &argv[0], &d,
- &num)) {
- year = num;
- } else {
- // special case: if year is not finite set it to -1900
- year = -1900;
- }
- } else {
- return;
- }
-
- // if we don't got atleast two values, return undefined
- // do it only here, so valueOf first arg is called
- if (argc < 2)
- return;
-
- if (swfdec_as_date_value_to_number_and_integer (cx, &argv[1], &d,
- &num)) {
- brokentime.month = num;
- } else {
- // special case: if month is not finite set year to -1900
- year = -1900;
- brokentime.month = 0;
- }
-
- if (argc > 2) {
- if (swfdec_as_date_value_to_number_and_integer (cx, &argv[2], &d,
- &num)) {
- brokentime.day_of_month = num;
- } else {
- SWFDEC_AS_VALUE_SET_NUMBER (ret, d);
- return;
- }
- } else {
- brokentime.day_of_month = 1;
- }
-
- if (argc > 3) {
- if (swfdec_as_date_value_to_number_and_integer (cx, &argv[3], &d,
- &num)) {
- brokentime.hours = num;
- } else {
- SWFDEC_AS_VALUE_SET_NUMBER (ret, d);
- return;
- }
- }
-
- if (argc > 4) {
- if (swfdec_as_date_value_to_number_and_integer (cx, &argv[4], &d,
- &num)) {
- brokentime.minutes = num;
- } else {
- SWFDEC_AS_VALUE_SET_NUMBER (ret, d);
- return;
- }
- }
-
- if (argc > 5) {
- if (swfdec_as_date_value_to_number_and_integer (cx, &argv[5], &d,
- &num)) {
- brokentime.seconds = num;
- } else {
- SWFDEC_AS_VALUE_SET_NUMBER (ret, d);
- return;
- }
- }
-
- if (year >= 100) {
- brokentime.year = year - 1900;
- } else {
- brokentime.year = year;
- }
-
- if (argc > 6) {
- if (swfdec_as_date_value_to_number_and_integer (cx, &argv[6], &d,
- &num)) {
- brokentime.milliseconds = num;
- } else {
- SWFDEC_AS_VALUE_SET_NUMBER (ret, d);
- return;
- }
- }
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret,
- swfdec_as_date_brokentime_to_milliseconds (&brokentime));
-}
-
-// Constructor
-
-SWFDEC_AS_CONSTRUCTOR (103, 256, swfdec_as_date_construct, swfdec_as_date_get_type)
-void
-swfdec_as_date_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- guint i;
- SwfdecAsDate *date;
-
- if (!cx->frame->construct) {
- SwfdecAsValue val;
- if (!swfdec_as_context_use_mem (cx, sizeof (SwfdecAsDate)))
- return;
- object = g_object_new (SWFDEC_TYPE_AS_DATE, NULL);
- swfdec_as_object_add (object, cx, sizeof (SwfdecAsDate));
- swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_Date, &val);
- if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
- swfdec_as_object_set_constructor (object,
- SWFDEC_AS_VALUE_GET_OBJECT (&val));
- } else {
- SWFDEC_INFO ("\"Date\" is not an object");
- }
- }
-
- date = SWFDEC_AS_DATE (object);
-
- /* FIXME: find a general solution here */
- if (SWFDEC_IS_PLAYER (SWFDEC_AS_OBJECT (date)->context)) {
- date->utc_offset =
- SWFDEC_PLAYER (SWFDEC_AS_OBJECT (date)->context)->priv->system->utc_offset;
- }
-
- // don't accept arguments when not constructing
- if (!cx->frame->construct)
- argc = 0;
-
- // special case: ignore undefined and everything after it
- for (i = 0; i < argc; i++) {
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[i])) {
- argc = i;
- break;
- }
- }
-
- if (argc == 0) // current time, local
- {
- GTimeVal tv;
-
- swfdec_as_context_get_time (cx, &tv);
- swfdec_as_date_set_milliseconds_utc (date,
- tv.tv_sec * 1000.0 + tv.tv_usec / 1000.0);
- }
- else if (argc == 1) // milliseconds from epoch, local
- {
- // need to save directly to keep fractions of a milliseconds
- date->milliseconds = swfdec_as_value_to_number (cx, &argv[0]);
- }
- else // year, month etc. local
- {
- int year, num;
- double d;
- BrokenTime brokentime;
-
- date->milliseconds = 0;
-
- memset (&brokentime, 0, sizeof (brokentime));
-
- i = 0;
-
- if (argc > i) {
- if (swfdec_as_date_value_to_number_and_integer_floor (cx, &argv[i++], &d,
- &num)) {
- year = num;
- } else {
- // special case: if year is not finite set it to -1900
- year = -1900;
- }
- } else {
- year = -1900;
- }
-
- if (argc > i) {
- if (swfdec_as_date_value_to_number_and_integer (cx, &argv[i++], &d,
- &num)) {
- brokentime.month = num;
- } else {
- // special case: if month is not finite set year to -1900
- year = -1900;
- brokentime.month = 0;
- }
- }
-
- if (argc > i) {
- if (swfdec_as_date_value_to_number_and_integer (cx, &argv[i++], &d,
- &num)) {
- brokentime.day_of_month = num;
- } else {
- date->milliseconds = d;
- }
- } else {
- brokentime.day_of_month = 1;
- }
-
- if (argc > i) {
- if (swfdec_as_date_value_to_number_and_integer (cx, &argv[i++], &d,
- &num)) {
- brokentime.hours = num;
- } else {
- date->milliseconds = d;
- }
- }
-
- if (argc > i) {
- if (swfdec_as_date_value_to_number_and_integer (cx, &argv[i++], &d,
- &num)) {
- brokentime.minutes = num;
- } else {
- date->milliseconds = d;
- }
- }
-
- if (argc > i) {
- if (swfdec_as_date_value_to_number_and_integer (cx, &argv[i++], &d,
- &num)) {
- brokentime.seconds = num;
- } else {
- date->milliseconds = d;
- }
- }
-
- if (year >= 100) {
- brokentime.year = year - 1900;
- } else {
- brokentime.year = year;
- }
-
- if (argc > i) {
- if (swfdec_as_date_value_to_number_and_integer (cx, &argv[i++], &d,
- &num)) {
- brokentime.milliseconds += num;
- } else {
- date->milliseconds = d;
- }
- }
-
- if (date->milliseconds == 0) {
- swfdec_as_date_set_milliseconds_local (date,
- swfdec_as_date_brokentime_to_milliseconds (&brokentime));
- }
- }
-
- SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
-}
diff --git a/libswfdec/swfdec_as_date.h b/libswfdec/swfdec_as_date.h
deleted file mode 100644
index b095520..0000000
--- a/libswfdec/swfdec_as_date.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AS_DATE_H_
-#define _SWFDEC_AS_DATE_H_
-
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_script.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecAsDate SwfdecAsDate;
-typedef struct _SwfdecAsDateClass SwfdecAsDateClass;
-
-#define SWFDEC_TYPE_AS_DATE (swfdec_as_date_get_type())
-#define SWFDEC_IS_AS_DATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_DATE))
-#define SWFDEC_IS_AS_DATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_DATE))
-#define SWFDEC_AS_DATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_DATE, SwfdecAsDate))
-#define SWFDEC_AS_DATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_DATE, SwfdecAsDateClass))
-#define SWFDEC_AS_DATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_DATE, SwfdecAsDateClass))
-
-struct _SwfdecAsDate {
- SwfdecAsObject object;
-
- // time from epoch in UTC
- double milliseconds;
-
- // the difference between local timezone and UTC in minutes
- int utc_offset;
-};
-
-struct _SwfdecAsDateClass {
- SwfdecAsObjectClass object_class;
-};
-
-GType swfdec_as_date_get_type (void);
-
-SwfdecAsObject *swfdec_as_date_new (SwfdecAsContext * context);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_as_debugger.c b/libswfdec/swfdec_as_debugger.c
deleted file mode 100644
index d9f34f3..0000000
--- a/libswfdec/swfdec_as_debugger.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "swfdec_as_debugger.h"
-#include "swfdec_as_context.h"
-
-G_DEFINE_TYPE (SwfdecAsDebugger, swfdec_as_debugger, G_TYPE_OBJECT)
-
-/**
- * SECTION:SwfdecAsDebugger
- * @title: SwfdecAsDebugger
- * @short_description: the debugger object
- * @see also: SwfdecAsContext
- *
- * The debugger object is a special object that can be set on a #SwfdecAsContext
- * upon creation. If that is done, the debugger can then be used to inspect the
- * running Actionscript application.
- */
-
-/**
- * SwfdecAsDebugger
- *
- * This is the type of the debugger object.
- */
-
-/**
- * SwfdecAsDebuggerClass:
- * @add: Called whenever an object is added to the garbage collection engine
- * using swfdec_as_object_add ()
- * @remove: Called whenever an object is about to be collected by the garbage
- * collector.
- * @step: This function is called everytime just before a bytecode is executed
- * by the script engine. So it's very powerful, but can also slow down
- * the script engine a lot.
- * @enter_frame: Called after a new #SwfdecAsFrame has been initialized and
- * pushed to the top of the execution stack.
- * @leave_frame: Called just after a #SwfdecAsFrame has been removed from the
- * execution stack. The return value has not been forwarded to
- * the parent when this function is called.
- * @set_variable: Called whenever swfdec_as_object_set_variable() is called,
- * before actually setting the variable. This function is also
- * called when variables are set by internal code, not just when
- * interpreting scripts. It also doesn't matter if setting the
- * variable will succeed.
- *
- * The class object for the debugger. You need to override these functions to
- * get useful functionality for the debugger.
- */
-
-static void
-swfdec_as_debugger_class_init (SwfdecAsDebuggerClass *klass)
-{
-}
-
-static void
-swfdec_as_debugger_init (SwfdecAsDebugger *debugger)
-{
-}
-
diff --git a/libswfdec/swfdec_as_debugger.h b/libswfdec/swfdec_as_debugger.h
deleted file mode 100644
index 2e2c0e7..0000000
--- a/libswfdec/swfdec_as_debugger.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AS_DEBUGGER_H_
-#define _SWFDEC_AS_DEBUGGER_H_
-
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_script.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecAsDebuggerClass SwfdecAsDebuggerClass;
-
-#define SWFDEC_TYPE_AS_DEBUGGER (swfdec_as_debugger_get_type())
-#define SWFDEC_IS_AS_DEBUGGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_DEBUGGER))
-#define SWFDEC_IS_AS_DEBUGGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_DEBUGGER))
-#define SWFDEC_AS_DEBUGGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_DEBUGGER, SwfdecAsDebugger))
-#define SWFDEC_AS_DEBUGGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_DEBUGGER, SwfdecAsDebuggerClass))
-#define SWFDEC_AS_DEBUGGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_DEBUGGER, SwfdecAsDebuggerClass))
-
-struct _SwfdecAsDebugger {
- /*< private >*/
- GObject object;
-};
-
-struct _SwfdecAsDebuggerClass {
- /*< private >*/
- GObjectClass object_class;
-
- /*< public >*/
- /* a new object was added to the GC */
- void (* add) (SwfdecAsDebugger * debugger,
- SwfdecAsContext * context,
- SwfdecAsObject * object);
- /* an object was removed from the GC */
- void (* remove) (SwfdecAsDebugger * debugger,
- SwfdecAsContext * context,
- SwfdecAsObject * object);
- /* called before executing a bytecode */
- void (* step) (SwfdecAsDebugger * debugger,
- SwfdecAsContext * context);
- /* called after adding a frame from the function stack */
- void (* enter_frame) (SwfdecAsDebugger * debugger,
- SwfdecAsContext * context,
- SwfdecAsFrame * frame);
- /* called after removing a frame from the function stack */
- void (* leave_frame) (SwfdecAsDebugger * debugger,
- SwfdecAsContext * context,
- SwfdecAsFrame * frame,
- const SwfdecAsValue * return_value);
- /* called before setting a variable */
- void (* set_variable)(SwfdecAsDebugger * debugger,
- SwfdecAsContext * context,
- SwfdecAsObject * object,
- const char * variable,
- const SwfdecAsValue * value);
-};
-
-GType swfdec_as_debugger_get_type (void);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_as_frame.c b/libswfdec/swfdec_as_frame.c
deleted file mode 100644
index 39888b6..0000000
--- a/libswfdec/swfdec_as_frame.c
+++ /dev/null
@@ -1,895 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_frame_internal.h"
-#include "swfdec_as_frame.h"
-#include "swfdec_as_array.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_stack.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_as_super.h"
-#include "swfdec_debug.h"
-
-/**
- * SECTION:SwfdecAsFrame
- * @title: SwfdecAsFrame
- * @short_description: information about currently executing frames
- *
- * This section is only interesting for people that want to look into debugging.
- * A SwfdecAsFrame describes a currently executing function while it is
- * running. On every new function call, a new frame is created and pushed on top
- * of the frame stack. To get the topmost one, use
- * swfdec_as_context_get_frame(). After that you can inspect various properties
- * of the frame, like the current stack.
- *
- * a #SwfdecAsFrame is a #SwfdecAsObject, so it is possible to set variables on
- * it. These are local variables inside the executing function. So you can use
- * functions such as swfdec_as_object_get_variable() to inspect them.
- */
-
-/**
- * SwfdecAsFrame:
- *
- * the object used to represent an executing function.
- */
-
-/*** STACK ITERATOR ***/
-
-/**
- * SwfdecAsStackIterator:
- *
- * This is a struct used to walk the stack of a frame. It is supposed to be
- * allocated on the stack. All of its members are private.
- */
-
-/**
- * swfdec_as_stack_iterator_init_arguments:
- * @iter: iterator to be initialized
- * @frame: the frame to initialize from
- *
- * Initializes a stack iterator to walk the arguments passed to the given @frame. See
- * swfdec_as_stack_iterator_init() about suggested iterator usage.
- *
- * Returns: The value of the first argument
- **/
-SwfdecAsValue *
-swfdec_as_stack_iterator_init_arguments (SwfdecAsStackIterator *iter, SwfdecAsFrame *frame)
-{
- SwfdecAsContext *context;
-
- g_return_val_if_fail (iter != NULL, NULL);
- g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
-
- if (frame->argc == 0) {
- iter->i = iter->n = 0;
- iter->stack = NULL;
- iter->current = NULL;
- return NULL;
- }
- context = SWFDEC_AS_OBJECT (frame)->context;
- if (frame->argv) {
- iter->stack = NULL;
- iter->current = (SwfdecAsValue *) frame->argv;
- } else {
- SwfdecAsStack *stack = context->stack;
- SwfdecAsValue *end;
- iter->current = frame->stack_begin - 1;
- end = context->cur;
- while (iter->current < stack->elements ||
- iter->current > end) {
- stack = stack->next;
- end = &stack->elements[stack->used_elements];
- }
- iter->stack = stack;
- }
- iter->i = 0;
- iter->n = frame->argc;
- return iter->current;
-}
-
-/**
- * swfdec_as_stack_iterator_init:
- * @iter: a #SwfdecStackIterator
- * @frame: the frame to initialize from
- *
- * Initializes @iter to walk the stack of @frame. The first value on the stack
- * will alread be returned. This makes it possible to write a simple loop to
- * print the whole stack:
- * |[for (value = swfdec_as_stack_iterator_init (&iter, frame); value != NULL;
- * value = swfdec_as_stack_iterator_next (&iter)) {
- * char *s = swfdec_as_value_to_debug (value);
- * g_print ("%s\n", s);
- * g_free (s);
- * }]|
- *
- * Returns: the topmost value on the stack of @frame or %NULL if none
- **/
-SwfdecAsValue *
-swfdec_as_stack_iterator_init (SwfdecAsStackIterator *iter, SwfdecAsFrame *frame)
-{
- SwfdecAsContext *context;
- SwfdecAsStack *stack;
-
- g_return_val_if_fail (iter != NULL, NULL);
- g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
-
- context = SWFDEC_AS_OBJECT (frame)->context;
- iter->i = 0;
- stack = context->stack;
- if (context->frame == frame) {
- iter->current = context->cur;
- } else {
- SwfdecAsFrame *follow = context->frame;
- while (follow->next != frame)
- follow = follow->next;
- iter->current = follow->stack_begin;
- /* FIXME: get rid of arguments on stack */
- while (iter->current < &stack->elements[0] || iter->current > &stack->elements[stack->n_elements]) {
- stack = stack->next;
- g_assert (stack);
- }
- }
- iter->stack = stack;
- /* figure out number of args */
- iter->n = iter->current - &stack->elements[0];
- while (frame->stack_begin < &stack->elements[0] && frame->stack_begin > &stack->elements[stack->n_elements]) {
- iter->n += stack->used_elements;
- stack = stack->next;
- };
- g_assert (iter->n >= (guint) (frame->stack_begin - &stack->elements[0]));
- iter->n -= frame->stack_begin - &stack->elements[0];
- if (iter->n == 0)
- return NULL;
- if (iter->current == &iter->stack->elements[0]) {
- iter->stack = iter->stack->next;
- g_assert (iter->stack);
- iter->current = &iter->stack->elements[iter->stack->used_elements];
- }
- iter->current--;
- return iter->current;
-}
-
-/**
- * swfdec_as_stack_iterator_next:
- * @iter: a #SwfdecAsStackIterator
- *
- * Gets the next value on the stack.
- *
- * Returns: The next value on the stack or %NULL if no more values are on the stack
- **/
-SwfdecAsValue *
-swfdec_as_stack_iterator_next (SwfdecAsStackIterator *iter)
-{
- if (iter->i < iter->n)
- iter->i++;
- if (iter->i >= iter->n)
- return NULL;
- if (iter->stack) {
- if (iter->current == &iter->stack->elements[0]) {
- iter->stack = iter->stack->next;
- g_assert (iter->stack);
- iter->current = &iter->stack->elements[iter->stack->used_elements];
- }
- iter->current--;
- } else {
- iter->current++;
- }
- return iter->current;
-}
-
-/*** BLOCK HANDLING ***/
-
-typedef struct {
- const guint8 * start; /* start of block */
- const guint8 * end; /* end of block (hitting this address will exit the block) */
- SwfdecAsFrameBlockFunc func; /* function to call when block is exited (or frame is destroyed) */
- gpointer data; /* data to pass to function */
-} SwfdecAsFrameBlock;
-
-/**
- * swfdec_as_frame_push_block:
- * @frame: a #SwfdecAsFrame
- * @start: start of block
- * @end: byte after end of block
- * @func: function to call when block gets exited
- * @data: data to pass to @func
- *
- * Registers a function that guards a block of memory. When the function
- * exits this block of memory, it will call this function. This can happen
- * either when the program counter leaves the guarded region, when the
- * function returns or when the context aborted due to an unrecoverable error.
- **/
-void
-swfdec_as_frame_push_block (SwfdecAsFrame *frame, const guint8 *start,
- const guint8 *end, SwfdecAsFrameBlockFunc func, gpointer data)
-{
- SwfdecAsFrameBlock block = { start, end, func, data };
-
- g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
- g_return_if_fail (start <= end);
- g_return_if_fail (start >= frame->block_start);
- g_return_if_fail (end <= frame->block_end);
- g_return_if_fail (func != NULL);
-
- frame->block_start = start;
- frame->block_end = end;
- g_array_append_val (frame->blocks, block);
-}
-
-void
-swfdec_as_frame_pop_block (SwfdecAsFrame *frame)
-{
- SwfdecAsFrameBlockFunc func;
- gpointer data;
- SwfdecAsFrameBlock *block;
-
- g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
- g_return_if_fail (frame->blocks->len > 0);
-
- block = &g_array_index (frame->blocks, SwfdecAsFrameBlock, frame->blocks->len - 1);
- func = block->func;
- data = block->data;
- g_array_set_size (frame->blocks, frame->blocks->len - 1);
- if (frame->blocks->len) {
- block--;
- frame->block_start = block->start;
- frame->block_end = block->end;
- } else {
- frame->block_start = frame->script->buffer->data;
- frame->block_end = frame->script->buffer->data + frame->script->buffer->length;
- }
- /* only call function after we popped the block, so the block can push a new one */
- func (frame, data);
-}
-
-/*** FRAME ***/
-
-G_DEFINE_TYPE (SwfdecAsFrame, swfdec_as_frame, SWFDEC_TYPE_AS_OBJECT)
-
-static void
-swfdec_as_frame_dispose (GObject *object)
-{
- SwfdecAsFrame *frame = SWFDEC_AS_FRAME (object);
-
- /* pop blocks while state is intact */
- while (frame->blocks->len > 0)
- swfdec_as_frame_pop_block (frame);
-
- /* clean up */
- g_slice_free1 (sizeof (SwfdecAsValue) * frame->n_registers, frame->registers);
- if (frame->constant_pool) {
- swfdec_constant_pool_free (frame->constant_pool);
- frame->constant_pool = NULL;
- }
- if (frame->constant_pool_buffer) {
- swfdec_buffer_unref (frame->constant_pool_buffer);
- frame->constant_pool_buffer = NULL;
- }
- g_array_free (frame->blocks, TRUE);
- g_slist_free (frame->scope_chain);
- if (frame->script) {
- swfdec_script_unref (frame->script);
- frame->script = NULL;
- }
-
- G_OBJECT_CLASS (swfdec_as_frame_parent_class)->dispose (object);
-}
-
-static void
-swfdec_as_frame_mark (SwfdecAsObject *object)
-{
- SwfdecAsFrame *frame = SWFDEC_AS_FRAME (object);
- guint i;
-
- if (frame->next)
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (frame->next));
- g_slist_foreach (frame->scope_chain, (GFunc) swfdec_as_object_mark, NULL);
- if (frame->thisp)
- swfdec_as_object_mark (frame->thisp);
- if (frame->super)
- swfdec_as_object_mark (frame->super);
- swfdec_as_object_mark (frame->target);
- swfdec_as_object_mark (frame->original_target);
- if (frame->function)
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (frame->function));
- for (i = 0; i < frame->n_registers; i++) {
- swfdec_as_value_mark (&frame->registers[i]);
- }
- /* don't mark argv, it's const, others have to take care of it */
- SWFDEC_AS_OBJECT_CLASS (swfdec_as_frame_parent_class)->mark (object);
-}
-
-static char *
-swfdec_as_frame_debug (SwfdecAsObject *object)
-{
- SwfdecAsFrame *frame = SWFDEC_AS_FRAME (object);
- GString *string = g_string_new ("");
- SwfdecAsStackIterator iter;
- SwfdecAsValue *val;
- char *s;
- guint i;
-
- if (frame->thisp) {
- s = swfdec_as_object_get_debug (frame->thisp);
- g_string_append (string, s);
- g_string_append (string, ".");
- g_free (s);
- }
- g_string_append (string, frame->function_name);
- g_string_append (string, " (");
- i = 0;
- for (val = swfdec_as_stack_iterator_init_arguments (&iter, frame); val && i < 4;
- val = swfdec_as_stack_iterator_next (&iter)) {
- if (i > 0)
- g_string_append (string, ", ");
- i++;
- if (i == 3 && frame->argc > 4) {
- g_string_append (string, "...");
- } else {
- s = swfdec_as_value_to_debug (val);
- g_string_append (string, s);
- g_free (s);
- }
- }
- g_string_append (string, ")");
- return g_string_free (string, FALSE);
-}
-
-static void
-swfdec_as_frame_class_init (SwfdecAsFrameClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
-
- object_class->dispose = swfdec_as_frame_dispose;
-
- asobject_class->mark = swfdec_as_frame_mark;
- asobject_class->debug = swfdec_as_frame_debug;
-}
-
-static void
-swfdec_as_frame_init (SwfdecAsFrame *frame)
-{
- frame->function_name = "unnamed";
- frame->blocks = g_array_new (FALSE, FALSE, sizeof (SwfdecAsFrameBlock));
- frame->block_end = (gpointer) -1;
-}
-
-static void
-swfdec_as_frame_load (SwfdecAsFrame *frame)
-{
- SwfdecAsContext *context = SWFDEC_AS_OBJECT (frame)->context;
-
- frame->stack_begin = context->cur;
- context->base = frame->stack_begin;
- frame->next = context->frame;
- context->frame = frame;
- context->call_depth++;
-}
-
-SwfdecAsFrame *
-swfdec_as_frame_new (SwfdecAsContext *context, SwfdecScript *script)
-{
- SwfdecAsFrame *frame;
- gsize size;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
- g_return_val_if_fail (script != NULL, NULL);
-
- size = sizeof (SwfdecAsFrame) + sizeof (SwfdecAsValue) * script->n_registers;
- if (!swfdec_as_context_use_mem (context, size))
- return NULL;
- frame = g_object_new (SWFDEC_TYPE_AS_FRAME, NULL);
- swfdec_as_object_add (SWFDEC_AS_OBJECT (frame), context, size);
- frame->script = swfdec_script_ref (script);
- frame->function_name = script->name;
- SWFDEC_DEBUG ("new frame for function %s", frame->function_name);
- frame->pc = script->main;
- frame->scope_chain = g_slist_prepend (frame->scope_chain, frame);
- frame->n_registers = script->n_registers;
- frame->registers = g_slice_alloc0 (sizeof (SwfdecAsValue) * frame->n_registers);
- if (script->constant_pool) {
- frame->constant_pool_buffer = swfdec_buffer_ref (script->constant_pool);
- frame->constant_pool = swfdec_constant_pool_new_from_action (
- script->constant_pool->data, script->constant_pool->length, script->version);
- if (frame->constant_pool) {
- swfdec_constant_pool_attach_to_context (frame->constant_pool, context);
- } else {
- SWFDEC_ERROR ("couldn't create constant pool");
- }
- }
- swfdec_as_frame_load (frame);
- return frame;
-}
-
-SwfdecAsFrame *
-swfdec_as_frame_new_native (SwfdecAsContext *context)
-{
- SwfdecAsFrame *frame;
- gsize size;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
-
- size = sizeof (SwfdecAsFrame);
- if (!swfdec_as_context_use_mem (context, size))
- return NULL;
- frame = g_object_new (SWFDEC_TYPE_AS_FRAME, NULL);
- SWFDEC_DEBUG ("new native frame");
- swfdec_as_object_add (SWFDEC_AS_OBJECT (frame), context, size);
- swfdec_as_frame_load (frame);
- return frame;
-}
-
-/**
- * swfdec_as_frame_return:
- * @frame: a #SwfdecAsFrame that is currently executing.
- * @return_value: return value of the function or %NULL for none. An undefined
- * value will be used in that case.
- *
- * Ends execution of the frame and instructs the frame's context to continue
- * execution with its parent frame. This function may only be called on the
- * currently executing frame.
- **/
-void
-swfdec_as_frame_return (SwfdecAsFrame *frame, SwfdecAsValue *return_value)
-{
- SwfdecAsContext *context;
- SwfdecAsValue retval;
- SwfdecAsFrame *next;
-
- g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
- context = SWFDEC_AS_OBJECT (frame)->context;
- g_return_if_fail (frame == context->frame);
-
- /* save return value in case it was on the stack somewhere */
- if (frame->construct) {
- SWFDEC_AS_VALUE_SET_OBJECT (&retval, frame->thisp);
- } else if (return_value) {
- retval = *return_value;
- } else {
- SWFDEC_AS_VALUE_SET_UNDEFINED (&retval);
- }
- /* pop frame and leftover stack */
- next = frame->next;
- context->frame = next;
- g_assert (context->call_depth > 0);
- context->call_depth--;
- while (context->base > frame->stack_begin ||
- context->end < frame->stack_begin)
- swfdec_as_stack_pop_segment (context);
- context->cur = frame->stack_begin;
- /* setup stack for previous frame */
- if (next) {
- if (next->stack_begin >= &context->stack->elements[0] &&
- next->stack_begin <= context->cur) {
- context->base = next->stack_begin;
- } else {
- context->base = &context->stack->elements[0];
- }
- } else {
- g_assert (context->stack->next == NULL);
- context->base = &context->stack->elements[0];
- }
- /* pop argv if on stack */
- if (frame->argv == NULL && frame->argc > 0) {
- guint i = frame->argc;
- while (TRUE) {
- guint n = context->cur - context->base;
- n = MIN (n, i);
- swfdec_as_stack_pop_n (context, n);
- i -= n;
- if (i == 0)
- break;
- swfdec_as_stack_pop_segment (context);
- }
- }
- if (context->debugger) {
- SwfdecAsDebuggerClass *klass = SWFDEC_AS_DEBUGGER_GET_CLASS (context->debugger);
-
- if (klass->leave_frame)
- klass->leave_frame (context->debugger, context, frame, &retval);
- }
- /* set return value */
- if (frame->return_value) {
- *frame->return_value = retval;
- } else {
- swfdec_as_stack_ensure_free (context, 1);
- *swfdec_as_stack_push (context) = retval;
- }
-}
-
-/**
- * swfdec_as_frame_set_this:
- * @frame: a #SwfdecAsFrame
- * @thisp: object to use as the this object
- *
- * Sets the object to be used as this pointer. If this function is not called,
- * the this value will be undefined.
- * You may only call this function once per @frame and it must be called
- * directly after creating the frame and before calling swfdec_as_frame_preload().
- **/
-void
-swfdec_as_frame_set_this (SwfdecAsFrame *frame, SwfdecAsObject *thisp)
-{
- g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
- g_return_if_fail (frame->thisp == NULL);
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (thisp));
-
- g_assert (!SWFDEC_IS_AS_SUPER (thisp));
- frame->thisp = thisp;
- if (frame->target == NULL) {
- frame->target = thisp;
- frame->original_target = thisp;
- }
-}
-
-/**
- * swfdec_as_frame_get_variable_and_flags:
- * @frame: a #SwfdecAsFrame
- * @variable: name of the variable
- * @value: pointer to take value of the variable or %NULL
- * @flags: pointer to take flags or %NULL
- * @pobject: pointer to take the actual object that held the variable or %NULL
- *
- * Walks the scope chain of @frame trying to resolve the given @variable and if
- * found, returns its value and flags. Note that there might be a difference
- * between @pobject and the returned object, since the returned object will be
- * part of the scope chain while @pobject will contain the actual property. It
- * will be a prototype of the returned object though.
- *
- * Returns: Object in scope chain that contained the variable.
- **/
-SwfdecAsObject *
-swfdec_as_frame_get_variable_and_flags (SwfdecAsFrame *frame, const char *variable,
- SwfdecAsValue *value, guint *flags, SwfdecAsObject **pobject)
-{
- GSList *walk;
-
- g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
- g_return_val_if_fail (variable != NULL, NULL);
-
- for (walk = frame->scope_chain; walk; walk = walk->next) {
- if (swfdec_as_object_get_variable_and_flags (walk->data, variable, value,
- flags, pobject))
- return walk->data;
- }
- /* we've walked the scope chain down. Now look in the special objects. */
- /* 1) the target */
- if (swfdec_as_object_get_variable_and_flags (frame->target, variable, value,
- flags, pobject))
- return frame->target;
- /* 2) the global object */
- if (swfdec_as_object_get_variable_and_flags (
- SWFDEC_AS_OBJECT (frame)->context->global, variable, value, flags, pobject))
- return SWFDEC_AS_OBJECT (frame)->context->global;
-
- return NULL;
-}
-
-void
-swfdec_as_frame_set_variable_and_flags (SwfdecAsFrame *frame, const char *variable,
- const SwfdecAsValue *value, guint default_flags)
-{
- SwfdecAsObject *pobject, *set;
- GSList *walk;
-
- g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
- g_return_if_fail (variable != NULL);
-
- set = NULL;
- for (walk = frame->scope_chain; walk; walk = walk->next) {
- if (swfdec_as_object_get_variable_and_flags (walk->data, variable, NULL, NULL, &pobject) &&
- pobject == walk->data) {
- set = walk->data;
- break;
- }
- }
- if (set == NULL)
- set = frame->target;
-
- swfdec_as_object_set_variable_and_flags (set, variable, value, default_flags);
-}
-
-SwfdecAsDeleteReturn
-swfdec_as_frame_delete_variable (SwfdecAsFrame *frame, const char *variable)
-{
- GSList *walk;
- SwfdecAsDeleteReturn ret;
-
- g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), FALSE);
- g_return_val_if_fail (variable != NULL, FALSE);
-
- for (walk = frame->scope_chain; walk; walk = walk->next) {
- ret = swfdec_as_object_delete_variable (walk->data, variable);
- if (ret)
- return ret;
- }
- /* we've walked the scope chain down. Now look in the special objects. */
- /* 1) the target set via SetTarget */
- ret = swfdec_as_object_delete_variable (frame->target, variable);
- if (ret)
- return ret;
- /* 2) the global object */
- return swfdec_as_object_delete_variable (SWFDEC_AS_OBJECT (frame)->context->global, variable);
-}
-
-/**
- * swfdec_as_frame_set_target:
- * @frame: a #SwfdecAsFrame
- * @target: the new object to use as target or %NULL to unset
- *
- * Sets the new target to be used in this @frame. The target is a legacy
- * Actionscript concept that is similar to "with". If you don't have to,
- * you shouldn't use this function.
- **/
-void
-swfdec_as_frame_set_target (SwfdecAsFrame *frame, SwfdecAsObject *target)
-{
- g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
- g_return_if_fail (target == NULL || SWFDEC_IS_AS_OBJECT (target));
-
- if (target) {
- frame->target = target;
- } else {
- frame->target = frame->original_target;
- }
-}
-
-void
-swfdec_as_frame_preload (SwfdecAsFrame *frame)
-{
- SwfdecAsObject *object, *args;
- guint i, current_reg = 1;
- SwfdecScript *script;
- SwfdecAsValue val;
- const SwfdecAsValue *cur;
- SwfdecAsContext *context;
- SwfdecAsStackIterator iter;
-
- g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
-
-
- /* setup */
- object = SWFDEC_AS_OBJECT (frame);
- context = object->context;
- script = frame->script;
- if (frame->script == NULL)
- goto out;
-
- /* create arguments and super object if necessary */
- if ((script->flags & (SWFDEC_SCRIPT_PRELOAD_ARGS | SWFDEC_SCRIPT_SUPPRESS_ARGS)) != SWFDEC_SCRIPT_SUPPRESS_ARGS) {
- SwfdecAsFrame *next;
- args = swfdec_as_array_new (context);
- if (!args)
- goto out;
- for (cur = swfdec_as_stack_iterator_init_arguments (&iter, frame); cur != NULL;
- cur = swfdec_as_stack_iterator_next (&iter)) {
- swfdec_as_array_push (SWFDEC_AS_ARRAY (args), cur);
- }
-
- next = frame->next;
- while (next != NULL && (next->function == NULL ||
- SWFDEC_IS_AS_NATIVE_FUNCTION (next->function))) {
- next = next->next;
- }
- if (next != NULL) {
- SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (next->function));
- } else {
- SWFDEC_AS_VALUE_SET_NULL (&val);
- }
- swfdec_as_object_set_variable (args, SWFDEC_AS_STR_caller, &val);
-
- if (frame->function != NULL) {
- SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (frame->function));
- } else {
- SWFDEC_AS_VALUE_SET_NULL (&val);
- }
- swfdec_as_object_set_variable (args, SWFDEC_AS_STR_callee, &val);
- } else {
- /* silence gcc */
- args = NULL;
- }
-
- /* set the default variables (unless suppressed */
- if (!(script->flags & SWFDEC_SCRIPT_SUPPRESS_THIS)) {
- if (frame->thisp) {
- SWFDEC_AS_VALUE_SET_OBJECT (&val, frame->thisp);
- } else {
- SWFDEC_AS_VALUE_SET_UNDEFINED (&val);
- }
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_this, &val);
- }
- if (!(script->flags & SWFDEC_SCRIPT_SUPPRESS_ARGS)) {
- SWFDEC_AS_VALUE_SET_OBJECT (&val, args);
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_arguments, &val);
- }
- if (!(script->flags & SWFDEC_SCRIPT_SUPPRESS_SUPER)) {
- if (frame->super) {
- SWFDEC_AS_VALUE_SET_OBJECT (&val, frame->super);
- } else {
- SWFDEC_AS_VALUE_SET_UNDEFINED (&val);
- }
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_super, &val);
- }
-
- /* set and preload argument variables */
- SWFDEC_AS_VALUE_SET_UNDEFINED (&val);
- cur = swfdec_as_stack_iterator_init_arguments (&iter, frame);
- for (i = 0; i < script->n_arguments; i++) {
- if (cur == NULL)
- cur = &val;
- /* set this value at the right place */
- if (script->arguments[i].preload) {
- if (script->arguments[i].preload < frame->n_registers) {
- frame->registers[script->arguments[i].preload] = *cur;
- } else {
- SWFDEC_ERROR ("trying to set %uth argument %s in nonexisting register %u",
- i, script->arguments[i].name, script->arguments[i].preload);
- }
- } else {
- const char *tmp = swfdec_as_context_get_string (context, script->arguments[i].name);
- swfdec_as_object_set_variable (object, tmp, cur);
- }
- /* get the next argument */
- cur = swfdec_as_stack_iterator_next (&iter);
- }
-
- /* preload from flags */
- if ((script->flags & (SWFDEC_SCRIPT_PRELOAD_THIS | SWFDEC_SCRIPT_SUPPRESS_THIS)) == SWFDEC_SCRIPT_PRELOAD_THIS
- && current_reg < script->n_registers) {
- if (frame->thisp) {
- SWFDEC_AS_VALUE_SET_OBJECT (&frame->registers[current_reg++], frame->thisp);
- } else {
- SWFDEC_AS_VALUE_SET_UNDEFINED (&frame->registers[current_reg++]);
- }
- }
- if (script->flags & SWFDEC_SCRIPT_PRELOAD_ARGS && current_reg < script->n_registers) {
- SWFDEC_AS_VALUE_SET_OBJECT (&frame->registers[current_reg++], args);
- }
- if (script->flags & SWFDEC_SCRIPT_PRELOAD_SUPER && current_reg < script->n_registers) {
- if (frame->super) {
- SWFDEC_AS_VALUE_SET_OBJECT (&frame->registers[current_reg++], frame->super);
- } else {
- SWFDEC_AS_VALUE_SET_UNDEFINED (&frame->registers[current_reg++]);
- }
- }
- if (script->flags & SWFDEC_SCRIPT_PRELOAD_ROOT && current_reg < script->n_registers) {
- if (!swfdec_as_frame_get_variable (frame, SWFDEC_AS_STR__root, &frame->registers[current_reg])) {
- SWFDEC_WARNING ("no root to preload");
- }
- current_reg++;
- }
- if (script->flags & SWFDEC_SCRIPT_PRELOAD_PARENT && current_reg < script->n_registers) {
- if (!swfdec_as_frame_get_variable (frame, SWFDEC_AS_STR__parent, &frame->registers[current_reg])) {
- SWFDEC_WARNING ("no root to preload");
- }
- current_reg++;
- }
- if (script->flags & SWFDEC_SCRIPT_PRELOAD_GLOBAL && current_reg < script->n_registers) {
- SWFDEC_AS_VALUE_SET_OBJECT (&frame->registers[current_reg++], context->global);
- }
- /* set block boundaries */
- frame->block_start = frame->script->buffer->data;
- frame->block_end = frame->script->buffer->data + frame->script->buffer->length;
-
-out:
- if (context->state == SWFDEC_AS_CONTEXT_ABORTED) {
- swfdec_as_frame_return (frame, NULL);
- return;
- }
- if (context->debugger) {
- SwfdecAsDebuggerClass *klass = SWFDEC_AS_DEBUGGER_GET_CLASS (context->debugger);
-
- if (klass->enter_frame)
- klass->enter_frame (context->debugger, context, frame);
- }
-}
-
-void
-swfdec_as_frame_handle_exception (SwfdecAsFrame *frame)
-{
- SwfdecAsContext *cx;
-
- g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
- cx = SWFDEC_AS_OBJECT (frame)->context;
- g_return_if_fail (cx->exception);
-
- /* pop blocks in the hope that we are inside a Try block */
- while (cx->exception && frame->blocks->len) {
- swfdec_as_frame_pop_block (frame);
- }
- /* no Try blocks caught it, exit frame */
- if (cx->exception) {
- swfdec_as_frame_return (frame, NULL);
- }
-}
-
-/**
- * swfdec_as_frame_get_next:
- * @frame: a #SwfdecAsFrame
- *
- * Gets the next frame in the frame stack. The next frame is the frame that
- * will be executed after this @frame.
- *
- * Returns: the next #SwfdecAsFrame or %NULL if this is the bottommost frame.
- **/
-SwfdecAsFrame *
-swfdec_as_frame_get_next (SwfdecAsFrame *frame)
-{
- g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
-
- return frame->next;
-}
-
-/**
- * swfdec_as_frame_get_function_name:
- * @frame: a #SwfdecAsFrame
- *
- * Gets the name of the function that is currently executing. This function is
- * intended for debugging purposes.
- *
- * Returns: a string. Do not free.
- **/
-const char *
-swfdec_as_frame_get_function_name (SwfdecAsFrame *frame)
-{
- g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
-
- g_assert (frame->function_name);
- return frame->function_name;
-}
-
-/**
- * swfdec_as_frame_get_script:
- * @frame: a #SwfdecAsFrame
- *
- * Gets the script associated with the given @frame. If the frame references
- * a native function, there will be no script and this function returns %NULL.
- *
- * Returns: The script executed by this frame or %NULL
- **/
-SwfdecScript *
-swfdec_as_frame_get_script (SwfdecAsFrame *frame)
-{
- g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
-
- return frame->script;
-}
-
-/**
- * swfdec_as_frame_get_this:
- * @frame: a #SwfdecAsFrame
- *
- * Gets the this object of the given @frame. If the frame has no this object,
- * %NULL is returned.
- *
- * Returns: The this object of the frame or %NULL if none.
- **/
-SwfdecAsObject *
-swfdec_as_frame_get_this (SwfdecAsFrame *frame)
-{
- g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
-
- return frame->thisp;
-}
-
diff --git a/libswfdec/swfdec_as_frame.h b/libswfdec/swfdec_as_frame.h
deleted file mode 100644
index 344eaa7..0000000
--- a/libswfdec/swfdec_as_frame.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AS_FRAME_H_
-#define _SWFDEC_AS_FRAME_H_
-
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecAsFrameClass SwfdecAsFrameClass;
-typedef struct _SwfdecAsStackIterator SwfdecAsStackIterator;
-
-struct _SwfdecAsStackIterator {
- /*< private >*/
- SwfdecAsStack * stack;
- SwfdecAsValue * current;
- guint i;
- guint n;
-};
-
-
-#define SWFDEC_TYPE_AS_FRAME (swfdec_as_frame_get_type())
-#define SWFDEC_IS_AS_FRAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_FRAME))
-#define SWFDEC_IS_AS_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_FRAME))
-#define SWFDEC_AS_FRAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_FRAME, SwfdecAsFrame))
-#define SWFDEC_AS_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_FRAME, SwfdecAsFrameClass))
-#define SWFDEC_AS_FRAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_FRAME, SwfdecAsFrameClass))
-
-GType swfdec_as_frame_get_type (void);
-
-SwfdecAsFrame * swfdec_as_frame_get_next (SwfdecAsFrame * frame);
-const char * swfdec_as_frame_get_function_name (SwfdecAsFrame * frame);
-SwfdecScript * swfdec_as_frame_get_script (SwfdecAsFrame * frame);
-SwfdecAsObject *swfdec_as_frame_get_this (SwfdecAsFrame * frame);
-
-SwfdecAsValue * swfdec_as_stack_iterator_init (SwfdecAsStackIterator * iter,
- SwfdecAsFrame * frame);
-SwfdecAsValue * swfdec_as_stack_iterator_init_arguments
- (SwfdecAsStackIterator * iter,
- SwfdecAsFrame * frame);
-SwfdecAsValue * swfdec_as_stack_iterator_next (SwfdecAsStackIterator * iter);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_as_frame_internal.h b/libswfdec/swfdec_as_frame_internal.h
deleted file mode 100644
index 866d1fa..0000000
--- a/libswfdec/swfdec_as_frame_internal.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AS_FRAME_INTERNAL_H_
-#define _SWFDEC_AS_FRAME_INTERNAL_H_
-
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_script_internal.h>
-
-G_BEGIN_DECLS
-
-typedef void (* SwfdecAsFrameBlockFunc) (SwfdecAsFrame *frame, gpointer data);
-
-struct _SwfdecAsFrame {
- SwfdecAsObject object;
-
- SwfdecAsFrame * next; /* next frame (FIXME: keep a list in the context instead?) */
- SwfdecAsFunction * function; /* function we're executing or NULL if toplevel */
- SwfdecAsObject * thisp; /* this object in current frame or NULL if none */
- SwfdecAsObject * super; /* super object in current frame or NULL if none */
- gboolean construct; /* TRUE if this is the constructor for thisp */
- SwfdecAsValue * return_value; /* pointer to where to store the return value */
- guint argc; /* number of arguments */
- const SwfdecAsValue * argv; /* arguments or %NULL if taken from stack */
- /* debugging */
- const char * function_name; /* name of function */
- /* script execution */
- SwfdecScript * script; /* script being executed */
- GSList * scope_chain; /* the scope chain (with objects etc) */
- const guint8 * block_start; /* start of current block */
- const guint8 * block_end; /* end of current block */
- GArray * blocks; /* blocks we have entered (like With) */
- SwfdecAsObject * target; /* target to use as last object in scope chain or for SetVariable */
- SwfdecAsObject * original_target;/* original target (used when resetting target) */
- gboolean is_local; /* TRUE if this frame takes local variables */
- SwfdecAsValue * registers; /* the registers */
- guint n_registers; /* number of allocated registers */
- SwfdecConstantPool * constant_pool; /* constant pool currently in use */
- SwfdecBuffer * constant_pool_buffer; /* buffer containing the raw data for constant_pool */
- SwfdecAsValue * stack_begin; /* beginning of stack */
- const guint8 * pc; /* program counter on stack */
- /* native function */
-};
-
-struct _SwfdecAsFrameClass {
- SwfdecAsObjectClass object_class;
-};
-
-SwfdecAsFrame * swfdec_as_frame_new (SwfdecAsContext * context,
- SwfdecScript * script);
-SwfdecAsFrame * swfdec_as_frame_new_native (SwfdecAsContext * context);
-void swfdec_as_frame_return (SwfdecAsFrame * frame,
- SwfdecAsValue * return_value);
-
-void swfdec_as_frame_set_this (SwfdecAsFrame * frame,
- SwfdecAsObject * thisp);
-void swfdec_as_frame_preload (SwfdecAsFrame * frame);
-
-#define swfdec_as_frame_get_variable(frame, variable, value) \
- swfdec_as_frame_get_variable_and_flags (frame, variable, value, NULL, NULL)
-SwfdecAsObject *swfdec_as_frame_get_variable_and_flags
- (SwfdecAsFrame * frame,
- const char * variable,
- SwfdecAsValue * value,
- guint * flags,
- SwfdecAsObject ** pobject);
-#define swfdec_as_frame_set_variable(frame, variable, value) \
- swfdec_as_frame_set_variable_and_flags (frame, variable, value, 0)
-void swfdec_as_frame_set_variable_and_flags
- (SwfdecAsFrame * frame,
- const char * variable,
- const SwfdecAsValue * value,
- guint default_flags);
-SwfdecAsDeleteReturn
- swfdec_as_frame_delete_variable (SwfdecAsFrame * frame,
- const char * variable);
-
-void swfdec_as_frame_set_target (SwfdecAsFrame * frame,
- SwfdecAsObject * target);
-void swfdec_as_frame_push_block (SwfdecAsFrame * frame,
- const guint8 * start,
- const guint8 * end,
- SwfdecAsFrameBlockFunc func,
- gpointer data);
-void swfdec_as_frame_pop_block (SwfdecAsFrame * frame);
-void swfdec_as_frame_handle_exception(SwfdecAsFrame * frame);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_as_function.c b/libswfdec/swfdec_as_function.c
deleted file mode 100644
index cc0e975..0000000
--- a/libswfdec/swfdec_as_function.c
+++ /dev/null
@@ -1,279 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_function.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_frame_internal.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_stack.h"
-#include "swfdec_as_super.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-
-G_DEFINE_ABSTRACT_TYPE (SwfdecAsFunction, swfdec_as_function, SWFDEC_TYPE_AS_OBJECT)
-
-/**
- * SECTION:SwfdecAsFunction
- * @title: SwfdecAsFunction
- * @short_description: script objects that can be executed
- *
- * Functions is the basic object for executing code in the Swfdec script engine.
- * There is multiple different variants of functions, such as script-created
- * ones and native functions.
- *
- * If you want to create your own functions, you should create native functions.
- * The easiest way to do this is with swfdec_as_object_add_function() or
- * swfdec_as_native_function_new().
- *
- * In Actionscript, every function can be used as a constructor. If you want to
- * make a native function be used as a constructor for your own #SwfdecAsObject
- * subclass, have a look at swfdec_as_native_function_set_construct_type().
- */
-
-/**
- * SwfdecAsFunction
- *
- * This is the base executable object in Swfdec. It is an abstract object. If
- * you want to create functions yourself, use #SwfdecAsNativeFunction.
- */
-
-static void
-swfdec_as_function_class_init (SwfdecAsFunctionClass *klass)
-{
-}
-
-static void
-swfdec_as_function_init (SwfdecAsFunction *function)
-{
-}
-
-/**
- * swfdec_as_function_set_constructor:
- * @fun: a #SwfdecAsFunction
- *
- * Sets the constructor and prototype of @fun. This is a shortcut for calling
- * swfdec_as_object_set_constructor() with the right arguments.
- **/
-void
-swfdec_as_function_set_constructor (SwfdecAsFunction *fun)
-{
- SwfdecAsContext *context;
- SwfdecAsObject *object;
- SwfdecAsValue val;
-
- g_return_if_fail (SWFDEC_IS_AS_FUNCTION (fun));
-
- object = SWFDEC_AS_OBJECT (fun);
- context = object->context;
- if (context->Function == NULL)
- return;
-
- SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Function);
- swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR_constructor,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
-
- SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Function_prototype);
- swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR___proto__,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT |
- SWFDEC_AS_VARIABLE_VERSION_6_UP);
-}
-
-SwfdecAsFrame *
-swfdec_as_function_call_no_preload (SwfdecAsFunction *function,
- SwfdecAsObject *thisp, guint n_args, const SwfdecAsValue *args,
- SwfdecAsValue *return_value)
-{
- SwfdecAsFrame *frame;
- SwfdecAsFunctionClass *klass;
-
- g_return_val_if_fail (SWFDEC_IS_AS_FUNCTION (function), NULL);
- g_return_val_if_fail (thisp == NULL || SWFDEC_IS_AS_OBJECT (thisp), NULL);
-
- /* just to be sure... */
- if (return_value)
- SWFDEC_AS_VALUE_SET_UNDEFINED (return_value);
-
- klass = SWFDEC_AS_FUNCTION_GET_CLASS (function);
- g_assert (klass->call);
- frame = klass->call (function);
- /* FIXME: figure out what to do in these situations?
- * It's a problem when called inside swfdec_as_function_call () as the
- * user of that function expects success, but super may fail here */
- if (frame == NULL)
- return NULL;
- /* second check especially for super object */
- if (thisp != NULL && frame->thisp == NULL) {
- swfdec_as_frame_set_this (frame, swfdec_as_object_resolve (thisp));
- }
- frame->is_local = TRUE;
- frame->argc = n_args;
- frame->argv = args;
- frame->return_value = return_value;
- return frame;
-}
-
-/**
- * swfdec_as_function_call:
- * @function: the #SwfdecAsFunction to call
- * @thisp: this argument to use for the call or %NULL for none
- * @n_args: number of arguments to pass to the function
- * @args: the arguments to pass or %NULL to read the last @n_args stack elements.
- * The memory must be unchanged until the function call has completed.
- * This is after the call to swfdec_as_context_run () has finished.
- * @return_value: pointer for return value or %NULL to push the return value to
- * the stack
- *
- * Calls the given function. This means a #SwfdecAsFrame is created for the
- * function and pushed on top of the execution stack. The function is however
- * not executed. Call swfdec_as_context_run () to execute it.
- **/
-void
-swfdec_as_function_call (SwfdecAsFunction *function, SwfdecAsObject *thisp, guint n_args,
- const SwfdecAsValue *args, SwfdecAsValue *return_value)
-{
- SwfdecAsFrame *frame;
-
- g_return_if_fail (SWFDEC_IS_AS_FUNCTION (function));
- g_return_if_fail (thisp == NULL || SWFDEC_IS_AS_OBJECT (thisp));
-
- frame = swfdec_as_function_call_no_preload (function, thisp, n_args, args, return_value);
- if (frame == NULL)
- return;
- if (thisp != NULL) {
- swfdec_as_super_new (frame, thisp, thisp->prototype);
- } else {
- SWFDEC_FIXME ("does the super object really reference the function when thisp is NULL?");
- swfdec_as_super_new (frame, SWFDEC_AS_OBJECT (function), SWFDEC_AS_OBJECT (function)->prototype);
- }
- swfdec_as_frame_preload (frame);
-}
-
-/*** AS CODE ***/
-
-SWFDEC_AS_NATIVE (101, 10, swfdec_as_function_do_call)
-void
-swfdec_as_function_do_call (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecAsFunction *fun;
- SwfdecAsObject *thisp;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_FUNCTION, &fun, "|O", &thisp);
-
- if (thisp == NULL) {
- thisp = swfdec_as_object_new_empty (cx);
- if (thisp == NULL)
- return;
- }
- if (argc > 0) {
- argc--;
- argv++;
- }
- swfdec_as_function_call (fun, thisp, argc, argv, ret);
- swfdec_as_context_run (cx);
-}
-
-SWFDEC_AS_NATIVE (101, 11, swfdec_as_function_apply)
-void
-swfdec_as_function_apply (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecAsValue *argv_pass = NULL;
- int length = 0;
- SwfdecAsFunction *fun;
- SwfdecAsObject *thisp;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_FUNCTION, &fun, "|O", &thisp);
-
- if (thisp == NULL) {
- thisp = swfdec_as_object_new_empty (cx);
- if (thisp == NULL)
- return;
- }
-
- if (argc > 1 && SWFDEC_AS_VALUE_IS_OBJECT (&argv[1])) {
- int i;
- SwfdecAsObject *array;
- SwfdecAsValue val;
-
- array = SWFDEC_AS_VALUE_GET_OBJECT (&argv[1]);
-
- swfdec_as_object_get_variable (array, SWFDEC_AS_STR_length, &val);
- length = swfdec_as_value_to_integer (cx, &val);
-
- if (length > 0) {
- /* FIXME: find a smarter way to do this, like providing argv not as an array */
- if (!swfdec_as_context_use_mem (cx, sizeof (SwfdecAsValue) * length))
- return;
- argv_pass = g_malloc (sizeof (SwfdecAsValue) * length);
-
- for (i = 0; i < length; i++) {
- swfdec_as_object_get_variable (array,
- swfdec_as_integer_to_string (cx, i), &argv_pass[i]);
- }
- } else {
- length = 0;
- }
- }
-
- swfdec_as_function_call (fun, thisp, length, argv_pass, ret);
- swfdec_as_context_run (cx);
-
- if (argv_pass) {
- swfdec_as_context_unuse_mem (cx, sizeof (SwfdecAsValue) * length);
- g_free (argv_pass);
- }
-}
-
-void
-swfdec_as_function_init_context (SwfdecAsContext *context)
-{
- SwfdecAsObject *function, *proto;
- SwfdecAsValue val;
-
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
-
- function = SWFDEC_AS_OBJECT (swfdec_as_object_add_function (context->global,
- SWFDEC_AS_STR_Function, 0, NULL, 0));
- if (!function)
- return;
- swfdec_as_object_set_variable_flags (context->global, SWFDEC_AS_STR_Function, SWFDEC_AS_VARIABLE_VERSION_6_UP);
- context->Function = function;
- SWFDEC_AS_VALUE_SET_OBJECT (&val, function);
- swfdec_as_object_set_variable_and_flags (function, SWFDEC_AS_STR_constructor,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
- proto = swfdec_as_object_new_empty (context);
- if (!proto)
- return;
- context->Function_prototype = proto;
- SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
- swfdec_as_object_set_variable_and_flags (function, SWFDEC_AS_STR_prototype,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
- swfdec_as_object_set_variable_and_flags (function, SWFDEC_AS_STR___proto__,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT |
- SWFDEC_AS_VARIABLE_VERSION_6_UP);
- SWFDEC_AS_VALUE_SET_OBJECT (&val, function);
- swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
-}
-
diff --git a/libswfdec/swfdec_as_function.h b/libswfdec/swfdec_as_function.h
deleted file mode 100644
index 534aad5..0000000
--- a/libswfdec/swfdec_as_function.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AS_FUNCTION_H_
-#define _SWFDEC_AS_FUNCTION_H_
-
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_script.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecAsFunctionClass SwfdecAsFunctionClass;
-
-#define SWFDEC_TYPE_AS_FUNCTION (swfdec_as_function_get_type())
-#define SWFDEC_IS_AS_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_FUNCTION))
-#define SWFDEC_IS_AS_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_FUNCTION))
-#define SWFDEC_AS_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_FUNCTION, SwfdecAsFunction))
-#define SWFDEC_AS_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_FUNCTION, SwfdecAsFunctionClass))
-#define SWFDEC_AS_FUNCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_FUNCTION, SwfdecAsFunctionClass))
-
-/* FIXME: do two obejcts, one for scripts and one for native? */
-struct _SwfdecAsFunction {
- /*< private >*/
- SwfdecAsObject object;
-};
-
-struct _SwfdecAsFunctionClass {
- SwfdecAsObjectClass object_class;
-
- /* return a frame that calls this function or NULL if uncallable */
- SwfdecAsFrame * (* call) (SwfdecAsFunction * function);
-};
-
-GType swfdec_as_function_get_type (void);
-
-void swfdec_as_function_call (SwfdecAsFunction * function,
- SwfdecAsObject * thisp,
- guint n_args,
- const SwfdecAsValue * args,
- SwfdecAsValue * return_value);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_as_initialize.as b/libswfdec/swfdec_as_initialize.as
deleted file mode 100644
index 4e60ec2..0000000
--- a/libswfdec/swfdec_as_initialize.as
+++ /dev/null
@@ -1,100 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-/*** GENERAL ***/
-
-ASSetPropFlags = ASnative (1, 0);
-ASSetNative = ASnative (4, 0);
-ASSetNativeAccessor = ASnative (4, 1);
-
-/*** BASE OBJECTS ***/
-
-ASSetNative (Object.constructor.prototype, 101, "6call,6apply", 10);
-ASSetPropFlags (Object.constructor.prototype, null, 3);
-
-ASSetNative(Object.prototype, 101, "6watch,6unwatch,6addProperty,valueOf,toString,6hasOwnProperty,6isPrototypeOf,6isPropertyEnumerable");
-Object.prototype.toLocaleString = function () {
- return this.toString ();
-};
-ASSetPropFlags (Object.prototype, null, 3);
-ASSetPropFlags (Object, null, 7);
-
-Boolean = ASconstructor(107, 2);
-ASSetNative(Boolean.prototype, 107, "valueOf,toString");
-ASSetPropFlags(Boolean.prototype, null, 3);
-
-Number = ASconstructor (106, 2);
-ASSetNative (Number.prototype, 106, "valueOf,toString");
-ASSetPropFlags(Number.prototype, null, 3);
-Number.NaN = NaN;
-Number.POSITIVE_INFINITY = Infinity;
-Number.NEGATIVE_INFINITY = -Infinity;
-Number.MIN_VALUE = 4.94065645841247e-324;
-Number.MAX_VALUE = 1.79769313486231e+308;
-ASSetPropFlags(Number, null, 7);
-
-String = ASconstructor(251, 0);
-ASSetNative(String.prototype, 251, "valueOf,toString,toUpperCase,toLowerCase,charAt,charCodeAt,concat,indexOf,lastIndexOf,slice,substring,split,substr", 1);
-ASSetPropFlags(String.prototype, null, 3);
-String.fromCharCode = ASnative(251, 14);
-ASSetPropFlags(String, null, 3);
-
-Math = {
- E: 2.71828182845905,
- LN10: 2.30258509299405,
- LN2: 0.693147180559945,
- LOG10E: 0.434294481903252,
- LOG2E: 1.44269504088896,
- PI: 3.14159265358979,
- SQRT1_2: 0.707106781186548,
- SQRT2: 1.4142135623731
-};
-ASSetNative (Math, 200, "abs,min,max,sin,cos,atan2,tan,exp,log,sqrt,round,random,floor,ceil,atan,asin,acos,pow");
-ASSetPropFlags (Math, null, 7);
-
-Date = ASconstructor (103, 256);
-ASSetNative (Date.prototype, 103, "getFullYear,getYear,getMonth,getDate,getDay,getHours,getMinutes,getSeconds,getMilliseconds,setFullYear,setMonth,setDate,setHours,setMinutes,setSeconds,setMilliseconds,getTime,setTime,getTimezoneOffset,toString,setYear");
-ASSetNative (Date.prototype, 103, "getUTCFullYear,getUTCYear,getUTCMonth,getUTCDate,getUTCDay,getUTCHours,getUTCMinutes,getUTCSeconds,getUTCMilliseconds,setUTCFullYear,setUTCMonth,setUTCDate,setUTCHours,setUTCMinutes,setUTCSeconds,setUTCMilliseconds", 128);
-Date.prototype.valueOf = Date.prototype.getTime;
-Date.UTC = ASnative (103, 257);
-ASSetPropFlags (Date.prototype, null, 3);
-ASSetPropFlags (Date, null, 7);
-
-Array = ASconstructor (252, 0);
-ASSetNative (Array.prototype, 252, "push,pop,concat,shift,unshift,slice,join,splice,toString,sort,reverse,sortOn", 1);
-ASSetPropFlags (Array.prototype, null, 3);
-Array.CASEINSENSITIVE = 1;
-Array.DESCENDING = 2;
-Array.UNIQUESORT = 4;
-Array.RETURNINDEXEDARRAY = 8;
-Array.NUMERIC = 16;
-
-/* GLOBAL FUNCTIONS */
-
-escape = ASnative (100, 0);
-unescape = ASnative (100, 1);
-parseInt = ASnative (100, 2);
-parseFloat = ASnative (100, 3);
-isNaN = ASnative (200, 18);
-isFinite = ASnative (200, 19);
-
-/*** GLOBAL PROPFLAGS */
-
-ASSetPropFlags (this, null, 1, 6);
diff --git a/libswfdec/swfdec_as_initialize.h b/libswfdec/swfdec_as_initialize.h
deleted file mode 100644
index 2fbca42..0000000
--- a/libswfdec/swfdec_as_initialize.h
+++ /dev/null
@@ -1,175 +0,0 @@
-/* This file is autogenerated, do not edit! */
-
-/* compiled from swfdec_as_initialize.as */
-static const unsigned char swfdec_as_initialize[] = {
- 0x88, 0xF3, 0x04, 0x36, 0x00, 0x41, 0x53, 0x53, 0x65, 0x74, 0x50, 0x72, 0x6F, 0x70, 0x46, 0x6C,
- 0x61, 0x67, 0x73, 0x00, 0x41, 0x53, 0x6E, 0x61, 0x74, 0x69, 0x76, 0x65, 0x00, 0x41, 0x53, 0x53,
- 0x65, 0x74, 0x4E, 0x61, 0x74, 0x69, 0x76, 0x65, 0x00, 0x41, 0x53, 0x53, 0x65, 0x74, 0x4E, 0x61,
- 0x74, 0x69, 0x76, 0x65, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x6F, 0x72, 0x00, 0x4F, 0x62, 0x6A,
- 0x65, 0x63, 0x74, 0x00, 0x63, 0x6F, 0x6E, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x6F, 0x72, 0x00,
- 0x70, 0x72, 0x6F, 0x74, 0x6F, 0x74, 0x79, 0x70, 0x65, 0x00, 0x36, 0x63, 0x61, 0x6C, 0x6C, 0x2C,
- 0x36, 0x61, 0x70, 0x70, 0x6C, 0x79, 0x00, 0x36, 0x77, 0x61, 0x74, 0x63, 0x68, 0x2C, 0x36, 0x75,
- 0x6E, 0x77, 0x61, 0x74, 0x63, 0x68, 0x2C, 0x36, 0x61, 0x64, 0x64, 0x50, 0x72, 0x6F, 0x70, 0x65,
- 0x72, 0x74, 0x79, 0x2C, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x4F, 0x66, 0x2C, 0x74, 0x6F, 0x53, 0x74,
- 0x72, 0x69, 0x6E, 0x67, 0x2C, 0x36, 0x68, 0x61, 0x73, 0x4F, 0x77, 0x6E, 0x50, 0x72, 0x6F, 0x70,
- 0x65, 0x72, 0x74, 0x79, 0x2C, 0x36, 0x69, 0x73, 0x50, 0x72, 0x6F, 0x74, 0x6F, 0x74, 0x79, 0x70,
- 0x65, 0x4F, 0x66, 0x2C, 0x36, 0x69, 0x73, 0x50, 0x72, 0x6F, 0x70, 0x65, 0x72, 0x74, 0x79, 0x45,
- 0x6E, 0x75, 0x6D, 0x65, 0x72, 0x61, 0x62, 0x6C, 0x65, 0x00, 0x74, 0x6F, 0x4C, 0x6F, 0x63, 0x61,
- 0x6C, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x74, 0x68, 0x69, 0x73, 0x00, 0x74, 0x6F,
- 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x42, 0x6F, 0x6F, 0x6C, 0x65, 0x61, 0x6E, 0x00, 0x41,
- 0x53, 0x63, 0x6F, 0x6E, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x6F, 0x72, 0x00, 0x76, 0x61, 0x6C,
- 0x75, 0x65, 0x4F, 0x66, 0x2C, 0x74, 0x6F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x4E, 0x75,
- 0x6D, 0x62, 0x65, 0x72, 0x00, 0x4E, 0x61, 0x4E, 0x00, 0x50, 0x4F, 0x53, 0x49, 0x54, 0x49, 0x56,
- 0x45, 0x5F, 0x49, 0x4E, 0x46, 0x49, 0x4E, 0x49, 0x54, 0x59, 0x00, 0x49, 0x6E, 0x66, 0x69, 0x6E,
- 0x69, 0x74, 0x79, 0x00, 0x4E, 0x45, 0x47, 0x41, 0x54, 0x49, 0x56, 0x45, 0x5F, 0x49, 0x4E, 0x46,
- 0x49, 0x4E, 0x49, 0x54, 0x59, 0x00, 0x4D, 0x49, 0x4E, 0x5F, 0x56, 0x41, 0x4C, 0x55, 0x45, 0x00,
- 0x4D, 0x41, 0x58, 0x5F, 0x56, 0x41, 0x4C, 0x55, 0x45, 0x00, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67,
- 0x00, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x4F, 0x66, 0x2C, 0x74, 0x6F, 0x53, 0x74, 0x72, 0x69, 0x6E,
- 0x67, 0x2C, 0x74, 0x6F, 0x55, 0x70, 0x70, 0x65, 0x72, 0x43, 0x61, 0x73, 0x65, 0x2C, 0x74, 0x6F,
- 0x4C, 0x6F, 0x77, 0x65, 0x72, 0x43, 0x61, 0x73, 0x65, 0x2C, 0x63, 0x68, 0x61, 0x72, 0x41, 0x74,
- 0x2C, 0x63, 0x68, 0x61, 0x72, 0x43, 0x6F, 0x64, 0x65, 0x41, 0x74, 0x2C, 0x63, 0x6F, 0x6E, 0x63,
- 0x61, 0x74, 0x2C, 0x69, 0x6E, 0x64, 0x65, 0x78, 0x4F, 0x66, 0x2C, 0x6C, 0x61, 0x73, 0x74, 0x49,
- 0x6E, 0x64, 0x65, 0x78, 0x4F, 0x66, 0x2C, 0x73, 0x6C, 0x69, 0x63, 0x65, 0x2C, 0x73, 0x75, 0x62,
- 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x2C, 0x73, 0x70, 0x6C, 0x69, 0x74, 0x2C, 0x73, 0x75, 0x62,
- 0x73, 0x74, 0x72, 0x00, 0x66, 0x72, 0x6F, 0x6D, 0x43, 0x68, 0x61, 0x72, 0x43, 0x6F, 0x64, 0x65,
- 0x00, 0x4D, 0x61, 0x74, 0x68, 0x00, 0x45, 0x00, 0x4C, 0x4E, 0x31, 0x30, 0x00, 0x4C, 0x4E, 0x32,
- 0x00, 0x4C, 0x4F, 0x47, 0x31, 0x30, 0x45, 0x00, 0x4C, 0x4F, 0x47, 0x32, 0x45, 0x00, 0x50, 0x49,
- 0x00, 0x53, 0x51, 0x52, 0x54, 0x31, 0x5F, 0x32, 0x00, 0x53, 0x51, 0x52, 0x54, 0x32, 0x00, 0x61,
- 0x62, 0x73, 0x2C, 0x6D, 0x69, 0x6E, 0x2C, 0x6D, 0x61, 0x78, 0x2C, 0x73, 0x69, 0x6E, 0x2C, 0x63,
- 0x6F, 0x73, 0x2C, 0x61, 0x74, 0x61, 0x6E, 0x32, 0x2C, 0x74, 0x61, 0x6E, 0x2C, 0x65, 0x78, 0x70,
- 0x2C, 0x6C, 0x6F, 0x67, 0x2C, 0x73, 0x71, 0x72, 0x74, 0x2C, 0x72, 0x6F, 0x75, 0x6E, 0x64, 0x2C,
- 0x72, 0x61, 0x6E, 0x64, 0x6F, 0x6D, 0x2C, 0x66, 0x6C, 0x6F, 0x6F, 0x72, 0x2C, 0x63, 0x65, 0x69,
- 0x6C, 0x2C, 0x61, 0x74, 0x61, 0x6E, 0x2C, 0x61, 0x73, 0x69, 0x6E, 0x2C, 0x61, 0x63, 0x6F, 0x73,
- 0x2C, 0x70, 0x6F, 0x77, 0x00, 0x44, 0x61, 0x74, 0x65, 0x00, 0x67, 0x65, 0x74, 0x46, 0x75, 0x6C,
- 0x6C, 0x59, 0x65, 0x61, 0x72, 0x2C, 0x67, 0x65, 0x74, 0x59, 0x65, 0x61, 0x72, 0x2C, 0x67, 0x65,
- 0x74, 0x4D, 0x6F, 0x6E, 0x74, 0x68, 0x2C, 0x67, 0x65, 0x74, 0x44, 0x61, 0x74, 0x65, 0x2C, 0x67,
- 0x65, 0x74, 0x44, 0x61, 0x79, 0x2C, 0x67, 0x65, 0x74, 0x48, 0x6F, 0x75, 0x72, 0x73, 0x2C, 0x67,
- 0x65, 0x74, 0x4D, 0x69, 0x6E, 0x75, 0x74, 0x65, 0x73, 0x2C, 0x67, 0x65, 0x74, 0x53, 0x65, 0x63,
- 0x6F, 0x6E, 0x64, 0x73, 0x2C, 0x67, 0x65, 0x74, 0x4D, 0x69, 0x6C, 0x6C, 0x69, 0x73, 0x65, 0x63,
- 0x6F, 0x6E, 0x64, 0x73, 0x2C, 0x73, 0x65, 0x74, 0x46, 0x75, 0x6C, 0x6C, 0x59, 0x65, 0x61, 0x72,
- 0x2C, 0x73, 0x65, 0x74, 0x4D, 0x6F, 0x6E, 0x74, 0x68, 0x2C, 0x73, 0x65, 0x74, 0x44, 0x61, 0x74,
- 0x65, 0x2C, 0x73, 0x65, 0x74, 0x48, 0x6F, 0x75, 0x72, 0x73, 0x2C, 0x73, 0x65, 0x74, 0x4D, 0x69,
- 0x6E, 0x75, 0x74, 0x65, 0x73, 0x2C, 0x73, 0x65, 0x74, 0x53, 0x65, 0x63, 0x6F, 0x6E, 0x64, 0x73,
- 0x2C, 0x73, 0x65, 0x74, 0x4D, 0x69, 0x6C, 0x6C, 0x69, 0x73, 0x65, 0x63, 0x6F, 0x6E, 0x64, 0x73,
- 0x2C, 0x67, 0x65, 0x74, 0x54, 0x69, 0x6D, 0x65, 0x2C, 0x73, 0x65, 0x74, 0x54, 0x69, 0x6D, 0x65,
- 0x2C, 0x67, 0x65, 0x74, 0x54, 0x69, 0x6D, 0x65, 0x7A, 0x6F, 0x6E, 0x65, 0x4F, 0x66, 0x66, 0x73,
- 0x65, 0x74, 0x2C, 0x74, 0x6F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x2C, 0x73, 0x65, 0x74, 0x59,
- 0x65, 0x61, 0x72, 0x00, 0x67, 0x65, 0x74, 0x55, 0x54, 0x43, 0x46, 0x75, 0x6C, 0x6C, 0x59, 0x65,
- 0x61, 0x72, 0x2C, 0x67, 0x65, 0x74, 0x55, 0x54, 0x43, 0x59, 0x65, 0x61, 0x72, 0x2C, 0x67, 0x65,
- 0x74, 0x55, 0x54, 0x43, 0x4D, 0x6F, 0x6E, 0x74, 0x68, 0x2C, 0x67, 0x65, 0x74, 0x55, 0x54, 0x43,
- 0x44, 0x61, 0x74, 0x65, 0x2C, 0x67, 0x65, 0x74, 0x55, 0x54, 0x43, 0x44, 0x61, 0x79, 0x2C, 0x67,
- 0x65, 0x74, 0x55, 0x54, 0x43, 0x48, 0x6F, 0x75, 0x72, 0x73, 0x2C, 0x67, 0x65, 0x74, 0x55, 0x54,
- 0x43, 0x4D, 0x69, 0x6E, 0x75, 0x74, 0x65, 0x73, 0x2C, 0x67, 0x65, 0x74, 0x55, 0x54, 0x43, 0x53,
- 0x65, 0x63, 0x6F, 0x6E, 0x64, 0x73, 0x2C, 0x67, 0x65, 0x74, 0x55, 0x54, 0x43, 0x4D, 0x69, 0x6C,
- 0x6C, 0x69, 0x73, 0x65, 0x63, 0x6F, 0x6E, 0x64, 0x73, 0x2C, 0x73, 0x65, 0x74, 0x55, 0x54, 0x43,
- 0x46, 0x75, 0x6C, 0x6C, 0x59, 0x65, 0x61, 0x72, 0x2C, 0x73, 0x65, 0x74, 0x55, 0x54, 0x43, 0x4D,
- 0x6F, 0x6E, 0x74, 0x68, 0x2C, 0x73, 0x65, 0x74, 0x55, 0x54, 0x43, 0x44, 0x61, 0x74, 0x65, 0x2C,
- 0x73, 0x65, 0x74, 0x55, 0x54, 0x43, 0x48, 0x6F, 0x75, 0x72, 0x73, 0x2C, 0x73, 0x65, 0x74, 0x55,
- 0x54, 0x43, 0x4D, 0x69, 0x6E, 0x75, 0x74, 0x65, 0x73, 0x2C, 0x73, 0x65, 0x74, 0x55, 0x54, 0x43,
- 0x53, 0x65, 0x63, 0x6F, 0x6E, 0x64, 0x73, 0x2C, 0x73, 0x65, 0x74, 0x55, 0x54, 0x43, 0x4D, 0x69,
- 0x6C, 0x6C, 0x69, 0x73, 0x65, 0x63, 0x6F, 0x6E, 0x64, 0x73, 0x00, 0x76, 0x61, 0x6C, 0x75, 0x65,
- 0x4F, 0x66, 0x00, 0x67, 0x65, 0x74, 0x54, 0x69, 0x6D, 0x65, 0x00, 0x55, 0x54, 0x43, 0x00, 0x41,
- 0x72, 0x72, 0x61, 0x79, 0x00, 0x70, 0x75, 0x73, 0x68, 0x2C, 0x70, 0x6F, 0x70, 0x2C, 0x63, 0x6F,
- 0x6E, 0x63, 0x61, 0x74, 0x2C, 0x73, 0x68, 0x69, 0x66, 0x74, 0x2C, 0x75, 0x6E, 0x73, 0x68, 0x69,
- 0x66, 0x74, 0x2C, 0x73, 0x6C, 0x69, 0x63, 0x65, 0x2C, 0x6A, 0x6F, 0x69, 0x6E, 0x2C, 0x73, 0x70,
- 0x6C, 0x69, 0x63, 0x65, 0x2C, 0x74, 0x6F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x2C, 0x73, 0x6F,
- 0x72, 0x74, 0x2C, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x2C, 0x73, 0x6F, 0x72, 0x74, 0x4F,
- 0x6E, 0x00, 0x43, 0x41, 0x53, 0x45, 0x49, 0x4E, 0x53, 0x45, 0x4E, 0x53, 0x49, 0x54, 0x49, 0x56,
- 0x45, 0x00, 0x44, 0x45, 0x53, 0x43, 0x45, 0x4E, 0x44, 0x49, 0x4E, 0x47, 0x00, 0x55, 0x4E, 0x49,
- 0x51, 0x55, 0x45, 0x53, 0x4F, 0x52, 0x54, 0x00, 0x52, 0x45, 0x54, 0x55, 0x52, 0x4E, 0x49, 0x4E,
- 0x44, 0x45, 0x58, 0x45, 0x44, 0x41, 0x52, 0x52, 0x41, 0x59, 0x00, 0x4E, 0x55, 0x4D, 0x45, 0x52,
- 0x49, 0x43, 0x00, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x00, 0x75, 0x6E, 0x65, 0x73, 0x63, 0x61,
- 0x70, 0x65, 0x00, 0x70, 0x61, 0x72, 0x73, 0x65, 0x49, 0x6E, 0x74, 0x00, 0x70, 0x61, 0x72, 0x73,
- 0x65, 0x46, 0x6C, 0x6F, 0x61, 0x74, 0x00, 0x69, 0x73, 0x4E, 0x61, 0x4E, 0x00, 0x69, 0x73, 0x46,
- 0x69, 0x6E, 0x69, 0x74, 0x65, 0x00, 0x96, 0x13, 0x00, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x07, 0x01, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13,
- 0x00, 0x08, 0x02, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00,
- 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13, 0x00, 0x08, 0x03, 0x07, 0x01, 0x00, 0x00, 0x00,
- 0x07, 0x04, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x0E,
- 0x00, 0x07, 0x0A, 0x00, 0x00, 0x00, 0x08, 0x07, 0x07, 0x65, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0x05, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07,
- 0x04, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00,
- 0x02, 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x05, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E,
- 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x09, 0x00, 0x08,
- 0x08, 0x07, 0x65, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96,
- 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x09, 0x8E, 0x08, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08,
- 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0B, 0x52, 0x3E, 0x4F, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00,
- 0x00, 0x00, 0x02, 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07,
- 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00,
- 0x02, 0x08, 0x04, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17,
- 0x96, 0x13, 0x00, 0x08, 0x0C, 0x07, 0x02, 0x00, 0x00, 0x00, 0x07, 0x6B, 0x00, 0x00, 0x00, 0x07,
- 0x02, 0x00, 0x00, 0x00, 0x08, 0x0D, 0x3D, 0x1D, 0x96, 0x09, 0x00, 0x08, 0x0E, 0x07, 0x6B, 0x00,
- 0x00, 0x00, 0x08, 0x0C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03,
- 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02,
- 0x08, 0x0C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00,
- 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x13, 0x00, 0x08, 0x0F, 0x07, 0x02, 0x00, 0x00, 0x00, 0x07,
- 0x6A, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x0D, 0x3D, 0x1D, 0x96, 0x09, 0x00,
- 0x08, 0x0E, 0x07, 0x6A, 0x00, 0x00, 0x00, 0x08, 0x0F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E,
- 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07,
- 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0x0F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x07,
- 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x1C,
- 0x96, 0x04, 0x00, 0x08, 0x10, 0x08, 0x10, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x1C, 0x96,
- 0x04, 0x00, 0x08, 0x11, 0x08, 0x12, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x1C, 0x96, 0x04,
- 0x00, 0x08, 0x13, 0x08, 0x12, 0x1C, 0x96, 0x05, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x0C, 0x4F,
- 0x96, 0x02, 0x00, 0x08, 0x0F, 0x1C, 0x96, 0x0B, 0x00, 0x08, 0x14, 0x06, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x1C, 0x96, 0x0B, 0x00, 0x08, 0x15,
- 0x06, 0xFF, 0xFF, 0xEF, 0x7F, 0xE2, 0xFF, 0xFF, 0xFF, 0x4F, 0x96, 0x08, 0x00, 0x07, 0x07, 0x00,
- 0x00, 0x00, 0x02, 0x08, 0x0F, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00,
- 0x3D, 0x17, 0x96, 0x13, 0x00, 0x08, 0x16, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFB, 0x00, 0x00,
- 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x0D, 0x3D, 0x1D, 0x96, 0x0E, 0x00, 0x07, 0x01, 0x00,
- 0x00, 0x00, 0x08, 0x17, 0x07, 0xFB, 0x00, 0x00, 0x00, 0x08, 0x16, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x08,
- 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0x16, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E,
- 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08,
- 0x16, 0x1C, 0x96, 0x13, 0x00, 0x08, 0x18, 0x07, 0x0E, 0x00, 0x00, 0x00, 0x07, 0xFB, 0x00, 0x00,
- 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00,
- 0x00, 0x00, 0x02, 0x08, 0x16, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00,
- 0x3D, 0x17, 0x96, 0x5F, 0x00, 0x08, 0x19, 0x08, 0x1A, 0x06, 0x0A, 0xBF, 0x05, 0x40, 0x74, 0x57,
- 0x14, 0x8B, 0x08, 0x1B, 0x06, 0xB1, 0x6B, 0x02, 0x40, 0x1F, 0x55, 0xB5, 0xBB, 0x08, 0x1C, 0x06,
- 0x42, 0x2E, 0xE6, 0x3F, 0xEC, 0x39, 0xFA, 0xFE, 0x08, 0x1D, 0x06, 0x7B, 0xCB, 0xDB, 0x3F, 0x11,
- 0xE5, 0x26, 0x15, 0x08, 0x1E, 0x06, 0x47, 0x15, 0xF7, 0x3F, 0xEF, 0x82, 0x2B, 0x65, 0x08, 0x1F,
- 0x06, 0xFB, 0x21, 0x09, 0x40, 0x11, 0x2D, 0x44, 0x54, 0x08, 0x20, 0x06, 0x9E, 0xA0, 0xE6, 0x3F,
- 0xD1, 0x3B, 0x7F, 0x66, 0x08, 0x21, 0x06, 0x9E, 0xA0, 0xF6, 0x3F, 0xE3, 0x3B, 0x7F, 0x66, 0x07,
- 0x08, 0x00, 0x00, 0x00, 0x43, 0x1D, 0x96, 0x09, 0x00, 0x08, 0x22, 0x07, 0xC8, 0x00, 0x00, 0x00,
- 0x08, 0x19, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96,
- 0x08, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x19, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03,
- 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x13, 0x00, 0x08, 0x23, 0x07, 0x00, 0x01, 0x00,
- 0x00, 0x07, 0x67, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x0D, 0x3D, 0x1D, 0x96,
- 0x09, 0x00, 0x08, 0x24, 0x07, 0x67, 0x00, 0x00, 0x00, 0x08, 0x23, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x0E,
- 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x08, 0x25, 0x07, 0x67, 0x00, 0x00, 0x00, 0x08, 0x23, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x02,
- 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x23, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x04,
- 0x00, 0x08, 0x26, 0x08, 0x23, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x02, 0x00, 0x08,
- 0x27, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x23, 0x1C, 0x96, 0x13, 0x00, 0x08, 0x28, 0x07, 0x01,
- 0x01, 0x00, 0x00, 0x07, 0x67, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D,
- 0x4F, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0x23, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96,
- 0x08, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x23, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03,
- 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x13, 0x00, 0x08, 0x29, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x07, 0xFC, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x0D, 0x3D, 0x1D, 0x96,
- 0x0E, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x2A, 0x07, 0xFC, 0x00, 0x00, 0x00, 0x08, 0x29,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08,
- 0x02, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0x29, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D,
- 0x17, 0x96, 0x02, 0x00, 0x08, 0x29, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x2B, 0x07, 0x01, 0x00, 0x00,
- 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x29, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x2C, 0x07, 0x02, 0x00,
- 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x29, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x2D, 0x07, 0x04,
- 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x29, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x2E, 0x07,
- 0x08, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x29, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x2F,
- 0x07, 0x10, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x13, 0x00, 0x08, 0x30, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x07, 0x64, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13,
- 0x00, 0x08, 0x31, 0x07, 0x01, 0x00, 0x00, 0x00, 0x07, 0x64, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00,
- 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13, 0x00, 0x08, 0x32, 0x07, 0x02, 0x00, 0x00, 0x00,
- 0x07, 0x64, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13,
- 0x00, 0x08, 0x33, 0x07, 0x03, 0x00, 0x00, 0x00, 0x07, 0x64, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00,
- 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13, 0x00, 0x08, 0x34, 0x07, 0x12, 0x00, 0x00, 0x00,
- 0x07, 0xC8, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13,
- 0x00, 0x08, 0x35, 0x07, 0x13, 0x00, 0x00, 0x00, 0x07, 0xC8, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00,
- 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x0D, 0x00, 0x07, 0x06, 0x00, 0x00, 0x00, 0x07, 0x01,
- 0x00, 0x00, 0x00, 0x02, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08,
- 0x00, 0x3D, 0x17, 0x00
-};
-
diff --git a/libswfdec/swfdec_as_internal.h b/libswfdec/swfdec_as_internal.h
deleted file mode 100644
index 30a556c..0000000
--- a/libswfdec/swfdec_as_internal.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AS_INTERNAL_H_
-#define _SWFDEC_AS_INTERNAL_H_
-
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
-
-G_BEGIN_DECLS
-
-/* This header contains all the non-exported symbols that can't go into
- * exported headers
- */
-#define SWFDEC_AS_NATIVE(x, y, func) SWFDEC_AS_CONSTRUCTOR (x, y, func, NULL)
-#define SWFDEC_AS_CONSTRUCTOR(x, y, func, type) void func (SwfdecAsContext *cx, \
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret);
-
-#define SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT 256
-
-void swfdec_as_function_set_constructor (SwfdecAsFunction * fun);
-void swfdec_as_function_init_context (SwfdecAsContext * context);
-SwfdecAsFrame * swfdec_as_function_call_no_preload (SwfdecAsFunction * function,
- SwfdecAsObject * thisp,
- guint n_args,
- const SwfdecAsValue * args,
- SwfdecAsValue * return_value);
-
-/* swfdec_as_context.c */
-gboolean swfdec_as_context_check_continue (SwfdecAsContext * context);
-void swfdec_as_context_run_init_script (SwfdecAsContext * context,
- const guint8 * data,
- gsize length,
- guint version);
-
-/* swfdec_as_object.c */
-typedef SwfdecAsVariableForeach SwfdecAsVariableForeachRemove;
-typedef const char *(* SwfdecAsVariableForeachRename) (SwfdecAsObject *object,
- const char *variable, SwfdecAsValue *value, guint flags, gpointer data);
-
-SwfdecAsValue * swfdec_as_object_peek_variable (SwfdecAsObject * object,
- const char * name);
-void swfdec_as_object_collect (SwfdecAsObject * object);
-guint swfdec_as_object_foreach_remove (SwfdecAsObject * object,
- SwfdecAsVariableForeach func,
- gpointer data);
-void swfdec_as_object_foreach_rename (SwfdecAsObject * object,
- SwfdecAsVariableForeachRename func,
- gpointer data);
-
-void swfdec_as_object_init_context (SwfdecAsContext * context);
-void swfdec_as_object_decode (SwfdecAsObject * obj,
- const char * str);
-SwfdecAsObject * swfdec_as_object_get_prototype (SwfdecAsObject * object);
-void swfdec_as_object_add_native_variable (SwfdecAsObject * object,
- const char * variable,
- SwfdecAsNative get,
- SwfdecAsNative set);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
deleted file mode 100644
index 813c1ce..0000000
--- a/libswfdec/swfdec_as_interpret.c
+++ /dev/null
@@ -1,3268 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_interpret.h"
-#include "swfdec_as_array.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_frame_internal.h"
-#include "swfdec_as_function.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_script_function.h"
-#include "swfdec_as_stack.h"
-#include "swfdec_as_string.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_as_super.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-#include <errno.h>
-#include <math.h>
-#include <string.h>
-#include "swfdec_decoder.h"
-#include "swfdec_load_object.h"
-#include "swfdec_movie.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_sprite.h"
-#include "swfdec_sprite_movie.h"
-#include "swfdec_resource.h"
-#include "swfdec_text_field_movie.h" // for typeof
-
-/* Define this to get SWFDEC_WARN'd about missing properties of objects.
- * This can be useful to find out about unimplemented native properties,
- * but usually just causes a lot of spam. */
-//#define SWFDEC_WARN_MISSING_PROPERTIES
-
-/*** SUPPORT FUNCTIONS ***/
-
-#define swfdec_action_has_register(cx, i) \
- ((i) < (cx)->frame->n_registers)
-
-/*** ALL THE ACTION IS HERE ***/
-
-static void
-swfdec_action_stop (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- if (SWFDEC_IS_SPRITE_MOVIE (cx->frame->target))
- SWFDEC_SPRITE_MOVIE (cx->frame->target)->playing = FALSE;
- else
- SWFDEC_ERROR ("no movie to stop");
-}
-
-static void
-swfdec_action_play (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- if (SWFDEC_IS_SPRITE_MOVIE (cx->frame->target))
- SWFDEC_SPRITE_MOVIE (cx->frame->target)->playing = TRUE;
- else
- SWFDEC_ERROR ("no movie to play");
-}
-
-static void
-swfdec_action_next_frame (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- if (SWFDEC_IS_SPRITE_MOVIE (cx->frame->target)) {
- SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (cx->frame->target);
- if (movie->frame < movie->n_frames) {
- swfdec_sprite_movie_goto (movie, movie->frame + 1);
- } else {
- SWFDEC_INFO ("can't execute nextFrame, already at last frame");
- }
- } else {
- SWFDEC_ERROR ("no movie to nextFrame on");
- }
-}
-
-static void
-swfdec_action_previous_frame (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- if (SWFDEC_IS_SPRITE_MOVIE (cx->frame->target)) {
- SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (cx->frame->target);
- if (movie->frame > 1) {
- swfdec_sprite_movie_goto (movie, movie->frame - 1);
- } else {
- SWFDEC_INFO ("can't execute previousFrame, already at first frame");
- }
- } else {
- SWFDEC_ERROR ("no movie to previousFrame on");
- }
-}
-
-static void
-swfdec_action_goto_frame (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- guint frame;
-
- if (len != 2) {
- SWFDEC_ERROR ("GotoFrame action length invalid (is %u, should be 2", len);
- return;
- }
- frame = (data[0] | data[1] << 8);
- if (SWFDEC_IS_SPRITE_MOVIE (cx->frame->target)) {
- SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (cx->frame->target);
- swfdec_sprite_movie_goto (movie, frame + 1);
- movie->playing = FALSE;
- } else {
- SWFDEC_ERROR ("no movie to goto on");
- }
-}
-
-static void
-swfdec_action_goto_label (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- if (!memchr (data, 0, len)) {
- SWFDEC_ERROR ("GotoLabel action does not specify a string");
- return;
- }
-
- if (SWFDEC_IS_SPRITE_MOVIE (cx->frame->target)) {
- SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (cx->frame->target);
- int frame;
- if (movie->sprite == NULL ||
- (frame = swfdec_sprite_get_frame (movie->sprite, (const char *) data)) == -1)
- return;
- swfdec_sprite_movie_goto (movie, frame + 1);
- movie->playing = FALSE;
- } else {
- SWFDEC_ERROR ("no movie to goto on");
- }
-}
-
-/* returns: frame to go to or 0 on error */
-static guint
-swfdec_value_to_frame (SwfdecAsContext *cx, SwfdecSpriteMovie *movie, SwfdecAsValue *val)
-{
- int frame;
-
- if (movie->sprite == NULL)
- return 0;
- if (SWFDEC_AS_VALUE_IS_STRING (val)) {
- const char *name = SWFDEC_AS_VALUE_GET_STRING (val);
- double d;
- if (strchr (name, ':')) {
- SWFDEC_ERROR ("FIXME: handle targets");
- }
- /* treat valid encoded numbers as numbers, otherwise assume it's a frame label */
- d = swfdec_as_value_to_number (cx, val);
- if (isnan (d))
- frame = swfdec_sprite_get_frame (movie->sprite, name) + 1;
- else
- frame = d;
- } else if (SWFDEC_AS_VALUE_IS_NUMBER (val)) {
- frame = swfdec_as_value_to_integer (cx, val);
- } else {
- SWFDEC_WARNING ("cannot convert value to frame number");
- /* FIXME: how do we treat undefined etc? */
- frame = 0;
- }
- return frame <= 0 ? 0 : frame;
-}
-
-static void
-swfdec_action_goto_frame2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecBits bits;
- guint bias;
- gboolean play;
- SwfdecAsValue *val;
-
- swfdec_bits_init_data (&bits, data, len);
- if (swfdec_bits_getbits (&bits, 6)) {
- SWFDEC_WARNING ("reserved bits in GotoFrame2 aren't 0");
- }
- bias = swfdec_bits_getbit (&bits);
- play = swfdec_bits_getbit (&bits);
- if (bias) {
- bias = swfdec_bits_get_u16 (&bits);
- }
- val = swfdec_as_stack_peek (cx, 1);
- /* now set it */
- if (SWFDEC_IS_SPRITE_MOVIE (cx->frame->target)) {
- SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (cx->frame->target);
- guint frame = swfdec_value_to_frame (cx, movie, val);
- if (frame > 0) {
- frame += bias;
- frame = CLAMP (frame, 1, movie->n_frames);
- swfdec_sprite_movie_goto (movie, frame);
- movie->playing = play;
- }
- } else {
- SWFDEC_ERROR ("no movie to GotoFrame2 on");
- }
- swfdec_as_stack_pop (cx);
-}
-
-static void
-swfdec_script_skip_actions (SwfdecAsContext *cx, guint jump)
-{
- SwfdecScript *script = cx->frame->script;
- const guint8 *pc = cx->frame->pc;
- const guint8 *endpc = script->buffer->data + script->buffer->length;
-
- /* jump instructions */
- do {
- if (pc >= endpc)
- break;
- if (*pc & 0x80) {
- if (pc + 2 >= endpc)
- break;
- pc += 3 + (pc[1] | (pc[2] << 8));
- } else {
- pc++;
- }
- } while (jump-- > 0);
- cx->frame->pc = pc;
-}
-
-#if 0
-static void
-swfdec_action_wait_for_frame2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- jsval val;
-
- if (len != 1) {
- SWFDEC_ERROR ("WaitForFrame2 needs a 1-byte data");
- return JS_FALSE;
- }
- val = cx->fp->sp[-1];
- cx->fp->sp--;
- if (SWFDEC_IS_SPRITE_MOVIE (cx->frame->target)) {
- SwfdecMovie *movie = SWFDEC_MOVIE (cx->frame->target);
- int frame = swfdec_value_to_frame (cx, movie, val);
- guint jump = data[2];
- guint loaded;
- if (frame < 0)
- return JS_TRUE;
- if (SWFDEC_IS_ROOT_MOVIE (movie)) {
- SwfdecDecoder *dec = SWFDEC_ROOT_MOVIE (movie)->decoder;
- loaded = dec->frames_loaded;
- g_assert (loaded <= movie->n_frames);
- } else {
- loaded = movie->n_frames;
- }
- if (loaded <= (guint) frame)
- swfdec_script_skip_actions (cx, jump);
- } else {
- SWFDEC_ERROR ("no movie to WaitForFrame2 on");
- }
- return JS_TRUE;
-}
-#endif
-
-static void
-swfdec_action_wait_for_frame (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecSpriteMovie *movie;
- guint jump;
- int frame, loaded;
-
- if (len != 3) {
- SWFDEC_ERROR ("WaitForFrame action length invalid (is %u, should be 3", len);
- return;
- }
- if (!SWFDEC_IS_SPRITE_MOVIE (cx->frame->target)) {
- SWFDEC_ERROR ("no movie for WaitForFrame");
- return;
- }
-
- movie = SWFDEC_SPRITE_MOVIE (cx->frame->target);
- frame = data[0] || (data[1] << 8);
- jump = data[2];
- loaded = swfdec_sprite_movie_get_frames_loaded (movie);
- if (loaded < (int) movie->n_frames &&
- loaded <= frame)
- swfdec_script_skip_actions (cx, jump);
-}
-
-static void
-swfdec_action_constant_pool (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecConstantPool *pool;
- SwfdecAsFrame *frame;
-
- frame = cx->frame;
- pool = swfdec_constant_pool_new_from_action (data, len, cx->version);
- if (pool == NULL)
- return;
- swfdec_constant_pool_attach_to_context (pool, cx);
- if (frame->constant_pool)
- swfdec_constant_pool_free (frame->constant_pool);
- frame->constant_pool = pool;
- if (frame->constant_pool_buffer)
- swfdec_buffer_unref (frame->constant_pool_buffer);
- frame->constant_pool_buffer = swfdec_buffer_new_subbuffer (frame->script->buffer,
- data - frame->script->buffer->data, len);
-}
-
-static void
-swfdec_action_push (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecBits bits;
-
- swfdec_bits_init_data (&bits, data, len);
- while (swfdec_bits_left (&bits)) {
- guint type = swfdec_bits_get_u8 (&bits);
- SWFDEC_LOG ("push type %u", type);
- swfdec_as_stack_ensure_free (cx, 1);
- switch (type) {
- case 0: /* string */
- {
- char *s = swfdec_bits_get_string (&bits, cx->version);
- if (s == NULL)
- return;
- SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_push (cx),
- swfdec_as_context_give_string (cx, s));
- break;
- }
- case 1: /* float */
- SWFDEC_AS_VALUE_SET_NUMBER (swfdec_as_stack_push (cx),
- swfdec_bits_get_float (&bits));
- break;
- case 2: /* null */
- SWFDEC_AS_VALUE_SET_NULL (swfdec_as_stack_push (cx));
- break;
- case 3: /* undefined */
- SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_push (cx));
- break;
- case 4: /* register */
- {
- guint regnum = swfdec_bits_get_u8 (&bits);
- if (!swfdec_action_has_register (cx, regnum)) {
- SWFDEC_ERROR ("cannot Push register %u: not enough registers", regnum);
- SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_push (cx));
- } else {
- *swfdec_as_stack_push (cx) = cx->frame->registers[regnum];
- }
- break;
- }
- case 5: /* boolean */
- SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_push (cx),
- swfdec_bits_get_u8 (&bits) ? TRUE : FALSE);
- break;
- case 6: /* double */
- SWFDEC_AS_VALUE_SET_NUMBER (swfdec_as_stack_push (cx),
- swfdec_bits_get_double (&bits));
- break;
- case 7: /* 32bit int */
- SWFDEC_AS_VALUE_SET_INT (swfdec_as_stack_push (cx),
- (int) swfdec_bits_get_u32 (&bits));
- break;
- case 8: /* 8bit ConstantPool address */
- {
- guint i = swfdec_bits_get_u8 (&bits);
- SwfdecConstantPool *pool = cx->frame->constant_pool;
- if (pool == NULL) {
- SWFDEC_ERROR ("no constant pool to push from");
- return;
- }
- if (i >= swfdec_constant_pool_size (pool)) {
- SWFDEC_ERROR ("constant pool index %u too high - only %u elements",
- i, swfdec_constant_pool_size (pool));
- return;
- }
- SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_push (cx),
- swfdec_constant_pool_get (pool, i));
- break;
- }
- case 9: /* 16bit ConstantPool address */
- {
- guint i = swfdec_bits_get_u16 (&bits);
- SwfdecConstantPool *pool = cx->frame->constant_pool;
- if (pool == NULL) {
- SWFDEC_ERROR ("no constant pool to push from");
- return;
- }
- if (i >= swfdec_constant_pool_size (pool)) {
- SWFDEC_ERROR ("constant pool index %u too high - only %u elements",
- i, swfdec_constant_pool_size (pool));
- return;
- }
- SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_push (cx),
- swfdec_constant_pool_get (pool, i));
- break;
- }
- default:
- SWFDEC_ERROR ("Push: type %u not implemented", type);
- return;
- }
- }
-}
-
-/* NB: name must be GC'd */
-static SwfdecAsObject *
-super_special_movie_lookup_magic (SwfdecAsContext *cx, SwfdecAsObject *o, const char *name)
-{
- SwfdecAsValue val;
-
- if (o == NULL) {
- o = swfdec_as_frame_get_variable (cx->frame, name, NULL);
- if (o == NULL)
- return NULL;
- }
- if (SWFDEC_IS_MOVIE (o)) {
- SwfdecMovie *ret = swfdec_movie_get_by_name (SWFDEC_MOVIE (o), name, TRUE);
- if (ret)
- return SWFDEC_AS_OBJECT (ret);
- }
- if (!swfdec_as_object_get_variable (o, name, &val))
- return NULL;
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return NULL;
- return SWFDEC_AS_VALUE_GET_OBJECT (&val);
-}
-
-static SwfdecAsObject *
-swfdec_action_get_movie_by_slash_path (SwfdecAsContext *cx, const char *path)
-{
- SwfdecAsObject *o;
-
- o = cx->frame->target;
- if (!SWFDEC_IS_MOVIE (o))
- return NULL;
- if (*path == '/') {
- o = SWFDEC_AS_OBJECT (swfdec_movie_get_root (SWFDEC_MOVIE (o)));
- path++;
- }
- while (*path) {
- char *slash = strchr (path, '/');
- const char *name;
- if (slash) {
- if (slash == path)
- return NULL;
- name = swfdec_as_context_give_string (cx, g_strndup (path, slash - path));
- path = slash + 1;
- } else {
- name = swfdec_as_context_get_string (cx, path);
- path += strlen (path);
- }
- o = super_special_movie_lookup_magic (cx, o, name);
- if (!SWFDEC_IS_MOVIE (o))
- return NULL;
- }
- return o;
-}
-
-SwfdecAsObject *
-swfdec_action_lookup_object (SwfdecAsContext *cx, SwfdecAsObject *o, const char *path, const char *end)
-{
- gboolean dot_allowed = TRUE;
- const char *start;
-
- if (path == end) {
- if (o == NULL)
- o = cx->frame->target;
- if (SWFDEC_IS_MOVIE (o))
- return o;
- else
- return NULL;
- }
-
- if (path[0] == '/') {
- if (o == NULL)
- o = cx->frame->target;
- if (!SWFDEC_IS_MOVIE (o))
- return NULL;
- o = SWFDEC_AS_OBJECT (swfdec_movie_get_root (SWFDEC_MOVIE (o)));
- path++;
- dot_allowed = FALSE;
- }
- while (path < end) {
- for (start = path; path < end; path++) {
- if (dot_allowed && path[0] == '.') {
- if (end - path >= 2 && path[1] == '.') {
- dot_allowed = FALSE;
- continue;
- }
- } else if (path[0] == ':') {
- if (path[1] == '/')
- continue;
- if (path == start) {
- start++;
- continue;
- }
- } else if (path[0] == '/') {
- dot_allowed = FALSE;
- } else if (path - start < 127) {
- continue;
- }
-
- break;
- }
-
- /* parse variable */
- if (start[0] == '.' && start[1] == '.' && start + 2 == path) {
- if (o == NULL) {
- GSList *walk;
- for (walk = cx->frame->scope_chain; walk; walk = walk->next) {
- if (SWFDEC_IS_MOVIE (walk->data)) {
- o = walk->data;
- break;
- }
- }
- if (o == NULL)
- o = cx->frame->target;
- }
- /* ".." goes back to parent */
- if (!SWFDEC_IS_MOVIE (o))
- return NULL;
- o = SWFDEC_AS_OBJECT (SWFDEC_MOVIE (o)->parent);
- if (o == NULL)
- return NULL;
- } else {
- o = super_special_movie_lookup_magic (cx, o,
- swfdec_as_context_give_string (cx, g_strndup (start, path - start)));
- if (o == NULL)
- return NULL;
- }
- if (path - start < 127)
- path++;
- }
-
- return o;
-}
-
-/* FIXME: this function belongs into swfdec_movie.c */
-SwfdecMovie *
-swfdec_player_get_movie_from_value (SwfdecPlayer *player, SwfdecAsValue *val)
-{
- SwfdecAsContext *cx;
- const char *s;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (SWFDEC_IS_AS_VALUE (val), NULL);
-
- cx = SWFDEC_AS_CONTEXT (player);
- s = swfdec_as_value_to_string (cx, val);
- return swfdec_player_get_movie_from_string (player, s);
-}
-
-SwfdecMovie *
-swfdec_player_get_movie_from_string (SwfdecPlayer *player, const char *s)
-{
- SwfdecAsObject *ret;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (s != NULL, NULL);
-
- ret = swfdec_action_lookup_object (SWFDEC_AS_CONTEXT (player), NULL, s, s + strlen (s));
- if (!SWFDEC_IS_MOVIE (ret)) {
- SWFDEC_WARNING ("\"%s\" does not reference a movie", s);
- return NULL;
- }
- return SWFDEC_MOVIE (ret);
-}
-
-/**
- * swfdec_action_get_movie_by_path:
- * @cx: a #SwfdecAsContext
- * @path: the path to look up
- * @object: pointer that takes the object that was looked up. The object may be
- * %NULL.
- * @variable: pointer that takes variable part of the path. The variable will
- * be either %NULL or a non-gc'ed variable name.
- *
- * Looks up a Flash4-compatible path using "/", ":" and "." style syntax.
- *
- * Returns: The #SwfdecMovie that was looked up or %NULL if the path does not
- * specify a valid movie.
- **/
-static gboolean
-swfdec_action_get_movie_by_path (SwfdecAsContext *cx, const char *path,
- SwfdecAsObject **object, const char **variable)
-{
- SwfdecAsObject *movie;
- char *end, *s;
-
- g_assert (path != NULL);
- g_assert (object != NULL);
- g_assert (variable != NULL);
- g_assert (cx->frame != NULL);
-
- /* find dot or colon */
- end = strpbrk (path, ".:");
-
- /* if no dot or colon, look up slash-path */
- if (end == NULL) {
- /* shortcut for the general case */
- if (strchr (path, '/') != NULL) {
- movie = swfdec_action_get_movie_by_slash_path (cx, path);
- if (movie) {
- *object = movie;
- *variable = NULL;
- return TRUE;
- }
- }
-
- *object = NULL;
- *variable = path;
- return TRUE;
- }
- /* find last dot or colon */
- while ((s = strpbrk (end + 1, ".:")) != NULL)
- end = s;
-
- /* variable to use is the part after the last dot or colon */
- *variable = end + 1;
- /* look up object for start of path */
- if (path == end)
- movie = NULL;
- else
- movie = swfdec_action_lookup_object (cx, NULL, path, end);
- if (movie) {
- *object = movie;
- return TRUE;
- } else {
- *variable = NULL;
- return FALSE;
- }
-}
-
-static void
-swfdec_action_get_variable (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *val;
- const char *s;
- SwfdecAsObject *object;
-
- val = swfdec_as_stack_peek (cx, 1);
- s = swfdec_as_value_to_string (cx, val);
- if (swfdec_action_get_movie_by_path (cx, s, &object, &s)) {
- if (object) {
- if (s) {
- swfdec_as_object_get_variable (object, swfdec_as_context_get_string (cx, s), val);
- } else {
- SWFDEC_AS_VALUE_SET_OBJECT (val, object);
- }
- } else {
- swfdec_as_frame_get_variable (cx->frame, swfdec_as_context_get_string (cx, s), val);
- }
- } else {
- SWFDEC_AS_VALUE_SET_UNDEFINED (val);
-#ifdef SWFDEC_WARN_MISSING_PROPERTIES
- SWFDEC_WARNING ("no variable named %s", s);
-#endif
- }
-}
-
-static void
-swfdec_action_set_variable (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- const char *s, *rest;
- SwfdecAsObject *object;
-
- s = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 2));
- if (swfdec_action_get_movie_by_path (cx, s, &object, &rest)) {
- if (object && rest) {
- swfdec_as_object_set_variable (object, swfdec_as_context_get_string (cx, rest),
- swfdec_as_stack_peek (cx, 1));
- } else {
- if (object)
- rest = s;
- else
- rest = swfdec_as_context_get_string (cx, rest);
- swfdec_as_frame_set_variable (cx->frame, rest, swfdec_as_stack_peek (cx, 1));
- }
- }
- swfdec_as_stack_pop_n (cx, 2);
-}
-
-/* FIXME: this sucks */
-extern struct {
- gboolean needs_movie;
- const char * name; /* GC'd */
- void (* get) (SwfdecMovie *movie, SwfdecAsValue *ret);
- void (* set) (SwfdecMovie *movie, const SwfdecAsValue *val);
-} swfdec_movieclip_props[];
-static void
-swfdec_action_get_property (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecMovie *movie;
- guint id;
-
- id = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 1));
- if (!SWFDEC_IS_PLAYER (cx)) {
- SWFDEC_INFO ("tried using GetProperty in a non-SwfdecPlayer context");
- goto error;
- } else {
- movie = swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx),
- swfdec_as_stack_peek (cx, 2));
- if (movie == NULL)
- goto error;
- }
- if (id > (cx->version > 4 ? 21 : 18)) {
- SWFDEC_WARNING ("trying to SetProperty %u, doesn't exist", id);
- goto error;
- }
- swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (movie), swfdec_movieclip_props[id].name,
- swfdec_as_stack_peek (cx, 2));
- swfdec_as_stack_pop (cx);
- return;
-
-error :
- swfdec_as_stack_pop (cx);
- SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 1));
-}
-
-static void
-swfdec_action_set_property (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecMovie *movie;
- guint id;
-
- id = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 2));
- if (!SWFDEC_IS_PLAYER (cx)) {
- SWFDEC_INFO ("tried using GetProperty in a non-SwfdecPlayer context");
- goto error;
- } else {
- movie = swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx),
- swfdec_as_stack_peek (cx, 3));
- if (movie == NULL)
- goto error;
- }
- if (id > (cx->version > 4 ? 21 : 18)) {
- SWFDEC_WARNING ("trying to SetProperty %u, doesn't exist", id);
- goto error;
- }
- swfdec_as_object_set_variable (SWFDEC_AS_OBJECT (movie), swfdec_movieclip_props[id].name,
- swfdec_as_stack_peek (cx, 1));
- swfdec_as_stack_pop_n (cx, 3);
- return;
-
-error :
- swfdec_as_stack_pop_n (cx, 3);
-}
-
-static void
-swfdec_action_get_member (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsObject *object = swfdec_as_value_to_object (cx, swfdec_as_stack_peek (cx, 2));
- if (object) {
- const char *name;
- name = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1));
- swfdec_as_object_get_variable (object, name, swfdec_as_stack_peek (cx, 2));
-#ifdef SWFDEC_WARN_MISSING_PROPERTIES
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (swfdec_as_stack_peek (cx, 2))) {
- SWFDEC_WARNING ("no variable named %s:%s", G_OBJECT_TYPE_NAME (object), name);
- }
-#endif
- } else {
- SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 2));
- }
- swfdec_as_stack_pop (cx);
-}
-
-static void
-swfdec_action_set_member (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- if (SWFDEC_AS_VALUE_IS_OBJECT (swfdec_as_stack_peek (cx, 3))) {
- const char *name = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 2));
- swfdec_as_object_set_variable (SWFDEC_AS_VALUE_GET_OBJECT (swfdec_as_stack_peek (cx, 3)),
- name, swfdec_as_stack_peek (cx, 1));
- }
- swfdec_as_stack_pop_n (cx, 3);
-}
-
-static void
-swfdec_action_trace (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *val;
- const char *s;
-
- val = swfdec_as_stack_peek (cx, 1);
- if (val->type == SWFDEC_AS_TYPE_UNDEFINED) {
- s = SWFDEC_AS_STR_undefined;
- } else if (val->type == SWFDEC_AS_TYPE_OBJECT &&
- SWFDEC_IS_AS_STRING (swfdec_as_value_to_object (cx, val))) {
- s = SWFDEC_AS_STRING (swfdec_as_value_to_object (cx, val))->string;
- } else {
- s = swfdec_as_value_to_string (cx, val);
- }
- swfdec_as_stack_pop (cx);
- g_signal_emit_by_name (cx, "trace", s);
-}
-
-/* stack looks like this: [ function, this, arg1, arg2, ... ] */
-/* stack must be at least 2 elements big */
-static SwfdecAsFrame *
-swfdec_action_call (SwfdecAsContext *cx, guint n_args)
-{
- SwfdecAsFrame *frame;
- SwfdecAsFunction *fun;
- SwfdecAsObject *thisp;
-
- if (!SWFDEC_AS_VALUE_IS_OBJECT (swfdec_as_stack_peek (cx, 1)))
- goto error;
- fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (swfdec_as_stack_peek (cx, 1));
- if (!SWFDEC_IS_AS_FUNCTION (fun))
- goto error;
- if (!SWFDEC_AS_VALUE_IS_OBJECT (swfdec_as_stack_peek (cx, 2))) {
- thisp = NULL;
- } else {
- thisp = SWFDEC_AS_VALUE_GET_OBJECT (swfdec_as_stack_peek (cx, 2));
- }
- swfdec_as_stack_pop_n (cx, 2);
- /* sanitize argument count */
- if (n_args >= swfdec_as_stack_get_size (cx))
- n_args = swfdec_as_stack_get_size (cx);
- frame = swfdec_as_function_call_no_preload (fun, thisp, n_args, NULL, NULL);
- if (frame == NULL)
- return NULL;
- if (SWFDEC_IS_AS_SUPER (fun)) {
- SWFDEC_LOG ("replacing super object on frame");
- swfdec_as_super_new_chain (frame, SWFDEC_AS_SUPER (fun), NULL);
- }
- return frame;
-
-error:
- n_args += 2;
- if (n_args > swfdec_as_stack_get_size (cx))
- n_args = swfdec_as_stack_get_size (cx);
- swfdec_as_stack_pop_n (cx, n_args);
- SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_push (cx));
- return NULL;
-}
-
-static void
-swfdec_action_call_function (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsFrame *frame = cx->frame;
- SwfdecAsObject *obj;
- guint n_args;
- const char *name;
- SwfdecAsValue *fun, *thisp;
-
- swfdec_as_stack_ensure_size (cx, 2);
- n_args = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 2));
- name = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1));
- thisp = swfdec_as_stack_peek (cx, 2);
- fun = swfdec_as_stack_peek (cx, 1);
- obj = swfdec_as_frame_get_variable (frame, name, fun);
- if (obj) {
- SWFDEC_AS_VALUE_SET_OBJECT (thisp, obj);
- } else {
- SWFDEC_AS_VALUE_SET_NULL (thisp);
- SWFDEC_AS_VALUE_SET_UNDEFINED (fun);
- }
- frame = swfdec_action_call (cx, n_args);
- if (frame) {
- swfdec_as_frame_preload (frame);
- } else {
- SWFDEC_WARNING ("no function named %s", name);
- }
-}
-
-static void
-swfdec_action_call_method (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsFrame *frame = cx->frame;
- SwfdecAsValue *val;
- SwfdecAsObject *obj;
- SwfdecAsObject *pobj = NULL;
- guint n_args;
- const char *name;
-
- swfdec_as_stack_ensure_size (cx, 3);
- obj = swfdec_as_value_to_object (cx, swfdec_as_stack_peek (cx, 2));
- n_args = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 3));
- val = swfdec_as_stack_peek (cx, 1);
- if (obj) {
- name = swfdec_as_value_to_string (cx, val);
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (val) ||
- name == SWFDEC_AS_STR_EMPTY) {
- SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 3));
- SWFDEC_AS_VALUE_SET_OBJECT (swfdec_as_stack_peek (cx, 2), obj);
- name = "";
- pobj = obj;
- } else {
- SWFDEC_AS_VALUE_SET_OBJECT (swfdec_as_stack_peek (cx, 3), obj);
- swfdec_as_object_get_variable_and_flags (obj, name, swfdec_as_stack_peek (cx, 2), NULL, &pobj);
- }
- } else {
- if (SWFDEC_AS_VALUE_IS_STRING (val))
- name = SWFDEC_AS_VALUE_GET_STRING (val);
- else
- name = "???";
- SWFDEC_AS_VALUE_SET_NULL (swfdec_as_stack_peek (cx, 3));
- SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 2));
- }
- swfdec_as_stack_pop (cx);
- frame = swfdec_action_call (cx, n_args);
- if (frame) {
- /* setup super to point to the right prototype */
- if (SWFDEC_IS_AS_SUPER (obj)) {
- swfdec_as_super_new_chain (frame, SWFDEC_AS_SUPER (obj), name);
- } else if (cx->version > 6) {
- swfdec_as_super_new (frame, obj, pobj == obj ? obj->prototype : pobj);
- } else {
- swfdec_as_super_new (frame, obj, obj->prototype);
- }
- swfdec_as_frame_preload (frame);
- } else {
- SWFDEC_WARNING ("no function named \"%s\" on object %s", name, obj ? G_OBJECT_TYPE_NAME(obj) : "unknown");
- }
-}
-
-static void
-swfdec_action_pop (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- swfdec_as_stack_pop (cx);
-}
-
-static void
-swfdec_action_binary (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- double l, r;
-
- r = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 1));
- l = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 2));
- switch (action) {
- case SWFDEC_AS_ACTION_ADD:
- l = l + r;
- break;
- case SWFDEC_AS_ACTION_SUBTRACT:
- l = l - r;
- break;
- case SWFDEC_AS_ACTION_MULTIPLY:
- l = l * r;
- break;
- case SWFDEC_AS_ACTION_DIVIDE:
- if (cx->version < 5) {
- if (r == 0) {
- swfdec_as_stack_pop (cx);
- SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_peek (cx, 1), SWFDEC_AS_STR__ERROR_);
- return;
- }
- }
- if (r == 0) {
- if (l > 0)
- l = INFINITY;
- else if (l < 0)
- l = -INFINITY;
- else
- l = NAN;
- } else {
- l = l / r;
- }
- break;
- default:
- g_assert_not_reached ();
- break;
- }
- swfdec_as_stack_pop (cx);
- SWFDEC_AS_VALUE_SET_NUMBER (swfdec_as_stack_peek (cx, 1), l);
-}
-
-static void
-swfdec_action_add2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *rval, *lval, rtmp, ltmp;
-
- rval = swfdec_as_stack_peek (cx, 1);
- lval = swfdec_as_stack_peek (cx, 2);
- rtmp = *rval;
- ltmp = *lval;
- swfdec_as_value_to_primitive (&rtmp);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&rtmp) || SWFDEC_IS_MOVIE (SWFDEC_AS_VALUE_GET_OBJECT (&rtmp)))
- rval = &rtmp;
- swfdec_as_value_to_primitive (<mp);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (<mp) || SWFDEC_IS_MOVIE (SWFDEC_AS_VALUE_GET_OBJECT (<mp)))
- lval = <mp;
-
- if (SWFDEC_AS_VALUE_IS_STRING (lval) || SWFDEC_AS_VALUE_IS_STRING (rval)) {
- const char *lstr, *rstr;
- lstr = swfdec_as_value_to_string (cx, lval);
- rstr = swfdec_as_value_to_string (cx, rval);
- lstr = swfdec_as_str_concat (cx, lstr, rstr);
- swfdec_as_stack_pop (cx);
- SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_peek (cx, 1), lstr);
- } else {
- double d, d2;
- d = swfdec_as_value_to_number (cx, lval);
- d2 = swfdec_as_value_to_number (cx, rval);
- d += d2;
- swfdec_as_stack_pop (cx);
- SWFDEC_AS_VALUE_SET_NUMBER (swfdec_as_stack_peek (cx, 1), d);
- }
-}
-
-static void
-swfdec_action_new_comparison (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *lval, *rval;
- double l, r;
-
- rval = swfdec_as_stack_peek (cx, 1);
- lval = swfdec_as_stack_peek (cx, 2);
-
- /* swap if we do a greater comparison */
- if (action == SWFDEC_AS_ACTION_GREATER) {
- SwfdecAsValue *tmp = lval;
- lval = rval;
- rval = tmp;
- }
- /* comparison with object is always false */
- swfdec_as_value_to_primitive (lval);
- if (SWFDEC_AS_VALUE_IS_OBJECT (lval) &&
- !SWFDEC_IS_MOVIE (SWFDEC_AS_VALUE_GET_OBJECT (lval))) {
- swfdec_as_stack_pop (cx);
- SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1), FALSE);
- return;
- }
- /* same for the rval */
- swfdec_as_value_to_primitive (rval);
- if (SWFDEC_AS_VALUE_IS_OBJECT (rval) &&
- !SWFDEC_IS_MOVIE (SWFDEC_AS_VALUE_GET_OBJECT (rval))) {
- swfdec_as_stack_pop (cx);
- SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1), FALSE);
- return;
- }
- /* movieclips are not objects, but they evaluate to NaN, so we can handle them here */
- if (SWFDEC_AS_VALUE_IS_OBJECT (rval) ||
- SWFDEC_AS_VALUE_IS_OBJECT (lval)) {
- swfdec_as_stack_pop (cx);
- SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 1));
- return;
- }
- /* if both are strings, compare strings */
- if (SWFDEC_AS_VALUE_IS_STRING (rval) &&
- SWFDEC_AS_VALUE_IS_STRING (lval)) {
- const char *ls = SWFDEC_AS_VALUE_GET_STRING (lval);
- const char *rs = SWFDEC_AS_VALUE_GET_STRING (rval);
- int cmp;
- if (ls == SWFDEC_AS_STR_EMPTY) {
- cmp = rs == SWFDEC_AS_STR_EMPTY ? 0 : 1;
- } else if (rs == SWFDEC_AS_STR_EMPTY) {
- cmp = -1;
- } else {
- cmp = strcmp (ls, rs);
- }
- swfdec_as_stack_pop (cx);
- SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1), cmp < 0);
- return;
- }
- /* convert to numbers and compare those */
- l = swfdec_as_value_to_number (cx, lval);
- r = swfdec_as_value_to_number (cx, rval);
- swfdec_as_stack_pop (cx);
- /* NaN results in undefined */
- if (isnan (l) || isnan (r)) {
- SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 1));
- return;
- }
- SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1), l < r);
-}
-
-static void
-swfdec_action_not (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- if (cx->version <= 4) {
- double d = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 1));
- SWFDEC_AS_VALUE_SET_NUMBER (swfdec_as_stack_peek (cx, 1), d == 0 ? 1 : 0);
- } else {
- SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1),
- !swfdec_as_value_to_boolean (cx, swfdec_as_stack_peek (cx, 1)));
- }
-}
-
-static void
-swfdec_action_jump (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- gint16 offset;
-
- if (len != 2) {
- SWFDEC_ERROR ("Jump action length invalid (is %u, should be 2", len);
- return;
- }
- offset = data[0] | (data[1] << 8);
- cx->frame->pc += 5 + (int) offset;
-}
-
-static void
-swfdec_action_if (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- if (len != 2) {
- SWFDEC_ERROR ("Jump action length invalid (is %u, should be 2", len);
- return;
- }
- if (swfdec_as_value_to_boolean (cx, swfdec_as_stack_peek (cx, 1))) {
- gint16 offset = data[0] | (data[1] << 8);
- cx->frame->pc += 5 + (int) offset;
- }
- swfdec_as_stack_pop (cx);
-}
-
-static void
-swfdec_action_decrement (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *val;
-
- val = swfdec_as_stack_peek (cx, 1);
- SWFDEC_AS_VALUE_SET_NUMBER (val, swfdec_as_value_to_number (cx, val) - 1);
-}
-
-static void
-swfdec_action_increment (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *val;
-
- val = swfdec_as_stack_peek (cx, 1);
- SWFDEC_AS_VALUE_SET_NUMBER (val, swfdec_as_value_to_number (cx, val) + 1);
-}
-
-static void
-swfdec_action_get_url (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecBits bits;
- char *url, *target;
-
- swfdec_bits_init_data (&bits, data, len);
- url = swfdec_bits_get_string (&bits, cx->version);
- target = swfdec_bits_get_string (&bits, cx->version);
- if (url == NULL || target == NULL) {
- SWFDEC_ERROR ("not enough data in GetURL");
- g_free (url);
- g_free (target);
- return;
- }
- if (swfdec_bits_left (&bits)) {
- SWFDEC_WARNING ("leftover bytes in GetURL action");
- }
- if (!SWFDEC_IS_PLAYER (cx)) {
- SWFDEC_ERROR ("GetURL without a SwfdecPlayer");
- } else {
- swfdec_resource_load (SWFDEC_PLAYER (cx), target, url,
- SWFDEC_LOADER_REQUEST_DEFAULT, NULL, NULL, FALSE);
- }
- g_free (url);
- g_free (target);
-}
-
-static void
-swfdec_as_interpret_load_variables_on_finish (SwfdecAsObject *target,
- const char *text)
-{
- if (text != NULL)
- swfdec_as_object_decode (target, text);
-
- // only call onData for sprite movies
- // FIXME: is it called even when loading fails?
- swfdec_movie_queue_script (SWFDEC_MOVIE (target), SWFDEC_EVENT_DATA);
-}
-
-static void
-swfdec_action_get_url2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- const char *target, *url;
- guint method, internal, variables;
-
- if (len != 1) {
- SWFDEC_ERROR ("GetURL2 requires 1 byte of data, not %u", len);
- return;
- }
-
- method = data[0] & 3;
- if (method == 3) {
- SWFDEC_ERROR ("GetURL method 3 invalid");
- method = 0;
- }
- internal = data[0] & 64;
- variables = data[0] & 128;
- if (method == 1 || method == 2) {
- SWFDEC_FIXME ("encode variables");
- }
-
- target = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1));
- url = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 2));
-
- if (!SWFDEC_IS_PLAYER (cx)) {
- SWFDEC_ERROR ("GetURL2 action requires a SwfdecPlayer");
- } else if (variables) {
- SwfdecMovie *movie;
-
- movie = swfdec_player_get_movie_from_string (SWFDEC_PLAYER (cx), target);
- if (movie != NULL) {
- swfdec_load_object_create (SWFDEC_AS_OBJECT (movie), url, method, NULL, NULL,
- swfdec_as_interpret_load_variables_on_finish);
- }
- } else {
- swfdec_resource_load (SWFDEC_PLAYER (cx), target, url, method, NULL, NULL, internal);
- }
-
- swfdec_as_stack_pop_n (cx, 2);
-}
-
-static void
-swfdec_action_string_add (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- const char *lval, *rval;
-
- rval = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1));
- lval = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 2));
- lval = swfdec_as_str_concat (cx, lval, rval);
- SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_peek (cx, 2), lval);
- swfdec_as_stack_pop (cx);
-}
-
-static void
-swfdec_action_push_duplicate (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *val = swfdec_as_stack_peek (cx, 1);
-
- *swfdec_as_stack_push (cx) = *val;
-}
-
-static void
-swfdec_action_random_number (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- gint32 max;
- SwfdecAsValue *val;
-
- val = swfdec_as_stack_peek (cx, 1);
- max = swfdec_as_value_to_integer (cx, val);
-
- if (max <= 0)
- SWFDEC_AS_VALUE_SET_NUMBER (val, 0);
- else
- SWFDEC_AS_VALUE_SET_NUMBER (val, g_rand_int_range (cx->rand, 0, max));
-}
-
-static void
-swfdec_action_old_compare (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- double l, r;
- gboolean cond;
-
- l = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 2));
- r = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 1));
- switch (action) {
- case SWFDEC_AS_ACTION_EQUALS:
- cond = l == r;
- break;
- case SWFDEC_AS_ACTION_LESS:
- cond = l < r;
- break;
- default:
- g_assert_not_reached ();
- return;
- }
- swfdec_as_stack_pop (cx);
- if (cx->version < 5) {
- SWFDEC_AS_VALUE_SET_NUMBER (swfdec_as_stack_peek (cx, 1), cond ? 1 : 0);
- } else {
- SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1), cond);
- }
-}
-
-static void
-swfdec_action_string_extract (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- int start, n, left;
- const char *s;
-
- n = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 1));
- start = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 2));
- s = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 3));
- swfdec_as_stack_pop_n (cx, 2);
- left = g_utf8_strlen (s, -1);
- if (start > left) {
- SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_peek (cx, 1), SWFDEC_AS_STR_EMPTY);
- return;
- } else if (start < 2) {
- start = 0;
- } else {
- start--;
- }
- left -= start;
- if (n < 0 || n > left)
- n = left;
-
- SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_peek (cx, 1),
- swfdec_as_str_sub (cx, s, start, n));
-}
-
-static void
-swfdec_action_string_length (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- const char *s;
- SwfdecAsValue *v;
-
- v = swfdec_as_stack_peek (cx, 1);
- s = swfdec_as_value_to_string (cx, v);
- SWFDEC_AS_VALUE_SET_INT (v, g_utf8_strlen (s, -1));
-}
-
-static void
-swfdec_action_string_compare (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- const char *l, *r;
- gboolean cond;
-
- r = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1));
- l = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 2));
- switch (action) {
- case SWFDEC_AS_ACTION_STRING_EQUALS:
- cond = l == r;
- break;
- case SWFDEC_AS_ACTION_STRING_LESS:
- cond = strcmp (l, r) < 0;
- break;
- default:
- cond = FALSE;
- g_assert_not_reached ();
- break;
- }
- swfdec_as_stack_pop (cx);
- if (cx->version < 5) {
- SWFDEC_AS_VALUE_SET_NUMBER (swfdec_as_stack_peek (cx, 1), cond ? 1 : 0);
- } else {
- SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1), cond);
- }
-}
-
-static void
-swfdec_action_equals2_5 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *rval, *lval;
- SwfdecAsValue rtmp, ltmp;
- SwfdecAsValueType ltype, rtype;
- double l, r;
- gboolean cond;
-
- rval = swfdec_as_stack_peek (cx, 1);
- lval = swfdec_as_stack_peek (cx, 2);
- rtmp = *rval;
- ltmp = *lval;
- swfdec_as_value_to_primitive (&rtmp);
- swfdec_as_value_to_primitive (<mp);
- ltype = ltmp.type;
- rtype = rtmp.type;
-
- /* get objects compared */
- if (ltype == SWFDEC_AS_TYPE_OBJECT && rtype == SWFDEC_AS_TYPE_OBJECT) {
- SwfdecAsObject *lo = SWFDEC_AS_VALUE_GET_OBJECT (<mp);
- SwfdecAsObject *ro = SWFDEC_AS_VALUE_GET_OBJECT (&rtmp);
-
- if (SWFDEC_IS_MOVIE (lo) && SWFDEC_IS_MOVIE (ro)) {
- lo = SWFDEC_AS_OBJECT (swfdec_movie_resolve (SWFDEC_MOVIE (lo)));
- ro = SWFDEC_AS_OBJECT (swfdec_movie_resolve (SWFDEC_MOVIE (ro)));
- } else if (SWFDEC_IS_MOVIE (lo)) {
- swfdec_as_value_to_primitive (rval);
- rtype = rval->type;
- if (rtype != SWFDEC_AS_TYPE_OBJECT) {
- cond = FALSE;
- goto out;
- }
- ro = SWFDEC_AS_VALUE_GET_OBJECT (rval);
- } else if (SWFDEC_IS_MOVIE (ro)) {
- swfdec_as_value_to_primitive (lval);
- ltype = lval->type;
- if (ltype != SWFDEC_AS_TYPE_OBJECT) {
- cond = FALSE;
- goto out;
- }
- lo = SWFDEC_AS_VALUE_GET_OBJECT (lval);
- } else {
- lo = SWFDEC_AS_VALUE_GET_OBJECT (lval);
- ro = SWFDEC_AS_VALUE_GET_OBJECT (rval);
- }
- cond = lo == ro;
- goto out;
- }
-
- /* compare strings */
- if (ltype == SWFDEC_AS_TYPE_STRING && rtype == SWFDEC_AS_TYPE_STRING) {
- /* FIXME: flash 5 case insensitive? */
- cond = SWFDEC_AS_VALUE_GET_STRING (<mp) == SWFDEC_AS_VALUE_GET_STRING (&rtmp);
- goto out;
- }
-
- /* convert to numbers */
- if (SWFDEC_AS_VALUE_IS_OBJECT (<mp) && !SWFDEC_IS_MOVIE (SWFDEC_AS_VALUE_GET_OBJECT (<mp))) {
- l = swfdec_as_value_to_number (cx, lval);
- } else {
- l = swfdec_as_value_to_number (cx, <mp);
- }
- if (SWFDEC_AS_VALUE_IS_OBJECT (&rtmp) && !SWFDEC_IS_MOVIE (SWFDEC_AS_VALUE_GET_OBJECT (&rtmp))) {
- r = swfdec_as_value_to_number (cx, rval);
- } else {
- r = swfdec_as_value_to_number (cx, &rtmp);
- }
-
- /* get rid of undefined and null */
- cond = rtype == SWFDEC_AS_TYPE_UNDEFINED || rtype == SWFDEC_AS_TYPE_NULL;
- if (ltype == SWFDEC_AS_TYPE_UNDEFINED || ltype == SWFDEC_AS_TYPE_NULL) {
- goto out;
- } else if (cond) {
- cond = FALSE;
- goto out;
- }
-
- /* else compare as numbers */
- if (isnan (l) && isnan (r))
- cond = ltype == rtype;
- else
- cond = l == r;
-
-out:
- swfdec_as_stack_pop (cx);
- SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1), cond);
-}
-
-static void
-swfdec_action_equals2_6 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *rval, *lval;
- SwfdecAsValueType ltype, rtype;
- double l, r;
- gboolean cond;
-
- rval = swfdec_as_stack_peek (cx, 1);
- lval = swfdec_as_stack_peek (cx, 2);
- ltype = lval->type;
- rtype = rval->type;
-
- /* get objects compared */
- if (ltype == SWFDEC_AS_TYPE_OBJECT && rtype == SWFDEC_AS_TYPE_OBJECT) {
- SwfdecAsObject *lo = SWFDEC_AS_VALUE_GET_OBJECT (lval);
- SwfdecAsObject *ro = SWFDEC_AS_VALUE_GET_OBJECT (rval);
-
- if (SWFDEC_IS_MOVIE (lo) && SWFDEC_IS_MOVIE (ro)) {
- lo = SWFDEC_AS_OBJECT (swfdec_movie_resolve (SWFDEC_MOVIE (lo)));
- ro = SWFDEC_AS_OBJECT (swfdec_movie_resolve (SWFDEC_MOVIE (ro)));
- } else if (SWFDEC_IS_MOVIE (lo)) {
- swfdec_as_value_to_primitive (rval);
- rtype = rval->type;
- if (rtype != SWFDEC_AS_TYPE_OBJECT) {
- cond = FALSE;
- goto out;
- }
- ro = SWFDEC_AS_VALUE_GET_OBJECT (rval);
- } else if (SWFDEC_IS_MOVIE (ro)) {
- swfdec_as_value_to_primitive (lval);
- ltype = lval->type;
- if (ltype != SWFDEC_AS_TYPE_OBJECT) {
- cond = FALSE;
- goto out;
- }
- lo = SWFDEC_AS_VALUE_GET_OBJECT (lval);
- }
- cond = lo == ro;
- goto out;
- }
-
- /* if one of the values is an object, call valueOf.
- * If it's still an object, return FALSE */
- swfdec_as_value_to_primitive (lval);
- ltype = lval->type;
- if (ltype == SWFDEC_AS_TYPE_OBJECT) {
- cond = FALSE;
- goto out;
- }
- swfdec_as_value_to_primitive (rval);
- rtype = rval->type;
- if (rtype == SWFDEC_AS_TYPE_OBJECT) {
- cond = FALSE;
- goto out;
- }
- /* now we have a comparison without objects */
-
- /* get rid of undefined and null */
- cond = rtype == SWFDEC_AS_TYPE_UNDEFINED || rtype == SWFDEC_AS_TYPE_NULL;
- if (ltype == SWFDEC_AS_TYPE_UNDEFINED || ltype == SWFDEC_AS_TYPE_NULL) {
- goto out;
- } else if (cond) {
- cond = FALSE;
- goto out;
- }
-
- /* compare strings */
- if (ltype == SWFDEC_AS_TYPE_STRING && rtype == SWFDEC_AS_TYPE_STRING) {
- /* FIXME: flash 5 case insensitive? */
- cond = SWFDEC_AS_VALUE_GET_STRING (lval) == SWFDEC_AS_VALUE_GET_STRING (rval);
- goto out;
- }
-
- /* else compare as numbers */
- l = swfdec_as_value_to_number (cx, lval);
- r = swfdec_as_value_to_number (cx, rval);
-
- if (isnan (l) && isnan (r))
- cond = ltype == rtype;
- else
- cond = l == r;
-
-out:
- swfdec_as_stack_pop (cx);
- SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1), cond);
-}
-
-static void
-swfdec_action_equals2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- if (cx->version <= 5) {
- swfdec_action_equals2_5 (cx, action, data, len);
- } else {
- swfdec_action_equals2_6 (cx, action, data, len);
- }
-}
-
-static void
-swfdec_action_strict_equals (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *rval, *lval;
- gboolean cond;
-
- rval = swfdec_as_stack_peek (cx, 1);
- lval = swfdec_as_stack_peek (cx, 2);
-
- if (rval->type != lval->type) {
- cond = FALSE;
- } else {
- switch (rval->type) {
- case SWFDEC_AS_TYPE_UNDEFINED:
- case SWFDEC_AS_TYPE_NULL:
- cond = TRUE;
- break;
- case SWFDEC_AS_TYPE_BOOLEAN:
- cond = SWFDEC_AS_VALUE_GET_BOOLEAN (rval) == SWFDEC_AS_VALUE_GET_BOOLEAN (lval);
- break;
- case SWFDEC_AS_TYPE_NUMBER:
- {
- double l, r;
- r = SWFDEC_AS_VALUE_GET_NUMBER (rval);
- l = SWFDEC_AS_VALUE_GET_NUMBER (lval);
- cond = (l == r) || (isnan (l) && isnan (r));
- }
- break;
- case SWFDEC_AS_TYPE_STRING:
- cond = SWFDEC_AS_VALUE_GET_STRING (rval) == SWFDEC_AS_VALUE_GET_STRING (lval);
- break;
- case SWFDEC_AS_TYPE_OBJECT:
- {
- SwfdecAsObject *lo = SWFDEC_AS_VALUE_GET_OBJECT (lval);
- SwfdecAsObject *ro = SWFDEC_AS_VALUE_GET_OBJECT (rval);
- if (SWFDEC_IS_MOVIE (lo) && SWFDEC_IS_MOVIE (ro)) {
- cond = swfdec_movie_resolve (SWFDEC_MOVIE (lo)) == swfdec_movie_resolve (SWFDEC_MOVIE (ro));
- } else if (!SWFDEC_IS_MOVIE (lo) && !SWFDEC_IS_MOVIE (ro)) {
- cond = lo == ro;
- } else {
- cond = FALSE;
- }
- }
- break;
- case SWFDEC_AS_TYPE_INT:
- default:
- g_assert_not_reached ();
- cond = FALSE;
- }
- }
-
- swfdec_as_stack_pop (cx);
- SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1), cond);
-}
-
-static void
-swfdec_action_do_set_target (SwfdecAsContext *cx, const char *target, const char *end)
-{
- swfdec_as_frame_set_target (cx->frame, NULL);
-
- if (target != end) {
- SwfdecAsObject *o = swfdec_action_lookup_object (cx, NULL, target, end);
- if (o == NULL) {
- SWFDEC_WARNING ("target \"%s\" is not an object", target);
- } else if (!SWFDEC_IS_MOVIE (o)) {
- SWFDEC_FIXME ("target \"%s\" is not a movie, something weird is supposed to happen now", target);
- o = NULL;
- }
- swfdec_as_frame_set_target (cx->frame, o);
- }
-}
-
-static void
-swfdec_action_set_target (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- char *end;
-
- end = memchr (data, 0, len);
- if (end == NULL) {
- SWFDEC_ERROR ("SetTarget action does not specify a string");
- return;
- }
- swfdec_action_do_set_target (cx, (const char *) data, end);
-}
-
-static void
-swfdec_action_set_target2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- const char *s;
-
- s = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1));
- swfdec_action_do_set_target (cx, s, s + strlen (s));
- swfdec_as_stack_pop (cx);
-}
-
-static void
-swfdec_action_start_drag (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecRect rect, *rectp = NULL;
- SwfdecMovie *movie;
- gboolean center;
- guint stack_size = 3;
-
- swfdec_as_stack_ensure_size (cx, 3);
- center = swfdec_as_value_to_boolean (cx, swfdec_as_stack_peek (cx, 2));
- if (swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 3))) {
- swfdec_as_stack_ensure_size (cx, 7);
- rect.x0 = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 7));
- rect.y0 = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 6));
- rect.x1 = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 5));
- rect.y1 = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 4));
- swfdec_rect_scale (&rect, &rect, SWFDEC_TWIPS_SCALE_FACTOR);
- stack_size = 7;
- rectp = ▭
- }
- if (!SWFDEC_IS_PLAYER (cx)) {
- SWFDEC_ERROR ("called startDrag on a non-SwfdecPlayer");
- } else {
- movie = swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx), swfdec_as_stack_peek (cx, 1));
- if (movie != NULL) {
- swfdec_player_set_drag_movie (SWFDEC_PLAYER (cx), movie, center, rectp);
- } else {
- SWFDEC_ERROR ("startDrag on something not a Movie");
- }
- }
- swfdec_as_stack_pop_n (cx, stack_size);
-}
-
-static void
-swfdec_action_end_drag (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- if (SWFDEC_IS_PLAYER (cx)) {
- swfdec_player_set_drag_movie (SWFDEC_PLAYER (cx), NULL, FALSE, NULL);
- } else {
- SWFDEC_WARNING ("can't end a drag on non-players");
- }
-}
-
-static void
-swfdec_action_stop_sounds (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- if (SWFDEC_IS_PLAYER (cx)) {
- swfdec_player_stop_all_sounds (SWFDEC_PLAYER (cx));
- }
-}
-
-static void
-swfdec_action_new_object (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *constructor;
- SwfdecAsFunction *fun;
- guint n_args;
-
- swfdec_as_stack_ensure_size (cx, 2);
- swfdec_action_get_variable (cx, action, data, len);
- constructor = swfdec_as_stack_peek (cx, 1);
- n_args = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 2));
- n_args = MIN (swfdec_as_stack_get_size (cx) - 2, n_args);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (constructor) ||
- !SWFDEC_IS_AS_FUNCTION (fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (constructor))) {
- SWFDEC_WARNING ("not a constructor");
- goto fail;
- }
-
- swfdec_as_stack_pop_n (cx, 2);
- swfdec_as_object_create (fun, n_args, NULL, NULL);
- return;
-
-fail:
- swfdec_as_stack_pop_n (cx, n_args + 1);
- SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 1));
-}
-
-static void
-swfdec_action_new_method (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *constructor;
- SwfdecAsFunction *fun;
- guint n_args;
- const char *name;
-
- swfdec_as_stack_ensure_size (cx, 3);
- name = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1));
-
- constructor = swfdec_as_stack_peek (cx, 2);
- n_args = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 3));
- n_args = MIN (swfdec_as_stack_get_size (cx) - 3, n_args);
- if (name != SWFDEC_AS_STR_EMPTY) {
- if (!SWFDEC_AS_VALUE_IS_OBJECT (constructor)) {
- SWFDEC_WARNING ("NewMethod called without an object to get variable %s from", name);
- goto fail;
- }
- swfdec_as_object_get_variable (SWFDEC_AS_VALUE_GET_OBJECT (constructor),
- name, constructor);
- }
- if (!SWFDEC_AS_VALUE_IS_OBJECT (constructor) ||
- !SWFDEC_IS_AS_FUNCTION (fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (constructor))) {
- SWFDEC_WARNING ("%s is not a constructor", name);
- goto fail;
- }
-
- swfdec_as_stack_pop_n (cx, 3);
- swfdec_as_object_create (fun, n_args, NULL, NULL);
- return;
-
-fail:
- swfdec_as_stack_pop_n (cx, n_args + 2);
- SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 1));
-}
-
-static void
-swfdec_action_init_object (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsObject *object;
- guint i, n_args, size;
-
- n_args = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 1));
- swfdec_as_stack_pop (cx);
- if (n_args * 2 > swfdec_as_stack_get_size (cx)) {
- size = swfdec_as_stack_get_size (cx);
- SWFDEC_FIXME ("InitObject action with too small stack, help!");
- n_args = size / 2;
- size &= 1;
- } else {
- size = 0;
- }
-
- object = swfdec_as_object_new (cx);
- if (object == NULL)
- return;
- for (i = 0; i < n_args; i++) {
- const char *s = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 2));
- swfdec_as_object_set_variable (object, s, swfdec_as_stack_peek (cx, 1));
- swfdec_as_stack_pop_n (cx, 2);
- }
- swfdec_as_stack_pop_n (cx, size);
- SWFDEC_AS_VALUE_SET_OBJECT (swfdec_as_stack_push (cx), object);
-}
-
-static void
-swfdec_action_init_array (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- int i, n;
- SwfdecAsObject *array;
-
- swfdec_as_stack_ensure_size (cx, 1);
- n = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 1));
- swfdec_as_stack_pop (cx);
- array = swfdec_as_array_new (cx);
- if (array == NULL)
- return;
- /* NB: we can't increase the stack here, as the number can easily be MAXINT */
- for (i = 0; i < n && swfdec_as_stack_get_size (cx) > 0; i++) {
- swfdec_as_stack_ensure_size (cx, 1);
- swfdec_as_array_push (SWFDEC_AS_ARRAY (array), swfdec_as_stack_pop (cx));
- }
- if (i != n) {
- SwfdecAsValue val;
- SWFDEC_AS_VALUE_SET_INT (&val, i);
- swfdec_as_object_set_variable (array, SWFDEC_AS_STR_length, &val);
- }
- SWFDEC_AS_VALUE_SET_OBJECT (swfdec_as_stack_push (cx), array);
-}
-
-static void
-swfdec_action_define_function (SwfdecAsContext *cx, guint action,
- const guint8 *data, guint len)
-{
- char *function_name;
- const char *name = NULL;
- guint i, n_args, size, n_registers;
- SwfdecBits bits;
- SwfdecBuffer *buffer;
- SwfdecAsFunction *fun;
- SwfdecAsFrame *frame;
- SwfdecScript *script;
- guint flags = 0;
- SwfdecScriptArgument *args;
- gboolean v2 = (action == 0x8e);
-
- frame = cx->frame;
- swfdec_bits_init_data (&bits, data, len);
- function_name = swfdec_bits_get_string (&bits, cx->version);
- if (function_name == NULL) {
- SWFDEC_ERROR ("could not parse function name");
- return;
- }
- n_args = swfdec_bits_get_u16 (&bits);
- if (v2) {
- n_registers = swfdec_bits_get_u8 (&bits);
- if (n_registers == 0)
- n_registers = 4;
- flags = swfdec_bits_get_u16 (&bits);
- } else {
- n_registers = 5;
- }
- if (n_args) {
- args = g_new0 (SwfdecScriptArgument, n_args);
- for (i = 0; i < n_args && swfdec_bits_left (&bits); i++) {
- if (v2) {
- args[i].preload = swfdec_bits_get_u8 (&bits);
- if (args[i].preload && args[i].preload >= n_registers) {
- SWFDEC_ERROR ("argument %u cannot be preloaded into register %u out of %u",
- i, args[i].preload, n_registers);
- /* FIXME: figure out correct error handling here */
- args[i].preload = 0;
- }
- }
- args[i].name = swfdec_bits_get_string (&bits, cx->version);
- if (args[i].name == NULL || args[i].name == '\0') {
- SWFDEC_ERROR ("empty argument name not allowed");
- g_free (args);
- return;
- }
- /* FIXME: check duplicate arguments */
- }
- } else {
- args = NULL;
- }
- size = swfdec_bits_get_u16 (&bits);
- /* check the script can be created */
- if (frame->script->buffer->data + frame->script->buffer->length < frame->pc + 3 + len + size) {
- SWFDEC_ERROR ("size of function is too big");
- g_free (args);
- g_free (function_name);
- return;
- }
- /* create the script */
- buffer = swfdec_buffer_new_subbuffer (frame->script->buffer,
- frame->pc + 3 + len - frame->script->buffer->data, size);
- swfdec_bits_init (&bits, buffer);
- if (*function_name) {
- name = function_name;
- } else if (swfdec_as_stack_get_size (cx) > 0) {
- /* This is kind of a hack that uses a feature of the Adobe compiler:
- * foo = function () {} is compiled as these actions:
- * Push "foo", DefineFunction, SetVariable/SetMember
- * With this knowledge we can inspect the topmost stack member, since
- * it will contain the name this function will soon be assigned to.
- */
- if (SWFDEC_AS_VALUE_IS_STRING (swfdec_as_stack_peek (cx, 1)))
- name = SWFDEC_AS_VALUE_GET_STRING (swfdec_as_stack_peek (cx, 1));
- }
- if (name == NULL)
- name = "unnamed_function";
- script = swfdec_script_new_from_bits (&bits, name, cx->version);
- swfdec_buffer_unref (buffer);
- if (script == NULL) {
- SWFDEC_ERROR ("failed to create script");
- g_free (args);
- g_free (function_name);
- return;
- }
- if (frame->constant_pool_buffer)
- script->constant_pool = swfdec_buffer_ref (frame->constant_pool_buffer);
- script->flags = flags;
- script->n_registers = n_registers;
- script->n_arguments = n_args;
- script->arguments = args;
- /* see function-scope tests */
- if (cx->version > 5) {
- /* FIXME: or original target? */
- fun = swfdec_as_script_function_new (frame->original_target, frame->scope_chain, script);
- } else {
- fun = swfdec_as_script_function_new (frame->original_target, NULL, script);
- }
- if (fun == NULL)
- return;
- /* This is a hack that should only trigger for functions defined in the init scripts.
- * It is supposed to ensure that those functions inherit their target when being
- * called instead of when being defined */
- if (!SWFDEC_IS_MOVIE (frame->original_target))
- SWFDEC_AS_SCRIPT_FUNCTION (fun)->target = NULL;
- /* attach the function */
- if (*function_name == '\0') {
- swfdec_as_stack_ensure_free (cx, 1);
- SWFDEC_AS_VALUE_SET_OBJECT (swfdec_as_stack_push (cx), SWFDEC_AS_OBJECT (fun));
- } else {
- SwfdecAsValue funval;
- /* FIXME: really varobj? Not eval or sth like that? */
- name = swfdec_as_context_get_string (cx, function_name);
- SWFDEC_AS_VALUE_SET_OBJECT (&funval, SWFDEC_AS_OBJECT (fun));
- swfdec_as_object_set_variable (frame->target, name, &funval);
- }
-
- /* update current context */
- frame->pc += 3 + len + size;
- g_free (function_name);
-}
-
-static void
-swfdec_action_bitwise (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- int a, b;
-
- a = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 1));
- b = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 2));
-
- switch (action) {
- case 0x60:
- a = (int) (a & b);
- break;
- case 0x61:
- a = (int) (a | b);
- break;
- case 0x62:
- a = (int) (a ^ b);
- break;
- default:
- g_assert_not_reached ();
- break;
- }
-
- swfdec_as_stack_pop (cx);
- SWFDEC_AS_VALUE_SET_INT (swfdec_as_stack_peek (cx, 1), a);
-}
-
-static void
-swfdec_action_shift (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- int amount, value;
-
- amount = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 1));
- amount &= 31;
- value = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 2));
-
- switch (action) {
- case 0x63:
- value = value << amount;
- break;
- case 0x64:
- value = ((gint) value) >> amount;
- break;
- case 0x65:
- value = ((guint) value) >> amount;
- break;
- default:
- g_assert_not_reached ();
- }
-
- swfdec_as_stack_pop (cx);
- SWFDEC_AS_VALUE_SET_INT (swfdec_as_stack_peek (cx, 1), value);
-}
-
-static void
-swfdec_action_to_integer (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *val = swfdec_as_stack_peek (cx, 1);
-
- SWFDEC_AS_VALUE_SET_INT (val, swfdec_as_value_to_integer (cx, val));
-}
-
-static void
-swfdec_action_target_path (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *val;
- SwfdecMovie *movie;
- char *s;
-
- val = swfdec_as_stack_peek (cx, 1);
-
- if (!SWFDEC_AS_VALUE_IS_OBJECT (val) ||
- !SWFDEC_IS_MOVIE (movie = (SwfdecMovie *) SWFDEC_AS_VALUE_GET_OBJECT (val))) {
- SWFDEC_AS_VALUE_SET_UNDEFINED (val);
- return;
- }
- s = swfdec_movie_get_path (movie, TRUE);
- SWFDEC_AS_VALUE_SET_STRING (val, swfdec_as_context_give_string (cx, s));
-}
-
-static void
-swfdec_action_define_local (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsObject *target;
- const char *name;
-
- name = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 2));
- if (cx->frame->is_local) {
- target = SWFDEC_AS_OBJECT (cx->frame);
- } else {
- target = cx->frame->target;
- }
- swfdec_as_object_set_variable (target, name,
- swfdec_as_stack_peek (cx, 1));
- swfdec_as_stack_pop_n (cx, 2);
-}
-
-static void
-swfdec_action_define_local2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue val = { 0, };
- SwfdecAsObject *target;
- const char *name;
-
- name = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1));
- if (cx->frame->is_local) {
- target = SWFDEC_AS_OBJECT (cx->frame);
- } else {
- target = cx->frame->target;
- }
- swfdec_as_object_set_variable (target, name, &val);
- swfdec_as_stack_pop (cx);
-}
-
-static void
-swfdec_action_return (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- swfdec_as_frame_return (cx->frame, swfdec_as_stack_pop (cx));
-}
-
-static void
-swfdec_action_delete (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *val;
- const char *name;
- gboolean success = FALSE;
-
- name = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1));
- val = swfdec_as_stack_peek (cx, 2);
- if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
- success = swfdec_as_object_delete_variable (
- SWFDEC_AS_VALUE_GET_OBJECT (val), name) == SWFDEC_AS_DELETE_DELETED;
- }
- SWFDEC_AS_VALUE_SET_BOOLEAN (val, success);
- swfdec_as_stack_pop_n (cx, 1);
-}
-
-static void
-swfdec_action_delete2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *val;
- const char *name;
- gboolean success = FALSE;
-
- val = swfdec_as_stack_peek (cx, 1);
- name = swfdec_as_value_to_string (cx, val);
- success = swfdec_as_frame_delete_variable (cx->frame, name) == SWFDEC_AS_DELETE_DELETED;
- SWFDEC_AS_VALUE_SET_BOOLEAN (val, success);
-}
-
-static void
-swfdec_action_store_register (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- if (len != 1) {
- SWFDEC_ERROR ("StoreRegister action requires a length of 1, but got %u", len);
- return;
- }
- if (!swfdec_action_has_register (cx, *data)) {
- SWFDEC_ERROR ("Cannot store into register %u, not enough registers", (guint) *data);
- return;
- }
- cx->frame->registers[*data] = *swfdec_as_stack_peek (cx, 1);
-}
-
-static void
-swfdec_action_modulo (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- double x, y;
-
- y = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 1));
- x = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 2));
- /* yay, we're portable! */
- if (y == 0.0) {
- x = NAN;
- } else {
- errno = 0;
- x = fmod (x, y);
- if (errno != 0) {
- SWFDEC_FIXME ("errno set after fmod");
- }
- }
- swfdec_as_stack_pop (cx);
- SWFDEC_AS_VALUE_SET_NUMBER (swfdec_as_stack_peek (cx, 1), x);
-}
-
-static void
-swfdec_action_swap (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- swfdec_as_stack_swap (cx, 1, 2);
-}
-
-static void
-swfdec_action_to_number (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SWFDEC_AS_VALUE_SET_NUMBER (swfdec_as_stack_peek (cx, 1),
- swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 1)));
-}
-
-static void
-swfdec_action_to_string (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_peek (cx, 1),
- swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1)));
-}
-
-static void
-swfdec_action_type_of (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *val;
- const char *type;
-
- val = swfdec_as_stack_peek (cx, 1);
- switch (val->type) {
- case SWFDEC_AS_TYPE_NUMBER:
- type = SWFDEC_AS_STR_number;
- break;
- case SWFDEC_AS_TYPE_BOOLEAN:
- type = SWFDEC_AS_STR_boolean;
- break;
- case SWFDEC_AS_TYPE_STRING:
- type = SWFDEC_AS_STR_string;
- break;
- case SWFDEC_AS_TYPE_UNDEFINED:
- type = SWFDEC_AS_STR_undefined;
- break;
- case SWFDEC_AS_TYPE_NULL:
- type = SWFDEC_AS_STR_null;
- break;
- case SWFDEC_AS_TYPE_OBJECT:
- {
- SwfdecAsObject *obj = SWFDEC_AS_VALUE_GET_OBJECT (val);
- if (SWFDEC_IS_MOVIE (obj)) {
- if (SWFDEC_IS_TEXT_FIELD_MOVIE (obj)) {
- type = SWFDEC_AS_STR_object;
- } else {
- type = SWFDEC_AS_STR_movieclip;
- }
- } else if (SWFDEC_IS_AS_FUNCTION (obj)) {
- type = SWFDEC_AS_STR_function;
- } else {
- type = SWFDEC_AS_STR_object;
- }
- }
- break;
- case SWFDEC_AS_TYPE_INT:
- default:
- g_assert_not_reached ();
- type = SWFDEC_AS_STR_EMPTY;
- break;
- }
- SWFDEC_AS_VALUE_SET_STRING (val, type);
-}
-
-static void
-swfdec_action_get_time (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- GTimeVal tv;
- gulong diff;
-
- swfdec_as_context_get_time (cx, &tv);
- /* we assume here that swfdec_as_context_get_time always returns a tv > start_time */
- diff = tv.tv_sec - cx->start_time.tv_sec;
- if (diff > G_MAXULONG / 1000 - 1) {
- SWFDEC_ERROR ("FIXME: time overflow");
- }
- diff *= 1000;
- diff = diff + (tv.tv_usec - cx->start_time.tv_usec) / 1000;
-
- SWFDEC_AS_VALUE_SET_INT (swfdec_as_stack_push (cx), diff);
-}
-
-static gboolean
-swfdec_action_is_instance_of (SwfdecAsObject *object,
- SwfdecAsObject *constructor)
-{
- SwfdecAsValue val;
- SwfdecAsObject *class, *prototype;
- GSList *iter;
-
- g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), FALSE);
- g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (constructor), FALSE);
-
- // FIXME: propflag tests are wrong, and we shouldn't get __proto__.prototype
- swfdec_as_object_get_variable (constructor, SWFDEC_AS_STR_prototype, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return FALSE;
- prototype = SWFDEC_AS_VALUE_GET_OBJECT (&val);
-
- class = object;
- while ((class = swfdec_as_object_get_prototype (class)) != NULL) {
- if (class == prototype)
- return TRUE;
- for (iter = class->interfaces; iter != NULL; iter = iter->next) {
- if (iter->data == prototype)
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-static void
-swfdec_action_instance_of (SwfdecAsContext *cx, guint action,
- const guint8 *data, guint len)
-{
- SwfdecAsValue *val;
- SwfdecAsObject *object, *constructor;
-
- val = swfdec_as_stack_pop (cx);
- if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
- constructor = SWFDEC_AS_VALUE_GET_OBJECT (val);
- } else {
- constructor = NULL;
- }
-
- val = swfdec_as_stack_pop (cx);
- if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
- object = SWFDEC_AS_VALUE_GET_OBJECT (val);
- } else {
- object = NULL;
- }
-
-
- if (object == NULL || constructor == NULL) {
- SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_push (cx), FALSE);
- return;
- }
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_push (cx),
- swfdec_action_is_instance_of (object, constructor));
-}
-
-static void
-swfdec_action_cast (SwfdecAsContext *cx, guint action, const guint8 *data,
- guint len)
-{
- SwfdecAsValue *val;
- SwfdecAsObject *object, *constructor;
-
- val = swfdec_as_stack_pop (cx);
- if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
- object = SWFDEC_AS_VALUE_GET_OBJECT (val);
- } else {
- object = NULL;
- }
-
- val = swfdec_as_stack_pop (cx);
- if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
- constructor = SWFDEC_AS_VALUE_GET_OBJECT (val);
- } else {
- constructor = NULL;
- }
-
- if (object == NULL || constructor == NULL) {
- SWFDEC_AS_VALUE_SET_NULL (swfdec_as_stack_push (cx));
- return;
- }
-
- if (swfdec_action_is_instance_of (object, constructor)) {
- SWFDEC_AS_VALUE_SET_OBJECT (swfdec_as_stack_push (cx), object);
- } else {
- SWFDEC_AS_VALUE_SET_NULL (swfdec_as_stack_push (cx));
- }
-}
-
-static void
-swfdec_action_implements (SwfdecAsContext *cx, guint action,
- const guint8 *data, guint len)
-{
- SwfdecAsValue *val, *argv;
- SwfdecAsObject *object, *proto, *interface;
- int argc, i;
-
- swfdec_as_stack_ensure_size (cx, 2);
-
- val = swfdec_as_stack_pop (cx);
- if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
- object = SWFDEC_AS_VALUE_GET_OBJECT (val);
- swfdec_as_object_get_variable (object, SWFDEC_AS_STR_prototype, val);
- if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
- proto = SWFDEC_AS_VALUE_GET_OBJECT (val);
- } else {
- proto = NULL;
- }
- } else {
- object = NULL;
- proto = NULL;
- }
-
- val = swfdec_as_stack_pop (cx);
- argc = swfdec_as_value_to_integer (cx, val);
-
- if (argc > 0) {
- swfdec_as_stack_ensure_size (cx, argc);
- argv = swfdec_as_stack_pop_n (cx, argc);
- } else {
- argv = NULL;
- }
-
- if (proto == NULL)
- return;
-
- for (i = 0; i < argc; i++) {
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[i]))
- continue;
- interface = SWFDEC_AS_VALUE_GET_OBJECT (&argv[i]);
- swfdec_as_object_get_variable (interface, SWFDEC_AS_STR_prototype, val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (val))
- continue;
- proto->interfaces =
- g_slist_prepend (proto->interfaces, SWFDEC_AS_VALUE_GET_OBJECT (val));
- }
-}
-
-static void
-swfdec_action_extends (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *superclass, *subclass, proto;
- SwfdecAsObject *prototype;
- SwfdecAsObject *super;
-
- superclass = swfdec_as_stack_peek (cx, 1);
- subclass = swfdec_as_stack_peek (cx, 2);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (superclass) ||
- !SWFDEC_IS_AS_FUNCTION (SWFDEC_AS_VALUE_GET_OBJECT (superclass))) {
- SWFDEC_ERROR ("superclass is not a function");
- goto fail;
- }
- if (!SWFDEC_AS_VALUE_IS_OBJECT (subclass)) {
- SWFDEC_ERROR ("subclass is not an object");
- goto fail;
- }
- super = SWFDEC_AS_VALUE_GET_OBJECT (superclass);
- prototype = swfdec_as_object_new_empty (cx);
- if (prototype == NULL)
- goto fail;
- swfdec_as_object_get_variable (super, SWFDEC_AS_STR_prototype, &proto);
- swfdec_as_object_set_variable (prototype, SWFDEC_AS_STR___proto__, &proto);
- if (cx->version > 5) {
- swfdec_as_object_set_variable_and_flags (prototype, SWFDEC_AS_STR___constructor__,
- superclass, SWFDEC_AS_VARIABLE_HIDDEN);
- }
- SWFDEC_AS_VALUE_SET_OBJECT (&proto, prototype);
- swfdec_as_object_set_variable (SWFDEC_AS_VALUE_GET_OBJECT (subclass),
- SWFDEC_AS_STR_prototype, &proto);
-fail:
- swfdec_as_stack_pop_n (cx, 2);
-}
-
-static gboolean
-swfdec_action_enumerate_foreach (SwfdecAsObject *object, const char *variable,
- SwfdecAsValue *value, guint flags, gpointer listp)
-{
- GSList **list = listp;
-
- if (flags & SWFDEC_AS_VARIABLE_HIDDEN)
- return TRUE;
-
- *list = g_slist_remove (*list, variable);
- *list = g_slist_prepend (*list, (gpointer) variable);
- return TRUE;
-}
-
-static void
-swfdec_action_do_enumerate (SwfdecAsContext *cx, SwfdecAsObject *object)
-{
- guint i;
- GSList *walk, *list = NULL;
-
- for (i = 0; i < 256 && object; i++) {
- swfdec_as_object_foreach (object, swfdec_action_enumerate_foreach, &list);
- object = swfdec_as_object_get_prototype (object);
- }
- if (i == 256) {
- swfdec_as_context_abort (object->context, "Prototype recursion limit exceeded");
- g_slist_free (list);
- return;
- }
- list = g_slist_reverse (list);
- i = 0;
- for (walk = list; walk; walk = walk->next) {
- /* 8 is an arbitrary value */
- if (i % 8 == 0) {
- swfdec_as_stack_ensure_free (cx, 8);
- i = 0;
- }
- i++;
- SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_push (cx), walk->data);
- }
- g_slist_free (list);
-}
-
-static void
-swfdec_action_enumerate2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *val;
- SwfdecAsObject *obj;
-
- val = swfdec_as_stack_peek (cx, 1);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (val)) {
- SWFDEC_WARNING ("Enumerate called without an object");
- SWFDEC_AS_VALUE_SET_UNDEFINED (val);
- return;
- }
- obj = SWFDEC_AS_VALUE_GET_OBJECT (val);
- SWFDEC_AS_VALUE_SET_UNDEFINED (val);
- swfdec_action_do_enumerate (cx, obj);
-}
-
-static void
-swfdec_action_enumerate (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- /* FIXME: make this proper functions */
- swfdec_action_get_variable (cx, action, data, len);
- swfdec_action_enumerate2 (cx, action, data, len);
-}
-
-static void
-swfdec_action_logical (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- gboolean l, r;
-
- if (cx->version <= 4) {
- l = (swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 1)) != 0);
- // don't call second parameter if not necessary
- if ((action == SWFDEC_AS_ACTION_AND && !l) ||
- (action != SWFDEC_AS_ACTION_AND && l)) {
- r = (swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 2)) != 0);
- } else {
- r = FALSE;
- }
- } else {
- l = swfdec_as_value_to_boolean (cx, swfdec_as_stack_peek (cx, 1));
- r = swfdec_as_value_to_boolean (cx, swfdec_as_stack_peek (cx, 2));
- }
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 2),
- (action == SWFDEC_AS_ACTION_AND) ? (l && r) : (l || r));
- swfdec_as_stack_pop (cx);
-}
-
-static void
-swfdec_action_char_to_ascii (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *val = swfdec_as_stack_peek (cx, 1);
- const char *s = swfdec_as_value_to_string (cx, val);
-
- if (cx->version <= 5) {
- char *ascii = g_convert (s, -1, "LATIN1", "UTF-8", NULL, NULL, NULL);
-
- if (ascii == NULL) {
- /* This can happen if a Flash 5 movie gets loaded into a Flash 7 movie */
- SWFDEC_FIXME ("Someone threw unconvertible text %s at Flash <= 5", s);
- SWFDEC_AS_VALUE_SET_INT (val, 0); /* FIXME: what to return??? */
- } else {
- SWFDEC_AS_VALUE_SET_INT (val, (guchar) ascii[0]);
- g_free (ascii);
- }
- } else {
- gunichar *uni = g_utf8_to_ucs4_fast (s, -1, NULL);
-
- if (uni == NULL) {
- /* This should never happen, everything is valid UTF-8 in here */
- g_warning ("conversion of character %s failed", s);
- SWFDEC_AS_VALUE_SET_INT (val, 0);
- } else {
- SWFDEC_AS_VALUE_SET_INT (val, uni[0]);
- g_free (uni);
- }
- }
-}
-
-static void
-swfdec_action_ascii_to_char (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsValue *val = swfdec_as_stack_peek (cx, 1);
-
- if (cx->version <= 5) {
- char s[3];
- char *utf8;
- guint i;
-
- if (action == SWFDEC_AS_ACTION_ASCII_TO_CHAR) {
- s[0] = ((guint) swfdec_as_value_to_integer (cx, val)) % 256;
- s[1] = 0;
- } else {
- g_assert (action == SWFDEC_AS_ACTION_MB_ASCII_TO_CHAR);
-
- i = ((guint) swfdec_as_value_to_integer (cx, val));
- if (i > 255) {
- s[0] = i / 256;
- s[1] = i % 256;
- s[2] = 0;
- } else {
- s[0] = i;
- s[1] = 0;
- }
- }
-
- utf8 = g_convert (s, -1, "UTF-8", "LATIN1", NULL, NULL, NULL);
- if (utf8 == NULL) {
- g_warning ("conversion of character %u failed", (guint) s[0]);
- SWFDEC_AS_VALUE_SET_STRING (val, SWFDEC_AS_STR_EMPTY);
- } else {
- SWFDEC_AS_VALUE_SET_STRING (val, swfdec_as_context_get_string (cx, utf8));
- g_free (utf8);
- }
- } else {
- char *s;
- gunichar c = ((guint) swfdec_as_value_to_integer (cx, val)) % 65536;
-
- s = g_ucs4_to_utf8 (&c, 1, NULL, NULL, NULL);
- if (s == NULL) {
- g_warning ("conversion of character %u failed", (guint) c);
- SWFDEC_AS_VALUE_SET_STRING (val, SWFDEC_AS_STR_EMPTY);
- } else {
- SWFDEC_AS_VALUE_SET_STRING (val, swfdec_as_context_get_string (cx, s));
- g_free (s);
- }
- }
-}
-
-static void
-swfdec_action_throw (SwfdecAsContext *cx, guint action, const guint8 *data,
- guint len)
-{
- swfdec_as_context_throw (cx, swfdec_as_stack_pop (cx));
-}
-
-typedef struct {
- const guint8 * catch_start;
- const guint8 * finally_start;
- guint catch_size;
- guint finally_size;
-
- gboolean use_register;
- union {
- guint register_number;
- char * variable_name;
- };
-} TryData;
-
-static void
-swfdec_action_try_data_free (gpointer data)
-{
- TryData *try_data = data;
-
- g_return_if_fail (try_data != NULL);
-
- if (!try_data->use_register)
- g_free (try_data->variable_name);
- g_free (try_data);
-}
-
-static void
-swfdec_action_try_end_finally (SwfdecAsFrame *frame, gpointer data)
-{
- SwfdecAsValue *exception_value = data;
- SwfdecAsContext *cx;
-
- g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
- g_return_if_fail (SWFDEC_IS_AS_VALUE (exception_value));
-
- cx = SWFDEC_AS_OBJECT (frame)->context;
-
- // finally has ended and we had exception stored, throw it
- if (!cx->exception)
- swfdec_as_context_throw (cx, exception_value);
-
- g_free (data);
-}
-
-static void
-swfdec_action_try_end_catch (SwfdecAsFrame *frame, gpointer data)
-{
- TryData *try_data = data;
- SwfdecAsContext *cx;
- SwfdecAsValue *exception_value, val;
-
- g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
- g_return_if_fail (try_data != NULL);
-
- cx = SWFDEC_AS_OBJECT (frame)->context;
-
- if (swfdec_as_context_catch (cx, &val))
- {
- // we got an exception while in catch block:
- // create new block for finally to pass on the exception
- // jump to that block
-
- exception_value = g_malloc (sizeof (SwfdecAsValue));
- *exception_value = val;
-
- // FIXME: the exception value is not marked while finally block runs
- swfdec_as_frame_push_block (frame, try_data->finally_start,
- try_data->finally_start + try_data->finally_size,
- swfdec_action_try_end_finally, exception_value);
- frame->pc = try_data->finally_start;
- }
-
- swfdec_action_try_data_free (try_data);
-}
-
-static void
-swfdec_action_try_end_try (SwfdecAsFrame *frame, gpointer data)
-{
- TryData *try_data = data;
- SwfdecAsContext *cx;
- SwfdecAsValue val;
-
- g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
- g_return_if_fail (try_data != NULL);
-
- // if we don't have a catch block, we handle try block exactly like it was
- // catch block
- if (!try_data->catch_start) {
- swfdec_action_try_end_catch (frame, try_data);
- return;
- }
-
- cx = SWFDEC_AS_OBJECT (frame)->context;
-
- if (swfdec_as_context_catch (cx, &val))
- {
- // we got an exception while in try block:
- // set the exception variable
- // add new block for catch and jump to it
-
- if (try_data->use_register)
- {
- if (try_data->register_number < frame->n_registers) {
- frame->registers[try_data->register_number] = val;
- } else {
- SWFDEC_ERROR ("cannot set Error to register %u: not enough registers",
- try_data->register_number);
- }
- }
- else
- {
- // FIXME: this is duplicate of SetVariable
- SwfdecAsObject *object;
- const char *s, *rest;
-
- s = swfdec_as_context_get_string (cx, try_data->variable_name);
- if (swfdec_action_get_movie_by_path (cx, s, &object, &rest)) {
- if (object && rest) {
- swfdec_as_object_set_variable (object,
- swfdec_as_context_get_string (cx, rest), &val);
- } else {
- if (object) {
- rest = s;
- } else {
- rest = swfdec_as_context_get_string (cx, rest);
- }
- swfdec_as_frame_set_variable (frame, rest, &val);
- }
- }
- else
- {
- SWFDEC_ERROR ("cannot set Error to variable %s",
- try_data->variable_name);
- }
- }
-
- swfdec_as_frame_push_block (frame, try_data->catch_start,
- try_data->catch_start + try_data->catch_size,
- swfdec_action_try_end_catch, try_data);
- frame->pc = try_data->catch_start;
- }
- else
- {
- swfdec_action_try_data_free (try_data);
- }
-}
-
-static void
-swfdec_action_try (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecBits bits;
- TryData *try_data;
- guint try_size;
- gboolean use_finally, use_catch;
-
- if (len < 8) {
- SWFDEC_ERROR ("With action requires a length of at least 8, but got %u",
- len);
- return;
- }
-
- try_data = g_malloc0 (sizeof (TryData));
-
- swfdec_bits_init_data (&bits, data, len);
-
- swfdec_bits_getbits (&bits, 5); // reserved
- try_data->use_register = swfdec_bits_getbit (&bits);
- use_finally = swfdec_bits_getbit (&bits);
- use_catch = swfdec_bits_getbit (&bits);
-
- try_size = swfdec_bits_get_u16 (&bits);
- try_data->catch_size = swfdec_bits_get_u16 (&bits);
- try_data->finally_size = swfdec_bits_get_u16 (&bits);
- if (use_catch)
- try_data->catch_start = data + len + try_size;
- if (use_finally)
- try_data->finally_start = try_data->catch_start + try_data->catch_size;
-
- if (try_data->use_register) {
- try_data->register_number = swfdec_bits_get_u8 (&bits);
- } else {
- try_data->variable_name =
- swfdec_bits_get_string (&bits, cx->version);
- }
-
- if (swfdec_bits_left (&bits)) {
- SWFDEC_WARNING ("leftover bytes in Try action");
- }
-
- if (try_data->catch_start || try_data->finally_start) {
- swfdec_as_frame_push_block (cx->frame, data + len, data + len + try_size,
- swfdec_action_try_end_try, try_data);
- } else {
- SWFDEC_WARNING ("Try with neither catch nor finally block");
- swfdec_action_try_data_free (try_data);
- }
-}
-
-static void
-swfdec_action_pop_with (SwfdecAsFrame *frame, gpointer with_object)
-{
- g_assert (frame->scope_chain->data == with_object);
- frame->scope_chain = g_slist_delete_link (frame->scope_chain, frame->scope_chain);
-}
-
-static void
-swfdec_action_with (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecAsObject *object;
- guint offset;
-
- if (len != 2) {
- SWFDEC_ERROR ("With action requires a length of 2, but got %u", len);
- swfdec_as_stack_pop (cx);
- return;
- }
- offset = data[0] | (data[1] << 8);
- object = swfdec_as_value_to_object (cx, swfdec_as_stack_peek (cx, 1));
- if (object == NULL) {
- SWFDEC_INFO ("With called without an object, skipping");
- cx->frame->pc = (guint8 *) data + len + offset;
- } else {
- cx->frame->scope_chain = g_slist_prepend (cx->frame->scope_chain, object);
- swfdec_as_frame_push_block (cx->frame, data + len, data + len + offset,
- swfdec_action_pop_with, object);
- }
- swfdec_as_stack_pop (cx);
-}
-
-static void
-swfdec_action_remove_sprite (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- if (!SWFDEC_IS_MOVIE (cx->frame->target)) {
- SWFDEC_FIXME ("target is not a movie in RemoveSprite");
- } else if (!SWFDEC_IS_PLAYER (cx)) {
- SWFDEC_INFO ("tried using RemoveSprite in a non-SwfdecPlayer context");
- } else {
- SwfdecMovie *movie = swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx),
- swfdec_as_stack_peek (cx, 1));
- if (movie && swfdec_depth_classify (movie->depth) == SWFDEC_DEPTH_CLASS_DYNAMIC) {
- SWFDEC_LOG ("removing clip %s", movie->name);
- swfdec_movie_remove (movie);
- } else {
- SWFDEC_INFO ("cannot remove movie");
- }
- }
- swfdec_as_stack_pop (cx);
-}
-
-static void
-swfdec_action_clone_sprite (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
-{
- SwfdecMovie *movie, *new_movie;
- const char *new_name;
- int depth;
-
- depth = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 1)) - 16384;
- new_name = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 2));
- if (!SWFDEC_IS_MOVIE (cx->frame->target)) {
- SWFDEC_FIXME ("target is not a movie in CloneSprite");
- } else if (!SWFDEC_IS_PLAYER (cx)) {
- SWFDEC_INFO ("tried using CloneSprite in a non-SwfdecPlayer context");
- } else {
- movie = swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx),
- swfdec_as_stack_peek (cx, 3));
- if (movie == NULL) {
- SWFDEC_ERROR ("Object is not an SwfdecMovie object");
- swfdec_as_stack_pop_n (cx, 3);
- return;
- }
- new_movie = swfdec_movie_duplicate (movie, new_name, depth);
- if (new_movie) {
- SWFDEC_LOG ("duplicated %s as %s to depth %u", movie->name, new_movie->name, new_movie->depth);
- }
- }
- swfdec_as_stack_pop_n (cx, 3);
-}
-
-/*** PRINT FUNCTIONS ***/
-
-static char *
-swfdec_action_print_with (guint action, const guint8 *data, guint len)
-{
- if (len != 2) {
- SWFDEC_ERROR ("With action requires a length of 2, but got %u", len);
- return NULL;
- }
- return g_strdup_printf ("With %u", data[0] | (data[1] << 8));
-}
-
-static char *
-swfdec_action_print_store_register (guint action, const guint8 *data, guint len)
-{
- if (len != 1) {
- SWFDEC_ERROR ("StoreRegister action requires a length of 1, but got %u", len);
- return NULL;
- }
- return g_strdup_printf ("StoreRegister %u", (guint) *data);
-}
-
-static char *
-swfdec_action_print_set_target (guint action, const guint8 *data, guint len)
-{
- if (!memchr (data, 0, len)) {
- SWFDEC_ERROR ("SetTarget action does not specify a string");
- return NULL;
- }
- return g_strconcat ("SetTarget ", data, NULL);
-}
-
-static char *
-swfdec_action_print_define_function (guint action, const guint8 *data, guint len)
-{
- SwfdecBits bits;
- GString *string;
- const char *function_name;
- guint i, n_args, size;
- gboolean v2 = (action == 0x8e);
-
- string = g_string_new (v2 ? "DefineFunction2 " : "DefineFunction ");
- swfdec_bits_init_data (&bits, data, len);
- /* FIXME: version! */
- function_name = swfdec_bits_get_string (&bits, 7);
- if (function_name == NULL) {
- SWFDEC_ERROR ("could not parse function name");
- g_string_free (string, TRUE);
- return NULL;
- }
- if (*function_name) {
- g_string_append (string, function_name);
- g_string_append_c (string, ' ');
- }
- n_args = swfdec_bits_get_u16 (&bits);
- g_string_append_c (string, '(');
- if (v2) {
- /* n_regs = */ swfdec_bits_get_u8 (&bits);
- /* flags = */ swfdec_bits_get_u16 (&bits);
- }
-
- for (i = 0; i < n_args; i++) {
- guint preload;
- const char *arg_name;
- if (v2)
- preload = swfdec_bits_get_u8 (&bits);
- else
- preload = 0;
- arg_name = swfdec_bits_get_string (&bits, 7);
- if (preload == 0 && (arg_name == NULL || *arg_name == '\0')) {
- SWFDEC_ERROR ("empty argument name not allowed");
- g_string_free (string, TRUE);
- return NULL;
- }
- if (i)
- g_string_append (string, ", ");
- g_string_append (string, arg_name);
- if (preload)
- g_string_append_printf (string, " (%u)", preload);
- }
- g_string_append_c (string, ')');
- size = swfdec_bits_get_u16 (&bits);
- g_string_append_printf (string, " %u", size);
- return g_string_free (string, FALSE);
-}
-
-static char *
-swfdec_action_print_get_url2 (guint action, const guint8 *data, guint len)
-{
- guint method;
-
- if (len != 1) {
- SWFDEC_ERROR ("GetURL2 requires 1 byte of data, not %u", len);
- return NULL;
- }
- method = data[0] >> 6;
- if (method == 3) {
- SWFDEC_ERROR ("GetURL method 3 invalid");
- method = 0;
- }
- if (method) {
- SWFDEC_FIXME ("implement encoding variables using %s", method == 1 ? "GET" : "POST");
- }
- return g_strdup_printf ("GetURL2%s%s%s", method == 0 ? "" : (method == 1 ? " GET" : " POST"),
- data[0] & 2 ? " LoadTarget" : "", data[0] & 1 ? " LoadVariables" : "");
-}
-
-static char *
-swfdec_action_print_get_url (guint action, const guint8 *data, guint len)
-{
- SwfdecBits bits;
- char *url, *target, *ret;
-
- swfdec_bits_init_data (&bits, data, len);
- url = swfdec_bits_get_string (&bits, 7);
- target = swfdec_bits_get_string (&bits, 7);
- if (url == NULL) {
- SWFDEC_ERROR ("not enough data in GetURL");
- url = g_strdup ("???");
- }
- if (target == NULL) {
- SWFDEC_ERROR ("not enough data in GetURL");
- target = g_strdup ("???");
- }
- if (swfdec_bits_left (&bits)) {
- SWFDEC_WARNING ("leftover bytes in GetURL action");
- }
- ret = g_strdup_printf ("GetURL %s %s", url, target);
- g_free (url);
- g_free (target);
- return ret;
-}
-
-static char *
-swfdec_action_print_if (guint action, const guint8 *data, guint len)
-{
- gint16 offset;
-
- if (len != 2) {
- SWFDEC_ERROR ("If action length invalid (is %u, should be 2", len);
- return NULL;
- }
- offset = data[0] | (data[1] << 8);
- return g_strdup_printf ("If %d", (int) offset);
-}
-
-static char *
-swfdec_action_print_jump (guint action, const guint8 *data, guint len)
-{
- gint16 offset;
-
- if (len != 2) {
- SWFDEC_ERROR ("Jump action length invalid (is %u, should be 2", len);
- return NULL;
- }
- offset = data[0] | (data[1] << 8);
- return g_strdup_printf ("Jump %d", (int) offset);
-}
-
-static char *
-swfdec_action_print_push (guint action, const guint8 *data, guint len)
-{
- gboolean first = TRUE;
- SwfdecBits bits;
- GString *string = g_string_new ("Push");
-
- swfdec_bits_init_data (&bits, data, len);
- while (swfdec_bits_left (&bits)) {
- guint type = swfdec_bits_get_u8 (&bits);
- if (first)
- g_string_append (string, " ");
- else
- g_string_append (string, ", ");
- first = FALSE;
- switch (type) {
- case 0: /* string */
- {
- /* FIXME: need version! */
- char *s = swfdec_bits_get_string (&bits, 7);
- if (!s) {
- g_string_free (string, TRUE);
- return NULL;
- }
- g_string_append_c (string, '"');
- g_string_append (string, s);
- g_string_append_c (string, '"');
- g_free (s);
- break;
- }
- case 1: /* float */
- g_string_append_printf (string, "%g", swfdec_bits_get_float (&bits));
- break;
- case 2: /* null */
- g_string_append (string, "null");
- break;
- case 3: /* undefined */
- g_string_append (string, "void");
- break;
- case 4: /* register */
- g_string_append_printf (string, "Register %u", swfdec_bits_get_u8 (&bits));
- break;
- case 5: /* boolean */
- g_string_append (string, swfdec_bits_get_u8 (&bits) ? "True" : "False");
- break;
- case 6: /* double */
- g_string_append_printf (string, "%g", swfdec_bits_get_double (&bits));
- break;
- case 7: /* 32bit int */
- g_string_append_printf (string, "%d", swfdec_bits_get_u32 (&bits));
- break;
- case 8: /* 8bit ConstantPool address */
- g_string_append_printf (string, "Pool %u", swfdec_bits_get_u8 (&bits));
- break;
- case 9: /* 16bit ConstantPool address */
- g_string_append_printf (string, "Pool %u", swfdec_bits_get_u16 (&bits));
- break;
- default:
- SWFDEC_ERROR ("Push: type %u not implemented", type);
- return NULL;
- }
- }
- return g_string_free (string, FALSE);
-}
-
-/* NB: constant pool actions are special in that they are called at init time */
-static char *
-swfdec_action_print_constant_pool (guint action, const guint8 *data, guint len)
-{
- guint i;
- GString *string;
- SwfdecConstantPool *pool;
-
- /* FIXME: version */
- pool = swfdec_constant_pool_new_from_action (data, len, 6);
- if (pool == NULL)
- return g_strdup ("ConstantPool (invalid)");
- string = g_string_new ("ConstantPool");
- for (i = 0; i < swfdec_constant_pool_size (pool); i++) {
- g_string_append (string, i ? ", " : " ");
- g_string_append (string, swfdec_constant_pool_get (pool, i));
- g_string_append_printf (string, " (%u)", i);
- }
- return g_string_free (string, FALSE);
-}
-
-#if 0
-static char *
-swfdec_action_print_wait_for_frame2 (guint action, const guint8 *data, guint len)
-{
- if (len != 1) {
- SWFDEC_ERROR ("WaitForFrame2 needs a 1-byte data");
- return NULL;
- }
- return g_strdup_printf ("WaitForFrame2 %u", (guint) *data);
-}
-#endif
-
-static char *
-swfdec_action_print_goto_frame2 (guint action, const guint8 *data, guint len)
-{
- gboolean play, bias;
- SwfdecBits bits;
-
- swfdec_bits_init_data (&bits, data, len);
- if (swfdec_bits_getbits (&bits, 6)) {
- SWFDEC_WARNING ("reserved bits in GotoFrame2 aren't 0");
- }
- bias = swfdec_bits_getbit (&bits);
- play = swfdec_bits_getbit (&bits);
- if (bias) {
- return g_strdup_printf ("GotoFrame2 %s +%u", play ? "play" : "stop",
- swfdec_bits_get_u16 (&bits));
- } else {
- return g_strdup_printf ("GotoFrame2 %s", play ? "play" : "stop");
- }
-}
-
-static char *
-swfdec_action_print_goto_frame (guint action, const guint8 *data, guint len)
-{
- guint frame;
-
- if (len != 2)
- return NULL;
-
- frame = data[0] | (data[1] << 8);
- return g_strdup_printf ("GotoFrame %u", frame);
-}
-
-static char *
-swfdec_action_print_goto_label (guint action, const guint8 *data, guint len)
-{
- if (!memchr (data, 0, len)) {
- SWFDEC_ERROR ("GotoLabel action does not specify a string");
- return NULL;
- }
-
- return g_strdup_printf ("GotoLabel %s", data);
-}
-
-static char *
-swfdec_action_print_wait_for_frame (guint action, const guint8 *data, guint len)
-{
- guint frame, jump;
-
- if (len != 3)
- return NULL;
-
- frame = data[0] | (data[1] << 8);
- jump = data[2];
- return g_strdup_printf ("WaitForFrame %u %u", frame, jump);
-}
-
-/*** BIG FUNCTION TABLE ***/
-
-const SwfdecActionSpec swfdec_as_actions[256] = {
- /* version 1 */
- [SWFDEC_AS_ACTION_NEXT_FRAME] = { "NextFrame", NULL, 0, 0, swfdec_action_next_frame, 1 },
- [SWFDEC_AS_ACTION_PREVIOUS_FRAME] = { "PreviousFrame", NULL, 0, 0, swfdec_action_previous_frame, 1 },
- [SWFDEC_AS_ACTION_PLAY] = { "Play", NULL, 0, 0, swfdec_action_play, 1 },
- [SWFDEC_AS_ACTION_STOP] = { "Stop", NULL, 0, 0, swfdec_action_stop, 1 },
- [SWFDEC_AS_ACTION_TOGGLE_QUALITY] = { "ToggleQuality", NULL, -1, -1, NULL, 1 },
- /* version 2 */
- [SWFDEC_AS_ACTION_STOP_SOUNDS] = { "StopSounds", NULL, 0, 0, swfdec_action_stop_sounds, 2 },
- /* version 4 */
- [SWFDEC_AS_ACTION_ADD] = { "Add", NULL, 2, 1, swfdec_action_binary, 4 },
- [SWFDEC_AS_ACTION_SUBTRACT] = { "Subtract", NULL, 2, 1, swfdec_action_binary, 4 },
- [SWFDEC_AS_ACTION_MULTIPLY] = { "Multiply", NULL, 2, 1, swfdec_action_binary, 4 },
- [SWFDEC_AS_ACTION_DIVIDE] = { "Divide", NULL, 2, 1, swfdec_action_binary, 4 },
- [SWFDEC_AS_ACTION_EQUALS] = { "Equals", NULL, 2, 1, swfdec_action_old_compare, 4 },
- [SWFDEC_AS_ACTION_LESS] = { "Less", NULL, 2, 1, swfdec_action_old_compare, 4 },
- [SWFDEC_AS_ACTION_AND] = { "And", NULL, 2, 1, swfdec_action_logical, 4 },
- [SWFDEC_AS_ACTION_OR] = { "Or", NULL, 2, 1, swfdec_action_logical, 4 },
- [SWFDEC_AS_ACTION_NOT] = { "Not", NULL, 1, 1, swfdec_action_not, 4 },
- [SWFDEC_AS_ACTION_STRING_EQUALS] = { "StringEquals", NULL, 2, 1, swfdec_action_string_compare, 4 },
- [SWFDEC_AS_ACTION_STRING_LENGTH] = { "StringLength", NULL, 1, 1, swfdec_action_string_length, 4 },
- [SWFDEC_AS_ACTION_STRING_EXTRACT] = { "StringExtract", NULL, 3, 1, swfdec_action_string_extract, 4 },
- [SWFDEC_AS_ACTION_POP] = { "Pop", NULL, 1, 0, swfdec_action_pop, 4 },
- [SWFDEC_AS_ACTION_TO_INTEGER] = { "ToInteger", NULL, 1, 1, swfdec_action_to_integer, 4 },
- [SWFDEC_AS_ACTION_GET_VARIABLE] = { "GetVariable", NULL, 1, 1, swfdec_action_get_variable, 4 },
- [SWFDEC_AS_ACTION_SET_VARIABLE] = { "SetVariable", NULL, 2, 0, swfdec_action_set_variable, 4 },
- /* version 3 */
- [SWFDEC_AS_ACTION_SET_TARGET2] = { "SetTarget2", NULL, 1, 0, swfdec_action_set_target2, 3 },
- /* version 4 */
- [SWFDEC_AS_ACTION_STRING_ADD] = { "StringAdd", NULL, 2, 1, swfdec_action_string_add, 4 },
- [SWFDEC_AS_ACTION_GET_PROPERTY] = { "GetProperty", NULL, 2, 1, swfdec_action_get_property, 4 },
- [SWFDEC_AS_ACTION_SET_PROPERTY] = { "SetProperty", NULL, 3, 0, swfdec_action_set_property, 4 },
- [SWFDEC_AS_ACTION_CLONE_SPRITE] = { "CloneSprite", NULL, 3, 0, swfdec_action_clone_sprite, 4 },
- [SWFDEC_AS_ACTION_REMOVE_SPRITE] = { "RemoveSprite", NULL, 1, 0, swfdec_action_remove_sprite, 4 },
- [SWFDEC_AS_ACTION_TRACE] = { "Trace", NULL, 1, 0, swfdec_action_trace, 4 },
- [SWFDEC_AS_ACTION_START_DRAG] = { "StartDrag", NULL, -1, 0, swfdec_action_start_drag, 4 },
- [SWFDEC_AS_ACTION_END_DRAG] = { "EndDrag", NULL, 0, 0, swfdec_action_end_drag, 4 },
- [SWFDEC_AS_ACTION_STRING_LESS] = { "StringLess", NULL, 2, 1, swfdec_action_string_compare, 4 },
- /* version 7 */
- [SWFDEC_AS_ACTION_THROW] = { "Throw", NULL, 1, 0, swfdec_action_throw, 7 },
- [SWFDEC_AS_ACTION_CAST] = { "Cast", NULL, 2, 1, swfdec_action_cast, 7 },
- [SWFDEC_AS_ACTION_IMPLEMENTS] = { "Implements", NULL, -1, 0, swfdec_action_implements, 7 },
- /* version 4 */
- [SWFDEC_AS_ACTION_RANDOM] = { "RandomNumber", NULL, 1, 1, swfdec_action_random_number, 4 },
- [SWFDEC_AS_ACTION_MB_STRING_LENGTH] = { "MBStringLength", NULL, -1, -1, NULL, 4 },
- [SWFDEC_AS_ACTION_CHAR_TO_ASCII] = { "CharToAscii", NULL, 1, 1, swfdec_action_char_to_ascii, 4 },
- [SWFDEC_AS_ACTION_ASCII_TO_CHAR] = { "AsciiToChar", NULL, 1, 1, swfdec_action_ascii_to_char, 4 },
- [SWFDEC_AS_ACTION_GET_TIME] = { "GetTime", NULL, 0, 1, swfdec_action_get_time, 4 },
- [SWFDEC_AS_ACTION_MB_STRING_EXTRACT] = { "MBStringExtract", NULL, 3, 1, swfdec_action_string_extract, 4 },
- [SWFDEC_AS_ACTION_MB_CHAR_TO_ASCII] = { "MBCharToAscii", NULL, -1, -1, NULL, 4 },
- [SWFDEC_AS_ACTION_MB_ASCII_TO_CHAR] = { "MBAsciiToChar", NULL, 1, 1, swfdec_action_ascii_to_char, 4 },
- /* version 5 */
- [SWFDEC_AS_ACTION_DELETE] = { "Delete", NULL, 2, 1, swfdec_action_delete, 5 },
- [SWFDEC_AS_ACTION_DELETE2] = { "Delete2", NULL, 1, 1, swfdec_action_delete2, 5 },
- [SWFDEC_AS_ACTION_DEFINE_LOCAL] = { "DefineLocal", NULL, 2, 0, swfdec_action_define_local, 5 },
- [SWFDEC_AS_ACTION_CALL_FUNCTION] = { "CallFunction", NULL, -1, 1, swfdec_action_call_function, 5 },
- [SWFDEC_AS_ACTION_RETURN] = { "Return", NULL, 1, 0, swfdec_action_return, 5 },
- [SWFDEC_AS_ACTION_MODULO] = { "Modulo", NULL, 2, 1, swfdec_action_modulo, 5 },
- [SWFDEC_AS_ACTION_NEW_OBJECT] = { "NewObject", NULL, -1, 1, swfdec_action_new_object, 5 },
- [SWFDEC_AS_ACTION_DEFINE_LOCAL2] = { "DefineLocal2", NULL, 1, 0, swfdec_action_define_local2, 5 },
- [SWFDEC_AS_ACTION_INIT_ARRAY] = { "InitArray", NULL, -1, 1, swfdec_action_init_array, 5 },
- [SWFDEC_AS_ACTION_INIT_OBJECT] = { "InitObject", NULL, -1, 1, swfdec_action_init_object, 5 },
- [SWFDEC_AS_ACTION_TYPE_OF] = { "TypeOf", NULL, 1, 1, swfdec_action_type_of, 5 },
- [SWFDEC_AS_ACTION_TARGET_PATH] = { "TargetPath", NULL, 1, 1, swfdec_action_target_path, 5 },
- [SWFDEC_AS_ACTION_ENUMERATE] = { "Enumerate", NULL, 1, -1, swfdec_action_enumerate, 5 },
- [SWFDEC_AS_ACTION_ADD2] = { "Add2", NULL, 2, 1, swfdec_action_add2, 5 },
- [SWFDEC_AS_ACTION_LESS2] = { "Less2", NULL, 2, 1, swfdec_action_new_comparison, 5 },
- [SWFDEC_AS_ACTION_EQUALS2] = { "Equals2", NULL, 2, 1, swfdec_action_equals2, 5 },
- [SWFDEC_AS_ACTION_TO_NUMBER] = { "ToNumber", NULL, 1, 1, swfdec_action_to_number, 5 },
- [SWFDEC_AS_ACTION_TO_STRING] = { "ToString", NULL, 1, 1, swfdec_action_to_string, 5 },
- [SWFDEC_AS_ACTION_PUSH_DUPLICATE] = { "PushDuplicate", NULL, 1, 2, swfdec_action_push_duplicate, 5 },
- [SWFDEC_AS_ACTION_SWAP] = { "Swap", NULL, 2, 2, swfdec_action_swap, 5 },
- /* version 4 */
- [SWFDEC_AS_ACTION_GET_MEMBER] = { "GetMember", NULL, 2, 1, swfdec_action_get_member, 4 },
- [SWFDEC_AS_ACTION_SET_MEMBER] = { "SetMember", NULL, 3, 0, swfdec_action_set_member, 4 },
- /* version 5 */
- [SWFDEC_AS_ACTION_INCREMENT] = { "Increment", NULL, 1, 1, swfdec_action_increment, 5 },
- [SWFDEC_AS_ACTION_DECREMENT] = { "Decrement", NULL, 1, 1, swfdec_action_decrement, 5 },
- [SWFDEC_AS_ACTION_CALL_METHOD] = { "CallMethod", NULL, -1, 1, swfdec_action_call_method, 5 },
- [SWFDEC_AS_ACTION_NEW_METHOD] = { "NewMethod", NULL, -1, 1, swfdec_action_new_method, 5 },
- /* version 6 */
- [SWFDEC_AS_ACTION_INSTANCE_OF] = { "InstanceOf", NULL, 2, 1, swfdec_action_instance_of, 6 },
- [SWFDEC_AS_ACTION_ENUMERATE2] = { "Enumerate2", NULL, 1, -1, swfdec_action_enumerate2, 6 },
- [SWFDEC_AS_ACTION_BREAKPOINT] = { "Breakpoint", NULL, -1, -1, NULL, 6 },
- /* version 5 */
- [SWFDEC_AS_ACTION_BIT_AND] = { "BitAnd", NULL, 2, 1, swfdec_action_bitwise, 5 },
- [SWFDEC_AS_ACTION_BIT_OR] = { "BitOr", NULL, 2, 1, swfdec_action_bitwise, 5 },
- [SWFDEC_AS_ACTION_BIT_XOR] = { "BitXor", NULL, 2, 1, swfdec_action_bitwise, 5 },
- [SWFDEC_AS_ACTION_BIT_LSHIFT] = { "BitLShift", NULL, 2, 1, swfdec_action_shift, 5 },
- [SWFDEC_AS_ACTION_BIT_RSHIFT] = { "BitRShift", NULL, 2, 1, swfdec_action_shift, 5 },
- [SWFDEC_AS_ACTION_BIT_URSHIFT] = { "BitURShift", NULL, 2, 1, swfdec_action_shift, 5 },
- /* version 6 */
- [SWFDEC_AS_ACTION_STRICT_EQUALS] = { "StrictEquals", NULL, 2, 1, swfdec_action_strict_equals, 6 },
- [SWFDEC_AS_ACTION_GREATER] = { "Greater", NULL, 2, 1, swfdec_action_new_comparison, 6 },
- [SWFDEC_AS_ACTION_STRING_GREATER] = { "StringGreater", NULL, -1, -1, NULL, 6 },
- /* version 7 */
- [SWFDEC_AS_ACTION_EXTENDS] = { "Extends", NULL, 2, 0, swfdec_action_extends, 7 },
- /* version 1 */
- [SWFDEC_AS_ACTION_GOTO_FRAME] = { "GotoFrame", swfdec_action_print_goto_frame, 0, 0, swfdec_action_goto_frame, 1 },
- [SWFDEC_AS_ACTION_GET_URL] = { "GetURL", swfdec_action_print_get_url, 0, 0, swfdec_action_get_url, 1 },
- /* version 5 */
- [SWFDEC_AS_ACTION_STORE_REGISTER] = { "StoreRegister", swfdec_action_print_store_register, 1, 1, swfdec_action_store_register, 5 },
- [SWFDEC_AS_ACTION_CONSTANT_POOL] = { "ConstantPool", swfdec_action_print_constant_pool, 0, 0, swfdec_action_constant_pool, 5 },
- [SWFDEC_AS_ACTION_STRICT_MODE] = { "StrictMode", NULL, -1, -1, NULL, 5 },
- /* version 1 */
- [SWFDEC_AS_ACTION_WAIT_FOR_FRAME] = { "WaitForFrame", swfdec_action_print_wait_for_frame, 0, 0, swfdec_action_wait_for_frame, 1 },
- [SWFDEC_AS_ACTION_SET_TARGET] = { "SetTarget", swfdec_action_print_set_target, 0, 0, swfdec_action_set_target, 1 },
- /* version 3 */
- [SWFDEC_AS_ACTION_GOTO_LABEL] = { "GotoLabel", swfdec_action_print_goto_label, 0, 0, swfdec_action_goto_label, 3 },
-#if 0
- /* version 4 */
- [0x8d] = { "WaitForFrame2", swfdec_action_print_wait_for_frame2, 1, 0, { NULL, swfdec_action_wait_for_frame2, swfdec_action_wait_for_frame2, swfdec_action_wait_for_frame2, swfdec_action_wait_for_frame2 } },
-#endif
- /* version 7 */
- [SWFDEC_AS_ACTION_DEFINE_FUNCTION2] = { "DefineFunction2", swfdec_action_print_define_function, 0, -1, swfdec_action_define_function, 7 },
- [SWFDEC_AS_ACTION_TRY] = { "Try", NULL, 0, 0, swfdec_action_try, 7 },
- /* version 5 */
- [SWFDEC_AS_ACTION_WITH] = { "With", swfdec_action_print_with, 1, 0, swfdec_action_with, 5 },
- /* version 4 */
- [SWFDEC_AS_ACTION_PUSH] = { "Push", swfdec_action_print_push, 0, -1, swfdec_action_push, 4 },
- [SWFDEC_AS_ACTION_JUMP] = { "Jump", swfdec_action_print_jump, 0, 0, swfdec_action_jump, 4 },
- [SWFDEC_AS_ACTION_GET_URL2] = { "GetURL2", swfdec_action_print_get_url2, 2, 0, swfdec_action_get_url2, 4 },
- /* version 5 */
- [SWFDEC_AS_ACTION_DEFINE_FUNCTION] = { "DefineFunction", swfdec_action_print_define_function, 0, -1, swfdec_action_define_function, 5 },
- /* version 4 */
- [SWFDEC_AS_ACTION_IF] = { "If", swfdec_action_print_if, 1, 0, swfdec_action_if, 4 },
- [SWFDEC_AS_ACTION_CALL] = { "Call", NULL, -1, -1, NULL, 4 },
- [SWFDEC_AS_ACTION_GOTO_FRAME2] = { "GotoFrame2", swfdec_action_print_goto_frame2, 1, 0, swfdec_action_goto_frame2, 4 }
-};
-
diff --git a/libswfdec/swfdec_as_interpret.h b/libswfdec/swfdec_as_interpret.h
deleted file mode 100644
index 6b9402b..0000000
--- a/libswfdec/swfdec_as_interpret.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AS_INTERPRET_H_
-#define _SWFDEC_AS_INTERPRET_H_
-
-#include <libswfdec/swfdec_as_types.h>
-
-G_BEGIN_DECLS
-
-typedef struct {
- const char * name; /* name identifying the action */
- char * (* print) (guint action, const guint8 *data, guint len);
- int remove; /* values removed from stack or -1 for dynamic */
- int add; /* values added to the stack or -1 for dynamic */
- void (* exec) (SwfdecAsContext *cx, guint action, const guint8 *data, guint len);
- guint version; /* the version this action was introduced in */
-} SwfdecActionSpec;
-
-extern const SwfdecActionSpec swfdec_as_actions[256];
-
-/* all known actions */
-typedef enum {
- SWFDEC_AS_ACTION_NEXT_FRAME = 0x04,
- SWFDEC_AS_ACTION_PREVIOUS_FRAME = 0x05,
- SWFDEC_AS_ACTION_PLAY = 0x06,
- SWFDEC_AS_ACTION_STOP = 0x07,
- SWFDEC_AS_ACTION_TOGGLE_QUALITY = 0x08,
- SWFDEC_AS_ACTION_STOP_SOUNDS = 0x09,
- SWFDEC_AS_ACTION_ADD = 0x0A,
- SWFDEC_AS_ACTION_SUBTRACT = 0x0B,
- SWFDEC_AS_ACTION_MULTIPLY = 0x0C,
- SWFDEC_AS_ACTION_DIVIDE = 0x0D,
- SWFDEC_AS_ACTION_EQUALS = 0x0E,
- SWFDEC_AS_ACTION_LESS = 0x0F,
- SWFDEC_AS_ACTION_AND = 0x10,
- SWFDEC_AS_ACTION_OR = 0x11,
- SWFDEC_AS_ACTION_NOT = 0x12,
- SWFDEC_AS_ACTION_STRING_EQUALS = 0x13,
- SWFDEC_AS_ACTION_STRING_LENGTH = 0x14,
- SWFDEC_AS_ACTION_STRING_EXTRACT = 0x15,
- SWFDEC_AS_ACTION_POP = 0x17,
- SWFDEC_AS_ACTION_TO_INTEGER = 0x18,
- SWFDEC_AS_ACTION_GET_VARIABLE = 0x1C,
- SWFDEC_AS_ACTION_SET_VARIABLE = 0x1D,
- SWFDEC_AS_ACTION_SET_TARGET2 = 0x20,
- SWFDEC_AS_ACTION_STRING_ADD = 0x21,
- SWFDEC_AS_ACTION_GET_PROPERTY = 0x22,
- SWFDEC_AS_ACTION_SET_PROPERTY = 0x23,
- SWFDEC_AS_ACTION_CLONE_SPRITE = 0x24,
- SWFDEC_AS_ACTION_REMOVE_SPRITE = 0x25,
- SWFDEC_AS_ACTION_TRACE = 0x26,
- SWFDEC_AS_ACTION_START_DRAG = 0x27,
- SWFDEC_AS_ACTION_END_DRAG = 0x28,
- SWFDEC_AS_ACTION_STRING_LESS = 0x29,
- SWFDEC_AS_ACTION_THROW = 0x2A,
- SWFDEC_AS_ACTION_CAST = 0x2B,
- SWFDEC_AS_ACTION_IMPLEMENTS = 0x2C,
- SWFDEC_AS_ACTION_RANDOM = 0x30,
- SWFDEC_AS_ACTION_MB_STRING_LENGTH = 0x31,
- SWFDEC_AS_ACTION_CHAR_TO_ASCII = 0x32,
- SWFDEC_AS_ACTION_ASCII_TO_CHAR = 0x33,
- SWFDEC_AS_ACTION_GET_TIME = 0x34,
- SWFDEC_AS_ACTION_MB_STRING_EXTRACT = 0x35,
- SWFDEC_AS_ACTION_MB_CHAR_TO_ASCII = 0x36,
- SWFDEC_AS_ACTION_MB_ASCII_TO_CHAR = 0x37,
- SWFDEC_AS_ACTION_DELETE = 0x3A,
- SWFDEC_AS_ACTION_DELETE2 = 0x3B,
- SWFDEC_AS_ACTION_DEFINE_LOCAL = 0x3C,
- SWFDEC_AS_ACTION_CALL_FUNCTION = 0x3D,
- SWFDEC_AS_ACTION_RETURN = 0x3E,
- SWFDEC_AS_ACTION_MODULO = 0x3F,
- SWFDEC_AS_ACTION_NEW_OBJECT = 0x40,
- SWFDEC_AS_ACTION_DEFINE_LOCAL2 = 0x41,
- SWFDEC_AS_ACTION_INIT_ARRAY = 0x42,
- SWFDEC_AS_ACTION_INIT_OBJECT = 0x43,
- SWFDEC_AS_ACTION_TYPE_OF = 0x44,
- SWFDEC_AS_ACTION_TARGET_PATH = 0x45,
- SWFDEC_AS_ACTION_ENUMERATE = 0x46,
- SWFDEC_AS_ACTION_ADD2 = 0x47,
- SWFDEC_AS_ACTION_LESS2 = 0x48,
- SWFDEC_AS_ACTION_EQUALS2 = 0x49,
- SWFDEC_AS_ACTION_TO_NUMBER = 0x4A,
- SWFDEC_AS_ACTION_TO_STRING = 0x4B,
- SWFDEC_AS_ACTION_PUSH_DUPLICATE = 0x4C,
- SWFDEC_AS_ACTION_SWAP = 0x4D,
- SWFDEC_AS_ACTION_GET_MEMBER = 0x4E,
- SWFDEC_AS_ACTION_SET_MEMBER = 0x4F,
- SWFDEC_AS_ACTION_INCREMENT = 0x50,
- SWFDEC_AS_ACTION_DECREMENT = 0x51,
- SWFDEC_AS_ACTION_CALL_METHOD = 0x52,
- SWFDEC_AS_ACTION_NEW_METHOD = 0x53,
- SWFDEC_AS_ACTION_INSTANCE_OF = 0x54,
- SWFDEC_AS_ACTION_ENUMERATE2 = 0x55,
- SWFDEC_AS_ACTION_BREAKPOINT = 0x5F,
- SWFDEC_AS_ACTION_BIT_AND = 0x60,
- SWFDEC_AS_ACTION_BIT_OR = 0x61,
- SWFDEC_AS_ACTION_BIT_XOR = 0x62,
- SWFDEC_AS_ACTION_BIT_LSHIFT = 0x63,
- SWFDEC_AS_ACTION_BIT_RSHIFT = 0x64,
- SWFDEC_AS_ACTION_BIT_URSHIFT = 0x65,
- SWFDEC_AS_ACTION_STRICT_EQUALS = 0x66,
- SWFDEC_AS_ACTION_GREATER = 0x67,
- SWFDEC_AS_ACTION_STRING_GREATER = 0x68,
- SWFDEC_AS_ACTION_EXTENDS = 0x69,
- SWFDEC_AS_ACTION_GOTO_FRAME = 0x81,
- SWFDEC_AS_ACTION_GET_URL = 0x83,
- SWFDEC_AS_ACTION_STORE_REGISTER = 0x87,
- SWFDEC_AS_ACTION_CONSTANT_POOL = 0x88,
- SWFDEC_AS_ACTION_STRICT_MODE = 0x89,
- SWFDEC_AS_ACTION_WAIT_FOR_FRAME = 0x8A,
- SWFDEC_AS_ACTION_SET_TARGET = 0x8B,
- SWFDEC_AS_ACTION_GOTO_LABEL = 0x8C,
- SWFDEC_AS_ACTION_WAIT_FOR_FRAME2 = 0x8D,
- SWFDEC_AS_ACTION_DEFINE_FUNCTION2 = 0x8E,
- SWFDEC_AS_ACTION_TRY = 0x8F,
- SWFDEC_AS_ACTION_WITH = 0x94,
- SWFDEC_AS_ACTION_PUSH = 0x96,
- SWFDEC_AS_ACTION_JUMP = 0x99,
- SWFDEC_AS_ACTION_GET_URL2 = 0x9A,
- SWFDEC_AS_ACTION_DEFINE_FUNCTION = 0x9B,
- SWFDEC_AS_ACTION_IF = 0x9D,
- SWFDEC_AS_ACTION_CALL = 0x9E,
- SWFDEC_AS_ACTION_GOTO_FRAME2 = 0x9F
-} SwfdecAsAction;
-
-// FIXME: move
-SwfdecAsObject * swfdec_action_lookup_object (SwfdecAsContext * cx,
- SwfdecAsObject * o,
- const char * path,
- const char * end);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_as_math.c b/libswfdec/swfdec_as_math.c
deleted file mode 100644
index 30b0c6e..0000000
--- a/libswfdec/swfdec_as_math.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-
-#include "swfdec_as_object.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_native_function.h"
-#include "swfdec_debug.h"
-
-/*** AS CODE ***/
-
-#define MATH_FUN(name) \
-void \
-swfdec_as_math_ ## name (SwfdecAsContext *cx, SwfdecAsObject *object, \
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret) \
-{ \
- double d; \
-\
- SWFDEC_AS_CHECK (0, NULL, "n", &d); \
-\
- d = name (d); \
- SWFDEC_AS_VALUE_SET_NUMBER (ret, d); \
-}
-
-SWFDEC_AS_NATIVE (200, 16, swfdec_as_math_acos)
-MATH_FUN (acos)
-SWFDEC_AS_NATIVE (200, 15, swfdec_as_math_asin)
-MATH_FUN (asin)
-SWFDEC_AS_NATIVE (200, 14, swfdec_as_math_atan)
-MATH_FUN (atan)
-SWFDEC_AS_NATIVE (200, 13, swfdec_as_math_ceil)
-MATH_FUN (ceil)
-SWFDEC_AS_NATIVE (200, 4, swfdec_as_math_cos)
-MATH_FUN (cos)
-SWFDEC_AS_NATIVE (200, 7, swfdec_as_math_exp)
-MATH_FUN (exp)
-SWFDEC_AS_NATIVE (200, 12, swfdec_as_math_floor)
-MATH_FUN (floor)
-SWFDEC_AS_NATIVE (200, 8, swfdec_as_math_log)
-MATH_FUN (log)
-SWFDEC_AS_NATIVE (200, 3, swfdec_as_math_sin)
-MATH_FUN (sin)
-SWFDEC_AS_NATIVE (200, 9, swfdec_as_math_sqrt)
-MATH_FUN (sqrt)
-SWFDEC_AS_NATIVE (200, 6, swfdec_as_math_tan)
-MATH_FUN (tan)
-
-SWFDEC_AS_NATIVE (200, 0, swfdec_as_math_abs)
-void
-swfdec_as_math_abs (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- double d;
-
- SWFDEC_AS_CHECK (0, NULL, "n", &d);
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret, fabs (d));
-}
-
-SWFDEC_AS_NATIVE (200, 5, swfdec_as_math_atan2)
-void
-swfdec_as_math_atan2 (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- double x, y;
-
- SWFDEC_AS_CHECK (0, NULL, "nn", &y, &x);
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret, atan2 (y, x));
-}
-
-SWFDEC_AS_NATIVE (200, 2, swfdec_as_math_max)
-void
-swfdec_as_math_max (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- double x, y;
-
- SWFDEC_AS_CHECK (0, NULL, "nn", &x, &y);
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret, MAX (x, y));
-}
-
-SWFDEC_AS_NATIVE (200, 1, swfdec_as_math_min)
-void
-swfdec_as_math_min (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- double x, y;
-
- SWFDEC_AS_CHECK (0, NULL, "nn", &x, &y);
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret, MIN (x, y));
-}
-
-SWFDEC_AS_NATIVE (200, 17, swfdec_as_math_pow)
-void
-swfdec_as_math_pow (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- double x, y;
-
- SWFDEC_AS_CHECK (0, NULL, "nn", &x, &y);
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret, pow (x, y));
-}
-
-SWFDEC_AS_NATIVE (200, 11, swfdec_as_math_random)
-void
-swfdec_as_math_random (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_NUMBER (ret, g_rand_double (cx->rand));
-}
-
-SWFDEC_AS_NATIVE (200, 10, swfdec_as_math_round)
-void
-swfdec_as_math_round (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- double d;
-
- SWFDEC_AS_CHECK (0, NULL, "n", &d);
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret, floor (d + 0.5));
-}
diff --git a/libswfdec/swfdec_as_native_function.c b/libswfdec/swfdec_as_native_function.c
deleted file mode 100644
index 74ba3e6..0000000
--- a/libswfdec/swfdec_as_native_function.c
+++ /dev/null
@@ -1,395 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_native_function.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_frame_internal.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_stack.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-
-/*** GTK-DOC ***/
-
-/**
- * SwfdecAsNative:
- * @context: #SwfdecAsContext
- * @thisp: the this object. <warning>Can be %NULL.</warning>
- * @argc: number of arguments passed to this function
- * @argv: the @argc arguments passed to this function
- * @retval: set to the return value. Initialized to undefined by default
- *
- * This is the prototype for all native functions.
- */
-
-/**
- * SwfdecAsNativeFunction:
- *
- * This is the object type for native functions.
- */
-
-/*** IMPLEMENTATION ***/
-
-G_DEFINE_TYPE (SwfdecAsNativeFunction, swfdec_as_native_function, SWFDEC_TYPE_AS_FUNCTION)
-
-static SwfdecAsFrame *
-swfdec_as_native_function_call (SwfdecAsFunction *function)
-{
- SwfdecAsNativeFunction *native = SWFDEC_AS_NATIVE_FUNCTION (function);
- SwfdecAsFrame *frame;
- SwfdecAsContext *cx;
-
- cx = SWFDEC_AS_OBJECT (function)->context;
- frame = swfdec_as_frame_new_native (cx);
- if (frame == NULL)
- return NULL;
- g_assert (native->name);
- frame->function_name = native->name;
- frame->function = function;
- /* We copy the target here so we have a proper SwfdecMovie reference inside native
- * functions. This is for example necessary for swfdec_player_get_movie_by_value()
- * and probably other stuff that does variable lookups inside native functions.
- */
- /* FIXME: copy target or original target? */
- if (frame->next) {
- frame->target = frame->next->original_target;
- frame->original_target = frame->target;
- }
- return frame;
-}
-
-static char *
-swfdec_as_native_function_debug (SwfdecAsObject *object)
-{
- SwfdecAsNativeFunction *native = SWFDEC_AS_NATIVE_FUNCTION (object);
-
- return g_strdup_printf ("%s ()", native->name);
-}
-
-static void
-swfdec_as_native_function_dispose (GObject *object)
-{
- SwfdecAsNativeFunction *function = SWFDEC_AS_NATIVE_FUNCTION (object);
-
- g_free (function->name);
- function->name = NULL;
-
- G_OBJECT_CLASS (swfdec_as_native_function_parent_class)->dispose (object);
-}
-
-static void
-swfdec_as_native_function_class_init (SwfdecAsNativeFunctionClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
- SwfdecAsFunctionClass *function_class = SWFDEC_AS_FUNCTION_CLASS (klass);
-
- object_class->dispose = swfdec_as_native_function_dispose;
-
- asobject_class->debug = swfdec_as_native_function_debug;
-
- function_class->call = swfdec_as_native_function_call;
-}
-
-static void
-swfdec_as_native_function_init (SwfdecAsNativeFunction *function)
-{
-}
-
-/**
- * swfdec_as_native_function_new:
- * @context: a #SwfdecAsContext
- * @name: name of the function
- * @native: function to call when executed
- * @min_args: minimum number of arguments required
- * @prototype: The object to be used as "prototype" property for the created
- * function or %NULL for none.
- *
- * Creates a new native function, that will execute @native when called. The
- * @min_args parameter sets a requirement for the minimum number of arguments
- * to pass to @native. If the function gets called with less arguments, it
- * will just redurn undefined. You might want to use
- * swfdec_as_object_add_function() instead of this function.
- *
- * Returns: a new #SwfdecAsFunction or %NULL on OOM
- **/
-SwfdecAsFunction *
-swfdec_as_native_function_new (SwfdecAsContext *context, const char *name,
- SwfdecAsNative native, guint min_args, SwfdecAsObject *prototype)
-{
- SwfdecAsNativeFunction *fun;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
- g_return_val_if_fail (native != NULL, NULL);
- g_return_val_if_fail (prototype == NULL || SWFDEC_IS_AS_OBJECT (prototype), NULL);
-
- if (!swfdec_as_context_use_mem (context, sizeof (SwfdecAsNativeFunction)))
- return NULL;
- fun = g_object_new (SWFDEC_TYPE_AS_NATIVE_FUNCTION, NULL);
- if (fun == NULL)
- return NULL;
- fun->native = native;
- fun->min_args = min_args;
- fun->name = g_strdup (name);
- swfdec_as_object_add (SWFDEC_AS_OBJECT (fun), context, sizeof (SwfdecAsNativeFunction));
- /* need to set prototype before setting the constructor or Function.constructor
- * being CONSTANT disallows setting it. */
- if (prototype) {
- SwfdecAsValue val;
- SWFDEC_AS_VALUE_SET_OBJECT (&val, prototype);
- swfdec_as_object_set_variable_and_flags (SWFDEC_AS_OBJECT (fun), SWFDEC_AS_STR_prototype,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
- }
- swfdec_as_function_set_constructor (SWFDEC_AS_FUNCTION (fun));
-
- return SWFDEC_AS_FUNCTION (fun);
-}
-
-/**
- * swfdec_as_native_function_set_object_type:
- * @function: a #SwfdecAsNativeFunction
- * @type: required #GType for the this object
- *
- * Sets the required type for the this object to @type. If the this object
- * isn't of the required type, the function will not be called and its
- * return value will be undefined.
- **/
-void
-swfdec_as_native_function_set_object_type (SwfdecAsNativeFunction *function, GType type)
-{
- GTypeQuery query;
-
- g_return_if_fail (SWFDEC_IS_AS_NATIVE_FUNCTION (function));
- g_return_if_fail (g_type_is_a (type, SWFDEC_TYPE_AS_OBJECT));
-
- g_type_query (type, &query);
- function->type = type;
-}
-
-/**
- * swfdec_as_native_function_set_construct_type:
- * @function: a #SwfdecAsNativeFunction
- * @type: #GType used when constructing an object with @function
- *
- * Sets the @type to be used when using @function as a constructor. If this is
- * not set, using @function as a constructor will create a #SwfdecAsObject.
- **/
-void
-swfdec_as_native_function_set_construct_type (SwfdecAsNativeFunction *function, GType type)
-{
- GTypeQuery query;
-
- g_return_if_fail (SWFDEC_IS_AS_NATIVE_FUNCTION (function));
- g_return_if_fail (g_type_is_a (type, SWFDEC_TYPE_AS_OBJECT));
-
- g_type_query (type, &query);
- function->construct_type = type;
- function->construct_size = query.instance_size;
-}
-
-/**
- * SWFDEC_AS_CHECK:
- * @type: required type of this object or 0 for ignoring
- * @result: converted this object
- * @...: conversion string and pointers taking converted values
- *
- * This is a shortcut macro for calling swfdec_as_native_function_check() at
- * the beginning of a native function. See that function for details.
- * It requires the native function parameters to have the default name. So your
- * function must be declared like this:
- * |[static void
- * my_function (SwfdecAsContext *cx, SwfdecAsObject *object,
- * guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval);]|
- */
-/**
- * swfdec_as_native_function_check:
- * @cx: a #SwfdecAsContext
- * @object: this object passed to the native function
- * @type: expected type of @object or 0 for any
- * @result: pointer to variable taking cast result of @object
- * @argc: count of arguments passed to the function
- * @argv: arguments passed to the function
- * @args: argument conversion string
- * @...: pointers to variables taking converted arguments
- *
- * This function is a convenience function to validate and convert arguments to
- * a native function while avoiding common pitfalls. You typically want to call
- * it at the beginning of every native function you write. Or you can use the
- * SWFDEC_AS_CHECK() macro instead which calls this function.
- * The @cx, @object, @argc and @argv paramters should be passed verbatim from
- * the function call to your native function. If @type is not 0, @object is then
- * checked to be of that type and cast to @result. After that the @args string
- * is used to convert the arguments. Every character in @args describes the
- * conversion of one argument. For that argument, you have to pass a pointer
- * that takes the value. For the conversion, the default conversion functions
- * like swfdec_as_value_to_string() are used. If not enough arguments are
- * available, the function stops converting and returns %NULL. The following
- * conversion characters are allowed:<itemizedlist>
- * <listitem><para>"b": convert to boolean. Requires a %gboolean pointer
- * </para></listitem>
- * <listitem><para>"i": convert to integer. Requires an %integer pointer
- * </para></listitem>
- * <listitem><para>"n": convert to number. Requires a %double pointer
- * </para></listitem>
- * <listitem><para>"o": convert to object. Requires a #SwfdecAsObject pointer.
- * If the conversion fails, this function immediately return %
- * FALSE.</para></listitem>
- * <listitem><para>"O": convert to object or %NULL. Requires a #SwfdecAsObject
- * pointer.</para></listitem>
- * <listitem><para>"s": convert to garbage-collected string. Requires a const
- * %char pointer</para></listitem>
- * <listitem><para>"v": copy the value. The given argument must be a pointer
- * to a #SwfdecAsValue</para></listitem>
- * <listitem><para>"|": optional arguments follow. Optional arguments will be
- * initialized to the empty value for their type. This
- * conversion character is only allowed once in the conversion
- * string.</para></listitem>
- * </itemizedlist>
- *
- * Returns: %TRUE if the conversion succeeded, %FALSE otherwise
- **/
-gboolean
-swfdec_as_native_function_check (SwfdecAsContext *cx, SwfdecAsObject *object,
- GType type, gpointer *result, guint argc, SwfdecAsValue *argv,
- const char *args, ...)
-{
- gboolean ret;
- va_list varargs;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (cx), FALSE);
- g_return_val_if_fail (type == 0 || result != NULL, FALSE);
-
- va_start (varargs, args);
- ret = swfdec_as_native_function_checkv (cx, object, type, result, argc, argv, args, varargs);
- va_end (varargs);
- return ret;
-}
-
-/**
- * swfdec_as_native_function_checkv:
- * @cx: a #SwfdecAsContext
- * @object: this object passed to the native function
- * @type: expected type of @object
- * @result: pointer to variable taking cast result of @object
- * @argc: count of arguments passed to the function
- * @argv: arguments passed to the function
- * @args: argument conversion string
- * @varargs: pointers to variables taking converted arguments
- *
- * This is the valist version of swfdec_as_native_function_check(). See that
- * function for details.
- *
- * Returns: %TRUE if the conversion succeeded, %FALSE otherwise
- **/
-gboolean
-swfdec_as_native_function_checkv (SwfdecAsContext *cx, SwfdecAsObject *object,
- GType type, gpointer *result, guint argc, SwfdecAsValue *argv,
- const char *args, va_list varargs)
-{
- guint i;
- gboolean optional = FALSE;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (cx), FALSE);
- g_return_val_if_fail (type == 0 || result != NULL, FALSE);
-
- /* check that we got a valid type */
- if (type) {
- if (!G_TYPE_CHECK_INSTANCE_TYPE (object, type))
- return FALSE;
- *result = object;
- }
- for (i = 0; *args; i++, args++) {
- if (!optional && i >= argc && *args != '|')
- break;
- switch (*args) {
- case 'v':
- {
- SwfdecAsValue *val = va_arg (varargs, SwfdecAsValue *);
- if (i < argc)
- *val = argv[i];
- else
- SWFDEC_AS_VALUE_SET_UNDEFINED (val);
- }
- break;
- case 'b':
- {
- gboolean *b = va_arg (varargs, gboolean *);
- if (i < argc)
- *b = swfdec_as_value_to_boolean (cx, &argv[i]);
- else
- *b = FALSE;
- }
- break;
- case 'i':
- {
- int *j = va_arg (varargs, int *);
- if (i < argc)
- *j = swfdec_as_value_to_integer (cx, &argv[i]);
- else
- *j = 0;
- }
- break;
- case 'n':
- {
- double *d = va_arg (varargs, double *);
- if (i < argc)
- *d = swfdec_as_value_to_number (cx, &argv[i]);
- else
- *d = 0;
- }
- break;
- case 's':
- {
- const char **s = va_arg (varargs, const char **);
- if (i < argc)
- *s = swfdec_as_value_to_string (cx, &argv[i]);
- else
- *s = SWFDEC_AS_STR_EMPTY;
- }
- break;
- case 'o':
- case 'O':
- {
- SwfdecAsObject **o = va_arg (varargs, SwfdecAsObject **);
- if (i < argc)
- *o = swfdec_as_value_to_object (cx, &argv[i]);
- else
- *o = NULL;
- if (*o == NULL && *args != 'O')
- return FALSE;
- }
- break;
- case '|':
- g_return_val_if_fail (optional == FALSE, FALSE);
- optional = TRUE;
- i--;
- break;
- default:
- g_warning ("'%c' is not a valid type conversion", *args);
- return FALSE;
- }
- }
- if (*args)
- return FALSE;
- return TRUE;
-}
diff --git a/libswfdec/swfdec_as_native_function.h b/libswfdec/swfdec_as_native_function.h
deleted file mode 100644
index 88c172d..0000000
--- a/libswfdec/swfdec_as_native_function.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AS_NATIVE_FUNCTION_H_
-#define _SWFDEC_AS_NATIVE_FUNCTION_H_
-
-#include <libswfdec/swfdec_as_function.h>
-#include <libswfdec/swfdec_as_types.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecAsNativeFunction SwfdecAsNativeFunction;
-typedef struct _SwfdecAsNativeFunctionClass SwfdecAsNativeFunctionClass;
-
-#define SWFDEC_TYPE_AS_NATIVE_FUNCTION (swfdec_as_native_function_get_type())
-#define SWFDEC_IS_AS_NATIVE_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_NATIVE_FUNCTION))
-#define SWFDEC_IS_AS_NATIVE_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_NATIVE_FUNCTION))
-#define SWFDEC_AS_NATIVE_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_NATIVE_FUNCTION, SwfdecAsNativeFunction))
-#define SWFDEC_AS_NATIVE_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_NATIVE_FUNCTION, SwfdecAsNativeFunctionClass))
-#define SWFDEC_AS_NATIVE_FUNCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_NATIVE_FUNCTION, SwfdecAsNativeFunctionClass))
-
-/* FIXME: do two obejcts, one for scripts and one for native? */
-struct _SwfdecAsNativeFunction {
- /*< private >*/
- SwfdecAsFunction function;
-
- SwfdecAsNative native; /* native call or NULL when script */
- char * name; /* function name */
- /* checks for calling this function */
- GType type; /* required type for this object when caling function */
- guint min_args; /* minimum number of required arguments */
- /* constructor info */
- GType construct_type; /* type used when used as a constructor or 0 */
- guint construct_size; /* instance size of type */
-};
-
-struct _SwfdecAsNativeFunctionClass {
- SwfdecAsFunctionClass function_class;
-};
-
-GType swfdec_as_native_function_get_type (void);
-
-SwfdecAsFunction *swfdec_as_native_function_new (SwfdecAsContext * context,
- const char * name,
- SwfdecAsNative native,
- guint min_args,
- SwfdecAsObject * prototype);
-
-void swfdec_as_native_function_set_object_type
- (SwfdecAsNativeFunction *function,
- GType type);
-void swfdec_as_native_function_set_construct_type
- (SwfdecAsNativeFunction *function,
- GType type);
-
-gboolean swfdec_as_native_function_check (SwfdecAsContext * cx,
- SwfdecAsObject * object,
- GType type,
- gpointer * result,
- guint argc,
- SwfdecAsValue * argv,
- const char * args,
- ...);
-gboolean swfdec_as_native_function_checkv(SwfdecAsContext * cx,
- SwfdecAsObject * object,
- GType type,
- gpointer * result,
- guint argc,
- SwfdecAsValue * argv,
- const char * args,
- va_list varargs);
-#define SWFDEC_AS_CHECK(type,result,...) G_STMT_START {\
- if (!swfdec_as_native_function_check (cx, object, type, (gpointer) result, argc, argv, __VA_ARGS__)) \
- return; \
-}G_STMT_END
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_as_number.c b/libswfdec/swfdec_as_number.c
deleted file mode 100644
index 71472ee..0000000
--- a/libswfdec/swfdec_as_number.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-
-#include "swfdec_as_number.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_frame.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_native_function.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-
-G_DEFINE_TYPE (SwfdecAsNumber, swfdec_as_number, SWFDEC_TYPE_AS_OBJECT)
-
-static void
-swfdec_as_number_class_init (SwfdecAsNumberClass *klass)
-{
-}
-
-static void
-swfdec_as_number_init (SwfdecAsNumber *number)
-{
-}
-
-/*** AS CODE ***/
-
-SWFDEC_AS_CONSTRUCTOR (106, 2, swfdec_as_number_construct, swfdec_as_number_get_type)
-void
-swfdec_as_number_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- double d;
-
- if (argc > 0) {
- d = swfdec_as_value_to_number (object->context, &argv[0]);
- } else {
- d = NAN;
- }
-
- if (swfdec_as_context_is_constructing (cx)) {
- SwfdecAsNumber *num = SWFDEC_AS_NUMBER (object);
- num->number = d;
- SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
- } else {
- SWFDEC_AS_VALUE_SET_NUMBER (ret, d);
- }
-}
-
-SWFDEC_AS_NATIVE (106, 1, swfdec_as_number_toString)
-void
-swfdec_as_number_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecAsNumber *num;
- SwfdecAsValue val;
- const char *s;
-
- if (!SWFDEC_IS_AS_NUMBER (object))
- return;
-
- num = SWFDEC_AS_NUMBER (object);
- if (argc > 0) {
- SWFDEC_FIXME ("radix is not yet implemented");
- }
- SWFDEC_AS_VALUE_SET_NUMBER (&val, num->number);
- s = swfdec_as_value_to_string (object->context, &val);
- SWFDEC_AS_VALUE_SET_STRING (ret, s);
-}
-
-SWFDEC_AS_NATIVE (106, 0, swfdec_as_number_valueOf)
-void
-swfdec_as_number_valueOf (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecAsNumber *num;
-
- if (!SWFDEC_IS_AS_NUMBER (object))
- return;
-
- num = SWFDEC_AS_NUMBER (object);
- SWFDEC_AS_VALUE_SET_NUMBER (ret, num->number);
-}
-
-// only available as ASnative
-SWFDEC_AS_NATIVE (3, 1, swfdec_as_number_old_constructor)
-void
-swfdec_as_number_old_constructor (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("old 'Number' function (only available as ASnative)");
-}
-
-// only available as ASnative
-SWFDEC_AS_NATIVE (3, 4, swfdec_as_number_old_toString)
-void
-swfdec_as_number_old_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("old 'Number.prototype.toString' function (only available as ASnative)");
-}
diff --git a/libswfdec/swfdec_as_number.h b/libswfdec/swfdec_as_number.h
deleted file mode 100644
index 9b6ede0..0000000
--- a/libswfdec/swfdec_as_number.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AS_NUMBER_H_
-#define _SWFDEC_AS_NUMBER_H_
-
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecAsNumber SwfdecAsNumber;
-typedef struct _SwfdecAsNumberClass SwfdecAsNumberClass;
-
-#define SWFDEC_TYPE_AS_NUMBER (swfdec_as_number_get_type())
-#define SWFDEC_IS_AS_NUMBER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_NUMBER))
-#define SWFDEC_IS_AS_NUMBER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_NUMBER))
-#define SWFDEC_AS_NUMBER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_NUMBER, SwfdecAsNumber))
-#define SWFDEC_AS_NUMBER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_NUMBER, SwfdecAsNumberClass))
-#define SWFDEC_AS_NUMBER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_NUMBER, SwfdecAsNumberClass))
-
-struct _SwfdecAsNumber {
- SwfdecAsObject object;
-
- double number; /* number represented by this number object */
-};
-
-struct _SwfdecAsNumberClass {
- SwfdecAsObjectClass object_class;
-};
-
-GType swfdec_as_number_get_type (void);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_as_object.c b/libswfdec/swfdec_as_object.c
deleted file mode 100644
index d898f01..0000000
--- a/libswfdec/swfdec_as_object.c
+++ /dev/null
@@ -1,1773 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "swfdec_as_object.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_frame_internal.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_native_function.h"
-#include "swfdec_as_stack.h"
-#include "swfdec_as_string.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_as_super.h"
-#include "swfdec_debug.h"
-#include "swfdec_movie.h"
-
-/**
- * SECTION:SwfdecAsObject
- * @title: SwfdecAsObject
- * @short_description: the base object type for scriptable objects
- *
- * This is the basic object type in Swfdec. Every object used by the script
- * engine must be a #SwfdecAsObject. It handles memory management and assigning
- * variables to it. Almost all functions that are called on objects require that
- * the objects have been added to the garbage collector previously. For
- * custom-created objects, you need to do this using swfdec_as_object_add(),
- * built-in functions that create objects do this manually.
- *
- * Note that you cannot know the lifetime of a #SwfdecAsObject, since scripts
- * may assign it as a variable to other objects. So you should not assume to
- * know when an object gets removed.
- */
-
-/**
- * SwfdecAsObject:
- *
- * Every object value inside the Swfdec script engine must be a SwfdecAsObject.
- * If you want to add custom objects to your script engine, you need to create a
- * subclass. The class provides a number of virtual functions that you can
- * override to achieve the desired behaviour.
- */
-
-/**
- * SwfdecAsVariableFlag:
- * @SWFDEC_AS_VARIABLE_HIDDEN: Do not include variable in enumerations and
- * swfdec_as_object_foreach().
- * @SWFDEC_AS_VARIABLE_PERMANENT: Do not allow swfdec_as_object_delete_variable()
- * to delete this variable.
- * @SWFDEC_AS_VARIABLE_CONSTANT: Do not allow changing the value with
- * swfdec_as_object_set_variable().
- * @SWFDEC_AS_VARIABLE_VERSION_6_UP: This symbol is only visible in version 6
- * and above.
- * @SWFDEC_AS_VARIABLE_VERSION_NOT_6: This symbols is visible in all versions
- * but version 6.
- * @SWFDEC_AS_VARIABLE_VERSION_7_UP: This symbol is only visible in version 7
- * and above.
- * @SWFDEC_AS_VARIABLE_VERSION_8_UP: This symbol is only visible in version 8
- * and above.
- * @SWFDEC_AS_VARIABLE_VERSION_9_UP: This symbol is only visible in version 9
- * and above.
- *
- * These flags are used to describe various properties of a variable inside
- * Swfdec. You can manually set them with swfdec_as_object_set_variable_flags().
- */
-
-/**
- * SwfdecAsDeleteReturn:
- * @SWFDEC_AS_DELETE_NOT_FOUND: The variable was not found and therefore
- * couldn't be deleted.
- * @SWFDEC_AS_DELETE_DELETED: The variable was deleted.
- * @SWFDEC_AS_DELETE_NOT_DELETED: The variable was found but could not be
- * deleted.
- *
- * This is the return value used by swfdec_as_object_delete_variable(). It
- * describes the various outcomes of trying to delete a variable.
- */
-
-/**
- * SwfdecAsVariableForeach:
- * @object: The object this function is run on
- * @variable: garbage-collected name of the current variables
- * @value: value of the current variable
- * @flags: Flags associated with the current variable
- * @data: User data passed to swfdec_as_object_foreach()
- *
- * Function prototype for the swfdec_as_object_foreach() function.
- *
- * Returns: %TRUE to continue running the foreach function, %FALSE to stop
- */
-
-typedef struct _SwfdecAsVariable SwfdecAsVariable;
-struct _SwfdecAsVariable {
- guint flags; /* SwfdecAsVariableFlag values */
- SwfdecAsValue value; /* value of property */
- SwfdecAsFunction * get; /* getter set with swfdec_as_object_add_property */
- SwfdecAsFunction * set; /* setter or %NULL */
-};
-
-typedef struct {
- SwfdecAsFunction * watch; /* watcher or %NULL */
- SwfdecAsValue watch_data; /* user data to watcher */
- guint refcount; /* refcount - misused for recursion detection */
-} SwfdecAsWatch;
-
-G_DEFINE_TYPE (SwfdecAsObject, swfdec_as_object, G_TYPE_OBJECT)
-
-static void
-swfdec_as_object_dispose (GObject *gobject)
-{
- SwfdecAsObject *object = SWFDEC_AS_OBJECT (gobject);
-
- g_assert (object->properties == NULL);
- g_slist_free (object->interfaces);
- object->interfaces = NULL;
-
- G_OBJECT_CLASS (swfdec_as_object_parent_class)->dispose (gobject);
-}
-
-static void
-swfdec_as_object_mark_property (gpointer key, gpointer value, gpointer unused)
-{
- SwfdecAsVariable *var = value;
-
- swfdec_as_string_mark (key);
- if (var->get) {
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (var->get));
- if (var->set)
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (var->set));
- } else {
- swfdec_as_value_mark (&var->value);
- }
-}
-
-static void
-swfdec_as_object_mark_watch (gpointer key, gpointer value, gpointer unused)
-{
- SwfdecAsWatch *watch = value;
-
- swfdec_as_string_mark (key);
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (watch->watch));
- swfdec_as_value_mark (&watch->watch_data);
-}
-
-static void
-swfdec_as_object_do_mark (SwfdecAsObject *object)
-{
- if (object->prototype)
- swfdec_as_object_mark (object->prototype);
- g_hash_table_foreach (object->properties, swfdec_as_object_mark_property, NULL);
- if (object->watches)
- g_hash_table_foreach (object->watches, swfdec_as_object_mark_watch, NULL);
- g_slist_foreach (object->interfaces, (GFunc) swfdec_as_object_mark, NULL);
-}
-
-static void
-swfdec_as_object_do_add (SwfdecAsObject *object)
-{
-}
-
-static gboolean
-swfdec_as_object_lookup_case_insensitive (gpointer key, gpointer value, gpointer user_data)
-{
- return g_ascii_strcasecmp (key, user_data) == 0;
-}
-
-static gboolean
-swfdec_as_variable_name_is_valid (const char *name)
-{
- return name != SWFDEC_AS_STR_EMPTY;
-}
-
-static inline SwfdecAsVariable *
-swfdec_as_object_hash_lookup (SwfdecAsObject *object, const char *variable)
-{
- SwfdecAsVariable *var = g_hash_table_lookup (object->properties, variable);
-
- if (var || object->context->version >= 7)
- return var;
- var = g_hash_table_find (object->properties, swfdec_as_object_lookup_case_insensitive, (gpointer) variable);
- return var;
-}
-
-static inline SwfdecAsVariable *
-swfdec_as_object_hash_create (SwfdecAsObject *object, const char *variable, guint flags)
-{
- SwfdecAsVariable *var;
-
- if (!swfdec_as_context_use_mem (object->context, sizeof (SwfdecAsVariable)))
- return NULL;
- if (!swfdec_as_variable_name_is_valid (variable))
- return NULL;
- var = g_slice_new0 (SwfdecAsVariable);
- var->flags = flags;
- g_hash_table_insert (object->properties, (gpointer) variable, var);
-
- return var;
-}
-
-static gboolean
-swfdec_as_object_variable_enabled_in_version (SwfdecAsVariable *var,
- guint version)
-{
- if (var->flags & SWFDEC_AS_VARIABLE_VERSION_6_UP && version < 6)
- return FALSE;
- if (var->flags & SWFDEC_AS_VARIABLE_VERSION_NOT_6 && version == 6)
- return FALSE;
- if (var->flags & SWFDEC_AS_VARIABLE_VERSION_7_UP && version < 7)
- return FALSE;
- if (var->flags & SWFDEC_AS_VARIABLE_VERSION_8_UP && version < 8)
- return FALSE;
- if (var->flags & SWFDEC_AS_VARIABLE_VERSION_9_UP && version < 9)
- return FALSE;
-
- return TRUE;
-}
-
-static gboolean
-swfdec_as_object_do_get (SwfdecAsObject *object, SwfdecAsObject *orig,
- const char *variable, SwfdecAsValue *val, guint *flags)
-{
- SwfdecAsVariable *var = swfdec_as_object_hash_lookup (object, variable);
-
- if (var == NULL)
- return FALSE;
-
- /* variable flag checks */
- if (!swfdec_as_object_variable_enabled_in_version (var,
- object->context->version))
- return FALSE;
-
- if (var->get) {
- swfdec_as_function_call (var->get, orig, 0, NULL, val);
- swfdec_as_context_run (object->context);
- *flags = var->flags;
- } else {
- *val = var->value;
- *flags = var->flags;
- }
- return TRUE;
-}
-
-static SwfdecAsWatch *
-swfdec_as_watch_new (SwfdecAsFunction *function)
-{
- SwfdecAsWatch *watch;
-
- if (!swfdec_as_context_use_mem (SWFDEC_AS_OBJECT (function)->context,
- sizeof (SwfdecAsWatch)))
- return NULL;
-
- watch = g_slice_new (SwfdecAsWatch);
- watch->refcount = 1;
- watch->watch = function;
- SWFDEC_AS_VALUE_SET_UNDEFINED (&watch->watch_data);
- return watch;
-}
-
-static inline gboolean
-swfdec_as_watch_can_recurse (SwfdecAsWatch *watch)
-{
- guint version;
-
- version = SWFDEC_AS_OBJECT (watch->watch)->context->version;
- if (version <= 6) {
- return watch->refcount <= 1;
- } else {
- return watch->refcount <= 64 + 1;
- }
-}
-
-static inline void
-swfdec_as_watch_ref (SwfdecAsWatch *watch)
-{
- watch->refcount++;
-}
-
-static inline void
-swfdec_as_watch_unref (SwfdecAsWatch *watch)
-{
- watch->refcount--;
- if (watch->refcount == 0) {
- swfdec_as_context_unuse_mem (SWFDEC_AS_OBJECT (watch->watch)->context,
- sizeof (SwfdecAsWatch));
- g_slice_free (SwfdecAsWatch, watch);
- }
-}
-
-/*
- * Like swfdec_as_object_get_prototype, but doesn't check 8_UP flag when
- * version is 7 and doesn't check if the property has been deleted if version
- * is 6 or earlier
- */
-static SwfdecAsObject *
-swfdec_as_object_get_prototype_internal (SwfdecAsObject *object)
-{
- int version;
-
- g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL);
-
- version = object->context->version;
-
- if (object->prototype == NULL)
- return NULL;
-
- if (object->prototype_flags & SWFDEC_AS_VARIABLE_VERSION_6_UP && version < 6)
- return NULL;
- // don't check for NOT_6 flag
- if (object->prototype_flags & SWFDEC_AS_VARIABLE_VERSION_7_UP && version < 7)
- return NULL;
- // don't check 8_UP or 9_UP for version 6, 7 or 8
- if (object->prototype_flags & (SWFDEC_AS_VARIABLE_VERSION_8_UP | SWFDEC_AS_VARIABLE_VERSION_9_UP) && version < 6)
- return NULL;
- // check that it exists, if version < 7
- if (version < 7 &&
- !swfdec_as_object_hash_lookup (object, SWFDEC_AS_STR___proto__))
- return NULL;
-
- return object->prototype;
-}
-
-/*
- * Get's the object->prototype, if propflags allow it for current version and
- * if it hasn't been deleted from the object already
- */
-SwfdecAsObject *
-swfdec_as_object_get_prototype (SwfdecAsObject *object)
-{
- int version;
- SwfdecAsObject *prototype;
-
- g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL);
-
- version = object->context->version;
-
- prototype = swfdec_as_object_get_prototype_internal (object);
-
- if (prototype == NULL)
- return NULL;
- // check 8_UP for version 7, still not for version 6
- if (object->prototype_flags & SWFDEC_AS_VARIABLE_VERSION_8_UP &&
- version == 7)
- return NULL;
- // check 9_UP flag for version 8, still not for version 7 or 6
- if (object->prototype_flags & SWFDEC_AS_VARIABLE_VERSION_9_UP &&
- version == 8)
- return NULL;
- // require it to exist even on version >= 7
- if (version >= 7 &&
- !swfdec_as_object_hash_lookup (object, SWFDEC_AS_STR___proto__))
- return NULL;
-
- return object->prototype;
-}
-
-static SwfdecAsVariable *
-swfdec_as_object_hash_lookup_with_prototype (SwfdecAsObject *object,
- const char *variable, SwfdecAsObject **proto)
-{
- SwfdecAsVariable *var;
- SwfdecAsObject *proto_;
-
- g_return_val_if_fail (swfdec_as_variable_name_is_valid (variable), NULL);
-
- proto_ = NULL;
-
- // match first level variable even if it has version flags that hide it in
- // this version
- var = swfdec_as_object_hash_lookup (object, variable);
- if (var == NULL && variable != SWFDEC_AS_STR___proto__) {
- guint i;
-
- proto_ = swfdec_as_object_get_prototype (object);
-
- for (i = 0; i < SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT && proto_; i++) {
- var = swfdec_as_object_hash_lookup (proto_, variable);
- if (var && var->get)
- break;
- proto_ = swfdec_as_object_get_prototype (proto_);
- var = NULL;
- }
-
- if (i == SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT) {
- swfdec_as_context_abort (object->context, "Prototype recursion limit exceeded");
- return NULL;
- }
- }
-
- if (proto != NULL)
- *proto = proto_;
-
- return var;
-}
-
-static void
-swfdec_as_object_do_set (SwfdecAsObject *object, const char *variable,
- const SwfdecAsValue *val, guint flags)
-{
- SwfdecAsVariable *var;
- SwfdecAsWatch *watch;
- SwfdecAsObject *proto;
-
- if (!swfdec_as_variable_name_is_valid (variable))
- return;
-
- var = swfdec_as_object_hash_lookup_with_prototype (object, variable, &proto);
- if (swfdec_as_context_is_aborted (object->context))
- return;
-
- // if variable is disabled in this version
- if (var != NULL && !swfdec_as_object_variable_enabled_in_version (var,
- object->context->version)) {
- if (proto == NULL) {
- // it's at the top level, remove getter and setter plus overwrite
- var->get = NULL;
- var->set = NULL;
- } else {
- // it's in proto, we create a new one at the top level
- var = NULL;
- }
- }
-
- if (var == NULL) {
- var = swfdec_as_object_hash_create (object, variable, flags);
- if (var == NULL)
- return;
- } else {
- if (var->flags & SWFDEC_AS_VARIABLE_CONSTANT)
- return;
- // remove the flags that could make this variable hidden
- if (object->context->version == 6) {
- // version 6, so let's forget SWFDEC_AS_VARIABLE_VERSION_7_UP flag, oops!
- // we will still set the value though, even if that flag is set
- var->flags &= ~(SWFDEC_AS_VARIABLE_VERSION_6_UP |
- SWFDEC_AS_VARIABLE_VERSION_NOT_6 | SWFDEC_AS_VARIABLE_VERSION_8_UP |
- SWFDEC_AS_VARIABLE_VERSION_9_UP);
- } else {
- var->flags &= ~(SWFDEC_AS_VARIABLE_VERSION_6_UP |
- SWFDEC_AS_VARIABLE_VERSION_NOT_6 | SWFDEC_AS_VARIABLE_VERSION_7_UP |
- SWFDEC_AS_VARIABLE_VERSION_8_UP | SWFDEC_AS_VARIABLE_VERSION_9_UP);
- }
- }
- if (object->watches) {
- SwfdecAsValue ret = *val;
- watch = g_hash_table_lookup (object->watches, variable);
- /* FIXME: figure out if this limit here is correct. Add a watch in Flash 7
- * and set a variable using Flash 6 */
- if (watch && swfdec_as_watch_can_recurse (watch)) {
- SwfdecAsValue args[4];
- SWFDEC_AS_VALUE_SET_STRING (&args[0], variable);
- args[1] = var->value;
- args[2] = *val;
- args[3] = watch->watch_data;
- swfdec_as_watch_ref (watch);
- swfdec_as_function_call (watch->watch, object, 4, args, &ret);
- swfdec_as_context_run (object->context);
- swfdec_as_watch_unref (watch);
- var = swfdec_as_object_hash_lookup_with_prototype (object, variable,
- NULL);
- if (swfdec_as_context_is_aborted (object->context))
- return;
- if (var == NULL) {
- SWFDEC_INFO ("watch removed variable %s", variable);
- return;
- }
- }
-
- var->value = ret;
- } else {
- watch = NULL;
- }
- if (var->get) {
- if (var->set) {
- SwfdecAsValue tmp;
- swfdec_as_function_call (var->set, object, 1, val, &tmp);
- swfdec_as_context_run (object->context);
- }
- } else if (watch == NULL) {
- var->value = *val;
- }
-
- if (variable == SWFDEC_AS_STR___proto__) {
- if (SWFDEC_AS_VALUE_IS_OBJECT (val) &&
- !SWFDEC_IS_MOVIE (SWFDEC_AS_VALUE_GET_OBJECT (val))) {
- object->prototype = SWFDEC_AS_VALUE_GET_OBJECT (val);
- object->prototype_flags = var->flags;
- } else {
- object->prototype = NULL;
- object->prototype_flags = 0;
- }
- }
-}
-
-static void
-swfdec_as_object_do_set_flags (SwfdecAsObject *object, const char *variable, guint flags, guint mask)
-{
- SwfdecAsVariable *var = swfdec_as_object_hash_lookup (object, variable);
-
- if (var) {
- var->flags = (var->flags & ~mask) | flags;
-
- if (variable == SWFDEC_AS_STR___proto__)
- object->prototype_flags = var->flags;
- }
-}
-
-static void
-swfdec_as_object_free_property (gpointer key, gpointer value, gpointer data)
-{
- SwfdecAsObject *object = data;
-
- swfdec_as_context_unuse_mem (object->context, sizeof (SwfdecAsVariable));
- g_slice_free (SwfdecAsVariable, value);
-}
-
-static SwfdecAsDeleteReturn
-swfdec_as_object_do_delete (SwfdecAsObject *object, const char *variable)
-{
- SwfdecAsVariable *var;
-
- var = g_hash_table_lookup (object->properties, variable);
- if (var == NULL)
- return SWFDEC_AS_DELETE_NOT_FOUND;
- if (var->flags & SWFDEC_AS_VARIABLE_PERMANENT)
- return SWFDEC_AS_DELETE_NOT_DELETED;
-
- // Note: We won't remove object->prototype, even if __proto__ is deleted
-
- swfdec_as_object_free_property (NULL, var, object);
- if (!g_hash_table_remove (object->properties, variable)) {
- g_assert_not_reached ();
- }
- return SWFDEC_AS_DELETE_DELETED;
-}
-
-typedef struct {
- SwfdecAsObject * object;
- SwfdecAsVariableForeach func;
- gpointer data;
- gboolean retval;
-} ForeachData;
-
-static void
-swfdec_as_object_hash_foreach (gpointer key, gpointer value, gpointer data)
-{
- ForeachData *fdata = data;
- SwfdecAsVariable *var = value;
-
- if (!fdata->retval)
- return;
-
- fdata->retval = fdata->func (fdata->object, key, &var->value, var->flags, fdata->data);
-}
-
-/* FIXME: does not do Adobe Flash's order for Enumerate actions */
-static gboolean
-swfdec_as_object_do_foreach (SwfdecAsObject *object, SwfdecAsVariableForeach func, gpointer data)
-{
- ForeachData fdata = { object, func, data, TRUE };
-
- g_hash_table_foreach (object->properties, swfdec_as_object_hash_foreach, &fdata);
- return fdata.retval;
-}
-
-typedef struct {
- SwfdecAsObject * object;
- SwfdecAsVariableForeachRemove func;
- gpointer data;
-} ForeachRemoveData;
-
-static gboolean
-swfdec_as_object_hash_foreach_remove (gpointer key, gpointer value, gpointer data)
-{
- ForeachRemoveData *fdata = data;
- SwfdecAsVariable *var = value;
-
- if (!fdata->func (fdata->object, key, &var->value, var->flags, fdata->data))
- return FALSE;
-
- swfdec_as_object_free_property (NULL, var, fdata->object);
- return TRUE;
-}
-
-/**
- * swfdec_as_object_foreach_remove:
- * @object: a #SwfdecAsObject
- * @func: function that determines which object to remove
- * @data: data to pass to @func
- *
- * Removes all variables form @object where @func returns %TRUE. This is an
- * internal function for array operations.
- *
- * Returns: he number of variables removed
- **/
-guint
-swfdec_as_object_foreach_remove (SwfdecAsObject *object, SwfdecAsVariableForeach func,
- gpointer data)
-{
- ForeachRemoveData fdata = { object, func, data };
-
- g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), 0);
- g_return_val_if_fail (func != NULL, 0);
-
- return g_hash_table_foreach_remove (object->properties,
- swfdec_as_object_hash_foreach_remove, &fdata);
-}
-
-typedef struct {
- SwfdecAsObject * object;
- GHashTable * properties_new;
- SwfdecAsVariableForeachRename func;
- gpointer data;
-} ForeachRenameData;
-
-static gboolean
-swfdec_as_object_hash_foreach_rename (gpointer key, gpointer value, gpointer data)
-{
- ForeachRenameData *fdata = data;
- SwfdecAsVariable *var = value;
- const char *key_new;
-
- key_new = fdata->func (fdata->object, key, &var->value, var->flags, fdata->data);
- if (key_new) {
- g_hash_table_insert (fdata->properties_new, (gpointer) key_new, var);
- } else {
- swfdec_as_object_free_property (NULL, var, fdata->object);
- }
-
- return TRUE;
-}
-
-/**
- * swfdec_as_object_foreach_rename:
- * @object: a #SwfdecAsObject
- * @func: function determining the new name
- * @data: data to pass to @func
- *
- * Calls @func for each variable of @object. The function is then supposed
- * to return the new name of the variable or %NULL if the variable should be
- * removed. This is an internal function for array operations.
- **/
-void
-swfdec_as_object_foreach_rename (SwfdecAsObject *object, SwfdecAsVariableForeachRename func,
- gpointer data)
-{
- ForeachRenameData fdata = { object, NULL, func, data };
-
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
- g_return_if_fail (func != NULL);
-
- fdata.properties_new = g_hash_table_new (g_direct_hash, g_direct_equal);
- g_hash_table_foreach_remove (object->properties, swfdec_as_object_hash_foreach_rename, &fdata);
- g_hash_table_destroy (object->properties);
- object->properties = fdata.properties_new;
-}
-
-static char *
-swfdec_as_object_do_debug (SwfdecAsObject *object)
-{
- if (G_OBJECT_TYPE (object) != SWFDEC_TYPE_AS_OBJECT)
- return g_strdup (G_OBJECT_TYPE_NAME (object));
-
- return g_strdup ("Object");
-}
-
-static void
-swfdec_as_object_class_init (SwfdecAsObjectClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->dispose = swfdec_as_object_dispose;
-
- klass->mark = swfdec_as_object_do_mark;
- klass->add = swfdec_as_object_do_add;
- klass->get = swfdec_as_object_do_get;
- klass->set = swfdec_as_object_do_set;
- klass->set_flags = swfdec_as_object_do_set_flags;
- klass->del = swfdec_as_object_do_delete;
- klass->foreach = swfdec_as_object_do_foreach;
- klass->debug = swfdec_as_object_do_debug;
-}
-
-static void
-swfdec_as_object_init (SwfdecAsObject *object)
-{
-}
-
-/**
- * swfdec_as_object_new_empty:
- * @context: a #SwfdecAsContext
- *
- * Creates an empty object. The prototype and constructor properties of the
- * returned object will not be set. You probably want to call
- * swfdec_as_object_set_constructor() on the returned object yourself.
- * You may want to use swfdec_as_object_new() instead.
- *
- * Returns: A new #SwfdecAsObject adde to @context or %NULL on OOM.
- **/
-SwfdecAsObject *
-swfdec_as_object_new_empty (SwfdecAsContext *context)
-{
- SwfdecAsObject *object;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
-
- if (!swfdec_as_context_use_mem (context, sizeof (SwfdecAsObject)))
- return NULL;
- object = g_object_new (SWFDEC_TYPE_AS_OBJECT, NULL);
- swfdec_as_object_add (object, context, sizeof (SwfdecAsObject));
- return object;
-}
-
-/**
- * swfdec_as_object_new:
- * @context: a #SwfdecAsContext
- *
- * Allocates a new Object. This does the same as the Actionscript code
- * "new Object()".
- *
- * Returns: the new object or NULL on out of memory.
- **/
-SwfdecAsObject *
-swfdec_as_object_new (SwfdecAsContext *context)
-{
- SwfdecAsObject *object;
- SwfdecAsValue val;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
- g_assert (context->Object);
- g_assert (context->Object_prototype);
-
- object = swfdec_as_object_new_empty (context);
- if (object == NULL)
- return NULL;
- SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object);
- swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR_constructor,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
- SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object_prototype);
- swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR___proto__,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
- return object;
-}
-
-/**
- * swfdec_as_object_add:
- * @object: #SwfdecAsObject to make garbage-collected
- * @context: #SwfdecAsContext that should manage the object
- * @size: size the object currently uses
- *
- * Takes over the reference to @object for the garbage collector of @context.
- * The object may not already be part of a different context. The given @size
- * must have been allocated before with swfdec_as_context_use_mem ().
- * Note that after swfdec_as_object_add() the garbage collector might hold the
- * only reference to @object.
- **/
-void
-swfdec_as_object_add (SwfdecAsObject *object, SwfdecAsContext *context, gsize size)
-{
- SwfdecAsObjectClass *klass;
-
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
- g_return_if_fail (object->properties == NULL);
-
- object->context = context;
- object->size = size;
- g_hash_table_insert (context->objects, object, object);
- object->properties = g_hash_table_new (g_direct_hash, g_direct_equal);
- klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
- g_return_if_fail (klass->add);
- klass->add (object);
- if (context->debugger) {
- SwfdecAsDebuggerClass *dklass = SWFDEC_AS_DEBUGGER_GET_CLASS (context->debugger);
- if (dklass->add)
- dklass->add (context->debugger, context, object);
- }
-}
-
-/* This is a huge hack design-wise, but we can't use watch->watch,
- * it might be gone already */
-static gboolean
-swfdec_as_object_steal_watches (gpointer key, gpointer value, gpointer object)
-{
- SwfdecAsWatch *watch = value;
-
- g_assert (watch->refcount == 1);
- watch->watch = (SwfdecAsFunction *) object;
- swfdec_as_watch_unref (watch);
- return TRUE;
-}
-
-void
-swfdec_as_object_collect (SwfdecAsObject *object)
-{
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
- g_return_if_fail (object->properties != NULL);
-
- g_hash_table_foreach (object->properties, swfdec_as_object_free_property, object);
- g_hash_table_destroy (object->properties);
- object->properties = NULL;
- if (object->watches) {
- g_hash_table_foreach_steal (object->watches, swfdec_as_object_steal_watches, object);
- g_hash_table_destroy (object->watches);
- object->watches = NULL;
- }
- if (object->size)
- swfdec_as_context_unuse_mem (object->context, object->size);
- g_object_unref (object);
-}
-
-/**
- * swfdec_as_object_set_variable:
- * @object: a #SwfdecAsObject
- * @variable: garbage-collected name of the variable to set
- * @value: value to set the variable to
- *
- * Sets a variable on @object. It is not guaranteed that getting the variable
- * after setting it results in the same value. This is a mcaro that calls
- * swfdec_as_object_set_variable_and_flags()
- **/
-/**
- * swfdec_as_object_set_variable_and_flags:
- * @object: a #SwfdecAsObject
- * @variable: garbage-collected name of the variable to set
- * @value: value to set the variable to
- * @default_flags: flags to use if creating the variable anew - the flags will
- * be ignored if the property already exists.
- *
- * Sets a variable on @object. It is not guaranteed that getting the variable
- * after setting it results in the same value, because various mechanisms (like
- * the Actionscript Object.addProperty function or constant variables) can
- * avoid this.
- **/
-void
-swfdec_as_object_set_variable_and_flags (SwfdecAsObject *object,
- const char *variable, const SwfdecAsValue *value, guint default_flags)
-{
- SwfdecAsObjectClass *klass;
-
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
- g_return_if_fail (variable != NULL);
- g_return_if_fail (SWFDEC_IS_AS_VALUE (value));
-
- if (object->context->debugger) {
- SwfdecAsDebugger *debugger = object->context->debugger;
- SwfdecAsDebuggerClass *dklass = SWFDEC_AS_DEBUGGER_GET_CLASS (debugger);
- if (dklass->set_variable)
- dklass->set_variable (debugger, object->context, object, variable, value);
- }
- klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
- klass->set (object, variable, value, default_flags);
-}
-
-/**
- * swfdec_as_object_peek_variable:
- * @object: the object to query
- * @name: name of the variable to query
- *
- * Checks if the given @object contains a variable wih the given @name and if
- * so, returns a pointer to its value. This pointer will be valid until calling
- * a setting function on the given object again.
- * <warning><para>This function is internal as it provides a pointer to an
- * internal structure. Do not use it unless you are sure you need to. This
- * function skips prototypes, variables added via swfdec_as_value_add_variable()
- * and does not verify visibility flags.</para></warning>
- *
- * Returns: a pointer to the queried variable or %NULL if it doesn't exist
- **/
-SwfdecAsValue *
-swfdec_as_object_peek_variable (SwfdecAsObject *object, const char *name)
-{
- SwfdecAsVariable *var;
-
- var = swfdec_as_object_hash_lookup (object, name);
- if (var == NULL ||
- var->get != NULL)
- return NULL;
-
- return &var->value;
-}
-
-/**
- * swfdec_as_object_get_variable:
- * @object: a #SwfdecAsObject
- * @variable: a garbage-collected string containing the name of the variable
- * @value: pointer to a #SwfdecAsValue that takes the return value or %NULL
- *
- * Gets the value of the given @variable on @object. It walks the prototype
- * chain. This is a shortcut macro for
- * swfdec_as_object_get_variable_and_flags().
- *
- * Returns: %TRUE if the variable existed, %FALSE otherwise
- */
-
-/**
- * swfdec_as_object_get_variable_and_flags:
- * @object: a #SwfdecAsObject
- * @variable: a garbage-collected string containing the name of the variable
- * @value: pointer to a #SwfdecAsValue that takes the return value or %NULL
- * @flags: pointer to a guint taking the variable's flags or %NULL
- * @pobject: pointer to set to the object that really holds the property or
- * %NULL
- *
- * Looks up @variable on @object. It also walks the object's prototype chain.
- * If the variable exists, its value, flags and the real object containing the
- * variable will be set and %TRUE will be returned.
- *
- * Returns: %TRUE if the variable exists, %FALSE otherwise
- **/
-gboolean
-swfdec_as_object_get_variable_and_flags (SwfdecAsObject *object,
- const char *variable, SwfdecAsValue *value, guint *flags, SwfdecAsObject **pobject)
-{
- SwfdecAsObjectClass *klass;
- guint i;
- SwfdecAsValue tmp_val;
- guint tmp_flags;
- SwfdecAsObject *tmp_pobject, *cur;
-
- g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), FALSE);
- g_return_val_if_fail (variable != NULL, FALSE);
-
- if (value == NULL)
- value = &tmp_val;
- if (flags == NULL)
- flags = &tmp_flags;
- if (pobject == NULL)
- pobject = &tmp_pobject;
-
- cur = object;
- for (i = 0; i <= SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT && cur != NULL; i++) {
- klass = SWFDEC_AS_OBJECT_GET_CLASS (cur);
- if (klass->get (cur, object, variable, value, flags)) {
- *pobject = cur;
- return TRUE;
- }
- cur = swfdec_as_object_get_prototype_internal (cur);
- }
- if (i > SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT) {
- swfdec_as_context_abort (object->context, "Prototype recursion limit exceeded");
- *flags = 0;
- *pobject = NULL;
- return FALSE;
- }
- //SWFDEC_WARNING ("no such variable %s", variable);
- SWFDEC_AS_VALUE_SET_UNDEFINED (value);
- *flags = 0;
- *pobject = NULL;
- return FALSE;
-}
-
-/**
- * swfdec_as_object_has_variable:
- * @object: a #SwfdecAsObject
- * @variable: garbage-collected variable name
- *
- * Checks if a user-set @variable with the given name exists on @object. This
- * function does not check variables that are available via an overwritten get
- * function of the object's class.
- *
- * Returns: %TRUE if the @object contains the given @variable
- **/
-gboolean
-swfdec_as_object_has_variable (SwfdecAsObject *object, const char *variable)
-{
- guint i;
- SwfdecAsVariable *var;
-
- g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), FALSE);
-
- for (i = 0; i <= SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT && object != NULL; i++) {
- var = swfdec_as_object_hash_lookup (object, variable);
- if (var) {
- /* FIXME: propflags? */
- return TRUE;
- }
- object = swfdec_as_object_get_prototype_internal (object);
- }
- return FALSE;
-}
-
-/**
- * swfdec_as_object_delete_variable:
- * @object: a #SwfdecAsObject
- * @variable: garbage-collected name of the variable
- *
- * Deletes the given variable if possible. If the variable is protected from
- * deletion, it will not be deleted.
- *
- * Returns: See #SwfdecAsDeleteReturn for details of the return value.
- **/
-SwfdecAsDeleteReturn
-swfdec_as_object_delete_variable (SwfdecAsObject *object, const char *variable)
-{
- SwfdecAsObjectClass *klass;
-
- g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), FALSE);
- g_return_val_if_fail (variable != NULL, FALSE);
-
- klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
- return klass->del (object, variable);
-}
-
-/**
- * swfdec_as_object_delete_all_variables:
- * @object: a #SwfdecAsObject
- *
- * Deletes all user-set variables from the given object.
- **/
-void
-swfdec_as_object_delete_all_variables (SwfdecAsObject *object)
-{
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
-
- g_hash_table_foreach (object->properties, swfdec_as_object_free_property, object);
- g_hash_table_remove_all (object->properties);
-}
-
-/**
- * swfdec_as_object_set_variable_flags:
- * @object: a #SwfdecAsObject
- * @variable: the variable to modify
- * @flags: flags to set
- *
- * Sets the given flags for the given variable.
- **/
-void
-swfdec_as_object_set_variable_flags (SwfdecAsObject *object,
- const char *variable, SwfdecAsVariableFlag flags)
-{
- SwfdecAsObjectClass *klass;
-
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
- g_return_if_fail (variable != NULL);
-
- klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
- klass->set_flags (object, variable, flags, flags);
-}
-
-/**
- * swfdec_as_object_unset_variable_flags:
- * @object: a #SwfdecAsObject
- * @variable: the variable to modify
- * @flags: flags to unset
- *
- * Unsets the given flags for the given variable. The variable must exist in
- * @object.
- **/
-void
-swfdec_as_object_unset_variable_flags (SwfdecAsObject *object,
- const char *variable, SwfdecAsVariableFlag flags)
-{
- SwfdecAsObjectClass *klass;
-
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
- g_return_if_fail (variable != NULL);
-
- klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
- klass->set_flags (object, variable, 0, flags);
-}
-
-/**
- * swfdec_as_object_foreach:
- * @object: a #SwfdecAsObject
- * @func: function to call
- * @data: data to pass to @func
- *
- * Calls @func for every variable of @object or until @func returns %FALSE. The
- * variables of @object must not be modified by @func.
- *
- * Returns: %TRUE if @func always returned %TRUE
- **/
-gboolean
-swfdec_as_object_foreach (SwfdecAsObject *object, SwfdecAsVariableForeach func,
- gpointer data)
-{
- SwfdecAsObjectClass *klass;
-
- g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), FALSE);
- g_return_val_if_fail (func != NULL, FALSE);
-
- klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
- g_return_val_if_fail (klass->foreach != NULL, FALSE);
- return klass->foreach (object, func, data);
-}
-
-/*** SIMPLIFICATIONS ***/
-
-static void
-swfdec_as_object_do_nothing (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
-}
-
-/**
- * swfdec_as_object_add_function:
- * @object: a #SwfdecAsObject
- * @name: name of the function. The string does not have to be
- * garbage-collected.
- * @type: the required type of the this Object to make this function execute.
- * May be 0 to accept any type.
- * @native: a native function or %NULL to just not do anything
- * @min_args: minimum number of arguments to pass to @native
- *
- * Adds @native as a variable named @name to @object. The newly added variable
- * will not be enumerated.
- *
- * Returns: the newly created #SwfdecAsFunction or %NULL on error.
- **/
-SwfdecAsFunction *
-swfdec_as_object_add_function (SwfdecAsObject *object, const char *name, GType type,
- SwfdecAsNative native, guint min_args)
-{
- g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL);
- g_return_val_if_fail (name != NULL, NULL);
- g_return_val_if_fail (type == 0 || g_type_is_a (type, SWFDEC_TYPE_AS_OBJECT), NULL);
-
- return swfdec_as_object_add_constructor (object, name, type, 0, native, min_args, NULL);
-}
-
-/**
- * swfdec_as_object_add_constructor:
- * @object: a #SwfdecAsObject
- * @name: name of the function. The string does not have to be
- * garbage-collected.
- * @type: the required type of the this Object to make this function execute.
- * May be 0 to accept any type.
- * @construct_type: type used when using this function as a constructor. May
- * be 0 to use the default type.
- * @native: a native function or %NULL to just not do anything
- * @min_args: minimum number of arguments to pass to @native
- * @prototype: An optional object to be set as the "prototype" property of the
- * new function. The prototype will be hidden and constant.
- *
- * Adds @native as a constructor named @name to @object. The newly added variable
- * will not be enumerated.
- *
- * Returns: the newly created #SwfdecAsFunction or %NULL on error.
- **/
-SwfdecAsFunction *
-swfdec_as_object_add_constructor (SwfdecAsObject *object, const char *name, GType type,
- GType construct_type, SwfdecAsNative native, guint min_args, SwfdecAsObject *prototype)
-{
- SwfdecAsFunction *function;
- SwfdecAsValue val;
-
- g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL);
- g_return_val_if_fail (name != NULL, NULL);
- g_return_val_if_fail (type == 0 || g_type_is_a (type, SWFDEC_TYPE_AS_OBJECT), NULL);
- g_return_val_if_fail (construct_type == 0 || g_type_is_a (construct_type, SWFDEC_TYPE_AS_OBJECT), NULL);
- g_return_val_if_fail (prototype == NULL || SWFDEC_IS_AS_OBJECT (prototype), NULL);
-
- if (!native)
- native = swfdec_as_object_do_nothing;
- function = swfdec_as_native_function_new (object->context, name, native, min_args, prototype);
- if (function == NULL)
- return NULL;
- if (type != 0)
- swfdec_as_native_function_set_object_type (SWFDEC_AS_NATIVE_FUNCTION (function), type);
- if (construct_type != 0)
- swfdec_as_native_function_set_construct_type (SWFDEC_AS_NATIVE_FUNCTION (function), construct_type);
- name = swfdec_as_context_get_string (object->context, name);
- SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (function));
- /* FIXME: I'd like to make sure no such property exists yet */
- swfdec_as_object_set_variable_and_flags (object, name, &val,
- SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
- return function;
-}
-
-/**
- * swfdec_as_object_run:
- * @object: a #SwfdecAsObject
- * @script: script to execute
- *
- * Executes the given @script with @object as this pointer.
- **/
-void
-swfdec_as_object_run (SwfdecAsObject *object, SwfdecScript *script)
-{
- SwfdecAsContext *context;
- SwfdecAsFrame *frame;
-
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
- g_return_if_fail (script != NULL);
-
- context = object->context;
- frame = swfdec_as_frame_new (context, script);
- if (frame == NULL)
- return;
- swfdec_as_frame_set_this (frame, object);
- swfdec_as_frame_preload (frame);
- swfdec_as_context_run (context);
- swfdec_as_stack_pop (context);
-}
-
-/**
- * swfdec_as_object_call:
- * @object: a #SwfdecAsObject
- * @name: garbage-collected string naming the function to call.
- * @argc: number of arguments to provide to function
- * @argv: arguments or %NULL when @argc is 0
- * @return_value: location to take the return value of the call or %NULL to
- * ignore the return value.
- *
- * Calls the function named @name on the given object. This function is
- * essentially equal to the folloeing Actionscript code:
- * <informalexample><programlisting>
- * @return_value = @object. at name (@argv[0], ..., @argv[argc-1]);
- * </programlisting></informalexample>
- **/
-void
-swfdec_as_object_call (SwfdecAsObject *object, const char *name, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *return_value)
-{
- SwfdecAsValue tmp;
- SwfdecAsFunction *fun;
-
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
- g_return_if_fail (name != NULL);
- g_return_if_fail (argc == 0 || argv != NULL);
- g_return_if_fail (object->context->global != NULL); /* for SwfdecPlayer */
-
- if (return_value)
- SWFDEC_AS_VALUE_SET_UNDEFINED (return_value);
- swfdec_as_object_get_variable (object, name, &tmp);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&tmp))
- return;
- fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&tmp);
- if (!SWFDEC_IS_AS_FUNCTION (fun))
- return;
- swfdec_as_function_call (fun, object, argc, argv, return_value ? return_value : &tmp);
- if (swfdec_as_context_is_aborted (object->context))
- return;
- swfdec_as_context_run (object->context);
-}
-
-/**
- * swfdec_as_object_create:
- * @fun: constructor
- * @n_args: number of arguments
- * @args: arguments to pass to constructor
- * @return_value: pointer for return value or %NULL to push the return value to
- * the stack
- *
- * Creates a new object for the given constructor and pushes the constructor on
- * top of the stack. To actually run the constructor, you need to call
- * swfdec_as_context_run().
- **/
-void
-swfdec_as_object_create (SwfdecAsFunction *fun, guint n_args,
- const SwfdecAsValue *args, SwfdecAsValue *return_value)
-{
- SwfdecAsValue val;
- SwfdecAsObject *new;
- SwfdecAsContext *context;
- SwfdecAsFunction *cur;
- SwfdecAsFrame *frame;
- guint size = 0;
- GType type = 0;
-
- g_return_if_fail (SWFDEC_IS_AS_FUNCTION (fun));
-
- context = SWFDEC_AS_OBJECT (fun)->context;
- cur = fun;
- do {
- if (SWFDEC_IS_AS_NATIVE_FUNCTION (cur)) {
- SwfdecAsNativeFunction *native = SWFDEC_AS_NATIVE_FUNCTION (cur);
- if (native->construct_size) {
- type = native->construct_type;
- size = native->construct_size;
- break;
- }
- }
- swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (cur), SWFDEC_AS_STR_prototype, &val);
- if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
- SwfdecAsObject *proto = SWFDEC_AS_VALUE_GET_OBJECT (&val);
- swfdec_as_object_get_variable (proto, SWFDEC_AS_STR___constructor__, &val);
- if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
- cur = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&val);
- if (SWFDEC_IS_AS_FUNCTION (cur)) {
- continue;
- }
- }
- }
- cur = NULL;
- } while (type == 0 && cur != NULL);
- if (type == 0) {
- type = SWFDEC_TYPE_AS_OBJECT;
- size = sizeof (SwfdecAsObject);
- }
- if (!swfdec_as_context_use_mem (context, size))
- return;
-
- new = g_object_new (type, NULL);
- swfdec_as_object_add (new, context, size);
- /* set initial variables */
- if (swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (fun), SWFDEC_AS_STR_prototype, &val)) {
- swfdec_as_object_set_variable_and_flags (new, SWFDEC_AS_STR___proto__,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
- }
- SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (fun));
- if (context->version < 7) {
- swfdec_as_object_set_variable_and_flags (new, SWFDEC_AS_STR_constructor,
- &val, SWFDEC_AS_VARIABLE_HIDDEN);
- }
- swfdec_as_object_set_variable_and_flags (new, SWFDEC_AS_STR___constructor__,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_VERSION_6_UP);
-
- frame = swfdec_as_function_call_no_preload (fun, new, n_args, args, return_value);
- frame->construct = TRUE;
- swfdec_as_super_new (frame, new, new->prototype);
- swfdec_as_frame_preload (frame);
-}
-
-/**
- * swfdec_as_object_set_constructor:
- * @object: a #SwfdecAsObject
- * @construct: the constructor of @object
- *
- * Sets the constructor variables for @object. Most objects get these
- * variables set automatically, but for objects you created yourself, you want
- * to call this function. This is essentially the same as the following script
- * code:
- * |[ object.constructor = construct;
- * object.__proto__ = construct.prototype; ]|
- **/
-void
-swfdec_as_object_set_constructor (SwfdecAsObject *object, SwfdecAsObject *construct)
-{
- SwfdecAsValue val;
-
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (construct));
-
- SWFDEC_AS_VALUE_SET_OBJECT (&val, construct);
- swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR_constructor,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
- swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (construct),
- SWFDEC_AS_STR_prototype, &val);
- if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
- SwfdecAsObject *proto = SWFDEC_AS_VALUE_GET_OBJECT (&val);
- SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
- swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR___proto__,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
- } else {
- SWFDEC_WARNING ("constructor has no prototype, not setting any");
- }
-}
-
-/**
- * swfdec_as_object_add_variable:
- * @object: a #SwfdecAsObject
- * @variable: name of the variable
- * @get: getter function to call when reading the variable
- * @set: setter function to call when writing the variable or %NULL if read-only
- * @default_flags: flags to use if creating the variable anew - the flags will
- * be ignored if the property already exists.
- *
- * Adds a variable to @object in the same way as the Actionscript code
- * "object.addProperty()" would do. Accessing the variable will from now on be
- * handled by calling the @get or @set functions. A previous value of the
- * variable or a previous call to this function will be overwritten.
- **/
-void
-swfdec_as_object_add_variable (SwfdecAsObject *object, const char *variable,
- SwfdecAsFunction *get, SwfdecAsFunction *set, guint default_flags)
-{
- SwfdecAsVariable *var;
-
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
- g_return_if_fail (variable != NULL);
- g_return_if_fail (SWFDEC_IS_AS_FUNCTION (get));
- g_return_if_fail (set == NULL || SWFDEC_IS_AS_FUNCTION (set));
-
- var = swfdec_as_object_hash_lookup (object, variable);
- if (var == NULL)
- var = swfdec_as_object_hash_create (object, variable, default_flags);
- if (var == NULL)
- return;
- var->get = get;
- var->set = set;
-}
-
-void
-swfdec_as_object_add_native_variable (SwfdecAsObject *object,
- const char *variable, SwfdecAsNative get, SwfdecAsNative set)
-{
- SwfdecAsFunction *get_func, *set_func;
-
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
- g_return_if_fail (variable != NULL);
- g_return_if_fail (get != NULL);
-
- get_func =
- swfdec_as_native_function_new (object->context, variable, get, 0, NULL);
- if (get_func == NULL)
- return;
-
- if (set != NULL) {
- set_func =
- swfdec_as_native_function_new (object->context, variable, set, 0, NULL);
- } else {
- set_func = NULL;
- }
-
- swfdec_as_object_add_variable (object, variable, get_func, set_func, 0);
-}
-
-/*** AS CODE ***/
-
-SWFDEC_AS_NATIVE (101, 2, swfdec_as_object_addProperty)
-void
-swfdec_as_object_addProperty (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- SwfdecAsFunction *get, *set;
- const char *name;
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
- if (argc < 3)
- return;
- name = swfdec_as_value_to_string (cx, &argv[0]);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[1]) ||
- !SWFDEC_IS_AS_FUNCTION ((get = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&argv[1]))))
- return;
- if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[2])) {
- set = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&argv[2]);
- if (!SWFDEC_IS_AS_FUNCTION (set))
- return;
- } else if (SWFDEC_AS_VALUE_IS_NULL (&argv[2])) {
- set = NULL;
- } else {
- return;
- }
-
- swfdec_as_object_add_variable (object, name, get, set, 0);
- SWFDEC_AS_VALUE_SET_BOOLEAN (retval, TRUE);
-}
-
-SWFDEC_AS_NATIVE (101, 5, swfdec_as_object_hasOwnProperty)
-void
-swfdec_as_object_hasOwnProperty (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- SwfdecAsVariable *var;
- const char *name;
-
- if (object == NULL)
- return;
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
-
- // return false even if no params
- if (argc < 1)
- return;
-
- name = swfdec_as_value_to_string (object->context, &argv[0]);
-
- if (!(var = swfdec_as_object_hash_lookup (object, name)))
- return;
-
- /* This functions only checks NOT 6 flag, and checks it on ALL VERSIONS */
- if (var->flags & SWFDEC_AS_VARIABLE_VERSION_NOT_6)
- return;
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (retval, TRUE);
-}
-
-SWFDEC_AS_NATIVE (101, 7, swfdec_as_object_isPropertyEnumerable)
-void
-swfdec_as_object_isPropertyEnumerable (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *retval)
-{
- SwfdecAsVariable *var;
- const char *name;
-
- if (object == NULL)
- return;
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
-
- // return false even if no params
- if (argc < 1)
- return;
-
- name = swfdec_as_value_to_string (object->context, &argv[0]);
-
- if (!(var = swfdec_as_object_hash_lookup (object, name)))
- return;
-
- if (var->flags & SWFDEC_AS_VARIABLE_HIDDEN)
- return;
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (retval, TRUE);
-}
-
-SWFDEC_AS_NATIVE (101, 6, swfdec_as_object_isPrototypeOf)
-void
-swfdec_as_object_isPrototypeOf (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *retval)
-{
- SwfdecAsObject *class;
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
-
- // return false even if no params
- if (argc < 1)
- return;
-
- class = swfdec_as_value_to_object (cx, &argv[0]);
- if (class == NULL)
- return;
-
- while ((class = swfdec_as_object_get_prototype (class)) != NULL) {
- if (object == class) {
- SWFDEC_AS_VALUE_SET_BOOLEAN (retval, TRUE);
- return;
- }
- }
-
- // not found, nothing to do
-}
-
-SWFDEC_AS_NATIVE (101, 0, swfdec_as_object_watch)
-void
-swfdec_as_object_watch (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- SwfdecAsWatch *watch;
- const char *name;
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
-
- if (argc < 2)
- return;
-
- name = swfdec_as_value_to_string (cx, &argv[0]);
-
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[1]))
- return;
-
- if (!SWFDEC_IS_AS_FUNCTION (SWFDEC_AS_VALUE_GET_OBJECT (&argv[1])))
- return;
-
- if (object->watches == NULL) {
- object->watches = g_hash_table_new_full (g_direct_hash, g_direct_equal,
- NULL, (GDestroyNotify) swfdec_as_watch_unref);
- watch = NULL;
- } else {
- watch = g_hash_table_lookup (object->watches, name);
- }
- if (watch == NULL) {
- watch = swfdec_as_watch_new (SWFDEC_AS_FUNCTION (SWFDEC_AS_VALUE_GET_OBJECT (&argv[1])));
- if (watch == NULL)
- return;
- g_hash_table_insert (object->watches, (char *) name, watch);
- } else {
- watch->watch = SWFDEC_AS_FUNCTION (SWFDEC_AS_VALUE_GET_OBJECT (&argv[1]));
- }
-
- if (argc >= 3) {
- watch->watch_data = argv[2];
- } else {
- SWFDEC_AS_VALUE_SET_UNDEFINED (&watch->watch_data);
- }
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (retval, TRUE);
-}
-
-SWFDEC_AS_NATIVE (101, 1, swfdec_as_object_unwatch)
-void
-swfdec_as_object_unwatch (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- SwfdecAsVariable *var;
- const char *name;
-
- if (object == NULL)
- return;
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
-
- if (argc < 1)
- return;
-
- name = swfdec_as_value_to_string (cx, &argv[0]);
-
- // special case: can't unwatch native properties
- if ((var = swfdec_as_object_hash_lookup (object, name))&& var->get != NULL)
- return;
-
- if (object->watches != NULL &&
- g_hash_table_remove (object->watches, name)) {
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (retval, TRUE);
-
- if (g_hash_table_size (object->watches) == 0) {
- g_hash_table_destroy (object->watches);
- object->watches = NULL;
- }
- }
-}
-
-SWFDEC_AS_NATIVE (101, 3, swfdec_as_object_valueOf)
-void
-swfdec_as_object_valueOf (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- if (object != NULL)
- SWFDEC_AS_VALUE_SET_OBJECT (retval, object);
-}
-
-SWFDEC_AS_NATIVE (101, 4, swfdec_as_object_toString)
-void
-swfdec_as_object_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- if (SWFDEC_IS_AS_FUNCTION (object)) {
- SWFDEC_AS_VALUE_SET_STRING (retval, SWFDEC_AS_STR__type_Function_);
- } else {
- SWFDEC_AS_VALUE_SET_STRING (retval, SWFDEC_AS_STR__object_Object_);
- }
-}
-
-// only available as ASnative
-SWFDEC_AS_NATIVE (3, 3, swfdec_as_object_old_constructor)
-void
-swfdec_as_object_old_constructor (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("old 'Object' function (only available as ASnative)");
-}
-
-void
-swfdec_as_object_decode (SwfdecAsObject *object, const char *str)
-{
- SwfdecAsContext *cx = object->context;
- SwfdecAsValue val;
- char **varlist, *p, *unescaped;
- guint i;
-
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
- g_return_if_fail (str != NULL);
-
- varlist = g_strsplit (str, "&", -1);
-
- for (i = 0; varlist[i] != NULL; i++) {
- p = strchr (varlist[i], '=');
- if (p != NULL) {
- *p++ = '\0';
- if (*p == '\0')
- p = NULL;
- }
-
- if (p != NULL) {
- unescaped = swfdec_as_string_unescape (cx, p);
- if (unescaped != NULL) {
- SWFDEC_AS_VALUE_SET_STRING (&val,
- swfdec_as_context_give_string (cx, unescaped));
- } else {
- SWFDEC_AS_VALUE_SET_STRING (&val, SWFDEC_AS_STR_EMPTY);
- }
- } else {
- SWFDEC_AS_VALUE_SET_STRING (&val, SWFDEC_AS_STR_EMPTY);
- }
- unescaped = swfdec_as_string_unescape (cx, varlist[i]);
- if (unescaped != NULL) {
- swfdec_as_object_set_variable (object,
- swfdec_as_context_give_string (cx, unescaped), &val);
- }
- }
- g_strfreev (varlist);
-}
-
-void
-swfdec_as_object_init_context (SwfdecAsContext *context)
-{
- SwfdecAsValue val;
- SwfdecAsObject *object, *proto;
-
- proto = swfdec_as_object_new_empty (context);
- if (!proto)
- return;
- object = SWFDEC_AS_OBJECT (swfdec_as_object_add_function (context->global,
- SWFDEC_AS_STR_Object, 0, NULL, 0));
- if (!object)
- return;
- context->Object = object;
- context->Object_prototype = proto;
- SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
- /* first, set our own */
- swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR_prototype,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT |
- SWFDEC_AS_VARIABLE_CONSTANT);
-
- /* then finish the function prototype (use this order or
- * SWFDEC_AS_VARIABLE_CONSTANT won't let us */
- swfdec_as_object_set_variable_and_flags (context->Function_prototype,
- SWFDEC_AS_STR___proto__, &val,
- SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
-
- SWFDEC_AS_VALUE_SET_OBJECT (&val, object);
- swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
-}
-
-/**
- * swfdec_as_object_get_debug:
- * @object: a #SwfdecAsObject
- *
- * Gets a representation string suitable for debugging. This function is
- * guaranteed to not modify the state of the script engine, unlike
- * swfdec_as_value_to_string() for example.
- *
- * Returns: A newly allocated string. Free it with g_free() after use.
- **/
-char *
-swfdec_as_object_get_debug (SwfdecAsObject *object)
-{
- SwfdecAsObjectClass *klass;
-
- g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL);
-
- klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
- return klass->debug (object);
-}
-
-/**
- * swfdec_as_object_resolve:
- * @object: a #SwfdecAsObject
- *
- * Resolves the object to its real object. Some internal objects should not be
- * exposed to scripts, for example #SwfdecAsFrame objects. If an object you want
- * to expose might be internal, call this function to resolve it to an object
- * that is safe to expose.
- *
- * Returns: a non-internal object
- **/
-SwfdecAsObject *
-swfdec_as_object_resolve (SwfdecAsObject *object)
-{
- SwfdecAsObjectClass *klass;
-
- g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL);
-
- klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
- if (klass->resolve == NULL)
- return object;
-
- return klass->resolve (object);
-}
diff --git a/libswfdec/swfdec_as_object.h b/libswfdec/swfdec_as_object.h
deleted file mode 100644
index 2fe888f..0000000
--- a/libswfdec/swfdec_as_object.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AS_OBJECT_H_
-#define _SWFDEC_AS_OBJECT_H_
-
-#include <glib-object.h>
-#include <libswfdec/swfdec_as_types.h>
-
-G_BEGIN_DECLS
-
-/* NB: matches ASSetPropFlags */
-typedef enum {
- SWFDEC_AS_VARIABLE_HIDDEN = (1 << 0),
- SWFDEC_AS_VARIABLE_PERMANENT = (1 << 1),
- SWFDEC_AS_VARIABLE_CONSTANT = (1 << 2),
-
- SWFDEC_AS_VARIABLE_VERSION_6_UP = (1 << 7),
- SWFDEC_AS_VARIABLE_VERSION_NOT_6 = (1 << 8),
- SWFDEC_AS_VARIABLE_VERSION_7_UP = (1 << 10),
- SWFDEC_AS_VARIABLE_VERSION_8_UP = (1 << 12),
- SWFDEC_AS_VARIABLE_VERSION_9_UP = (1 << 13),
-} SwfdecAsVariableFlag;
-
-typedef enum {
- SWFDEC_AS_DELETE_NOT_FOUND = 0,
- SWFDEC_AS_DELETE_DELETED,
- SWFDEC_AS_DELETE_NOT_DELETED
-} SwfdecAsDeleteReturn;
-
-typedef struct _SwfdecAsObjectClass SwfdecAsObjectClass;
-typedef gboolean (* SwfdecAsVariableForeach) (SwfdecAsObject *object,
- const char *variable, SwfdecAsValue *value, guint flags, gpointer data);
-
-#define SWFDEC_TYPE_AS_OBJECT (swfdec_as_object_get_type())
-#define SWFDEC_IS_AS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_OBJECT))
-#define SWFDEC_IS_AS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_OBJECT))
-#define SWFDEC_AS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_OBJECT, SwfdecAsObject))
-#define SWFDEC_AS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_OBJECT, SwfdecAsObjectClass))
-#define SWFDEC_AS_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_OBJECT, SwfdecAsObjectClass))
-
-struct _SwfdecAsObject {
- /*< protected >*/
- GObject object;
- SwfdecAsContext * context; /* context the object belongs to */
- /*< private >*/
- SwfdecAsObject * prototype; /* prototype object (referred to as __proto__) */
- guint prototype_flags; /* propflags for the prototype object */
- GHashTable * properties; /* string->SwfdecAsVariable mapping or NULL when not in GC */
- GHashTable * watches; /* string->WatchData mapping or NULL when not watching anything */
- guint8 flags; /* GC flags */
- gsize size; /* size reserved in GC */
- GSList * interfaces; /* list of interfaces this object implements */
-};
-
-struct _SwfdecAsObjectClass {
- GObjectClass object_class;
-
- /* mark everything that should survive during GC */
- void (* mark) (SwfdecAsObject * object);
- /* object was added to the context */
- void (* add) (SwfdecAsObject * object);
- /* get the value and flags for a variables */
- gboolean (* get) (SwfdecAsObject * object,
- SwfdecAsObject * orig,
- const char * variable,
- SwfdecAsValue * val,
- guint * flags);
- /* set the variable - and return it (or NULL on error) */
- void (* set) (SwfdecAsObject * object,
- const char * variable,
- const SwfdecAsValue * val,
- guint default_flags);
- /* set flags of a variable */
- void (* set_flags) (SwfdecAsObject * object,
- const char * variable,
- guint flags,
- guint mask);
- /* delete the variable - return TRUE if it exists */
- SwfdecAsDeleteReturn (* del) (SwfdecAsObject * object,
- const char * variable);
- /* call with every variable until func returns FALSE */
- gboolean (* foreach) (SwfdecAsObject * object,
- SwfdecAsVariableForeach func,
- gpointer data);
- /* get the real object referenced by this object (useful for internal objects) */
- SwfdecAsObject * (* resolve) (SwfdecAsObject * object);
- /* get a debug string representation for this object */
- char * (* debug) (SwfdecAsObject * object);
-};
-
-GType swfdec_as_object_get_type (void);
-
-SwfdecAsObject *swfdec_as_object_new (SwfdecAsContext * context);
-SwfdecAsObject *swfdec_as_object_new_empty (SwfdecAsContext * context);
-void swfdec_as_object_create (SwfdecAsFunction * fun,
- guint n_args,
- const SwfdecAsValue * args,
- SwfdecAsValue * return_value);
-void swfdec_as_object_set_constructor(SwfdecAsObject * object,
- SwfdecAsObject * construct);
-SwfdecAsObject *swfdec_as_object_resolve (SwfdecAsObject * object);
-char * swfdec_as_object_get_debug (SwfdecAsObject * object);
-
-void swfdec_as_object_add (SwfdecAsObject * object,
- SwfdecAsContext * context,
- gsize size);
-
-/* I'd like to name these [gs]et_property, but binding authors will complain
- * about overlap with g_object_[gs]et_property then */
-#define swfdec_as_object_set_variable(object, variable, value) \
- swfdec_as_object_set_variable_and_flags (object, variable, value, 0)
-void swfdec_as_object_set_variable_and_flags
- (SwfdecAsObject * object,
- const char * variable,
- const SwfdecAsValue * value,
- guint default_flags);
-void swfdec_as_object_add_variable (SwfdecAsObject * object,
- const char * variable,
- SwfdecAsFunction * get,
- SwfdecAsFunction * set,
- SwfdecAsVariableFlag default_flags);
-#define swfdec_as_object_get_variable(object, variable, value) \
- swfdec_as_object_get_variable_and_flags (object, variable, value, NULL, NULL)
-gboolean swfdec_as_object_get_variable_and_flags
- (SwfdecAsObject * object,
- const char * variable,
- SwfdecAsValue * value,
- guint * flags,
- SwfdecAsObject ** pobject);
-gboolean swfdec_as_object_has_variable (SwfdecAsObject * object,
- const char * variable);
-SwfdecAsDeleteReturn
- swfdec_as_object_delete_variable(SwfdecAsObject * object,
- const char * variable);
-void swfdec_as_object_delete_all_variables
- (SwfdecAsObject * object);
-void swfdec_as_object_set_variable_flags
- (SwfdecAsObject * object,
- const char * variable,
- SwfdecAsVariableFlag flags);
-void swfdec_as_object_unset_variable_flags
- (SwfdecAsObject * object,
- const char * variable,
- SwfdecAsVariableFlag flags);
-gboolean swfdec_as_object_foreach (SwfdecAsObject * object,
- SwfdecAsVariableForeach func,
- gpointer data);
-
-SwfdecAsFunction *swfdec_as_object_add_function (SwfdecAsObject * object,
- const char * name,
- GType type,
- SwfdecAsNative native,
- guint min_args);
-SwfdecAsFunction *swfdec_as_object_add_constructor
- (SwfdecAsObject * object,
- const char * name,
- GType type,
- GType construct_type,
- SwfdecAsNative native,
- guint min_args,
- SwfdecAsObject * prototype);
-
-void swfdec_as_object_call (SwfdecAsObject * object,
- const char * name,
- guint argc,
- SwfdecAsValue * argv,
- SwfdecAsValue * return_value);
-void swfdec_as_object_run (SwfdecAsObject * object,
- SwfdecScript * script);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_as_script_function.c b/libswfdec/swfdec_as_script_function.c
deleted file mode 100644
index c696305..0000000
--- a/libswfdec/swfdec_as_script_function.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_script_function.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_frame_internal.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_stack.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-
-G_DEFINE_TYPE (SwfdecAsScriptFunction, swfdec_as_script_function, SWFDEC_TYPE_AS_FUNCTION)
-
-static SwfdecAsFrame *
-swfdec_as_script_function_call (SwfdecAsFunction *function)
-{
- SwfdecAsScriptFunction *script = SWFDEC_AS_SCRIPT_FUNCTION (function);
- SwfdecAsFrame *frame;
-
- frame = swfdec_as_frame_new (SWFDEC_AS_OBJECT (function)->context, script->script);
- if (frame == NULL)
- return NULL;
- frame->scope_chain = g_slist_concat (frame->scope_chain, g_slist_copy (script->scope_chain));
- frame->function = function;
- frame->target = script->target;
- frame->original_target = script->target;
- return frame;
-}
-
-static void
-swfdec_as_script_function_dispose (GObject *object)
-{
- SwfdecAsScriptFunction *script = SWFDEC_AS_SCRIPT_FUNCTION (object);
-
- if (script->script) {
- swfdec_script_unref (script->script);
- script->script = NULL;
- }
- g_slist_free (script->scope_chain);
- script->scope_chain = NULL;
-
- G_OBJECT_CLASS (swfdec_as_script_function_parent_class)->dispose (object);
-}
-
-static void
-swfdec_as_script_function_mark (SwfdecAsObject *object)
-{
- SwfdecAsScriptFunction *script = SWFDEC_AS_SCRIPT_FUNCTION (object);
-
- g_slist_foreach (script->scope_chain, (GFunc) swfdec_as_object_mark, NULL);
-
- SWFDEC_AS_OBJECT_CLASS (swfdec_as_script_function_parent_class)->mark (object);
-}
-
-static char *
-swfdec_as_script_function_debug (SwfdecAsObject *object)
-{
- SwfdecAsScriptFunction *script = SWFDEC_AS_SCRIPT_FUNCTION (object);
- SwfdecScript *s = script->script;
- GString *string;
- guint i;
-
- string = g_string_new (s->name);
- g_string_append (string, " (");
- for (i = 0; i < s->n_arguments; i++) {
- if (i > 0)
- g_string_append (string, ", ");
- g_string_append (string, s->arguments[i].name);
- }
- g_string_append (string, ")");
-
- return g_string_free (string, FALSE);
-}
-
-static void
-swfdec_as_script_function_class_init (SwfdecAsScriptFunctionClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
- SwfdecAsFunctionClass *function_class = SWFDEC_AS_FUNCTION_CLASS (klass);
-
- object_class->dispose = swfdec_as_script_function_dispose;
-
- asobject_class->mark = swfdec_as_script_function_mark;
- asobject_class->debug = swfdec_as_script_function_debug;
-
- function_class->call = swfdec_as_script_function_call;
-}
-
-static void
-swfdec_as_script_function_init (SwfdecAsScriptFunction *script_function)
-{
-}
-
-SwfdecAsFunction *
-swfdec_as_script_function_new (SwfdecAsObject *target, const GSList *scope_chain, SwfdecScript *script)
-{
- SwfdecAsValue val;
- SwfdecAsScriptFunction *fun;
- SwfdecAsObject *proto;
- SwfdecAsContext *context;
-
- g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (target), NULL);
- g_return_val_if_fail (script != NULL, NULL);
-
- context = target->context;
- if (!swfdec_as_context_use_mem (context, sizeof (SwfdecAsScriptFunction)))
- return NULL;
- fun = g_object_new (SWFDEC_TYPE_AS_SCRIPT_FUNCTION, NULL);
- if (fun == NULL)
- return NULL;
- fun->scope_chain = g_slist_copy ((GSList *) scope_chain);
- fun->script = script;
- fun->target = target;
- swfdec_as_object_add (SWFDEC_AS_OBJECT (fun), context, sizeof (SwfdecAsScriptFunction));
- /* set prototype */
- proto = swfdec_as_object_new_empty (context);
- if (proto == NULL)
- return NULL;
- SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
- swfdec_as_object_set_variable_and_flags (SWFDEC_AS_OBJECT (fun),
- SWFDEC_AS_STR_prototype, &val,
- SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
- swfdec_as_function_set_constructor (SWFDEC_AS_FUNCTION (fun));
- SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (fun));
- swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
- SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object_prototype);
- swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR___proto__,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
-
- return SWFDEC_AS_FUNCTION (fun);
-}
-
diff --git a/libswfdec/swfdec_as_script_function.h b/libswfdec/swfdec_as_script_function.h
deleted file mode 100644
index 1972e15..0000000
--- a/libswfdec/swfdec_as_script_function.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AS_SCRIPT_FUNCTION_H_
-#define _SWFDEC_AS_SCRIPT_FUNCTION_H_
-
-#include <libswfdec/swfdec_as_function.h>
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_script.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecAsScriptFunction SwfdecAsScriptFunction;
-typedef struct _SwfdecAsScriptFunctionClass SwfdecAsScriptFunctionClass;
-
-#define SWFDEC_TYPE_AS_SCRIPT_FUNCTION (swfdec_as_script_function_get_type())
-#define SWFDEC_IS_AS_SCRIPT_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_SCRIPT_FUNCTION))
-#define SWFDEC_IS_AS_SCRIPT_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_SCRIPT_FUNCTION))
-#define SWFDEC_AS_SCRIPT_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_SCRIPT_FUNCTION, SwfdecAsScriptFunction))
-#define SWFDEC_AS_SCRIPT_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_SCRIPT_FUNCTION, SwfdecAsScriptFunctionClass))
-#define SWFDEC_AS_SCRIPT_FUNCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_SCRIPT_FUNCTION, SwfdecAsScriptFunctionClass))
-
-/* FIXME: do two obejcts, one for scripts and one for native? */
-struct _SwfdecAsScriptFunction {
- SwfdecAsFunction function;
-
- /* for script script_functions */
- SwfdecScript * script; /* script being executed or NULL when native */
- GSList * scope_chain; /* scope this script_function was defined in */
- SwfdecAsObject * target; /* target this object was defined in or NULL if in init script */
-};
-
-struct _SwfdecAsScriptFunctionClass {
- SwfdecAsFunctionClass function_class;
-};
-
-GType swfdec_as_script_function_get_type (void);
-
-SwfdecAsFunction * swfdec_as_script_function_new (SwfdecAsObject * target,
- const GSList * scope_chain,
- SwfdecScript * script);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_as_stack.c b/libswfdec/swfdec_as_stack.c
deleted file mode 100644
index f86e1e0..0000000
--- a/libswfdec/swfdec_as_stack.c
+++ /dev/null
@@ -1,200 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include "swfdec_as_stack.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_frame_internal.h"
-#include "swfdec_debug.h"
-
-/* FIXME: make this configurable? */
-#define SWFDEC_AS_STACK_SIZE 8192 /* random big number */
-
-/* minimum number of elements that need to stay free that makes us remove a stack segment */
-#define SWFDEC_AS_STACK_LEFTOVER 16
-
-static SwfdecAsStack *
-swfdec_as_stack_new (SwfdecAsContext *context, guint n_elements)
-{
- gsize size;
- SwfdecAsStack *stack;
-
- size = sizeof (SwfdecAsStack) + n_elements * sizeof (SwfdecAsValue);
- if (!swfdec_as_context_use_mem (context, size))
- return NULL;
-
- stack = g_slice_alloc (size);
- stack->n_elements = n_elements;
- stack->used_elements = 0;
- stack->next = NULL;
- return stack;
-}
-
-static void
-swfdec_as_stack_set (SwfdecAsContext *context, SwfdecAsStack *stack)
-{
- context->stack = stack;
- context->base = &stack->elements[0];
- context->cur = context->base + stack->used_elements;
- context->end = context->base + SWFDEC_AS_STACK_SIZE;
-}
-
-gboolean
-swfdec_as_stack_push_segment (SwfdecAsContext *context)
-{
- SwfdecAsStack *stack;
-
- /* finish current stack */
- if (context->stack) {
- context->stack->used_elements = context->cur - context->base;
- g_assert (context->stack->used_elements <= context->stack->n_elements);
- }
-
- stack = swfdec_as_stack_new (context, SWFDEC_AS_STACK_SIZE);
- if (stack == NULL)
- return FALSE;
- SWFDEC_DEBUG ("pushing new stack segment %p", stack);
- stack->next = context->stack;
- swfdec_as_stack_set (context, stack);
- return TRUE;
-}
-
-static void
-swfdec_as_stack_free (SwfdecAsContext *context, SwfdecAsStack *stack)
-{
- gsize size;
-
- size = sizeof (SwfdecAsStack) + stack->n_elements * sizeof (SwfdecAsValue);
- swfdec_as_context_unuse_mem (context, size);
- g_slice_free1 (size, stack);
-}
-
-void
-swfdec_as_stack_pop_segment (SwfdecAsContext *context)
-{
- SwfdecAsStack *stack = context->stack;
- if (stack->next) {
- swfdec_as_stack_set (context, stack->next);
- } else {
- context->base = context->cur = context->end = NULL;
- context->stack = NULL;
- }
- SWFDEC_DEBUG ("popping stack segment %p, next is %p", stack, context->stack);
- swfdec_as_stack_free (context, stack);
-}
-
-void
-swfdec_as_stack_mark (SwfdecAsStack *stack)
-{
- guint i;
-
- for (i = 0; i < stack->used_elements; i++) {
- swfdec_as_value_mark (&stack->elements[i]);
- }
- if (stack->next)
- swfdec_as_stack_mark (stack->next);
-}
-
-void
-swfdec_as_stack_ensure_size (SwfdecAsContext *context, guint n_elements)
-{
- guint current;
- SwfdecAsStack *next;
-
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
- g_return_if_fail (n_elements < SWFDEC_AS_STACK_SIZE / 2);
-
- current = (guint) (context->cur - context->base);
- if (G_LIKELY (current >= n_elements))
- return;
- next = context->stack->next;
- /* check if we can move this to the last stack */
- if (next && context->base != context->frame->stack_begin &&
- (next->n_elements - next->used_elements > SWFDEC_AS_STACK_LEFTOVER + current)) {
- memmove (&next->elements[next->used_elements], context->base, current * sizeof (SwfdecAsValue));
- next->used_elements += current;
- swfdec_as_stack_pop_segment (context);
- return;
- }
- if (current) {
- n_elements -= current;
- memmove (context->base + n_elements, context->base, current * sizeof (SwfdecAsValue));
- }
- context->cur += n_elements;
- if (n_elements) {
- if (next && context->base != context->frame->stack_begin) {
- /* this should be true by a huge amount */
- g_assert (next->used_elements >= n_elements);
- if (context->frame->stack_begin <= &next->elements[next->used_elements] &&
- context->frame->stack_begin >= &next->elements[0]) {
- current = &next->elements[next->used_elements] - context->frame->stack_begin;
- current = MIN (n_elements, current);
- } else {
- current = n_elements;
- }
- next->used_elements -= current;
- n_elements -= current;
- memmove (context->base + n_elements, &next->elements[next->used_elements], current * sizeof (SwfdecAsValue));
- }
- if (n_elements) {
- memset (context->base, 0, n_elements * sizeof (SwfdecAsValue));
- }
- }
-}
-
-void
-swfdec_as_stack_ensure_free (SwfdecAsContext *context, guint n_elements)
-{
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
- g_return_if_fail (n_elements < SWFDEC_AS_STACK_SIZE / 2);
-
- if (G_LIKELY ((guint) (context->end - context->cur) >= n_elements))
- return;
-
- if (!swfdec_as_stack_push_segment (context))
- context->cur = context->end - n_elements;
-}
-
-guint
-swfdec_as_stack_get_size (SwfdecAsContext *context)
-{
- SwfdecAsStack *stack;
- SwfdecAsValue *target;
- guint ret;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), 0);
-
- if (context->frame == NULL)
- return 0;
- target = context->frame->stack_begin;
- if (target == context->base)
- return context->cur - context->base;
- stack = context->stack->next;
- ret = context->cur - context->base;
- while (target < &stack->elements[0] && target > &stack->elements[stack->used_elements]) {
- ret += stack->n_elements;
- stack = stack->next;
- }
- ret += &stack->elements[stack->used_elements] - target;
- return ret;
-}
diff --git a/libswfdec/swfdec_as_stack.h b/libswfdec/swfdec_as_stack.h
deleted file mode 100644
index 26e66ea..0000000
--- a/libswfdec/swfdec_as_stack.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AS_STACK_H_
-#define _SWFDEC_AS_STACK_H_
-
-#include <libswfdec/swfdec_as_types.h>
-
-G_BEGIN_DECLS
-
-struct _SwfdecAsStack {
- guint n_elements; /* number of elements */
- guint used_elements; /* elements in use (only set on stored stack) */
- SwfdecAsStack * next; /* pointer to next stack */
- SwfdecAsValue elements[0]; /* the elements */
-};
-
-gboolean swfdec_as_stack_push_segment (SwfdecAsContext * context);
-void swfdec_as_stack_pop_segment (SwfdecAsContext * context);
-
-//#define SWFDEC_MAD_CHECKS
-#ifdef SWFDEC_MAD_CHECKS
-#include <libswfdec/swfdec_as_context.h>
-static inline SwfdecAsValue *
-swfdec_as_stack_peek (SwfdecAsContext *cx, guint n)
-{
- g_assert (cx != NULL);
- g_assert (n > 0);
- g_assert (cx->cur - n >= cx->base);
-
- return &(cx)->cur[-(gssize)(n)];
-}
-
-static inline SwfdecAsValue *
-swfdec_as_stack_pop (SwfdecAsContext *cx)
-{
- g_assert (cx != NULL);
- g_assert (cx->cur > cx->base);
-
- return --cx->cur;
-}
-
-static inline SwfdecAsValue *
-swfdec_as_stack_pop_n (SwfdecAsContext *cx, guint n)
-{
- g_assert (cx != NULL);
- g_assert ((guint) (cx->cur - cx->base) >= n);
-
- return cx->cur -= n;
-}
-
-static inline SwfdecAsValue *
-swfdec_as_stack_push (SwfdecAsContext *cx)
-{
- g_assert (cx != NULL);
- g_assert (cx->cur < cx->end);
-
- cx->cur->type = SWFDEC_AS_TYPE_OBJECT + 1;
- return cx->cur++;
-}
-#else /* SWFDEC_MAD_CHECKS */
-#define swfdec_as_stack_peek(cx,n) (&(cx)->cur[-(gssize)(n)])
-#define swfdec_as_stack_pop(cx) (--(cx)->cur)
-#define swfdec_as_stack_pop_n(cx, n) ((cx)->cur -= (n))
-#define swfdec_as_stack_push(cx) ((cx)->cur++)
-#endif
-#define swfdec_as_stack_swap(cx,x,y) G_STMT_START { \
- SwfdecAsContext *__cx = (cx); \
- SwfdecAsValue __tmp; \
- guint __x = (x), __y = (y); \
- __tmp = *swfdec_as_stack_peek(__cx, __x); \
- *swfdec_as_stack_peek(__cx, __x) = *swfdec_as_stack_peek(__cx, __y); \
- *swfdec_as_stack_peek(__cx, __y) = __tmp; \
-}G_STMT_END
-
-void swfdec_as_stack_mark (SwfdecAsStack * stack);
-void swfdec_as_stack_ensure_size (SwfdecAsContext * context,
- guint n_elements);
-void swfdec_as_stack_ensure_free (SwfdecAsContext * context,
- guint n_elements);
-guint swfdec_as_stack_get_size (SwfdecAsContext * context);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_as_string.c b/libswfdec/swfdec_as_string.c
deleted file mode 100644
index 69f5719..0000000
--- a/libswfdec/swfdec_as_string.c
+++ /dev/null
@@ -1,914 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-#include <string.h>
-
-#include "swfdec_as_string.h"
-#include "swfdec_as_array.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_native_function.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-
-G_DEFINE_TYPE (SwfdecAsString, swfdec_as_string, SWFDEC_TYPE_AS_OBJECT)
-
-static void
-swfdec_as_string_do_mark (SwfdecAsObject *object)
-{
- SwfdecAsString *string = SWFDEC_AS_STRING (object);
-
- swfdec_as_string_mark (string->string);
-
- SWFDEC_AS_OBJECT_CLASS (swfdec_as_string_parent_class)->mark (object);
-}
-
-static char *
-swfdec_as_string_debug (SwfdecAsObject *object)
-{
- SwfdecAsString *string = SWFDEC_AS_STRING (object);
-
- return g_strdup (string->string);
-}
-
-static void
-swfdec_as_string_class_init (SwfdecAsStringClass *klass)
-{
- SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
-
- asobject_class->mark = swfdec_as_string_do_mark;
- asobject_class->debug = swfdec_as_string_debug;
-}
-
-static void
-swfdec_as_string_init (SwfdecAsString *string)
-{
- string->string = SWFDEC_AS_STR_EMPTY;
-}
-
-/*** AS CODE ***/
-
-static const char *
-swfdec_as_string_object_to_string (SwfdecAsContext *context,
- SwfdecAsObject *object)
-{
- SwfdecAsValue val;
-
- g_return_val_if_fail (object == NULL || SWFDEC_IS_AS_OBJECT (object),
- SWFDEC_AS_STR_EMPTY);
-
- if (object == NULL) {
- SWFDEC_AS_VALUE_SET_UNDEFINED (&val);
- } else {
- SWFDEC_AS_VALUE_SET_OBJECT (&val, object);
- }
-
- return swfdec_as_value_to_string (context, &val);
-}
-
-static inline const char *
-swfdec_as_str_nth_char (const char *s, guint n)
-{
- while (*s && n--)
- s = g_utf8_next_char (s);
- return s;
-}
-
-SWFDEC_AS_NATIVE (251, 9, swfdec_as_string_lastIndexOf)
-void
-swfdec_as_string_lastIndexOf (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *string = swfdec_as_string_object_to_string (cx, object);
- gsize len;
- const char *s;
-
- if (argc < 1)
- return;
-
- s = swfdec_as_value_to_string (cx, &argv[0]);
- if (argc == 2) {
- int offset = swfdec_as_value_to_integer (cx, &argv[1]);
- if (offset < 0) {
- SWFDEC_AS_VALUE_SET_INT (ret, -1);
- return;
- }
- len = g_utf8_offset_to_pointer (string, offset + 1) - string;
- } else {
- len = G_MAXSIZE;
- }
- s = g_strrstr_len (string, len, s);
- if (s) {
- SWFDEC_AS_VALUE_SET_INT (ret, g_utf8_pointer_to_offset (string, s));
- } else {
- SWFDEC_AS_VALUE_SET_INT (ret, -1);
- }
-}
-
-SWFDEC_AS_NATIVE (251, 8, swfdec_as_string_indexOf)
-void
-swfdec_as_string_indexOf (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *string = swfdec_as_string_object_to_string (cx, object);
- int offset=0, len, i=-1;
- const char *s, *t = NULL;
-
- if (argc < 1)
- return;
-
- s = swfdec_as_value_to_string (cx, &argv[0]);
- if (argc == 2)
- offset = swfdec_as_value_to_integer (cx, &argv[1]);
- if (offset < 0)
- offset = 0;
- len = g_utf8_strlen (string, -1);
- if (offset < len) {
- t = strstr (g_utf8_offset_to_pointer (string, offset), s);
- }
- if (t != NULL) {
- i = g_utf8_pointer_to_offset (string, t);
- }
-
- SWFDEC_AS_VALUE_SET_INT (ret, i);
-}
-
-SWFDEC_AS_NATIVE (251, 5, swfdec_as_string_charAt)
-void
-swfdec_as_string_charAt (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *string = swfdec_as_string_object_to_string (cx, object);
- int i;
- const char *s, *t;
-
- if (argc < 1)
- return;
-
- i = swfdec_as_value_to_integer (cx, &argv[0]);
- if (i < 0) {
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_EMPTY);
- return;
- }
- s = swfdec_as_str_nth_char (string, i);
- if (*s == 0) {
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_EMPTY);
- return;
- }
- t = g_utf8_next_char (s);
- s = swfdec_as_context_give_string (cx, g_strndup (s, t - s));
- SWFDEC_AS_VALUE_SET_STRING (ret, s);
-}
-
-SWFDEC_AS_NATIVE (251, 6, swfdec_as_string_charCodeAt)
-void
-swfdec_as_string_charCodeAt (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *string = swfdec_as_string_object_to_string (cx, object);
- int i;
- const char *s;
- gunichar c;
-
- if (argc < 1)
- return;
-
- i = swfdec_as_value_to_integer (cx, &argv[0]);
- if (i < 0) {
- SWFDEC_AS_VALUE_SET_NUMBER (ret, NAN);
- return;
- }
- s = swfdec_as_str_nth_char (string, i);
- if (*s == 0) {
- if (cx->version > 5) {
- SWFDEC_AS_VALUE_SET_NUMBER (ret, NAN);
- } else {
- SWFDEC_AS_VALUE_SET_INT (ret, 0);
- }
- return;
- }
- c = g_utf8_get_char (s);
- SWFDEC_AS_VALUE_SET_NUMBER (ret, c);
-}
-
-static void
-swfdec_as_string_fromCharCode_5 (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- guint i, c;
- guint8 append;
- GError *error = NULL;
- char *s;
- GByteArray *array = g_byte_array_new ();
-
- if (argc > 0) {
- for (i = 0; i < argc; i++) {
- c = ((guint) swfdec_as_value_to_integer (cx, &argv[i])) % 65536;
- if (c > 255) {
- append = c / 256;
- g_byte_array_append (array, &append, 1);
- }
- append = c;
- g_byte_array_append (array, &append, 1);
- }
-
- /* FIXME: are these the correct charset names? */
- s = g_convert ((char *) array->data, array->len, "UTF-8", "LATIN1", NULL, NULL, &error);
- } else{
- s = g_strdup ("");
- }
-
- if (s) {
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (cx, s));
- g_free (s);
- } else {
- SWFDEC_ERROR ("%s", error->message);
- g_error_free (error);
- }
- g_byte_array_free (array, TRUE);
-}
-
-static void
-swfdec_as_string_fromCharCode_6 (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- gunichar tmp[8];
- gunichar *chars;
- guint i;
- char *s;
- GError *error = NULL;
-
- if (argc <= 8)
- chars = tmp;
- else
- chars = g_new (gunichar, argc);
-
- for (i = 0; i < argc; i++) {
- chars[i] = ((guint) swfdec_as_value_to_integer (cx, &argv[i])) % 65536;
- }
-
- s = g_ucs4_to_utf8 (chars, argc, NULL, NULL, &error);
- if (s) {
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (cx, s));
- g_free (s);
- } else {
- SWFDEC_ERROR ("%s", error->message);
- g_error_free (error);
- }
-
- if (chars != tmp)
- g_free (chars);
-}
-
-SWFDEC_AS_NATIVE (251, 14, swfdec_as_string_fromCharCode)
-void
-swfdec_as_string_fromCharCode (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (cx->version <= 5) {
- swfdec_as_string_fromCharCode_5 (cx, object, argc, argv, ret);
- } else {
- swfdec_as_string_fromCharCode_6 (cx, object, argc, argv, ret);
- }
-}
-
-SWFDEC_AS_CONSTRUCTOR (251, 0, swfdec_as_string_construct, swfdec_as_string_get_type)
-void
-swfdec_as_string_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *s;
-
- if (argc > 0) {
- s = swfdec_as_value_to_string (cx, &argv[0]);
- } else {
- s = SWFDEC_AS_STR_EMPTY;
- }
-
- if (swfdec_as_context_is_constructing (cx)) {
- SwfdecAsString *string = SWFDEC_AS_STRING (object);
- SwfdecAsValue val;
-
- string->string = s;
- SWFDEC_AS_VALUE_SET_INT (&val, g_utf8_strlen (string->string, -1));
- swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR_length,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
- SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
- } else {
- SWFDEC_AS_VALUE_SET_STRING (ret, s);
- }
-}
-
-SWFDEC_AS_NATIVE (251, 2, swfdec_as_string_toString)
-void
-swfdec_as_string_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_AS_STRING (object))
- return;
-
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STRING (object)->string);
-}
-
-SWFDEC_AS_NATIVE (251, 1, swfdec_as_string_valueOf)
-void
-swfdec_as_string_valueOf (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_AS_STRING (object))
- return;
-
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STRING (object)->string);
-}
-
-#if 0
-charAt(index:Number) : String
-charCodeAt(index:Number) : Number
-concat(value:Object) : String
-indexOf(value:String, [startIndex:Number]) : Number
-slice(start:Number, end:Number) : String
-split(delimiter:String, [limit:Number]) : Array
-#endif
-
-static void
-swfdec_as_string_split_5 (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecAsArray *arr;
- SwfdecAsValue val;
- const char *str, *end, *delim;
- int count;
-
- if (argc < 1)
- return;
-
- str = swfdec_as_string_object_to_string (cx, object);
- arr = SWFDEC_AS_ARRAY (swfdec_as_array_new (cx));
- if (arr == NULL)
- return;
- SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (arr));
- /* hi, i'm the special case */
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0])) {
- delim = SWFDEC_AS_STR_COMMA;
- } else {
- delim = swfdec_as_value_to_string (cx, &argv[0]);
- }
- if (delim == SWFDEC_AS_STR_EMPTY) {
- SWFDEC_AS_VALUE_SET_STRING (&val, str);
- swfdec_as_array_push (arr, &val);
- return;
- }
- if (argc > 1) {
- swfdec_as_value_to_string (cx, &argv[0]);
- count = swfdec_as_value_to_integer (cx, &argv[1]);
- } else {
- count = G_MAXINT;
- }
- if (count <= 0)
- return;
- if (str == SWFDEC_AS_STR_EMPTY || delim[1] != 0) {
- SWFDEC_AS_VALUE_SET_STRING (&val, str);
- swfdec_as_array_push (arr, &val);
- return;
- }
- while (count > 0) {
- end = strchr (str, delim[0]);
- if (end == NULL) {
- SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_get_string (cx, str));
- swfdec_as_array_push (arr, &val);
- break;
- }
- SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_give_string (cx, g_strndup (str, end - str)));
- swfdec_as_array_push (arr, &val);
- if (count)
- count--;
- str = end + 1;
- }
-}
-
-static void
-swfdec_as_string_split_6 (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecAsArray *arr;
- SwfdecAsValue val;
- const char *str, *end, *delim;
- int count;
- guint len;
-
- if (argc < 1)
- return;
-
- str = swfdec_as_string_object_to_string (cx, object);
- arr = SWFDEC_AS_ARRAY (swfdec_as_array_new (cx));
- if (arr == NULL)
- return;
- SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (arr));
- /* hi, i'm the special case */
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0])) {
- SWFDEC_AS_VALUE_SET_STRING (&val, str);
- swfdec_as_array_push (arr, &val);
- return;
- }
- delim = swfdec_as_value_to_string (cx, &argv[0]);
- if (str == SWFDEC_AS_STR_EMPTY) {
- SWFDEC_AS_VALUE_SET_STRING (&val, str);
- swfdec_as_array_push (arr, &val);
- return;
- }
- if (argc > 1)
- count = swfdec_as_value_to_integer (cx, &argv[1]);
- else
- count = G_MAXINT;
- if (count <= 0)
- return;
- len = strlen (delim);
- while (count > 0) {
- if (delim == SWFDEC_AS_STR_EMPTY) {
- if (*str)
- end = str + 1;
- else
- break;
- } else {
- end = strstr (str, delim);
- if (end == NULL) {
- SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_get_string (cx, str));
- swfdec_as_array_push (arr, &val);
- break;
- }
- }
- SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_give_string (cx, g_strndup (str, end - str)));
- swfdec_as_array_push (arr, &val);
- if (count)
- count--;
- str = end + len;
- }
-}
-
-SWFDEC_AS_NATIVE (251, 12, swfdec_as_string_split)
-void
-swfdec_as_string_split (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (cx->version <= 5) {
- swfdec_as_string_split_5 (cx, object, argc, argv, ret);
- } else {
- swfdec_as_string_split_6 (cx, object, argc, argv, ret);
- }
-}
-
-SWFDEC_AS_NATIVE (251, 10, swfdec_as_string_slice)
-void
-swfdec_as_string_slice (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- int start, end, length;
- const char *str;
-
- if (argc == 0)
- return;
-
- str = swfdec_as_string_object_to_string (cx, object);
- length = strlen (str);
-
- start = swfdec_as_value_to_integer (cx, &argv[0]);
- if (start < 0)
- start += length;
- start = CLAMP (start, 0, length);
-
- if (argc > 1) {
- end = swfdec_as_value_to_integer (cx, &argv[1]);
- if (end < 0)
- end += length;
- end = CLAMP (end, start, length);
- } else {
- end = length;
- }
-
- SWFDEC_AS_VALUE_SET_STRING (ret,
- swfdec_as_context_give_string (cx, g_strndup (str + start, end - start)));
-}
-
-SWFDEC_AS_NATIVE (251, 7, swfdec_as_string_concat)
-void
-swfdec_as_string_concat (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- guint i;
- GString *string;
-
- string = g_string_new (swfdec_as_string_object_to_string (cx, object));
-
- for (i = 0; i < argc; i++) {
- string = g_string_append (string, swfdec_as_value_to_string (cx, &argv[i]));
- }
-
- SWFDEC_AS_VALUE_SET_STRING (ret,
- swfdec_as_context_give_string (cx, g_string_free (string, FALSE)));
-}
-
-const char *
-swfdec_as_str_sub (SwfdecAsContext *cx, const char *str, guint offset, guint len)
-{
- const char *end;
-
- str = g_utf8_offset_to_pointer (str, offset);
- end = g_utf8_offset_to_pointer (str, len);
- str = swfdec_as_context_give_string (cx, g_strndup (str, end - str));
- return str;
-}
-
-SWFDEC_AS_NATIVE (251, 13, swfdec_as_string_substr)
-void
-swfdec_as_string_substr (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *string = swfdec_as_string_object_to_string (cx, object);
- int from, to, len;
-
- if (argc < 1)
- return;
-
- from = swfdec_as_value_to_integer (cx, &argv[0]);
- len = g_utf8_strlen (string, -1);
-
- if (argc > 1 && !SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[1])) {
- to = swfdec_as_value_to_integer (cx, &argv[1]);
- /* FIXME: wtf? */
- if (to < 0) {
- if (-to <= from)
- to = 0;
- else
- to += len;
- if (to < 0)
- to = 0;
- if (from < 0 && to >= -from)
- to = 0;
- }
- } else {
- to = G_MAXINT;
- }
- if (from < 0)
- from += len;
- from = CLAMP (from, 0, len);
- to = CLAMP (to, 0, len - from);
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_str_sub (cx, string, from, to));
-}
-
-SWFDEC_AS_NATIVE (251, 11, swfdec_as_string_substring)
-void
-swfdec_as_string_substring (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *string = swfdec_as_string_object_to_string (cx, object);
- int from, to, len;
-
- if (argc < 1)
- return;
-
- len = g_utf8_strlen (string, -1);
- from = swfdec_as_value_to_integer (cx, &argv[0]);
- if (argc > 1 && !SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[1])) {
- to = swfdec_as_value_to_integer (cx, &argv[1]);
- } else {
- to = len;
- }
- from = MAX (from, 0);
- if (from >= len) {
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_EMPTY);
- return;
- }
- to = CLAMP (to, 0, len);
- if (to < from) {
- int tmp = to;
- to = from;
- from = tmp;
- }
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_str_sub (cx, string, from, to - from));
-}
-
-SWFDEC_AS_NATIVE (251, 4, swfdec_as_string_toLowerCase)
-void
-swfdec_as_string_toLowerCase (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *string = swfdec_as_string_object_to_string (cx, object);
- char *s;
-
- s = g_utf8_strdown (string, -1);
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, s));
-}
-
-SWFDEC_AS_NATIVE (251, 3, swfdec_as_string_toUpperCase)
-void
-swfdec_as_string_toUpperCase (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *string = swfdec_as_string_object_to_string (cx, object);
- char *s;
-
- s = g_utf8_strup (string, -1);
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, s));
-}
-
-// only available as ASnative
-SWFDEC_AS_NATIVE (102, 1, swfdec_as_string_old_toLowerCase)
-void
-swfdec_as_string_old_toLowerCase (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *string = swfdec_as_string_object_to_string (cx, object);
- char *s;
-
- s = g_ascii_strdown (string, -1);
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, s));
-}
-
-// only available as ASnative
-SWFDEC_AS_NATIVE (102, 0, swfdec_as_string_old_toUpperCase)
-void
-swfdec_as_string_old_toUpperCase (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *string = swfdec_as_string_object_to_string (cx, object);
- char *s;
-
- s = g_ascii_strup (string, -1);
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, s));
-}
-
-/* escape and unescape are implemented here so the mad string functions share the same place */
-
-static char *
-swfdec_as_string_unescape_5 (SwfdecAsContext *cx, const char *msg)
-{
- GByteArray *array;
- char cur = 0; /* currently decoded character */
- char *out, *in, *s;
- guint decoding = 0; /* set if we're decoding a %XY string */
-
-/* attention: c is a char* */
-#define APPEND(chr) G_STMT_START{ \
- g_byte_array_append (array, (guchar *) chr, 1); \
-}G_STMT_END
- in = s = g_convert (msg, -1, "LATIN1", "UTF-8", NULL, NULL, NULL);
- if (s == NULL) {
- SWFDEC_FIXME ("%s can not be converted to utf8 - is this Flash 5 or what?", msg);
- return NULL;
- }
- array = g_byte_array_new ();
- while (*s != 0) {
- if (decoding) {
- decoding++;
- if (*s >= '0' && *s <= '9') {
- cur = cur * 16 + *s - '0';
- } else if (*s >= 'A' && *s <= 'F') {
- cur = cur * 16 + *s - 'A' + 10;
- } else if (*s >= 'a' && *s <= 'f') {
- cur = cur * 16 + *s - 'a' + 10;
- } else {
- cur = 0;
- decoding = 0;
- }
- if (decoding == 3) {
- APPEND (&cur);
- cur = 0;
- decoding = 0;
- }
- } else if (*s == '%') {
- decoding = 1;
- } else if (*s == '+') {
- char tmp = ' ';
- APPEND (&tmp);
- } else {
- APPEND (s);
- }
- s++;
- }
- g_free (in);
- if (array->len == 0) {
- g_byte_array_free (array, TRUE);
- return NULL;
- }
- cur = 0;
- g_byte_array_append (array, (guchar *) &cur, 1);
- out = g_convert ((char *) array->data, -1, "UTF-8", "LATIN1", NULL, NULL, NULL);
- g_byte_array_free (array, TRUE);
- if (out) {
- return out;
- } else {
- g_warning ("can't convert %s to UTF-8", msg);
- g_free (out);
- return g_strdup ("");
- }
-#undef APPEND
-}
-
-char *
-swfdec_as_string_escape (SwfdecAsContext *cx, const char *s)
-{
- GByteArray *array;
- char *in = NULL;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (cx), NULL);
- g_return_val_if_fail (s != NULL, NULL);
-
- array = g_byte_array_new ();
- if (cx->version <= 5) {
- in = g_convert (s, -1, "LATIN1", "UTF-8", NULL, NULL, NULL);
- if (s == NULL) {
- SWFDEC_FIXME ("%s can not be converted to utf8 - is this Flash 5 or what?", s);
- return NULL;
- } else {
- s = in;
- }
- }
- while (*s) {
- if ((*s >= '0' && *s <= '9') ||
- (*s >= 'A' && *s <= 'Z') ||
- (*s >= 'a' && *s <= 'z')) {
- g_byte_array_append (array, (guchar *) s, 1);
- } else {
- guchar add[3] = { '%', 0, 0 };
- add[1] = (guchar) *s / 16;
- add[2] = (guchar) *s % 16;
- add[1] += add[1] < 10 ? '0' : ('A' - 10);
- add[2] += add[2] < 10 ? '0' : ('A' - 10);
- g_byte_array_append (array, add, 3);
- }
- s++;
- }
- g_byte_array_append (array, (guchar *) s, 1);
- g_free (in);
- return (char *) g_byte_array_free (array, FALSE);
-}
-
-SWFDEC_AS_NATIVE (100, 0, swfdec_as_string_escape_internal)
-void
-swfdec_as_string_escape_internal (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *s;
- char *result;
-
- SWFDEC_AS_CHECK (0, NULL, "s", &s);
-
- result = swfdec_as_string_escape (cx, s);
- if (result != NULL) {
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (cx, result));
- g_free (result);
- } else {
- SWFDEC_AS_VALUE_SET_UNDEFINED (ret);
- }
-}
-
-static char *
-swfdec_as_string_unescape_6 (SwfdecAsContext *cx, const char *s)
-{
- GByteArray *array;
- const char *msg;
- char cur = 0; /* currently decoded character */
- guint decoding = 0; /* set if we're decoding a %XY string */
- guint utf8left = 0; /* how many valid utf8 chars are still required */
- const guchar invalid[3] = { 0xEF, 0xBF, 0xBD };
-
-/* attention: c is a char* */
-#define APPEND(chr) G_STMT_START{ \
- guchar c = *chr; \
- if (utf8left) { \
- if ((c & 0xC0) == 0x80) { \
- g_byte_array_append (array, &c, 1); \
- utf8left--; \
- } else { \
- guint __len = array->len - 1; \
- while ((array->data[__len] & 0xC0) != 0xC0) \
- __len--; \
- g_byte_array_set_size (array, __len); \
- g_byte_array_append (array, invalid, 3); \
- utf8left = 0; \
- } \
- } else { \
- if (c < 0x80) { \
- g_byte_array_append (array, &c, 1); \
- } else if (c < 0xC0) { \
- guchar __foo = 0xC2; \
- g_byte_array_append (array, &__foo, 1); \
- g_byte_array_append (array, &c, 1); \
- } else if (c > 0xF7) { \
- break; \
- } else { \
- g_byte_array_append (array, &c, 1); \
- utf8left = (c < 0xE0) ? 1 : ((c < 0xF0) ? 2 : 3); \
- } \
- } \
-}G_STMT_END
- array = g_byte_array_new ();
- msg = s;
- while (*s != 0) {
- if (decoding) {
- decoding++;
- if (*s >= '0' && *s <= '9') {
- cur = cur * 16 + *s - '0';
- } else if (*s >= 'A' && *s <= 'F') {
- cur = cur * 16 + *s - 'A' + 10;
- } else if (*s >= 'a' && *s <= 'f') {
- cur = cur * 16 + *s - 'a' + 10;
- } else {
- cur = 0;
- decoding = 0;
- if ((guchar) *s > 0x7F) {
- APPEND (s);
- }
- }
- if (decoding == 3) {
- APPEND (&cur);
- cur = 0;
- decoding = 0;
- }
- } else if (*s == '%') {
- decoding = 1;
- } else if (*s == '+') {
- char tmp = ' ';
- APPEND (&tmp);
- } else {
- APPEND (s);
- }
- s++;
- }
- cur = 0;
- /* loop for break statement in APPEND macro */
- if (utf8left) {
- guint __len = array->len - 1;
- while ((array->data[__len] & 0xC0) != 0xC0)
- __len--;
- g_byte_array_set_size (array, __len);
- }
- g_byte_array_append (array, (guchar *) &cur, 1);
- if (g_utf8_validate ((char *) array->data, -1, NULL)) {
- return (char *) g_byte_array_free (array, FALSE);
- } else {
- g_warning ("%s unescaped is invalid UTF-8", msg);
- g_byte_array_free (array, TRUE);
- return g_strdup ("");
- }
-#undef APPEND
-}
-
-char *
-swfdec_as_string_unescape (SwfdecAsContext *context, const char *string)
-{
- if (context->version < 6) {
- return swfdec_as_string_unescape_5 (context, string);
- } else {
- return swfdec_as_string_unescape_6 (context, string);
- }
-}
-
-SWFDEC_AS_NATIVE (100, 1, swfdec_as_string_unescape_internal)
-void
-swfdec_as_string_unescape_internal (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *s;
- char *result;
-
- SWFDEC_AS_CHECK (0, NULL, "s", &s);
-
- result = swfdec_as_string_unescape (cx, s);
- if (result != NULL) {
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (cx, result));
- g_free (result);
- } else {
- SWFDEC_AS_VALUE_SET_UNDEFINED (ret);
- }
-}
-
-// only available as ASnative
-SWFDEC_AS_NATIVE (3, 0, swfdec_as_string_old_constructor)
-void
-swfdec_as_string_old_constructor (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("old 'String' function (only available as ASnative)");
-}
diff --git a/libswfdec/swfdec_as_string.h b/libswfdec/swfdec_as_string.h
deleted file mode 100644
index c0cd621..0000000
--- a/libswfdec/swfdec_as_string.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AS_STRING_H_
-#define _SWFDEC_AS_STRING_H_
-
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecAsString SwfdecAsString;
-typedef struct _SwfdecAsStringClass SwfdecAsStringClass;
-
-#define SWFDEC_TYPE_AS_STRING (swfdec_as_string_get_type())
-#define SWFDEC_IS_AS_STRING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_STRING))
-#define SWFDEC_IS_AS_STRING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_STRING))
-#define SWFDEC_AS_STRING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_STRING, SwfdecAsString))
-#define SWFDEC_AS_STRING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_STRING, SwfdecAsStringClass))
-#define SWFDEC_AS_STRING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_STRING, SwfdecAsStringClass))
-
-struct _SwfdecAsString {
- SwfdecAsObject object;
-
- const char * string; /* string represented by this string object */
-};
-
-struct _SwfdecAsStringClass {
- SwfdecAsObjectClass object_class;
-};
-
-GType swfdec_as_string_get_type (void);
-
-const char * swfdec_as_str_sub (SwfdecAsContext * cx,
- const char * str,
- guint offset,
- guint len);
-
-char * swfdec_as_string_escape (SwfdecAsContext * context,
- const char * string);
-char * swfdec_as_string_unescape (SwfdecAsContext * context,
- const char * string);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
deleted file mode 100644
index 7f880aa..0000000
--- a/libswfdec/swfdec_as_strings.c
+++ /dev/null
@@ -1,491 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#define SWFDEC_AS_CONSTANT_STRING(str) "\2" str "\0"
-const char swfdec_as_strings[] =
- SWFDEC_AS_CONSTANT_STRING ("")
- SWFDEC_AS_CONSTANT_STRING ("__proto__")
- SWFDEC_AS_CONSTANT_STRING ("this")
- SWFDEC_AS_CONSTANT_STRING ("code")
- SWFDEC_AS_CONSTANT_STRING ("level")
- SWFDEC_AS_CONSTANT_STRING ("description")
- SWFDEC_AS_CONSTANT_STRING ("status")
- SWFDEC_AS_CONSTANT_STRING ("NetConnection.Connect.Success")
- SWFDEC_AS_CONSTANT_STRING ("onLoad")
- SWFDEC_AS_CONSTANT_STRING ("onEnterFrame")
- SWFDEC_AS_CONSTANT_STRING ("onUnload")
- SWFDEC_AS_CONSTANT_STRING ("onMouseMove")
- SWFDEC_AS_CONSTANT_STRING ("onMouseDown")
- SWFDEC_AS_CONSTANT_STRING ("onMouseUp")
- SWFDEC_AS_CONSTANT_STRING ("onKeyUp")
- SWFDEC_AS_CONSTANT_STRING ("onKeyDown")
- SWFDEC_AS_CONSTANT_STRING ("onData")
- SWFDEC_AS_CONSTANT_STRING ("onPress")
- SWFDEC_AS_CONSTANT_STRING ("onRelease")
- SWFDEC_AS_CONSTANT_STRING ("onReleaseOutside")
- SWFDEC_AS_CONSTANT_STRING ("onRollOver")
- SWFDEC_AS_CONSTANT_STRING ("onRollOut")
- SWFDEC_AS_CONSTANT_STRING ("onDragOver")
- SWFDEC_AS_CONSTANT_STRING ("onDragOut")
- SWFDEC_AS_CONSTANT_STRING ("onConstruct")
- SWFDEC_AS_CONSTANT_STRING ("onStatus")
- SWFDEC_AS_CONSTANT_STRING ("error")
- SWFDEC_AS_CONSTANT_STRING ("NetStream.Buffer.Empty")
- SWFDEC_AS_CONSTANT_STRING ("NetStream.Buffer.Full")
- SWFDEC_AS_CONSTANT_STRING ("NetStream.Buffer.Flush")
- SWFDEC_AS_CONSTANT_STRING ("NetStream.Play.Start")
- SWFDEC_AS_CONSTANT_STRING ("NetStream.Play.Stop")
- SWFDEC_AS_CONSTANT_STRING ("NetStream.Play.StreamNotFound")
- SWFDEC_AS_CONSTANT_STRING ("undefined")
- SWFDEC_AS_CONSTANT_STRING ("null")
- SWFDEC_AS_CONSTANT_STRING ("[object Object]")
- SWFDEC_AS_CONSTANT_STRING ("true")
- SWFDEC_AS_CONSTANT_STRING ("false")
- SWFDEC_AS_CONSTANT_STRING ("_x")
- SWFDEC_AS_CONSTANT_STRING ("_y")
- SWFDEC_AS_CONSTANT_STRING ("_xscale")
- SWFDEC_AS_CONSTANT_STRING ("_yscale")
- SWFDEC_AS_CONSTANT_STRING ("_currentframe")
- SWFDEC_AS_CONSTANT_STRING ("_totalframes")
- SWFDEC_AS_CONSTANT_STRING ("_alpha")
- SWFDEC_AS_CONSTANT_STRING ("_visible")
- SWFDEC_AS_CONSTANT_STRING ("_width")
- SWFDEC_AS_CONSTANT_STRING ("_height")
- SWFDEC_AS_CONSTANT_STRING ("_rotation")
- SWFDEC_AS_CONSTANT_STRING ("_target")
- SWFDEC_AS_CONSTANT_STRING ("_framesloaded")
- SWFDEC_AS_CONSTANT_STRING ("_name")
- SWFDEC_AS_CONSTANT_STRING ("_droptarget")
- SWFDEC_AS_CONSTANT_STRING ("_url")
- SWFDEC_AS_CONSTANT_STRING ("_highquality")
- SWFDEC_AS_CONSTANT_STRING ("_focusrect")
- SWFDEC_AS_CONSTANT_STRING ("_soundbuftime")
- SWFDEC_AS_CONSTANT_STRING ("_quality")
- SWFDEC_AS_CONSTANT_STRING ("_xmouse")
- SWFDEC_AS_CONSTANT_STRING ("_ymouse")
- SWFDEC_AS_CONSTANT_STRING ("_parent")
- SWFDEC_AS_CONSTANT_STRING ("_root")
- SWFDEC_AS_CONSTANT_STRING ("#ERROR#")
- SWFDEC_AS_CONSTANT_STRING ("number")
- SWFDEC_AS_CONSTANT_STRING ("boolean")
- SWFDEC_AS_CONSTANT_STRING ("string")
- SWFDEC_AS_CONSTANT_STRING ("movieclip")
- SWFDEC_AS_CONSTANT_STRING ("function")
- SWFDEC_AS_CONSTANT_STRING ("object")
- SWFDEC_AS_CONSTANT_STRING ("toString")
- SWFDEC_AS_CONSTANT_STRING ("valueOf")
- SWFDEC_AS_CONSTANT_STRING ("Function")
- SWFDEC_AS_CONSTANT_STRING ("prototype")
- SWFDEC_AS_CONSTANT_STRING ("constructor")
- SWFDEC_AS_CONSTANT_STRING ("Object")
- SWFDEC_AS_CONSTANT_STRING ("hasOwnProperty")
- SWFDEC_AS_CONSTANT_STRING ("NUMERIC")
- SWFDEC_AS_CONSTANT_STRING ("RETURNINDEXEDARRAY")
- SWFDEC_AS_CONSTANT_STRING ("UNIQUESORT")
- SWFDEC_AS_CONSTANT_STRING ("DESCENDING")
- SWFDEC_AS_CONSTANT_STRING ("CASEINSENSITIVE")
- SWFDEC_AS_CONSTANT_STRING ("Array")
- SWFDEC_AS_CONSTANT_STRING ("ASSetPropFlags")
- SWFDEC_AS_CONSTANT_STRING ("0")
- SWFDEC_AS_CONSTANT_STRING ("-Infinity")
- SWFDEC_AS_CONSTANT_STRING ("Infinity")
- SWFDEC_AS_CONSTANT_STRING ("NaN")
- SWFDEC_AS_CONSTANT_STRING ("Number")
- SWFDEC_AS_CONSTANT_STRING ("NAN")
- SWFDEC_AS_CONSTANT_STRING ("MAX_VALUE")
- SWFDEC_AS_CONSTANT_STRING ("MIN_VALUE")
- SWFDEC_AS_CONSTANT_STRING ("NEGATIVE_INFINITY")
- SWFDEC_AS_CONSTANT_STRING ("POSITIVE_INFINITY")
- SWFDEC_AS_CONSTANT_STRING ("[type Object]")
- SWFDEC_AS_CONSTANT_STRING ("startDrag")
- SWFDEC_AS_CONSTANT_STRING ("Mouse")
- SWFDEC_AS_CONSTANT_STRING ("hide")
- SWFDEC_AS_CONSTANT_STRING ("show")
- SWFDEC_AS_CONSTANT_STRING ("addListener")
- SWFDEC_AS_CONSTANT_STRING ("removeListener")
- SWFDEC_AS_CONSTANT_STRING ("MovieClip")
- SWFDEC_AS_CONSTANT_STRING ("attachMovie")
- SWFDEC_AS_CONSTANT_STRING ("duplicateMovieClip")
- SWFDEC_AS_CONSTANT_STRING ("getBytesLoaded")
- SWFDEC_AS_CONSTANT_STRING ("getBytesTotal")
- SWFDEC_AS_CONSTANT_STRING ("getDepth")
- SWFDEC_AS_CONSTANT_STRING ("getNextHighestDepth")
- SWFDEC_AS_CONSTANT_STRING ("getURL")
- SWFDEC_AS_CONSTANT_STRING ("gotoAndPlay")
- SWFDEC_AS_CONSTANT_STRING ("gotoAndStop")
- SWFDEC_AS_CONSTANT_STRING ("hitTest")
- SWFDEC_AS_CONSTANT_STRING ("nextFrame")
- SWFDEC_AS_CONSTANT_STRING ("play")
- SWFDEC_AS_CONSTANT_STRING ("prevFrame")
- SWFDEC_AS_CONSTANT_STRING ("removeMovieClip")
- SWFDEC_AS_CONSTANT_STRING ("stop")
- SWFDEC_AS_CONSTANT_STRING ("stopDrag")
- SWFDEC_AS_CONSTANT_STRING ("swapDepths")
- SWFDEC_AS_CONSTANT_STRING ("super")
- SWFDEC_AS_CONSTANT_STRING ("length")
- SWFDEC_AS_CONSTANT_STRING ("[type Function]")
- SWFDEC_AS_CONSTANT_STRING ("arguments")
- SWFDEC_AS_CONSTANT_STRING (",")
- SWFDEC_AS_CONSTANT_STRING ("registerClass")
- SWFDEC_AS_CONSTANT_STRING ("__constructor__")
- SWFDEC_AS_CONSTANT_STRING ("_global")
- SWFDEC_AS_CONSTANT_STRING ("aa")
- SWFDEC_AS_CONSTANT_STRING ("ab")
- SWFDEC_AS_CONSTANT_STRING ("ba")
- SWFDEC_AS_CONSTANT_STRING ("bb")
- SWFDEC_AS_CONSTANT_STRING ("ga")
- SWFDEC_AS_CONSTANT_STRING ("gb")
- SWFDEC_AS_CONSTANT_STRING ("ra")
- SWFDEC_AS_CONSTANT_STRING ("rb")
- SWFDEC_AS_CONSTANT_STRING ("getRGB")
- SWFDEC_AS_CONSTANT_STRING ("getTransform")
- SWFDEC_AS_CONSTANT_STRING ("setRGB")
- SWFDEC_AS_CONSTANT_STRING ("setTransform")
- SWFDEC_AS_CONSTANT_STRING ("Color")
- SWFDEC_AS_CONSTANT_STRING ("push")
- SWFDEC_AS_CONSTANT_STRING ("parseInt")
- SWFDEC_AS_CONSTANT_STRING ("Math")
- SWFDEC_AS_CONSTANT_STRING ("abs")
- SWFDEC_AS_CONSTANT_STRING ("acos")
- SWFDEC_AS_CONSTANT_STRING ("asin")
- SWFDEC_AS_CONSTANT_STRING ("atan")
- SWFDEC_AS_CONSTANT_STRING ("ceil")
- SWFDEC_AS_CONSTANT_STRING ("cos")
- SWFDEC_AS_CONSTANT_STRING ("exp")
- SWFDEC_AS_CONSTANT_STRING ("floor")
- SWFDEC_AS_CONSTANT_STRING ("log")
- SWFDEC_AS_CONSTANT_STRING ("sin")
- SWFDEC_AS_CONSTANT_STRING ("sqrt")
- SWFDEC_AS_CONSTANT_STRING ("tan")
- SWFDEC_AS_CONSTANT_STRING ("E")
- SWFDEC_AS_CONSTANT_STRING ("LN10")
- SWFDEC_AS_CONSTANT_STRING ("LN2")
- SWFDEC_AS_CONSTANT_STRING ("LOG10E")
- SWFDEC_AS_CONSTANT_STRING ("LOG2E")
- SWFDEC_AS_CONSTANT_STRING ("PI")
- SWFDEC_AS_CONSTANT_STRING ("SQRT1_2")
- SWFDEC_AS_CONSTANT_STRING ("SQRT2")
- SWFDEC_AS_CONSTANT_STRING ("atan2")
- SWFDEC_AS_CONSTANT_STRING ("min")
- SWFDEC_AS_CONSTANT_STRING ("max")
- SWFDEC_AS_CONSTANT_STRING ("pow")
- SWFDEC_AS_CONSTANT_STRING ("random")
- SWFDEC_AS_CONSTANT_STRING ("round")
- SWFDEC_AS_CONSTANT_STRING ("String")
- SWFDEC_AS_CONSTANT_STRING ("fromCharCode")
- SWFDEC_AS_CONSTANT_STRING ("substr")
- SWFDEC_AS_CONSTANT_STRING ("substring")
- SWFDEC_AS_CONSTANT_STRING ("toLowerCase")
- SWFDEC_AS_CONSTANT_STRING ("toUpperCase")
- SWFDEC_AS_CONSTANT_STRING ("isFinite")
- SWFDEC_AS_CONSTANT_STRING ("isNaN")
- SWFDEC_AS_CONSTANT_STRING ("setInterval")
- SWFDEC_AS_CONSTANT_STRING ("clearInterval")
- SWFDEC_AS_CONSTANT_STRING ("escape")
- SWFDEC_AS_CONSTANT_STRING ("unescape")
- SWFDEC_AS_CONSTANT_STRING ("charAt")
- SWFDEC_AS_CONSTANT_STRING ("charCodeAt")
- SWFDEC_AS_CONSTANT_STRING ("NetConnection")
- SWFDEC_AS_CONSTANT_STRING ("connect")
- SWFDEC_AS_CONSTANT_STRING ("createEmptyMovieClip")
- SWFDEC_AS_CONSTANT_STRING ("split")
- SWFDEC_AS_CONSTANT_STRING ("join")
- SWFDEC_AS_CONSTANT_STRING ("pop")
- SWFDEC_AS_CONSTANT_STRING ("shift")
- SWFDEC_AS_CONSTANT_STRING ("unshift")
- SWFDEC_AS_CONSTANT_STRING ("reverse")
- SWFDEC_AS_CONSTANT_STRING ("concat")
- SWFDEC_AS_CONSTANT_STRING ("slice")
- SWFDEC_AS_CONSTANT_STRING ("splice")
- SWFDEC_AS_CONSTANT_STRING ("sort")
- SWFDEC_AS_CONSTANT_STRING ("sortOn")
- SWFDEC_AS_CONSTANT_STRING ("NetStream")
- SWFDEC_AS_CONSTANT_STRING ("pause")
- SWFDEC_AS_CONSTANT_STRING ("seek")
- SWFDEC_AS_CONSTANT_STRING ("setBufferTime")
- SWFDEC_AS_CONSTANT_STRING ("load")
- SWFDEC_AS_CONSTANT_STRING ("XML")
- SWFDEC_AS_CONSTANT_STRING ("Video")
- SWFDEC_AS_CONSTANT_STRING ("attachVideo")
- SWFDEC_AS_CONSTANT_STRING ("clear")
- SWFDEC_AS_CONSTANT_STRING ("time")
- SWFDEC_AS_CONSTANT_STRING ("bytesLoaded")
- SWFDEC_AS_CONSTANT_STRING ("bytesTotal")
- SWFDEC_AS_CONSTANT_STRING ("indexOf")
- SWFDEC_AS_CONSTANT_STRING ("call")
- SWFDEC_AS_CONSTANT_STRING ("Boolean")
- SWFDEC_AS_CONSTANT_STRING ("addProperty")
- SWFDEC_AS_CONSTANT_STRING ("ASnative")
- SWFDEC_AS_CONSTANT_STRING ("_listeners")
- SWFDEC_AS_CONSTANT_STRING ("broadcastMessage")
- SWFDEC_AS_CONSTANT_STRING ("showAll")
- SWFDEC_AS_CONSTANT_STRING ("noBorder")
- SWFDEC_AS_CONSTANT_STRING ("exactFit")
- SWFDEC_AS_CONSTANT_STRING ("noScale")
- SWFDEC_AS_CONSTANT_STRING ("Stage")
- SWFDEC_AS_CONSTANT_STRING ("onResize")
- SWFDEC_AS_CONSTANT_STRING ("getBounds")
- SWFDEC_AS_CONSTANT_STRING ("xMin")
- SWFDEC_AS_CONSTANT_STRING ("xMax")
- SWFDEC_AS_CONSTANT_STRING ("yMin")
- SWFDEC_AS_CONSTANT_STRING ("yMax")
- SWFDEC_AS_CONSTANT_STRING ("close")
- SWFDEC_AS_CONSTANT_STRING ("_bytesLoaded")
- SWFDEC_AS_CONSTANT_STRING ("_bytesTotal")
- SWFDEC_AS_CONSTANT_STRING ("xmlDecl")
- SWFDEC_AS_CONSTANT_STRING ("docTypeDecl")
- SWFDEC_AS_CONSTANT_STRING ("XMLNode")
- SWFDEC_AS_CONSTANT_STRING ("namespaceURI")
- SWFDEC_AS_CONSTANT_STRING ("localName")
- SWFDEC_AS_CONSTANT_STRING ("prefix")
- SWFDEC_AS_CONSTANT_STRING ("previousSibling")
- SWFDEC_AS_CONSTANT_STRING ("parentNode")
- SWFDEC_AS_CONSTANT_STRING ("nodeName")
- SWFDEC_AS_CONSTANT_STRING ("nodeType")
- SWFDEC_AS_CONSTANT_STRING ("nodeValue")
- SWFDEC_AS_CONSTANT_STRING ("nextSibling")
- SWFDEC_AS_CONSTANT_STRING ("lastChild")
- SWFDEC_AS_CONSTANT_STRING ("firstChild")
- SWFDEC_AS_CONSTANT_STRING ("childNodes")
- SWFDEC_AS_CONSTANT_STRING ("cloneNode")
- SWFDEC_AS_CONSTANT_STRING ("removeNode")
- SWFDEC_AS_CONSTANT_STRING ("insertBefore")
- SWFDEC_AS_CONSTANT_STRING ("appendChild")
- SWFDEC_AS_CONSTANT_STRING ("getNamespaceForPrefix")
- SWFDEC_AS_CONSTANT_STRING ("getPrefixForNamespace")
- SWFDEC_AS_CONSTANT_STRING ("hasChildNodes")
- SWFDEC_AS_CONSTANT_STRING ("attributes")
- SWFDEC_AS_CONSTANT_STRING ("loaded")
- SWFDEC_AS_CONSTANT_STRING ("lastIndexOf")
- SWFDEC_AS_CONSTANT_STRING ("hasAudio")
- SWFDEC_AS_CONSTANT_STRING ("hasStreamingAudio")
- SWFDEC_AS_CONSTANT_STRING ("hasStreamingVideo")
- SWFDEC_AS_CONSTANT_STRING ("hasEmbeddedVideo")
- SWFDEC_AS_CONSTANT_STRING ("hasMP3")
- SWFDEC_AS_CONSTANT_STRING ("hasAudioEncoder")
- SWFDEC_AS_CONSTANT_STRING ("hasVideoEncoder")
- SWFDEC_AS_CONSTANT_STRING ("hasAccessibility")
- SWFDEC_AS_CONSTANT_STRING ("hasPrinting")
- SWFDEC_AS_CONSTANT_STRING ("hasScreenPlayback")
- SWFDEC_AS_CONSTANT_STRING ("hasScreenBroadcast")
- SWFDEC_AS_CONSTANT_STRING ("isDebugger")
- SWFDEC_AS_CONSTANT_STRING ("version")
- SWFDEC_AS_CONSTANT_STRING ("manufacturer")
- SWFDEC_AS_CONSTANT_STRING ("screenResolutionX")
- SWFDEC_AS_CONSTANT_STRING ("screenResolutionY")
- SWFDEC_AS_CONSTANT_STRING ("screenDPI")
- SWFDEC_AS_CONSTANT_STRING ("screenColor")
- SWFDEC_AS_CONSTANT_STRING ("pixelAspectRatio")
- SWFDEC_AS_CONSTANT_STRING ("os")
- SWFDEC_AS_CONSTANT_STRING ("language")
- SWFDEC_AS_CONSTANT_STRING ("hasIME")
- SWFDEC_AS_CONSTANT_STRING ("playerType")
- SWFDEC_AS_CONSTANT_STRING ("avHardwareDisable")
- SWFDEC_AS_CONSTANT_STRING ("localFileReadDisable")
- SWFDEC_AS_CONSTANT_STRING ("windowlessDisable")
- SWFDEC_AS_CONSTANT_STRING ("hasTLS")
- SWFDEC_AS_CONSTANT_STRING ("serverString")
- SWFDEC_AS_CONSTANT_STRING ("$version")
- SWFDEC_AS_CONSTANT_STRING ("contentType")
- SWFDEC_AS_CONSTANT_STRING ("application/x-www-form-urlencoded")
- SWFDEC_AS_CONSTANT_STRING ("ignoreWhite")
- SWFDEC_AS_CONSTANT_STRING ("ASconstructor")
- SWFDEC_AS_CONSTANT_STRING ("Date")
- SWFDEC_AS_CONSTANT_STRING ("UTC")
- SWFDEC_AS_CONSTANT_STRING ("getTime")
- SWFDEC_AS_CONSTANT_STRING ("getTimezoneOffset")
- SWFDEC_AS_CONSTANT_STRING ("getMilliseconds")
- SWFDEC_AS_CONSTANT_STRING ("getUTCMilliseconds")
- SWFDEC_AS_CONSTANT_STRING ("getSeconds")
- SWFDEC_AS_CONSTANT_STRING ("getUTCSeconds")
- SWFDEC_AS_CONSTANT_STRING ("getMinutes")
- SWFDEC_AS_CONSTANT_STRING ("getUTCMinutes")
- SWFDEC_AS_CONSTANT_STRING ("getHours")
- SWFDEC_AS_CONSTANT_STRING ("getUTCHours")
- SWFDEC_AS_CONSTANT_STRING ("getDay")
- SWFDEC_AS_CONSTANT_STRING ("getUTCDay")
- SWFDEC_AS_CONSTANT_STRING ("getDate")
- SWFDEC_AS_CONSTANT_STRING ("getUTCDate")
- SWFDEC_AS_CONSTANT_STRING ("getMonth")
- SWFDEC_AS_CONSTANT_STRING ("getUTCMonth")
- SWFDEC_AS_CONSTANT_STRING ("getYear")
- SWFDEC_AS_CONSTANT_STRING ("getUTCYear")
- SWFDEC_AS_CONSTANT_STRING ("getFullYear")
- SWFDEC_AS_CONSTANT_STRING ("getUTCFullYear")
- SWFDEC_AS_CONSTANT_STRING ("setTime")
- SWFDEC_AS_CONSTANT_STRING ("setMilliseconds")
- SWFDEC_AS_CONSTANT_STRING ("setUTCMilliseconds")
- SWFDEC_AS_CONSTANT_STRING ("setSeconds")
- SWFDEC_AS_CONSTANT_STRING ("setUTCSeconds")
- SWFDEC_AS_CONSTANT_STRING ("setMinutes")
- SWFDEC_AS_CONSTANT_STRING ("setUTCMinutes")
- SWFDEC_AS_CONSTANT_STRING ("setHours")
- SWFDEC_AS_CONSTANT_STRING ("setUTCHours")
- SWFDEC_AS_CONSTANT_STRING ("setDate")
- SWFDEC_AS_CONSTANT_STRING ("setUTCDate")
- SWFDEC_AS_CONSTANT_STRING ("setMonth")
- SWFDEC_AS_CONSTANT_STRING ("setUTCMonth")
- SWFDEC_AS_CONSTANT_STRING ("setYear")
- SWFDEC_AS_CONSTANT_STRING ("setUTCYear")
- SWFDEC_AS_CONSTANT_STRING ("setFullYear")
- SWFDEC_AS_CONSTANT_STRING ("setUTCFullYear")
- SWFDEC_AS_CONSTANT_STRING ("target")
- SWFDEC_AS_CONSTANT_STRING ("isPropertyEnumerable")
- SWFDEC_AS_CONSTANT_STRING ("watch")
- SWFDEC_AS_CONSTANT_STRING ("unwatch")
- SWFDEC_AS_CONSTANT_STRING ("apply")
- SWFDEC_AS_CONSTANT_STRING ("isPrototypeOf")
- SWFDEC_AS_CONSTANT_STRING ("/")
- SWFDEC_AS_CONSTANT_STRING ("_typewriter")
- SWFDEC_AS_CONSTANT_STRING ("_sans")
- SWFDEC_AS_CONSTANT_STRING ("_serif")
- SWFDEC_AS_CONSTANT_STRING ("align")
- SWFDEC_AS_CONSTANT_STRING ("left")
- SWFDEC_AS_CONSTANT_STRING ("right")
- SWFDEC_AS_CONSTANT_STRING ("center")
- SWFDEC_AS_CONSTANT_STRING ("justify")
- SWFDEC_AS_CONSTANT_STRING ("font")
- SWFDEC_AS_CONSTANT_STRING ("url")
- SWFDEC_AS_CONSTANT_STRING ("bullet")
- SWFDEC_AS_CONSTANT_STRING ("bold")
- SWFDEC_AS_CONSTANT_STRING ("italic")
- SWFDEC_AS_CONSTANT_STRING ("kerning")
- SWFDEC_AS_CONSTANT_STRING ("underline")
- SWFDEC_AS_CONSTANT_STRING ("blockIndent")
- SWFDEC_AS_CONSTANT_STRING ("color")
- SWFDEC_AS_CONSTANT_STRING ("indent")
- SWFDEC_AS_CONSTANT_STRING ("leading")
- SWFDEC_AS_CONSTANT_STRING ("leftMargin")
- SWFDEC_AS_CONSTANT_STRING ("rightMargin")
- SWFDEC_AS_CONSTANT_STRING ("size")
- SWFDEC_AS_CONSTANT_STRING ("tabStops")
- SWFDEC_AS_CONSTANT_STRING ("letterSpacing")
- SWFDEC_AS_CONSTANT_STRING ("display")
- SWFDEC_AS_CONSTANT_STRING ("none")
- SWFDEC_AS_CONSTANT_STRING ("inline")
- SWFDEC_AS_CONSTANT_STRING ("block")
- SWFDEC_AS_CONSTANT_STRING ("TextField")
- SWFDEC_AS_CONSTANT_STRING ("text")
- SWFDEC_AS_CONSTANT_STRING ("htmlText")
- SWFDEC_AS_CONSTANT_STRING ("html")
- SWFDEC_AS_CONSTANT_STRING ("TextFormat")
- SWFDEC_AS_CONSTANT_STRING ("Times New Roman")
- SWFDEC_AS_CONSTANT_STRING ("condenseWhite")
- SWFDEC_AS_CONSTANT_STRING ("textColor")
- SWFDEC_AS_CONSTANT_STRING ("embedFonts")
- SWFDEC_AS_CONSTANT_STRING ("autoSize")
- SWFDEC_AS_CONSTANT_STRING ("wordWrap")
- SWFDEC_AS_CONSTANT_STRING ("border")
- SWFDEC_AS_CONSTANT_STRING ("Key")
- SWFDEC_AS_CONSTANT_STRING ("background")
- SWFDEC_AS_CONSTANT_STRING ("backgroundColor")
- SWFDEC_AS_CONSTANT_STRING ("borderColor")
- SWFDEC_AS_CONSTANT_STRING ("multiline")
- SWFDEC_AS_CONSTANT_STRING ("type")
- SWFDEC_AS_CONSTANT_STRING ("input")
- SWFDEC_AS_CONSTANT_STRING ("dynamic")
- SWFDEC_AS_CONSTANT_STRING ("scroll")
- SWFDEC_AS_CONSTANT_STRING ("maxChars")
- SWFDEC_AS_CONSTANT_STRING ("selectable")
- SWFDEC_AS_CONSTANT_STRING ("password")
- SWFDEC_AS_CONSTANT_STRING ("variable")
- SWFDEC_AS_CONSTANT_STRING ("restrict")
- SWFDEC_AS_CONSTANT_STRING ("mouseWheelEnabled")
- SWFDEC_AS_CONSTANT_STRING ("_level0")
- SWFDEC_AS_CONSTANT_STRING ("hscroll")
- SWFDEC_AS_CONSTANT_STRING ("maxhscroll")
- SWFDEC_AS_CONSTANT_STRING ("maxscroll")
- SWFDEC_AS_CONSTANT_STRING ("bottomScroll")
- SWFDEC_AS_CONSTANT_STRING ("Sans")
- SWFDEC_AS_CONSTANT_STRING ("Serif")
- SWFDEC_AS_CONSTANT_STRING ("Monospace")
- SWFDEC_AS_CONSTANT_STRING ("textHeight")
- SWFDEC_AS_CONSTANT_STRING ("textWidth")
- SWFDEC_AS_CONSTANT_STRING ("onScroller")
- SWFDEC_AS_CONSTANT_STRING ("styleSheet")
- SWFDEC_AS_CONSTANT_STRING ("_styles")
- SWFDEC_AS_CONSTANT_STRING ("onLoadStart")
- SWFDEC_AS_CONSTANT_STRING ("onLoadComplete")
- 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")
- SWFDEC_AS_CONSTANT_STRING ("creationDate")
- SWFDEC_AS_CONSTANT_STRING ("creator")
- SWFDEC_AS_CONSTANT_STRING ("modificationDate")
- SWFDEC_AS_CONSTANT_STRING ("name")
- SWFDEC_AS_CONSTANT_STRING ("postData")
- SWFDEC_AS_CONSTANT_STRING ("PrintJob")
- SWFDEC_AS_CONSTANT_STRING ("orientation")
- SWFDEC_AS_CONSTANT_STRING ("pageHeight")
- SWFDEC_AS_CONSTANT_STRING ("pageWidth")
- SWFDEC_AS_CONSTANT_STRING ("paperHeight")
- SWFDEC_AS_CONSTANT_STRING ("paperWidth")
- SWFDEC_AS_CONSTANT_STRING ("callee")
- SWFDEC_AS_CONSTANT_STRING ("caller")
- SWFDEC_AS_CONSTANT_STRING ("enableDebugConsole")
- SWFDEC_AS_CONSTANT_STRING ("remote")
- SWFDEC_AS_CONSTANT_STRING ("localWithFile")
- SWFDEC_AS_CONSTANT_STRING ("localWithNetwork")
- SWFDEC_AS_CONSTANT_STRING ("localTrusted")
- SWFDEC_AS_CONSTANT_STRING ("normal")
- SWFDEC_AS_CONSTANT_STRING ("layer")
- SWFDEC_AS_CONSTANT_STRING ("multiply")
- SWFDEC_AS_CONSTANT_STRING ("screen")
- SWFDEC_AS_CONSTANT_STRING ("lighten")
- SWFDEC_AS_CONSTANT_STRING ("darken")
- SWFDEC_AS_CONSTANT_STRING ("difference")
- SWFDEC_AS_CONSTANT_STRING ("add")
- SWFDEC_AS_CONSTANT_STRING ("subtract")
- SWFDEC_AS_CONSTANT_STRING ("invert")
- SWFDEC_AS_CONSTANT_STRING ("alpha")
- SWFDEC_AS_CONSTANT_STRING ("erase")
- SWFDEC_AS_CONSTANT_STRING ("overlay")
- SWFDEC_AS_CONSTANT_STRING ("hardlight")
- SWFDEC_AS_CONSTANT_STRING ("getTextExtent")
- SWFDEC_AS_CONSTANT_STRING ("domain")
- SWFDEC_AS_CONSTANT_STRING ("linear")
- SWFDEC_AS_CONSTANT_STRING ("radial")
- SWFDEC_AS_CONSTANT_STRING ("matrixType")
- SWFDEC_AS_CONSTANT_STRING ("box")
- SWFDEC_AS_CONSTANT_STRING ("a")
- SWFDEC_AS_CONSTANT_STRING ("b")
- SWFDEC_AS_CONSTANT_STRING ("c")
- SWFDEC_AS_CONSTANT_STRING ("d")
- SWFDEC_AS_CONSTANT_STRING ("e")
- SWFDEC_AS_CONSTANT_STRING ("f")
- SWFDEC_AS_CONSTANT_STRING ("g")
- SWFDEC_AS_CONSTANT_STRING ("h")
- SWFDEC_AS_CONSTANT_STRING ("i")
- SWFDEC_AS_CONSTANT_STRING ("r")
- SWFDEC_AS_CONSTANT_STRING ("w")
- SWFDEC_AS_CONSTANT_STRING ("x")
- SWFDEC_AS_CONSTANT_STRING ("y")
- SWFDEC_AS_CONSTANT_STRING ("idMap")
- SWFDEC_AS_CONSTANT_STRING ("id")
- SWFDEC_AS_CONSTANT_STRING ("onClose")
- SWFDEC_AS_CONSTANT_STRING ("onConnect")
- /* add more here */
-;
diff --git a/libswfdec/swfdec_as_super.c b/libswfdec/swfdec_as_super.c
deleted file mode 100644
index 9e67b40..0000000
--- a/libswfdec/swfdec_as_super.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-
-#include "swfdec_as_super.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_frame_internal.h"
-#include "swfdec_as_function.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-#include "swfdec_movie.h"
-
-G_DEFINE_TYPE (SwfdecAsSuper, swfdec_as_super, SWFDEC_TYPE_AS_FUNCTION)
-
-static SwfdecAsFrame *
-swfdec_as_super_call (SwfdecAsFunction *function)
-{
- SwfdecAsSuper *super = SWFDEC_AS_SUPER (function);
- SwfdecAsValue val;
- SwfdecAsFunction *fun;
- SwfdecAsFunctionClass *klass;
- SwfdecAsFrame *frame;
-
- if (super->object == NULL) {
- SWFDEC_WARNING ("super () called without an object.");
- return NULL;
- }
-
- swfdec_as_object_get_variable (super->object, SWFDEC_AS_STR___constructor__, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val) ||
- !SWFDEC_IS_AS_FUNCTION (fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&val)))
- return NULL;
-
- klass = SWFDEC_AS_FUNCTION_GET_CLASS (fun);
- frame = klass->call (fun);
- if (frame == NULL)
- return NULL;
- /* We set the real function here. 1) swfdec_as_context_run() requires it.
- * And b) it makes more sense reading the constructor's name than reading "super"
- * in a debugger
- */
- frame->function = fun;
- frame->construct = frame->next->construct;
- swfdec_as_frame_set_this (frame, super->thisp);
- return frame;
-}
-
-static gboolean
-swfdec_as_super_get (SwfdecAsObject *object, SwfdecAsObject *orig,
- const char *variable, SwfdecAsValue *val, guint *flags)
-{
- SwfdecAsSuper *super = SWFDEC_AS_SUPER (object);
- SwfdecAsObjectClass *klass;
- SwfdecAsObject *cur;
- guint i;
-
- if (super->object == NULL) {
- SWFDEC_WARNING ("super.%s () called without an object.", variable);
- return FALSE;
- }
- cur = super->object->prototype;
- for (i = 0; i <= SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT && cur != NULL; i++) {
- klass = SWFDEC_AS_OBJECT_GET_CLASS (cur);
- /* FIXME: is the orig pointer correct? */
- if (klass->get (cur, super->object, variable, val, flags))
- return TRUE;
- /* FIXME: need get_prototype_internal here? */
- cur = swfdec_as_object_get_prototype (cur);
- }
- if (i > SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT)
- swfdec_as_context_abort (object->context, "Prototype recursion limit exceeded");
- SWFDEC_AS_VALUE_SET_UNDEFINED (val);
- *flags = 0;
- return FALSE;
-}
-
-static void
-swfdec_as_super_set (SwfdecAsObject *object, const char *variable, const SwfdecAsValue *val, guint flags)
-{
- /* This seems to be ignored completely */
-}
-
-static void
-swfdec_as_super_set_flags (SwfdecAsObject *object, const char *variable, guint flags, guint mask)
-{
- /* if we have no variables, we also can't set its flags... */
-}
-
-static SwfdecAsDeleteReturn
-swfdec_as_super_delete (SwfdecAsObject *object, const char *variable)
-{
- /* if we have no variables... */
- return SWFDEC_AS_DELETE_NOT_FOUND;
-}
-
-static SwfdecAsObject *
-swfdec_as_super_resolve (SwfdecAsObject *object)
-{
- SwfdecAsSuper *super = SWFDEC_AS_SUPER (object);
-
- return super->thisp;
-}
-
-static void
-swfdec_as_super_class_init (SwfdecAsSuperClass *klass)
-{
- SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
- SwfdecAsFunctionClass *function_class = SWFDEC_AS_FUNCTION_CLASS (klass);
-
- asobject_class->get = swfdec_as_super_get;
- asobject_class->set = swfdec_as_super_set;
- asobject_class->set_flags = swfdec_as_super_set_flags;
- asobject_class->del = swfdec_as_super_delete;
- asobject_class->resolve = swfdec_as_super_resolve;
-
- function_class->call = swfdec_as_super_call;
-}
-
-static void
-swfdec_as_super_init (SwfdecAsSuper *super)
-{
-}
-
-void
-swfdec_as_super_new (SwfdecAsFrame *frame, SwfdecAsObject *thisp, SwfdecAsObject *ref)
-{
- SwfdecAsContext *context;
- SwfdecAsSuper *super;
-
- g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (thisp));
- g_return_if_fail (ref == NULL || SWFDEC_IS_AS_OBJECT (ref));
-
- if (frame->super != NULL)
- return;
- context = SWFDEC_AS_OBJECT (frame)->context;
- if (context->version <= 5)
- return;
-
- if (!swfdec_as_context_use_mem (context, sizeof (SwfdecAsSuper)))
- return;
- super = g_object_new (SWFDEC_TYPE_AS_SUPER, NULL);
- frame->super = SWFDEC_AS_OBJECT (super);
- swfdec_as_object_add (SWFDEC_AS_OBJECT (super), context, sizeof (SwfdecAsSuper));
- super->thisp = thisp;
- if (context->version <= 5) {
- super->object = NULL;
- } else {
- super->object = ref;
- }
-}
-
-/**
- * swfdec_as_super_new_chain:
- * @frame: the frame that is called
- * @super: the super object to chain from
- * @chain_to: object to chain to. Must be in the prototype chain of @super. Or
- * %NULL to just use the super object's prototype
- *
- * This function creates a super object relative to the given @super object. It
- * is only needed when calling functions on the @super object.
- **/
-void
-swfdec_as_super_new_chain (SwfdecAsFrame *frame, SwfdecAsSuper *super,
- const char *function_name)
-{
- SwfdecAsObject *ref;
- SwfdecAsContext *context;
-
- g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
- g_return_if_fail (SWFDEC_IS_AS_SUPER (super));
-
- if (frame->super != NULL)
- return;
-
- if (super->object == NULL)
- return;
- ref = super->object->prototype;
- if (ref == NULL)
- return;
- context = SWFDEC_AS_OBJECT (frame)->context;
- if (function_name && context->version > 6) {
- /* skip prototypes to find the next one that has this function defined */
- SwfdecAsObject *res;
- if (swfdec_as_object_get_variable_and_flags (ref,
- function_name, NULL, NULL, &res) && ref != res) {
- while (ref->prototype != res) {
- ref = ref->prototype;
- g_return_if_fail (ref);
- }
- }
- }
- swfdec_as_super_new (frame, super->thisp, ref);
-}
-
diff --git a/libswfdec/swfdec_as_super.h b/libswfdec/swfdec_as_super.h
deleted file mode 100644
index ad082e9..0000000
--- a/libswfdec/swfdec_as_super.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AS_SUPER_H_
-#define _SWFDEC_AS_SUPER_H_
-
-#include <libswfdec/swfdec_as_function.h>
-#include <libswfdec/swfdec_as_types.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecAsSuper SwfdecAsSuper;
-typedef struct _SwfdecAsSuperClass SwfdecAsSuperClass;
-
-#define SWFDEC_TYPE_AS_SUPER (swfdec_as_super_get_type())
-#define SWFDEC_IS_AS_SUPER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_SUPER))
-#define SWFDEC_IS_AS_SUPER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_SUPER))
-#define SWFDEC_AS_SUPER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_SUPER, SwfdecAsSuper))
-#define SWFDEC_AS_SUPER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_SUPER, SwfdecAsSuperClass))
-#define SWFDEC_AS_SUPER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_SUPER, SwfdecAsSuperClass))
-
-struct _SwfdecAsSuper {
- SwfdecAsFunction function;
-
- SwfdecAsObject * thisp; /* object super was called on */
- SwfdecAsObject * object; /* current prototype we reference or NULL if none */
-};
-
-struct _SwfdecAsSuperClass {
- SwfdecAsFunctionClass function_class;
-};
-
-GType swfdec_as_super_get_type (void);
-
-void swfdec_as_super_new (SwfdecAsFrame * frame,
- SwfdecAsObject * thisp,
- SwfdecAsObject * ref);
-void swfdec_as_super_new_chain (SwfdecAsFrame * frame,
- SwfdecAsSuper * super,
- const char * function_name);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_as_types.c b/libswfdec/swfdec_as_types.c
deleted file mode 100644
index e5253d3..0000000
--- a/libswfdec/swfdec_as_types.c
+++ /dev/null
@@ -1,677 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-#include <string.h>
-
-#include "swfdec_as_types.h"
-#include "swfdec_as_object.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_function.h"
-#include "swfdec_as_number.h"
-#include "swfdec_as_stack.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_as_super.h"
-#include "swfdec_debug.h"
-#include "swfdec_movie.h"
-
-/*** GTK-DOC ***/
-
-/**
- * SECTION:SwfdecAsValue
- * @title: SwfdecAsValue
- * @short_description: exchanging values with the Actionscript engine
- *
- * This section describes how values are handled inside the Actionscript
- * engine. Since Actionscript is a dynamically typed language, the variable type
- * has to be carried with every value. #SwfdecAsValue accomplishes that. Swfdec
- * allows two possible ways of accessing these values: The common method is to
- * use the provided functions to explicitly convert the values to a given type
- * with a function such as swfdec_as_value_to_string (). This is convenient,
- * but can be very slow as it can call back into the Actionscript engine when
- * converting various objects. So it can be unsuitable in some cases.
- * A different possibiltiy is accessing the values directly using the accessor
- * macros. You must check the type before doing so though. For setting values,
- * there only exist macros, since type conversion is not necessary.
- */
-
-/**
- * SwfdecAsValueType:
- * @SWFDEC_AS_TYPE_UNDEFINED: the special undefined value
- * @SWFDEC_AS_TYPE_BOOLEAN: a boolean value - true or false
- * @SWFDEC_AS_TYPE_INT: reserved value for integers. Should the need arise for
- * performance enhancements - especially on embedded
- * devices - it might be useful to implement this type.
- * For now, this type will never appear in Swfdec. Using
- * it will cause Swfdec to crash.
- * @SWFDEC_AS_TYPE_NUMBER: a double value - also used for integer numbers
- * @SWFDEC_AS_TYPE_STRING: a string. Strings are garbage-collected and unique.
- * @SWFDEC_AS_TYPE_NULL: the spaecial null value
- * @SWFDEC_AS_TYPE_OBJECT: an object - must be of type #SwfdecAsObject
- *
- * These are the possible values the Swfdec Actionscript engine knows about.
- */
-
-/**
- * SwfdecAsValue:
- * @type: the type of this value.
- *
- * This is the type used to present an opaque value in the Actionscript
- * engine. See #SwfdecAsValueType for possible types. It's similar in
- * spirit to #GValue. The value held is garbage-collected. Apart from the type
- * member, use the provided macros to access this structure.
- * <note>If you memset a SwfdecAsValue to 0, it is a valid undefined value.</note>
- */
-
-/**
- * SWFDEC_AS_VALUE_SET_UNDEFINED:
- * @val: value to set as undefined
- *
- * Sets @val to the special undefined value. If you create a temporary value,
- * you can instead use code such as |[ SwfdecAsValue val = { 0, }; ]|
- */
-
-/**
- * SWFDEC_AS_VALUE_GET_BOOLEAN:
- * @val: value to get, the value must reference a boolean
- *
- * Gets the boolean associated with value. If you are not sure if the value is
- * a boolean, use swfdec_as_value_to_boolean () instead.
- *
- * Returns: %TRUE or %FALSE
- */
-
-/**
- * SWFDEC_AS_VALUE_SET_BOOLEAN:
- * @val: value to set
- * @b: boolean value to set, must be either %TRUE or %FALSE
- *
- * Sets @val to the specified boolean value.
- */
-
-/**
- * SWFDEC_AS_VALUE_GET_NUMBER:
- * @val: value to get, the value must reference a number
- *
- * Gets the number associated with @val. If you are not sure that the value is
- * a valid number value, consider using swfdec_as_value_to_number() or
- * swfdec_as_value_to_int() instead.
- *
- * Returns: a double. It can be NaN or +-Infinity, but not -0.0
- */
-
-/**
- * SWFDEC_AS_VALUE_SET_NUMBER:
- * @val: value to set
- * @d: double value to set
- *
- * Sets @val to the given value. If you are sure the value is a valid
- * integer value, use SWFDEC_AS_VALUE_SET_INT() instead.
- */
-
-/**
- * SWFDEC_AS_VALUE_SET_INT:
- * @val: value to set
- * @d: integer value to set
- *
- * Sets @val to the given value. Currently this macro is equivalent to
- * SWFDEC_AS_VALUE_SET_NUMBER(), but this may change in future versions of
- * Swfdec.
- */
-
-/**
- * SWFDEC_AS_VALUE_GET_STRING:
- * @val: value to get, the value must reference a string
- *
- * Gets the string associated with @val. If you are not sure that the value is
- * a string value, consider using swfdec_as_value_to_string() instead.
- *
- * Returns: a garbage-collected string.
- */
-
-/**
- * SWFDEC_AS_VALUE_SET_STRING:
- * @val: value to set
- * @s: garbage-collected string to use
- *
- * Sets @val to the given string value.
- */
-
-/**
- * SWFDEC_AS_VALUE_SET_NULL:
- * @val: value to set
- *
- * Sets @val to the special null value.
- */
-
-/**
- * SWFDEC_AS_VALUE_GET_OBJECT:
- * @val: value to get, the value must reference an object
- *
- * Gets the object associated with @val. If you are not sure that the value is
- * an object value, consider using swfdec_as_value_to_object() instead.
- *
- * Returns: a #SwfdecAsObject
- */
-
-/**
- * SWFDEC_AS_VALUE_SET_OBJECT:
- * @val: value to set
- * @o: garbage-collected #SwfdecAsObject to use
- *
- * Sets @val to the given object. The object must have been added to the
- * garbage collector via swfdec_as_object_add() previously.
- */
-
-/*** actual code ***/
-
-/**
- * swfdec_as_str_concat:
- * @cx: a #SwfdecAsContext
- * @s1: first string
- * @s2: second string
- *
- * Convenience function to concatenate two garbage-collected strings. This
- * function is equivalent to g_strconcat ().
- *
- * Returns: A new garbage-collected string
- **/
-const char *
-swfdec_as_str_concat (SwfdecAsContext *cx, const char * s1, const char *s2)
-{
- const char *ret;
- char *s;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (cx), SWFDEC_AS_STR_EMPTY);
- g_return_val_if_fail (s1, SWFDEC_AS_STR_EMPTY);
- g_return_val_if_fail (s2, SWFDEC_AS_STR_EMPTY);
-
- s = g_strconcat (s1, s2, NULL);
- ret = swfdec_as_context_get_string (cx, s);
- g_free (s);
-
- return ret;
-}
-
-/**
- * swfdec_as_integer_to_string:
- * @context: a #SwfdecAsContext
- * @i: an integer that fits into 32 bits
- *
- * Converts @d into a string using the same conversion algorithm as the
- * official Flash player.
- *
- * Returns: a garbage-collected string
- **/
-const char *
-swfdec_as_integer_to_string (SwfdecAsContext *context, int i)
-{
- return swfdec_as_context_give_string (context, g_strdup_printf ("%d", i));
-}
-
-/**
- * swfdec_as_double_to_string:
- * @context: a #SwfdecAsContext
- * @d: a double
- *
- * Converts @d into a string using the same conversion algorithm as the
- * official Flash player.
- *
- * Returns: a garbage-collected string
- **/
-/* FIXME: this function is still buggy - and it's ugly as hell.
- * Someone with the right expertise should rewrite it
- * Some pointers:
- * http://www.cs.indiana.edu/~burger/FP-Printing-PLDI96.pdf
- * http://lxr.mozilla.org/mozilla/source/js/tamarin/core/MathUtils.cpp
- */
-const char *
-swfdec_as_double_to_string (SwfdecAsContext *context, double d)
-{
- gboolean found = FALSE, gotdot = FALSE;
- guint digits = 15;
- char tmp[50], *end, *start, *s;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), SWFDEC_AS_STR_EMPTY);
-
- if (isnan (d))
- return SWFDEC_AS_STR_NaN;
- if (isinf (d))
- return d < 0 ? SWFDEC_AS_STR__Infinity : SWFDEC_AS_STR_Infinity;
- /* stupid -0.0 */
- if (fabs (d) == 0.0)
- return SWFDEC_AS_STR_0;
-
- tmp[0] = ' ';
- s = &tmp[1];
- if (ABS (d) > 0.00001 && ABS (d) < 1e+15) {
- g_ascii_formatd (s, 50, "%.22f", d);
- } else {
- g_ascii_formatd (s, 50, "%.25e", d);
- }
- start = s;
- /* skip - sign */
- if (*start == '-')
- start++;
- /* count digits (maximum allowed is 15) */
- while (digits) {
- if (*start == '.') {
- start++;
- gotdot = TRUE;
- continue;
- }
- if (*start < '0' || *start > '9')
- break;
- if (found || *start != '0') {
- digits--;
- found = TRUE;
- }
- start++;
- }
- end = start;
- /* go to end of string */
- while (*end != 'e' && *end != 0)
- end++;
- /* round using the next digit */
- if (*start >= '5' && *start <= '9') {
- char *finish = NULL;
- /* skip all 9s at the end */
- while (start[-1] == '9')
- start--;
- /* if we're before the dot, replace 9s with 0s */
- if (start[-1] == '.') {
- finish = start;
- start--;
- }
- while (start[-1] == '9') {
- start[-1] = '0';
- start--;
- }
- /* write out correct number */
- if (start[-1] == '-') {
- s--;
- start[-2] = '-';
- start[-1] = '1';
- } else if (start[-1] == ' ') {
- s--;
- start[-1] = '1';
- } else {
- start[-1]++;
- }
- /* reposition cursor at end */
- if (finish)
- start = finish;
- }
- /* remove trailing zeros (note we skipped zero above, so there will be non-0 bytes left) */
- if (gotdot) {
- while (start[-1] == '0')
- start--;
- if (start[-1] == '.')
- start--;
- }
- /* add exponent */
- if (*end == 'e') {
- /* 'e' */
- *start++ = *end++;
- /* + or - */
- *start++ = *end++;
- /* skip 0s */
- while (*end == '0')
- end++;
- /* add rest */
- while (*end != 0)
- *start++ = *end++;
- }
- /* end string */
- *start = 0;
- return swfdec_as_context_get_string (context, s);
-}
-
-/**
- * swfdec_as_value_to_string:
- * @context: a #SwfdecAsContext
- * @value: value to be expressed as string
- *
- * Converts @value to a string according to the rules of Flash. This might
- * cause calling back into the script engine if the @value is an object. In
- * that case, the object's valueOf function is called.
- * <warning>Never use this function for debugging purposes.</warning>
- *
- * Returns: a garbage-collected string representing @value. The value will
- * never be %NULL.
- **/
-const char *
-swfdec_as_value_to_string (SwfdecAsContext *context, const SwfdecAsValue *value)
-{
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), SWFDEC_AS_STR_EMPTY);
- g_return_val_if_fail (SWFDEC_IS_AS_VALUE (value), SWFDEC_AS_STR_EMPTY);
-
- switch (value->type) {
- case SWFDEC_AS_TYPE_STRING:
- return SWFDEC_AS_VALUE_GET_STRING (value);
- case SWFDEC_AS_TYPE_UNDEFINED:
- if (context->version > 6)
- return SWFDEC_AS_STR_undefined;
- else
- return SWFDEC_AS_STR_EMPTY;
- case SWFDEC_AS_TYPE_BOOLEAN:
- return SWFDEC_AS_VALUE_GET_BOOLEAN (value) ? SWFDEC_AS_STR_true : SWFDEC_AS_STR_false;
- case SWFDEC_AS_TYPE_NULL:
- return SWFDEC_AS_STR_null;
- case SWFDEC_AS_TYPE_NUMBER:
- return swfdec_as_double_to_string (context, SWFDEC_AS_VALUE_GET_NUMBER (value));
- case SWFDEC_AS_TYPE_OBJECT:
- {
- SwfdecAsObject *object = SWFDEC_AS_VALUE_GET_OBJECT (value);
- if (SWFDEC_IS_MOVIE (object)) {
- SwfdecMovie *movie = swfdec_movie_resolve (SWFDEC_MOVIE (object));
- if (movie == NULL) {
- return SWFDEC_AS_STR_EMPTY;
- } else {
- char *str = swfdec_movie_get_path (SWFDEC_MOVIE (object), TRUE);
- return swfdec_as_context_give_string (context, str);
- }
- } else {
- SwfdecAsValue ret;
- swfdec_as_object_call (object, SWFDEC_AS_STR_toString, 0, NULL, &ret);
- if (SWFDEC_AS_VALUE_IS_STRING (&ret))
- return SWFDEC_AS_VALUE_GET_STRING (&ret);
- else if (SWFDEC_IS_AS_SUPER (SWFDEC_AS_VALUE_GET_OBJECT (value)))
- return SWFDEC_AS_STR__type_Object_;
- else if (SWFDEC_IS_AS_FUNCTION (SWFDEC_AS_VALUE_GET_OBJECT (value)))
- return SWFDEC_AS_STR__type_Function_;
- else
- return SWFDEC_AS_STR__type_Object_;
- }
- }
- case SWFDEC_AS_TYPE_INT:
- default:
- g_assert_not_reached ();
- return SWFDEC_AS_STR_EMPTY;
- }
-}
-
-/**
- * swfdec_as_value_to_debug:
- * @value: a #SwfdecAsValue
- *
- * Converts the given @value to a string in a safe way. It will not call into
- * the scripting engine. Its intended use is for output in debuggers.
- *
- * Returns: a newly allocated string. Free with g_free().
- **/
-char *
-swfdec_as_value_to_debug (const SwfdecAsValue *value)
-{
- g_return_val_if_fail (SWFDEC_IS_AS_VALUE (value), NULL);
-
- switch (value->type) {
- case SWFDEC_AS_TYPE_STRING:
- return g_shell_quote (SWFDEC_AS_VALUE_GET_STRING (value));
- case SWFDEC_AS_TYPE_UNDEFINED:
- return g_strdup ("undefined");
- case SWFDEC_AS_TYPE_BOOLEAN:
- return g_strdup (SWFDEC_AS_VALUE_GET_BOOLEAN (value) ? "true" : "false");
- case SWFDEC_AS_TYPE_NULL:
- return g_strdup ("null");
- case SWFDEC_AS_TYPE_NUMBER:
- return g_strdup_printf ("%g", SWFDEC_AS_VALUE_GET_NUMBER (value));
- case SWFDEC_AS_TYPE_OBJECT:
- return swfdec_as_object_get_debug (SWFDEC_AS_VALUE_GET_OBJECT (value));
- case SWFDEC_AS_TYPE_INT:
- default:
- g_assert_not_reached ();
- return NULL;
- }
-}
-
-/**
- * swfdec_as_value_to_number:
- * @context: a #SwfdecAsContext
- * @value: a #SwfdecAsValue used by context
- *
- * Converts the value to a number according to Flash's conversion routines and
- * the current Flash version. This conversion routine is similar, but not equal
- * to ECMAScript. For objects, it can call back into the script engine by
- * calling the object's valueOf function.
- *
- * Returns: a double value. It can be NaN or +-Infinity. It will not be -0.0.
- **/
-double
-swfdec_as_value_to_number (SwfdecAsContext *context, const SwfdecAsValue *value)
-{
- SwfdecAsValue tmp;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), 0.0);
- g_return_val_if_fail (SWFDEC_IS_AS_VALUE (value), 0.0);
-
- tmp = *value;
- swfdec_as_value_to_primitive (&tmp);
-
- switch (tmp.type) {
- case SWFDEC_AS_TYPE_UNDEFINED:
- case SWFDEC_AS_TYPE_NULL:
- return (context->version >= 7) ? NAN : 0.0;
- case SWFDEC_AS_TYPE_BOOLEAN:
- return SWFDEC_AS_VALUE_GET_BOOLEAN (&tmp) ? 1 : 0;
- case SWFDEC_AS_TYPE_NUMBER:
- return SWFDEC_AS_VALUE_GET_NUMBER (&tmp);
- case SWFDEC_AS_TYPE_STRING:
- {
- const char *s;
- char *end;
- double d;
-
- // FIXME: We should most likely copy Tamarin's code here (MathUtils.cpp)
- s = SWFDEC_AS_VALUE_GET_STRING (&tmp);
- if (s == SWFDEC_AS_STR_EMPTY)
- return NAN;
- if (context->version > 5 && s[0] == '0' &&
- (s[1] == 'x' || s[1] == 'X')) {
- d = g_ascii_strtoll (s + 2, &end, 16);
- } else if (context->version > 5 && s[0] == '0' &&
- s[strspn (s, "01234567")] == '\0') {
- d = g_ascii_strtoll (s, &end, 8);
- } else {
- if (strpbrk (s, "xXiI") != NULL)
- return NAN;
- d = g_ascii_strtod (s, &end);
- }
- if (*end == '\0')
- return d == -0.0 ? 0.0 : d;
- else
- return NAN;
- }
- case SWFDEC_AS_TYPE_OBJECT:
- return NAN;
- case SWFDEC_AS_TYPE_INT:
- default:
- g_assert_not_reached ();
- return NAN;
- }
-}
-
-/**
- * swfdec_as_double_to_integer:
- * @d: any double
- *
- * Converts the given double to an integer using the same rules as the Flash
- * player.
- *
- * Returns: an integer
- **/
-int
-swfdec_as_double_to_integer (double d)
-{
- if (!isfinite (d))
- return 0;
- if (d < 0) {
- d = fmod (-d, 4294967296.0);
- return - (guint) d;
- } else {
- d = fmod (d, 4294967296.0);
- return (guint) d;
- }
-}
-
-/**
- * swfdec_as_value_to_integer:
- * @context: a #SwfdecAsContext
- * @value: value to convert
- *
- * Converts the given value to an integer. This is done similar to the
- * conversion used by swfdec_as_value_to_number().
- *
- * Returns: An Integer that can be represented in 32 bits.
- **/
-int
-swfdec_as_value_to_integer (SwfdecAsContext *context, const SwfdecAsValue *value)
-{
- double d;
-
- d = swfdec_as_value_to_number (context, value);
- return swfdec_as_double_to_integer (d);
-}
-
-/**
- * swfdec_as_value_to_object:
- * @context: a #SwfdecAsContext
- * @value: value to convert
- *
- * Converts a given value to its representation as an object. The object
- * representation for primitive types is a wrapper object of the corresponding
- * class (Number for numbers, String for strings, Boolean for bools). If the
- * value does not have an object representing it, such as undefined and null
- * values, %NULL is returned.
- *
- * Returns: object representing @value or %NULL.
- **/
-SwfdecAsObject *
-swfdec_as_value_to_object (SwfdecAsContext *context, const SwfdecAsValue *value)
-{
- SwfdecAsFunction *fun;
- SwfdecAsValue val;
- const char *s;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
- g_return_val_if_fail (SWFDEC_IS_AS_VALUE (value), NULL);
-
- switch (value->type) {
- case SWFDEC_AS_TYPE_UNDEFINED:
- case SWFDEC_AS_TYPE_NULL:
- return NULL;
- case SWFDEC_AS_TYPE_NUMBER:
- s = SWFDEC_AS_STR_Number;
- break;
- case SWFDEC_AS_TYPE_STRING:
- s = SWFDEC_AS_STR_String;
- break;
- case SWFDEC_AS_TYPE_BOOLEAN:
- s = SWFDEC_AS_STR_Boolean;
- break;
- case SWFDEC_AS_TYPE_OBJECT:
- return SWFDEC_AS_VALUE_GET_OBJECT (value);
- case SWFDEC_AS_TYPE_INT:
- default:
- g_assert_not_reached ();
- return NULL;
- }
-
- swfdec_as_object_get_variable (context->global, s, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val) ||
- !SWFDEC_IS_AS_FUNCTION (fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&val)))
- return NULL;
- swfdec_as_object_create (fun, 1, value, &val);
- swfdec_as_context_run (context);
- if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
- return SWFDEC_AS_VALUE_GET_OBJECT (&val);
- } else {
- SWFDEC_ERROR ("did not construct an object");
- return NULL;
- }
-}
-
-/**
-* swfdec_as_value_to_boolean:
-* @context: a #SwfdecAsContext
-* @value: value to convert
-*
-* Converts the given value to a boolean according to Flash's rules. Note that
-* these rules changed significantly for strings between Flash 6 and 7.
-*
-* Returns: either %TRUE or %FALSE.
-**/
-gboolean
-swfdec_as_value_to_boolean (SwfdecAsContext *context, const SwfdecAsValue *value)
-{
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), FALSE);
- g_return_val_if_fail (SWFDEC_IS_AS_VALUE (value), FALSE);
-
- /* FIXME: what do we do when called in flash 4? */
- switch (value->type) {
- case SWFDEC_AS_TYPE_UNDEFINED:
- case SWFDEC_AS_TYPE_NULL:
- return FALSE;
- case SWFDEC_AS_TYPE_BOOLEAN:
- return SWFDEC_AS_VALUE_GET_BOOLEAN (value);
- case SWFDEC_AS_TYPE_NUMBER:
- {
- double d = SWFDEC_AS_VALUE_GET_NUMBER (value);
- return d != 0.0 && !isnan (d);
- }
- case SWFDEC_AS_TYPE_STRING:
- if (context->version <= 6) {
- double d = swfdec_as_value_to_number (context, value);
- return d != 0.0 && !isnan (d);
- } else {
- return SWFDEC_AS_VALUE_GET_STRING (value) != SWFDEC_AS_STR_EMPTY;
- }
- case SWFDEC_AS_TYPE_OBJECT:
- return TRUE;
- case SWFDEC_AS_TYPE_INT:
- default:
- g_assert_not_reached ();
- return FALSE;
- }
-}
-
-/**
-* swfdec_as_value_to_primitive:
-* @value: value to convert
-*
-* Tries to convert the given @value inline to its primitive value. Primitive
-* values are values that are not objects. If the value is an object, the
-* object's valueOf function is called. If the result of that function is still
-* an object, it is returned nonetheless.
-**/
-void
-swfdec_as_value_to_primitive (SwfdecAsValue *value)
-{
- g_return_if_fail (SWFDEC_IS_AS_VALUE (value));
-
- if (SWFDEC_AS_VALUE_IS_OBJECT (value) && !SWFDEC_IS_MOVIE (SWFDEC_AS_VALUE_GET_OBJECT (value))) {
- swfdec_as_object_call (SWFDEC_AS_VALUE_GET_OBJECT (value), SWFDEC_AS_STR_valueOf,
- 0, NULL, value);
- }
-}
-
diff --git a/libswfdec/swfdec_as_types.h b/libswfdec/swfdec_as_types.h
deleted file mode 100644
index ff22c8f..0000000
--- a/libswfdec/swfdec_as_types.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AS_TYPES_H_
-#define _SWFDEC_AS_TYPES_H_
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-/* fundamental types */
-typedef enum {
- SWFDEC_AS_TYPE_UNDEFINED = 0,
- SWFDEC_AS_TYPE_BOOLEAN,
- SWFDEC_AS_TYPE_INT, /* unimplemented, but reserved if someone wants it */
- SWFDEC_AS_TYPE_NUMBER,
- SWFDEC_AS_TYPE_STRING,
- SWFDEC_AS_TYPE_NULL,
- SWFDEC_AS_TYPE_OBJECT
-} SwfdecAsValueType;
-
-typedef struct _SwfdecAsArray SwfdecAsArray;
-typedef struct _SwfdecAsContext SwfdecAsContext;
-typedef struct _SwfdecAsDebugger SwfdecAsDebugger;
-typedef struct _SwfdecAsFrame SwfdecAsFrame;
-typedef struct _SwfdecAsFunction SwfdecAsFunction;
-typedef struct _SwfdecAsObject SwfdecAsObject;
-typedef struct _SwfdecAsScope SwfdecAsScope;
-typedef struct _SwfdecAsStack SwfdecAsStack;
-typedef struct _SwfdecAsValue SwfdecAsValue;
-typedef void (* SwfdecAsNative) (SwfdecAsContext * context,
- SwfdecAsObject * thisp,
- guint argc,
- SwfdecAsValue * argv,
- SwfdecAsValue * retval);
-typedef struct _SwfdecScript SwfdecScript;
-
-
-/* IMPORTANT: a SwfdecAsValue memset to 0 is a valid undefined value */
-struct _SwfdecAsValue {
- SwfdecAsValueType type;
- /*< private >*/
- union {
- gboolean boolean;
- double number;
- const char * string;
- SwfdecAsObject * object;
- } value;
-};
-
-#define SWFDEC_IS_AS_VALUE(val) ((val) != NULL && (val)->type <= SWFDEC_TYPE_AS_OBJECT)
-
-#define SWFDEC_AS_VALUE_IS_UNDEFINED(val) ((val)->type == SWFDEC_AS_TYPE_UNDEFINED)
-#define SWFDEC_AS_VALUE_SET_UNDEFINED(val) (val)->type = SWFDEC_AS_TYPE_UNDEFINED
-
-#define SWFDEC_AS_VALUE_IS_BOOLEAN(val) ((val)->type == SWFDEC_AS_TYPE_BOOLEAN)
-#define SWFDEC_AS_VALUE_GET_BOOLEAN(val) ((val)->value.boolean)
-#define SWFDEC_AS_VALUE_SET_BOOLEAN(val,b) G_STMT_START { \
- SwfdecAsValue *__val = (val); \
- gboolean __tmp = (b); \
- g_assert (__tmp == TRUE || __tmp == FALSE); \
- (__val)->value.boolean = __tmp; \
- (__val)->type = SWFDEC_AS_TYPE_BOOLEAN; \
-} G_STMT_END
-
-#define SWFDEC_AS_VALUE_IS_NUMBER(val) ((val)->type == SWFDEC_AS_TYPE_NUMBER)
-#define SWFDEC_AS_VALUE_GET_NUMBER(val) ((val)->value.number)
-#define SWFDEC_AS_VALUE_SET_NUMBER(val,d) G_STMT_START { \
- SwfdecAsValue *__val = (val); \
- (__val)->value.number = (d); \
- (__val)->type = SWFDEC_AS_TYPE_NUMBER; \
-} G_STMT_END
-
-#define SWFDEC_AS_VALUE_SET_INT(val,d) SWFDEC_AS_VALUE_SET_NUMBER(val,(int) (d))
-
-#define SWFDEC_AS_VALUE_IS_STRING(val) ((val)->type == SWFDEC_AS_TYPE_STRING)
-#define SWFDEC_AS_VALUE_GET_STRING(val) ((val)->value.string)
-#define SWFDEC_AS_VALUE_SET_STRING(val,s) G_STMT_START { \
- SwfdecAsValue *__val = (val); \
- (__val)->value.string = s; \
- (__val)->type = SWFDEC_AS_TYPE_STRING; \
-} G_STMT_END
-
-#define SWFDEC_AS_VALUE_IS_NULL(val) ((val)->type == SWFDEC_AS_TYPE_NULL)
-#define SWFDEC_AS_VALUE_SET_NULL(val) (val)->type = SWFDEC_AS_TYPE_NULL
-
-#define SWFDEC_AS_VALUE_IS_OBJECT(val) ((val)->type == SWFDEC_AS_TYPE_OBJECT)
-#define SWFDEC_AS_VALUE_GET_OBJECT(val) ((val)->value.object)
-#define SWFDEC_AS_VALUE_SET_OBJECT(val,o) G_STMT_START { \
- SwfdecAsValue *__val = (val); \
- SwfdecAsObject *__o = (o); \
- g_assert (__o != NULL); \
- (__val)->type = SWFDEC_AS_TYPE_OBJECT; \
- (__val)->value.object = __o; \
-} G_STMT_END
-
-/* value conversion functions */
-gboolean swfdec_as_value_to_boolean (SwfdecAsContext * context,
- const SwfdecAsValue * value);
-int swfdec_as_value_to_integer (SwfdecAsContext * context,
- const SwfdecAsValue * value);
-double swfdec_as_value_to_number (SwfdecAsContext * context,
- const SwfdecAsValue * value);
-SwfdecAsObject *swfdec_as_value_to_object (SwfdecAsContext * context,
- const SwfdecAsValue * value);
-void swfdec_as_value_to_primitive (SwfdecAsValue * value);
-const char * swfdec_as_value_to_string (SwfdecAsContext * context,
- const SwfdecAsValue * value);
-char * swfdec_as_value_to_debug (const SwfdecAsValue * value);
-
-/* special conversion functions */
-const char * swfdec_as_integer_to_string (SwfdecAsContext * context,
- int i);
-int swfdec_as_double_to_integer (double d);
-const char * swfdec_as_double_to_string (SwfdecAsContext * context,
- double d);
-const char * swfdec_as_str_concat (SwfdecAsContext * cx,
- const char * s1,
- const char * s2);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_asbroadcaster.c b/libswfdec/swfdec_asbroadcaster.c
deleted file mode 100644
index f15b828..0000000
--- a/libswfdec/swfdec_asbroadcaster.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_as_object.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_frame_internal.h"
-#include "swfdec_debug.h"
-
-/*** AS CODE ***/
-
-SWFDEC_AS_NATIVE (101, 12, broadcastMessage)
-void
-broadcastMessage (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecAsValue val;
- SwfdecAsObject *listeners, *o;
- gint i, length;
- const char *name;
- GSList *list = NULL, *walk;
-
- if (object == NULL)
- return;
-
- if (argc < 1)
- return;
- name = swfdec_as_value_to_string (cx, &argv[0]);
- argv += 1;
- argc--;
-
- swfdec_as_object_get_variable (object, SWFDEC_AS_STR__listeners, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return;
-
- listeners = SWFDEC_AS_VALUE_GET_OBJECT (&val);
- swfdec_as_object_get_variable (listeners, SWFDEC_AS_STR_length, &val);
- length = swfdec_as_value_to_integer (cx, &val);
-
- /* return undefined if we won't try to call anything */
- if (length <= 0)
- return;
-
- /* FIXME: solve this wth foreach, so it gets faster for weird cases */
- for (i = 0; i < length; i++) {
- swfdec_as_object_get_variable (listeners, swfdec_as_integer_to_string (cx, i), &val);
- o = swfdec_as_value_to_object (cx, &val);
- if (o == NULL)
- continue;
- list = g_slist_prepend (list, o);
- }
- if (list == NULL)
- return;
-
- list = g_slist_reverse (list);
- for (walk = list; walk; walk = walk->next) {
- swfdec_as_object_call (walk->data, name, argc, argv, &val);
- }
- g_slist_free (list);
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, TRUE);
-}
-
diff --git a/libswfdec/swfdec_audio.c b/libswfdec/swfdec_audio.c
deleted file mode 100644
index e9a5e5f..0000000
--- a/libswfdec/swfdec_audio.c
+++ /dev/null
@@ -1,346 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include "swfdec_audio_internal.h"
-#include "swfdec_debug.h"
-#include "swfdec_player_internal.h"
-
-/**
- * SECTION:SwfdecAudio
- * @title: SwfdecAudio
- * @see_also: SwfdecPlayer
- * @short_description: object used for audio output
- *
- * SwfdecAudio is the way audio output is provided by a #SwfdecPlayer. See
- * its documentation on how to access #SwfdecAudio objects.
- *
- * An audio object gives access to one audio stream played inside a player.
- * You are responsible for outputting this data, swfdec does not try to do this
- * for you.
- *
- * Audio data is always provided in 16bit host-endian stereo. If the data was
- * encoded into a different format originally, Swfdec will already have decoded
- * it. The data is always referenced relative to the player. Sample 0
- * references the first sample to be played at the current position. If the
- * player gets iterated, sample 0 changes. There is no way to access samples
- * belonging to a previous state.
- */
-
-/**
- * SwfdecAudio
- *
- * This object is used for audio output. It is an abstract class.
- */
-
-G_DEFINE_ABSTRACT_TYPE (SwfdecAudio, swfdec_audio, G_TYPE_OBJECT)
-
-static void
-swfdec_audio_dispose (GObject *object)
-{
- SwfdecAudio *audio = SWFDEC_AUDIO (object);
-
- g_assert (audio->player == NULL);
-
- G_OBJECT_CLASS (swfdec_audio_parent_class)->dispose (object);
-}
-
-static void
-swfdec_audio_class_init (SwfdecAudioClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->dispose = swfdec_audio_dispose;
-}
-
-static void
-swfdec_audio_init (SwfdecAudio *audio)
-{
-}
-
-/**
- * swfdec_audio_add:
- * @audio: audio to add
- * @player: a #SwfdecPlayer to attach to or NULL
- *
- * Registers a new audio object for playback in @player. If player is %NULL,
- * this function does nothing.
- * The starting point of the audio stream will be equivalent the player's time.
- **/
-void
-swfdec_audio_add (SwfdecAudio *audio, SwfdecPlayer *player)
-{
- SwfdecPlayerPrivate *priv;
-
- g_return_if_fail (SWFDEC_IS_AUDIO (audio));
- g_return_if_fail (audio->player == NULL);
- if (player == NULL)
- return;
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
-
- g_object_ref (audio);
- audio->player = player;
- priv = player->priv;
- priv->audio = g_list_append (priv->audio, audio);
- SWFDEC_INFO ("adding %s %p", G_OBJECT_TYPE_NAME (audio), audio);
-}
-
-void
-swfdec_audio_remove (SwfdecAudio *audio)
-{
- g_return_if_fail (SWFDEC_IS_AUDIO (audio));
-
- if (audio->player != NULL) {
- SwfdecPlayerPrivate *priv = audio->player->priv;
- SWFDEC_INFO ("removing %s %p", G_OBJECT_TYPE_NAME (audio), audio);
- priv->audio = g_list_remove (priv->audio, audio);
- if (audio->added) {
- g_signal_emit_by_name (audio->player, "audio-removed", audio);
- audio->added = FALSE;
- }
- audio->player = NULL;
- g_object_unref (audio);
- }
-}
-
-/**
- * swfdec_audio_iterate:
- * @audio: the #SwfdecAudio to iterate
- * @n_samples: number of samples to remove
- *
- * Iterates the @audio. Iterating means discarding the first @n_samples
- * samples of the audio stream.
- *
- * Returns: maximum number of remaining frames. If G_MAXUINT is returned,
- * then the number of frames isn't known yet.
- **/
-guint
-swfdec_audio_iterate (SwfdecAudio *audio, guint n_samples)
-{
- SwfdecAudioClass *klass;
-
- g_return_val_if_fail (SWFDEC_IS_AUDIO (audio), 0);
- g_return_val_if_fail (n_samples > 0, 0);
-
- klass = SWFDEC_AUDIO_GET_CLASS (audio);
- g_assert (klass->iterate);
- return klass->iterate (audio, n_samples);
-}
-
-/**
- * swfdec_audio_render:
- * @audio: a #SwfdecAudio
- * @dest: memory area to render to
- * @start_offset: offset in samples at which to start rendering. The offset is
- * calculated relative to the last iteration, so the value set
- * by swfdec_player_set_audio_advance() is ignored.
- * @n_samples: amount of samples to render.
- *
- * Renders the samples from @audio into the area pointed to by @dest. The data
- * is added to @dest, so you probably want to initialize @dest to silence
- * before calling this function.
- **/
-void
-swfdec_audio_render (SwfdecAudio *audio, gint16 *dest,
- guint start_offset, guint n_samples)
-{
- SwfdecAudioClass *klass;
-
- g_return_if_fail (SWFDEC_IS_AUDIO (audio));
- g_return_if_fail (dest != NULL);
- g_return_if_fail (n_samples > 0);
-
- klass = SWFDEC_AUDIO_GET_CLASS (audio);
- klass->render (audio, dest, start_offset, n_samples);
-}
-
-/**
- * swfdec_player_render_audio:
- * @player: a #SwfdecPlayer
- * @dest: location to add audio signal to. The audio signal will be in
- * 44100kHz signed 16bit stereo.
- * @start_offset: offset in samples at which to start rendering. The offset is
- * calculated relative to the last iteration, so the value set
- * by swfdec_player_set_audio_advance() is ignored.
- * @n_samples: amount of samples to render.
- *
- * Renders the data for this frame into the given location. The data is added to @dest,
- * so you probably want to initialize @dest to silence before calling this function.
- **/
-void
-swfdec_player_render_audio (SwfdecPlayer *player, gint16* dest,
- guint start_offset, guint n_samples)
-{
- GList *walk;
- SwfdecAudio *audio;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (dest != NULL);
- g_return_if_fail (n_samples > 0);
-
- SWFDEC_LOG ("rendering offset %u, samples %u", start_offset, n_samples);
- for (walk = player->priv->audio; walk; walk = walk->next) {
- audio = walk->data;
- swfdec_audio_render (audio, dest, start_offset, n_samples);
- }
-}
-
-/*** SWFDEC_AUDIO_FORMAT ***/
-
-/* SwfdecAudioFormat is represented in the least significant bits of a uint:
- * - the LSBit is 1 if it's 16bit audio, 0 for 8bit
- * - the next bit is 1 for stereo, 0 for mono
- * - the other two bits are for the rate, see swfdec_audio_format_new()
- * This is the same format the Flash file format uses to store audio formats.
- */
-
-SwfdecAudioFormat
-swfdec_audio_format_parse (SwfdecBits *bits)
-{
- g_return_val_if_fail (bits != NULL, 0);
-
- return swfdec_bits_getbits (bits, 4);
-}
-
-SwfdecAudioFormat
-swfdec_audio_format_new (guint rate, guint channels, gboolean is_16bit)
-{
- SwfdecAudioFormat ret;
-
- g_return_val_if_fail (channels == 1 || channels == 2, 0);
-
- switch (rate) {
- case 44100:
- ret = 3 << 2;
- break;
- case 22050:
- ret = 2 << 2;
- break;
- case 11025:
- ret = 1 << 2;
- break;
- case 5512:
- ret = 0 << 2;
- break;
- default:
- g_return_val_if_reached (0);
- break;
- }
- if (is_16bit)
- ret |= 2;
- if (channels == 2)
- ret |= 1;
-
- return ret;
-}
-
-guint
-swfdec_audio_format_get_channels (SwfdecAudioFormat format)
-{
- g_return_val_if_fail (SWFDEC_IS_AUDIO_FORMAT (format), 2);
-
- return (format & 0x1) + 1;
-}
-
-gboolean
-swfdec_audio_format_is_16bit (SwfdecAudioFormat format)
-{
- g_return_val_if_fail (SWFDEC_IS_AUDIO_FORMAT (format), TRUE);
-
- return format & 0x2 ? TRUE : FALSE;
-}
-
-guint
-swfdec_audio_format_get_rate (SwfdecAudioFormat format)
-{
- g_return_val_if_fail (SWFDEC_IS_AUDIO_FORMAT (format), 44100);
-
- return 44100 / swfdec_audio_format_get_granularity (format);
-}
-
-/**
- * swfdec_audio_format_get_granularity:
- * @format: an auio format
- *
- * The granularity is a Swfdec-specific name, describing how often a sample in
- * a 44100Hz audio stream is defined. So for example 44100Hz has a granularity
- * of 1 and 11025Hz has a granularity of 4 (because only every fourth sample
- * is defined).
- *
- * Returns: the granularity of the format
- **/
-guint
-swfdec_audio_format_get_granularity (SwfdecAudioFormat format)
-{
- g_return_val_if_fail (SWFDEC_IS_AUDIO_FORMAT (format), 1);
-
- return 1 << (3 - (format >> 2));
-}
-
-const char *
-swfdec_audio_format_to_string (SwfdecAudioFormat format)
-{
- static const char *names[] = {
- "8bit 5.5kHz mono",
- "8bit 5.5kHz stereo",
- "16bit 5.5kHz mono",
- "16bit 5.5kHz stereo",
- "8bit 11kHz mono",
- "8bit 11kHz stereo",
- "16bit 11kHz mono",
- "16bit 11kHz stereo",
- "8bit 22kHz mono",
- "8bit 22kHz stereo",
- "16bit 22kHz mono",
- "16bit 22kHz stereo",
- "8bit 44kHz mono",
- "8bit 44kHz stereo",
- "16bit 44kHz mono",
- "16bit 44kHz stereo"
- };
- g_return_val_if_fail (SWFDEC_IS_AUDIO_FORMAT (format), "");
-
- return names[format];
-}
-
-/**
- * swfdec_audio_format_get_bytes_per_sample:
- * @format: audio format to check
- *
- * Computes the number of bytes required to store one sample of audio encoded
- * in @format.
- *
- * Returns: The number of bytes for one sample
- **/
-guint
-swfdec_audio_format_get_bytes_per_sample (SwfdecAudioFormat format)
-{
- guint bps[4] = { 1, 2, 2, 4 };
-
- g_return_val_if_fail (SWFDEC_IS_AUDIO_FORMAT (format), 1);
-
- return bps [format & 0x3];
-}
-
diff --git a/libswfdec/swfdec_audio.h b/libswfdec/swfdec_audio.h
deleted file mode 100644
index 4352faf..0000000
--- a/libswfdec/swfdec_audio.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AUDIO_H_
-#define _SWFDEC_AUDIO_H_
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecAudio SwfdecAudio;
-typedef struct _SwfdecAudioClass SwfdecAudioClass;
-
-#define SWFDEC_TYPE_AUDIO (swfdec_audio_get_type())
-#define SWFDEC_IS_AUDIO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AUDIO))
-#define SWFDEC_IS_AUDIO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AUDIO))
-#define SWFDEC_AUDIO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AUDIO, SwfdecAudio))
-#define SWFDEC_AUDIO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AUDIO, SwfdecAudioClass))
-#define SWFDEC_AUDIO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AUDIO, SwfdecAudioClass))
-
-GType swfdec_audio_get_type (void);
-
-void swfdec_audio_render (SwfdecAudio * audio,
- gint16 * dest,
- guint start_offset,
- guint n_samples);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_audio_event.c b/libswfdec/swfdec_audio_event.c
deleted file mode 100644
index fa43359..0000000
--- a/libswfdec/swfdec_audio_event.c
+++ /dev/null
@@ -1,330 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include "swfdec_audio_event.h"
-#include "swfdec_debug.h"
-#include "swfdec_player_internal.h"
-
-
-G_DEFINE_TYPE (SwfdecAudioEvent, swfdec_audio_event, SWFDEC_TYPE_AUDIO)
-
-
-static guint
-swfdec_audio_event_iterate (SwfdecAudio *audio, guint remove)
-{
- SwfdecAudioEvent *event = SWFDEC_AUDIO_EVENT (audio);
-
- if (event->n_samples == 0)
- return 0;
-
- event->offset += remove;
- event->loop += event->offset / event->n_samples;
- event->offset %= event->n_samples;
-
- if (event->loop < event->n_loops)
- return event->n_samples * (event->n_loops - event->loop) - event->offset;
- else
- return 0;
-}
-
-static guint16
-swfdec_audio_event_get_envelop_volume (SwfdecAudioEvent *event, guint pos,
- guint offset, guint channel)
-{
- double distance;
-
- g_return_val_if_fail (SWFDEC_IS_AUDIO_EVENT (event), 32768);
- g_return_val_if_fail (pos <= event->n_envelopes, 32768);
- g_return_val_if_fail (channel == 0 || channel == 1, 32768);
-
- if (event->n_envelopes == 0)
- return 32768;
-
- if (pos == 0)
- return event->envelope[pos].volume[channel];
-
- if (pos == event->n_envelopes)
- return event->envelope[pos - 1].volume[channel];
-
- distance = event->envelope[pos].offset - event->envelope[pos - 1].offset;
- g_return_val_if_fail (offset >= event->envelope[pos - 1].offset, 1);
- offset -= event->envelope[pos - 1].offset;
- g_return_val_if_fail (offset < distance, 1);
-
- return event->envelope[pos - 1].volume[channel] * (1 - offset / distance) +
- event->envelope[pos].volume[channel] * (offset / distance);
-}
-
-static void
-swfdec_audio_event_render (SwfdecAudio *audio, gint16* dest, guint start,
- guint n_samples)
-{
- SwfdecAudioEvent *event = SWFDEC_AUDIO_EVENT (audio);
- guint offset = event->offset + start;
- guint loop, samples, global_offset, pos, i, granularity, channels;
- gint16 *dest_end;
-
- if (event->n_samples == 0)
- return;
-
- granularity = swfdec_audio_format_get_granularity (event->decoded_format);
- channels = swfdec_audio_format_get_channels (event->decoded_format);
-
- global_offset = (channels - 1) * granularity * (event->loop *
- ((event->stop_sample != 0 ? event->stop_sample : event->n_samples) -
- event->start_sample) + event->offset - event->start_sample);
-
- dest_end = dest;
- loop = event->loop + offset / event->n_samples;
- offset %= event->n_samples;
- for (; loop < event->n_loops && n_samples > 0; loop++) {
- samples = MIN (n_samples, event->n_samples - offset);
- swfdec_sound_buffer_render (dest_end, event->decoded,
- event->decoded_format, loop == 0 ? NULL : event->decoded, offset,
- samples);
- n_samples -= samples;
- dest_end += samples * 2;
- offset = 0;
- }
-
- if (event->n_envelopes == 0)
- return;
-
- pos = 0;
- for (i = 0; i < (guint) (dest_end - dest); i++) {
- while (pos < event->n_envelopes &&
- event->envelope[pos].offset <= global_offset + (i / 2))
- pos++;
- if (channels == 1) {
- dest[i] *= (swfdec_audio_event_get_envelop_volume (event, pos,
- global_offset + (i / 2), 0) * 0.5 +
- swfdec_audio_event_get_envelop_volume (event, pos,
- global_offset + (i / 2), 1) * 0.5) / 32768.0;
- } else {
- dest[i] *= swfdec_audio_event_get_envelop_volume (event, pos,
- global_offset + (i / 2), i % 2) / 32768.0;
- }
- }
-}
-
-static void
-swfdec_audio_event_dispose (GObject *object)
-{
- SwfdecAudioEvent *audio = SWFDEC_AUDIO_EVENT (object);
-
- g_free (audio->envelope);
- audio->envelope = NULL;
- audio->n_envelopes = 0;
- if (audio->decoded) {
- swfdec_buffer_unref (audio->decoded);
- audio->decoded = NULL;
- }
-
- G_OBJECT_CLASS (swfdec_audio_event_parent_class)->dispose (object);
-}
-
-static void
-swfdec_audio_event_class_init (SwfdecAudioEventClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- SwfdecAudioClass *audio_class = SWFDEC_AUDIO_CLASS (klass);
-
- object_class->dispose = swfdec_audio_event_dispose;
-
- audio_class->iterate = swfdec_audio_event_iterate;
- audio_class->render = swfdec_audio_event_render;
-}
-
-static void
-swfdec_audio_event_init (SwfdecAudioEvent *audio_event)
-{
-}
-
-static void
-swfdec_audio_event_decode (SwfdecAudioEvent *event)
-{
- guint granule, bytes_per_sample;
-
- event->decoded = swfdec_sound_get_decoded (event->sound,
- &event->decoded_format);
- if (event->decoded == NULL) {
- SWFDEC_INFO ("Could not decode audio. Will assume %u samples of silence instead.",
- event->sound->n_samples);
- event->decoded = swfdec_buffer_new_and_alloc0 (event->sound->n_samples / 4);
- event->decoded_format = swfdec_audio_format_new (5512, 1, FALSE);
- } else {
- swfdec_buffer_ref (event->decoded);
- }
- granule = swfdec_audio_format_get_granularity (event->decoded_format);
- bytes_per_sample = swfdec_audio_format_get_channels (event->decoded_format) *
- (swfdec_audio_format_is_16bit (event->decoded_format) ? 2 : 1);
- if (event->start_sample) {
- guint skip;
- if (event->start_sample % granule) {
- SWFDEC_FIXME ("figure out how high resolution start samples work");
- }
- skip = bytes_per_sample * (event->start_sample / granule);
- if (skip >= event->decoded->length) {
- SWFDEC_WARNING ("start sample %u > total number of samples %"G_GSIZE_FORMAT,
- event->start_sample / granule, event->decoded->length / bytes_per_sample);
- swfdec_buffer_unref (event->decoded);
- event->decoded = swfdec_buffer_new ();
- } else {
- SwfdecBuffer *sub = swfdec_buffer_new_subbuffer (event->decoded,
- skip, event->decoded->length - skip);
- swfdec_buffer_unref (event->decoded);
- event->decoded = sub;
- }
- }
- if (event->stop_sample) {
- guint keep;
- if (event->stop_sample % granule) {
- SWFDEC_FIXME ("figure out how high resolution stop samples work");
- }
- keep = bytes_per_sample * (event->stop_sample / granule - event->start_sample / granule);
- if (keep > event->decoded->length) {
- SWFDEC_WARNING ("stop sample %u outside of decoded number of samples %"G_GSIZE_FORMAT,
- event->stop_sample / granule, event->decoded->length / bytes_per_sample +
- event->start_sample / granule);
- } else if (keep < event->decoded->length) {
- SwfdecBuffer *sub = swfdec_buffer_new_subbuffer (event->decoded,
- 0, keep);
- swfdec_buffer_unref (event->decoded);
- event->decoded = sub;
- }
- }
- event->n_samples = event->decoded->length / bytes_per_sample * granule;
- SWFDEC_LOG ("total 44100Hz samples: %u", event->n_samples);
-}
-
-static SwfdecAudioEvent *
-swfdec_audio_event_create (SwfdecSound *sound, guint offset, guint end_offset, guint n_loops)
-{
- SwfdecAudioEvent *event;
-
- event = g_object_new (SWFDEC_TYPE_AUDIO_EVENT, NULL);
- event->sound = sound;
- event->start_sample = offset;
- event->n_loops = n_loops;
- event->stop_sample = end_offset;
- swfdec_audio_event_decode (event);
- event->offset = 0;
-
- return event;
-}
-
-/**
- * swfdec_audio_event_new:
- * @player: the #SwfdecPlayer to play the sound in
- * @sound: the sound to be played
- * @offset: offset into sound at which to start playing
- * @n_loops: number of times the sound should be played
- *
- * Starts playing back a sound from the given offset and loops the sound
- * @n_loops times.
- *
- * Returns: a new #SwfdecAudio
- **/
-SwfdecAudio *
-swfdec_audio_event_new (SwfdecPlayer *player, SwfdecSound *sound, guint offset,
- guint n_loops)
-{
- SwfdecAudioEvent *event;
-
- g_return_val_if_fail (player == NULL || SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (SWFDEC_IS_SOUND (sound), NULL);
-
- event = swfdec_audio_event_create (sound, offset, 0, n_loops);
- swfdec_audio_add (SWFDEC_AUDIO (event), player);
-
- return SWFDEC_AUDIO (event);
-}
-
-static SwfdecAudio *
-swfdec_audio_event_get (SwfdecPlayer *player, SwfdecSound *sound)
-{
- GList *walk;
-
- if (player == NULL)
- return NULL;
-
- for (walk = player->priv->audio; walk; walk = walk->next) {
- SwfdecAudio *audio = walk->data;
- if (!SWFDEC_IS_AUDIO_EVENT (audio))
- continue;
- if (SWFDEC_AUDIO_EVENT (audio)->sound == sound) {
- return audio;
- }
- }
- return NULL;
-}
-
-/**
- * swfdec_audio_event_new_from_chunk:
- * @player: a #SwfdecPlayer or NULL
- * @event: a sound event to start playing back
- *
- * Starts playback of the given sound event (or, when @player is NULL, creates
- * an element for playing back the given sound).
- *
- * Returns: the sound effect or NULL if no new sound was created.
- **/
-SwfdecAudio *
-swfdec_audio_event_new_from_chunk (SwfdecPlayer *player, SwfdecSoundChunk *chunk)
-{
- SwfdecAudioEvent *event;
-
- g_return_val_if_fail (player == NULL || SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (chunk != NULL, NULL);
-
- if (chunk->stop) {
- SwfdecAudio *audio = swfdec_audio_event_get (player, chunk->sound);
- if (audio) {
- SWFDEC_LOG ("stopping sound %d", SWFDEC_CHARACTER (chunk->sound)->id);
- swfdec_audio_remove (audio);
- }
- return NULL;
- }
- SWFDEC_LOG ("adding sound %d to playing sounds", SWFDEC_CHARACTER (chunk->sound)->id);
- if (chunk->no_restart &&
- (event = (SwfdecAudioEvent *) swfdec_audio_event_get (player, chunk->sound))) {
- SWFDEC_DEBUG ("sound %d is already playing, reusing it",
- SWFDEC_CHARACTER (event->sound)->id);
- g_object_ref (event);
- return SWFDEC_AUDIO (event);
- }
- event = swfdec_audio_event_create (chunk->sound, chunk->start_sample,
- chunk->stop_sample, chunk->loop_count);
- event->n_envelopes = chunk->n_envelopes;
- if (event->n_envelopes)
- event->envelope = g_memdup (chunk->envelope, sizeof (SwfdecSoundEnvelope) * event->n_envelopes);
- SWFDEC_DEBUG ("playing sound %d from offset %d now", SWFDEC_CHARACTER (event->sound)->id,
- event->start_sample);
- swfdec_audio_add (SWFDEC_AUDIO (event), player);
-
- return SWFDEC_AUDIO (event);
-}
-
diff --git a/libswfdec/swfdec_audio_event.h b/libswfdec/swfdec_audio_event.h
deleted file mode 100644
index 40a0eb6..0000000
--- a/libswfdec/swfdec_audio_event.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AUDIO_EVENT_H_
-#define _SWFDEC_AUDIO_EVENT_H_
-
-#include <libswfdec/swfdec_audio_internal.h>
-#include <libswfdec/swfdec_sound.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecAudioEvent SwfdecAudioEvent;
-typedef struct _SwfdecAudioEventClass SwfdecAudioEventClass;
-
-#define SWFDEC_TYPE_AUDIO_EVENT (swfdec_audio_event_get_type())
-#define SWFDEC_IS_AUDIO_EVENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AUDIO_EVENT))
-#define SWFDEC_IS_AUDIO_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AUDIO_EVENT))
-#define SWFDEC_AUDIO_EVENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AUDIO_EVENT, SwfdecAudioEvent))
-#define SWFDEC_AUDIO_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AUDIO_EVENT, SwfdecAudioEventClass))
-#define SWFDEC_AUDIO_EVENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AUDIO_EVENT, SwfdecAudioEventClass))
-
-struct _SwfdecAudioEvent
-{
- SwfdecAudio audio;
-
- /* static data */
- SwfdecSound * sound; /* sound we're playing */
- guint start_sample; /* sample at which to start playing */
- guint stop_sample; /* first sample to not play anymore or 0 for playing all */
- guint n_loops; /* amount of times this sample still needs to be played back */
- guint n_envelopes; /* amount of points in the envelope */
- SwfdecSoundEnvelope * envelope; /* volume envelope or NULL if none */
- /* dynamic data */
- SwfdecBuffer * decoded; /* the decoded buffer we play back */
- SwfdecAudioFormat decoded_format; /* format of the decoded buffer */
- guint offset; /* current offset in 44.1kHz */
- guint loop; /* current loop we're in */
- guint n_samples; /* length of decoded buffer in 44.1kHz samples - can be 0 */
-};
-
-struct _SwfdecAudioEventClass
-{
- SwfdecAudioClass audio_class;
-};
-
-GType swfdec_audio_event_get_type (void);
-
-SwfdecAudio * swfdec_audio_event_new (SwfdecPlayer * player,
- SwfdecSound * sound,
- guint offset,
- guint n_loops);
-SwfdecAudio * swfdec_audio_event_new_from_chunk (SwfdecPlayer * player,
- SwfdecSoundChunk * chunk);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_audio_flv.c b/libswfdec/swfdec_audio_flv.c
deleted file mode 100644
index 59de5c5..0000000
--- a/libswfdec/swfdec_audio_flv.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include "swfdec_audio_flv.h"
-#include "swfdec_debug.h"
-#include "swfdec_sound.h"
-
-
-G_DEFINE_TYPE (SwfdecAudioFlv, swfdec_audio_flv, SWFDEC_TYPE_AUDIO)
-
-static void
-swfdec_audio_flv_dispose (GObject *object)
-{
- SwfdecAudioFlv *flv = SWFDEC_AUDIO_FLV (object);
-
- if (flv->decoder != NULL) {
- swfdec_audio_decoder_free (flv->decoder);
- flv->decoder = NULL;
- }
- g_queue_foreach (flv->playback_queue, (GFunc) swfdec_buffer_unref, NULL);
- g_queue_free (flv->playback_queue);
- g_object_unref (flv->flvdecoder);
-
- G_OBJECT_CLASS (swfdec_audio_flv_parent_class)->dispose (object);
-}
-
-static SwfdecBuffer *
-swfdec_audio_flv_decode_one (SwfdecAudioFlv *flv)
-{
- SwfdecBuffer *buffer;
- guint format;
- SwfdecAudioFormat in;
- guint now, soon;
-
- if (g_queue_is_empty (flv->playback_queue)) {
- /* sync */
- guint last;
- swfdec_flv_decoder_get_audio (flv->flvdecoder,
- SWFDEC_TICKS_TO_MSECS (flv->timestamp),
- NULL, NULL, &last, NULL);
- flv->playback_skip = SWFDEC_TICKS_TO_SAMPLES (
- flv->timestamp - SWFDEC_MSECS_TO_TICKS (last));
- flv->next_timestamp = last;
- SWFDEC_DEBUG ("syncing to %ums: next timestamp to decode is %ums, skipping %u samples",
- (guint) SWFDEC_TICKS_TO_MSECS (flv->timestamp),
- flv->next_timestamp, flv->playback_skip);
- }
- if (flv->decoder)
- buffer = swfdec_audio_decoder_pull (flv->decoder);
- else
- buffer = NULL;
- while (buffer == NULL) {
- if (flv->decoder && flv->next_timestamp == 0)
- return NULL;
- buffer = swfdec_flv_decoder_get_audio (flv->flvdecoder, flv->next_timestamp,
- &format, &in, &now, &soon);
-
- if (flv->next_timestamp != now) {
- /* FIXME: do sync on first frame here */
- SWFDEC_WARNING ("FIXME: didn't get requested timestamp - still loading?");
- }
- /* FIXME FIXME FIXME: This avoids decoding the last frame forever, however it ensures sync */
- if (soon == 0)
- return NULL;
- flv->next_timestamp = soon;
- if (flv->in == 0) {
- /* init */
- if (flv->decoder) {
- swfdec_audio_decoder_free (flv->decoder);
- flv->decoder = NULL;
- }
- flv->format = format;
- flv->in = in;
- flv->decoder = swfdec_audio_decoder_new (flv->format, flv->in);
- if (flv->decoder == NULL)
- return NULL;
- } else if (format != flv->format ||
- in != flv->in) {
- SWFDEC_ERROR ("FIXME: format change not implemented");
- return NULL;
- } else if (flv->decoder == NULL) {
- return NULL;
- }
- swfdec_audio_decoder_push (flv->decoder, buffer);
- if (flv->next_timestamp == 0)
- swfdec_audio_decoder_push (flv->decoder, NULL);
- buffer = swfdec_audio_decoder_pull (flv->decoder);
- }
-
- g_queue_push_tail (flv->playback_queue, buffer);
- return buffer;
-}
-
-static void
-swfdec_audio_flv_render (SwfdecAudio *audio, gint16* dest,
- guint start, guint n_samples)
-{
- SwfdecAudioFlv *flv = SWFDEC_AUDIO_FLV (audio);
- GList *walk;
- guint samples;
- SwfdecBuffer *buffer, *previous;
-
- g_assert (start < G_MAXINT);
- start += flv->playback_skip;
- SWFDEC_LOG ("flv %p rendering offset %u, samples %u", flv, start, n_samples);
- walk = g_queue_peek_head_link (flv->playback_queue);
- previous = NULL;
- while (n_samples) {
- if (walk) {
- buffer = walk->data;
- walk = walk->next;
- } else {
- buffer = swfdec_audio_flv_decode_one (flv);
- if (!buffer)
- break;
- }
- samples = swfdec_sound_buffer_get_n_samples (buffer,
- swfdec_audio_decoder_get_format (flv->decoder));
- if (start) {
- if (samples <= start) {
- start -= samples;
- continue;
- }
- samples -= start;
- SWFDEC_LOG ("rendering %u samples, skipping %u",
- samples, start);
- } else {
- SWFDEC_LOG ("rendering %u samples", samples);
- }
- samples = MIN (samples, n_samples);
- swfdec_sound_buffer_render (dest, buffer,
- swfdec_audio_decoder_get_format (flv->decoder), previous, start,
- samples);
- start = 0;
- n_samples -= samples;
- dest += 2 * samples;
- previous = buffer;
- }
-}
-
-static guint
-swfdec_audio_flv_iterate (SwfdecAudio *audio, guint remove)
-{
- SwfdecAudioFlv *flv = SWFDEC_AUDIO_FLV (audio);
- SwfdecBuffer *buffer;
- guint next;
-
- flv->playback_skip += remove;
- buffer = g_queue_peek_head (flv->playback_queue);
- while (buffer && flv->playback_skip >=
- swfdec_sound_buffer_get_n_samples (buffer, swfdec_audio_decoder_get_format (flv->decoder))
- + swfdec_audio_format_get_granularity (swfdec_audio_decoder_get_format (flv->decoder))) {
- buffer = g_queue_pop_head (flv->playback_queue);
- SWFDEC_LOG ("removing buffer with %u samples",
- swfdec_sound_buffer_get_n_samples (buffer,
- swfdec_audio_decoder_get_format (flv->decoder)));
- flv->playback_skip -= swfdec_sound_buffer_get_n_samples (buffer,
- swfdec_audio_decoder_get_format (flv->decoder));
- swfdec_buffer_unref (buffer);
- buffer = g_queue_peek_head (flv->playback_queue);
- }
- flv->timestamp += SWFDEC_SAMPLES_TO_TICKS (remove);
-
- if (!g_queue_is_empty (flv->playback_queue))
- return G_MAXUINT;
- swfdec_flv_decoder_get_audio (flv->flvdecoder,
- SWFDEC_TICKS_TO_MSECS (flv->timestamp),
- NULL, NULL, NULL, &next);
- return next ? G_MAXUINT : 0;
-}
-
-static void
-swfdec_audio_flv_class_init (SwfdecAudioFlvClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- SwfdecAudioClass *audio_class = SWFDEC_AUDIO_CLASS (klass);
-
- object_class->dispose = swfdec_audio_flv_dispose;
-
- audio_class->iterate = swfdec_audio_flv_iterate;
- audio_class->render = swfdec_audio_flv_render;
-}
-
-static void
-swfdec_audio_flv_init (SwfdecAudioFlv *flv)
-{
- flv->playback_queue = g_queue_new ();
-}
-
-SwfdecAudio *
-swfdec_audio_flv_new (SwfdecPlayer *player, SwfdecFlvDecoder *decoder, guint timestamp)
-{
- SwfdecAudioFlv *flv;
-
- flv = g_object_new (SWFDEC_TYPE_AUDIO_FLV, NULL);
-
- SWFDEC_DEBUG ("new audio flv for decoder %p, starting at %ums",
- decoder, timestamp);
- g_object_ref (decoder);
- flv->flvdecoder = decoder;
- flv->timestamp = SWFDEC_MSECS_TO_TICKS (timestamp);
- swfdec_audio_add (SWFDEC_AUDIO (flv), player);
-
- return SWFDEC_AUDIO (flv);
-}
-
diff --git a/libswfdec/swfdec_audio_flv.h b/libswfdec/swfdec_audio_flv.h
deleted file mode 100644
index 52ac2a5..0000000
--- a/libswfdec/swfdec_audio_flv.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AUDIO_FLV_H_
-#define _SWFDEC_AUDIO_FLV_H_
-
-#include <libswfdec/swfdec_audio_internal.h>
-#include <libswfdec/swfdec_flv_decoder.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecAudioFlv SwfdecAudioFlv;
-typedef struct _SwfdecAudioFlvClass SwfdecAudioFlvClass;
-
-#define SWFDEC_TYPE_AUDIO_FLV (swfdec_audio_flv_get_type())
-#define SWFDEC_IS_AUDIO_FLV(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AUDIO_FLV))
-#define SWFDEC_IS_AUDIO_FLV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AUDIO_FLV))
-#define SWFDEC_AUDIO_FLV(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AUDIO_FLV, SwfdecAudioFlv))
-#define SWFDEC_AUDIO_FLV_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AUDIO_FLV, SwfdecAudioFlvClass))
-#define SWFDEC_AUDIO_FLV_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AUDIO_FLV, SwfdecAudioFlvClass))
-
-struct _SwfdecAudioFlv
-{
- SwfdecAudio audio;
-
- SwfdecFlvDecoder * flvdecoder; /* decoder we play back */
- guint format; /* codec format of audio */
- gboolean width; /* width of audio */
- SwfdecAudioFormat in; /* input format of data */
- SwfdecAudioDecoder * decoder; /* decoder used for playback */
-
- SwfdecTick timestamp; /* current playback timestamp */
- guint next_timestamp; /* next timestamp in FLV file we request from */
- guint playback_skip; /* number of samples to skip at start of queue */
- GQueue * playback_queue; /* all the samples we've decoded so far */
-};
-
-struct _SwfdecAudioFlvClass
-{
- SwfdecAudioClass audio_class;
-};
-
-GType swfdec_audio_flv_get_type (void);
-
-SwfdecAudio * swfdec_audio_flv_new (SwfdecPlayer * player,
- SwfdecFlvDecoder * decoder,
- guint timestamp);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_audio_internal.h b/libswfdec/swfdec_audio_internal.h
deleted file mode 100644
index 512f6e7..0000000
--- a/libswfdec/swfdec_audio_internal.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AUDIO_INTERNAL_H_
-#define _SWFDEC_AUDIO_INTERNAL_H_
-
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_audio.h>
-#include <libswfdec/swfdec_bits.h>
-#include <libswfdec/swfdec_types.h>
-
-G_BEGIN_DECLS
-
-typedef guint SwfdecAudioFormat;
-#define SWFDEC_IS_AUDIO_FORMAT(format) ((format) <= 0xF)
-#define SWFDEC_AUDIO_FORMAT_INVALID ((SwfdecAudioFormat) -1)
-
-
-struct _SwfdecAudio {
- GObject object;
-
- SwfdecPlayer * player; /* the player that plays us */
- gboolean added; /* set to TRUE after the added signal has been emitted */
-};
-
-struct _SwfdecAudioClass {
- GObjectClass object_class;
-
- guint (* iterate) (SwfdecAudio * audio,
- guint n_samples);
- void (* render) (SwfdecAudio * audio,
- gint16 * dest,
- guint start,
- guint n_samples);
-};
-
-void swfdec_audio_add (SwfdecAudio * audio,
- SwfdecPlayer * player);
-void swfdec_audio_remove (SwfdecAudio * audio);
-
-guint swfdec_audio_iterate (SwfdecAudio * audio,
- guint n_samples);
-
-SwfdecAudioFormat swfdec_audio_format_parse (SwfdecBits * bits);
-SwfdecAudioFormat swfdec_audio_format_new (guint rate,
- guint channels,
- gboolean is_16bit);
-guint swfdec_audio_format_get_channels(SwfdecAudioFormat format);
-gboolean swfdec_audio_format_is_16bit (SwfdecAudioFormat format);
-guint swfdec_audio_format_get_rate (SwfdecAudioFormat format);
-guint swfdec_audio_format_get_granularity
- (SwfdecAudioFormat format);
-guint swfdec_audio_format_get_bytes_per_sample
- (SwfdecAudioFormat format);
-const char * swfdec_audio_format_to_string (SwfdecAudioFormat format);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_audio_stream.c b/libswfdec/swfdec_audio_stream.c
deleted file mode 100644
index d4eb6ca..0000000
--- a/libswfdec/swfdec_audio_stream.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include "swfdec_audio_stream.h"
-#include "swfdec_debug.h"
-#include "swfdec_sound.h"
-#include "swfdec_sprite.h"
-
-
-G_DEFINE_TYPE (SwfdecAudioStream, swfdec_audio_stream, SWFDEC_TYPE_AUDIO)
-
-static void
-swfdec_audio_stream_dispose (GObject *object)
-{
- SwfdecAudioStream *stream = SWFDEC_AUDIO_STREAM (object);
-
- if (stream->decoder != NULL) {
- swfdec_audio_decoder_free (stream->decoder);
- stream->decoder = NULL;
- }
- g_queue_foreach (stream->playback_queue, (GFunc) swfdec_buffer_unref, NULL);
- g_queue_free (stream->playback_queue);
-
- G_OBJECT_CLASS (swfdec_audio_stream_parent_class)->dispose (object);
-}
-
-static SwfdecBuffer *
-swfdec_audio_stream_decode_one (SwfdecAudioStream *stream)
-{
- SwfdecSpriteFrame *frame;
- SwfdecBuffer *buffer;
-
- g_assert (!stream->done);
- if (stream->decoder == NULL)
- return NULL;
-
- while (!(buffer = swfdec_audio_decoder_pull (stream->decoder)) &&
- !stream->done) {
- if (stream->current_frame >= stream->sprite->n_frames)
- goto end;
- frame = &stream->sprite->frames[stream->current_frame];
- stream->current_frame++;
- if (frame->sound_head != stream->sound)
- goto end;
- if (frame->sound_samples == 0)
- continue;
- if (frame->sound_block)
- swfdec_audio_decoder_push (stream->decoder, frame->sound_block);
- continue;
-end:
- swfdec_audio_decoder_push (stream->decoder, NULL);
- stream->done = TRUE;
- }
- return buffer;
-}
-
-static void
-swfdec_audio_stream_render (SwfdecAudio *audio, gint16* dest,
- guint start, guint n_samples)
-{
- SwfdecAudioStream *stream = SWFDEC_AUDIO_STREAM (audio);
- GList *walk;
- guint samples;
- SwfdecBuffer *buffer, *previous;
-
- g_assert (start < G_MAXINT);
- start += stream->playback_skip;
- SWFDEC_LOG ("stream %p rendering offset %u, samples %u", stream, start, n_samples);
- walk = g_queue_peek_head_link (stream->playback_queue);
- previous = NULL;
- while (n_samples) {
- if (walk) {
- buffer = walk->data;
- walk = walk->next;
- } else {
- if (stream->done)
- break;
- buffer = swfdec_audio_stream_decode_one (stream);
- if (!buffer)
- break;
- g_queue_push_tail (stream->playback_queue, buffer);
- }
- samples = swfdec_sound_buffer_get_n_samples (buffer,
- swfdec_audio_decoder_get_format (stream->decoder));
- if (start) {
- if (samples <= start) {
- start -= samples;
- continue;
- }
- samples -= start;
- SWFDEC_LOG ("rendering %u samples, skipping %u",
- samples, start);
- } else {
- SWFDEC_LOG ("rendering %u samples", samples);
- }
- samples = MIN (samples, n_samples);
- swfdec_sound_buffer_render (dest, buffer,
- swfdec_audio_decoder_get_format (stream->decoder),
- previous, start, samples);
- start = 0;
- n_samples -= samples;
- dest += 2 * samples;
- previous = buffer;
- }
-}
-
-static guint
-swfdec_audio_stream_iterate (SwfdecAudio *audio, guint remove)
-{
- SwfdecAudioStream *stream = SWFDEC_AUDIO_STREAM (audio);
- SwfdecBuffer *buffer;
-
- stream->playback_skip += remove;
- buffer = g_queue_peek_head (stream->playback_queue);
- while (buffer && stream->playback_skip >=
- swfdec_sound_buffer_get_n_samples (buffer, swfdec_audio_decoder_get_format (stream->decoder))
- + swfdec_audio_format_get_granularity (swfdec_audio_decoder_get_format (stream->decoder))) {
- buffer = g_queue_pop_head (stream->playback_queue);
- SWFDEC_LOG ("removing buffer with %u samples",
- swfdec_sound_buffer_get_n_samples (buffer,
- swfdec_audio_decoder_get_format (stream->decoder)));
- stream->playback_skip -= swfdec_sound_buffer_get_n_samples (buffer,
- swfdec_audio_decoder_get_format (stream->decoder));
- swfdec_buffer_unref (buffer);
- buffer = g_queue_peek_head (stream->playback_queue);
- }
-
- if (!stream->done) {
- return G_MAXUINT;
- } else {
- GList *walk;
- guint ret = 0;
- SwfdecAudioFormat format = swfdec_audio_decoder_get_format (stream->decoder);
-
- for (walk = g_queue_peek_head_link (stream->playback_queue); walk; walk = walk->next) {
- ret += swfdec_sound_buffer_get_n_samples (walk->data, format);
- }
- return ret - stream->playback_skip;
- }
-}
-
-static void
-swfdec_audio_stream_class_init (SwfdecAudioStreamClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- SwfdecAudioClass *audio_class = SWFDEC_AUDIO_CLASS (klass);
-
- object_class->dispose = swfdec_audio_stream_dispose;
-
- audio_class->iterate = swfdec_audio_stream_iterate;
- audio_class->render = swfdec_audio_stream_render;
-}
-
-static void
-swfdec_audio_stream_init (SwfdecAudioStream *stream)
-{
- stream->playback_queue = g_queue_new ();
-}
-
-SwfdecAudio *
-swfdec_audio_stream_new (SwfdecPlayer *player, SwfdecSprite *sprite, guint start_frame)
-{
- SwfdecAudioStream *stream;
- SwfdecSpriteFrame *frame;
-
- stream = g_object_new (SWFDEC_TYPE_AUDIO_STREAM, NULL);
-
- SWFDEC_DEBUG ("new audio stream for sprite %d, starting at %u",
- SWFDEC_CHARACTER (sprite)->id, start_frame);
- stream->sprite = sprite;
- frame = &sprite->frames[start_frame];
- g_assert (frame->sound_head);
- stream->sound = frame->sound_head;
- stream->playback_skip = frame->sound_skip;
- stream->current_frame = start_frame;
- stream->decoder = swfdec_audio_decoder_new (stream->sound->codec,
- stream->sound->format);
- swfdec_audio_add (SWFDEC_AUDIO (stream), player);
-
- return SWFDEC_AUDIO (stream);
-}
-
diff --git a/libswfdec/swfdec_audio_stream.h b/libswfdec/swfdec_audio_stream.h
deleted file mode 100644
index 306c9c8..0000000
--- a/libswfdec/swfdec_audio_stream.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_AUDIO_STREAM_H_
-#define _SWFDEC_AUDIO_STREAM_H_
-
-#include <libswfdec/swfdec_audio_internal.h>
-#include <libswfdec/swfdec_codec_audio.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecAudioStream SwfdecAudioStream;
-typedef struct _SwfdecAudioStreamClass SwfdecAudioStreamClass;
-
-#define SWFDEC_TYPE_AUDIO_STREAM (swfdec_audio_stream_get_type())
-#define SWFDEC_IS_AUDIO_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AUDIO_STREAM))
-#define SWFDEC_IS_AUDIO_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AUDIO_STREAM))
-#define SWFDEC_AUDIO_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AUDIO_STREAM, SwfdecAudioStream))
-#define SWFDEC_AUDIO_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AUDIO_STREAM, SwfdecAudioStreamClass))
-#define SWFDEC_AUDIO_STREAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AUDIO_STREAM, SwfdecAudioStreamClass))
-
-struct _SwfdecAudioStream
-{
- SwfdecAudio audio;
-
- SwfdecSprite * sprite; /* sprite we're playing back */
- SwfdecSound * sound; /* sound we're playing */
- SwfdecAudioDecoder * decoder; /* decoder used for this frame */
- guint playback_skip; /* number of samples to skip at the beginning of queue */
- GQueue * playback_queue; /* all the samples we've decoded so far */
- guint current_frame; /* last decoded frame */
- gboolean done; /* TRUE when no new data will be made available */
-};
-
-struct _SwfdecAudioStreamClass
-{
- SwfdecAudioClass audio_class;
-};
-
-GType swfdec_audio_stream_get_type (void);
-
-SwfdecAudio * swfdec_audio_stream_new (SwfdecPlayer * player,
- SwfdecSprite * sprite,
- guint start_frame);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_bevel_filter.c b/libswfdec/swfdec_bevel_filter.c
deleted file mode 100644
index 4e6c4f7..0000000
--- a/libswfdec/swfdec_bevel_filter.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (1107, 1, swfdec_bevel_filter_get_distance)
-void
-swfdec_bevel_filter_get_distance (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.distance (get)");
-}
-
-SWFDEC_AS_NATIVE (1107, 2, swfdec_bevel_filter_set_distance)
-void
-swfdec_bevel_filter_set_distance (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.distance (set)");
-}
-
-SWFDEC_AS_NATIVE (1107, 3, swfdec_bevel_filter_get_angle)
-void
-swfdec_bevel_filter_get_angle (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.angle (get)");
-}
-
-SWFDEC_AS_NATIVE (1107, 4, swfdec_bevel_filter_set_angle)
-void
-swfdec_bevel_filter_set_angle (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.angle (set)");
-}
-
-SWFDEC_AS_NATIVE (1107, 5, swfdec_bevel_filter_get_highlightColor)
-void
-swfdec_bevel_filter_get_highlightColor (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.highlightColor (get)");
-}
-
-SWFDEC_AS_NATIVE (1107, 6, swfdec_bevel_filter_set_highlightColor)
-void
-swfdec_bevel_filter_set_highlightColor (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.highlightColor (set)");
-}
-
-SWFDEC_AS_NATIVE (1107, 7, swfdec_bevel_filter_get_highlightAlpha)
-void
-swfdec_bevel_filter_get_highlightAlpha (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.highlightAlpha (get)");
-}
-
-SWFDEC_AS_NATIVE (1107, 8, swfdec_bevel_filter_set_highlightAlpha)
-void
-swfdec_bevel_filter_set_highlightAlpha (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.highlightAlpha (set)");
-}
-
-SWFDEC_AS_NATIVE (1107, 9, swfdec_bevel_filter_get_shadowColor)
-void
-swfdec_bevel_filter_get_shadowColor (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.shadowColor (get)");
-}
-
-SWFDEC_AS_NATIVE (1107, 10, swfdec_bevel_filter_set_shadowColor)
-void
-swfdec_bevel_filter_set_shadowColor (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.shadowColor (set)");
-}
-
-SWFDEC_AS_NATIVE (1107, 11, swfdec_bevel_filter_get_shadowAlpha)
-void
-swfdec_bevel_filter_get_shadowAlpha (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.shadowAlpha (get)");
-}
-
-SWFDEC_AS_NATIVE (1107, 12, swfdec_bevel_filter_set_shadowAlpha)
-void
-swfdec_bevel_filter_set_shadowAlpha (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.shadowAlpha (set)");
-}
-
-SWFDEC_AS_NATIVE (1107, 13, swfdec_bevel_filter_get_quality)
-void
-swfdec_bevel_filter_get_quality (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.quality (get)");
-}
-
-SWFDEC_AS_NATIVE (1107, 14, swfdec_bevel_filter_set_quality)
-void
-swfdec_bevel_filter_set_quality (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.quality (set)");
-}
-
-SWFDEC_AS_NATIVE (1107, 15, swfdec_bevel_filter_get_strength)
-void
-swfdec_bevel_filter_get_strength (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.strength (get)");
-}
-
-SWFDEC_AS_NATIVE (1107, 16, swfdec_bevel_filter_set_strength)
-void
-swfdec_bevel_filter_set_strength (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.strength (set)");
-}
-
-SWFDEC_AS_NATIVE (1107, 17, swfdec_bevel_filter_get_knockout)
-void
-swfdec_bevel_filter_get_knockout (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.knockout (get)");
-}
-
-SWFDEC_AS_NATIVE (1107, 18, swfdec_bevel_filter_set_knockout)
-void
-swfdec_bevel_filter_set_knockout (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.knockout (set)");
-}
-
-SWFDEC_AS_NATIVE (1107, 19, swfdec_bevel_filter_get_blurX)
-void
-swfdec_bevel_filter_get_blurX (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.blurX (get)");
-}
-
-SWFDEC_AS_NATIVE (1107, 20, swfdec_bevel_filter_set_blurX)
-void
-swfdec_bevel_filter_set_blurX (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.blurX (set)");
-}
-
-SWFDEC_AS_NATIVE (1107, 21, swfdec_bevel_filter_get_blurY)
-void
-swfdec_bevel_filter_get_blurY (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.blurY (get)");
-}
-
-SWFDEC_AS_NATIVE (1107, 22, swfdec_bevel_filter_set_blurY)
-void
-swfdec_bevel_filter_set_blurY (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.blurY (set)");
-}
-
-SWFDEC_AS_NATIVE (1107, 23, swfdec_bevel_filter_get_type)
-void
-swfdec_bevel_filter_get_type (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.type (get)");
-}
-
-SWFDEC_AS_NATIVE (1107, 24, swfdec_bevel_filter_set_type)
-void
-swfdec_bevel_filter_set_type (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter.type (set)");
-}
-
-// constructor
-SWFDEC_AS_NATIVE (1107, 0, swfdec_bevel_filter_construct)
-void
-swfdec_bevel_filter_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BevelFilter");
-}
diff --git a/libswfdec/swfdec_bitmap_data.c b/libswfdec/swfdec_bitmap_data.c
deleted file mode 100644
index 4686140..0000000
--- a/libswfdec/swfdec_bitmap_data.c
+++ /dev/null
@@ -1,306 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-// static
-SWFDEC_AS_NATIVE (1100, 40, swfdec_bitmap_data_loadBitmap)
-void
-swfdec_bitmap_data_loadBitmap (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.loadBitmap (static)");
-}
-
-// properties
-SWFDEC_AS_NATIVE (1100, 100, swfdec_bitmap_data_get_width)
-void
-swfdec_bitmap_data_get_width (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.width (get)");
-}
-
-SWFDEC_AS_NATIVE (1100, 101, swfdec_bitmap_data_set_width)
-void
-swfdec_bitmap_data_set_width (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.width (set)");
-}
-
-SWFDEC_AS_NATIVE (1100, 102, swfdec_bitmap_data_get_height)
-void
-swfdec_bitmap_data_get_height (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.height (get)");
-}
-
-SWFDEC_AS_NATIVE (1100, 103, swfdec_bitmap_data_set_height)
-void
-swfdec_bitmap_data_set_height (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.height (set)");
-}
-
-SWFDEC_AS_NATIVE (1100, 104, swfdec_bitmap_data_get_rectangle)
-void
-swfdec_bitmap_data_get_rectangle (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.rectangle (get)");
-}
-
-SWFDEC_AS_NATIVE (1100, 105, swfdec_bitmap_data_set_rectangle)
-void
-swfdec_bitmap_data_set_rectangle (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.rectangle (set)");
-}
-
-SWFDEC_AS_NATIVE (1100, 106, swfdec_bitmap_data_get_transparent)
-void
-swfdec_bitmap_data_get_transparent (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.transparent (get)");
-}
-
-SWFDEC_AS_NATIVE (1100, 107, swfdec_bitmap_data_set_transparent)
-void
-swfdec_bitmap_data_set_transparent (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.transparent (set)");
-}
-
-// normal
-SWFDEC_AS_NATIVE (1100, 1, swfdec_bitmap_data_getPixel)
-void
-swfdec_bitmap_data_getPixel (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.getPixel");
-}
-
-SWFDEC_AS_NATIVE (1100, 2, swfdec_bitmap_data_setPixel)
-void
-swfdec_bitmap_data_setPixel (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.setPixel");
-}
-
-SWFDEC_AS_NATIVE (1100, 3, swfdec_bitmap_data_fillRect)
-void
-swfdec_bitmap_data_fillRect (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.fillRect");
-}
-
-SWFDEC_AS_NATIVE (1100, 4, swfdec_bitmap_data_copyPixels)
-void
-swfdec_bitmap_data_copyPixels (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.copyPixels");
-}
-
-SWFDEC_AS_NATIVE (1100, 5, swfdec_bitmap_data_applyFilter)
-void
-swfdec_bitmap_data_applyFilter (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.applyFilter");
-}
-
-SWFDEC_AS_NATIVE (1100, 6, swfdec_bitmap_data_scroll)
-void
-swfdec_bitmap_data_scroll (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.scroll");
-}
-
-SWFDEC_AS_NATIVE (1100, 7, swfdec_bitmap_data_threshold)
-void
-swfdec_bitmap_data_threshold (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.threshold");
-}
-
-SWFDEC_AS_NATIVE (1100, 8, swfdec_bitmap_data_draw)
-void
-swfdec_bitmap_data_draw (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.draw");
-}
-
-SWFDEC_AS_NATIVE (1100, 9, swfdec_bitmap_data_pixelDissolve)
-void
-swfdec_bitmap_data_pixelDissolve (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.pixelDissolve");
-}
-
-SWFDEC_AS_NATIVE (1100, 10, swfdec_bitmap_data_getPixel32)
-void
-swfdec_bitmap_data_getPixel32 (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.getPixel32");
-}
-
-SWFDEC_AS_NATIVE (1100, 11, swfdec_bitmap_data_setPixel32)
-void
-swfdec_bitmap_data_setPixel32 (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.setPixel32");
-}
-
-SWFDEC_AS_NATIVE (1100, 12, swfdec_bitmap_data_floodFill)
-void
-swfdec_bitmap_data_floodFill (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.floodFill");
-}
-
-SWFDEC_AS_NATIVE (1100, 13, swfdec_bitmap_data_getColorBoundsRect)
-void
-swfdec_bitmap_data_getColorBoundsRect (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.getColorBoundsRect");
-}
-
-SWFDEC_AS_NATIVE (1100, 14, swfdec_bitmap_data_perlinNoise)
-void
-swfdec_bitmap_data_perlinNoise (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.perlinNoise");
-}
-
-SWFDEC_AS_NATIVE (1100, 15, swfdec_bitmap_data_colorTransform)
-void
-swfdec_bitmap_data_colorTransform (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.colorTransform");
-}
-
-SWFDEC_AS_NATIVE (1100, 16, swfdec_bitmap_data_hitTest)
-void
-swfdec_bitmap_data_hitTest (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.hitTest");
-}
-
-SWFDEC_AS_NATIVE (1100, 17, swfdec_bitmap_data_paletteMap)
-void
-swfdec_bitmap_data_paletteMap (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.paletteMap");
-}
-
-SWFDEC_AS_NATIVE (1100, 18, swfdec_bitmap_data_merge)
-void
-swfdec_bitmap_data_merge (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.merge");
-}
-
-SWFDEC_AS_NATIVE (1100, 19, swfdec_bitmap_data_noise)
-void
-swfdec_bitmap_data_noise (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.noise");
-}
-
-SWFDEC_AS_NATIVE (1100, 20, swfdec_bitmap_data_copyChannel)
-void
-swfdec_bitmap_data_copyChannel (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.copyChannel");
-}
-
-SWFDEC_AS_NATIVE (1100, 21, swfdec_bitmap_data_clone)
-void
-swfdec_bitmap_data_clone (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.clone");
-}
-
-SWFDEC_AS_NATIVE (1100, 22, swfdec_bitmap_data_dispose)
-void
-swfdec_bitmap_data_dispose (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.dispose");
-}
-
-SWFDEC_AS_NATIVE (1100, 23, swfdec_bitmap_data_generateFilterRect)
-void
-swfdec_bitmap_data_generateFilterRect (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.generateFilterRect");
-}
-
-SWFDEC_AS_NATIVE (1100, 24, swfdec_bitmap_data_compare)
-void
-swfdec_bitmap_data_compare (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData.compare");
-}
-
-// constructor
-SWFDEC_AS_NATIVE (1100, 0, swfdec_bitmap_data_construct)
-void
-swfdec_bitmap_data_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapData");
-}
diff --git a/libswfdec/swfdec_bitmap_filter.c b/libswfdec/swfdec_bitmap_filter.c
deleted file mode 100644
index ae9af4c..0000000
--- a/libswfdec/swfdec_bitmap_filter.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (1112, 1, swfdec_bitmap_filter_getPixel)
-void
-swfdec_bitmap_filter_getPixel (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BitmapFilter.clone");
-}
-
-SWFDEC_AS_NATIVE (1112, 0, swfdec_bitmap_filter_construct)
-void
-swfdec_bitmap_filter_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- // FIXME: this is just commented out so that it won't always output warning
- // when running initialization scripts
- //SWFDEC_STUB ("BitmapFilter");
-}
diff --git a/libswfdec/swfdec_bits.c b/libswfdec/swfdec_bits.c
deleted file mode 100644
index 1cf166d..0000000
--- a/libswfdec/swfdec_bits.c
+++ /dev/null
@@ -1,760 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include <zlib.h>
-
-#include "swfdec_bits.h"
-#include "swfdec_color.h"
-#include "swfdec_debug.h"
-#include "swfdec_rect.h"
-
-
-#define SWFDEC_BITS_CHECK(b,n) G_STMT_START { \
- if (swfdec_bits_left(b) < (n)) { \
- SWFDEC_ERROR ("reading past end of buffer"); \
- b->ptr = b->end; \
- b->idx = 0; \
- return 0; \
- } \
-}G_STMT_END
-#define SWFDEC_BYTES_CHECK(b,n) G_STMT_START { \
- g_assert (b->end >= b->ptr); \
- g_assert (b->idx == 0); \
- if ((unsigned long) (b->end - b->ptr) < n) { \
- SWFDEC_ERROR ("reading past end of buffer"); \
- b->ptr = b->end; \
- b->idx = 0; \
- return 0; \
- } \
-} G_STMT_END
-
-/**
- * swfdec_bits_init:
- * @bits: a #SwfdecBits
- * @buffer: buffer to use for data or NULL
- *
- * initializes @bits for use with the data in @buffer. The buffer will not be
- * referenced, so you are responsible for keeping it around while @bits is used.
- **/
-void
-swfdec_bits_init (SwfdecBits *bits, SwfdecBuffer *buffer)
-{
- g_return_if_fail (bits != NULL);
-
- if (buffer) {
- bits->buffer = buffer;
- bits->ptr = buffer->data;
- bits->idx = 0;
- bits->end = buffer->data + buffer->length;
- } else {
- memset (bits, 0, sizeof (SwfdecBits));
- }
-}
-
-/**
- * swfdec_bits_init_bits:
- * @bits: a #SwfdecBits
- * @from: a #SwfdecBits to initialize from
- * @bytes: number of bytes to move to @bits
- *
- * Initializes @bits for use with the next @bytes bytes from @from. If not
- * enough bytes are available, less bytes will be available in @bits. @from
- * will skip the bytes now available in @bits. If you want to know if this
- * function moves enough bytes, you should ensure that enough data is
- * available using swfdec_bits_left() before calling this function.
- **/
-void
-swfdec_bits_init_bits (SwfdecBits *bits, SwfdecBits *from, guint bytes)
-{
- g_return_if_fail (bits != NULL);
- g_return_if_fail (from != NULL);
- g_return_if_fail (from->idx == 0);
-
- bits->buffer = from->buffer;
- bits->ptr = from->ptr;
- if (bytes > (guint) (from->end - from->ptr))
- bytes = from->end - from->ptr;
- bits->end = bits->ptr + bytes;
- bits->idx = 0;
- from->ptr = bits->end;
-}
-
-/**
- * swfdec_bits_init_data:
- * @bits: the #SwfdecBits to initialize
- * @data: data to initialize with
- * @len: length of the data
- *
- * Initializes @bits for use with the given @data. All operations on @bits will
- * return copies of the data, so after use, you can free the supplied data. Using
- * %NULL for @data is valid if @len is 0.
- **/
-void
-swfdec_bits_init_data (SwfdecBits *bits, const guint8 *data, guint len)
-{
- g_return_if_fail (bits != NULL);
- g_return_if_fail (data != NULL || len == 0);
-
- bits->buffer = NULL;
- bits->ptr = data;
- bits->idx = 0;
- bits->end = bits->ptr + len;
-}
-
-guint
-swfdec_bits_left (const SwfdecBits *b)
-{
- if (b->ptr == NULL)
- return 0;
- g_assert (b->end >= b->ptr);
- g_assert (b->end > b->ptr || b->idx == 0);
- return (b->end - b->ptr) * 8 - b->idx;
-}
-
-int
-swfdec_bits_getbit (SwfdecBits * b)
-{
- int r;
-
- SWFDEC_BITS_CHECK (b, 1);
-
- r = ((*b->ptr) >> (7 - b->idx)) & 1;
-
- b->idx++;
- if (b->idx >= 8) {
- b->ptr++;
- b->idx = 0;
- }
-
- return r;
-}
-
-guint
-swfdec_bits_getbits (SwfdecBits * b, guint n)
-{
- unsigned long r = 0;
- guint i;
-
- SWFDEC_BITS_CHECK (b, n);
-
- while (n > 0) {
- i = MIN (n, 8 - b->idx);
- r <<= i;
- r |= ((*b->ptr) >> (8 - i - b->idx)) & ((1 << i) - 1);
- n -= i;
- if (i == 8) {
- b->ptr++;
- } else {
- b->idx += i;
- if (b->idx >= 8) {
- b->ptr++;
- b->idx = 0;
- }
- }
- }
- return r;
-}
-
-guint
-swfdec_bits_peekbits (const SwfdecBits * b, guint n)
-{
- SwfdecBits tmp = *b;
-
- return swfdec_bits_getbits (&tmp, n);
-}
-
-int
-swfdec_bits_getsbits (SwfdecBits * b, guint n)
-{
- unsigned long r = 0;
-
- SWFDEC_BITS_CHECK (b, n);
-
- if (n == 0)
- return 0;
- r = -swfdec_bits_getbit (b);
- r = (r << (n - 1)) | swfdec_bits_getbits (b, n - 1);
- return r;
-}
-
-guint
-swfdec_bits_peek_u8 (const SwfdecBits * b)
-{
- g_assert (b->idx == 0);
- g_assert (b->ptr <= b->end);
- if (b->ptr == b->end)
- return 0;
-
- return *b->ptr;
-}
-
-guint
-swfdec_bits_get_u8 (SwfdecBits * b)
-{
- SWFDEC_BYTES_CHECK (b, 1);
-
- return *b->ptr++;
-}
-
-guint
-swfdec_bits_get_u16 (SwfdecBits * b)
-{
- guint r;
-
- SWFDEC_BYTES_CHECK (b, 2);
-
- r = b->ptr[0] | (b->ptr[1] << 8);
- b->ptr += 2;
-
- return r;
-}
-
-int
-swfdec_bits_get_s16 (SwfdecBits * b)
-{
- short r;
-
- SWFDEC_BYTES_CHECK (b, 2);
-
- r = b->ptr[0] | (b->ptr[1] << 8);
- b->ptr += 2;
-
- return r;
-}
-
-guint
-swfdec_bits_get_u32 (SwfdecBits * b)
-{
- guint r;
-
- SWFDEC_BYTES_CHECK (b, 4);
-
- r = b->ptr[0] | (b->ptr[1] << 8) | (b->ptr[2] << 16) | (b->ptr[3] << 24);
- b->ptr += 4;
-
- return r;
-}
-
-guint
-swfdec_bits_get_bu16 (SwfdecBits *b)
-{
- guint r;
-
- SWFDEC_BYTES_CHECK (b, 2);
-
- r = (b->ptr[0] << 8) | b->ptr[1];
- b->ptr += 2;
-
- return r;
-}
-
-guint
-swfdec_bits_get_bu24 (SwfdecBits *b)
-{
- guint r;
-
- SWFDEC_BYTES_CHECK (b, 3);
-
- r = (b->ptr[0] << 16) | (b->ptr[1] << 8) | b->ptr[2];
- b->ptr += 3;
-
- return r;
-}
-
-guint
-swfdec_bits_get_bu32 (SwfdecBits *b)
-{
- guint r;
-
- SWFDEC_BYTES_CHECK (b, 4);
-
- r = (b->ptr[0] << 24) | (b->ptr[1] << 16) | (b->ptr[2] << 8) | b->ptr[3];
- b->ptr += 4;
-
- return r;
-}
-
-float
-swfdec_bits_get_float (SwfdecBits * b)
-{
- union {
- gint32 i;
- float f;
- } conv;
-
- SWFDEC_BYTES_CHECK (b, 4);
-
- conv.i = (b->ptr[3] << 24) | (b->ptr[2] << 16) | (b->ptr[1] << 8) | b->ptr[0];
- b->ptr += 4;
-
- return conv.f;
-}
-
-/* fixup mad byte ordering of doubles in flash files.
- * If little endian x86 byte order is 0 1 2 3 4 5 6 7 and PPC32 byte order is
- * 7 6 5 4 3 2 1 0, then Flash uses 4 5 6 7 0 1 2 3.
- * If your architecture has a different byte ordering for storing doubles,
- * this conversion function will fail. To find out your byte ordering, you can
- * use this command line:
- * python -c "import struct; print struct.unpack('8c', struct.pack('d', 7.949928895127363e-275))"
- */
-double
-swfdec_bits_get_double (SwfdecBits * b)
-{
- union {
- guint32 i[2];
- double d;
- } conv;
-
- SWFDEC_BYTES_CHECK (b, 8);
-
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
- conv.i[1] = (b->ptr[3] << 24) | (b->ptr[2] << 16) | (b->ptr[1] << 8) | b->ptr[0];
- conv.i[0] = (b->ptr[7] << 24) | (b->ptr[6] << 16) | (b->ptr[5] << 8) | b->ptr[4];
-#else
- conv.i[0] = (b->ptr[3] << 24) | (b->ptr[2] << 16) | (b->ptr[1] << 8) | b->ptr[0];
- conv.i[1] = (b->ptr[7] << 24) | (b->ptr[6] << 16) | (b->ptr[5] << 8) | b->ptr[4];
-#if 0
- conv.i[0] = (b->ptr[0] << 24) | (b->ptr[1] << 16) | (b->ptr[2] << 8) | b->ptr[3];
- conv.i[1] = (b->ptr[4] << 24) | (b->ptr[5] << 16) | (b->ptr[6] << 8) | b->ptr[7];
-#endif
-#endif
- b->ptr += 8;
-
- return conv.d;
-}
-
-double
-swfdec_bits_get_bdouble (SwfdecBits * b)
-{
- double d;
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
- guint64 tmp;
- gpointer p;
-#endif
-
- SWFDEC_BYTES_CHECK (b, 8);
-
-#if G_BYTE_ORDER == G_BIG_ENDIAN
- memcpy (&d, b->ptr, 8);
-#elif G_BYTE_ORDER == G_LITTLE_ENDIAN
- memcpy (&tmp, b->ptr, 8);
- tmp = GUINT64_FROM_BE (tmp);
- p = &tmp;
- d = *((double *) p);
-#endif
- b->ptr += 8;
-
- return d;
-}
-
-void
-swfdec_bits_syncbits (SwfdecBits * b)
-{
- if (b->idx) {
- b->ptr++;
- b->idx = 0;
- }
-}
-
-void
-swfdec_bits_get_color_transform (SwfdecBits * bits, SwfdecColorTransform * ct)
-{
- int has_add;
- int has_mult;
- int n_bits;
-
- ct->mask = FALSE;
- has_add = swfdec_bits_getbit (bits);
- has_mult = swfdec_bits_getbit (bits);
- n_bits = swfdec_bits_getbits (bits, 4);
- if (has_mult) {
- ct->ra = swfdec_bits_getsbits (bits, n_bits);
- ct->ga = swfdec_bits_getsbits (bits, n_bits);
- ct->ba = swfdec_bits_getsbits (bits, n_bits);
- ct->aa = swfdec_bits_getsbits (bits, n_bits);
- } else {
- ct->ra = 256;
- ct->ga = 256;
- ct->ba = 256;
- ct->aa = 256;
- }
- if (has_add) {
- ct->rb = swfdec_bits_getsbits (bits, n_bits);
- ct->gb = swfdec_bits_getsbits (bits, n_bits);
- ct->bb = swfdec_bits_getsbits (bits, n_bits);
- ct->ab = swfdec_bits_getsbits (bits, n_bits);
- } else {
- ct->rb = 0;
- ct->gb = 0;
- ct->bb = 0;
- ct->ab = 0;
- }
- swfdec_bits_syncbits (bits);
-}
-
-void
-swfdec_bits_get_matrix (SwfdecBits * bits, cairo_matrix_t *matrix,
- cairo_matrix_t *inverse)
-{
- int has_scale;
- int has_rotate;
- int n_translate_bits;
-
- has_scale = swfdec_bits_getbit (bits);
- if (has_scale) {
- int n_scale_bits = swfdec_bits_getbits (bits, 5);
- matrix->xx = SWFDEC_FIXED_TO_DOUBLE (swfdec_bits_getsbits (bits, n_scale_bits));
- matrix->yy = SWFDEC_FIXED_TO_DOUBLE (swfdec_bits_getsbits (bits, n_scale_bits));
-
- SWFDEC_LOG ("scalefactors: x = %d/65536, y = %d/65536",
- SWFDEC_DOUBLE_TO_FIXED (matrix->xx), SWFDEC_DOUBLE_TO_FIXED (matrix->yy));
- } else {
- SWFDEC_LOG ("no scalefactors given");
- matrix->xx = 1.0;
- matrix->yy = 1.0;
- }
- has_rotate = swfdec_bits_getbit (bits);
- if (has_rotate) {
- int n_rotate_bits = swfdec_bits_getbits (bits, 5);
- matrix->yx = SWFDEC_FIXED_TO_DOUBLE (swfdec_bits_getsbits (bits, n_rotate_bits));
- matrix->xy = SWFDEC_FIXED_TO_DOUBLE (swfdec_bits_getsbits (bits, n_rotate_bits));
-
- SWFDEC_LOG ("skew: xy = %d/65536, yx = %d/65536",
- SWFDEC_DOUBLE_TO_FIXED (matrix->xy),
- SWFDEC_DOUBLE_TO_FIXED (matrix->yx));
- } else {
- SWFDEC_LOG ("no rotation");
- matrix->xy = 0;
- matrix->yx = 0;
- }
- n_translate_bits = swfdec_bits_getbits (bits, 5);
- matrix->x0 = swfdec_bits_getsbits (bits, n_translate_bits);
- matrix->y0 = swfdec_bits_getsbits (bits, n_translate_bits);
-
- swfdec_matrix_ensure_invertible (matrix, inverse);
- swfdec_bits_syncbits (bits);
-}
-
-static const char *
-swfdec_bits_skip_string (SwfdecBits *bits)
-{
- char *s;
- const char *end;
- guint len;
-
- SWFDEC_BYTES_CHECK (bits, 1);
- end = memchr (bits->ptr, 0, bits->end - bits->ptr);
- if (end == NULL) {
- SWFDEC_ERROR ("could not parse string");
- return NULL;
- }
-
- len = end - (const char *) bits->ptr;
- s = (char *) bits->ptr;
- bits->ptr += len + 1;
-
- return s;
-}
-
-/**
- * swfdec_bits_get_string:
- * @bits: a #SwfdecBits
- * @version: Flash player version
- *
- * Prior to Flash 6, strings used to be encoded as LATIN1. Since Flash 6,
- * strings are encoded as UTF-8. This version does that check automatically
- * and converts strings to UTF-8.
- *
- * Returns: a UTF-8 encoded string or %NULL on error
- **/
-char *
-swfdec_bits_get_string (SwfdecBits *bits, guint version)
-{
- const char *s;
-
- g_return_val_if_fail (bits != NULL, NULL);
-
- s = swfdec_bits_skip_string (bits);
- if (s == NULL)
- return NULL;
-
- if (version < 6) {
- char *ret = g_convert (s, -1, "UTF-8", "LATIN1", NULL , NULL, NULL);
- if (ret == NULL)
- g_warning ("Could not convert string from LATIN1 to UTF-8");
- return ret;
- } else {
- if (!g_utf8_validate (s, -1, NULL)) {
- SWFDEC_ERROR ("parsed string is not valid utf-8");
- return NULL;
- }
- return g_strdup (s);
- }
-}
-
-/**
- * swfdec_bits_skip_bytes:
- * @bits: a #SwfdecBits
- * @n_bytes: number of bytes to skip
- *
- * Skips up to @n_bytes bytes in @bits. If not enough bytes are available,
- * only the available amount is skipped and a warning is printed.
- *
- * Returns: the number of bytes actually skipped
- **/
-guint
-swfdec_bits_skip_bytes (SwfdecBits *bits, guint n_bytes)
-{
- g_assert (bits->idx == 0);
- if ((guint) (bits->end - bits->ptr) < n_bytes) {
- SWFDEC_WARNING ("supposed to skip %u bytes, but only %td available",
- n_bytes, bits->end - bits->ptr);
- n_bytes = bits->end - bits->ptr;
- }
- bits->ptr += n_bytes;
- return n_bytes;
-}
-
-/**
- * swfdec_bits_get_string_length:
- * @bits: a #SwfdecBits
- * @len: number of bytes to read
- * @version: flash version number
- *
- * Reads the next @len bytes (not characters!) into a string and validates
- * its encoding is correct based on supplied version number.
- *
- * Returns: a new UTF-8 string or %NULL on error
- **/
-char *
-swfdec_bits_get_string_length (SwfdecBits * bits, guint len, guint version)
-{
- char *ret;
-
- if (len == 0)
- return g_strdup ("");
- SWFDEC_BYTES_CHECK (bits, len);
-
- ret = g_strndup ((char *) bits->ptr, len);
- bits->ptr += len;
-
- if (version < 6) {
- char *tmp = g_convert (ret, -1, "UTF-8", "LATIN1", NULL , NULL, NULL);
- g_free(ret);
- ret = tmp;
- } else {
- if (!g_utf8_validate (ret, -1, NULL)) {
- SWFDEC_ERROR ("parsed string is not valid utf-8");
- g_free (ret);
- ret = NULL;
- }
- }
-
- return ret;
-}
-
-SwfdecColor
-swfdec_bits_get_color (SwfdecBits * bits)
-{
- guint r, g, b;
-
- r = swfdec_bits_get_u8 (bits);
- g = swfdec_bits_get_u8 (bits);
- b = swfdec_bits_get_u8 (bits);
-
- return SWFDEC_COLOR_COMBINE (r, g, b, 0xff);
-}
-
-SwfdecColor
-swfdec_bits_get_rgba (SwfdecBits * bits)
-{
- guint r, g, b, a;
-
- r = swfdec_bits_get_u8 (bits);
- g = swfdec_bits_get_u8 (bits);
- b = swfdec_bits_get_u8 (bits);
- a = swfdec_bits_get_u8 (bits);
-
- return SWFDEC_COLOR_COMBINE (r, g, b, a);
-}
-
-void
-swfdec_bits_get_rect (SwfdecBits * bits, SwfdecRect *rect)
-{
- int nbits;
-
- nbits = swfdec_bits_getbits (bits, 5);
- rect->x0 = swfdec_bits_getsbits (bits, nbits);
- rect->x1 = swfdec_bits_getsbits (bits, nbits);
- rect->y0 = swfdec_bits_getsbits (bits, nbits);
- rect->y1 = swfdec_bits_getsbits (bits, nbits);
-
- swfdec_bits_syncbits (bits);
-}
-
-/**
- * swfdec_bits_get_buffer:
- * @bits: #SwfdecBits
- * @len: length of buffer or -1 for maximum
- *
- * Gets the contents of the next @len bytes of @bits and buts them in a new
- * subbuffer. If @len is 0 (or @len is -1 and no more data is available), this
- * is considered a reading error and %NULL is returned.
- *
- * Returns: the new #SwfdecBuffer or NULL if the requested amount of data
- * isn't available
- **/
-SwfdecBuffer *
-swfdec_bits_get_buffer (SwfdecBits *bits, int len)
-{
- SwfdecBuffer *buffer;
-
- g_return_val_if_fail (len >= -1, NULL);
-
- if (len > 0) {
- SWFDEC_BYTES_CHECK (bits, (guint) len);
- } else {
- g_assert (bits->idx == 0);
- len = bits->end - bits->ptr;
- g_assert (len >= 0);
- }
- if (len == 0)
- return NULL;
- if (bits->buffer) {
- buffer = swfdec_buffer_new_subbuffer (bits->buffer, bits->ptr - bits->buffer->data, len);
- } else {
- buffer = swfdec_buffer_new_and_alloc (len);
- memcpy (buffer->data, bits->ptr, len);
- }
- bits->ptr += len;
- return buffer;
-}
-
-static void *
-swfdec_bits_zalloc (void *opaque, guint items, guint size)
-{
- return g_malloc (items * size);
-}
-
-static void
-swfdec_bits_zfree (void *opaque, void *addr)
-{
- g_free (addr);
-}
-
-/**
- * swfdec_bits_decompress:
- * @bits: a #SwfdecBits
- * @compressed: number of bytes to decompress or -1 for the rest
- * @decompressed: number of bytes to expect in the decompressed result or -1
- * if unknown
- *
- * Decompresses the next @compressed bytes of data in @bits using the zlib
- * decompression algorithm and returns the result in a buffer. If @decompressed
- * was set and not enough data is available, the return buffer will be filled
- * up with 0 bytes.
- *
- * Returns: a new #SwfdecBuffer containing the decompressed data or NULL on
- * failure. If @decompressed > 0, the buffer's length will be @decompressed.
- **/
-SwfdecBuffer *
-swfdec_bits_decompress (SwfdecBits *bits, int compressed, int decompressed)
-{
- z_stream z = { 0, };
- SwfdecBuffer *buffer;
- int result;
-
- g_return_val_if_fail (bits != NULL, NULL);
- g_return_val_if_fail (compressed >= -1, NULL);
- g_return_val_if_fail (decompressed > 0 || decompressed == -1, NULL);
-
- /* prepare the bits structure */
- if (compressed > 0) {
- SWFDEC_BYTES_CHECK (bits, (guint) compressed);
- } else {
- g_assert (bits->idx == 0);
- compressed = bits->end - bits->ptr;
- g_assert (compressed >= 0);
- }
- if (compressed == 0)
- return NULL;
-
- z.zalloc = swfdec_bits_zalloc;
- z.zfree = swfdec_bits_zfree;
- z.opaque = NULL;
- z.next_in = (Bytef *) bits->ptr;
- z.avail_in = compressed;
- result = inflateInit (&z);
- if (result != Z_OK) {
- SWFDEC_ERROR ("Error initialising zlib: %d %s", result, z.msg ? z.msg : "");
- goto fail;
- }
- buffer = swfdec_buffer_new_and_alloc (decompressed > 0 ? decompressed : compressed * 2);
- z.next_out = buffer->data;
- z.avail_out = buffer->length;
- while (TRUE) {
- result = inflate (&z, decompressed > 0 ? Z_FINISH : 0);
- switch (result) {
- case Z_STREAM_END:
- goto out;
- case Z_OK:
- if (decompressed < 0) {
- buffer->data = g_realloc (buffer->data, buffer->length + compressed);
- buffer->length += compressed;
- z.next_out = buffer->data + z.total_out;
- z.avail_out = buffer->length - z.total_out;
- goto out;
- }
- /* else fall through */
- default:
- SWFDEC_ERROR ("error decompressing data: inflate returned %d %s",
- result, z.msg ? z.msg : "");
- swfdec_buffer_unref (buffer);
- goto fail;
- }
- }
-out:
- if (decompressed < 0) {
- buffer->length = z.total_out;
- } else {
- if (buffer->length < z.total_out) {
- SWFDEC_WARNING ("Not enough data decompressed: %lu instead of %"G_GSIZE_FORMAT" expected",
- (gulong) z.total_out, buffer->length);
- memset (buffer->data + z.total_out, 0, buffer->length - z.total_out);
- }
- }
- result = inflateEnd (&z);
- if (result != Z_OK) {
- SWFDEC_ERROR ("error in inflateEnd: %d %s", result, z.msg ? z.msg : "");
- }
- bits->ptr += compressed;
- return buffer;
-
-fail:
- bits->ptr += compressed;
- return NULL;
-}
diff --git a/libswfdec/swfdec_bits.h b/libswfdec/swfdec_bits.h
deleted file mode 100644
index c56bc99..0000000
--- a/libswfdec/swfdec_bits.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef __SWFDEC_BITS_H__
-#define __SWFDEC_BITS_H__
-
-#include <cairo.h>
-#include <libswfdec/swfdec_color.h>
-#include <libswfdec/swfdec_buffer.h>
-
-typedef struct _SwfdecBits SwfdecBits;
-
-struct _SwfdecBits
-{
- SwfdecBuffer * buffer; /* buffer data is taken from or NULL */
- const unsigned char * ptr; /* current location to read from */
- guint idx; /* bits already read from ptr */
- const unsigned char * end; /* pointer after last byte */
-};
-
-void swfdec_bits_init (SwfdecBits *bits, SwfdecBuffer *buffer);
-void swfdec_bits_init_data (SwfdecBits *bits, const guint8 *data, guint len);
-void swfdec_bits_init_bits (SwfdecBits *bits, SwfdecBits *from, guint bytes);
-guint swfdec_bits_left (const SwfdecBits *b);
-int swfdec_bits_getbit (SwfdecBits * b);
-guint swfdec_bits_getbits (SwfdecBits * b, guint n);
-guint swfdec_bits_peekbits (const SwfdecBits * b, guint n);
-int swfdec_bits_getsbits (SwfdecBits * b, guint n);
-guint swfdec_bits_peek_u8 (const SwfdecBits * b);
-guint swfdec_bits_get_u8 (SwfdecBits * b);
-guint swfdec_bits_get_u16 (SwfdecBits * b);
-int swfdec_bits_get_s16 (SwfdecBits * b);
-guint swfdec_bits_get_u32 (SwfdecBits * b);
-guint swfdec_bits_get_bu16 (SwfdecBits *b);
-guint swfdec_bits_get_bu24 (SwfdecBits *b);
-guint swfdec_bits_get_bu32 (SwfdecBits *b);
-float swfdec_bits_get_float (SwfdecBits * b);
-double swfdec_bits_get_double (SwfdecBits * b);
-double swfdec_bits_get_bdouble (SwfdecBits * b);
-void swfdec_bits_syncbits (SwfdecBits * b);
-
-void swfdec_bits_get_color_transform (SwfdecBits * bits,
- SwfdecColorTransform * ct);
-void swfdec_bits_get_matrix (SwfdecBits * bits, cairo_matrix_t *matrix,
- cairo_matrix_t *inverse);
-guint swfdec_bits_skip_bytes (SwfdecBits *bits, guint bytes);
-char *swfdec_bits_get_string_length (SwfdecBits * bits, guint len, guint version);
-char *swfdec_bits_get_string (SwfdecBits *bits, guint version);
-SwfdecColor swfdec_bits_get_color (SwfdecBits * bits);
-SwfdecColor swfdec_bits_get_rgba (SwfdecBits * bits);
-void swfdec_bits_get_rect (SwfdecBits * bits, SwfdecRect *rect);
-SwfdecBuffer *swfdec_bits_get_buffer (SwfdecBits *bits, int len);
-SwfdecBuffer *swfdec_bits_decompress (SwfdecBits *bits, int compressed,
- int decompressed);
-
-
-#endif
diff --git a/libswfdec/swfdec_blur_filter.c b/libswfdec/swfdec_blur_filter.c
deleted file mode 100644
index 3a40c40..0000000
--- a/libswfdec/swfdec_blur_filter.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (1102, 1, swfdec_blur_filter_get_blurX)
-void
-swfdec_blur_filter_get_blurX (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BlurFilter.blurX (get)");
-}
-
-SWFDEC_AS_NATIVE (1102, 2, swfdec_blur_filter_set_blurX)
-void
-swfdec_blur_filter_set_blurX (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BlurFilter.blurX (set)");
-}
-
-SWFDEC_AS_NATIVE (1102, 3, swfdec_blur_filter_get_blurY)
-void
-swfdec_blur_filter_get_blurY (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BlurFilter.blurY (get)");
-}
-
-SWFDEC_AS_NATIVE (1102, 4, swfdec_blur_filter_set_blurY)
-void
-swfdec_blur_filter_set_blurY (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BlurFilter.blurY (set)");
-}
-
-SWFDEC_AS_NATIVE (1102, 5, swfdec_blur_filter_get_quality)
-void
-swfdec_blur_filter_get_quality (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BlurFilter.quality (get)");
-}
-
-SWFDEC_AS_NATIVE (1102, 6, swfdec_blur_filter_set_quality)
-void
-swfdec_blur_filter_set_quality (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BlurFilter.quality (set)");
-}
-
-// constructor
-SWFDEC_AS_NATIVE (1102, 0, swfdec_blur_filter_construct)
-void
-swfdec_blur_filter_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("BlurFilter");
-}
diff --git a/libswfdec/swfdec_buffer.c b/libswfdec/swfdec_buffer.c
deleted file mode 100644
index 3420d10..0000000
--- a/libswfdec/swfdec_buffer.c
+++ /dev/null
@@ -1,641 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <swfdec_buffer.h>
-#include <glib.h>
-#include <string.h>
-#include <swfdec_debug.h>
-#include <liboil/liboil.h>
-
-/*** gtk-doc ***/
-
-/**
- * SECTION:SwfdecBuffer
- * @title: SwfdecBuffer
- * @short_description: memory region handling
- *
- * This section describes how memory is to be handled when interacting with the
- * Swfdec library. Memory regions are refcounted and passed using a
- * #SwfdecBuffer. If large memory segments need to be handled that may span
- * multiple buffers, Swfdec uses a #SwfdecBufferQueue.
- */
-
-/*** SwfdecBuffer ***/
-
-/**
- * SwfdecBuffer:
- * @data: the data. read-only
- * @length: number of bytes in @data. read-only
- *
- * To allow for easy sharing of memory regions, #SwfdecBuffer was created.
- * Every buffer refers to a memory region and its size and takes care of
- * freeing that region when the buffer is no longer needed. They are
- * reference countedto make it easy to refer to the same region from various
- * independant parts of your code. Buffers also support some advanced
- * functionalities like extracting parts of the buffer using
- * swfdec_buffer_new_subbuffer() or using mmapped files with
- * swfdec_buffer_new_from_file() without the need for a different API.
- */
-
-/**
- * SwfdecBufferFreeFunc:
- * @data: The data to free
- * @priv: The private data registered for passing to this function
- *
- * This is the function prototype for the function that is called for freeing
- * the memory pointed to by a buffer. See swfdec_buffer_new() for an example.
- */
-
-GType
-swfdec_buffer_get_type (void)
-{
- static GType type_swfdec_buffer = 0;
-
- if (!type_swfdec_buffer)
- type_swfdec_buffer = g_boxed_type_register_static
- ("SwfdecBuffer",
- (GBoxedCopyFunc) swfdec_buffer_ref,
- (GBoxedFreeFunc) swfdec_buffer_unref);
-
- return type_swfdec_buffer;
-}
-
-/**
- * swfdec_buffer_new:
- *
- * Creates a new #SwfdecBuffer to be filled by the user. Use like this:
- * <informalexample><programlisting>SwfdecBuffer *buffer = swfdec_buffer_new ();
- * buffer->data = mydata;
- * buffer->length = mydata_length;
- * buffer->free = mydata_freefunc;
- * buffer->priv = mydata_private;</programlisting></informalexample>
- *
- * Returns: a new #SwfdecBuffer referencing nothing.
- **/
-SwfdecBuffer *
-swfdec_buffer_new (void)
-{
- SwfdecBuffer *buffer;
-
- buffer = g_new0 (SwfdecBuffer, 1);
- buffer->ref_count = 1;
- return buffer;
-}
-
-/**
- * swfdec_buffer_new_and_alloc:
- * @size: amount of bytes to allocate
- *
- * Creates a new buffer and allocates new memory of @size bytes to be used with
- * the buffer.
- *
- * Returns: a new #SwfdecBuffer with buffer->data pointing to new data
- **/
-SwfdecBuffer *
-swfdec_buffer_new_and_alloc (gsize size)
-{
- SwfdecBuffer *buffer = swfdec_buffer_new ();
-
- buffer->data = g_malloc (size);
- buffer->length = size;
- buffer->free = (SwfdecBufferFreeFunc) g_free;
-
- return buffer;
-}
-
-/**
- * swfdec_buffer_new_and_alloc0:
- * @size: amount of bytes to allocate
- *
- * Createsa new buffer just like swfdec_buffer_new_and_alloc(), but ensures
- * that the returned data gets initialized to be 0.
- *
- * Returns: a new #SwfdecBuffer with buffer->data pointing to new data
- **/
-SwfdecBuffer *
-swfdec_buffer_new_and_alloc0 (gsize size)
-{
- SwfdecBuffer *buffer = swfdec_buffer_new ();
-
- buffer->data = g_malloc0 (size);
- buffer->length = size;
- buffer->free = (SwfdecBufferFreeFunc) g_free;
-
- return buffer;
-}
-
-/**
- * swfdec_buffer_new_for_data:
- * @data: memory region allocated with g_malloc()
- * @size: size of @data in bytes
- *
- * Takes ownership of @data and creates a new buffer managing it.
- *
- * Returns: a new #SwfdecBuffer pointing to @data
- **/
-SwfdecBuffer *
-swfdec_buffer_new_for_data (unsigned char *data, gsize size)
-{
- SwfdecBuffer *buffer;
-
- g_return_val_if_fail (data != NULL, NULL);
- g_return_val_if_fail (size > 0, NULL);
-
- buffer = swfdec_buffer_new ();
- buffer->data = data;
- buffer->length = size;
- buffer->free = (SwfdecBufferFreeFunc) g_free;
-
- return buffer;
-}
-
-static void
-swfdec_buffer_free_subbuffer (unsigned char *data, gpointer priv)
-{
- swfdec_buffer_unref (priv);
-}
-
-/**
- * swfdec_buffer_new_subbuffer:
- * @buffer: #SwfdecBuffer managing the region of memory
- * @offset: starting offset into data
- * @length: amount of bytes to manage
- *
- * Creates a #SwfdecBuffer for managing a partial section of the memory pointed
- * to by @buffer.
- *
- * Returns: a new #SwfdecBuffer managing the indicated region.
- **/
-SwfdecBuffer *
-swfdec_buffer_new_subbuffer (SwfdecBuffer * buffer, gsize offset, gsize length)
-{
- SwfdecBuffer *subbuffer;
-
- g_return_val_if_fail (buffer != NULL, NULL);
- g_return_val_if_fail (offset + length <= buffer->length, NULL);
-
- subbuffer = swfdec_buffer_new ();
-
- subbuffer->priv = swfdec_buffer_ref (swfdec_buffer_get_super (buffer));
- subbuffer->data = buffer->data + offset;
- subbuffer->length = length;
- subbuffer->free = swfdec_buffer_free_subbuffer;
-
- return subbuffer;
-}
-
-/**
- * swfdec_buffer_get_super:
- * @buffer: a #SwfdecBuffer
- *
- * Returns the largest buffer that contains the memory pointed to by @buffer.
- * This will either be the passed @buffer itself, or if the buffer was created
- * via swfdec_buffer_new_subbuffer(), the buffer used for that.
- *
- * Returns: The largest @buffer available that contains the memory pointed to
- * by @buffer.
- **/
-SwfdecBuffer *
-swfdec_buffer_get_super (SwfdecBuffer *buffer)
-{
- g_return_val_if_fail (buffer != NULL, NULL);
-
- if (buffer->free == swfdec_buffer_free_subbuffer)
- buffer = buffer->priv;
-
- g_assert (buffer->free != swfdec_buffer_free_subbuffer);
- return buffer;
-}
-
-static void
-swfdec_buffer_free_mapped (unsigned char *data, gpointer priv)
-{
- g_mapped_file_free (priv);
-}
-
-/**
- * swfdec_buffer_new_from_file:
- * @filename: file to read
- * @error: return location for a #GError or %NULL
- *
- * Creates a buffer containing the contents of the given file. If loading the
- * file fails, %NULL is returned and @error is set. The error can be
- * any of the errors that are valid for g_file_get_contents().
- *
- * Returns: a new #SwfdecBuffer or %NULL on failure
- **/
-SwfdecBuffer *
-swfdec_buffer_new_from_file (const char *filename, GError **error)
-{
- GMappedFile *file;
- char *data;
- gsize length;
-
- g_return_val_if_fail (filename != NULL, NULL);
-
- file = g_mapped_file_new (filename, FALSE, NULL);
- if (file != NULL) {
- SwfdecBuffer *buffer = swfdec_buffer_new ();
- buffer->data = (unsigned char *) g_mapped_file_get_contents (file),
- buffer->length = g_mapped_file_get_length (file);
- buffer->free = swfdec_buffer_free_mapped;
- buffer->priv = file;
- return buffer;
- }
-
- if (!g_file_get_contents (filename, &data, &length, error))
- return NULL;
-
- return swfdec_buffer_new_for_data ((guint8 *) data, length);
-}
-
-/**
- * swfdec_buffer_ref:
- * @buffer: a #SwfdecBuffer
- *
- * increases the reference count of @buffer by one.
- *
- * Returns: The passed in @buffer.
- **/
-SwfdecBuffer *
-swfdec_buffer_ref (SwfdecBuffer * buffer)
-{
- g_return_val_if_fail (buffer != NULL, NULL);
- g_return_val_if_fail (buffer->ref_count > 0, NULL);
-
- buffer->ref_count++;
- return buffer;
-}
-
-/**
- * swfdec_buffer_unref:
- * @buffer: a #SwfdecBuffer
- *
- * Decreases the reference count of @buffer by one. If no reference to this
- * buffer exists anymore, the buffer and the memory it manages are freed.
- **/
-void
-swfdec_buffer_unref (SwfdecBuffer * buffer)
-{
- g_return_if_fail (buffer != NULL);
- g_return_if_fail (buffer->ref_count > 0);
-
- buffer->ref_count--;
- if (buffer->ref_count == 0) {
- if (buffer->free)
- buffer->free (buffer->data, buffer->priv);
- g_free (buffer);
- }
-}
-
-/*** SwfdecBufferQueue ***/
-
-/**
- * SwfdecBufferQueue:
- *
- * A #SwfdecBufferQueue is a queue of continuous buffers that allows reading
- * its data in chunks of pre-defined sizes. It is used to transform a data
- * stream that was provided by buffers of random sizes to buffers of the right
- * size.
- */
-
-GType
-swfdec_buffer_queue_get_type (void)
-{
- static GType type_swfdec_buffer_queue = 0;
-
- if (!type_swfdec_buffer_queue)
- type_swfdec_buffer_queue = g_boxed_type_register_static
- ("SwfdecBufferQueue",
- (GBoxedCopyFunc) swfdec_buffer_queue_ref,
- (GBoxedFreeFunc) swfdec_buffer_queue_unref);
-
- return type_swfdec_buffer_queue;
-}
-
-/**
- * swfdec_buffer_queue_new:
- *
- * Creates a new empty buffer queue.
- *
- * Returns: a new buffer queue. Use swfdec_buffer_queue_unref () to free it.
- **/
-SwfdecBufferQueue *
-swfdec_buffer_queue_new (void)
-{
- SwfdecBufferQueue *buffer_queue;
-
- buffer_queue = g_new0 (SwfdecBufferQueue, 1);
- buffer_queue->ref_count = 1;
- return buffer_queue;
-}
-
-/**
- * swfdec_buffer_queue_get_depth:
- * @queue: a #SwfdecBufferQueue
- *
- * Returns the number of bytes currently in @queue.
- *
- * Returns: amount of bytes in @queue.
- **/
-guint
-swfdec_buffer_queue_get_depth (SwfdecBufferQueue * queue)
-{
- g_return_val_if_fail (queue != NULL, 0);
-
- return queue->depth;
-}
-
-/**
- * swfdec_buffer_queue_get_offset:
- * @queue: a #SwfdecBufferQueue
- *
- * Queries the amount of bytes that has already been pulled out of
- * @queue using functions like swfdec_buffer_queue_pull().
- *
- * Returns: Number of bytes that were already pulled from this queue.
- **/
-guint
-swfdec_buffer_queue_get_offset (SwfdecBufferQueue * queue)
-{
- g_return_val_if_fail (queue != NULL, 0);
-
- return queue->offset;
-}
-
-/**
- * swfdec_buffer_queue_clear:
- * @queue: a #SwfdecBufferQueue
- *
- * Resets @queue into to initial state. All buffers it contains will be
- * released and the offset will be reset to 0.
- **/
-void
-swfdec_buffer_queue_clear (SwfdecBufferQueue *queue)
-{
- g_return_if_fail (queue != NULL);
-
- g_list_foreach (queue->buffers, (GFunc) swfdec_buffer_unref, NULL);
- g_list_free (queue->buffers);
- memset (queue, 0, sizeof (SwfdecBufferQueue));
-}
-
-/**
- * swfdec_buffer_queue_push:
- * @queue: a #SwfdecBufferQueue
- * @buffer: #SwfdecBuffer to append to @queue
- *
- * Appends the given @buffer to the buffers already in @queue. This function
- * will take ownership of the given @buffer. Use swfdec_buffer_ref () before
- * calling this function to keep a reference.
- **/
-void
-swfdec_buffer_queue_push (SwfdecBufferQueue * queue, SwfdecBuffer * buffer)
-{
- g_return_if_fail (queue != NULL);
- g_return_if_fail (buffer != NULL);
-
- if (buffer->length == 0) {
- swfdec_buffer_unref (buffer);
- return;
- }
- queue->buffers = g_list_append (queue->buffers, buffer);
- queue->depth += buffer->length;
-}
-
-/**
- * swfdec_buffer_queue_pull_buffer:
- * @queue: a #SwfdecBufferQueue
- *
- * Pulls the first buffer out of @queue and returns it. This function is
- * equivalent to calling swfdec_buffer_queue_pull() with the size of the
- * first buffer in it.
- *
- * Returns: The first buffer in @queue or %NULL if @queue is empty.
- **/
-SwfdecBuffer *
-swfdec_buffer_queue_pull_buffer (SwfdecBufferQueue * queue)
-{
- SwfdecBuffer *buffer;
-
- g_return_val_if_fail (queue != NULL, NULL);
- if (queue->buffers == NULL)
- return NULL;
-
- buffer = queue->buffers->data;
-
- return swfdec_buffer_queue_pull (queue, buffer->length);
-}
-
-/**
- * swfdec_buffer_queue_pull:
- * @queue: a #SwfdecBufferQueue
- * @length: amount of bytes to pull
- *
- * If enough data is still available in @queue, the first @length bytes are
- * put into a new buffer and that buffer is returned. The @length bytes are
- * removed from the head of the queue. If not enough data is available, %NULL
- * is returned.
- *
- * Returns: a new #SwfdecBuffer or %NULL
- **/
-SwfdecBuffer *
-swfdec_buffer_queue_pull (SwfdecBufferQueue * queue, guint length)
-{
- GList *g;
- SwfdecBuffer *newbuffer;
- SwfdecBuffer *buffer;
- SwfdecBuffer *subbuffer;
-
- g_return_val_if_fail (queue != NULL, NULL);
- g_return_val_if_fail (length > 0, NULL);
-
- if (queue->depth < length)
- return NULL;
-
- /* FIXME: This function should share code with swfdec_buffer_queue_peek */
- SWFDEC_LOG ("pulling %d, %d available", length, queue->depth);
-
- g = g_list_first (queue->buffers);
- buffer = g->data;
-
- if (buffer->length > length) {
- newbuffer = swfdec_buffer_new_subbuffer (buffer, 0, length);
-
- subbuffer = swfdec_buffer_new_subbuffer (buffer, length,
- buffer->length - length);
- g->data = subbuffer;
- swfdec_buffer_unref (buffer);
- } else if (buffer->length == length) {
- queue->buffers = g_list_remove (queue->buffers, buffer);
- newbuffer = buffer;
- } else {
- guint offset = 0;
-
- newbuffer = swfdec_buffer_new_and_alloc (length);
-
- while (offset < length) {
- g = g_list_first (queue->buffers);
- buffer = g->data;
-
- if (buffer->length > length - offset) {
- guint n = length - offset;
-
- oil_copy_u8 (newbuffer->data + offset, buffer->data, n);
- subbuffer = swfdec_buffer_new_subbuffer (buffer, n, buffer->length - n);
- g->data = subbuffer;
- swfdec_buffer_unref (buffer);
- offset += n;
- } else {
- oil_copy_u8 (newbuffer->data + offset, buffer->data, buffer->length);
-
- queue->buffers = g_list_delete_link (queue->buffers, g);
- offset += buffer->length;
- swfdec_buffer_unref (buffer);
- }
- }
- }
-
- queue->depth -= length;
- queue->offset += length;
-
- return newbuffer;
-}
-
-/**
- * swfdec_buffer_queue_peek_buffer:
- * @queue: a #SwfdecBufferQueue
- *
- * Gets the first buffer out of @queue and returns it. This function is
- * equivalent to calling swfdec_buffer_queue_peek() with the size of the
- * first buffer in it.
- *
- * Returns: The first buffer in @queue or %NULL if @queue is empty. Use
- * swfdec_buffer_unref() after use.
- **/
-SwfdecBuffer *
-swfdec_buffer_queue_peek_buffer (SwfdecBufferQueue * queue)
-{
- SwfdecBuffer *buffer;
-
- g_return_val_if_fail (queue != NULL, NULL);
- if (queue->buffers == NULL)
- return NULL;
-
- buffer = queue->buffers->data;
-
- return swfdec_buffer_queue_peek (queue, buffer->length);
-}
-
-/**
- * swfdec_buffer_queue_peek:
- * @queue: a #SwfdecBufferQueue to read from
- * @length: amount of bytes to peek
- *
- * Creates a new buffer with the first @length bytes from @queue, but unlike
- * swfdec_buffer_queue_pull(), does not remove them from @queue.
- *
- * Returns: NULL if the requested amount of data wasn't available or a new
- * readonly #SwfdecBuffer. Use swfdec_buffer_unref() after use.
- **/
-SwfdecBuffer *
-swfdec_buffer_queue_peek (SwfdecBufferQueue * queue, guint length)
-{
- GList *g;
- SwfdecBuffer *newbuffer;
- SwfdecBuffer *buffer;
- guint offset = 0;
-
- g_return_val_if_fail (length > 0, NULL);
-
- if (queue->depth < length)
- return NULL;
-
- SWFDEC_LOG ("peeking %d, %d available", length, queue->depth);
-
- g = g_list_first (queue->buffers);
- buffer = g->data;
- if (buffer->length > length) {
- newbuffer = swfdec_buffer_new_subbuffer (buffer, 0, length);
- } else {
- newbuffer = swfdec_buffer_new_and_alloc (length);
- while (offset < length) {
- buffer = g->data;
-
- if (buffer->length > length - offset) {
- int n = length - offset;
-
- oil_copy_u8 (newbuffer->data + offset, buffer->data, n);
- offset += n;
- } else {
- oil_copy_u8 (newbuffer->data + offset, buffer->data, buffer->length);
- offset += buffer->length;
- }
- g = g_list_next (g);
- }
- }
-
- return newbuffer;
-}
-
-/**
- * swfdec_buffer_queue_ref:
- * @queue: a #SwfdecBufferQueue
- *
- * increases the reference count of @queue by one.
- *
- * Returns: The passed in @queue.
- **/
-SwfdecBufferQueue *
-swfdec_buffer_queue_ref (SwfdecBufferQueue * queue)
-{
- g_return_val_if_fail (queue != NULL, NULL);
- g_return_val_if_fail (queue->ref_count > 0, NULL);
-
- queue->ref_count++;
- return queue;
-}
-
-/**
- * swfdec_buffer_queue_unref:
- * @queue: a #SwfdecBufferQueue
- *
- * Decreases the reference count of @queue by one. If no reference
- * to this buffer exists anymore, the buffer and the memory
- * it manages are freed.
- **/
-void
-swfdec_buffer_queue_unref (SwfdecBufferQueue * queue)
-{
- g_return_if_fail (queue != NULL);
- g_return_if_fail (queue->ref_count > 0);
-
- queue->ref_count--;
- if (queue->ref_count == 0) {
- swfdec_buffer_queue_clear (queue);
- g_free (queue);
- }
-}
-
diff --git a/libswfdec/swfdec_buffer.h b/libswfdec/swfdec_buffer.h
deleted file mode 100644
index 248f425..0000000
--- a/libswfdec/swfdec_buffer.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef __SWFDEC_BUFFER_H__
-#define __SWFDEC_BUFFER_H__
-
-#include <glib.h>
-#include <glib-object.h>
-
-typedef struct _SwfdecBuffer SwfdecBuffer;
-typedef struct _SwfdecBufferQueue SwfdecBufferQueue;
-
-typedef void (* SwfdecBufferFreeFunc) (unsigned char *data, gpointer priv);
-
-struct _SwfdecBuffer
-{
- unsigned char * data; /* memory region (consider as read only) */
- gsize length; /* length of the memory region pointer do by @data */
-
- /*< private >*/
- int ref_count; /* guess */
-
- SwfdecBufferFreeFunc free; /* function to call to free @data */
- gpointer priv; /* data to pass to @free */
-};
-
-#define SWFDEC_TYPE_BUFFER swfdec_buffer_get_type()
-GType swfdec_buffer_get_type (void);
-
-struct _SwfdecBufferQueue
-{
- /*< private >*/
- GList *buffers;
- guint depth;
- guint offset;
-
- int ref_count;
-};
-
-#define SWFDEC_TYPE_BUFFER_QUEUE swfdec_buffer_queue_get_type()
-GType swfdec_buffer_queue_get_type (void);
-
-SwfdecBuffer *swfdec_buffer_new (void);
-SwfdecBuffer *swfdec_buffer_new_and_alloc (gsize size);
-SwfdecBuffer *swfdec_buffer_new_and_alloc0 (gsize size);
-SwfdecBuffer *swfdec_buffer_new_for_data (unsigned char *data, gsize size);
-SwfdecBuffer *swfdec_buffer_new_subbuffer (SwfdecBuffer * buffer, gsize offset,
- gsize length);
-SwfdecBuffer *swfdec_buffer_new_from_file (const char *filename, GError **error);
-SwfdecBuffer *swfdec_buffer_ref (SwfdecBuffer * buffer);
-SwfdecBuffer *swfdec_buffer_get_super (SwfdecBuffer *buffer);
-void swfdec_buffer_unref (SwfdecBuffer * buffer);
-
-SwfdecBufferQueue *swfdec_buffer_queue_new (void);
-void swfdec_buffer_queue_clear (SwfdecBufferQueue *queue);
-guint swfdec_buffer_queue_get_depth (SwfdecBufferQueue * queue);
-guint swfdec_buffer_queue_get_offset (SwfdecBufferQueue * queue);
-void swfdec_buffer_queue_push (SwfdecBufferQueue * queue,
- SwfdecBuffer * buffer);
-SwfdecBuffer *swfdec_buffer_queue_pull (SwfdecBufferQueue * queue, guint length);
-SwfdecBuffer *swfdec_buffer_queue_pull_buffer (SwfdecBufferQueue * queue);
-SwfdecBuffer *swfdec_buffer_queue_peek (SwfdecBufferQueue * queue, guint length);
-SwfdecBuffer *swfdec_buffer_queue_peek_buffer (SwfdecBufferQueue * queue);
-SwfdecBufferQueue *swfdec_buffer_queue_ref (SwfdecBufferQueue * queue);
-void swfdec_buffer_queue_unref (SwfdecBufferQueue * queue);
-#endif
-
diff --git a/libswfdec/swfdec_button.c b/libswfdec/swfdec_button.c
deleted file mode 100644
index 471b936..0000000
--- a/libswfdec/swfdec_button.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <string.h>
-#include "swfdec_button.h"
-#include "swfdec_button_movie.h"
-#include "swfdec_debug.h"
-#include "swfdec_filter.h"
-#include "swfdec_sound.h"
-#include "swfdec_sprite.h"
-
-
-G_DEFINE_TYPE (SwfdecButton, swfdec_button, SWFDEC_TYPE_GRAPHIC)
-
-static void
-swfdec_button_init (SwfdecButton * button)
-{
-}
-
-static void
-swfdec_button_dispose (GObject *object)
-{
- guint i;
- SwfdecButton *button = SWFDEC_BUTTON (object);
-
- g_slist_foreach (button->records, (GFunc) swfdec_buffer_unref, NULL);
- g_slist_free (button->records);
- button->records = NULL;
- if (button->events != NULL) {
- swfdec_event_list_free (button->events);
- button->events = NULL;
- }
- for (i = 0; i < 4; i++) {
- if (button->sounds[i]) {
- swfdec_sound_chunk_free (button->sounds[i]);
- button->sounds[i] = NULL;
- }
- }
-
- G_OBJECT_CLASS (swfdec_button_parent_class)->dispose (G_OBJECT (button));
-}
-
-static SwfdecMovie *
-swfdec_button_create_movie (SwfdecGraphic *graphic, gsize *size)
-{
- SwfdecButton *button = SWFDEC_BUTTON (graphic);
- SwfdecButtonMovie *movie = g_object_new (SWFDEC_TYPE_BUTTON_MOVIE, NULL);
-
- movie->button = g_object_ref (button);
- *size = sizeof (SwfdecButtonMovie);
- if (button->events)
- SWFDEC_MOVIE (movie)->events = swfdec_event_list_copy (button->events);
-
- return SWFDEC_MOVIE (movie);
-}
-
-static void
-swfdec_button_class_init (SwfdecButtonClass * g_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (g_class);
- SwfdecGraphicClass *graphic_class = SWFDEC_GRAPHIC_CLASS (g_class);
-
- object_class->dispose = swfdec_button_dispose;
-
- graphic_class->create_movie = swfdec_button_create_movie;
-}
-
-static guint
-swfdec_button_translate_conditions (guint conditions, gboolean menu)
-{
- static const guint events[][2] = {
- /* idle => over up */ { 1 << SWFDEC_EVENT_ROLL_OVER, 1 << SWFDEC_EVENT_ROLL_OVER },
- /* over up => idle */ { 1 << SWFDEC_EVENT_ROLL_OUT, 1 << SWFDEC_EVENT_ROLL_OUT },
- /* over up => over down */ { 1 << SWFDEC_EVENT_PRESS, 1 << SWFDEC_EVENT_PRESS },
- /* over down => over up */ { 1 << SWFDEC_EVENT_RELEASE, 1 << SWFDEC_EVENT_RELEASE },
- /* over down => out down */ { 1 << SWFDEC_EVENT_DRAG_OUT, 0 },
- /* out down => over down */ { 1 << SWFDEC_EVENT_DRAG_OVER, 0 },
- /* out down => idle */ { 1 << SWFDEC_EVENT_RELEASE_OUTSIDE, 1 << SWFDEC_EVENT_RELEASE_OUTSIDE },
- /* idle => over down */ { 0, 1 << SWFDEC_EVENT_DRAG_OVER },
- /* over down => idle */ { 0, 1 << SWFDEC_EVENT_DRAG_OUT }
- };
- guint i, ret;
-
- ret = 0;
- for (i = 0; i <= G_N_ELEMENTS (events); i++) {
- if (conditions & (1 << i))
- ret |= events[i][menu ? 1 : 0];
- }
- return ret;
-}
-
-int
-tag_func_define_button_2 (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecBits bits;
- int id, reserved;
- guint length;
- SwfdecButton *button;
- char *script_name;
-
- id = swfdec_bits_get_u16 (&s->b);
- button = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_BUTTON);
- if (!button)
- return SWFDEC_STATUS_OK;
-
- SWFDEC_LOG (" ID: %d", id);
-
- reserved = swfdec_bits_getbits (&s->b, 7);
- button->menubutton = swfdec_bits_getbit (&s->b) ? TRUE : FALSE;
- length = swfdec_bits_get_u16 (&s->b);
-
- SWFDEC_LOG (" reserved = %d", reserved);
- SWFDEC_LOG (" menu = %d", button->menubutton);
- SWFDEC_LOG (" length of region = %d", length);
-
- if (length)
- swfdec_bits_init_bits (&bits, &s->b, length > 2 ? length - 2 : 0);
- else
- swfdec_bits_init_bits (&bits, &s->b, swfdec_bits_left (&s->b) / 8);
- while (swfdec_bits_peek_u8 (&bits)) {
- SwfdecBits tmp;
- SwfdecBuffer *buffer;
- cairo_matrix_t trans;
- SwfdecColorTransform ctrans;
- guint states, gid;
- gboolean has_blend_mode, has_filters;
-
- /* we parse the placement info into buffers each containing one palcement */
- tmp = bits;
-
- if (s->version >= 8) {
- reserved = swfdec_bits_getbits (&bits, 2);
- has_blend_mode = swfdec_bits_getbit (&bits);
- has_filters = swfdec_bits_getbit (&bits);
- SWFDEC_LOG (" reserved = %d", reserved);
- SWFDEC_LOG (" has_blend_mode = %d", has_blend_mode);
- SWFDEC_LOG (" has_filters = %d", has_filters);
- } else {
- reserved = swfdec_bits_getbits (&bits, 4);
- has_blend_mode = 0;
- has_filters = 0;
- SWFDEC_LOG (" reserved = %d", reserved);
- }
- states = swfdec_bits_getbits (&bits, 4);
- gid = swfdec_bits_get_u16 (&bits);
- swfdec_bits_get_u16 (&bits);
-
- SWFDEC_LOG (" states: %s%s%s%s",
- states & (1 << SWFDEC_BUTTON_HIT) ? "HIT " : "",
- states & (1 << SWFDEC_BUTTON_DOWN) ? "DOWN " : "",
- states & (1 << SWFDEC_BUTTON_OVER) ? "OVER " : "",
- states & (1 << SWFDEC_BUTTON_UP) ? "UP " : "");
-
- swfdec_bits_get_matrix (&bits, &trans, NULL);
- SWFDEC_LOG ("matrix: %g %g %g %g %g %g",
- trans.xx, trans.yy,
- trans.xy, trans.yx,
- trans.x0, trans.y0);
- swfdec_bits_get_color_transform (&bits, &ctrans);
-
- if (has_filters) {
- GSList *list = swfdec_filter_parse (SWFDEC_DECODER (s)->player, &bits);
- g_slist_free (list);
- }
- if (has_blend_mode) {
- guint blend_mode = swfdec_bits_get_u8 (&bits);
- SWFDEC_LOG (" blend mode = %u", blend_mode);
- }
- buffer = swfdec_bits_get_buffer (&tmp, (swfdec_bits_left (&tmp) - swfdec_bits_left (&bits)) / 8);
- if (buffer == NULL)
- break;
- button->records = g_slist_prepend (button->records, buffer);
- /* add hit state movies to button's extents */
- if (states & (1 << SWFDEC_BUTTON_HIT)) {
- SwfdecGraphic *graphic = swfdec_swf_decoder_get_character (s, gid);
- if (SWFDEC_IS_GRAPHIC (graphic)) {
- SwfdecRect rect;
- swfdec_rect_transform (&rect, &graphic->extents, &trans);
- swfdec_rect_union (&SWFDEC_GRAPHIC (button)->extents, &SWFDEC_GRAPHIC (button)->extents, &rect);
- } else {
- SWFDEC_ERROR ("graphic for id %u not found", gid);
- }
- }
- }
- swfdec_bits_get_u8 (&bits);
- if (swfdec_bits_left (&bits)) {
- SWFDEC_WARNING ("%u bytes left when parsing button records", swfdec_bits_left (&bits) / 8);
- }
- button->records = g_slist_reverse (button->records);
-
- script_name = g_strdup_printf ("Button%u", SWFDEC_CHARACTER (button)->id);
- while (length != 0) {
- guint condition, key;
-
- length = swfdec_bits_get_u16 (&s->b);
- if (length)
- swfdec_bits_init_bits (&bits, &s->b, length > 2 ? length - 2 : 0);
- else
- swfdec_bits_init_bits (&bits, &s->b, swfdec_bits_left (&s->b) / 8);
- condition = swfdec_bits_get_u16 (&bits);
- key = condition >> 9;
- condition &= 0x1FF;
- condition = swfdec_button_translate_conditions (condition, button->menubutton);
-
- SWFDEC_LOG (" length = %d", length);
-
- if (button->events == NULL)
- button->events = swfdec_event_list_new (SWFDEC_DECODER (s)->player);
- SWFDEC_LOG (" new event for condition %u (key %u)", condition, key);
- swfdec_event_list_parse (button->events, &bits, s->version, condition, key,
- script_name);
- if (swfdec_bits_left (&bits)) {
- SWFDEC_WARNING ("%u bytes left after parsing script", swfdec_bits_left (&bits) / 8);
- }
- }
- g_free (script_name);
-
- return SWFDEC_STATUS_OK;
-}
-
-int
-tag_func_define_button (SwfdecSwfDecoder * s, guint tag)
-{
- guint id, flags;
- SwfdecButton *button;
-
- id = swfdec_bits_get_u16 (&s->b);
- button = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_BUTTON);
- if (!button)
- return SWFDEC_STATUS_OK;
-
- SWFDEC_LOG (" ID: %d", id);
-
- while (swfdec_bits_peek_u8 (&s->b)) {
- SwfdecBits tmp;
- SwfdecBuffer *buffer;
- cairo_matrix_t matrix;
- guint gid;
-
- tmp = s->b;
- flags = swfdec_bits_get_u8 (&tmp);
- gid = swfdec_bits_get_u16 (&tmp);
- swfdec_bits_get_u16 (&tmp);
- swfdec_bits_get_matrix (&tmp, &matrix, NULL);
- buffer = swfdec_bits_get_buffer (&s->b, (swfdec_bits_left (&s->b) - swfdec_bits_left (&tmp)) / 8);
- if (buffer == NULL)
- break;
- button->records = g_slist_prepend (button->records, buffer);
- /* add hit state movies to button's extents */
- if (flags & (1 << SWFDEC_BUTTON_HIT)) {
- SwfdecGraphic *graphic = swfdec_swf_decoder_get_character (s, gid);
- if (SWFDEC_IS_GRAPHIC (graphic)) {
- SwfdecRect rect;
- swfdec_rect_transform (&rect, &graphic->extents, &matrix);
- swfdec_rect_union (&SWFDEC_GRAPHIC (button)->extents, &SWFDEC_GRAPHIC (button)->extents, &rect);
- } else {
- SWFDEC_ERROR ("graphic for id %u not found", gid);
- }
- }
- }
-
- swfdec_bits_get_u8 (&s->b);
- button->records = g_slist_reverse (button->records);
-
- if (swfdec_bits_peek_u8 (&s->b)) {
- char *script_name = g_strdup_printf ("Button%u", id);
- button->events = swfdec_event_list_new (SWFDEC_DECODER (s)->player);
- SWFDEC_LOG (" event for button press");
- swfdec_event_list_parse (button->events, &s->b, s->version, 1 << SWFDEC_EVENT_RELEASE,
- 0, script_name);
- g_free (script_name);
- } else {
- swfdec_bits_get_u8 (&s->b);
- }
- if (swfdec_bits_left (&s->b)) {
- SWFDEC_WARNING ("%u bytes left after parsing script", swfdec_bits_left (&s->b) / 8);
- }
-
- return SWFDEC_STATUS_OK;
-}
-
diff --git a/libswfdec/swfdec_button.h b/libswfdec/swfdec_button.h
deleted file mode 100644
index ddf5900..0000000
--- a/libswfdec/swfdec_button.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_BUTTON_H_
-#define _SWFDEC_BUTTON_H_
-
-#include <libswfdec/swfdec_graphic.h>
-#include <libswfdec/swfdec_color.h>
-
-G_BEGIN_DECLS
-//typedef struct _SwfdecButton SwfdecButton;
-typedef struct _SwfdecButtonClass SwfdecButtonClass;
-
-#define SWFDEC_TYPE_BUTTON (swfdec_button_get_type())
-#define SWFDEC_IS_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_BUTTON))
-#define SWFDEC_IS_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_BUTTON))
-#define SWFDEC_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_BUTTON, SwfdecButton))
-#define SWFDEC_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_BUTTON, SwfdecButtonClass))
-
-/* these values have to be kept in line with record parsing */
-typedef enum {
- SWFDEC_BUTTON_INIT = -1,
- SWFDEC_BUTTON_UP = 0,
- SWFDEC_BUTTON_OVER = 1,
- SWFDEC_BUTTON_DOWN = 2,
- SWFDEC_BUTTON_HIT = 3
-} SwfdecButtonState;
-
-/* these values have to be kept in line with condition parsing */
-typedef enum {
- SWFDEC_BUTTON_IDLE_TO_OVER_UP = 0,
- SWFDEC_BUTTON_OVER_UP_TO_IDLE = 1,
- SWFDEC_BUTTON_OVER_UP_TO_OVER_DOWN = 2,
- SWFDEC_BUTTON_OVER_DOWN_TO_OVER_UP = 3,
- SWFDEC_BUTTON_OVER_DOWN_TO_OUT_DOWN = 4,
- SWFDEC_BUTTON_OUT_DOWN_TO_OVER_DOWN = 5,
- SWFDEC_BUTTON_OUT_DOWN_TO_IDLE = 6,
- SWFDEC_BUTTON_IDLE_TO_OVER_DOWN = 7,
- SWFDEC_BUTTON_OVER_DOWN_TO_IDLE = 8
-} SwfdecButtonCondition;
-
-struct _SwfdecButton {
- SwfdecGraphic graphic; /* graphic->extents is used for HIT area extents only */
-
- gboolean menubutton; /* treat as menubutton */
-
- GSList * records; /* the contained objects */
- SwfdecEventList * events; /* the events triggered by this button */
- SwfdecSoundChunk * sounds[4]; /* for meaning of index see DefineButtonSound */
-};
-
-struct _SwfdecButtonClass
-{
- SwfdecGraphicClass graphic_class;
-};
-
-GType swfdec_button_get_type (void);
-
-int tag_func_define_button (SwfdecSwfDecoder * s,
- guint tag);
-int tag_func_define_button_2 (SwfdecSwfDecoder * s,
- guint tag);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_button_movie.c b/libswfdec/swfdec_button_movie.c
deleted file mode 100644
index e7ccdba..0000000
--- a/libswfdec/swfdec_button_movie.c
+++ /dev/null
@@ -1,320 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_button_movie.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_audio_event.h"
-#include "swfdec_debug.h"
-#include "swfdec_event.h"
-#include "swfdec_filter.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_resource.h"
-
-G_DEFINE_TYPE (SwfdecButtonMovie, swfdec_button_movie, SWFDEC_TYPE_MOVIE)
-
-static void
-swfdec_button_movie_update_extents (SwfdecMovie *movie,
- SwfdecRect *extents)
-{
- swfdec_rect_union (extents, extents,
- &SWFDEC_GRAPHIC (SWFDEC_BUTTON_MOVIE (movie)->button)->extents);
-}
-
-static void
-swfdec_button_movie_perform_place (SwfdecButtonMovie *button, SwfdecBits *bits)
-{
- SwfdecMovie *movie = SWFDEC_MOVIE (button);
- gboolean has_blend_mode, has_filters, v2;
- SwfdecColorTransform ctrans;
- SwfdecGraphic *graphic;
- SwfdecPlayer *player;
- cairo_matrix_t trans;
- guint id, blend_mode;
- SwfdecMovie *new;
- int depth;
-
- swfdec_bits_getbits (bits, 2); /* reserved */
- has_blend_mode = swfdec_bits_getbit (bits);
- has_filters = swfdec_bits_getbit (bits);
- SWFDEC_LOG (" has_blend_mode = %d", has_blend_mode);
- SWFDEC_LOG (" has_filters = %d", has_filters);
- swfdec_bits_getbits (bits, 4); /* states */
- id = swfdec_bits_get_u16 (bits);
- depth = swfdec_bits_get_u16 (bits);
- depth -= 16384;
- if (swfdec_movie_find (movie, depth)) {
- SWFDEC_WARNING ("depth %d already occupied, skipping placement.", depth + 16384);
- return;
- }
- graphic = swfdec_swf_decoder_get_character (SWFDEC_SWF_DECODER (movie->resource->decoder), id);
- if (!SWFDEC_IS_GRAPHIC (graphic)) {
- SWFDEC_ERROR ("id %u does not specify a graphic", id);
- return;
- }
-
- player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
- new = swfdec_movie_new (player, depth, movie, movie->resource, graphic, NULL);
- swfdec_bits_get_matrix (bits, &trans, NULL);
- if (swfdec_bits_left (bits)) {
- v2 = TRUE;
- swfdec_bits_get_color_transform (bits, &ctrans);
- if (has_blend_mode) {
- blend_mode = swfdec_bits_get_u8 (bits);
- SWFDEC_LOG (" blend mode = %u", blend_mode);
- } else {
- blend_mode = 0;
- }
- if (has_filters) {
- GSList *filters = swfdec_filter_parse (player, bits);
- g_slist_free (filters);
- }
- } else {
- /* DefineButton1 record */
- v2 = FALSE;
- if (has_blend_mode || has_filters) {
- SWFDEC_ERROR ("cool, a DefineButton1 with filters or blend mode");
- }
- blend_mode = 0;
- }
- swfdec_movie_set_static_properties (new, &trans, v2 ? &ctrans : NULL, 0, 0, blend_mode, NULL);
- swfdec_movie_queue_script (new, SWFDEC_EVENT_INITIALIZE);
- swfdec_movie_queue_script (new, SWFDEC_EVENT_CONSTRUCT);
- swfdec_movie_queue_script (new, SWFDEC_EVENT_LOAD);
- swfdec_movie_initialize (new);
- if (swfdec_bits_left (bits)) {
- SWFDEC_WARNING ("button record for id %u has %u bytes left", id,
- swfdec_bits_left (bits) / 8);
- }
-}
-
-static void
-swfdec_button_movie_set_state (SwfdecButtonMovie *button, SwfdecButtonState state)
-{
- SwfdecMovie *movie = SWFDEC_MOVIE (button);
- SwfdecMovie *child;
- SwfdecBits bits;
- GSList *walk;
- guint old, new, i;
- int depth;
-
- if (button->state == state) {
- SWFDEC_LOG ("not changing state, it's already in %d", state);
- return;
- }
- SWFDEC_DEBUG ("changing state from %d to %d", button->state, state);
- /* remove all movies that aren't in the new state */
- new = 1 << state;
- if (button->state >= 0) {
- old = 1 << button->state;
- for (walk = button->button->records; walk; walk = walk->next) {
- swfdec_bits_init (&bits, walk->data);
- i = swfdec_bits_get_u8 (&bits);
- if ((i & old) && !(i & new)) {
- swfdec_bits_get_u16 (&bits);
- depth = swfdec_bits_get_u16 (&bits);
- child = swfdec_movie_find (movie, depth - 16384);
- if (child) {
- swfdec_movie_remove (child);
- } else {
- SWFDEC_WARNING ("no child at depth %d, none removed", depth);
- }
- }
- }
- } else {
- /* to make sure that this never triggers when initializing */
- old = 0;
- }
- button->state = state;
- /* add all movies that are in the new state */
- for (walk = button->button->records; walk; walk = walk->next) {
- swfdec_bits_init (&bits, walk->data);
- i = swfdec_bits_peek_u8 (&bits);
- if ((i & old) || !(i & new))
- continue;
- swfdec_button_movie_perform_place (button, &bits);
- }
-}
-
-static gboolean
-swfdec_button_movie_mouse_events (SwfdecMovie *movie)
-{
- return TRUE;
-}
-
-static void
-swfdec_button_movie_mouse_in (SwfdecMovie *movie)
-{
- if (swfdec_player_is_mouse_pressed (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context)))
- swfdec_button_movie_set_state (SWFDEC_BUTTON_MOVIE (movie), SWFDEC_BUTTON_DOWN);
- else
- swfdec_button_movie_set_state (SWFDEC_BUTTON_MOVIE (movie), SWFDEC_BUTTON_OVER);
-
- SWFDEC_MOVIE_CLASS (swfdec_button_movie_parent_class)->mouse_in (movie);
-}
-
-static void
-swfdec_button_movie_mouse_out (SwfdecMovie *movie)
-{
- SwfdecButtonMovie *button = SWFDEC_BUTTON_MOVIE (movie);
-
- if (swfdec_player_is_mouse_pressed (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context))) {
- if (button->button->menubutton) {
- swfdec_button_movie_set_state (SWFDEC_BUTTON_MOVIE (movie), SWFDEC_BUTTON_UP);
- } else {
- swfdec_button_movie_set_state (SWFDEC_BUTTON_MOVIE (movie), SWFDEC_BUTTON_OVER);
- }
- } else {
- swfdec_button_movie_set_state (button, SWFDEC_BUTTON_UP);
- }
-
- SWFDEC_MOVIE_CLASS (swfdec_button_movie_parent_class)->mouse_out (movie);
-}
-
-static void
-swfdec_button_movie_mouse_press (SwfdecMovie *movie, guint button)
-{
- if (button != 0)
- return;
- swfdec_button_movie_set_state (SWFDEC_BUTTON_MOVIE (movie), SWFDEC_BUTTON_DOWN);
-
- SWFDEC_MOVIE_CLASS (swfdec_button_movie_parent_class)->mouse_press (movie, button);
-}
-
-static void
-swfdec_button_movie_mouse_release (SwfdecMovie *movie, guint button)
-{
- SwfdecPlayer *player;
-
- if (button != 0)
- return;
- player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
- if (player->priv->mouse_below == movie) {
- swfdec_button_movie_set_state (SWFDEC_BUTTON_MOVIE (movie), SWFDEC_BUTTON_OVER);
-
- SWFDEC_MOVIE_CLASS (swfdec_button_movie_parent_class)->mouse_release (movie, button);
- } else {
- swfdec_button_movie_set_state (SWFDEC_BUTTON_MOVIE (movie), SWFDEC_BUTTON_UP);
-
- /* NB: We don't chain to parent here for menubuttons*/
- if (!SWFDEC_BUTTON_MOVIE (movie)->button->menubutton)
- SWFDEC_MOVIE_CLASS (swfdec_button_movie_parent_class)->mouse_release (movie, button);
- }
-}
-
-static void
-swfdec_button_movie_init_movie (SwfdecMovie *mov)
-{
- SwfdecButtonMovie *movie = SWFDEC_BUTTON_MOVIE (mov);
-
- swfdec_button_movie_set_state (movie, SWFDEC_BUTTON_UP);
-}
-
-static gboolean
-swfdec_button_movie_hit_test (SwfdecButtonMovie *button, double x, double y)
-{
- SwfdecSwfDecoder *dec;
- GSList *walk;
- double tmpx, tmpy;
-
- dec = SWFDEC_SWF_DECODER (SWFDEC_MOVIE (button)->resource->decoder);
- for (walk = button->button->records; walk; walk = walk->next) {
- SwfdecGraphic *graphic;
- SwfdecBits bits;
- cairo_matrix_t matrix, inverse;
- guint id;
-
- swfdec_bits_init (&bits, walk->data);
-
- if ((swfdec_bits_get_u8 (&bits) & (1 << SWFDEC_BUTTON_HIT)) == 0)
- continue;
-
- id = swfdec_bits_get_u16 (&bits);
- swfdec_bits_get_u16 (&bits); /* depth */
- graphic = swfdec_swf_decoder_get_character (dec, id);
- if (!SWFDEC_IS_GRAPHIC (graphic)) {
- SWFDEC_ERROR ("id %u is no graphic", id);
- continue;
- }
- tmpx = x;
- tmpy = y;
- swfdec_bits_get_matrix (&bits, &matrix, &inverse);
- cairo_matrix_transform_point (&inverse, &tmpx, &tmpy);
-
- SWFDEC_LOG ("Checking button contents at %g %g (transformed from %g %g)", tmpx, tmpy, x, y);
- if (swfdec_graphic_mouse_in (graphic, tmpx, tmpy))
- return TRUE;
- SWFDEC_LOG (" missed");
- }
- return FALSE;
-}
-
-static SwfdecMovie *
-swfdec_button_movie_contains (SwfdecMovie *movie, double x, double y, gboolean events)
-{
- if (events) {
- /* check for movies in a higher layer that react to events */
- SwfdecMovie *ret;
- ret = SWFDEC_MOVIE_CLASS (swfdec_button_movie_parent_class)->contains (movie, x, y, TRUE);
- if (ret && ret != movie && swfdec_movie_get_mouse_events (ret))
- return ret;
- }
-
- return swfdec_button_movie_hit_test (SWFDEC_BUTTON_MOVIE (movie), x, y) ? movie : NULL;
-}
-
-static void
-swfdec_button_movie_dispose (GObject *object)
-{
- SwfdecButtonMovie *button = SWFDEC_BUTTON_MOVIE (object);
-
- if (button->button) {
- g_object_unref (button->button);
- button->button = NULL;
- }
- G_OBJECT_CLASS (swfdec_button_movie_parent_class)->dispose (object);
-}
-
-static void
-swfdec_button_movie_class_init (SwfdecButtonMovieClass * g_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (g_class);
- SwfdecMovieClass *movie_class = SWFDEC_MOVIE_CLASS (g_class);
-
- object_class->dispose = swfdec_button_movie_dispose;
- movie_class->init_movie = swfdec_button_movie_init_movie;
- movie_class->update_extents = swfdec_button_movie_update_extents;
- movie_class->contains = swfdec_button_movie_contains;
-
- movie_class->mouse_events = swfdec_button_movie_mouse_events;
- movie_class->mouse_in = swfdec_button_movie_mouse_in;
- movie_class->mouse_out = swfdec_button_movie_mouse_out;
- movie_class->mouse_press = swfdec_button_movie_mouse_press;
- movie_class->mouse_release = swfdec_button_movie_mouse_release;
-}
-
-static void
-swfdec_button_movie_init (SwfdecButtonMovie *movie)
-{
- movie->state = SWFDEC_BUTTON_INIT;
-}
-
diff --git a/libswfdec/swfdec_button_movie.h b/libswfdec/swfdec_button_movie.h
deleted file mode 100644
index 1f6dfaf..0000000
--- a/libswfdec/swfdec_button_movie.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_BUTTON_MOVIE_H_
-#define _SWFDEC_BUTTON_MOVIE_H_
-
-#include <glib-object.h>
-#include <libswfdec/swfdec_movie.h>
-#include <libswfdec/swfdec_button.h>
-
-G_BEGIN_DECLS
-
-
-typedef struct _SwfdecButtonMovie SwfdecButtonMovie;
-typedef struct _SwfdecButtonMovieClass SwfdecButtonMovieClass;
-
-#define SWFDEC_TYPE_BUTTON_MOVIE (swfdec_button_movie_get_type())
-#define SWFDEC_IS_BUTTON_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_BUTTON_MOVIE))
-#define SWFDEC_IS_BUTTON_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_BUTTON_MOVIE))
-#define SWFDEC_BUTTON_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_BUTTON_MOVIE, SwfdecButtonMovie))
-#define SWFDEC_BUTTON_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_BUTTON_MOVIE, SwfdecButtonMovieClass))
-
-struct _SwfdecButtonMovie {
- SwfdecMovie movie;
-
- SwfdecButton * button; /* button we render */
- SwfdecButtonState state; /* current state we're in */
-};
-
-struct _SwfdecButtonMovieClass {
- SwfdecMovieClass movie_class;
-};
-
-GType swfdec_button_movie_get_type (void);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_button_movie_as.c b/libswfdec/swfdec_button_movie_as.c
deleted file mode 100644
index c6c2f36..0000000
--- a/libswfdec/swfdec_button_movie_as.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-// properties
-SWFDEC_AS_NATIVE (105, 4, swfdec_button_get_scale9Grid)
-void
-swfdec_button_get_scale9Grid (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Button.scale9Grid (get)");
-}
-
-SWFDEC_AS_NATIVE (105, 5, swfdec_button_set_scale9Grid)
-void
-swfdec_button_set_scale9Grid (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Button.scale9Grid (set)");
-}
-
-SWFDEC_AS_NATIVE (105, 6, swfdec_button_get_filters)
-void
-swfdec_button_get_filters (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Button.filters (get)");
-}
-
-SWFDEC_AS_NATIVE (105, 7, swfdec_button_set_filters)
-void
-swfdec_button_set_filters (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Button.filters (set)");
-}
-
-SWFDEC_AS_NATIVE (105, 8, swfdec_button_get_cacheAsBitmap)
-void
-swfdec_button_get_cacheAsBitmap (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Button.cacheAsBitmap (get)");
-}
-
-SWFDEC_AS_NATIVE (105, 9, swfdec_button_set_cacheAsBitmap)
-void
-swfdec_button_set_cacheAsBitmap (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Button.cacheAsBitmap (set)");
-}
-
-SWFDEC_AS_NATIVE (105, 10, swfdec_button_get_blendMode)
-void
-swfdec_button_get_blendMode (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Button.blendMode (get)");
-}
-
-SWFDEC_AS_NATIVE (105, 11, swfdec_button_set_blendMode)
-void
-swfdec_button_set_blendMode (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Button.blendMode (set)");
-}
-
-// normal
-SWFDEC_AS_NATIVE (105, 3, swfdec_button_movie_getDepth)
-void
-swfdec_button_movie_getDepth (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Button.getDepth");
-}
-
-// constructor
-SWFDEC_AS_NATIVE (105, 0, swfdec_button_movie_construct)
-void
-swfdec_button_movie_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Button");
-}
diff --git a/libswfdec/swfdec_cache.c b/libswfdec/swfdec_cache.c
deleted file mode 100644
index 48104e6..0000000
--- a/libswfdec/swfdec_cache.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/* Swfdec
- * Copyright (C) 2005 David Schleef <ds at schleef.org>
- * 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_cache.h"
-#include "swfdec_debug.h"
-
-SwfdecCache *
-swfdec_cache_new (gulong max_size)
-{
- SwfdecCache *cache;
-
- g_return_val_if_fail (max_size > 0, NULL);
-
- cache = g_new0 (SwfdecCache, 1);
- cache->refcount = 1;
- cache->queue = g_queue_new ();
- cache->max_size = max_size;
-
- return cache;
-}
-
-void
-swfdec_cache_ref (SwfdecCache *cache)
-{
- g_return_if_fail (cache != NULL);
-
- cache->refcount++;
-}
-
-void
-swfdec_cache_unref (SwfdecCache *cache)
-{
- g_return_if_fail (cache != NULL);
- g_return_if_fail (cache->refcount > 0);
-
- cache->refcount--;
- if (cache->refcount > 0)
- return;
-
- g_queue_free (cache->queue);
- g_free (cache);
-}
-
-gulong
-swfdec_cache_get_usage (SwfdecCache *cache)
-{
- g_return_val_if_fail (cache != NULL, 0);
-
- return cache->usage;
-}
-
-void
-swfdec_cache_shrink (SwfdecCache *cache, gulong max_usage)
-{
- g_return_if_fail (cache != NULL);
-
- while (cache->usage > max_usage) {
- SwfdecCacheHandle *handle = g_queue_pop_tail (cache->queue);
- g_assert (handle);
- cache->usage -= handle->size;
- SWFDEC_LOG ("%p removing %p (%lu => %lu)", cache, handle,
- cache->usage + handle->size, cache->usage);
- handle->unload (handle);
- }
-}
-
-gulong
-swfdec_cache_get_size (SwfdecCache *cache)
-{
- g_return_val_if_fail (cache != NULL, 0);
-
- return cache->max_size;
-}
-
-void
-swfdec_cache_set_size (SwfdecCache *cache, gulong max_usage)
-{
- g_return_if_fail (cache != NULL);
-
- swfdec_cache_shrink (cache, max_usage);
- cache->max_size = max_usage;
-}
-
-/**
- * swfdec_cache_add_handle:
- * @cache: a #SwfdecCache
- * @handle: a handle to add
- *
- * Adds @handle to @cache. If not enough space is available in the cache,
- * the cache will unload existing handles first. If handle is already part
- * of cache, its usage information will be updated. This will make it less
- * likely that it gets unloaded.
- **/
-void
-swfdec_cache_add_handle (SwfdecCache *cache, const SwfdecCacheHandle *handle)
-{
- GList *list;
-
- g_return_if_fail (cache != NULL);
- g_return_if_fail (handle != NULL);
- g_return_if_fail (handle->size > 0);
- g_return_if_fail (handle->unload != NULL);
-
- list = g_queue_find (cache->queue, handle);
- if (list) {
- /* bring to front of queue */
- g_queue_unlink (cache->queue, list);
- g_queue_push_head_link (cache->queue, list);
- } else {
- swfdec_cache_shrink (cache, cache->max_size - handle->size);
- g_queue_push_head (cache->queue, (gpointer) handle);
- cache->usage += handle->size;
- SWFDEC_LOG ("%p adding %p (%lu => %lu)", cache, handle,
- cache->usage - handle->size, cache->usage);
- }
-}
-
-/**
- * swfdec_cache_remove_handle:
- * @cache: a #SwfdecCache
- * @handle: the handle to remove
- *
- * Removes the given @handle from the @cache, if it was part of it. If the
- * handle wasn't part of the cache, nothing happens.
- **/
-void
-swfdec_cache_remove_handle (SwfdecCache *cache, const SwfdecCacheHandle *handle)
-{
- GList *list;
-
- g_return_if_fail (cache != NULL);
- g_return_if_fail (handle != NULL);
- g_return_if_fail (handle->size > 0);
- g_return_if_fail (handle->unload != NULL);
-
- list = g_queue_find (cache->queue, handle);
- if (list) {
- g_queue_delete_link (cache->queue, list);
- cache->usage -= handle->size;
- SWFDEC_LOG ("%p removing %p (%lu => %lu)", cache, handle,
- cache->usage + handle->size, cache->usage);
- }
-}
diff --git a/libswfdec/swfdec_cache.h b/libswfdec/swfdec_cache.h
deleted file mode 100644
index 5e58aa4..0000000
--- a/libswfdec/swfdec_cache.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Swfdec
- * Copyright (C) 2005 David Schleef <ds at schleef.org>
- * 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_CACHE_H_
-#define _SWFDEC_CACHE_H_
-
-#include <libswfdec/swfdec_types.h>
-
-G_BEGIN_DECLS
-
-//typedef struct _SwfdecCache SwfdecCache;
-//typedef struct _SwfdecCacheHandle SwfdecCacheHandle;
-
-struct _SwfdecCache {
- guint refcount; /* reference count */
- gulong max_size; /* max size of cache */
- gulong usage; /* current size of cache */
-
- GQueue * queue; /* queue of loaded SwfdecCacheHandle, sorted by most recently used */
-};
-
-struct _SwfdecCacheHandle {
- gulong size; /* size of this item */
-
- GDestroyNotify unload; /* function called when unloading this handle */
-};
-
-SwfdecCache * swfdec_cache_new (gulong max_size);
-void swfdec_cache_ref (SwfdecCache * cache);
-void swfdec_cache_unref (SwfdecCache * cache);
-
-gulong swfdec_cache_get_size (SwfdecCache * cache);
-void swfdec_cache_set_size (SwfdecCache * cache,
- gulong max_usage);
-gulong swfdec_cache_get_usage (SwfdecCache * cache);
-void swfdec_cache_shrink (SwfdecCache * cache,
- gulong max_usage);
-void swfdec_cache_add_handle (SwfdecCache * cache,
- const SwfdecCacheHandle *handle);
-void swfdec_cache_remove_handle (SwfdecCache * cache,
- const SwfdecCacheHandle *handle);
-
-
-G_END_DECLS
-
-#endif
diff --git a/libswfdec/swfdec_cached.c b/libswfdec/swfdec_cached.c
deleted file mode 100644
index 4279d1e..0000000
--- a/libswfdec/swfdec_cached.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_cached.h"
-#include "swfdec_debug.h"
-
-
-G_DEFINE_ABSTRACT_TYPE (SwfdecCached, swfdec_cached, SWFDEC_TYPE_CHARACTER)
-
-static void
-swfdec_cached_dispose (GObject *object)
-{
- SwfdecCached * cached = SWFDEC_CACHED (object);
-
- swfdec_cached_unload (cached);
- swfdec_cached_set_cache (cached, NULL);
-
- G_OBJECT_CLASS (swfdec_cached_parent_class)->dispose (object);
-}
-
-static void
-swfdec_cached_class_init (SwfdecCachedClass * g_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (g_class);
-
- object_class->dispose = swfdec_cached_dispose;
-}
-
-static void
-swfdec_cached_init (SwfdecCached * cached)
-{
-}
-
-void
-swfdec_cached_set_cache (SwfdecCached *cached, SwfdecCache *cache)
-{
- g_return_if_fail (SWFDEC_IS_CACHED (cached));
-
- if (cached->cache) {
- if (cached->handle.unload)
- swfdec_cache_remove_handle (cached->cache, &cached->handle);
- swfdec_cache_unref (cached->cache);
- }
- cached->cache = cache;
- if (cache) {
- swfdec_cache_ref (cache);
- if (cached->handle.unload)
- swfdec_cache_add_handle (cached->cache, &cached->handle);
- }
-}
-
-static void
-swfdec_cached_unload_func (gpointer data)
-{
- SwfdecCached *cached = SWFDEC_CACHED ((void *) ((guint8 *) data - G_STRUCT_OFFSET (SwfdecCached, handle)));
-
- cached->handle.unload = NULL;
- swfdec_cached_unload (cached);
-}
-
-void
-swfdec_cached_load (SwfdecCached *cached, guint size)
-{
- g_return_if_fail (SWFDEC_IS_CACHED (cached));
- g_return_if_fail (cached->handle.unload == NULL);
- g_return_if_fail (size > 0);
-
- cached->handle.unload = swfdec_cached_unload_func;
- cached->handle.size = size;
- if (cached->cache)
- swfdec_cache_add_handle (cached->cache, &cached->handle);
-}
-
-void
-swfdec_cached_use (SwfdecCached *cached)
-{
- g_return_if_fail (SWFDEC_IS_CACHED (cached));
- g_return_if_fail (cached->handle.unload != NULL);
-
- if (cached->cache)
- swfdec_cache_add_handle (cached->cache, &cached->handle);
-}
-
-void
-swfdec_cached_unload (SwfdecCached *cached)
-{
- g_return_if_fail (SWFDEC_IS_CACHED (cached));
-
- if (cached->handle.unload) {
- if (cached->cache)
- swfdec_cache_remove_handle (cached->cache, &cached->handle);
- cached->handle.unload = NULL;
- }
- if (cached->handle.size) {
- SwfdecCachedClass *klass;
-
- klass = SWFDEC_CACHED_GET_CLASS (cached);
- cached->handle.size = 0;
- g_return_if_fail (klass->unload != NULL);
- klass->unload (cached);
- }
-}
-
diff --git a/libswfdec/swfdec_cached.h b/libswfdec/swfdec_cached.h
deleted file mode 100644
index bc9a1f7..0000000
--- a/libswfdec/swfdec_cached.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Swfdec
- * Copyright (c) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_CACHED_H_
-#define _SWFDEC_CACHED_H_
-
-#include <cairo.h>
-#include <libswfdec/swfdec_cache.h>
-#include <libswfdec/swfdec_character.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecCached SwfdecCached;
-typedef struct _SwfdecCachedClass SwfdecCachedClass;
-
-#define SWFDEC_TYPE_CACHED (swfdec_cached_get_type())
-#define SWFDEC_IS_CACHED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_CACHED))
-#define SWFDEC_IS_CACHED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_CACHED))
-#define SWFDEC_CACHED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_CACHED, SwfdecCached))
-#define SWFDEC_CACHED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_CACHED, SwfdecCachedClass))
-#define SWFDEC_CACHED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_CACHED, SwfdecCachedClass))
-
-
-struct _SwfdecCached {
- SwfdecCharacter character;
-
- SwfdecCache * cache; /* cache to use for cached */
- SwfdecCacheHandle handle; /* handle to unload surface */
-};
-
-struct _SwfdecCachedClass
-{
- SwfdecCharacterClass character_class;
-
- void (* unload) (SwfdecCached * cached);
-};
-
-GType swfdec_cached_get_type (void);
-
-void swfdec_cached_load (SwfdecCached * cached,
- guint size);
-void swfdec_cached_use (SwfdecCached * cached);
-void swfdec_cached_unload (SwfdecCached * cached);
-void swfdec_cached_set_cache (SwfdecCached * cached,
- SwfdecCache * cache);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_camera.c b/libswfdec/swfdec_camera.c
deleted file mode 100644
index 96b6e42..0000000
--- a/libswfdec/swfdec_camera.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (2102, 200, swfdec_camera_get)
-void
-swfdec_camera_get (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Camera.get (static)");
-}
-
-SWFDEC_AS_NATIVE (2102, 201, swfdec_camera_names_get)
-void
-swfdec_camera_names_get (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Camera.names (static)");
-}
-
-SWFDEC_AS_NATIVE (2102, 0, swfdec_camera_setMode)
-void
-swfdec_camera_setMode (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Camera.setMode");
-}
-
-SWFDEC_AS_NATIVE (2102, 1, swfdec_camera_setQuality)
-void
-swfdec_camera_setQuality (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Camera.setQuality");
-}
-
-SWFDEC_AS_NATIVE (2102, 2, swfdec_camera_setKeyFrameInterval)
-void
-swfdec_camera_setKeyFrameInterval (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Camera.setKeyFrameInterval");
-}
-
-SWFDEC_AS_NATIVE (2102, 3, swfdec_camera_setMotionLevel)
-void
-swfdec_camera_setMotionLevel (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Camera.setMotionLevel");
-}
-
-SWFDEC_AS_NATIVE (2102, 4, swfdec_camera_setLoopback)
-void
-swfdec_camera_setLoopback (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Camera.setLoopback");
-}
-
-SWFDEC_AS_NATIVE (2102, 5, swfdec_camera_setCursor)
-void
-swfdec_camera_setCursor (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Camera.setCursor");
-}
diff --git a/libswfdec/swfdec_character.c b/libswfdec/swfdec_character.c
deleted file mode 100644
index db1aff5..0000000
--- a/libswfdec/swfdec_character.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_character.h"
-#include "swfdec_debug.h"
-#include "swfdec_decoder.h"
-
-
-G_DEFINE_ABSTRACT_TYPE (SwfdecCharacter, swfdec_character, G_TYPE_OBJECT)
-
-static void
-swfdec_character_class_init (SwfdecCharacterClass *klass)
-{
-}
-
-static void
-swfdec_character_init (SwfdecCharacter *character)
-{
-}
-
diff --git a/libswfdec/swfdec_character.h b/libswfdec/swfdec_character.h
deleted file mode 100644
index 50b577b..0000000
--- a/libswfdec/swfdec_character.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_CHARACTER_H_
-#define _SWFDEC_CHARACTER_H_
-
-#include <glib-object.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_rect.h>
-
-G_BEGIN_DECLS
-//typedef struct _SwfdecCharacter SwfdecCharacter;
-typedef struct _SwfdecCharacterClass SwfdecCharacterClass;
-
-#define SWFDEC_TYPE_CHARACTER (swfdec_character_get_type())
-#define SWFDEC_IS_CHARACTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_CHARACTER))
-#define SWFDEC_IS_CHARACTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_CHARACTER))
-#define SWFDEC_CHARACTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_CHARACTER, SwfdecCharacter))
-#define SWFDEC_CHARACTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_CHARACTER, SwfdecCharacterClass))
-#define SWFDEC_CHARACTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_CHARACTER, SwfdecCharacterClass))
-
-struct _SwfdecCharacter
-{
- GObject object;
-
- int id; /* id of this character in the character list */
-};
-
-struct _SwfdecCharacterClass
-{
- GObjectClass object_class;
-};
-
-GType swfdec_character_get_type (void);
-gpointer swfdec_character_new (SwfdecDecoder *dec, GType type);
-
-gboolean swfdec_character_mouse_in (SwfdecCharacter *character,
- double x, double y, int button);
-void swfdec_character_render (SwfdecCharacter *character, cairo_t *cr,
- const SwfdecColorTransform *color, const SwfdecRect *inval, gboolean fill);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_codec_adpcm.c b/libswfdec/swfdec_codec_adpcm.c
deleted file mode 100644
index 0aa39ab..0000000
--- a/libswfdec/swfdec_codec_adpcm.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_codec_audio.h"
-#include "swfdec_bits.h"
-#include "swfdec_debug.h"
-#include "swfdec_internal.h"
-
-typedef struct {
- SwfdecAudioDecoder decoder;
- SwfdecBufferQueue * queue;
-} SwfdecAudioDecoderAdpcm;
-
-static const int indexTable[4][16] = {
- { -1, 2 },
- { -1, -1, 2, 4 },
- { -1, -1, -1, -1, 2, 4, 6, 8 },
- { -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16 }
-};
-
-static const int stepSizeTable[89] = {
- 7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
- 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
- 50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
- 130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
- 337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
- 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
- 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
- 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
- 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
-};
-
-static SwfdecBuffer *
-swfdec_audio_decoder_adpcm_decode_chunk (SwfdecBits *bits, guint n_bits, guint channels)
-{
- SwfdecBuffer *ret;
- guint len;
- guint i, j, ch;
- guint index[2];
- int pred[2];
- gint16 *out;
- guint delta, sign, sign_mask;
- int diff;
- const int *realIndexTable;
- guint step[2];
-
- realIndexTable = indexTable[n_bits - 2];
- for (ch = 0; ch < channels; ch++) {
- /* can't use get_s16 here since that would be aligned */
- pred[ch] = swfdec_bits_getsbits (bits, 16);
- index[ch] = swfdec_bits_getbits (bits, 6);
- if (index[ch] >= G_N_ELEMENTS (stepSizeTable)) {
- SWFDEC_ERROR ("initial index too big: %u, max allowed is %td",
- index[ch], G_N_ELEMENTS (stepSizeTable) - 1);
- index[ch] = G_N_ELEMENTS (stepSizeTable) - 1;
- }
- step[ch] = stepSizeTable[index[ch]];
- }
- len = swfdec_bits_left (bits) / channels / n_bits;
- len = MIN (len, 4095);
- ret = swfdec_buffer_new_and_alloc ((len + 1) * sizeof (gint16) * channels);
- out = (gint16 *) (void *) ret->data;
- /* output initial value */
- SWFDEC_LOG ("decoding %u samples", len + 1);
- for (ch = 0; ch < channels; ch++)
- *out++ = pred[ch];
- sign_mask = 1 << (n_bits - 1);
- for (i = 0; i < len; i++) {
- for (ch = 0; ch < channels; ch++) {
- /* Step 1 - get the delta value */
- delta = swfdec_bits_getbits (bits, n_bits);
-
- /* Step 2 - Separate sign and magnitude */
- sign = delta & sign_mask;
- delta -= sign;
-
- /* Step 3 - Find new index value (for later) */
- index[ch] += realIndexTable[delta];
- if ( index[ch] >= G_MAXINT ) index[ch] = 0; /* underflow */
- if ( index[ch] >= G_N_ELEMENTS (stepSizeTable) ) index[ch] = G_N_ELEMENTS (stepSizeTable) - 1;
-
- /* Step 4 - Compute difference and new predicted value */
- j = n_bits - 1;
- diff = step[ch] >> j;
- do {
- j--;
- if (delta & 1)
- diff += step[ch] >> j;
- delta >>= 1;
- } while (j > 0 && delta);
-
- if ( sign )
- pred[ch] -= diff;
- else
- pred[ch] += diff;
-
- /* Step 5 - clamp output value */
- pred[ch] = CLAMP (pred[ch], -32768, 32767);
-
- /* Step 6 - Update step value */
- step[ch] = stepSizeTable[index[ch]];
-
- /* Step 7 - Output value */
- *out++ = pred[ch];
- }
- }
- return ret;
-}
-
-static void
-swfdec_audio_decoder_adpcm_push (SwfdecAudioDecoder *dec, SwfdecBuffer *buffer)
-{
- SwfdecAudioDecoderAdpcm *adpcm = (SwfdecAudioDecoderAdpcm *) dec;
- guint channels, n_bits;
- SwfdecBits bits;
-
- if (buffer == NULL)
- return;
-
- channels = swfdec_audio_format_get_channels (dec->format);
- swfdec_bits_init (&bits, buffer);
- n_bits = swfdec_bits_getbits (&bits, 2) + 2;
- SWFDEC_DEBUG ("starting decoding: %u channels, %u bits", channels, n_bits);
- /* 22 is minimum required header size */
- while (swfdec_bits_left (&bits) >= 22) {
- buffer = swfdec_audio_decoder_adpcm_decode_chunk (&bits, n_bits, channels);
- if (buffer)
- swfdec_buffer_queue_push (adpcm->queue, buffer);
- }
-}
-
-static SwfdecBuffer *
-swfdec_audio_decoder_adpcm_pull (SwfdecAudioDecoder *dec)
-{
- SwfdecAudioDecoderAdpcm *adpcm = (SwfdecAudioDecoderAdpcm *) dec;
-
- return swfdec_buffer_queue_pull_buffer (adpcm->queue);
-}
-
-static void
-swfdec_audio_decoder_adpcm_free (SwfdecAudioDecoder *dec)
-{
- SwfdecAudioDecoderAdpcm *adpcm = (SwfdecAudioDecoderAdpcm *) dec;
-
- swfdec_buffer_queue_unref (adpcm->queue);
- g_slice_free (SwfdecAudioDecoderAdpcm, adpcm);
-}
-
-SwfdecAudioDecoder *
-swfdec_audio_decoder_adpcm_new (guint type, SwfdecAudioFormat format)
-{
- SwfdecAudioDecoderAdpcm *adpcm;
-
- if (type != SWFDEC_AUDIO_CODEC_ADPCM)
- return NULL;
- adpcm = g_slice_new (SwfdecAudioDecoderAdpcm);
- adpcm->decoder.format = swfdec_audio_format_new (swfdec_audio_format_get_rate (format),
- swfdec_audio_format_get_channels (format), TRUE);
- adpcm->decoder.push = swfdec_audio_decoder_adpcm_push;
- adpcm->decoder.pull = swfdec_audio_decoder_adpcm_pull;
- adpcm->decoder.free = swfdec_audio_decoder_adpcm_free;
- adpcm->queue = swfdec_buffer_queue_new ();
-
- return &adpcm->decoder;
-}
-
diff --git a/libswfdec/swfdec_codec_audio.c b/libswfdec/swfdec_codec_audio.c
deleted file mode 100644
index 34edbe9..0000000
--- a/libswfdec/swfdec_codec_audio.c
+++ /dev/null
@@ -1,284 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_codec_audio.h"
-#include "swfdec_debug.h"
-#include "swfdec_internal.h"
-
-/*** UNCOMPRESSED SOUND ***/
-
-typedef struct {
- SwfdecAudioDecoder decoder;
- SwfdecBufferQueue * queue; /* queue collecting output buffers */
-} SwfdecAudioDecoderUncompressed;
-
-static void
-swfdec_audio_decoder_uncompressed_decode_8bit (SwfdecAudioDecoder *decoder,
- SwfdecBuffer *buffer)
-{
- SwfdecBuffer *ret;
- gint16 *out;
- guint8 *in;
- guint i;
-
- if (buffer == NULL)
- return;
-
- ret = swfdec_buffer_new_and_alloc (buffer->length * 2);
- out = (gint16 *) (void *) ret->data;
- in = buffer->data;
- for (i = 0; i < buffer->length; i++) {
- *out = ((gint16) *in << 8) ^ (-1);
- out++;
- in++;
- }
- swfdec_buffer_queue_push (((SwfdecAudioDecoderUncompressed *) decoder)->queue, ret);
-}
-
-static void
-swfdec_audio_decoder_uncompressed_decode_16bit (SwfdecAudioDecoder *decoder,
- SwfdecBuffer *buffer)
-{
- if (buffer == NULL)
- return;
-
- swfdec_buffer_ref (buffer);
- swfdec_buffer_queue_push (((SwfdecAudioDecoderUncompressed *) decoder)->queue, buffer);
-}
-
-static SwfdecBuffer *
-swfdec_audio_decoder_uncompressed_pull (SwfdecAudioDecoder *decoder)
-{
- SwfdecAudioDecoderUncompressed *dec = (SwfdecAudioDecoderUncompressed *) decoder;
-
- return swfdec_buffer_queue_pull_buffer (dec->queue);
-}
-
-static void
-swfdec_audio_decoder_uncompressed_free (SwfdecAudioDecoder *decoder)
-{
- SwfdecAudioDecoderUncompressed *dec = (SwfdecAudioDecoderUncompressed *) decoder;
-
- swfdec_buffer_queue_unref (dec->queue);
- g_free (dec);
-}
-
-static SwfdecAudioDecoder *
-swfdec_audio_decoder_uncompressed_new (guint type, SwfdecAudioFormat format)
-{
- SwfdecAudioDecoderUncompressed *dec;
-
- if (type != SWFDEC_AUDIO_CODEC_UNDEFINED &&
- type != SWFDEC_AUDIO_CODEC_UNCOMPRESSED)
- return NULL;
- if (type == SWFDEC_AUDIO_CODEC_UNDEFINED) {
- SWFDEC_WARNING ("endianness of audio unknown, assuming little endian");
- }
- dec = g_new (SwfdecAudioDecoderUncompressed, 1);
- dec->decoder.format = format;
- if (swfdec_audio_format_is_16bit (format))
- dec->decoder.push = swfdec_audio_decoder_uncompressed_decode_16bit;
- else
- dec->decoder.push = swfdec_audio_decoder_uncompressed_decode_8bit;
- dec->decoder.pull = swfdec_audio_decoder_uncompressed_pull;
- dec->decoder.free = swfdec_audio_decoder_uncompressed_free;
- dec->queue = swfdec_buffer_queue_new ();
-
- return &dec->decoder;
-}
-
-/*** PUBLIC API ***/
-
-static SwfdecAudioDecoder *
-swfdec_audio_decoder_builtin_new (guint codec, SwfdecAudioFormat format)
-{
- SwfdecAudioDecoder *ret;
-
- ret = swfdec_audio_decoder_uncompressed_new (codec, format);
- if (ret == NULL)
- ret = swfdec_audio_decoder_adpcm_new (codec, format);
-
- return ret;
-}
-
-struct {
- const char * name;
- SwfdecAudioDecoder * (* func) (guint, SwfdecAudioFormat);
-} audio_codecs[] = {
- { "builtin", swfdec_audio_decoder_builtin_new },
-#ifdef HAVE_GST
- { "gst", swfdec_audio_decoder_gst_new },
-#endif
-#ifdef HAVE_MAD
- { "mad", swfdec_audio_decoder_mad_new },
-#endif
-#ifdef HAVE_FFMPEG
- { "ffmpeg", swfdec_audio_decoder_ffmpeg_new },
-#endif
- { NULL, }
-};
-
-/**
- * swfdec_audio_decoder_new:
- * @format: #SwfdecAudioCodec to decode
- *
- * Creates a decoder suitable for decoding @format. If no decoder is available
- * for the given for mat, %NULL is returned.
- *
- * Returns: a new decoder or %NULL
- **/
-SwfdecAudioDecoder *
-swfdec_audio_decoder_new (guint codec, SwfdecAudioFormat format)
-{
- SwfdecAudioDecoder *ret;
- const char *list;
-
- g_return_val_if_fail (SWFDEC_IS_AUDIO_FORMAT (format), NULL);
-
- list = g_getenv ("SWFDEC_CODEC_AUDIO");
- if (list == NULL)
- list = g_getenv ("SWFDEC_CODEC");
- if (list == NULL) {
- guint i;
- ret = NULL;
- for (i = 0; audio_codecs[i].name != NULL; i++) {
- ret = audio_codecs[i].func (codec, format);
- if (ret)
- break;
- }
- } else {
- char **split = g_strsplit (list, ",", -1);
- guint i, j;
- ret = NULL;
- SWFDEC_LOG ("codecs limited to \"%s\"", list);
- for (i = 0; split[i] != NULL && ret == NULL; i++) {
- for (j = 0; audio_codecs[j].name != NULL; j++) {
- if (g_ascii_strcasecmp (audio_codecs[j].name, split[i]) != 0)
- continue;
- ret = audio_codecs[j].func (codec, format);
- if (ret)
- break;
- }
- }
- g_strfreev (split);
- }
-
- if (ret) {
- ret->codec = codec;
- g_return_val_if_fail (ret->push, NULL);
- g_return_val_if_fail (ret->pull, NULL);
- g_return_val_if_fail (ret->free, NULL);
- } else {
- SWFDEC_ERROR ("no suitable decoder for audio codec %u", codec);
- return NULL;
- }
- return ret;
-}
-
-/**
- * swfdec_audio_decoder_free:
- * @decoder: a #SwfdecAudioDecoder
- *
- * Frees the given decoder. When finishing decoding, be sure to pass a %NULL
- * buffer to swfdec_audio_decoder_push() first to flush the decoder. See that
- * function for details.
- **/
-void
-swfdec_audio_decoder_free (SwfdecAudioDecoder *decoder)
-{
- g_return_if_fail (decoder != NULL);
-
- decoder->free (decoder);
-}
-
-/**
- * swfdec_audio_decoder_get_format:
- * @decoder: a #SwfdecAudioDecoder
- *
- * Queries the format that is used by the decoder for its produced output.
- * The format will only be valid after swfdec_audio_decoder_pull () has been
- * called at least once.
- *
- * Returns: the format of the decoded data
- **/
-SwfdecAudioFormat
-swfdec_audio_decoder_get_format (SwfdecAudioDecoder *decoder)
-{
- g_return_val_if_fail (decoder != NULL, 0);
- g_return_val_if_fail (SWFDEC_IS_AUDIO_FORMAT (decoder->format), 0);
-
- return decoder->format;
-}
-
-/**
- * swfdec_audio_decoder_push:
- * @decoder: a #SwfdecAudioDecoder
- * @buffer: a #SwfdecBuffer to process or %NULL to flush
- *
- * Pushes a new buffer into the decoding pipeline. After this the results can
- * be queried using swfdec_audio_decoder_pull(). Some decoders may not decode
- * all available data immediately. So when you are done decoding, you may want
- * to flush the decoder. Flushing can be achieved by passing %NULL as the
- * @buffer argument. Do this when you are finished decoding.
- **/
-void
-swfdec_audio_decoder_push (SwfdecAudioDecoder *decoder, SwfdecBuffer *buffer)
-{
- g_return_if_fail (decoder != NULL);
-
- decoder->push (decoder, buffer);
-}
-
-/**
- * swfdec_audio_decoder_pull:
- * @decoder: a #SwfdecAudioDecoder
- *
- * Gets the next buffer of decoded audio data. Since some decoders do not
- * produce one output buffer per input buffer, any number of buffers may be
- * available after calling swfdec_audio_decoder_push(), even none. When no more
- * buffers are available, this function returns %NULL. You need to provide more
- * input in then. A simple decoding pipeline would look like this:
- * <informalexample><programlisting>do {
- * input = next_input_buffer ();
- * swfdec_audio_decoder_push (decoder, input);
- * while ((output = swfdec_audio_decoder_pull (decoder))) {
- * ... process output ...
- * }
- * } while (input != NULL); </programlisting></informalexample>
- *
- * Returns: the next buffer or %NULL if no more buffers are available.
- **/
-SwfdecBuffer *
-swfdec_audio_decoder_pull (SwfdecAudioDecoder *decoder)
-{
- SwfdecBuffer *ret;
-
- g_return_val_if_fail (decoder != NULL, NULL);
-
- ret = decoder->pull (decoder);
- if (ret == NULL)
- return NULL;
- g_return_val_if_fail (SWFDEC_IS_AUDIO_FORMAT (decoder->format), ret);
- return ret;
-}
-
diff --git a/libswfdec/swfdec_codec_audio.h b/libswfdec/swfdec_codec_audio.h
deleted file mode 100644
index 48eb139..0000000
--- a/libswfdec/swfdec_codec_audio.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_CODEC_H_
-#define _SWFDEC_CODEC_H_
-
-#include <glib.h>
-#include <libswfdec/swfdec_audio_internal.h>
-#include <libswfdec/swfdec_buffer.h>
-
-typedef struct _SwfdecAudioDecoder SwfdecAudioDecoder;
-
-#define SWFDEC_AUDIO_CODEC_UNDEFINED 0
-#define SWFDEC_AUDIO_CODEC_ADPCM 1
-#define SWFDEC_AUDIO_CODEC_MP3 2
-#define SWFDEC_AUDIO_CODEC_UNCOMPRESSED 3
-#define SWFDEC_AUDIO_CODEC_NELLYMOSER_8KHZ 5
-#define SWFDEC_AUDIO_CODEC_NELLYMOSER 6
-
-typedef SwfdecAudioDecoder * (SwfdecAudioDecoderNewFunc) (guint type, gboolean width,
- SwfdecAudioFormat format);
-struct _SwfdecAudioDecoder {
- guint codec;
- SwfdecAudioFormat format;
- void (* push) (SwfdecAudioDecoder * decoder,
- SwfdecBuffer * buffer);
- SwfdecBuffer * (* pull) (SwfdecAudioDecoder * decoder);
- void (* free) (SwfdecAudioDecoder * decoder);
-};
-
-SwfdecAudioDecoder * swfdec_audio_decoder_new (guint codec,
- SwfdecAudioFormat format);
-void swfdec_audio_decoder_free (SwfdecAudioDecoder * decoder);
-SwfdecAudioFormat swfdec_audio_decoder_get_format (SwfdecAudioDecoder * decoder);
-void swfdec_audio_decoder_push (SwfdecAudioDecoder * decoder,
- SwfdecBuffer * buffer);
-SwfdecBuffer * swfdec_audio_decoder_pull (SwfdecAudioDecoder * decoder);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_codec_ffmpeg.c b/libswfdec/swfdec_codec_ffmpeg.c
deleted file mode 100644
index 9e159d3..0000000
--- a/libswfdec/swfdec_codec_ffmpeg.c
+++ /dev/null
@@ -1,317 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <string.h>
-#include <avcodec.h>
-#include <swscale.h>
-
-#include "swfdec_codec_audio.h"
-#include "swfdec_codec_video.h"
-#include "swfdec_debug.h"
-#include "swfdec_internal.h"
-
-/*** GENERAL ***/
-
-static AVCodecContext *
-swfdec_codec_ffmpeg_init (enum CodecID id)
-{
- AVCodec *codec;
- AVCodecContext *ctx;
- static gboolean initialized = FALSE;
-
- if (!initialized) {
- avcodec_init();
- avcodec_register_all ();
- initialized = TRUE;
- }
-
- codec = avcodec_find_decoder (id);
- if (!codec)
- return NULL;
-
- ctx = avcodec_alloc_context ();
- if (avcodec_open (ctx, codec) < 0)
- goto fail;
-
- return ctx;
-fail:
- SWFDEC_ERROR ("failed to initialize playback via ffmpeg");
- avcodec_close (ctx);
- av_free (ctx);
- return NULL;
-}
-
-/*** AUDIO ***/
-
-typedef struct {
- SwfdecAudioDecoder decoder;
- AVCodecContext * ctx;
- SwfdecBufferQueue * queue;
-} SwfdecAudioDecoderFFMpeg;
-
-static SwfdecBuffer *
-swfdec_codec_ffmpeg_convert (AVCodecContext *ctx, SwfdecBuffer *buffer)
-{
- SwfdecBuffer *ret;
- guint count, i, j, rate;
- gint16 *out, *in;
-
- /* do the common case fast */
- if (ctx->channels == 2 && ctx->sample_rate == 44100) {
- ret = swfdec_buffer_new_and_alloc (buffer->length);
- memcpy (ret->data, buffer->data, buffer->length);
- return ret;
- }
-
- switch (ctx->sample_rate) {
- case 44100:
- rate = 1;
- break;
- case 22050:
- rate = 2;
- break;
- case 11025:
- rate = 4;
- break;
- default:
- SWFDEC_ERROR ("unsupported sample rate %u", ctx->sample_rate);
- return NULL;
- }
- if (ctx->channels == 1)
- rate *= 2;
- ret = swfdec_buffer_new_and_alloc (buffer->length * rate);
- out = (gint16 *) ret->data;
- in = (gint16 *) buffer->data;
- count = buffer->length / 2;
-
- for (i = 0; i < count; i++) {
- for (j = 0; j < rate; j++) {
- *out++ = *in;
- }
- in++;
- }
- return ret;
-}
-
-static void
-swfdec_audio_decoder_ffmpeg_push (SwfdecAudioDecoder *dec, SwfdecBuffer *buffer)
-{
- SwfdecAudioDecoderFFMpeg *ffmpeg = (SwfdecAudioDecoderFFMpeg *) dec;
- int out_size;
- int len;
- guint amount;
- SwfdecBuffer *outbuf = NULL;
-
- if (buffer == NULL)
- return;
- outbuf = swfdec_buffer_new_and_alloc (AVCODEC_MAX_AUDIO_FRAME_SIZE);
- for (amount = 0; amount < buffer->length; amount += len) {
-
- out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
- len = avcodec_decode_audio2 (ffmpeg->ctx, (short *) outbuf->data, &out_size, buffer->data + amount, buffer->length - amount);
-
- if (len < 0) {
- SWFDEC_ERROR ("Error %d while decoding", len);
- swfdec_buffer_unref (outbuf);
- return;
- }
- if (out_size > 0) {
- SwfdecBuffer *convert;
- outbuf->length = out_size;
- convert = swfdec_codec_ffmpeg_convert (ffmpeg->ctx, outbuf);
- if (convert == NULL) {
- swfdec_buffer_unref (outbuf);
- return;
- }
- swfdec_buffer_queue_push (ffmpeg->queue, convert);
- outbuf->length = AVCODEC_MAX_AUDIO_FRAME_SIZE;
- }
- }
- swfdec_buffer_unref (outbuf);
-}
-
-static SwfdecBuffer *
-swfdec_audio_decoder_ffmpeg_pull (SwfdecAudioDecoder *dec)
-{
- SwfdecAudioDecoderFFMpeg *ffmpeg = (SwfdecAudioDecoderFFMpeg *) dec;
-
- return swfdec_buffer_queue_pull_buffer (ffmpeg->queue);
-}
-
-static void
-swfdec_audio_decoder_ffmpeg_free (SwfdecAudioDecoder *dec)
-{
- SwfdecAudioDecoderFFMpeg *ffmpeg = (SwfdecAudioDecoderFFMpeg *) dec;
-
- avcodec_close (ffmpeg->ctx);
- av_free (ffmpeg->ctx);
- swfdec_buffer_queue_unref (ffmpeg->queue);
-
- g_slice_free (SwfdecAudioDecoderFFMpeg, ffmpeg);
-}
-
-SwfdecAudioDecoder *
-swfdec_audio_decoder_ffmpeg_new (guint type, SwfdecAudioFormat format)
-{
- SwfdecAudioDecoderFFMpeg *ffmpeg;
- AVCodecContext *ctx;
- enum CodecID id;
-
- switch (type) {
- case SWFDEC_AUDIO_CODEC_ADPCM:
- id = CODEC_ID_ADPCM_SWF;
- break;
- case SWFDEC_AUDIO_CODEC_MP3:
- id = CODEC_ID_MP3;
- break;
- default:
- return NULL;
- }
- ctx = swfdec_codec_ffmpeg_init (id);
- if (ctx == NULL)
- return NULL;
- ffmpeg = g_slice_new (SwfdecAudioDecoderFFMpeg);
- ffmpeg->ctx = ctx;
- ffmpeg->queue = swfdec_buffer_queue_new ();
- ffmpeg->decoder.format = swfdec_audio_format_new (44100, 2, TRUE);
- ffmpeg->decoder.pull = swfdec_audio_decoder_ffmpeg_pull;
- ffmpeg->decoder.push = swfdec_audio_decoder_ffmpeg_push;
- ffmpeg->decoder.free = swfdec_audio_decoder_ffmpeg_free;
- ctx->sample_rate = swfdec_audio_format_get_rate (format);
- ctx->channels = swfdec_audio_format_get_channels (format);
-
- return &ffmpeg->decoder;
-}
-
-/*** VIDEO ***/
-
-typedef struct {
- SwfdecVideoDecoder decoder;
- AVCodecContext * ctx; /* out context (d'oh) */
- AVFrame * frame; /* the frame we use for decoding */
- enum PixelFormat format; /* format we must output */
-} SwfdecVideoDecoderFFMpeg;
-
-static enum PixelFormat
-swfdec_video_decoder_ffmpeg_get_format (guint codec)
-{
- switch (swfdec_video_codec_get_format (codec)) {
- case SWFDEC_VIDEO_FORMAT_RGBA:
- return PIX_FMT_RGB32;
- case SWFDEC_VIDEO_FORMAT_I420:
- return PIX_FMT_YUV420P;
- default:
- g_return_val_if_reached (PIX_FMT_RGB32);
- }
-}
-
-#define ALIGNMENT 31
-static gboolean
-swfdec_video_decoder_ffmpeg_decode (SwfdecVideoDecoder *dec, SwfdecBuffer *buffer,
- SwfdecVideoImage *image)
-{
- SwfdecVideoDecoderFFMpeg *codec = (SwfdecVideoDecoderFFMpeg *) dec;
- int got_image = 0;
- guchar *tmp, *aligned;
-
- /* fullfill alignment and padding requirements */
- tmp = g_try_malloc (buffer->length + ALIGNMENT + FF_INPUT_BUFFER_PADDING_SIZE);
- if (tmp == NULL) {
- SWFDEC_WARNING ("Could not allocate temporary memory");
- return FALSE;
- }
- aligned = (guchar *) (((uintptr_t) tmp + ALIGNMENT) & ~ALIGNMENT);
- memcpy (aligned, buffer->data, buffer->length);
- memset (aligned + buffer->length, 0, FF_INPUT_BUFFER_PADDING_SIZE);
- if (avcodec_decode_video (codec->ctx, codec->frame, &got_image,
- aligned, buffer->length) < 0) {
- g_free (tmp);
- SWFDEC_WARNING ("error decoding frame");
- return FALSE;
- }
- g_free (tmp);
- if (got_image == 0) {
- SWFDEC_WARNING ("did not get an image from decoding");
- return FALSE;
- }
- if (codec->ctx->pix_fmt != codec->format) {
- SWFDEC_WARNING ("decoded to wrong format, expected %u, but got %u",
- codec->format, codec->ctx->pix_fmt);
- return FALSE;
- }
- image->width = codec->ctx->width;
- image->height = codec->ctx->height;
- image->mask = NULL;
- image->plane[0] = codec->frame->data[0];
- image->plane[1] = codec->frame->data[1];
- image->plane[2] = codec->frame->data[2];
- image->rowstride[0] = codec->frame->linesize[0];
- image->rowstride[1] = codec->frame->linesize[1];
- image->rowstride[2] = codec->frame->linesize[2];
- return TRUE;
-}
-
-static void
-swfdec_video_decoder_ffmpeg_free (SwfdecVideoDecoder *dec)
-{
- SwfdecVideoDecoderFFMpeg *codec = (SwfdecVideoDecoderFFMpeg *) dec;
-
- avcodec_close (codec->ctx);
- av_free (codec->ctx);
- av_free (codec->frame);
- g_free (codec);
-}
-
-SwfdecVideoDecoder *
-swfdec_video_decoder_ffmpeg_new (guint type)
-{
- SwfdecVideoDecoderFFMpeg *codec;
- AVCodecContext *ctx;
- enum CodecID id;
-
- switch (type) {
- case SWFDEC_VIDEO_CODEC_H263:
- id = CODEC_ID_FLV1;
- break;
- case SWFDEC_VIDEO_CODEC_SCREEN:
- id = CODEC_ID_FLASHSV;
- break;
- case SWFDEC_VIDEO_CODEC_VP6:
- id = CODEC_ID_VP6F;
- break;
- default:
- return NULL;
- }
- ctx = swfdec_codec_ffmpeg_init (id);
-
- if (ctx == NULL)
- return NULL;
- codec = g_new0 (SwfdecVideoDecoderFFMpeg, 1);
- codec->decoder.decode = swfdec_video_decoder_ffmpeg_decode;
- codec->decoder.free = swfdec_video_decoder_ffmpeg_free;
- codec->ctx = ctx;
- codec->frame = avcodec_alloc_frame ();
- codec->format = swfdec_video_decoder_ffmpeg_get_format (type);
-
- return &codec->decoder;
-}
-
diff --git a/libswfdec/swfdec_codec_gst.c b/libswfdec/swfdec_codec_gst.c
deleted file mode 100644
index 2167050..0000000
--- a/libswfdec/swfdec_codec_gst.c
+++ /dev/null
@@ -1,615 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <string.h>
-#include <gst/gst.h>
-
-#include "swfdec_codec_audio.h"
-#include "swfdec_codec_video.h"
-#include "swfdec_debug.h"
-#include "swfdec_internal.h"
-
-/*** BUFFER ***/
-
-static void
-swfdec_gst_buffer_free (unsigned char *data, gpointer priv)
-{
- gst_buffer_unref (priv);
-}
-
-static SwfdecBuffer *
-swfdec_buffer_new_from_gst (GstBuffer *buffer)
-{
- SwfdecBuffer *ret;
-
- g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
-
- ret = swfdec_buffer_new ();
- ret->data = GST_BUFFER_DATA (buffer);
- ret->length = GST_BUFFER_SIZE (buffer);
- ret->free = swfdec_gst_buffer_free;
- ret->priv = buffer;
-
- return ret;
-}
-
-static GstBuffer *
-swfdec_gst_buffer_new (SwfdecBuffer *buffer)
-{
- /* FIXME: make this a zero-copy operation */
- GstBuffer *ret;
-
- g_return_val_if_fail (buffer != NULL , NULL);
-
- ret = gst_buffer_new_and_alloc (buffer->length);
- memcpy (GST_BUFFER_DATA (ret), buffer->data, buffer->length);
- swfdec_buffer_unref (buffer);
-
- return ret;
-}
-
-/*** TYPEFINDING ***/
-
-/* NB: try to mirror decodebin behavior */
-static gboolean
-swfdec_gst_feature_filter (GstPluginFeature *feature, gpointer caps)
-{
- const GList *walk;
- const gchar *klass;
-
- /* we only care about element factories */
- if (!GST_IS_ELEMENT_FACTORY (feature))
- return FALSE;
-
- /* only decoders are interesting */
- klass = gst_element_factory_get_klass (GST_ELEMENT_FACTORY (feature));
- if (strstr (klass, "Decoder") == NULL)
- return FALSE;
-
- /* only select elements with autoplugging rank */
- if (gst_plugin_feature_get_rank (feature) < GST_RANK_MARGINAL)
- return FALSE;
-
- /* only care about the right sink caps */
- for (walk = gst_element_factory_get_static_pad_templates (GST_ELEMENT_FACTORY (feature));
- walk; walk = walk->next) {
- GstStaticPadTemplate *template = walk->data;
- GstCaps *intersect;
- GstCaps *template_caps;
-
- if (template->direction != GST_PAD_SINK)
- continue;
-
- template_caps = gst_static_caps_get (&template->static_caps);
- intersect = gst_caps_intersect (caps, template_caps);
-
- gst_caps_unref (template_caps);
- if (gst_caps_is_empty (intersect)) {
- gst_caps_unref (intersect);
- } else {
- gst_caps_unref (intersect);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-static int
-swfdec_gst_compare_features (gconstpointer a_, gconstpointer b_)
-{
- int diff;
- GstPluginFeature *a = GST_PLUGIN_FEATURE (a_);
- GstPluginFeature *b = GST_PLUGIN_FEATURE (b_);
-
- diff = gst_plugin_feature_get_rank (b) - gst_plugin_feature_get_rank (a);
- if (diff != 0)
- return diff;
-
- return strcmp (gst_plugin_feature_get_name (a), gst_plugin_feature_get_name (b));
-}
-
-static GstElement *
-swfdec_gst_get_element (GstCaps *caps)
-{
- GstElement *element;
- GList *list;
-
- list = gst_registry_feature_filter (gst_registry_get_default (),
- swfdec_gst_feature_filter, FALSE, caps);
- if (list == NULL)
- return NULL;
-
- list = g_list_sort (list, swfdec_gst_compare_features);
- element = gst_element_factory_create (list->data, "decoder");
- gst_plugin_feature_list_free (list);
- return element;
-}
-
-/*** PADS ***/
-
-static GstPad *
-swfdec_gst_connect_srcpad (GstElement *element, GstCaps *caps)
-{
- GstPadTemplate *tmpl;
- GstPad *srcpad, *sinkpad;
-
- sinkpad = gst_element_get_pad (element, "sink");
- if (sinkpad == NULL)
- return NULL;
- gst_caps_ref (caps);
- tmpl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
- srcpad = gst_pad_new_from_template (tmpl, "src");
- g_object_unref (tmpl);
- if (gst_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK)
- goto error;
-
- gst_object_unref (sinkpad);
- gst_pad_set_active (srcpad, TRUE);
- return srcpad;
-
-error:
- SWFDEC_ERROR ("failed to create or link srcpad");
- gst_object_unref (sinkpad);
- gst_object_unref (srcpad);
- return NULL;
-}
-
-static GstPad *
-swfdec_gst_connect_sinkpad (GstElement *element, GstCaps *caps)
-{
- GstPadTemplate *tmpl;
- GstPad *srcpad, *sinkpad;
-
- srcpad = gst_element_get_pad (element, "src");
- if (srcpad == NULL)
- return NULL;
- gst_caps_ref (caps);
- tmpl = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, caps);
- sinkpad = gst_pad_new_from_template (tmpl, "sink");
- g_object_unref (tmpl);
- if (gst_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK)
- goto error;
-
- gst_object_unref (srcpad);
- gst_pad_set_active (sinkpad, TRUE);
- return sinkpad;
-
-error:
- SWFDEC_ERROR ("failed to create or link sinkpad");
- gst_object_unref (srcpad);
- gst_object_unref (sinkpad);
- return NULL;
-}
-
-/*** DECODER ***/
-
-typedef struct {
- GstElement * decoder;
- GstPad * src;
- GstPad * sink;
- GQueue * queue; /* all the stored output GstBuffers */
-} SwfdecGstDecoder;
-
-static GstFlowReturn
-swfdec_gst_chain_func (GstPad *pad, GstBuffer *buffer)
-{
- GQueue *queue = g_object_get_data (G_OBJECT (pad), "swfdec-queue");
-
- g_queue_push_tail (queue, buffer);
-
- return GST_FLOW_OK;
-}
-
-static gboolean
-swfdec_gst_decoder_init (SwfdecGstDecoder *dec, const char *name, GstCaps *srccaps, GstCaps *sinkcaps)
-{
- if (name) {
- dec->decoder = gst_element_factory_make (name, "decoder");
- } else {
- dec->decoder = swfdec_gst_get_element (srccaps);
- }
- if (dec->decoder == NULL) {
- SWFDEC_ERROR ("failed to create decoder");
- return FALSE;
- }
- dec->src = swfdec_gst_connect_srcpad (dec->decoder, srccaps);
- if (dec->src == NULL)
- return FALSE;
- dec->sink = swfdec_gst_connect_sinkpad (dec->decoder, sinkcaps);
- if (dec->sink == NULL)
- return FALSE;
- gst_pad_set_chain_function (dec->sink, swfdec_gst_chain_func);
- dec->queue = g_queue_new ();
- g_object_set_data (G_OBJECT (dec->sink), "swfdec-queue", dec->queue);
- if (!gst_element_set_state (dec->decoder, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS) {
- SWFDEC_ERROR ("could not change element state");
- return FALSE;
- }
- return TRUE;
-}
-
-static void
-swfdec_gst_decoder_finish (SwfdecGstDecoder *dec)
-{
- if (dec->decoder) {
- gst_element_set_state (dec->decoder, GST_STATE_NULL);
- g_object_unref (dec->decoder);
- dec->decoder = NULL;
- }
- if (dec->src) {
- g_object_unref (dec->src);
- dec->src = NULL;
- }
- if (dec->sink) {
- g_object_unref (dec->sink);
- dec->sink = NULL;
- }
- if (dec->queue) {
- GstBuffer *buffer;
- while ((buffer = g_queue_pop_head (dec->queue)) != NULL) {
- gst_buffer_unref (buffer);
- }
- g_queue_free (dec->queue);
- dec->queue = NULL;
- }
-}
-
-static gboolean
-swfdec_gst_decoder_push (SwfdecGstDecoder *dec, GstBuffer *buffer)
-{
- GstFlowReturn ret;
- GstCaps *caps;
-
- /* set caps if none set yet */
- caps = gst_buffer_get_caps (buffer);
- if (caps) {
- gst_caps_unref (caps);
- } else {
- caps = GST_PAD_CAPS (dec->src);
- if (caps == NULL) {
- caps = (GstCaps *) gst_pad_get_pad_template_caps (dec->src);
- g_assert (gst_caps_is_fixed (caps));
- gst_pad_set_caps (dec->src, caps);
- }
- gst_buffer_set_caps (buffer, GST_PAD_CAPS (dec->src));
- }
-
- ret = gst_pad_push (dec->src, buffer);
- if (GST_FLOW_IS_SUCCESS (ret))
- return TRUE;
- SWFDEC_ERROR ("error %d pushing data", (int) ret);
- return FALSE;
-}
-
-static void
-swfdec_gst_decoder_push_eos (SwfdecGstDecoder *dec)
-{
- gst_pad_push_event (dec->src, gst_event_new_eos ());
-}
-
-static GstBuffer *
-swfdec_gst_decoder_pull (SwfdecGstDecoder *dec)
-{
- return g_queue_pop_head (dec->queue);
-}
-
-/*** AUDIO ***/
-
-typedef struct _SwfdecGstAudio SwfdecGstAudio;
-struct _SwfdecGstAudio {
- SwfdecAudioDecoder decoder;
-
- gboolean error;
- SwfdecGstDecoder dec;
- SwfdecGstDecoder convert;
- SwfdecGstDecoder resample;
-};
-
-static void
-swfdec_audio_decoder_gst_free (SwfdecAudioDecoder *dec)
-{
- SwfdecGstAudio *player = (SwfdecGstAudio *) dec;
-
- swfdec_gst_decoder_finish (&player->dec);
- swfdec_gst_decoder_finish (&player->convert);
- swfdec_gst_decoder_finish (&player->resample);
-
- g_slice_free (SwfdecGstAudio, player);
-}
-
-static void
-swfdec_audio_decoder_gst_push (SwfdecAudioDecoder *dec, SwfdecBuffer *buffer)
-{
- SwfdecGstAudio *player = (SwfdecGstAudio *) dec;
- GstBuffer *buf;
-
- if (player->error)
- return;
- if (buffer == NULL) {
- swfdec_gst_decoder_push_eos (&player->dec);
- } else {
- swfdec_buffer_ref (buffer);
- buf = swfdec_gst_buffer_new (buffer);
- if (!swfdec_gst_decoder_push (&player->dec, buf))
- goto error;
- }
- while ((buf = swfdec_gst_decoder_pull (&player->dec))) {
- if (!swfdec_gst_decoder_push (&player->convert, buf))
- goto error;
- }
- while ((buf = swfdec_gst_decoder_pull (&player->convert))) {
- if (!swfdec_gst_decoder_push (&player->resample, buf))
- goto error;
- }
- return;
-
-error:
- SWFDEC_ERROR ("error pushing");
- player->error = TRUE;
-}
-
-static SwfdecBuffer *
-swfdec_audio_decoder_gst_pull (SwfdecAudioDecoder *dec)
-{
- SwfdecGstAudio *player = (SwfdecGstAudio *) dec;
- GstBuffer *buf;
-
- if (player->error)
- return NULL;
- buf = swfdec_gst_decoder_pull (&player->resample);
- if (buf == NULL)
- return NULL;
- return swfdec_buffer_new_from_gst (buf);
-}
-
-static gboolean
-swfdec_audio_decoder_set_caps (GstPad *pad, GstCaps *caps)
-{
- SwfdecGstAudio *player = g_object_get_data (G_OBJECT (pad), "swfdec-player");
- GstStructure *structure = gst_caps_get_structure (caps, 0);
- int depth, channels, rate;
-
- if (SWFDEC_IS_AUDIO_FORMAT (player->decoder.format)) {
- SWFDEC_ERROR ("resetting format not allowed");
- player->error = TRUE;
- return FALSE;
- }
- if (!gst_structure_get_int (structure, "depth", &depth) ||
- !gst_structure_get_int (structure, "rate", &rate) ||
- !gst_structure_get_int (structure, "channels", &channels)) {
- SWFDEC_ERROR ("invalid caps");
- player->error = TRUE;
- return FALSE;
- }
-
- player->decoder.format = swfdec_audio_format_new (rate, channels, depth == 16 ? TRUE : FALSE);
- return TRUE;
-}
-
-SwfdecAudioDecoder *
-swfdec_audio_decoder_gst_new (guint type, SwfdecAudioFormat format)
-{
- SwfdecGstAudio *player;
- GstCaps *srccaps, *sinkcaps;
-
- if (!gst_init_check (NULL, NULL, NULL))
- return NULL;
-
- switch (type) {
- case SWFDEC_AUDIO_CODEC_MP3:
- srccaps = gst_caps_from_string ("audio/mpeg, mpegversion=(int)1, layer=(int)3");
- break;
- default:
- return NULL;
- }
- g_assert (srccaps);
-
- player = g_slice_new0 (SwfdecGstAudio);
- player->decoder.format = SWFDEC_AUDIO_FORMAT_INVALID;
- player->decoder.pull = swfdec_audio_decoder_gst_pull;
- player->decoder.push = swfdec_audio_decoder_gst_push;
- player->decoder.free = swfdec_audio_decoder_gst_free;
-
- /* create decoder */
- sinkcaps = gst_caps_from_string ("audio/x-raw-int");
- g_assert (sinkcaps);
- if (!swfdec_gst_decoder_init (&player->dec, NULL, srccaps, sinkcaps))
- goto error;
- /* create audioconvert */
- gst_caps_unref (srccaps);
- srccaps = sinkcaps;
- sinkcaps = gst_caps_from_string ("audio/x-raw-int, endianness=byte_order, signed=(boolean)true, width=16, depth=16, channels={2,1}");
- g_assert (sinkcaps);
- if (!swfdec_gst_decoder_init (&player->convert, "audioconvert", srccaps, sinkcaps))
- goto error;
- /* create audiorate */
- gst_caps_unref (srccaps);
- srccaps = sinkcaps;
- sinkcaps = gst_caps_from_string ("audio/x-raw-int, endianness=byte_order, signed=(boolean)true, width=16, depth=16, rate={44100, 22050, 11025, 5512}, channels={2,1}");
- g_assert (sinkcaps);
- if (!swfdec_gst_decoder_init (&player->resample, "audioresample", srccaps, sinkcaps))
- goto error;
- g_object_set_data (G_OBJECT (player->resample.sink), "swfdec-player", player);
- gst_pad_set_setcaps_function (player->resample.sink, swfdec_audio_decoder_set_caps);
-
- gst_caps_unref (srccaps);
- gst_caps_unref (sinkcaps);
- return &player->decoder;
-
-error:
- swfdec_audio_decoder_gst_free (&player->decoder);
- gst_caps_unref (srccaps);
- gst_caps_unref (sinkcaps);
- return NULL;
-}
-
-/*** VIDEO ***/
-
-/* NB: We don't put a colorspace tansform here, we just assume that the codecs
- * in GStreamer decode to the native format that we enforce. */
-typedef struct _SwfdecGstVideo SwfdecGstVideo;
-struct _SwfdecGstVideo {
- SwfdecVideoDecoder decoder;
-
- gboolean error;
- SwfdecGstDecoder dec; /* the decoder element */
- GstBuffer * last; /* last decoded buffer */
-};
-
-static void
-swfdec_video_decoder_gst_free (SwfdecVideoDecoder *dec)
-{
- SwfdecGstVideo *player = (SwfdecGstVideo *) dec;
-
- swfdec_gst_decoder_finish (&player->dec);
- if (player->last)
- gst_buffer_unref (player->last);
-
- g_slice_free (SwfdecGstVideo, player);
-}
-
-static gboolean
-swfdec_video_decoder_gst_decode (SwfdecVideoDecoder *dec, SwfdecBuffer *buffer,
- SwfdecVideoImage *image)
-{
- SwfdecGstVideo *player = (SwfdecGstVideo *) dec;
-#define SWFDEC_ALIGN(x, n) (((x) + (n) - 1) & (~((n) - 1)))
- GstBuffer *buf;
- GstCaps *caps;
- GstStructure *structure;
-
- if (player->error)
- return FALSE;
- if (player->last) {
- gst_buffer_unref (player->last);
- player->last = NULL;
- }
-
- buf = swfdec_gst_buffer_new (swfdec_buffer_ref (buffer));
- if (!swfdec_gst_decoder_push (&player->dec, buf)) {
- SWFDEC_ERROR ("failed to push buffer");
- player->error = TRUE;
- return FALSE;
- }
-
- player->last = swfdec_gst_decoder_pull (&player->dec);
- if (player->last == NULL) {
- SWFDEC_ERROR ("failed to pull decoded buffer");
- player->error = TRUE;
- return FALSE;
- }
- while ((buf = swfdec_gst_decoder_pull (&player->dec))) {
- SWFDEC_WARNING ("too many output buffers!");
- }
- caps = gst_buffer_get_caps (player->last);
- if (caps == NULL) {
- SWFDEC_ERROR ("no caps on decoded buffer");
- player->error = TRUE;
- return FALSE;
- }
- structure = gst_caps_get_structure (caps, 0);
- if (!gst_structure_get_int (structure, "width", (int *) &image->width) ||
- !gst_structure_get_int (structure, "height", (int *) &image->height)) {
- SWFDEC_ERROR ("invalid caps on decoded buffer");
- player->error = TRUE;
- return FALSE;
- }
- image->mask = NULL;
- buf = player->last;
- switch (swfdec_video_codec_get_format (dec->codec)) {
- case SWFDEC_VIDEO_FORMAT_RGBA:
- image->plane[0] = buf->data;
- image->rowstride[0] = image->width * 4;
- break;
- case SWFDEC_VIDEO_FORMAT_I420:
- image->plane[0] = buf->data;
- image->rowstride[0] = SWFDEC_ALIGN (image->width, 4);
- image->plane[1] = image->plane[0] + image->rowstride[0] * SWFDEC_ALIGN (image->height, 2);
- image->rowstride[1] = SWFDEC_ALIGN (image->width, 8) / 2;
- image->plane[2] = image->plane[1] + image->rowstride[1] * SWFDEC_ALIGN (image->height, 2) / 2;
- image->rowstride[2] = image->rowstride[1];
- g_assert (image->plane[2] + image->rowstride[2] * SWFDEC_ALIGN (image->height, 2) / 2 == image->plane[0] + buf->size);
- break;
- default:
- g_return_val_if_reached (FALSE);
- }
- return TRUE;
-#undef SWFDEC_ALIGN
-}
-
-static GstCaps *
-swfdec_video_decoder_get_sink_caps (guint codec)
-{
- switch (swfdec_video_codec_get_format (codec)) {
- case SWFDEC_VIDEO_FORMAT_RGBA:
-#if G_BYTE_ORDER == G_BIG_ENDIAN
- return gst_caps_from_string ("video/x-raw-rgb, bpp=32, endianness=4321, depth=24, "
- "red_mask=16711680, green_mask=65280, blue_mask=255");
-#else
- return gst_caps_from_string ("video/x-raw-rgb, bpp=32, endianness=4321, depth=24, "
- "red_mask=65280, green_mask=16711680, blue_mask=-16777216");
-#endif
- case SWFDEC_VIDEO_FORMAT_I420:
- return gst_caps_from_string ("video/x-raw-yuv, format=(fourcc)I420");
- default:
- g_return_val_if_reached (NULL);
- }
-}
-
-SwfdecVideoDecoder *
-swfdec_video_decoder_gst_new (guint codec)
-{
- SwfdecGstVideo *player;
- GstCaps *srccaps, *sinkcaps;
-
- if (!gst_init_check (NULL, NULL, NULL))
- return NULL;
-
- switch (codec) {
- case SWFDEC_VIDEO_CODEC_H263:
- srccaps = gst_caps_from_string ("video/x-flash-video");
- break;
- case SWFDEC_VIDEO_CODEC_VP6:
- srccaps = gst_caps_from_string ("video/x-vp6-flash");
- break;
- default:
- return NULL;
- }
- g_assert (srccaps);
- sinkcaps = swfdec_video_decoder_get_sink_caps (codec);
-
- player = g_slice_new0 (SwfdecGstVideo);
- player->decoder.decode = swfdec_video_decoder_gst_decode;
- player->decoder.free = swfdec_video_decoder_gst_free;
-
- if (!swfdec_gst_decoder_init (&player->dec, NULL, srccaps, sinkcaps)) {
- swfdec_video_decoder_gst_free (&player->decoder);
- gst_caps_unref (srccaps);
- gst_caps_unref (sinkcaps);
- return NULL;
- }
-
- gst_caps_unref (srccaps);
- gst_caps_unref (sinkcaps);
- return &player->decoder;
-}
-
diff --git a/libswfdec/swfdec_codec_mad.c b/libswfdec/swfdec_codec_mad.c
deleted file mode 100644
index ec15231..0000000
--- a/libswfdec/swfdec_codec_mad.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <string.h>
-#include <config.h>
-#include <liboil/liboil.h>
-#include <mad.h>
-
-#include "swfdec_codec_audio.h"
-#include "swfdec_debug.h"
-#include "swfdec_internal.h"
-
-typedef struct {
- SwfdecAudioDecoder decoder;
-
- struct mad_stream stream;
- struct mad_frame frame;
- struct mad_synth synth;
- guint8 data[MAD_BUFFER_MDLEN * 3];
- guint data_len;
- SwfdecBufferQueue * queue;
-} MadData;
-
-static SwfdecBuffer *
-convert_synth_to_buffer (MadData *mdata)
-{
- SwfdecBuffer *buffer;
- int n_samples;
- short *data;
- int i;
- short c0,c1;
-#define MAD_F_TO_S16(x) (CLAMP (x, -MAD_F_ONE, MAD_F_ONE) >> (MAD_F_FRACBITS - 14))
-
- n_samples = mdata->synth.pcm.length;
- if (n_samples == 0) {
- return NULL;
- }
-
- switch (mdata->synth.pcm.samplerate) {
- case 11025:
- n_samples *= 4;
- break;
- case 22050:
- n_samples *= 2;
- break;
- case 44100:
- break;
- default:
- SWFDEC_ERROR ("sample rate not handled (%d)",
- mdata->synth.pcm.samplerate);
- return NULL;
- }
-
- buffer = swfdec_buffer_new_and_alloc (n_samples * 2 * 2);
- data = (gint16 *) buffer->data;
-
- if (mdata->synth.pcm.samplerate == 11025) {
- if (mdata->synth.pcm.channels == 2) {
- for (i = 0; i < mdata->synth.pcm.length; i++) {
- c0 = MAD_F_TO_S16 (mdata->synth.pcm.samples[0][i]);
- c1 = MAD_F_TO_S16 (mdata->synth.pcm.samples[1][i]);
- *data++ = c0;
- *data++ = c1;
- *data++ = c0;
- *data++ = c1;
- *data++ = c0;
- *data++ = c1;
- *data++ = c0;
- *data++ = c1;
- }
- } else {
- for (i = 0; i < mdata->synth.pcm.length; i++) {
- c0 = MAD_F_TO_S16( mdata->synth.pcm.samples[0][i]);
- *data++ = c0;
- *data++ = c0;
- *data++ = c0;
- *data++ = c0;
- *data++ = c0;
- *data++ = c0;
- *data++ = c0;
- *data++ = c0;
- }
- }
- } else if (mdata->synth.pcm.samplerate == 22050) {
- if (mdata->synth.pcm.channels == 2) {
- for (i = 0; i < mdata->synth.pcm.length; i++) {
- c0 = MAD_F_TO_S16 (mdata->synth.pcm.samples[0][i]);
- c1 = MAD_F_TO_S16 (mdata->synth.pcm.samples[1][i]);
- *data++ = c0;
- *data++ = c1;
- *data++ = c0;
- *data++ = c1;
- }
- } else {
- for (i = 0; i < mdata->synth.pcm.length; i++) {
- c0 = MAD_F_TO_S16 (mdata->synth.pcm.samples[0][i]);
- *data++ = c0;
- *data++ = c0;
- *data++ = c0;
- *data++ = c0;
- }
- }
- } else if (mdata->synth.pcm.samplerate == 44100) {
- if (mdata->synth.pcm.channels == 2) {
- for (i = 0; i < mdata->synth.pcm.length; i++) {
- c0 = MAD_F_TO_S16 (mdata->synth.pcm.samples[0][i]);
- c1 = MAD_F_TO_S16 (mdata->synth.pcm.samples[1][i]);
- *data++ = c0;
- *data++ = c1;
- }
- } else {
- for (i = 0; i < mdata->synth.pcm.length; i++) {
- c0 = MAD_F_TO_S16 (mdata->synth.pcm.samples[0][i]);
- *data++ = c0;
- *data++ = c0;
- }
- }
- } else {
- SWFDEC_ERROR ("sample rate not handled (%d)",
- mdata->synth.pcm.samplerate);
- }
- return buffer;
-}
-
-static void
-swfdec_audio_decoder_mad_push (SwfdecAudioDecoder *dec, SwfdecBuffer *buffer)
-{
- MadData *data = (MadData *) dec;
- SwfdecBuffer *out, *empty = NULL;
- guint amount = 0, size;
-
- if (buffer == NULL) {
- buffer = empty = swfdec_buffer_new ();
- empty->data = g_malloc0 (MAD_BUFFER_GUARD * 3);
- empty->length = MAD_BUFFER_GUARD * 3;
- }
-
- //write (1, buffer->data, buffer->length);
- //g_print ("buffer %p gave us %u bytes\n", buffer, buffer->length);
- while (amount < buffer->length) {
- size = MIN (buffer->length - amount, MAD_BUFFER_MDLEN * 3 - data->data_len);
- memcpy (&data->data[data->data_len], buffer->data + amount, size);
- //write (1, buffer->data + amount, size);
- amount += size;
- data->data_len += size;
- mad_stream_buffer (&data->stream, data->data, data->data_len);
- while (1) {
- if (mad_frame_decode (&data->frame, &data->stream)) {
- if (data->stream.error == MAD_ERROR_BUFLEN)
- break;
- if (MAD_RECOVERABLE (data->stream.error)) {
- SWFDEC_LOG ("recoverable error 0x%04x", data->stream.error);
- continue;
- }
- SWFDEC_ERROR ("stream error 0x%04x", data->stream.error);
- break;
- }
-
- mad_synth_frame (&data->synth, &data->frame);
- out = convert_synth_to_buffer (data);
- if (out)
- swfdec_buffer_queue_push (data->queue, out);
- }
- if (data->stream.next_frame == NULL) {
- data->data_len = 0;
- } else {
- data->data_len = data->stream.bufend - data->stream.next_frame;
- memmove (data->data, data->stream.next_frame, data->data_len);
- }
- }
- //g_print ("%u bytes left\n", data->data_len);
-
- if (empty)
- swfdec_buffer_unref (empty);
-}
-
-static void
-swfdec_audio_decoder_mad_free (SwfdecAudioDecoder *dec)
-{
- MadData *data = (MadData *) dec;
-
- mad_synth_finish (&data->synth);
- mad_frame_finish (&data->frame);
- mad_stream_finish (&data->stream);
- swfdec_buffer_queue_unref (data->queue);
- g_slice_free (MadData, data);
-}
-
-static SwfdecBuffer *
-swfdec_audio_decoder_mad_pull (SwfdecAudioDecoder *dec)
-{
- return swfdec_buffer_queue_pull_buffer (((MadData *) dec)->queue);
-}
-
-SwfdecAudioDecoder *
-swfdec_audio_decoder_mad_new (guint type, SwfdecAudioFormat format)
-{
- MadData *data;
-
- if (type != SWFDEC_AUDIO_CODEC_MP3)
- return NULL;
-
- data = g_slice_new (MadData);
- data->decoder.format = swfdec_audio_format_new (44100, 2, TRUE);
- data->decoder.push = swfdec_audio_decoder_mad_push;
- data->decoder.pull = swfdec_audio_decoder_mad_pull;
- data->decoder.free = swfdec_audio_decoder_mad_free;
- mad_stream_init (&data->stream);
- mad_frame_init (&data->frame);
- mad_synth_init (&data->synth);
- data->data_len = 0;
- data->queue = swfdec_buffer_queue_new ();
-
- return &data->decoder;
-}
-
diff --git a/libswfdec/swfdec_codec_screen.c b/libswfdec/swfdec_codec_screen.c
deleted file mode 100644
index 5dbdfce..0000000
--- a/libswfdec/swfdec_codec_screen.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include <zlib.h>
-#include <liboil/liboil.h>
-
-#include "swfdec_codec_video.h"
-#include "swfdec_bits.h"
-#include "swfdec_debug.h"
-#include "swfdec_internal.h"
-
-typedef struct _SwfdecCodecScreen SwfdecCodecScreen;
-
-struct _SwfdecCodecScreen {
- SwfdecVideoDecoder decoder; /* the decoder */
- gulong width; /* width of last image */
- gulong height; /* height of last image */
- guint8 * data; /* contains decoded image */
-};
-
-static gboolean
-swfdec_video_decoder_screen_decode (SwfdecVideoDecoder *dec, SwfdecBuffer *buffer,
- SwfdecVideoImage *image)
-{
- SwfdecCodecScreen *screen = (SwfdecCodecScreen *) dec;
- SwfdecBits bits;
- gulong i, j, w, h, bw, bh, stride;
-
- swfdec_bits_init (&bits, buffer);
- bw = (swfdec_bits_getbits (&bits, 4) + 1) * 16;
- w = swfdec_bits_getbits (&bits, 12);
- bh = (swfdec_bits_getbits (&bits, 4) + 1) * 16;
- h = swfdec_bits_getbits (&bits, 12);
- if (screen->width == 0 || screen->height == 0) {
- if (w == 0 || h == 0) {
- SWFDEC_ERROR ("width or height is 0: %lux%lu", w, h);
- return FALSE;
- }
- screen->data = g_try_malloc (w * h * 4);
- if (screen->data == NULL) {
- SWFDEC_ERROR ("could not allocate %lu bytes", w * h * 4);
- return FALSE;
- }
- screen->width = w;
- screen->height = h;
- } else if (screen->width != w || screen->height != h) {
- SWFDEC_ERROR ("width or height differ from original: was %lux%lu, is %lux%lu",
- screen->width, screen->height, w, h);
- /* FIXME: this is what ffmpeg does, should we be more forgiving? */
- return FALSE;
- }
- stride = w * 4;
- SWFDEC_LOG ("size: %lu x %lu - block size %lu x %lu\n", w, h, bw, bh);
- for (j = 0; j < h; j += bh) {
- for (i = 0; i < w; i += bw) {
- guint x, y, size;
- SwfdecBuffer *buf;
- guint8 *in, *out;
- size = swfdec_bits_get_bu16 (&bits);
- if (size == 0)
- continue;
- buf = swfdec_bits_decompress (&bits, size, bw * bh * 4);
- if (buf == NULL) {
- SWFDEC_WARNING ("error decoding block");
- continue;
- }
- /* convert format and write out data */
- out = screen->data + stride * (h - j - 1) + i * 4;
- in = buf->data;
- for (y = 0; y < MIN (bh, h - j); y++) {
- for (x = 0; x < MIN (bw, w - i); x++) {
- out[x * 4 - y * stride + SWFDEC_COLOR_INDEX_BLUE] = *in++;
- out[x * 4 - y * stride + SWFDEC_COLOR_INDEX_GREEN] = *in++;
- out[x * 4 - y * stride + SWFDEC_COLOR_INDEX_RED] = *in++;
- out[x * 4 - y * stride + SWFDEC_COLOR_INDEX_ALPHA] = 0xFF;
- }
- }
- swfdec_buffer_unref (buf);
- }
- }
- image->width = screen->width;
- image->height = screen->height;
- image->plane[0] = screen->data;
- image->rowstride[0] = stride;
- image->mask = NULL;
- return TRUE;
-}
-
-static void
-swfdec_video_decoder_screen_free (SwfdecVideoDecoder *dec)
-{
- SwfdecCodecScreen *screen = (SwfdecCodecScreen *) dec;
-
- if (screen->data)
- g_free (screen->data);
- g_free (screen);
-}
-
-SwfdecVideoDecoder *
-swfdec_video_decoder_screen_new (guint type)
-{
- SwfdecCodecScreen *screen;
-
- if (type != SWFDEC_VIDEO_CODEC_SCREEN)
- return NULL;
-
- screen = g_new0 (SwfdecCodecScreen, 1);
- screen->decoder.decode = swfdec_video_decoder_screen_decode;
- screen->decoder.free = swfdec_video_decoder_screen_free;
-
- return &screen->decoder;
-}
-
diff --git a/libswfdec/swfdec_codec_video.c b/libswfdec/swfdec_codec_video.c
deleted file mode 100644
index dcd03ce..0000000
--- a/libswfdec/swfdec_codec_video.c
+++ /dev/null
@@ -1,320 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <liboil/liboil.h>
-#include "swfdec_codec_video.h"
-#include "swfdec_color.h"
-#include "swfdec_debug.h"
-#include "swfdec_internal.h"
-
-static SwfdecVideoDecoder *
-swfdec_video_decoder_builtin_new (guint codec)
-{
- SwfdecVideoDecoder *ret;
-
- ret = swfdec_video_decoder_screen_new (codec);
- if (ret == NULL)
- ret = swfdec_video_decoder_vp6_alpha_new (codec);
-
- return ret;
-}
-
-struct {
- const char * name;
- SwfdecVideoDecoder * (* func) (guint);
-} video_codecs[] = {
- { "builtin", swfdec_video_decoder_builtin_new },
-#ifdef HAVE_GST
- { "gst", swfdec_video_decoder_gst_new },
-#endif
-#ifdef HAVE_FFMPEG
- { "ffmpeg", swfdec_video_decoder_ffmpeg_new },
-#endif
- { NULL, }
-};
-
-/**
- * swfdec_video_decoder_new:
- * @codec: #SwfdecVideoCodec to create the #SwfdecVideoDecoder for
- *
- * Creates a new decoder to decode videos of type @codec. If no suitable
- * decoder could be created, %NULL is returned.
- *
- * Returns:
- **/
-SwfdecVideoDecoder *
-swfdec_video_decoder_new (guint codec)
-{
- SwfdecVideoDecoder *ret;
- const char *list;
-
- list = g_getenv ("SWFDEC_CODEC_VIDEO");
- if (list == NULL)
- list = g_getenv ("SWFDEC_CODEC");
- if (list == NULL) {
- guint i;
- ret = NULL;
- for (i = 0; video_codecs[i].name != NULL; i++) {
- ret = video_codecs[i].func (codec);
- if (ret)
- break;
- }
- } else {
- char **split = g_strsplit (list, ",", -1);
- guint i, j;
- ret = NULL;
- SWFDEC_LOG ("codecs limited to \"%s\"", list);
- for (i = 0; split[i] != NULL && ret == NULL; i++) {
- for (j = 0; video_codecs[j].name != NULL; j++) {
- if (g_ascii_strcasecmp (video_codecs[j].name, split[i]) != 0)
- continue;
- ret = video_codecs[j].func (codec);
- if (ret)
- break;
- }
- }
- g_strfreev (split);
- }
-
- if (ret != NULL) {
- ret->codec = codec;
- g_return_val_if_fail (ret->decode, ret);
- g_return_val_if_fail (ret->free, ret);
- } else {
- SWFDEC_WARNING ("no decoder found for codec %u", (guint) codec);
- }
- return ret;
-}
-
-/**
- * swfdec_video_decoder_free:
- * @decoder: a #SwfdecVideoDecoder
- *
- * Frees the given @decoder and all associated ressources.
- **/
-void
-swfdec_video_decoder_free (SwfdecVideoDecoder *decoder)
-{
- g_return_if_fail (decoder);
-
- decoder->free (decoder);
-}
-
-#define oil_argb(a,r,g,b) (((a) << 24) | ((r) << 16) | ((g) << 8) | b)
-static gint16 jfif_matrix[24] = {
- 0, 0, -8192, -8192,
- 16384, 0, 0, 0,
- 0, 16384, 16384, 16384,
- 0, 0, -5638, 29032,
- 0, 22970, -11700, 0,
- 0, 0, 0, 0
-};
-
-static void
-yuv_mux (guint32 *dest, const guint8 *src_y, const guint8 *src_u, const guint8 *src_v,
- int n)
-{
- int i;
- for (i = 0; i < n; i++) {
- dest[i] = oil_argb(255, src_y[i], src_u[i], src_v[i]);
- }
-}
-
-static void
-upsample (guint8 *d, guint8 *s, int n)
-{
- int i;
-
- d[0] = s[0];
-
- for (i = 0; i < n-3; i+=2) {
- d[i + 1] = (3*s[i/2] + s[i/2+1] + 2)>>2;
- d[i + 2] = (s[i/2] + 3*s[i/2+1] + 2)>>2;
- }
-
- if (n&1) {
- i = n-3;
- d[n-2] = s[n/2];
- d[n-1] = s[n/2];
- } else {
- d[n-1] = s[n/2-1];
- }
-}
-
-static guint8 *
-swfdec_video_i420_to_rgb (SwfdecVideoImage *image)
-{
- guint32 *tmp;
- guint8 *tmp_u;
- guint8 *tmp_v;
- guint8 *tmp1;
- guint32 *argb_image;
- const guint8 *yp, *up, *vp;
- guint32 *argbp;
- int j;
- guint halfwidth;
- int halfheight;
-
- halfwidth = (image->width + 1)>>1;
- tmp = g_malloc (4 * image->width * image->height);
- tmp_u = g_malloc (image->width);
- tmp_v = g_malloc (image->width);
- tmp1 = g_malloc (halfwidth);
- argb_image = g_malloc (4 * image->width * image->height);
-
- yp = image->plane[0];
- up = image->plane[1];
- vp = image->plane[2];
- argbp = argb_image;
- halfheight = (image->height+1)>>1;
- for(j=0;(guint)j<image->height;j++){
- guint32 weight = 192 - 128*(j&1);
-
- oil_merge_linear_u8(tmp1,
- up + image->rowstride[1] * CLAMP((j-1)/2,0,halfheight-1),
- up + image->rowstride[1] * CLAMP((j+1)/2,0,halfheight-1),
- &weight, halfwidth);
- upsample (tmp_u, tmp1, image->width);
- oil_merge_linear_u8(tmp1,
- vp + image->rowstride[2] * CLAMP((j-1)/2,0,halfheight-1),
- vp + image->rowstride[2] * CLAMP((j+1)/2,0,halfheight-1),
- &weight, halfwidth);
- upsample (tmp_v, tmp1, image->width);
-
- yuv_mux (tmp, yp, tmp_u, tmp_v, image->width);
- oil_colorspace_argb(argbp, tmp, jfif_matrix, image->width);
- yp += image->rowstride[0];
- argbp += image->width;
- }
- g_free(tmp);
- g_free(tmp_u);
- g_free(tmp_v);
- g_free(tmp1);
- return (unsigned char *)argb_image;
-}
-
-/* FIXME: use liboil for this */
-static void
-swfdec_video_codec_apply_mask (guint8 *data, guint rowstride, const guint8 *mask,
- guint mask_rowstride, guint width, guint height)
-{
- const guint8 *in;
- guint8 *out;
- guint x, y;
-
- data += SWFDEC_COLOR_INDEX_ALPHA;
- for (y = 0; y < height; y++) {
- in = mask;
- out = data;
- for (x = 0; x < width; x++) {
- *out = *in;
- out += 4;
- in++;
- }
- mask += mask_rowstride;
- data += rowstride;
- }
-}
-
-/**
- * swfdec_video_decoder_decode:
- * @decoder: a #SwfdecVideoDecoder
- * @buffer: buffer to decode
- *
- * Decodes the given buffer into an image surface.
- *
- * Returns: a new cairo image surface or %NULL on error.
- **/
-cairo_surface_t *
-swfdec_video_decoder_decode (SwfdecVideoDecoder *decoder, SwfdecBuffer *buffer)
-{
- SwfdecVideoImage image;
- static const cairo_user_data_key_t key;
- cairo_surface_t *surface;
- guint8 *data;
- guint rowstride;
-
- g_return_val_if_fail (decoder != NULL, NULL);
- g_return_val_if_fail (buffer != NULL, NULL);
-
- if (!decoder->decode (decoder, buffer, &image)) {
- SWFDEC_ERROR ("failed to decode video");
- return NULL;
- }
- g_assert (image.width != 0 && image.height != 0);
- /* FIXME: use cairo for all of this when cairo accelerates it */
- if (swfdec_video_codec_get_format (decoder->codec) == SWFDEC_VIDEO_FORMAT_I420) {
- data = swfdec_video_i420_to_rgb (&image);
- if (data == NULL) {
- SWFDEC_ERROR ("I420 => RGB conversion failed");
- return NULL;
- }
- rowstride = image.width * 4;
- } else {
- rowstride = image.rowstride[0];
- data = g_memdup (image.plane[0], rowstride * image.height);
- }
- if (image.mask) {
- swfdec_video_codec_apply_mask (data, image.width * 4, image.mask,
- image.mask_rowstride, image.width, image.height);
- }
- surface = cairo_image_surface_create_for_data (data,
- image.mask ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24,
- image.width, image.height, rowstride);
- if (cairo_surface_status (surface)) {
- SWFDEC_ERROR ("failed to create surface: %s",
- cairo_status_to_string (cairo_surface_status (surface)));
- cairo_surface_destroy (surface);
- return NULL;
- }
- cairo_surface_set_user_data (surface, &key, data,
- (cairo_destroy_func_t) g_free);
- return surface;
-}
-
-/**
- * swfdec_video_codec_get_format:
- * @codec: codec to check
- *
- * Returns the output format used for this codec. Video codecs must use these
- * codecs when decoding video.
- *
- * Returns: the output format to use for this format
- **/
-SwfdecVideoFormat
-swfdec_video_codec_get_format (guint codec)
-{
- switch (codec) {
- case SWFDEC_VIDEO_CODEC_H263:
- case SWFDEC_VIDEO_CODEC_VP6:
- case SWFDEC_VIDEO_CODEC_VP6_ALPHA:
- return SWFDEC_VIDEO_FORMAT_I420;
- case SWFDEC_VIDEO_CODEC_UNDEFINED:
- case SWFDEC_VIDEO_CODEC_SCREEN:
- case SWFDEC_VIDEO_CODEC_SCREEN2:
- return SWFDEC_VIDEO_FORMAT_RGBA;
- default:
- g_return_val_if_reached (SWFDEC_VIDEO_FORMAT_RGBA);
- }
-}
-
diff --git a/libswfdec/swfdec_codec_video.h b/libswfdec/swfdec_codec_video.h
deleted file mode 100644
index a7c968a..0000000
--- a/libswfdec/swfdec_codec_video.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_CODEC_VIDEO_H_
-#define _SWFDEC_CODEC_VIDEO_H_
-
-#include <glib.h>
-#include <cairo.h>
-#include <libswfdec/swfdec_buffer.h>
-
-#define SWFDEC_VIDEO_CODEC_UNDEFINED 0
-#define SWFDEC_VIDEO_CODEC_H263 2
-#define SWFDEC_VIDEO_CODEC_SCREEN 3
-#define SWFDEC_VIDEO_CODEC_VP6 4
-#define SWFDEC_VIDEO_CODEC_VP6_ALPHA 5
-#define SWFDEC_VIDEO_CODEC_SCREEN2 6
-
-typedef enum {
- SWFDEC_VIDEO_FORMAT_RGBA,
- SWFDEC_VIDEO_FORMAT_I420
-} SwfdecVideoFormat;
-
-typedef struct {
- guint width; /* width of image in pixels */
- guint height; /* height of image in pixels */
- const guint8 * plane[3]; /* planes of the image, not all might be used */
- const guint8 * mask; /* A8 mask or NULL if none */
- guint rowstride[3]; /* rowstrides of the planes */
- guint mask_rowstride; /* rowstride of mask plane */
-} SwfdecVideoImage;
-
-typedef struct _SwfdecVideoDecoder SwfdecVideoDecoder;
-typedef SwfdecVideoDecoder * (SwfdecVideoDecoderNewFunc) (guint format);
-
-/* notes about the decode function:
- * - the data must be in the format specified by swfdec_video_codec_get_format()
- * - the data returned in the image belongs to the decoder and must be valid
- * until the next function is called on the decoder.
- * - you need to explicitly set mask to %NULL.
- */
-struct _SwfdecVideoDecoder {
- guint codec;
- gboolean (* decode) (SwfdecVideoDecoder * decoder,
- SwfdecBuffer * buffer,
- SwfdecVideoImage * result);
- void (* free) (SwfdecVideoDecoder * decoder);
-};
-
-SwfdecVideoFormat swfdec_video_codec_get_format (guint codec);
-
-SwfdecVideoDecoder * swfdec_video_decoder_new (guint codec);
-void swfdec_video_decoder_free (SwfdecVideoDecoder * decoder);
-
-cairo_surface_t * swfdec_video_decoder_decode (SwfdecVideoDecoder * decoder,
- SwfdecBuffer * buffer);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_codec_vp6_alpha.c b/libswfdec/swfdec_codec_vp6_alpha.c
deleted file mode 100644
index 672d3d7..0000000
--- a/libswfdec/swfdec_codec_vp6_alpha.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include <zlib.h>
-#include <liboil/liboil.h>
-
-#include "swfdec_codec_video.h"
-#include "swfdec_bits.h"
-#include "swfdec_debug.h"
-#include "swfdec_internal.h"
-
-typedef struct _SwfdecCodecVp6Alpha SwfdecCodecVp6Alpha;
-
-struct _SwfdecCodecVp6Alpha {
- SwfdecVideoDecoder decoder; /* the decoder */
- SwfdecVideoDecoder * image; /* the image decoder */
- SwfdecVideoDecoder * alpha; /* the alpha decoder */
-};
-
-static gboolean
-swfdec_video_decoder_vp6_alpha_decode (SwfdecVideoDecoder *dec, SwfdecBuffer *buffer,
- SwfdecVideoImage *image)
-{
- SwfdecCodecVp6Alpha *vp6 = (SwfdecCodecVp6Alpha *) dec;
- SwfdecBuffer *tmp;
- SwfdecVideoImage alpha;
- SwfdecBits bits;
- guint size;
-
- swfdec_bits_init (&bits, buffer);
- size = swfdec_bits_get_bu24 (&bits);
- tmp = swfdec_bits_get_buffer (&bits, size);
- if (tmp == NULL)
- return FALSE;
- if (!vp6->image->decode (vp6->image, tmp, image)) {
- swfdec_buffer_unref (tmp);
- return FALSE;
- }
- swfdec_buffer_unref (tmp);
- tmp = swfdec_bits_get_buffer (&bits, -1);
- if (tmp == NULL)
- return FALSE;
- if (!vp6->alpha->decode (vp6->alpha, tmp, &alpha)) {
- swfdec_buffer_unref (tmp);
- return FALSE;
- }
- swfdec_buffer_unref (tmp);
- if (alpha.width != image->width || alpha.height != image->height) {
- SWFDEC_ERROR ("size of mask doesn't match image: %ux%u vs %ux%u",
- alpha.width, alpha.height, image->width, image->height);
- return FALSE;
- }
- image->mask = alpha.plane[0];
- image->mask_rowstride = alpha.rowstride[0];
- return TRUE;
-}
-
-static void
-swfdec_video_decoder_vp6_alpha_free (SwfdecVideoDecoder *dec)
-{
- SwfdecCodecVp6Alpha *vp6 = (SwfdecCodecVp6Alpha *) dec;
-
- if (vp6->image)
- swfdec_video_decoder_free (vp6->image);
- if (vp6->alpha)
- swfdec_video_decoder_free (vp6->alpha);
- g_free (vp6);
-}
-
-SwfdecVideoDecoder *
-swfdec_video_decoder_vp6_alpha_new (guint type)
-{
- SwfdecCodecVp6Alpha *vp6;
-
- if (type != SWFDEC_VIDEO_CODEC_VP6_ALPHA)
- return NULL;
-
- vp6 = g_new0 (SwfdecCodecVp6Alpha, 1);
- vp6->decoder.decode = swfdec_video_decoder_vp6_alpha_decode;
- vp6->decoder.free = swfdec_video_decoder_vp6_alpha_free;
- vp6->image = swfdec_video_decoder_new (SWFDEC_VIDEO_CODEC_VP6);
- vp6->alpha = swfdec_video_decoder_new (SWFDEC_VIDEO_CODEC_VP6);
- if (vp6->alpha == NULL || vp6->image == NULL) {
- swfdec_video_decoder_vp6_alpha_free (&vp6->decoder);
- return NULL;
- }
-
- return &vp6->decoder;
-}
-
diff --git a/libswfdec/swfdec_color.c b/libswfdec/swfdec_color.c
deleted file mode 100644
index 9ef554a..0000000
--- a/libswfdec/swfdec_color.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-#include "swfdec_color.h"
-#include "swfdec_debug.h"
-
-SwfdecColor
-swfdec_color_apply_morph (SwfdecColor start, SwfdecColor end, guint ratio)
-{
- guint r, g, b, a;
- guint start_ratio, end_ratio;
-
- g_assert (ratio < 65536);
- if (ratio == 0)
- return start;
- if (ratio == 65535)
- return end;
- start_ratio = 65535 - ratio;
- end_ratio = ratio;
- r = (SWFDEC_COLOR_R (start) * start_ratio + SWFDEC_COLOR_R (end) * end_ratio) / 65535;
- g = (SWFDEC_COLOR_G (start) * start_ratio + SWFDEC_COLOR_G (end) * end_ratio) / 65535;
- b = (SWFDEC_COLOR_B (start) * start_ratio + SWFDEC_COLOR_B (end) * end_ratio) / 65535;
- a = (SWFDEC_COLOR_A (start) * start_ratio + SWFDEC_COLOR_A (end) * end_ratio) / 65535;
-
- return SWFDEC_COLOR_COMBINE (r, g, b, a);
-}
-
-void
-swfdec_color_set_source (cairo_t *cr, SwfdecColor color)
-{
- cairo_set_source_rgba (cr,
- SWFDEC_COLOR_R (color) / 255.0, SWFDEC_COLOR_G (color) / 255.0,
- SWFDEC_COLOR_B (color) / 255.0, SWFDEC_COLOR_A (color) / 255.0);
-}
-
-SwfdecColor
-swfdec_color_apply_transform_premultiplied (SwfdecColor in,
- const SwfdecColorTransform * trans)
-{
- int r, g, b, a, aold;
-
- if (trans->mask)
- return SWFDEC_COLOR_COMBINE (0, 0, 0, 255);
-
- aold = SWFDEC_COLOR_A (in);
- if (aold == 0)
- return 0;
-
- a = (aold * trans->aa >> 8) + trans->ab;
- a = CLAMP (a, 0, 255);
-
- r = SWFDEC_COLOR_R (in);
- g = SWFDEC_COLOR_G (in);
- b = SWFDEC_COLOR_B (in);
- r = (r * trans->ra * a / aold >> 8) + trans->rb * a / 255;
- r = CLAMP (r, 0, a);
- g = (g * trans->ga * a / aold >> 8) + trans->gb * a / 255;
- g = CLAMP (g, 0, a);
- b = (b * trans->ba * a / aold >> 8) + trans->bb * a / 255;
- b = CLAMP (b, 0, a);
-
- return SWFDEC_COLOR_COMBINE (r, g, b, a);
-}
-
-SwfdecColor
-swfdec_color_apply_transform (SwfdecColor in, const SwfdecColorTransform * trans)
-{
- int r, g, b, a;
-
- if (trans->mask)
- return SWFDEC_COLOR_COMBINE (0, 0, 0, 255);
-
- r = SWFDEC_COLOR_R (in);
- g = SWFDEC_COLOR_G (in);
- b = SWFDEC_COLOR_B (in);
- a = SWFDEC_COLOR_A (in);
-
- SWFDEC_LOG ("in rgba %d,%d,%d,%d", r, g, b, a);
-
- r = (r * trans->ra >> 8) + trans->rb;
- g = (g * trans->ga >> 8) + trans->gb;
- b = (b * trans->ba >> 8) + trans->bb;
- a = (a * trans->aa >> 8) + trans->ab;
-
- r = CLAMP (r, 0, 255);
- g = CLAMP (g, 0, 255);
- b = CLAMP (b, 0, 255);
- a = CLAMP (a, 0, 255);
-
- SWFDEC_LOG ("out rgba %d,%d,%d,%d", r, g, b, a);
-
- return SWFDEC_COLOR_COMBINE (r, g, b, a);
-}
-
-/**
- * swfdec_color_transform_init_identity:
- * @trans: a #SwfdecColorTransform
- *
- * Initializes the color transform so it doesn't transform any colors.
- **/
-void
-swfdec_color_transform_init_identity (SwfdecColorTransform * trans)
-{
- g_return_if_fail (trans != NULL);
-
- trans->mask = FALSE;
- trans->ra = 256;
- trans->ga = 256;
- trans->ba = 256;
- trans->aa = 256;
- trans->rb = 0;
- trans->gb = 0;
- trans->bb = 0;
- trans->ab = 0;
-}
-
-void
-swfdec_color_transform_init_mask (SwfdecColorTransform *trans)
-{
- g_return_if_fail (trans != NULL);
-
- trans->mask = TRUE;
- /* don't init the other values so valgrind complains when they get accessed */
-}
-
-/**
- * swfdec_color_transform_init_color:
- * @trans: a #SwfdecColorTransform
- * @color: a #SwfdecColor to transform to
- *
- * Initializes this color transform so it results in exactly @color no matter
- * the input.
- **/
-void
-swfdec_color_transform_init_color (SwfdecColorTransform *trans, SwfdecColor color)
-{
- trans->mask = FALSE;
- trans->ra = 0;
- trans->rb = SWFDEC_COLOR_R (color);
- trans->ga = 0;
- trans->gb = SWFDEC_COLOR_G (color);
- trans->ba = 0;
- trans->bb = SWFDEC_COLOR_B (color);
- trans->aa = 0;
- trans->ab = SWFDEC_COLOR_A (color);
-}
-
-gboolean
-swfdec_color_transform_is_identity (const SwfdecColorTransform * trans)
-{
- return trans->mask == FALSE &&
- trans->ra == 256 && trans->ga == 256 && trans->ba == 256 && trans->aa == 256 &&
- trans->rb == 0 && trans->gb == 0 && trans->bb == 0 && trans->ab == 0;
-}
-
-/**
- * swfdec_color_transform_chain:
- * @dest: #SwfdecColorTransform to take the result
- * @last: a #SwfdecColorTransform
- * @first: a #SwfdecColorTransform
- *
- * Computes a color transform that has the same effect as if the color
- * transforms @first and @last would have been applied one after another.
- **/
-void
-swfdec_color_transform_chain (SwfdecColorTransform *dest,
- const SwfdecColorTransform *last, const SwfdecColorTransform *first)
-{
- g_return_if_fail (dest != NULL);
- g_return_if_fail (last != NULL);
- g_return_if_fail (first != NULL);
- g_return_if_fail (!last->mask);
-
- if (first->mask) {
- swfdec_color_transform_init_mask (dest);
- return;
- }
- dest->mask = FALSE;
- dest->ra = last->ra * first->ra >> 8;
- dest->rb = (last->ra * first->rb >> 8) + last->rb;
- dest->ga = last->ga * first->ga >> 8;
- dest->gb = (last->ga * first->gb >> 8) + last->gb;
- dest->ba = last->ba * first->ba >> 8;
- dest->bb = (last->ba * first->bb >> 8) + last->bb;
- dest->aa = last->aa * first->aa >> 8;
- dest->ab = (last->aa * first->ab >> 8) + last->ab;
-}
-
-void
-swfdec_matrix_ensure_invertible (cairo_matrix_t *matrix, cairo_matrix_t *inverse)
-{
- cairo_matrix_t tmp;
-
- g_return_if_fail (matrix != NULL);
-
- if (inverse == NULL)
- inverse = &tmp;
-
- g_assert (isfinite (matrix->xx) && isfinite (matrix->yx) && isfinite (matrix->xy) && isfinite (matrix->yy));
- *inverse = *matrix;
- while (cairo_matrix_invert (inverse)) {
- SWFDEC_INFO ("matrix not invertible, adding epsilon to smallest member");
- /* add epsilon at point closest to zero */
-#define EPSILON (1.0 / SWFDEC_FIXED_SCALE_FACTOR)
- if (ABS (matrix->xx) <= ABS (matrix->xy) &&
- ABS (matrix->xx) <= ABS (matrix->yx) &&
- ABS (matrix->xx) <= ABS (matrix->yy))
- matrix->xx += (matrix->xx >= 0) ? EPSILON : -EPSILON;
- else if (ABS (matrix->yy) <= ABS (matrix->xy) &&
- ABS (matrix->yy) <= ABS (matrix->yx))
- matrix->yy += (matrix->yy >= 0) ? EPSILON : -EPSILON;
- else if (ABS (matrix->xy) <= ABS (matrix->yx))
- matrix->xy += (matrix->xy >= 0) ? EPSILON : -EPSILON;
- else
- matrix->yx += (matrix->yx >= 0) ? EPSILON : -EPSILON;
- *inverse = *matrix;
- }
-}
-
-double
-swfdec_matrix_get_xscale (const cairo_matrix_t *matrix)
-{
- double alpha;
-
- if (matrix->xx) {
- alpha = atan2 (matrix->yx, matrix->xx);
- alpha = cos (alpha);
- return matrix->xx / alpha * 100;
- } else {
- return matrix->yx * 100;
- }
-}
-
-double
-swfdec_matrix_get_yscale (const cairo_matrix_t *matrix)
-{
- double alpha;
-
- if (matrix->yy) {
- alpha = atan2 (matrix->xy, matrix->yy);
- alpha = cos (alpha);
- return matrix->yy / alpha * 100;
- } else {
- return matrix->xy * 100;
- }
-}
-
-double
-swfdec_matrix_get_rotation (const cairo_matrix_t *matrix)
-{
- return atan2 (matrix->yx, matrix->xx) * 180 / G_PI;
-}
-
-void
-swfdec_matrix_morph (cairo_matrix_t *dest, const cairo_matrix_t *start,
- const cairo_matrix_t *end, guint ratio)
-{
- guint inv_ratio = 65535 - ratio;
- g_assert (ratio < 65536);
-
- if (ratio == 0) {
- *dest = *start;
- return;
- }
- if (ratio == 65535) {
- *dest = *end;
- return;
- }
- dest->xx = (start->xx * inv_ratio + end->xx * ratio) / 65535;
- dest->xy = (start->xy * inv_ratio + end->xy * ratio) / 65535;
- dest->yy = (start->yy * inv_ratio + end->yy * ratio) / 65535;
- dest->yx = (start->yx * inv_ratio + end->yx * ratio) / 65535;
- dest->x0 = (start->x0 * inv_ratio + end->x0 * ratio) / 65535;
- dest->y0 = (start->y0 * inv_ratio + end->y0 * ratio) / 65535;
-}
-
diff --git a/libswfdec/swfdec_color.h b/libswfdec/swfdec_color.h
deleted file mode 100644
index d2ba7a1..0000000
--- a/libswfdec/swfdec_color.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef __SWFDEC_COLOR_H__
-#define __SWFDEC_COLOR_H__
-
-#include <libswfdec/swfdec_types.h>
-
-struct _SwfdecColorTransform {
- gboolean mask; /* TRUE if this is a mask - masks are always black */
- /* naming here is taken from ActionScript, where ?a is the multiplier and ?b the offset */
- int ra, rb, ga, gb, ba, bb, aa, ab;
-};
-
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
-#define SWFDEC_COLOR_INDEX_ALPHA (3)
-#define SWFDEC_COLOR_INDEX_RED (2)
-#define SWFDEC_COLOR_INDEX_GREEN (1)
-#define SWFDEC_COLOR_INDEX_BLUE (0)
-#elif G_BYTE_ORDER == G_BIG_ENDIAN
-#define SWFDEC_COLOR_INDEX_ALPHA (0)
-#define SWFDEC_COLOR_INDEX_RED (1)
-#define SWFDEC_COLOR_INDEX_GREEN (2)
-#define SWFDEC_COLOR_INDEX_BLUE (3)
-#else
-#error "Unknown byte order"
-#endif
-
-#define SWFDEC_COLOR_COMBINE(r,g,b,a) (((a)<<24) | ((r)<<16) | ((g)<<8) | (b))
-#define SWFDEC_COLOR_A(x) (((x)>>24)&0xff)
-#define SWFDEC_COLOR_R(x) (((x)>>16)&0xff)
-#define SWFDEC_COLOR_G(x) (((x)>>8)&0xff)
-#define SWFDEC_COLOR_B(x) ((x)&0xff)
-
-SwfdecColor swfdec_color_apply_morph (SwfdecColor start, SwfdecColor end, guint ratio);
-void swfdec_color_set_source (cairo_t *cr, SwfdecColor color);
-void swfdec_color_transform_init_identity (SwfdecColorTransform * trans);
-void swfdec_color_transform_init_mask (SwfdecColorTransform * trans);
-void swfdec_color_transform_init_color (SwfdecColorTransform *trans, SwfdecColor color);
-gboolean swfdec_color_transform_is_identity (const SwfdecColorTransform * trans);
-#define swfdec_color_transform_is_mask(trans) ((trans)->mask)
-void swfdec_color_transform_chain (SwfdecColorTransform *dest,
- const SwfdecColorTransform *last, const SwfdecColorTransform *first);
-SwfdecColor swfdec_color_apply_transform (SwfdecColor in,
- const SwfdecColorTransform * trans);
-SwfdecColor swfdec_color_apply_transform_premultiplied (SwfdecColor in,
- const SwfdecColorTransform * trans);
-
-void swfdec_matrix_ensure_invertible (cairo_matrix_t *matrix, cairo_matrix_t *inverse);
-double swfdec_matrix_get_xscale (const cairo_matrix_t *matrix);
-double swfdec_matrix_get_yscale (const cairo_matrix_t *matrix);
-double swfdec_matrix_get_rotation (const cairo_matrix_t *matrix);
-void swfdec_matrix_morph (cairo_matrix_t *dest, const cairo_matrix_t *start,
- const cairo_matrix_t *end, guint ratio);
-
-
-#endif
diff --git a/libswfdec/swfdec_color_as.c b/libswfdec/swfdec_color_as.c
deleted file mode 100644
index 35a8304..0000000
--- a/libswfdec/swfdec_color_as.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_context.h"
-#include "swfdec_as_native_function.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-#include "swfdec_internal.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_movie.h"
-
-/*** AS CODE ***/
-
-static SwfdecMovie *
-swfdec_movie_color_get_movie (SwfdecAsObject *object)
-{
- SwfdecAsValue val;
- SwfdecAsObject *target;
-
- if (object == NULL)
- return NULL;
-
- swfdec_as_object_get_variable (object, SWFDEC_AS_STR_target, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return NULL;
-
- target = SWFDEC_AS_VALUE_GET_OBJECT (&val);
- if (!SWFDEC_IS_MOVIE (target))
- return NULL;
-
- return SWFDEC_MOVIE (target);
-}
-
-SWFDEC_AS_NATIVE (700, 2, swfdec_movie_color_getRGB)
-void
-swfdec_movie_color_getRGB (SwfdecAsContext *cx, SwfdecAsObject *obj,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- int result;
- SwfdecMovie *movie;
-
- movie = swfdec_movie_color_get_movie (obj);
-
- if (movie == NULL)
- return;
-
- result = (movie->color_transform.rb << 16) |
- ((movie->color_transform.gb % 256) << 8) |
- (movie->color_transform.bb % 256);
- SWFDEC_AS_VALUE_SET_INT (ret, result);
-}
-
-static inline void
-add_variable (SwfdecAsObject *obj, const char *name, double value)
-{
- SwfdecAsValue val;
-
- SWFDEC_AS_VALUE_SET_NUMBER (&val, value);
- swfdec_as_object_set_variable (obj, name, &val);
-}
-
-SWFDEC_AS_NATIVE (700, 3, swfdec_movie_color_getTransform)
-void
-swfdec_movie_color_getTransform (SwfdecAsContext *cx, SwfdecAsObject *obj,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecAsObject *ret;
- SwfdecMovie *movie;
-
- movie = swfdec_movie_color_get_movie (obj);
-
- if (movie == NULL)
- return;
-
- ret = swfdec_as_object_new (cx);
- if (ret == NULL)
- return;
-
- add_variable (ret, SWFDEC_AS_STR_ra, movie->color_transform.ra * 100.0 / 256.0);
- add_variable (ret, SWFDEC_AS_STR_ga, movie->color_transform.ga * 100.0 / 256.0);
- add_variable (ret, SWFDEC_AS_STR_ba, movie->color_transform.ba * 100.0 / 256.0);
- add_variable (ret, SWFDEC_AS_STR_aa, movie->color_transform.aa * 100.0 / 256.0);
- add_variable (ret, SWFDEC_AS_STR_rb, movie->color_transform.rb);
- add_variable (ret, SWFDEC_AS_STR_gb, movie->color_transform.gb);
- add_variable (ret, SWFDEC_AS_STR_bb, movie->color_transform.bb);
- add_variable (ret, SWFDEC_AS_STR_ab, movie->color_transform.ab);
- SWFDEC_AS_VALUE_SET_OBJECT (rval, ret);
-}
-
-SWFDEC_AS_NATIVE (700, 0, swfdec_movie_color_setRGB)
-void
-swfdec_movie_color_setRGB (SwfdecAsContext *cx, SwfdecAsObject *obj,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- guint color;
- SwfdecMovie *movie;
-
- if (argc < 1)
- return;
-
- movie = swfdec_movie_color_get_movie (obj);
-
- if (movie == NULL)
- return;
-
- color = swfdec_as_value_to_integer (cx, &argv[0]);
-
- movie->color_transform.ra = 0;
- movie->color_transform.rb = (color & 0xFF0000) >> 16;
- movie->color_transform.ga = 0;
- movie->color_transform.gb = (color & 0xFF00) >> 8;
- movie->color_transform.ba = 0;
- movie->color_transform.bb = color & 0xFF;
- swfdec_movie_invalidate_last (movie);
-}
-
-static inline void
-parse_property (SwfdecAsObject *obj, const char *name, int *target, gboolean scale)
-{
- SwfdecAsValue val;
- double d;
-
- if (!swfdec_as_object_get_variable (obj, name, &val))
- return;
- d = swfdec_as_value_to_number (obj->context, &val);
- if (scale) {
- *target = d * 256.0 / 100.0;
- } else {
- *target = d;
- }
-}
-
-SWFDEC_AS_NATIVE (700, 1, swfdec_movie_color_setTransform)
-void
-swfdec_movie_color_setTransform (SwfdecAsContext *cx, SwfdecAsObject *obj,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecAsObject *parse;
- SwfdecMovie *movie;
-
- if (argc < 1)
- return;
-
- movie = swfdec_movie_color_get_movie (obj);
-
- if (movie == NULL)
- return;
-
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]))
- return;
- parse = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
- parse_property (parse, SWFDEC_AS_STR_ra, &movie->color_transform.ra, TRUE);
- parse_property (parse, SWFDEC_AS_STR_ga, &movie->color_transform.ga, TRUE);
- parse_property (parse, SWFDEC_AS_STR_ba, &movie->color_transform.ba, TRUE);
- parse_property (parse, SWFDEC_AS_STR_aa, &movie->color_transform.aa, TRUE);
- parse_property (parse, SWFDEC_AS_STR_rb, &movie->color_transform.rb, FALSE);
- parse_property (parse, SWFDEC_AS_STR_gb, &movie->color_transform.gb, FALSE);
- parse_property (parse, SWFDEC_AS_STR_bb, &movie->color_transform.bb, FALSE);
- parse_property (parse, SWFDEC_AS_STR_ab, &movie->color_transform.ab, FALSE);
- swfdec_movie_invalidate_last (movie);
-}
diff --git a/libswfdec/swfdec_color_matrix_filter.c b/libswfdec/swfdec_color_matrix_filter.c
deleted file mode 100644
index 95959af..0000000
--- a/libswfdec/swfdec_color_matrix_filter.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (1110, 1, swfdec_color_matrix_filter_get_matrix)
-void
-swfdec_color_matrix_filter_get_matrix (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorMatrixFilter.matrix (get)");
-}
-
-SWFDEC_AS_NATIVE (1110, 2, swfdec_color_matrix_filter_set_matrix)
-void
-swfdec_color_matrix_filter_set_matrix (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorMatrixFilter.matrix (set)");
-}
-
-// constructor
-SWFDEC_AS_NATIVE (1110, 0, swfdec_color_matrix_filter_contruct)
-void
-swfdec_color_matrix_filter_contruct (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorMatrixFilter");
-}
diff --git a/libswfdec/swfdec_color_transform.c b/libswfdec/swfdec_color_transform.c
deleted file mode 100644
index a06a370..0000000
--- a/libswfdec/swfdec_color_transform.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-// properties
-SWFDEC_AS_NATIVE (1105, 101, swfdec_color_transform_get_alphaMultiplier)
-void
-swfdec_color_transform_get_alphaMultiplier (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform.alphaMultiplier (get)");
-}
-
-SWFDEC_AS_NATIVE (1105, 102, swfdec_color_transform_set_alphaMultiplier)
-void
-swfdec_color_transform_set_alphaMultiplier (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform.alphaMultiplier (set)");
-}
-
-SWFDEC_AS_NATIVE (1105, 103, swfdec_color_transform_get_redMultiplier)
-void
-swfdec_color_transform_get_redMultiplier (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform.redMultiplier (get)");
-}
-
-SWFDEC_AS_NATIVE (1105, 104, swfdec_color_transform_set_redMultiplier)
-void
-swfdec_color_transform_set_redMultiplier (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform.redMultiplier (set)");
-}
-
-SWFDEC_AS_NATIVE (1105, 105, swfdec_color_transform_get_greenMultiplier)
-void
-swfdec_color_transform_get_greenMultiplier (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform.greenMultiplier (get)");
-}
-
-SWFDEC_AS_NATIVE (1105, 106, swfdec_color_transform_set_greenMultiplier)
-void
-swfdec_color_transform_set_greenMultiplier (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform.greenMultiplier (set)");
-}
-
-SWFDEC_AS_NATIVE (1105, 107, swfdec_color_transform_get_blueMultiplier)
-void
-swfdec_color_transform_get_blueMultiplier (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform.blueMultiplier (get)");
-}
-
-SWFDEC_AS_NATIVE (1105, 108, swfdec_color_transform_set_blueMultiplier)
-void
-swfdec_color_transform_set_blueMultiplier (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform.blueMultiplier (set)");
-}
-
-SWFDEC_AS_NATIVE (1105, 109, swfdec_color_transform_get_alphaOffset)
-void
-swfdec_color_transform_get_alphaOffset (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform.alphaOffset (get)");
-}
-
-SWFDEC_AS_NATIVE (1105, 110, swfdec_color_transform_set_alphaOffset)
-void
-swfdec_color_transform_set_alphaOffset (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform.alphaOffset (set)");
-}
-
-SWFDEC_AS_NATIVE (1105, 111, swfdec_color_transform_get_redOffset)
-void
-swfdec_color_transform_get_redOffset (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform.redOffset (get)");
-}
-
-SWFDEC_AS_NATIVE (1105, 112, swfdec_color_transform_set_redOffset)
-void
-swfdec_color_transform_set_redOffset (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform.redOffset (set)");
-}
-
-SWFDEC_AS_NATIVE (1105, 113, swfdec_color_transform_get_greenOffset)
-void
-swfdec_color_transform_get_greenOffset (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform.greenOffset (get)");
-}
-
-SWFDEC_AS_NATIVE (1105, 114, swfdec_color_transform_set_greenOffset)
-void
-swfdec_color_transform_set_greenOffset (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform.greenOffset (set)");
-}
-
-SWFDEC_AS_NATIVE (1105, 115, swfdec_color_transform_get_blueOffset)
-void
-swfdec_color_transform_get_blueOffset (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform.blueOffset (get)");
-}
-
-SWFDEC_AS_NATIVE (1105, 116, swfdec_color_transform_set_blueOffset)
-void
-swfdec_color_transform_set_blueOffset (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform.blueOffset (set)");
-}
-
-SWFDEC_AS_NATIVE (1105, 117, swfdec_color_transform_get_rgb)
-void
-swfdec_color_transform_get_rgb (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform.rgb (get)");
-}
-
-SWFDEC_AS_NATIVE (1105, 118, swfdec_color_transform_set_rgb)
-void
-swfdec_color_transform_set_rgb (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform.rgb (set)");
-}
-
-// normal
-SWFDEC_AS_NATIVE (1105, 1, swfdec_color_transform_concat)
-void
-swfdec_color_transform_concat (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform.concat");
-}
-
-// constructor
-SWFDEC_AS_NATIVE (1105, 0, swfdec_color_transform_construct)
-void
-swfdec_color_transform_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ColorTransform");
-}
diff --git a/libswfdec/swfdec_convolution_filter.c b/libswfdec/swfdec_convolution_filter.c
deleted file mode 100644
index bcb6309..0000000
--- a/libswfdec/swfdec_convolution_filter.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (1109, 1, swfdec_convolution_filter_get_matrixX)
-void
-swfdec_convolution_filter_get_matrixX (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ConvolutionFilter.matrixX (get)");
-}
-
-SWFDEC_AS_NATIVE (1109, 2, swfdec_convolution_filter_set_matrixX)
-void
-swfdec_convolution_filter_set_matrixX (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ConvolutionFilter.matrixX (set)");
-}
-
-SWFDEC_AS_NATIVE (1109, 3, swfdec_convolution_filter_get_matrixY)
-void
-swfdec_convolution_filter_get_matrixY (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ConvolutionFilter.matrixY (get)");
-}
-
-SWFDEC_AS_NATIVE (1109, 4, swfdec_convolution_filter_set_matrixY)
-void
-swfdec_convolution_filter_set_matrixY (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ConvolutionFilter.matrixY (set)");
-}
-
-SWFDEC_AS_NATIVE (1109, 5, swfdec_convolution_filter_get_matrix)
-void
-swfdec_convolution_filter_get_matrix (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ConvolutionFilter.matrix (get)");
-}
-
-SWFDEC_AS_NATIVE (1109, 6, swfdec_convolution_filter_set_matrix)
-void
-swfdec_convolution_filter_set_matrix (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ConvolutionFilter.matrix (set)");
-}
-
-SWFDEC_AS_NATIVE (1109, 7, swfdec_convolution_filter_get_divisor)
-void
-swfdec_convolution_filter_get_divisor (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ConvolutionFilter.divisor (get)");
-}
-
-SWFDEC_AS_NATIVE (1109, 8, swfdec_convolution_filter_set_divisor)
-void
-swfdec_convolution_filter_set_divisor (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ConvolutionFilter.divisor (set)");
-}
-
-SWFDEC_AS_NATIVE (1109, 9, swfdec_convolution_filter_get_bias)
-void
-swfdec_convolution_filter_get_bias (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ConvolutionFilter.bias (get)");
-}
-
-SWFDEC_AS_NATIVE (1109, 10, swfdec_convolution_filter_set_bias)
-void
-swfdec_convolution_filter_set_bias (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ConvolutionFilter.bias (set)");
-}
-
-SWFDEC_AS_NATIVE (1109, 11, swfdec_convolution_filter_get_preserveAlpha)
-void
-swfdec_convolution_filter_get_preserveAlpha (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ConvolutionFilter.preserveAlpha (get)");
-}
-
-SWFDEC_AS_NATIVE (1109, 12, swfdec_convolution_filter_set_preserveAlpha)
-void
-swfdec_convolution_filter_set_preserveAlpha (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ConvolutionFilter.preserveAlpha (set)");
-}
-
-SWFDEC_AS_NATIVE (1109, 13, swfdec_convolution_filter_get_clamp)
-void
-swfdec_convolution_filter_get_clamp (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ConvolutionFilter.clamp (get)");
-}
-
-SWFDEC_AS_NATIVE (1109, 14, swfdec_convolution_filter_set_clamp)
-void
-swfdec_convolution_filter_set_clamp (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ConvolutionFilter.clamp (set)");
-}
-
-SWFDEC_AS_NATIVE (1109, 15, swfdec_convolution_filter_get_color)
-void
-swfdec_convolution_filter_get_color (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ConvolutionFilter.color (get)");
-}
-
-SWFDEC_AS_NATIVE (1109, 16, swfdec_convolution_filter_set_color)
-void
-swfdec_convolution_filter_set_color (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ConvolutionFilter.color (set)");
-}
-
-SWFDEC_AS_NATIVE (1109, 17, swfdec_convolution_filter_get_alpha)
-void
-swfdec_convolution_filter_get_alpha (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ConvolutionFilter.alpha (get)");
-}
-
-SWFDEC_AS_NATIVE (1109, 18, swfdec_convolution_filter_set_alpha)
-void
-swfdec_convolution_filter_set_alpha (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ConvolutionFilter.alpha (set)");
-}
-
-// constructor
-SWFDEC_AS_NATIVE (1109, 0, swfdec_convolution_filter_contruct)
-void
-swfdec_convolution_filter_contruct (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("ConvolutionFilter");
-}
diff --git a/libswfdec/swfdec_debug.c b/libswfdec/swfdec_debug.c
deleted file mode 100644
index 54eee5c..0000000
--- a/libswfdec/swfdec_debug.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <glib.h>
-#include "swfdec_debug.h"
-
-static const char *swfdec_debug_level_names[] = {
- "NONE ",
- "ERROR",
- "FIXME",
- "WARN ",
- "INFO ",
- "DEBUG",
- "LOG "
-};
-
-#ifndef SWFDEC_LEVEL_DEFAULT
-# define SWFDEC_LEVEL_DEFAULT SWFDEC_LEVEL_FIXME
-#endif
-
-static guint swfdec_debug_level = SWFDEC_LEVEL_DEFAULT;
-
-void
-swfdec_debug_log (guint level, const char *file, const char *function,
- int line, const char *format, ...)
-{
- va_list varargs;
- char *s;
-
- if (level > swfdec_debug_level)
- return;
-
- va_start (varargs, format);
- s = g_strdup_vprintf (format, varargs);
- va_end (varargs);
-
- g_printerr ("SWFDEC: %s: %s(%d): %s: %s\n",
- swfdec_debug_level_names[level], file, line, function, s);
- g_free (s);
-}
-
-void
-swfdec_debug_set_level (guint level)
-{
- if (swfdec_debug_level >= G_N_ELEMENTS (swfdec_debug_level_names))
- swfdec_debug_level = G_N_ELEMENTS (swfdec_debug_level_names) - 1;
- else
- swfdec_debug_level = level;
-}
-
-int
-swfdec_debug_get_level (void)
-{
- return swfdec_debug_level;
-}
-
diff --git a/libswfdec/swfdec_debug.h b/libswfdec/swfdec_debug.h
deleted file mode 100644
index e6821e9..0000000
--- a/libswfdec/swfdec_debug.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef __SWFDEC_DEBUG_H__
-#define __SWFDEC_DEBUG_H__
-
-#include <glib.h>
-
-enum {
- SWFDEC_LEVEL_NONE = 0,
- SWFDEC_LEVEL_ERROR,
- SWFDEC_LEVEL_FIXME,
- SWFDEC_LEVEL_WARNING,
- SWFDEC_LEVEL_INFO,
- SWFDEC_LEVEL_DEBUG,
- SWFDEC_LEVEL_LOG
-};
-
-#define SWFDEC_ERROR(...) \
- SWFDEC_DEBUG_LEVEL(SWFDEC_LEVEL_ERROR, __VA_ARGS__)
-#define SWFDEC_FIXME(...) \
- SWFDEC_DEBUG_LEVEL(SWFDEC_LEVEL_FIXME, __VA_ARGS__)
-#define SWFDEC_WARNING(...) \
- SWFDEC_DEBUG_LEVEL(SWFDEC_LEVEL_WARNING, __VA_ARGS__)
-#define SWFDEC_INFO(...) \
- SWFDEC_DEBUG_LEVEL(SWFDEC_LEVEL_INFO, __VA_ARGS__)
-#define SWFDEC_DEBUG(...) \
- SWFDEC_DEBUG_LEVEL(SWFDEC_LEVEL_DEBUG, __VA_ARGS__)
-#define SWFDEC_LOG(...) \
- SWFDEC_DEBUG_LEVEL(SWFDEC_LEVEL_LOG, __VA_ARGS__)
-
-#define SWFDEC_STUB(fun) \
- SWFDEC_DEBUG_LEVEL (SWFDEC_LEVEL_FIXME, "%s %s", fun, "is not implemented yet")
-
-#ifdef SWFDEC_DISABLE_DEBUG
-#define SWFDEC_DEBUG_LEVEL(level,...) (void) 0
-#else
-#define SWFDEC_DEBUG_LEVEL(level,...) \
- swfdec_debug_log ((level), __FILE__, G_STRFUNC, __LINE__, __VA_ARGS__)
-#endif
-
-void swfdec_debug_log (guint level, const char *file, const char *function,
- int line, const char *format, ...) G_GNUC_PRINTF (5, 6);
-void swfdec_debug_set_level (guint level);
-int swfdec_debug_get_level (void);
-
-#endif
diff --git a/libswfdec/swfdec_debugger.c b/libswfdec/swfdec_debugger.c
deleted file mode 100644
index 2dca1df..0000000
--- a/libswfdec/swfdec_debugger.c
+++ /dev/null
@@ -1,617 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include "swfdec_debugger.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_frame_internal.h"
-#include "swfdec_as_interpret.h"
-#include "swfdec_debug.h"
-#include "swfdec_decoder.h"
-#include "swfdec_movie.h"
-#include "swfdec_player_internal.h"
-
-enum {
- SCRIPT_ADDED,
- SCRIPT_REMOVED,
- BREAKPOINT,
- BREAKPOINT_ADDED,
- BREAKPOINT_REMOVED,
- MOVIE_ADDED,
- MOVIE_REMOVED,
- LAST_SIGNAL
-};
-
-G_DEFINE_TYPE (SwfdecDebugger, swfdec_debugger, SWFDEC_TYPE_PLAYER)
-static guint signals[LAST_SIGNAL] = { 0, };
-
-/*** SwfdecDebuggerScript ***/
-
-typedef struct {
- guint version; /* version of parsed file */
- SwfdecConstantPool * constant_pool; /* current constant pool */
- GArray * commands; /* SwfdecDebuggerCommands parsed so far */
-} ScriptParser;
-
-static char *
-swfdec_debugger_print_push (ScriptParser *parser, const guint8 *data, guint len)
-{
- gboolean first = TRUE;
- SwfdecBits bits;
- GString *string = g_string_new ("Push");
-
- swfdec_bits_init_data (&bits, data, len);
- while (swfdec_bits_left (&bits)) {
- guint type = swfdec_bits_get_u8 (&bits);
- if (first)
- g_string_append (string, " ");
- else
- g_string_append (string, ", ");
- first = FALSE;
- switch (type) {
- case 0: /* string */
- {
- char *s = swfdec_bits_get_string (&bits, parser->version);
- if (!s)
- goto error;
- g_string_append_c (string, '"');
- g_string_append (string, s);
- g_string_append_c (string, '"');
- g_free (s);
- break;
- }
- case 1: /* float */
- g_string_append_printf (string, "%g", swfdec_bits_get_float (&bits));
- break;
- case 2: /* null */
- g_string_append (string, "null");
- break;
- case 3: /* undefined */
- g_string_append (string, "undefined");
- break;
- case 4: /* register */
- g_string_append_printf (string, "Register %u", swfdec_bits_get_u8 (&bits));
- break;
- case 5: /* boolean */
- g_string_append (string, swfdec_bits_get_u8 (&bits) ? "True" : "False");
- break;
- case 6: /* double */
- g_string_append_printf (string, "%g", swfdec_bits_get_double (&bits));
- break;
- case 7: /* 32bit int */
- g_string_append_printf (string, "%d", swfdec_bits_get_u32 (&bits));
- break;
- case 8: /* 8bit ConstantPool address */
- case 9: /* 16bit ConstantPool address */
- {
- guint id;
- const char *s;
-
- if (!parser->constant_pool) {
- SWFDEC_ERROR ("no constant pool");
- goto error;
- }
- id = type == 8 ? swfdec_bits_get_u8 (&bits) : swfdec_bits_get_u16 (&bits);
- if (id >= swfdec_constant_pool_size (parser->constant_pool)) {
- SWFDEC_ERROR ("constant pool size too small");
- goto error;
- }
- s = swfdec_constant_pool_get (parser->constant_pool, id);
- g_string_append_c (string, '"');
- g_string_append (string, s);
- g_string_append_c (string, '"');
- }
- break;
- default:
- SWFDEC_ERROR ("Push: type %u not implemented", type);
- goto error;
- }
- }
- return g_string_free (string, FALSE);
-
-error:
- g_string_free (string, TRUE);
- return g_strdup ("erroneous action Push");
-}
-
-/* NB: constant pool actions are special in that they are called at init time */
-static gboolean
-swfdec_debugger_add_command (gconstpointer bytecode, guint action,
- const guint8 *data, guint len, gpointer parserp)
-{
- ScriptParser *parser = parserp;
- SwfdecDebuggerCommand command;
-
- command.code = bytecode;
- if (action == SWFDEC_AS_ACTION_PUSH) {
- command.description = swfdec_debugger_print_push (parser, data, len);
- } else {
- command.description = swfdec_script_print_action (action, data, len);
- }
- g_assert (command.description != NULL);
- g_array_append_val (parser->commands, command);
- if (action == SWFDEC_AS_ACTION_CONSTANT_POOL) {
- if (parser->constant_pool)
- swfdec_constant_pool_free (parser->constant_pool);
- parser->constant_pool = swfdec_constant_pool_new_from_action (data, len, parser->version);
- }
- return TRUE;
-}
-
-static SwfdecDebuggerScript *
-swfdec_debugger_script_new (SwfdecScript *script)
-{
- ScriptParser parser;
- SwfdecDebuggerScript *ret;
-
- ret = g_new0 (SwfdecDebuggerScript, 1);
- ret->script = script;
- swfdec_script_ref (script);
- parser.commands = g_array_new (TRUE, FALSE, sizeof (SwfdecDebuggerCommand));
- parser.version = script->version;
- if (script->constant_pool) {
- parser.constant_pool = swfdec_constant_pool_new_from_action (
- script->constant_pool->data, script->constant_pool->length, parser.version);
- } else {
- parser.constant_pool = NULL;
- }
- swfdec_script_foreach (script, swfdec_debugger_add_command, &parser);
- ret->n_commands = parser.commands->len;
- ret->commands = (SwfdecDebuggerCommand *) g_array_free (parser.commands, FALSE);
- if (parser.constant_pool)
- swfdec_constant_pool_free (parser.constant_pool);
-
- return ret;
-}
-
-static void
-swfdec_debugger_script_free (SwfdecDebuggerScript *script)
-{
- guint i;
-
- g_assert (script);
- swfdec_script_unref (script->script);
- for (i = 0; i < script->n_commands; i++) {
- g_free (script->commands[i].description);
- }
- g_free (script->commands);
- g_free (script);
-}
-
-/*** BREAKPOINTS ***/
-
-typedef enum {
- BREAKPOINT_NONE,
- BREAKPOINT_PC
-} BreakpointType;
-
-typedef struct {
- BreakpointType type;
- const guint8 * pc;
-} Breakpoint;
-
-static void
-swfdec_debugger_update_interrupting (SwfdecDebugger *debugger)
-{
- guint i;
-
- debugger->has_breakpoints = debugger->stepping;
-
- for (i = 0; i < debugger->breakpoints->len && !debugger->has_breakpoints; i++) {
- Breakpoint *br = &g_array_index (debugger->breakpoints, Breakpoint, i);
-
- if (br->type != BREAKPOINT_NONE)
- debugger->has_breakpoints = TRUE;
- }
-}
-
-guint
-swfdec_debugger_set_breakpoint (SwfdecDebugger *debugger,
- SwfdecDebuggerScript *script, guint line)
-{
- guint i;
- Breakpoint *br = NULL;
-
- g_return_val_if_fail (SWFDEC_IS_DEBUGGER (debugger), 0);
- g_return_val_if_fail (script != NULL, 0);
- g_return_val_if_fail (line < script->n_commands, 0);
-
- for (i = 0; i < debugger->breakpoints->len; i++) {
- br = &g_array_index (debugger->breakpoints, Breakpoint, i);
- if (br->type == BREAKPOINT_NONE)
- break;
- br = NULL;
- }
-
- if (br == NULL) {
- g_array_set_size (debugger->breakpoints, debugger->breakpoints->len + 1);
- br = &g_array_index (debugger->breakpoints, Breakpoint,
- debugger->breakpoints->len - 1);
- }
- br->type = BREAKPOINT_PC;
- br->pc = script->commands[line].code;
- swfdec_debugger_update_interrupting (debugger);
- g_signal_emit (debugger, signals[BREAKPOINT_ADDED], 0, i + 1);
- return i + 1;
-}
-
-void
-swfdec_debugger_unset_breakpoint (SwfdecDebugger *debugger, guint id)
-{
- Breakpoint *br;
-
- g_return_if_fail (SWFDEC_IS_DEBUGGER (debugger));
- g_return_if_fail (id > 0);
-
- if (debugger->breakpoints == NULL)
- return;
- if (id > debugger->breakpoints->len)
- return;
- br = &g_array_index (debugger->breakpoints, Breakpoint, id - 1);
- if (br->type == BREAKPOINT_NONE)
- return;
-
- g_signal_emit (debugger, signals[BREAKPOINT_REMOVED], 0, id);
- br->type = BREAKPOINT_NONE;
- swfdec_debugger_update_interrupting (debugger);
-}
-
-static gboolean
-swfdec_debugger_get_from_as (SwfdecDebugger *debugger, SwfdecScript *script,
- const guint8 *pc, SwfdecDebuggerScript **script_out, guint *line_out)
-{
- guint line;
- SwfdecDebuggerScript *dscript = swfdec_debugger_get_script (debugger, script);
-
- if (dscript == NULL)
- return FALSE;
- for (line = 0; line < dscript->n_commands; line++) {
- if (pc == dscript->commands[line].code) {
- if (script_out)
- *script_out = dscript;
- if (line_out)
- *line_out = line;
- return TRUE;
- }
- if (pc < (guint8 *) dscript->commands[line].code)
- return FALSE;
- }
- return FALSE;
-}
-
-gboolean
-swfdec_debugger_get_current (SwfdecDebugger *debugger,
- SwfdecDebuggerScript **dscript, guint *line)
-{
- SwfdecAsFrame *frame;
-
- g_return_val_if_fail (SWFDEC_IS_DEBUGGER (debugger), FALSE);
-
- frame = SWFDEC_AS_CONTEXT (debugger)->frame;
- if (frame == NULL)
- return FALSE;
- if (frame->script == NULL) /* native function */
- return FALSE;
- return swfdec_debugger_get_from_as (debugger, frame->script, frame->pc, dscript, line);
-}
-
-typedef struct {
- const guint8 *pc;
- SwfdecScript *current;
-} BreakpointFinder;
-
-static void
-swfdec_debugger_find_script (gpointer key, gpointer value, gpointer data)
-{
- BreakpointFinder *find = data;
- SwfdecScript *script = key;
-
- if (script->buffer->data > find->pc ||
- find->pc >= (script->buffer->data + script->buffer->length))
- return;
- if (find->current == NULL ||
- find->current->buffer->length > script->buffer->length)
- find->current = script;
-}
-
-gboolean
-swfdec_debugger_get_breakpoint (SwfdecDebugger *debugger, guint id,
- SwfdecDebuggerScript **script, guint *line)
-{
- Breakpoint *br;
- BreakpointFinder find = { NULL, NULL };
-
- g_return_val_if_fail (SWFDEC_IS_DEBUGGER (debugger), FALSE);
- g_return_val_if_fail (id > 0, FALSE);
-
- if (debugger->breakpoints == NULL)
- return FALSE;
- if (id > debugger->breakpoints->len)
- return FALSE;
- br = &g_array_index (debugger->breakpoints, Breakpoint, id - 1);
- if (br->type == BREAKPOINT_NONE)
- return FALSE;
-
- find.pc = br->pc;
- g_hash_table_foreach (debugger->scripts, swfdec_debugger_find_script, &find);
- if (find.current == NULL)
- return FALSE;
- return swfdec_debugger_get_from_as (debugger, find.current, find.pc, script, line);
-}
-
-guint
-swfdec_debugger_get_n_breakpoints (SwfdecDebugger *debugger)
-{
- g_return_val_if_fail (SWFDEC_IS_DEBUGGER (debugger), 0);
-
- if (debugger->breakpoints == NULL)
- return 0;
-
- return debugger->breakpoints->len;
-}
-
-/*** SwfdecDebugger ***/
-
-static void
-swfdec_debugger_dispose (GObject *object)
-{
- SwfdecDebugger *debugger = SWFDEC_DEBUGGER (object);
-
- swfdec_debugger_set_stepping (debugger, FALSE);
- g_assert (g_hash_table_size (debugger->scripts) == 0);
- g_hash_table_destroy (debugger->scripts);
- if (debugger->breakpoints)
- g_array_free (debugger->breakpoints, TRUE);
-
- G_OBJECT_CLASS (swfdec_debugger_parent_class)->dispose (object);
-}
-
-#if 0
-static void
-swfdec_debugger_do_breakpoint (SwfdecDebugger *debugger, guint id)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (debugger);
-
- GList *walk;
- for (walk = player->roots; walk; walk = walk->next) {
- swfdec_movie_update (walk->data);
- }
- g_object_thaw_notify (G_OBJECT (debugger));
- if (!swfdec_rect_is_empty (&player->invalid)) {
- double x, y, width, height;
- x = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.x0);
- y = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.y0);
- width = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.x1 - player->invalid.x0);
- height = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.y1 - player->invalid.y0);
- g_signal_emit_by_name (player, "invalidate", x, y, width, height);
- swfdec_rect_init_empty (&player->invalid);
- }
-
- g_signal_emit (debugger, signals[BREAKPOINT], 0, id);
-
- g_object_freeze_notify (G_OBJECT (debugger));
-}
-
-static void
-swfdec_debugger_step (SwfdecAsContext *context)
-{
- SwfdecDebugger *debugger = SWFDEC_DEBUGGER (context);
-
- if (context->state != SWFDEC_AS_CONTEXT_RUNNING)
- return;
- if (!debugger->has_breakpoints)
- return;
-
- if (debugger->stepping) {
- swfdec_debugger_do_breakpoint (debugger, 0);
- } else {
- guint i;
- Breakpoint *br;
- const guint8 *pc = context->frame->pc;
-
- for (i = 0; i < debugger->breakpoints->len; i++) {
- br = &g_array_index (debugger->breakpoints, Breakpoint, i);
- if (br->type == BREAKPOINT_NONE)
- continue;
- if (br->pc == pc) {
- swfdec_debugger_do_breakpoint (debugger, i + 1);
- return;
- }
- }
- }
-}
-#endif
-
-static void
-swfdec_debugger_class_init (SwfdecDebuggerClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->dispose = swfdec_debugger_dispose;
-
- signals[SCRIPT_ADDED] = g_signal_new ("script-added", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
- signals[SCRIPT_REMOVED] = g_signal_new ("script-removed", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
- signals[BREAKPOINT] = g_signal_new ("breakpoint",
- G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
- signals[BREAKPOINT_ADDED] = g_signal_new ("breakpoint-added",
- G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
- signals[BREAKPOINT_REMOVED] = g_signal_new ("breakpoint-removed",
- G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
- signals[MOVIE_ADDED] = g_signal_new ("movie-added",
- G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT);
- signals[MOVIE_REMOVED] = g_signal_new ("movie-removed",
- G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT);
-}
-
-static void
-swfdec_debugger_init (SwfdecDebugger *debugger)
-{
- debugger->scripts = g_hash_table_new_full (g_direct_hash, g_direct_equal,
- NULL, (GDestroyNotify) swfdec_debugger_script_free);
- debugger->breakpoints = g_array_new (FALSE, FALSE, sizeof (Breakpoint));
-}
-
-/**
- * swfdec_debugger_new:
- *
- * Creates a #SwfdecPlayer that can be debugged.
- *
- * Returns: a new #SwfdecDebugger
- **/
-SwfdecPlayer *
-swfdec_debugger_new (void)
-{
- SwfdecPlayer *player;
-
- swfdec_init ();
- player = g_object_new (SWFDEC_TYPE_DEBUGGER, NULL);
- return player;
-}
-
-void
-swfdec_debugger_add_script (SwfdecDebugger *debugger, SwfdecScript *script)
-{
- SwfdecDebuggerScript *dscript = swfdec_debugger_script_new (script);
-
- g_hash_table_insert (debugger->scripts, script, dscript);
- g_signal_emit (debugger, signals[SCRIPT_ADDED], 0, dscript);
-}
-
-SwfdecDebuggerScript *
-swfdec_debugger_get_script (SwfdecDebugger *debugger, SwfdecScript *script)
-{
- SwfdecDebuggerScript *dscript = g_hash_table_lookup (debugger->scripts, script);
-
- return dscript;
-}
-
-void
-swfdec_debugger_remove_script (SwfdecDebugger *debugger, SwfdecScript *script)
-{
- SwfdecDebuggerScript *dscript = g_hash_table_lookup (debugger->scripts, script);
-
- g_assert (dscript);
- g_signal_emit (debugger, signals[SCRIPT_REMOVED], 0, dscript);
- g_hash_table_remove (debugger->scripts, script);
-}
-
-typedef struct {
- GFunc func;
- gpointer data;
-} ForeachData;
-
-static void
-do_foreach (gpointer key, gpointer value, gpointer data)
-{
- ForeachData *fdata = data;
-
- fdata->func (value, fdata->data);
-}
-
-void
-swfdec_debugger_foreach_script (SwfdecDebugger *debugger, GFunc func, gpointer data)
-{
- ForeachData fdata = { func, data };
- g_hash_table_foreach (debugger->scripts, do_foreach, &fdata);
-}
-
-void
-swfdec_debugger_set_stepping (SwfdecDebugger *debugger, gboolean stepping)
-{
- g_return_if_fail (SWFDEC_IS_DEBUGGER (debugger));
-
- if (debugger->stepping == stepping)
- return;
- debugger->stepping = stepping;
-}
-
-gboolean
-swfdec_debugger_get_stepping (SwfdecDebugger *debugger)
-{
- g_return_val_if_fail (SWFDEC_IS_DEBUGGER (debugger), FALSE);
-
- return debugger->stepping;
-}
-
-const char *
-swfdec_debugger_run (SwfdecDebugger *debugger, const char *command)
-{
- SwfdecPlayer *player;
- GList *walk;
-
- g_return_val_if_fail (SWFDEC_IS_DEBUGGER (debugger), NULL);
- g_return_val_if_fail (command != NULL, NULL);
-
- player = SWFDEC_PLAYER (debugger);
- g_object_freeze_notify (G_OBJECT (debugger));
-
-
- SWFDEC_ERROR ("ooops");
-
-
- for (walk = player->roots; walk; walk = walk->next) {
- swfdec_movie_update (walk->data);
- }
- if (!swfdec_rect_is_empty (&player->invalid)) {
- double x, y, width, height;
- x = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.x0);
- y = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.y0);
- width = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.x1 - player->invalid.x0);
- height = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.y1 - player->invalid.y0);
- g_signal_emit_by_name (player, "invalidate", x, y, width, height);
- swfdec_rect_init_empty (&player->invalid);
- }
- g_object_thaw_notify (G_OBJECT (debugger));
-
- return command;
-}
-
-guint
-swfdec_debugger_script_has_breakpoint (SwfdecDebugger *debugger,
- SwfdecDebuggerScript *script, guint line)
-{
- guint i;
- const guint8 *pc;
-
- g_return_val_if_fail (SWFDEC_IS_DEBUGGER (debugger), FALSE);
- g_return_val_if_fail (script != NULL, FALSE);
- g_return_val_if_fail (line < script->n_commands, FALSE);
-
- pc = script->commands[line].code;
- for (i = 0; i < debugger->breakpoints->len; i++) {
- Breakpoint *br = &g_array_index (debugger->breakpoints, Breakpoint, i);
-
- if (br->type == BREAKPOINT_PC && pc == br->pc)
- return i + 1;
- }
- return 0;
-}
diff --git a/libswfdec/swfdec_debugger.h b/libswfdec/swfdec_debugger.h
deleted file mode 100644
index 139e93b..0000000
--- a/libswfdec/swfdec_debugger.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_DEBUGGER_H_
-#define _SWFDEC_DEBUGGER_H_
-
-#include <glib-object.h>
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_player_internal.h>
-#include <libswfdec/swfdec_script.h>
-#include <libswfdec/swfdec_types.h>
-
-G_BEGIN_DECLS
-
-//typedef struct _SwfdecDebugger SwfdecDebugger;
-typedef struct _SwfdecDebuggerClass SwfdecDebuggerClass;
-typedef struct _SwfdecDebuggerScript SwfdecDebuggerScript;
-typedef struct _SwfdecDebuggerCommand SwfdecDebuggerCommand;
-
-#define SWFDEC_TYPE_DEBUGGER (swfdec_debugger_get_type())
-#define SWFDEC_IS_DEBUGGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_DEBUGGER))
-#define SWFDEC_IS_DEBUGGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_DEBUGGER))
-#define SWFDEC_DEBUGGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_DEBUGGER, SwfdecDebugger))
-#define SWFDEC_DEBUGGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_DEBUGGER, SwfdecDebuggerClass))
-#define SWFDEC_DEBUGGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_DEBUGGER, SwfdecDebuggerClass))
-
-struct _SwfdecDebuggerCommand {
- const guint8 * code; /* pointer to start bytecode in SwfdecScript */
- char * description; /* string describing the action */
-};
-
-struct _SwfdecDebuggerScript {
- SwfdecScript * script; /* the script */
- SwfdecDebuggerCommand *commands; /* commands executed in the script (NULL-terminated) */
- guint n_commands; /* number of commands */
-};
-
-struct _SwfdecDebugger {
- SwfdecPlayer player;
-
- GHashTable * scripts; /* JSScript => SwfdecDebuggerScript mapping */
- GArray * breakpoints; /* all breakpoints */
- gboolean stepping; /* TRUE if we're currently stepping through the code */
- gboolean has_breakpoints; /* performance: track if there's breakpoints */
-};
-
-struct _SwfdecDebuggerClass {
- SwfdecPlayerClass player_class;
-};
-
-GType swfdec_debugger_get_type (void);
-SwfdecPlayer * swfdec_debugger_new (void);
-
-gboolean swfdec_debugger_get_current (SwfdecDebugger * debugger,
- SwfdecDebuggerScript **dscript,
- guint * line);
-guint swfdec_debugger_set_breakpoint (SwfdecDebugger * debugger,
- SwfdecDebuggerScript * script,
- guint line);
-void swfdec_debugger_unset_breakpoint
- (SwfdecDebugger * debugger,
- guint id);
-gboolean swfdec_debugger_get_breakpoint (SwfdecDebugger * debugger,
- guint id,
- SwfdecDebuggerScript **script,
- guint * line);
-guint swfdec_debugger_get_n_breakpoints
- (SwfdecDebugger * debugger);
-void swfdec_debugger_set_stepping (SwfdecDebugger * debugger,
- gboolean stepping);
-gboolean swfdec_debugger_get_stepping (SwfdecDebugger * debugger);
-
-void swfdec_debugger_add_script (SwfdecDebugger * debugger,
- SwfdecScript * script);
-SwfdecDebuggerScript * swfdec_debugger_get_script (SwfdecDebugger * debugger,
- SwfdecScript * script);
-void swfdec_debugger_remove_script (SwfdecDebugger * debugger,
- SwfdecScript * script);
-void swfdec_debugger_foreach_script (SwfdecDebugger * debugger,
- GFunc func,
- gpointer data);
-guint swfdec_debugger_script_has_breakpoint
- (SwfdecDebugger * debugger,
- SwfdecDebuggerScript * script,
- guint line);
-
-const char * swfdec_debugger_run (SwfdecDebugger * debugger,
- const char * command);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_decoder.c b/libswfdec/swfdec_decoder.c
deleted file mode 100644
index 24bbda0..0000000
--- a/libswfdec/swfdec_decoder.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include "swfdec_decoder.h"
-#include "swfdec_debug.h"
-#include "swfdec_decoder.h"
-#include "swfdec_image.h"
-#include "swfdec_image_decoder.h"
-#include "swfdec_swf_decoder.h"
-
-
-G_DEFINE_ABSTRACT_TYPE (SwfdecDecoder, swfdec_decoder, G_TYPE_OBJECT)
-
-static void
-swfdec_decoder_class_init (SwfdecDecoderClass *klass)
-{
-}
-
-static void
-swfdec_decoder_init (SwfdecDecoder *decoder)
-{
-}
-
-SwfdecDecoder *
-swfdec_decoder_new (SwfdecPlayer *player, const SwfdecBuffer *buffer)
-{
- guchar *data;
- SwfdecDecoder *retval;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (buffer != NULL, NULL);
-
- if (buffer->length < SWFDEC_DECODER_DETECT_LENGTH)
- return NULL;
-
- data = buffer->data;
- if ((data[0] == 'C' || data[0] == 'F') &&
- 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 if (swfdec_image_detect (data) != SWFDEC_IMAGE_TYPE_UNKNOWN) {
- retval = g_object_new (SWFDEC_TYPE_IMAGE_DECODER, NULL);
- } else {
- retval = NULL;
- }
- if (retval) {
- retval->player = player;
- }
- return retval;
-}
-
-SwfdecStatus
-swfdec_decoder_parse (SwfdecDecoder *decoder, SwfdecBuffer *buffer)
-{
- SwfdecDecoderClass *klass;
-
- g_return_val_if_fail (SWFDEC_IS_DECODER (decoder), SWFDEC_STATUS_ERROR);
- g_return_val_if_fail (buffer != NULL, SWFDEC_STATUS_ERROR);
-
- klass = SWFDEC_DECODER_GET_CLASS (decoder);
- g_return_val_if_fail (klass->parse, SWFDEC_STATUS_ERROR);
- return klass->parse (decoder, buffer);
-}
-
-SwfdecStatus
-swfdec_decoder_eof (SwfdecDecoder *decoder)
-{
- SwfdecDecoderClass *klass;
-
- g_return_val_if_fail (SWFDEC_IS_DECODER (decoder), SWFDEC_STATUS_ERROR);
-
- klass = SWFDEC_DECODER_GET_CLASS (decoder);
- g_return_val_if_fail (klass->eof, SWFDEC_STATUS_ERROR);
- return klass->eof (decoder);
-}
-
diff --git a/libswfdec/swfdec_decoder.h b/libswfdec/swfdec_decoder.h
deleted file mode 100644
index 3a58015..0000000
--- a/libswfdec/swfdec_decoder.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_DECODER_H_
-#define _SWFDEC_DECODER_H_
-
-#include <glib-object.h>
-#include <libswfdec/swfdec_buffer.h>
-#include <libswfdec/swfdec_loader.h>
-#include <libswfdec/swfdec_player.h>
-#include <libswfdec/swfdec_types.h>
-
-G_BEGIN_DECLS
-
-
-typedef enum {
- /* processing continued as expected */
- SWFDEC_STATUS_OK = 0,
- /* An error occured during parsing */
- SWFDEC_STATUS_ERROR = (1 << 0),
- /* more data needs to be made available for processing */
- SWFDEC_STATUS_NEEDBITS = (1 << 1),
- /* parsing is finished */
- SWFDEC_STATUS_EOF = (1 << 2),
- /* header parsing is complete, framerate, image size etc are known */
- SWFDEC_STATUS_INIT = (1 << 3),
- /* at least one new image is available for display */
- SWFDEC_STATUS_IMAGE = (1 << 4)
-} SwfdecStatus;
-
-//typedef struct _SwfdecDecoder SwfdecDecoder;
-typedef struct _SwfdecDecoderClass SwfdecDecoderClass;
-
-#define SWFDEC_TYPE_DECODER (swfdec_decoder_get_type())
-#define SWFDEC_IS_DECODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_DECODER))
-#define SWFDEC_IS_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_DECODER))
-#define SWFDEC_DECODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_DECODER, SwfdecDecoder))
-#define SWFDEC_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_DECODER, SwfdecDecoderClass))
-#define SWFDEC_DECODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_DECODER, SwfdecDecoderClass))
-
-struct _SwfdecDecoder
-{
- GObject object;
-
- SwfdecPlayer * player; /* FIXME: only needed to get the JS Context, I want it gone */
- SwfdecLoaderDataType data_type; /* type of the data we provide or UNKNOWN if not known yet */
- guint rate; /* rate per second in 256th */
- guint width; /* width of stream */
- guint height; /* guess */
- guint bytes_loaded; /* bytes already loaded */
- guint bytes_total; /* total bytes in the file or 0 if not known */
- guint frames_loaded; /* frames already loaded */
- guint frames_total; /* total frames */
-};
-
-struct _SwfdecDecoderClass
-{
- GObjectClass object_class;
-
- SwfdecStatus (* parse) (SwfdecDecoder * decoder,
- SwfdecBuffer * buffer);
- SwfdecStatus (* eof) (SwfdecDecoder * decoder);
-};
-
-GType swfdec_decoder_get_type (void);
-
-#define SWFDEC_DECODER_DETECT_LENGTH 4
-SwfdecDecoder * swfdec_decoder_new (SwfdecPlayer * player,
- const SwfdecBuffer * buffer);
-
-SwfdecStatus swfdec_decoder_parse (SwfdecDecoder * decoder,
- SwfdecBuffer * buffer);
-SwfdecStatus swfdec_decoder_eof (SwfdecDecoder * decoder);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_displacement_map_filter.c b/libswfdec/swfdec_displacement_map_filter.c
deleted file mode 100644
index 55dea6e..0000000
--- a/libswfdec/swfdec_displacement_map_filter.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (1111, 1, swfdec_displacement_map_filter_get_mapBitmap)
-void
-swfdec_displacement_map_filter_get_mapBitmap (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DisplacementMapFilter.mapBitmap (get)");
-}
-
-SWFDEC_AS_NATIVE (1111, 2, swfdec_displacement_map_filter_set_mapBitmap)
-void
-swfdec_displacement_map_filter_set_mapBitmap (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DisplacementMapFilter.mapBitmap (set)");
-}
-
-SWFDEC_AS_NATIVE (1111, 3, swfdec_displacement_map_filter_get_mapPoint)
-void
-swfdec_displacement_map_filter_get_mapPoint (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DisplacementMapFilter.mapPoint (get)");
-}
-
-SWFDEC_AS_NATIVE (1111, 4, swfdec_displacement_map_filter_set_mapPoint)
-void
-swfdec_displacement_map_filter_set_mapPoint (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DisplacementMapFilter.mapPoint (set)");
-}
-
-SWFDEC_AS_NATIVE (1111, 5, swfdec_displacement_map_filter_get_componentX)
-void
-swfdec_displacement_map_filter_get_componentX (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DisplacementMapFilter.componentX (get)");
-}
-
-SWFDEC_AS_NATIVE (1111, 6, swfdec_displacement_map_filter_set_componentX)
-void
-swfdec_displacement_map_filter_set_componentX (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DisplacementMapFilter.componentX (set)");
-}
-
-SWFDEC_AS_NATIVE (1111, 7, swfdec_displacement_map_filter_get_componentY)
-void
-swfdec_displacement_map_filter_get_componentY (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DisplacementMapFilter.componentY (get)");
-}
-
-SWFDEC_AS_NATIVE (1111, 8, swfdec_displacement_map_filter_set_componentY)
-void
-swfdec_displacement_map_filter_set_componentY (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DisplacementMapFilter.componentY (set)");
-}
-
-SWFDEC_AS_NATIVE (1111, 9, swfdec_displacement_map_filter_get_scaleX)
-void
-swfdec_displacement_map_filter_get_scaleX (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DisplacementMapFilter.scaleX (get)");
-}
-
-SWFDEC_AS_NATIVE (1111, 10, swfdec_displacement_map_filter_set_scaleX)
-void
-swfdec_displacement_map_filter_set_scaleX (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DisplacementMapFilter.scaleX (set)");
-}
-
-SWFDEC_AS_NATIVE (1111, 11, swfdec_displacement_map_filter_get_scaleY)
-void
-swfdec_displacement_map_filter_get_scaleY (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DisplacementMapFilter.scaleY (get)");
-}
-
-SWFDEC_AS_NATIVE (1111, 12, swfdec_displacement_map_filter_set_scaleY)
-void
-swfdec_displacement_map_filter_set_scaleY (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DisplacementMapFilter.scaleY (set)");
-}
-
-SWFDEC_AS_NATIVE (1111, 13, swfdec_displacement_map_filter_get_mode)
-void
-swfdec_displacement_map_filter_get_mode (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DisplacementMapFilter.mode (get)");
-}
-
-SWFDEC_AS_NATIVE (1111, 14, swfdec_displacement_map_filter_set_mode)
-void
-swfdec_displacement_map_filter_set_mode (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DisplacementMapFilter.mode (set)");
-}
-
-SWFDEC_AS_NATIVE (1111, 15, swfdec_displacement_map_filter_get_color)
-void
-swfdec_displacement_map_filter_get_color (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DisplacementMapFilter.color (get)");
-}
-
-SWFDEC_AS_NATIVE (1111, 16, swfdec_displacement_map_filter_set_color)
-void
-swfdec_displacement_map_filter_set_color (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DisplacementMapFilter.color (set)");
-}
-
-SWFDEC_AS_NATIVE (1111, 17, swfdec_displacement_map_filter_get_alpha)
-void
-swfdec_displacement_map_filter_get_alpha (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DisplacementMapFilter.alpha (get)");
-}
-
-SWFDEC_AS_NATIVE (1111, 18, swfdec_displacement_map_filter_set_alpha)
-void
-swfdec_displacement_map_filter_set_alpha (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DisplacementMapFilter.alpha (set)");
-}
-
-// constructor
-SWFDEC_AS_NATIVE (1111, 0, swfdec_displacement_map_filter_contruct)
-void
-swfdec_displacement_map_filter_contruct (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DisplacementMapFilter");
-}
diff --git a/libswfdec/swfdec_draw.c b/libswfdec/swfdec_draw.c
deleted file mode 100644
index 7da5374..0000000
--- a/libswfdec/swfdec_draw.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "swfdec_draw.h"
-#include "swfdec_color.h"
-#include "swfdec_debug.h"
-#include "swfdec_path.h"
-
-/*** DRAW ***/
-
-G_DEFINE_ABSTRACT_TYPE (SwfdecDraw, swfdec_draw, G_TYPE_OBJECT);
-
-static void
-swfdec_draw_do_morph (SwfdecDraw* dest, SwfdecDraw *source, guint ratio)
-{
- swfdec_path_merge (&dest->path, &source->path, &source->end_path, ratio / 65535.);
-}
-
-static void
-swfdec_draw_dispose (GObject *object)
-{
- SwfdecDraw *draw = SWFDEC_DRAW (object);
-
- swfdec_path_reset (&draw->path);
- swfdec_path_reset (&draw->end_path);
-
- G_OBJECT_CLASS (swfdec_draw_parent_class)->dispose (object);
-}
-
-static void
-swfdec_draw_class_init (SwfdecDrawClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->dispose = swfdec_draw_dispose;
-
- klass->morph = swfdec_draw_do_morph;
-}
-
-static void
-swfdec_draw_init (SwfdecDraw *draw)
-{
- swfdec_path_init (&draw->path);
- swfdec_path_init (&draw->end_path);
-}
-
-static gboolean
-swfdec_draw_can_morph (SwfdecDraw *draw)
-{
- return draw->end_path.num_data > 0;
-}
-
-/**
- * swfdec_draw_morph:
- * @draw: a #SwfdecDraw
- * @ratio: ratio of the morph from 0 to 65535
- *
- * Applies a morph to the given drawing operation. If the drawing operation
- * can not be morphed, it is returned unchanged. Otherwise a new drawing
- * operation is created.
- *
- * Returns: a new reference to a #SwfdecDraw corresponding to the given morph
- * ratio
- **/
-SwfdecDraw *
-swfdec_draw_morph (SwfdecDraw *draw, guint ratio)
-{
- SwfdecDrawClass *klass;
- SwfdecDraw *copy;
-
- g_return_val_if_fail (SWFDEC_IS_DRAW (draw), NULL);
- g_return_val_if_fail (ratio < 65536, NULL);
-
- if (!swfdec_draw_can_morph (draw) || ratio == 0) {
- /* not a morph */
- g_object_ref (draw);
- return draw;
- }
- klass = SWFDEC_DRAW_GET_CLASS (draw);
- g_assert (klass->morph);
- copy = g_object_new (G_OBJECT_CLASS_TYPE (klass), NULL);
- klass->morph (copy, draw, ratio);
- swfdec_draw_recompute (copy);
- return copy;
-}
-
-/**
- * swfdec_draw_paint:
- * @draw: drawing operation to perform
- * @cr: context to perform the operation on
- * @trans: color transofrmation to apply
- *
- * Draws the given drawing operation on the given Cairo context.
- **/
-void
-swfdec_draw_paint (SwfdecDraw *draw, cairo_t *cr, const SwfdecColorTransform *trans)
-{
- SwfdecDrawClass *klass;
-
- g_return_if_fail (SWFDEC_IS_DRAW (draw));
- g_return_if_fail (draw->path.num_data > 0);
- g_return_if_fail (cr != NULL);
- g_return_if_fail (trans != NULL);
-
- klass = SWFDEC_DRAW_GET_CLASS (draw);
- g_assert (klass->paint);
- klass->paint (draw, cr, trans);
-}
-
-static gpointer
-swfdec_draw_init_empty_surface (gpointer unused)
-{
- return cairo_image_surface_create (CAIRO_FORMAT_A1, 1, 1);
-}
-
-/**
- * swfdec_draw_contains:
- * @draw: a #SwfdecDraw
- * @x: x coordinate to check
- * @y: y coordinate to check
- *
- * Checks if the given @x and @y coordinate is inside or outside the area drawn
- * by the given drawing operation.
- *
- * Returns: %TRUE if the coordinates are inside the drawing operation.
- **/
-gboolean
-swfdec_draw_contains (SwfdecDraw *draw, double x, double y)
-{
- static GOnce empty_surface = G_ONCE_INIT;
- SwfdecDrawClass *klass;
- cairo_t *cr;
- gboolean result;
-
- g_return_val_if_fail (SWFDEC_IS_DRAW (draw), FALSE);
-
- if (!swfdec_rect_contains (&draw->extents, x, y))
- return FALSE;
-
- g_once (&empty_surface, swfdec_draw_init_empty_surface, NULL);
-
- klass = SWFDEC_DRAW_GET_CLASS (draw);
- g_assert (klass->contains);
- cr = cairo_create (empty_surface.retval);
- result = klass->contains (draw, cr, x, y);
- cairo_destroy (cr);
- return result;
-}
-
-/**
- * swfdec_draw_recompute:
- * @draw: a #SwfdecDraw
- *
- * This function must be called after a call to swfdec_draw_append_path() but
- * before using swfdec_draw_paint() again. It updates internal state and caches,
- * in particular the extents of this drawing operation.
- **/
-void
-swfdec_draw_recompute (SwfdecDraw *draw)
-{
- SwfdecDrawClass *klass;
-
- g_return_if_fail (SWFDEC_IS_DRAW (draw));
-
- klass = SWFDEC_DRAW_GET_CLASS (draw);
- g_assert (klass->compute_extents);
- klass->compute_extents (draw);
-}
diff --git a/libswfdec/swfdec_draw.h b/libswfdec/swfdec_draw.h
deleted file mode 100644
index e56a4ae..0000000
--- a/libswfdec/swfdec_draw.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_DRAW_H_
-#define _SWFDEC_DRAW_H_
-
-#include <glib-object.h>
-#include <cairo.h>
-#include <libswfdec/swfdec_swf_decoder.h>
-#include <libswfdec/swfdec_color.h>
-
-G_BEGIN_DECLS
-
-//typedef struct _SwfdecDraw SwfdecDraw;
-typedef struct _SwfdecDrawClass SwfdecDrawClass;
-
-#define SWFDEC_TYPE_DRAW (swfdec_draw_get_type())
-#define SWFDEC_IS_DRAW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_DRAW))
-#define SWFDEC_IS_DRAW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_DRAW))
-#define SWFDEC_DRAW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_DRAW, SwfdecDraw))
-#define SWFDEC_DRAW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_DRAW, SwfdecDrawClass))
-#define SWFDEC_DRAW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_DRAW, SwfdecDrawClass))
-
-struct _SwfdecDraw
-{
- GObject object;
-
- /*< protected >*/
- gboolean snap; /* this drawing op does pixel snapping on the device grid */
- SwfdecRect extents; /* extents of path */
- cairo_path_t path; /* path to draw with this operation - in twips */
- cairo_path_t end_path; /* end path to draw with this operation if morph operation */
-};
-
-struct _SwfdecDrawClass
-{
- GObjectClass object_class;
-
- /* morph this drawing operation using the given ratio */
- void (* morph) (SwfdecDraw * dest,
- SwfdecDraw * source,
- guint ratio);
- /* paint the current drawing operation */
- void (* paint) (SwfdecDraw * draw,
- cairo_t * cr,
- const SwfdecColorTransform * trans);
- /* compute extents of this drawing op for the given movie */
- void (* compute_extents) (SwfdecDraw * draw);
- /* check if the given coordinate is part of the area rendered to */
- gboolean (* contains) (SwfdecDraw * draw,
- cairo_t * cr,
- double x,
- double y);
-};
-
-GType swfdec_draw_get_type (void);
-
-SwfdecDraw * swfdec_draw_morph (SwfdecDraw * draw,
- guint ratio);
-void swfdec_draw_paint (SwfdecDraw * draw,
- cairo_t * cr,
- const SwfdecColorTransform * trans);
-gboolean swfdec_draw_contains (SwfdecDraw * draw,
- double x,
- double y);
-void swfdec_draw_recompute (SwfdecDraw * draw);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_drop_shadow_filter.c b/libswfdec/swfdec_drop_shadow_filter.c
deleted file mode 100644
index 1ef97bf..0000000
--- a/libswfdec/swfdec_drop_shadow_filter.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (1101, 1, swfdec_drop_shadow_filter_get_distance)
-void
-swfdec_drop_shadow_filter_get_distance (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.distance (get)");
-}
-
-SWFDEC_AS_NATIVE (1101, 2, swfdec_drop_shadow_filter_set_distance)
-void
-swfdec_drop_shadow_filter_set_distance (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.distance (set)");
-}
-
-SWFDEC_AS_NATIVE (1101, 3, swfdec_drop_shadow_filter_get_angle)
-void
-swfdec_drop_shadow_filter_get_angle (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.angle (get)");
-}
-
-SWFDEC_AS_NATIVE (1101, 4, swfdec_drop_shadow_filter_set_angle)
-void
-swfdec_drop_shadow_filter_set_angle (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.angle (set)");
-}
-
-SWFDEC_AS_NATIVE (1101, 5, swfdec_drop_shadow_filter_get_color)
-void
-swfdec_drop_shadow_filter_get_color (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.color (get)");
-}
-
-SWFDEC_AS_NATIVE (1101, 6, swfdec_drop_shadow_filter_set_color)
-void
-swfdec_drop_shadow_filter_set_color (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.color (set)");
-}
-
-SWFDEC_AS_NATIVE (1101, 7, swfdec_drop_shadow_filter_get_alpha)
-void
-swfdec_drop_shadow_filter_get_alpha (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.alpha (get)");
-}
-
-SWFDEC_AS_NATIVE (1101, 8, swfdec_drop_shadow_filter_set_alpha)
-void
-swfdec_drop_shadow_filter_set_alpha (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.alpha (set)");
-}
-
-SWFDEC_AS_NATIVE (1101, 9, swfdec_drop_shadow_filter_get_quality)
-void
-swfdec_drop_shadow_filter_get_quality (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.quality (get)");
-}
-
-SWFDEC_AS_NATIVE (1101, 10, swfdec_drop_shadow_filter_set_quality)
-void
-swfdec_drop_shadow_filter_set_quality (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.quality (set)");
-}
-
-SWFDEC_AS_NATIVE (1101, 11, swfdec_drop_shadow_filter_get_inner)
-void
-swfdec_drop_shadow_filter_get_inner (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.inner (get)");
-}
-
-SWFDEC_AS_NATIVE (1101, 12, swfdec_drop_shadow_filter_set_inner)
-void
-swfdec_drop_shadow_filter_set_inner (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.inner (set)");
-}
-
-SWFDEC_AS_NATIVE (1101, 13, swfdec_drop_shadow_filter_get_knockout)
-void
-swfdec_drop_shadow_filter_get_knockout (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.knockout (get)");
-}
-
-SWFDEC_AS_NATIVE (1101, 14, swfdec_drop_shadow_filter_set_knockout)
-void
-swfdec_drop_shadow_filter_set_knockout (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.knockout (set)");
-}
-
-SWFDEC_AS_NATIVE (1101, 15, swfdec_drop_shadow_filter_get_blurX)
-void
-swfdec_drop_shadow_filter_get_blurX (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.blurX (get)");
-}
-
-SWFDEC_AS_NATIVE (1101, 16, swfdec_drop_shadow_filter_set_blurX)
-void
-swfdec_drop_shadow_filter_set_blurX (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.blurX (set)");
-}
-
-SWFDEC_AS_NATIVE (1101, 17, swfdec_drop_shadow_filter_get_blurY)
-void
-swfdec_drop_shadow_filter_get_blurY (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.blurY (get)");
-}
-
-SWFDEC_AS_NATIVE (1101, 18, swfdec_drop_shadow_filter_set_blurY)
-void
-swfdec_drop_shadow_filter_set_blurY (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.blurY (set)");
-}
-
-SWFDEC_AS_NATIVE (1101, 19, swfdec_drop_shadow_filter_get_strength)
-void
-swfdec_drop_shadow_filter_get_strength (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.strength (get)");
-}
-
-SWFDEC_AS_NATIVE (1101, 20, swfdec_drop_shadow_filter_set_strength)
-void
-swfdec_drop_shadow_filter_set_strength (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.strength (set)");
-}
-
-SWFDEC_AS_NATIVE (1101, 21, swfdec_drop_shadow_filter_get_hideObject)
-void
-swfdec_drop_shadow_filter_get_hideObject (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.hideObject (get)");
-}
-
-SWFDEC_AS_NATIVE (1101, 22, swfdec_drop_shadow_filter_set_hideObject)
-void
-swfdec_drop_shadow_filter_set_hideObject (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter.hideObject (set)");
-}
-
-// constructor
-SWFDEC_AS_NATIVE (1101, 0, swfdec_drop_shadow_filter_construct)
-void
-swfdec_drop_shadow_filter_construct (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("DropShadowFilter");
-}
diff --git a/libswfdec/swfdec_event.c b/libswfdec/swfdec_event.c
deleted file mode 100644
index 6af665d..0000000
--- a/libswfdec/swfdec_event.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "swfdec_event.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_script_internal.h"
-
-typedef struct _SwfdecEvent SwfdecEvent;
-
-struct _SwfdecEvent {
- guint conditions;
- guint8 key;
- SwfdecScript *script;
-};
-
-struct _SwfdecEventList {
- SwfdecPlayer * player;
- guint refcount;
- GArray * events;
-};
-
-/**
- * swfdec_event_type_get_name:
- * @type: a #SwfdecEventType
- *
- * Gets the name for the event as a refcounted string or %NULL if the
- * given clip event has no associated event.
- *
- * Returns: The name of the event or %NULL if none.
- **/
-const char *
-swfdec_event_type_get_name (SwfdecEventType type)
-{
- switch (type) {
- case SWFDEC_EVENT_LOAD:
- return SWFDEC_AS_STR_onLoad;
- case SWFDEC_EVENT_ENTER:
- return SWFDEC_AS_STR_onEnterFrame;
- case SWFDEC_EVENT_UNLOAD:
- return SWFDEC_AS_STR_onUnload;
- case SWFDEC_EVENT_MOUSE_MOVE:
- return SWFDEC_AS_STR_onMouseMove;
- case SWFDEC_EVENT_MOUSE_DOWN:
- return SWFDEC_AS_STR_onMouseDown;
- case SWFDEC_EVENT_MOUSE_UP:
- return SWFDEC_AS_STR_onMouseUp;
- case SWFDEC_EVENT_KEY_UP:
- return SWFDEC_AS_STR_onKeyUp;
- case SWFDEC_EVENT_KEY_DOWN:
- return SWFDEC_AS_STR_onKeyDown;
- case SWFDEC_EVENT_DATA:
- return SWFDEC_AS_STR_onData;
- case SWFDEC_EVENT_INITIALIZE:
- return NULL;
- case SWFDEC_EVENT_PRESS:
- return SWFDEC_AS_STR_onPress;
- case SWFDEC_EVENT_RELEASE:
- return SWFDEC_AS_STR_onRelease;
- case SWFDEC_EVENT_RELEASE_OUTSIDE:
- return SWFDEC_AS_STR_onReleaseOutside;
- case SWFDEC_EVENT_ROLL_OVER:
- return SWFDEC_AS_STR_onRollOver;
- case SWFDEC_EVENT_ROLL_OUT:
- return SWFDEC_AS_STR_onRollOut;
- case SWFDEC_EVENT_DRAG_OVER:
- return SWFDEC_AS_STR_onDragOver;
- case SWFDEC_EVENT_DRAG_OUT:
- return SWFDEC_AS_STR_onDragOut;
- case SWFDEC_EVENT_KEY_PRESS:
- return NULL;
- case SWFDEC_EVENT_CONSTRUCT:
- return SWFDEC_AS_STR_onConstruct;
- default:
- g_assert_not_reached ();
- return NULL;
- }
-}
-
-SwfdecEventList *
-swfdec_event_list_new (SwfdecPlayer *player)
-{
- SwfdecEventList *list;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
-
- list = g_new0 (SwfdecEventList, 1);
- list->player = player;
- list->refcount = 1;
- list->events = g_array_new (FALSE, FALSE, sizeof (SwfdecEvent));
-
- return list;
-}
-
-/* FIXME: this is a bit nasty because of modifying */
-SwfdecEventList *
-swfdec_event_list_copy (SwfdecEventList *list)
-{
- g_return_val_if_fail (list != NULL, NULL);
- g_return_val_if_fail (list->refcount > 0, NULL);
-
- list->refcount++;
-
- return list;
-}
-
-void
-swfdec_event_list_free (SwfdecEventList *list)
-{
- guint i;
-
- g_return_if_fail (list != NULL);
- g_return_if_fail (list->refcount > 0);
-
- list->refcount--;
- if (list->refcount > 0)
- return;
-
- for (i = 0; i < list->events->len; i++) {
- SwfdecEvent *event = &g_array_index (list->events, SwfdecEvent, i);
- swfdec_script_unref (event->script);
- }
- g_array_free (list->events, TRUE);
- g_free (list);
-}
-
-#define N_CONDITIONS 19
-void
-swfdec_event_list_parse (SwfdecEventList *list, SwfdecBits *bits, int version,
- guint conditions, guint8 key, const char *description)
-{
- SwfdecEvent event;
- char *name;
- guint i;
-
- g_return_if_fail (list != NULL);
- g_return_if_fail (list->refcount == 1);
- g_return_if_fail (description != NULL);
-
- event.conditions = conditions;
- event.key = key;
- i = g_bit_nth_lsf (conditions, -1);
- name = g_strconcat (description, ".", i < N_CONDITIONS ?
- swfdec_event_type_get_name (i) : "???", NULL);
- event.script = swfdec_script_new_from_bits (bits, name, version);
- g_free (name);
- if (event.script)
- g_array_append_val (list->events, event);
-}
-
-void
-swfdec_event_list_execute (SwfdecEventList *list, SwfdecAsObject *object,
- guint condition, guint8 key)
-{
- guint i;
-
- g_return_if_fail (list != NULL);
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
- g_return_if_fail (condition < N_CONDITIONS);
-
- condition = (1 << condition);
- /* FIXME: Do we execute all events if the event list is gone already? */
- /* need to ref here because followup code could free all references to the list */
- list = swfdec_event_list_copy (list);
- for (i = 0; i < list->events->len; i++) {
- SwfdecEvent *event = &g_array_index (list->events, SwfdecEvent, i);
- if ((event->conditions & condition) &&
- event->key == key) {
- SWFDEC_LOG ("executing script for event %u on scriptable %p", condition, object);
- swfdec_as_object_run (object, event->script);
- }
- }
- swfdec_event_list_free (list);
-}
-
-gboolean
-swfdec_event_list_has_conditions (SwfdecEventList *list, SwfdecAsObject *object,
- guint condition, guint8 key)
-{
- guint i;
-
- g_return_val_if_fail (list != NULL, FALSE);
- g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), FALSE);
- g_return_val_if_fail (condition < N_CONDITIONS, FALSE);
-
- condition = 1 << condition;
- for (i = 0; i < list->events->len; i++) {
- SwfdecEvent *event = &g_array_index (list->events, SwfdecEvent, i);
- if ((event->conditions & condition) &&
- event->key == key)
- return TRUE;
- }
- return FALSE;
-}
-
-#define MOUSE_EVENTS 0x1FC0
-gboolean
-swfdec_event_list_has_mouse_events (SwfdecEventList *list)
-{
- guint i;
-
- g_return_val_if_fail (list != NULL, FALSE);
-
- for (i = 0; i < list->events->len; i++) {
- SwfdecEvent *event = &g_array_index (list->events, SwfdecEvent, i);
- if (event->conditions & MOUSE_EVENTS)
- return TRUE;
- }
- return FALSE;
-}
diff --git a/libswfdec/swfdec_event.h b/libswfdec/swfdec_event.h
deleted file mode 100644
index 4b1ba40..0000000
--- a/libswfdec/swfdec_event.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#include <libswfdec/swfdec_bits.h>
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_player.h>
-#include <libswfdec/swfdec_types.h>
-
-#ifndef _SWFDEC_EVENT_H_
-#define _SWFDEC_EVENT_H_
-
-G_BEGIN_DECLS
-
-typedef enum _SwfdecEventType {
- SWFDEC_EVENT_LOAD = 0,
- SWFDEC_EVENT_ENTER = 1,
- SWFDEC_EVENT_UNLOAD = 2,
- SWFDEC_EVENT_MOUSE_MOVE = 3,
- SWFDEC_EVENT_MOUSE_DOWN = 4,
- SWFDEC_EVENT_MOUSE_UP = 5,
- SWFDEC_EVENT_KEY_UP = 6,
- SWFDEC_EVENT_KEY_DOWN = 7,
- SWFDEC_EVENT_DATA = 8,
- SWFDEC_EVENT_INITIALIZE = 9,
- SWFDEC_EVENT_PRESS = 10,
- SWFDEC_EVENT_RELEASE = 11,
- SWFDEC_EVENT_RELEASE_OUTSIDE = 12,
- SWFDEC_EVENT_ROLL_OVER = 13,
- SWFDEC_EVENT_ROLL_OUT = 14,
- SWFDEC_EVENT_DRAG_OVER = 15,
- SWFDEC_EVENT_DRAG_OUT = 16,
- SWFDEC_EVENT_KEY_PRESS = 17,
- SWFDEC_EVENT_CONSTRUCT = 18
-} SwfdecEventType;
-
-const char * swfdec_event_type_get_name (SwfdecEventType type);
-
-SwfdecEventList * swfdec_event_list_new (SwfdecPlayer * player);
-SwfdecEventList * swfdec_event_list_copy (SwfdecEventList * list);
-void swfdec_event_list_free (SwfdecEventList * list);
-
-void swfdec_event_list_parse (SwfdecEventList * list,
- SwfdecBits * bits,
- int version,
- guint conditions,
- guint8 key,
- const char * description);
-void swfdec_event_list_execute (SwfdecEventList * list,
- SwfdecAsObject * object,
- guint condition,
- guint8 key);
-gboolean swfdec_event_list_has_conditions(SwfdecEventList * list,
- SwfdecAsObject * object,
- guint conditions,
- guint8 key);
-gboolean swfdec_event_list_has_mouse_events(SwfdecEventList * list);
-
-
-G_END_DECLS
-
-#endif
diff --git a/libswfdec/swfdec_external_interface.c b/libswfdec/swfdec_external_interface.c
deleted file mode 100644
index 9574954..0000000
--- a/libswfdec/swfdec_external_interface.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "swfdec_as_internal.h"
-#include "swfdec_as_native_function.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_player_scripting.h"
-#include "swfdec_xml.h"
-
-SWFDEC_AS_NATIVE (14, 0, swfdec_external_interface__initJS)
-void
-swfdec_external_interface__initJS (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- /* FIXME: call an init vfunc here? */
-}
-
-SWFDEC_AS_NATIVE (14, 1, swfdec_external_interface__objectID)
-void
-swfdec_external_interface__objectID (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
- SwfdecPlayerScripting *scripting = player->priv->scripting;
- SwfdecPlayerScriptingClass *klass;
-
- if (scripting == NULL) {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- return;
- }
- klass = SWFDEC_PLAYER_SCRIPTING_GET_CLASS (scripting);
- if (klass->js_get_id) {
- char *s = klass->js_get_id (scripting, player);
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, s));
- } else {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- }
-}
-
-SWFDEC_AS_NATIVE (14, 2, swfdec_external_interface__addCallback)
-void
-swfdec_external_interface__addCallback (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecPlayerPrivate *priv = SWFDEC_PLAYER (cx)->priv;
- SwfdecAsObject *fun;
- const char *name;
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
- SWFDEC_AS_CHECK (0, NULL, "sO", &name, &fun);
-
- /* FIXME: do we allow setting if scripting is unsupported? */
- if (!SWFDEC_IS_AS_FUNCTION (fun))
- return;
-
- g_hash_table_insert (priv->scripting_callbacks, (gpointer) name, fun);
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, TRUE);
-}
-
-SWFDEC_AS_NATIVE (14, 3, swfdec_external_interface__evalJS)
-void
-swfdec_external_interface__evalJS (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
- SwfdecPlayerScripting *scripting = player->priv->scripting;
- SwfdecPlayerScriptingClass *klass;
- const char *s;
-
- SWFDEC_AS_VALUE_SET_NULL (ret);
- if (scripting == NULL || argc == 0)
- return;
- s = swfdec_as_value_to_string (cx, &argv[0]);
- klass = SWFDEC_PLAYER_SCRIPTING_GET_CLASS (scripting);
- if (klass->js_call) {
- char *t = klass->js_call (scripting, player, s);
- if (t != NULL) {
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, t));
- }
- }
-}
-
-SWFDEC_AS_NATIVE (14, 4, swfdec_external_interface__callOut)
-void
-swfdec_external_interface__callOut (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
- SwfdecPlayerScripting *scripting = player->priv->scripting;
- SwfdecPlayerScriptingClass *klass;
- const char *s;
-
- SWFDEC_AS_VALUE_SET_NULL (ret);
- if (scripting == NULL || argc == 0)
- return;
- s = swfdec_as_value_to_string (cx, &argv[0]);
- klass = SWFDEC_PLAYER_SCRIPTING_GET_CLASS (scripting);
- if (klass->xml_call) {
- char *t = klass->xml_call (scripting, player, s);
- if (t != NULL) {
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, t));
- }
- }
-}
-
-SWFDEC_AS_NATIVE (14, 5, swfdec_external_interface__escapeXML)
-void
-swfdec_external_interface__escapeXML (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- const char *s;
-
- if (argc == 0 ||
- (s = swfdec_as_value_to_string (cx, &argv[0])) == SWFDEC_AS_STR_EMPTY) {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- return;
- }
-
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, swfdec_xml_escape (s)));
-}
-
-SWFDEC_AS_NATIVE (14, 6, swfdec_external_interface__unescapeXML)
-void
-swfdec_external_interface__unescapeXML (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- const char *s;
-
- if (argc == 0 ||
- (s = swfdec_as_value_to_string (cx, &argv[0])) == SWFDEC_AS_STR_EMPTY) {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- return;
- }
-
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx,
- swfdec_xml_unescape_len (cx, s, strlen (s), FALSE)));
-}
-
-SWFDEC_AS_NATIVE (14, 7, swfdec_external_interface__jsQuoteString)
-void
-swfdec_external_interface__jsQuoteString (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- const char *s;
- GString *str;
- size_t len;
-
- if (argc == 0 ||
- (s = swfdec_as_value_to_string (cx, &argv[0])) == SWFDEC_AS_STR_EMPTY) {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- return;
- }
-
- str = g_string_new ("");
- do {
- /* Yay, we don't escape backslashes! */
- len = strcspn (s, "\n\r\"");
- g_string_append_len (str, s, len);
- s += len;
- if (*s == '\0')
- break;
- g_string_append_c (str, '\\');
- switch (*s) {
- case '\n':
- g_string_append_c (str, 'n');
- break;
- case '\r':
- g_string_append_c (str, 'r');
- break;
- case '"':
- g_string_append_c (str, '"');
- break;
- default:
- g_assert_not_reached ();
- break;
- };
- s++;
- } while (TRUE);
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, g_string_free (str, FALSE)));
-}
-
-SWFDEC_AS_NATIVE (14, 100, swfdec_external_interface_get_available)
-void
-swfdec_external_interface_get_available (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, SWFDEC_PLAYER (cx)->priv->scripting != NULL);
-}
-
-SWFDEC_AS_NATIVE (14, 101, swfdec_external_interface_set_available)
-void
-swfdec_external_interface_set_available (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- /* read-only property */
-}
diff --git a/libswfdec/swfdec_file_loader.c b/libswfdec/swfdec_file_loader.c
deleted file mode 100644
index 178601a..0000000
--- a/libswfdec/swfdec_file_loader.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include "swfdec_loader_internal.h"
-#include "swfdec_buffer.h"
-#include "swfdec_debug.h"
-#include "swfdec_player_internal.h"
-
-/**
- * SwfdecFileLoader:
- *
- * This is a #SwfdecLoader that can load content from files. This symbol is
- * exported so you can subclass your own loaders from it and have automatic
- * file access.
- */
-
-G_DEFINE_TYPE (SwfdecFileLoader, swfdec_file_loader, SWFDEC_TYPE_LOADER)
-
-static void
-swfdec_file_loader_load (SwfdecLoader *loader, SwfdecPlayer *player,
- const char *url_string, SwfdecLoaderRequest request, SwfdecBuffer *buffer)
-{
- SwfdecStream *stream = SWFDEC_STREAM (loader);
- GError *error = NULL;
- char *real;
- SwfdecURL *url;
-
- if (swfdec_url_path_is_relative (url_string)) {
- url = swfdec_url_new_relative (swfdec_player_get_base_url (player), url_string);
- } else {
- url = swfdec_url_new (url_string);
- }
- if (url == NULL) {
- swfdec_stream_error (stream, "%s is an invalid URL", url_string);
- return;
- }
- swfdec_loader_set_url (loader, swfdec_url_get_url (url));
- if (!g_str_equal (swfdec_url_get_protocol (url), "file")) {
- swfdec_stream_error (stream, "Don't know how to handle this protocol");
- swfdec_url_free (url);
- return;
- }
- if (swfdec_url_get_host (url)) {
- swfdec_stream_error (stream, "filenames cannot have hostnames");
- swfdec_url_free (url);
- return;
- }
-
- /* FIXME: append query string here? */
- real = g_strconcat ("/", swfdec_url_get_path (url), NULL);
- buffer = swfdec_buffer_new_from_file (real, &error);
- g_free (real);
- if (buffer == NULL) {
- swfdec_stream_error (stream, "%s", error->message);
- g_error_free (error);
- } else {
- swfdec_loader_set_size (loader, buffer->length);
- swfdec_stream_open (stream);
- swfdec_stream_push (stream, buffer);
- swfdec_stream_eof (stream);
- }
- swfdec_url_free (url);
-}
-
-static void
-swfdec_file_loader_class_init (SwfdecFileLoaderClass *klass)
-{
- SwfdecLoaderClass *loader_class = SWFDEC_LOADER_CLASS (klass);
-
- loader_class->load = swfdec_file_loader_load;
-}
-
-static void
-swfdec_file_loader_init (SwfdecFileLoader *loader)
-{
-}
-
diff --git a/libswfdec/swfdec_file_loader.h b/libswfdec/swfdec_file_loader.h
deleted file mode 100644
index facd8c5..0000000
--- a/libswfdec/swfdec_file_loader.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_FILE_LOADER_H_
-#define _SWFDEC_FILE_LOADER_H_
-
-#include <libswfdec/swfdec_loader.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecFileLoader SwfdecFileLoader;
-typedef struct _SwfdecFileLoaderClass SwfdecFileLoaderClass;
-
-#define SWFDEC_TYPE_FILE_LOADER (swfdec_file_loader_get_type())
-#define SWFDEC_IS_FILE_LOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_FILE_LOADER))
-#define SWFDEC_IS_FILE_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_FILE_LOADER))
-#define SWFDEC_FILE_LOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_FILE_LOADER, SwfdecFileLoader))
-#define SWFDEC_FILE_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_FILE_LOADER, SwfdecFileLoaderClass))
-#define SWFDEC_FILE_LOADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_FILE_LOADER, SwfdecFileLoaderClass))
-
-struct _SwfdecFileLoader
-{
- SwfdecLoader loader;
-};
-
-struct _SwfdecFileLoaderClass
-{
- SwfdecLoaderClass loader_class;
-};
-
-GType swfdec_file_loader_get_type (void);
-
-
-G_END_DECLS
-
-#endif /* _SWFDEC_FILE_LOADER_H_ */
diff --git a/libswfdec/swfdec_file_reference.c b/libswfdec/swfdec_file_reference.c
deleted file mode 100644
index 4bbcd32..0000000
--- a/libswfdec/swfdec_file_reference.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (2204, 0, swfdec_file_reference_browse)
-void
-swfdec_file_reference_browse (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("FileReference.browse");
-}
-
-SWFDEC_AS_NATIVE (2204, 1, swfdec_file_reference_upload)
-void
-swfdec_file_reference_upload (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("FileReference.upload");
-}
-
-SWFDEC_AS_NATIVE (2204, 2, swfdec_file_reference_download)
-void
-swfdec_file_reference_download (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("FileReference.download");
-}
-
-SWFDEC_AS_NATIVE (2204, 3, swfdec_file_reference_cancel)
-void
-swfdec_file_reference_cancel (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("FileReference.cancel");
-}
-
-static void
-swfdec_file_reference_get_creationDate (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("FileReference.creationDate (get)");
-}
-
-static void
-swfdec_file_reference_get_creator (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("FileReference.creator (get)");
-}
-
-static void
-swfdec_file_reference_get_modificationDate (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("FileReference.modificationDate (get)");
-}
-
-static void
-swfdec_file_reference_get_name (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("FileReference.name (get)");
-}
-
-static void
-swfdec_file_reference_get_size (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("FileReference.size (get)");
-}
-
-static void
-swfdec_file_reference_get_type (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("FileReference.type (get)");
-}
-
-// Note: this is not actually the flash.net.FileReference function, but is
-// called from within that function
-SWFDEC_AS_NATIVE (2204, 200, swfdec_file_reference_construct)
-void
-swfdec_file_reference_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecAsObject *target;
- SwfdecAsValue val;
-
- SWFDEC_STUB ("FileReference");
-
- if (argc > 0 && SWFDEC_AS_VALUE_IS_OBJECT (&argv[0])) {
- target = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
- } else {
- target = object;
- if (target == NULL)
- return;
- }
-
- swfdec_as_object_add_native_variable (target, SWFDEC_AS_STR_creationDate,
- swfdec_file_reference_get_creationDate, NULL);
- swfdec_as_object_add_native_variable (target, SWFDEC_AS_STR_creator,
- swfdec_file_reference_get_creator, NULL);
- swfdec_as_object_add_native_variable (target, SWFDEC_AS_STR_modificationDate,
- swfdec_file_reference_get_modificationDate, NULL);
- swfdec_as_object_add_native_variable (target, SWFDEC_AS_STR_name,
- swfdec_file_reference_get_name, NULL);
- swfdec_as_object_add_native_variable (target, SWFDEC_AS_STR_size,
- swfdec_file_reference_get_size, NULL);
- swfdec_as_object_add_native_variable (target, SWFDEC_AS_STR_type,
- swfdec_file_reference_get_type, NULL);
-
- SWFDEC_AS_VALUE_SET_STRING (&val, SWFDEC_AS_STR_undefined);
- swfdec_as_object_set_variable (target, SWFDEC_AS_STR_postData, &val);
-}
diff --git a/libswfdec/swfdec_file_reference_list.c b/libswfdec/swfdec_file_reference_list.c
deleted file mode 100644
index 52f4703..0000000
--- a/libswfdec/swfdec_file_reference_list.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (2205, 0, swfdec_file_reference_list_browse)
-void
-swfdec_file_reference_list_browse (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("FileReferenceList.browse");
-}
diff --git a/libswfdec/swfdec_filter.c b/libswfdec/swfdec_filter.c
deleted file mode 100644
index b51561b..0000000
--- a/libswfdec/swfdec_filter.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_filter.h"
-#include "swfdec_debug.h"
-
-G_DEFINE_ABSTRACT_TYPE (SwfdecFilter, swfdec_filter, SWFDEC_TYPE_AS_OBJECT)
-
-static void
-swfdec_filter_class_init (SwfdecFilterClass *klass)
-{
-}
-
-static void
-swfdec_filter_init (SwfdecFilter *array)
-{
-}
-
-cairo_pattern_t *
-swfdec_filter_apply (SwfdecFilter *filter, cairo_pattern_t *pattern)
-{
- SwfdecFilterClass *klass;
- cairo_pattern_t *ret;
-
- g_return_val_if_fail (SWFDEC_IS_FILTER (filter), NULL);
- g_return_val_if_fail (pattern != NULL, NULL);
-
- klass = SWFDEC_FILTER_GET_CLASS (filter);
- g_assert (klass->apply);
-
- ret = klass->apply (filter, pattern);
- cairo_pattern_destroy (pattern);
- return ret;
-}
-
-GSList *
-swfdec_filter_parse (SwfdecPlayer *player, SwfdecBits *bits)
-{
- GSList *filters = NULL;
- guint i, n_filters, filter_id;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (bits != NULL, NULL);
-
- n_filters = swfdec_bits_get_u8 (bits);
- SWFDEC_LOG (" filters: %u", n_filters);
- for (i = 0; i < n_filters && swfdec_bits_left (bits); i++) {
- filter_id = swfdec_bits_get_u8 (bits);
- switch (filter_id) {
- case 0:
- SWFDEC_WARNING (" drop shadow");
- swfdec_bits_skip_bytes (bits, 16);
- break;
- case 1:
- SWFDEC_WARNING (" blur");
- swfdec_bits_skip_bytes (bits, 9);
- break;
- case 2:
- SWFDEC_WARNING (" glow");
- swfdec_bits_skip_bytes (bits, 15);
- break;
- case 3:
- SWFDEC_WARNING (" bevel");
- swfdec_bits_skip_bytes (bits, 27);
- break;
- case 4:
- {
- guint n;
- n = swfdec_bits_get_u8 (bits);
- SWFDEC_WARNING (" gradient glow");
- swfdec_bits_skip_bytes (bits, n * 5 + 19);
- }
- break;
- case 5:
- {
- guint x, y;
- x = swfdec_bits_get_u8 (bits);
- y = swfdec_bits_get_u8 (bits);
- SWFDEC_WARNING (" %u x %u convolution", x, y);
- swfdec_bits_skip_bytes (bits, (x + y) * 4 + 13);
- }
- break;
- case 6:
- SWFDEC_WARNING (" color matrix");
- swfdec_bits_skip_bytes (bits, 20 * 4);
- break;
- case 7:
- {
- guint n;
- n = swfdec_bits_get_u8 (bits);
- SWFDEC_WARNING (" gradient bevel");
- swfdec_bits_skip_bytes (bits, n * 5 + 19);
- }
- break;
- default:
- SWFDEC_ERROR ("unknown filter id %u", filter_id);
- break;
- }
- }
-
- filters = g_slist_reverse (filters);
- return filters;
-}
-
diff --git a/libswfdec/swfdec_filter.h b/libswfdec/swfdec_filter.h
deleted file mode 100644
index 2f39f15..0000000
--- a/libswfdec/swfdec_filter.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_FILTER_H_
-#define _SWFDEC_FILTER_H_
-
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_bits.h>
-#include <libswfdec/swfdec_types.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecFilterClass SwfdecFilterClass;
-
-#define SWFDEC_TYPE_FILTER (swfdec_filter_get_type())
-#define SWFDEC_IS_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_FILTER))
-#define SWFDEC_IS_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_FILTER))
-#define SWFDEC_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_FILTER, SwfdecFilter))
-#define SWFDEC_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_FILTER, SwfdecFilterClass))
-#define SWFDEC_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_FILTER, SwfdecFilterClass))
-
-struct _SwfdecFilter {
- SwfdecAsObject object;
-};
-
-struct _SwfdecFilterClass {
- SwfdecAsObjectClass object_class;
-
- SwfdecFilter * (* clone) (SwfdecFilter * filter);
- cairo_pattern_t * (* apply) (SwfdecFilter * filter,
- cairo_pattern_t * pattern);
-};
-
-GType swfdec_filter_get_type (void);
-
-cairo_pattern_t * swfdec_filter_apply (SwfdecFilter * filter,
- cairo_pattern_t * pattern);
-GSList * swfdec_filter_parse (SwfdecPlayer * player,
- SwfdecBits * bits);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_filter_as.c b/libswfdec/swfdec_filter_as.c
deleted file mode 100644
index 0f00211..0000000
--- a/libswfdec/swfdec_filter_as.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_filter.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (1112, 1, swfdec_filter_clone)
-void
-swfdec_filter_clone (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- SwfdecFilter *filter;
- SwfdecFilterClass *klass;
-
- if (!SWFDEC_IS_FILTER (object))
- return;
-
- filter = SWFDEC_FILTER (object);
- klass = SWFDEC_FILTER_GET_CLASS (filter);
- g_assert (klass->clone);
-
- filter = klass->clone (filter);
- if (filter)
- SWFDEC_AS_VALUE_SET_OBJECT (retval, SWFDEC_AS_OBJECT (filter));
-}
-
diff --git a/libswfdec/swfdec_flv_decoder.c b/libswfdec/swfdec_flv_decoder.c
deleted file mode 100644
index 52f14e2..0000000
--- a/libswfdec/swfdec_flv_decoder.c
+++ /dev/null
@@ -1,595 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_flv_decoder.h"
-#include "swfdec_audio_internal.h"
-#include "swfdec_bits.h"
-#include "swfdec_debug.h"
-
-enum {
- SWFDEC_STATE_HEADER, /* need to parse header */
- SWFDEC_STATE_LAST_TAG, /* read size of last tag */
- SWFDEC_STATE_TAG, /* read next tag */
- SWFDEC_STATE_EOF /* file is complete */
-};
-
-typedef struct _SwfdecFlvVideoTag SwfdecFlvVideoTag;
-typedef struct _SwfdecFlvAudioTag SwfdecFlvAudioTag;
-typedef struct _SwfdecFlvDataTag SwfdecFlvDataTag;
-
-struct _SwfdecFlvVideoTag {
- guint timestamp; /* milliseconds */
- guint format; /* format in use */
- int frame_type; /* 0: undefined, 1: keyframe, 2: iframe, 3: H263 disposable iframe */
- SwfdecBuffer * buffer; /* buffer for this data */
-};
-
-struct _SwfdecFlvAudioTag {
- guint timestamp; /* milliseconds */
- guint format; /* format in use */
- SwfdecAudioFormat original_format; /* channel/rate information */
- SwfdecBuffer * buffer; /* buffer for this data */
-};
-
-struct _SwfdecFlvDataTag {
- guint timestamp; /* milliseconds */
- SwfdecBuffer * buffer; /* buffer containing raw AMF data */
-};
-
-G_DEFINE_TYPE (SwfdecFlvDecoder, swfdec_flv_decoder, SWFDEC_TYPE_DECODER)
-
-static void
-swfdec_flv_decoder_dispose (GObject *object)
-{
- SwfdecFlvDecoder *flv = SWFDEC_FLV_DECODER (object);
- guint i;
-
- if (flv->audio) {
- for (i = 0; i < flv->audio->len; i++) {
- SwfdecFlvAudioTag *tag = &g_array_index (flv->audio, SwfdecFlvAudioTag, i);
- swfdec_buffer_unref (tag->buffer);
- }
- g_array_free (flv->audio, TRUE);
- flv->audio = NULL;
- }
- if (flv->video) {
- for (i = 0; i < flv->video->len; i++) {
- SwfdecFlvVideoTag *tag = &g_array_index (flv->video, SwfdecFlvVideoTag, i);
- swfdec_buffer_unref (tag->buffer);
- }
- g_array_free (flv->video, TRUE);
- flv->video = NULL;
- }
- if (flv->data) {
- for (i = 0; i < flv->data->len; i++) {
- SwfdecFlvDataTag *tag = &g_array_index (flv->data, SwfdecFlvDataTag, i);
- swfdec_buffer_unref (tag->buffer);
- }
- g_array_free (flv->data, TRUE);
- flv->data = NULL;
- }
- swfdec_buffer_queue_unref (flv->queue);
- flv->queue = NULL;
-
- G_OBJECT_CLASS (swfdec_flv_decoder_parent_class)->dispose (object);
-}
-
-static SwfdecStatus
-swfdec_flv_decoder_parse_header (SwfdecFlvDecoder *flv)
-{
- SwfdecBuffer *buffer;
- SwfdecBits bits;
- guint version, header_length;
- gboolean has_audio, has_video;
-
- buffer = swfdec_buffer_queue_peek (flv->queue, 9);
- if (buffer == NULL)
- return SWFDEC_STATUS_NEEDBITS;
-
- swfdec_bits_init (&bits, buffer);
- /* Check if we're really an FLV file */
- if (swfdec_bits_get_u8 (&bits) != 'F' ||
- swfdec_bits_get_u8 (&bits) != 'L' ||
- swfdec_bits_get_u8 (&bits) != 'V') {
- swfdec_buffer_unref (buffer);
- return SWFDEC_STATUS_ERROR;
- }
-
- version = swfdec_bits_get_u8 (&bits);
- swfdec_bits_getbits (&bits, 5);
- has_audio = swfdec_bits_getbit (&bits);
- swfdec_bits_getbit (&bits);
- has_video = swfdec_bits_getbit (&bits);
- header_length = swfdec_bits_get_bu32 (&bits);
- swfdec_buffer_unref (buffer);
- if (header_length < 9) {
- SWFDEC_ERROR ("invalid header length %u, must be 9 or greater", header_length);
- /* FIXME: treat as error or ignore? */
- return SWFDEC_STATUS_ERROR;
- }
- buffer = swfdec_buffer_queue_pull (flv->queue, header_length);
- if (buffer == NULL)
- return SWFDEC_STATUS_NEEDBITS;
- swfdec_buffer_unref (buffer);
- SWFDEC_LOG ("parsing flv stream");
- SWFDEC_LOG (" version %u", version);
- SWFDEC_LOG (" with%s audio", has_audio ? "" : "out");
- SWFDEC_LOG (" with%s video", has_video ? "" : "out");
- flv->version = version;
- if (has_audio) {
- flv->audio = g_array_new (FALSE, FALSE, sizeof (SwfdecFlvAudioTag));
- }
- if (has_video) {
- flv->video = g_array_new (FALSE, FALSE, sizeof (SwfdecFlvVideoTag));
- }
- flv->state = SWFDEC_STATE_LAST_TAG;
-
- return SWFDEC_STATUS_OK;
-}
-
-static SwfdecStatus
-swfdec_flv_decoder_parse_last_tag (SwfdecFlvDecoder *flv)
-{
- SwfdecBuffer *buffer;
- SwfdecBits bits;
- guint last_tag;
-
- buffer = swfdec_buffer_queue_pull (flv->queue, 4);
- if (buffer == NULL)
- return SWFDEC_STATUS_NEEDBITS;
-
- swfdec_bits_init (&bits, buffer);
- last_tag = swfdec_bits_get_bu32 (&bits);
- SWFDEC_LOG ("last tag was %u bytes", last_tag);
- swfdec_buffer_unref (buffer);
- flv->state = SWFDEC_STATE_TAG;
- return SWFDEC_STATUS_OK;
-}
-
-static guint
-swfdec_flv_decoder_find_video (SwfdecFlvDecoder *flv, guint timestamp)
-{
- guint min, max;
-
- g_assert (flv->video);
-
- min = 0;
- max = flv->video->len;
- while (max - min > 1) {
- guint cur = (max + min) / 2;
- SwfdecFlvVideoTag *tag = &g_array_index (flv->video, SwfdecFlvVideoTag, cur);
- if (tag->timestamp > timestamp) {
- max = cur;
- } else {
- min = cur;
- }
- }
- return min;
-}
-
-static guint
-swfdec_flv_decoder_find_audio (SwfdecFlvDecoder *flv, guint timestamp)
-{
- guint min, max;
-
- g_assert (flv->audio);
-
- min = 0;
- max = flv->audio->len;
- while (max - min > 1) {
- guint cur = (max + min) / 2;
- SwfdecFlvAudioTag *tag = &g_array_index (flv->audio, SwfdecFlvAudioTag, cur);
- if (tag->timestamp > timestamp) {
- max = cur;
- } else {
- min = cur;
- }
- }
- return min;
-}
-
-static guint
-swfdec_flv_decoder_find_data (SwfdecFlvDecoder *flv, guint timestamp)
-{
- guint min, max;
-
- g_assert (flv->data);
-
- min = 0;
- max = flv->data->len;
- while (max - min > 1) {
- guint cur = (max + min) / 2;
- SwfdecFlvDataTag *tag = &g_array_index (flv->data, SwfdecFlvDataTag, cur);
- if (tag->timestamp > timestamp) {
- max = cur;
- } else {
- min = cur;
- }
- }
- return min;
-}
-
-static SwfdecStatus
-swfdec_flv_decoder_parse_video_tag (SwfdecFlvDecoder *flv, SwfdecBits *bits, guint timestamp)
-{
- SwfdecFlvVideoTag tag;
-
- if (flv->video == NULL) {
- SWFDEC_INFO ("video tags even though header didn't decalre them. Initializing...");
- flv->video = g_array_new (FALSE, FALSE, sizeof (SwfdecFlvVideoTag));
- return SWFDEC_STATUS_OK;
- }
-
- tag.timestamp = timestamp;
- tag.frame_type = swfdec_bits_getbits (bits, 4);
- tag.format = swfdec_bits_getbits (bits, 4);
- tag.buffer = swfdec_bits_get_buffer (bits, -1);
- SWFDEC_LOG (" format: %u", tag.format);
- SWFDEC_LOG (" frame type: %u", tag.frame_type);
- if (tag.buffer == NULL) {
- SWFDEC_WARNING ("no buffer, ignoring");
- return SWFDEC_STATUS_OK;
- }
- if (flv->video->len == 0) {
- g_array_append_val (flv->video, tag);
- } else if (g_array_index (flv->video, SwfdecFlvVideoTag,
- flv->video->len - 1).timestamp < tag.timestamp) {
- g_array_append_val (flv->video, tag);
- } else {
- guint idx;
- SWFDEC_WARNING ("timestamps of video buffers not increasing (last was %u, now %u)",
- g_array_index (flv->video, SwfdecFlvVideoTag, flv->video->len - 1).timestamp,
- tag.timestamp);
- idx = swfdec_flv_decoder_find_video (flv, tag.timestamp);
- g_array_insert_val (flv->video, idx, tag);
- }
- return SWFDEC_STATUS_IMAGE;
-}
-
-static void
-swfdec_flv_decoder_parse_audio_tag (SwfdecFlvDecoder *flv, SwfdecBits *bits, guint timestamp)
-{
- SwfdecFlvAudioTag tag;
-
- if (flv->audio == NULL) {
- SWFDEC_INFO ("audio tags even though header didn't decalre them. Initializing...");
- flv->audio = g_array_new (FALSE, FALSE, sizeof (SwfdecFlvAudioTag));
- return;
- }
-
- tag.timestamp = timestamp;
- tag.format = swfdec_bits_getbits (bits, 4);
- tag.original_format = swfdec_audio_format_parse (bits);
- tag.buffer = swfdec_bits_get_buffer (bits, -1);
- SWFDEC_LOG (" codec: %u", (guint) tag.format);
- SWFDEC_LOG (" format: %s", swfdec_audio_format_to_string (tag.original_format));
- if (tag.buffer == NULL) {
- SWFDEC_WARNING ("no buffer, ignoring");
- return;
- }
- if (flv->audio->len == 0) {
- g_array_append_val (flv->audio, tag);
- } else if (g_array_index (flv->audio, SwfdecFlvAudioTag,
- flv->audio->len - 1).timestamp < tag.timestamp) {
- g_array_append_val (flv->audio, tag);
- } else {
- guint idx;
- SWFDEC_WARNING ("timestamps of audio buffers not increasing (last was %u, now %u)",
- g_array_index (flv->audio, SwfdecFlvAudioTag, flv->audio->len - 1).timestamp,
- tag.timestamp);
- idx = swfdec_flv_decoder_find_audio (flv, tag.timestamp);
- g_array_insert_val (flv->audio, idx, tag);
- }
-}
-
-static void
-swfdec_flv_decoder_parse_data_tag (SwfdecFlvDecoder *flv, SwfdecBits *bits, guint timestamp)
-{
- SwfdecFlvDataTag tag;
-
- if (flv->data == NULL) {
- flv->data = g_array_new (FALSE, FALSE, sizeof (SwfdecFlvDataTag));
- }
-
- tag.timestamp = timestamp;
- tag.buffer = swfdec_bits_get_buffer (bits, -1);
- if (tag.buffer == NULL) {
- SWFDEC_WARNING ("no buffer, ignoring");
- return;
- }
- if (flv->data->len == 0) {
- g_array_append_val (flv->data, tag);
- } else if (g_array_index (flv->data, SwfdecFlvDataTag,
- flv->data->len - 1).timestamp < tag.timestamp) {
- g_array_append_val (flv->data, tag);
- } else {
- guint idx;
- SWFDEC_WARNING ("timestamps of data buffers not increasing (last was %u, now %u)",
- g_array_index (flv->data, SwfdecFlvDataTag, flv->data->len - 1).timestamp,
- tag.timestamp);
- idx = swfdec_flv_decoder_find_data (flv, tag.timestamp);
- g_array_insert_val (flv->data, idx, tag);
- }
-}
-
-static SwfdecStatus
-swfdec_flv_decoder_parse_tag (SwfdecFlvDecoder *flv)
-{
- SwfdecBuffer *buffer;
- SwfdecBits bits;
- guint size, type, timestamp;
- SwfdecStatus ret = SWFDEC_STATUS_OK;
-
- buffer = swfdec_buffer_queue_peek (flv->queue, 4);
- if (buffer == NULL)
- return SWFDEC_STATUS_NEEDBITS;
- swfdec_bits_init (&bits, buffer);
- swfdec_bits_get_u8 (&bits);
- size = swfdec_bits_get_bu24 (&bits);
- swfdec_buffer_unref (buffer);
- buffer = swfdec_buffer_queue_pull (flv->queue, 11 + size);
- if (buffer == NULL)
- return SWFDEC_STATUS_NEEDBITS;
- swfdec_bits_init (&bits, buffer);
- type = swfdec_bits_get_u8 (&bits);
- /* I think I'm paranoid and complicated. I think I'm paranoid, manipulated */
- if (size != swfdec_bits_get_bu24 (&bits)) {
- g_assert_not_reached ();
- }
- timestamp = swfdec_bits_get_bu24 (&bits);
- swfdec_bits_get_bu32 (&bits);
- SWFDEC_LOG ("new tag");
- SWFDEC_LOG (" type %u", type);
- SWFDEC_LOG (" size %u", size);
- SWFDEC_LOG (" timestamp %u", timestamp);
- switch (type) {
- case 8:
- swfdec_flv_decoder_parse_audio_tag (flv, &bits, timestamp);
- break;
- case 9:
- ret = swfdec_flv_decoder_parse_video_tag (flv, &bits, timestamp);
- break;
- case 18:
- swfdec_flv_decoder_parse_data_tag (flv, &bits, timestamp);
- break;
- default:
- SWFDEC_WARNING ("unknown tag (type %u)", type);
- break;
- }
- swfdec_buffer_unref (buffer);
- flv->state = SWFDEC_STATE_LAST_TAG;
- return ret;
-}
-
-static SwfdecStatus
-swfdec_flv_decoder_parse (SwfdecDecoder *dec, SwfdecBuffer *buffer)
-{
- SwfdecFlvDecoder *flv = SWFDEC_FLV_DECODER (dec);
- SwfdecStatus status = 0;
-
- swfdec_buffer_queue_push (flv->queue, buffer);
-
- do {
- switch (flv->state) {
- case SWFDEC_STATE_HEADER:
- status |= swfdec_flv_decoder_parse_header (flv);
- break;
- case SWFDEC_STATE_LAST_TAG:
- status |= swfdec_flv_decoder_parse_last_tag (flv);
- break;
- case SWFDEC_STATE_TAG:
- status |= swfdec_flv_decoder_parse_tag (flv);
- break;
- case SWFDEC_STATE_EOF:
- status |= SWFDEC_STATUS_EOF;
- break;
- default:
- g_assert_not_reached ();
- status |= SWFDEC_STATUS_ERROR;
- break;
- }
- } while ((status & (SWFDEC_STATUS_EOF | SWFDEC_STATUS_NEEDBITS | SWFDEC_STATUS_ERROR)) == 0);
-
- return status;
-}
-
-static SwfdecStatus
-swfdec_flv_decoder_eof (SwfdecDecoder *dec)
-{
- SwfdecFlvDecoder *flv = SWFDEC_FLV_DECODER (dec);
-
- flv->state = SWFDEC_STATE_EOF;
-
- return 0;
-}
-
-static void
-swfdec_flv_decoder_class_init (SwfdecFlvDecoderClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
- SwfdecDecoderClass *decoder_class = SWFDEC_DECODER_CLASS (class);
-
- object_class->dispose = swfdec_flv_decoder_dispose;
-
- decoder_class->parse = swfdec_flv_decoder_parse;
- decoder_class->eof = swfdec_flv_decoder_eof;
-}
-
-static void
-swfdec_flv_decoder_init (SwfdecFlvDecoder *flv)
-{
- flv->state = SWFDEC_STATE_HEADER;
- flv->queue = swfdec_buffer_queue_new ();
-}
-
-SwfdecBuffer *
-swfdec_flv_decoder_get_video (SwfdecFlvDecoder *flv, guint timestamp,
- gboolean keyframe, guint *format, guint *real_timestamp, guint *next_timestamp)
-{
- guint id, offset;
- SwfdecFlvVideoTag *tag;
-
- g_return_val_if_fail (SWFDEC_IS_FLV_DECODER (flv), NULL);
- g_return_val_if_fail (flv->video != NULL, NULL);
-
- if (flv->video->len == 0) {
- if (next_timestamp)
- *next_timestamp = 0;
- if (real_timestamp)
- *real_timestamp = 0;
- if (format)
- *format = SWFDEC_VIDEO_CODEC_UNDEFINED;
- return NULL;
- }
- offset = g_array_index (flv->video, SwfdecFlvVideoTag, 0).timestamp;
- timestamp += offset;
- id = swfdec_flv_decoder_find_video (flv, timestamp);
- tag = &g_array_index (flv->video, SwfdecFlvVideoTag, id);
- if (keyframe) {
- while (id > 0 && tag->frame_type != 1) {
- id--;
- tag--;
- }
- }
- if (next_timestamp) {
- if (id + 1 >= flv->video->len)
- *next_timestamp = 0;
- else
- *next_timestamp = g_array_index (flv->video, SwfdecFlvVideoTag, id + 1).timestamp - offset;
- }
- if (real_timestamp)
- *real_timestamp = tag->timestamp - offset;
- if (format)
- *format = tag->format;
- return tag->buffer;
-}
-
-gboolean
-swfdec_flv_decoder_get_video_info (SwfdecFlvDecoder *flv,
- guint *first_timestamp, guint *last_timestamp)
-{
- g_return_val_if_fail (SWFDEC_IS_FLV_DECODER (flv), FALSE);
-
- if (flv->video == NULL)
- return FALSE;
-
- if (flv->video->len == 0) {
- if (first_timestamp)
- *first_timestamp = 0;
- if (last_timestamp)
- *last_timestamp = 0;
- return TRUE;
- }
- if (first_timestamp)
- *first_timestamp = g_array_index (flv->video, SwfdecFlvVideoTag, 0).timestamp;
- if (last_timestamp)
- *last_timestamp = g_array_index (flv->video, SwfdecFlvVideoTag, flv->video->len - 1).timestamp;
- return TRUE;
-}
-
-SwfdecBuffer *
-swfdec_flv_decoder_get_audio (SwfdecFlvDecoder *flv, guint timestamp,
- guint *codec, SwfdecAudioFormat *format,
- guint *real_timestamp, guint *next_timestamp)
-{
- guint id, offset;
- SwfdecFlvAudioTag *tag;
-
- g_return_val_if_fail (SWFDEC_IS_FLV_DECODER (flv), NULL);
- g_return_val_if_fail (flv->audio != NULL, NULL);
-
- if (flv->audio->len == 0) {
- if (next_timestamp)
- *next_timestamp = 0;
- if (real_timestamp)
- *real_timestamp = 0;
- if (codec)
- *codec = SWFDEC_AUDIO_CODEC_UNDEFINED;
- if (format)
- *format = swfdec_audio_format_new (44100, 2, TRUE);
- return NULL;
- }
- offset = g_array_index (flv->audio, SwfdecFlvAudioTag, 0).timestamp;
- timestamp += offset;
- id = swfdec_flv_decoder_find_audio (flv, timestamp);
- if (next_timestamp) {
- if (id + 1 >= flv->audio->len)
- *next_timestamp = 0;
- else
- *next_timestamp = g_array_index (flv->audio, SwfdecFlvAudioTag, id + 1).timestamp - offset;
- }
- tag = &g_array_index (flv->audio, SwfdecFlvAudioTag, id);
- if (real_timestamp)
- *real_timestamp = tag->timestamp - offset;
- if (codec)
- *codec = tag->format;
- if (format)
- *format = tag->original_format;
- return tag->buffer;
-}
-
-/**
- * swfdec_flv_decoder_get_data:
- * @flv: a #SwfdecFlvDecoder
- * @timestamp: timestamp to look for
- * @real_timestamp: the timestamp of the returned buffer, if any
- *
- * Finds the next data event with a timestamp of at least @timestamp. If one
- * exists, it is returned, and its real timestamp put into @real_timestamp.
- * Otherwise, %NULL is returned.
- *
- * Returns: a #SwfdecBuffer containing the next data or NULL if none
- **/
-SwfdecBuffer *
-swfdec_flv_decoder_get_data (SwfdecFlvDecoder *flv, guint timestamp, guint *real_timestamp)
-{
- guint id;
- SwfdecFlvDataTag *tag;
-
- g_return_val_if_fail (SWFDEC_IS_FLV_DECODER (flv), NULL);
-
- if (flv->data == NULL ||
- flv->data->len == 0)
- return NULL;
-
- id = swfdec_flv_decoder_find_data (flv, timestamp);
- tag = &g_array_index (flv->data, SwfdecFlvDataTag, id);
- while (tag->timestamp < timestamp) {
- id++;
- if (id >= flv->data->len)
- return NULL;
- tag++;
- }
- if (real_timestamp)
- *real_timestamp = tag->timestamp;
- return tag->buffer;
-}
-
-gboolean
-swfdec_flv_decoder_is_eof (SwfdecFlvDecoder *flv)
-{
- g_return_val_if_fail (SWFDEC_IS_FLV_DECODER (flv), TRUE);
-
- return flv->state == SWFDEC_STATE_EOF;
-}
-
diff --git a/libswfdec/swfdec_flv_decoder.h b/libswfdec/swfdec_flv_decoder.h
deleted file mode 100644
index 635fea4..0000000
--- a/libswfdec/swfdec_flv_decoder.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef __SWFDEC_FLV_DECODER_H__
-#define __SWFDEC_FLV_DECODER_H__
-
-#include <libswfdec/swfdec_codec_audio.h>
-#include <libswfdec/swfdec_codec_video.h>
-#include <libswfdec/swfdec_decoder.h>
-
-G_BEGIN_DECLS
-
-
-typedef struct _SwfdecFlvDecoder SwfdecFlvDecoder;
-typedef struct _SwfdecFlvDecoderClass SwfdecFlvDecoderClass;
-
-#define SWFDEC_TYPE_FLV_DECODER (swfdec_flv_decoder_get_type())
-#define SWFDEC_IS_FLV_DECODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_FLV_DECODER))
-#define SWFDEC_IS_FLV_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_FLV_DECODER))
-#define SWFDEC_FLV_DECODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_FLV_DECODER, SwfdecFlvDecoder))
-#define SWFDEC_FLV_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_FLV_DECODER, SwfdecFlvDecoderClass))
-#define SWFDEC_FLV_DECODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_FLV_DECODER, SwfdecFlvDecoderClass))
-
-struct _SwfdecFlvDecoder
-{
- SwfdecDecoder decoder;
-
- int version; /* only version 1 is known for now */
- int state; /* parsing state we're in */
- GArray * audio; /* audio tags */
- GArray * video; /* video tags */
- GArray * data; /* data tags (if any) */
- SwfdecBufferQueue * queue; /* queue for parsing */
-};
-
-struct _SwfdecFlvDecoderClass {
- SwfdecDecoderClass decoder_class;
-};
-
-GType swfdec_flv_decoder_get_type (void);
-
-gboolean swfdec_flv_decoder_is_eof (SwfdecFlvDecoder * flv);
-
-SwfdecBuffer * swfdec_flv_decoder_get_video (SwfdecFlvDecoder * flv,
- guint timestamp,
- gboolean keyframe,
- guint * format,
- guint * real_timestamp,
- guint * next_timestamp);
-gboolean swfdec_flv_decoder_get_video_info (SwfdecFlvDecoder * flv,
- guint * first_timestamp,
- guint * last_timestamp);
-SwfdecBuffer * swfdec_flv_decoder_get_audio (SwfdecFlvDecoder * flv,
- guint timestamp,
- guint * codec,
- SwfdecAudioFormat * format,
- guint * real_timestamp,
- guint * next_timestamp);
-SwfdecBuffer * swfdec_flv_decoder_get_data (SwfdecFlvDecoder * flv,
- guint timestamp,
- guint * real_timestamp);
-
-SwfdecMovie * swfdec_flv_decoder_add_movie (SwfdecFlvDecoder * flv,
- SwfdecMovie * parent);
-G_END_DECLS
-
-#endif
diff --git a/libswfdec/swfdec_font.c b/libswfdec/swfdec_font.c
deleted file mode 100644
index bce8792..0000000
--- a/libswfdec/swfdec_font.c
+++ /dev/null
@@ -1,457 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_font.h"
-#include "swfdec_bits.h"
-#include "swfdec_debug.h"
-#include "swfdec_shape_parser.h"
-#include "swfdec_swf_decoder.h"
-#include "swfdec_tag.h"
-
-G_DEFINE_TYPE (SwfdecFont, swfdec_font, SWFDEC_TYPE_CHARACTER)
-
-static void
-swfdec_font_dispose (GObject *object)
-{
- SwfdecFont * font = SWFDEC_FONT (object);
- guint i;
-
- if (font->glyphs) {
- for (i = 0; i < font->glyphs->len; i++) {
- SwfdecDraw *draw = g_array_index (font->glyphs, SwfdecFontEntry, i).draw;
- if (draw)
- g_object_unref (draw);
- }
- g_array_free (font->glyphs, TRUE);
- font->glyphs = NULL;
- }
- if (font->desc) {
- pango_font_description_free (font->desc);
- font->desc = NULL;
- }
- if (font->name) {
- g_free (font->name);
- font->name = NULL;
- }
-
- G_OBJECT_CLASS (swfdec_font_parent_class)->dispose (object);
-}
-
-static void
-swfdec_font_class_init (SwfdecFontClass * g_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (g_class);
-
- object_class->dispose = swfdec_font_dispose;
-}
-
-static void
-swfdec_font_init (SwfdecFont * font)
-{
- font->glyphs = g_array_new (FALSE, TRUE, sizeof (SwfdecFontEntry));
-}
-
-/**
- * swfdec_font_get_glyph:
- * @font: a #SwfdecFont
- * @glyph: id of glyph to render
- *
- * Tries to get the shape associated with the given glyph id. It is valid to
- * call this function with any glyph id. If no such glyph exists, this function
- * returns %NULL.
- *
- * Returns: the shape of the requested glyph or %NULL if no such glyph exists.
- **/
-SwfdecDraw *
-swfdec_font_get_glyph (SwfdecFont * font, guint glyph)
-{
- g_return_val_if_fail (SWFDEC_IS_FONT (font), NULL);
-
- if (glyph >= font->glyphs->len)
- return NULL;
-
- return g_array_index (font->glyphs, SwfdecFontEntry, glyph).draw;
-}
-
-#if 0
-static char *
-convert_from_language (const char *s, SwfdecLanguage language)
-{
- char *ret;
- const char *langcode;
-
- switch (language) {
- case SWFDEC_LANGUAGE_LATIN:
- langcode = "LATIN1";
- break;
- case SWFDEC_LANGUAGE_JAPANESE:
- langcode = "SHIFT_JIS";
- break;
- /* FIXME! */
- case SWFDEC_LANGUAGE_KOREAN:
- case SWFDEC_LANGUAGE_CHINESE:
- case SWFDEC_LANGUAGE_CHINESE_TRADITIONAL:
- default:
- SWFDEC_ERROR ("can't convert given text from language %u", language);
- return NULL;
- }
- SWFDEC_LOG ("converting text from %s", langcode);
- ret = g_convert (s, -1, "UTF-8", langcode, NULL, NULL, NULL);
- if (ret == NULL)
- SWFDEC_ERROR ("given text is not in language %s", langcode);
- return ret;
-}
-#endif
-
-int
-tag_func_define_font_info (SwfdecSwfDecoder *s, guint tag)
-{
- SwfdecFont *font;
- guint id, len, i;
- int reserved, wide, ansi, jis;
- char *name;
- /* we just assume Latin1 (FIXME: option to change this?) */
- SwfdecLanguage language = SWFDEC_LANGUAGE_LATIN;
-
- id = swfdec_bits_get_u16 (&s->b);
- font = swfdec_swf_decoder_get_character (s, id);
- if (!SWFDEC_IS_FONT (font)) {
- SWFDEC_WARNING ("didn't find a font with id %u", id);
- return SWFDEC_STATUS_OK;
- }
- len = swfdec_bits_get_u8 (&s->b);
- /* this string is locale specific */
- name = swfdec_bits_get_string_length (&s->b, len, s->version);
- reserved = swfdec_bits_getbits (&s->b, 2);
- font->small = swfdec_bits_getbit (&s->b);
- jis = swfdec_bits_getbit (&s->b);
- ansi = swfdec_bits_getbit (&s->b);
- if (jis != 0 || ansi != 0) {
- SWFDEC_LOG ("ansi = %d, jis = %d", ansi, jis);
- if (tag == SWFDEC_TAG_DEFINEFONTINFO2)
- SWFDEC_INFO ("ANSI and JIS flags are supposed to be 0 in DefineFontInfo");
- if (jis)
- language = SWFDEC_LANGUAGE_JAPANESE;
- }
- font->italic = swfdec_bits_getbit (&s->b);
- font->bold = swfdec_bits_getbit (&s->b);
- wide = swfdec_bits_getbit (&s->b);
- if (tag == SWFDEC_TAG_DEFINEFONTINFO2)
- language = swfdec_bits_get_u8 (&s->b);
- g_free (name);
- if (font->name) {
- SWFDEC_LOG ("Creating font description for font %d", id);
- font->desc = pango_font_description_new ();
- pango_font_description_set_family_static (font->desc, font->name);
- if (font->bold)
- pango_font_description_set_weight (font->desc, PANGO_WEIGHT_BOLD);
- if (font->italic)
- pango_font_description_set_style (font->desc, PANGO_STYLE_ITALIC);
- }
- for (i = 0; i < font->glyphs->len; i++) {
- g_array_index (font->glyphs, SwfdecFontEntry, i).value =
- wide ? swfdec_bits_get_u16 (&s->b) : swfdec_bits_get_u8 (&s->b);
- }
-
- return SWFDEC_STATUS_OK;
-}
-
-static void
-swfdec_font_parse_shape (SwfdecSwfDecoder *s, SwfdecFontEntry *entry, guint size)
-{
- SwfdecBits bits;
- SwfdecShapeParser *parser;
- GSList *list;
-
- swfdec_bits_init_bits (&bits, &s->b, size);
- parser = swfdec_shape_parser_new (NULL, NULL, NULL);
- swfdec_shape_parser_parse (parser, &bits);
- list = swfdec_shape_parser_free (parser);
- if (list) {
- entry->draw = g_object_ref (list->data);
- g_slist_foreach (list, (GFunc) g_object_unref, NULL);
- g_slist_free (list);
- } else {
- entry->draw = NULL;
- }
-
- if (swfdec_bits_left (&bits)) {
- SWFDEC_WARNING ("parsing shape didn't use %d bytes",
- swfdec_bits_left (&bits) / 8);
- }
-}
-
-int
-tag_func_define_font (SwfdecSwfDecoder * s, guint tag)
-{
- guint i, id, n_glyphs, offset, next_offset;
- SwfdecFont *font;
- SwfdecBits offsets;
-
- id = swfdec_bits_get_u16 (&s->b);
- font = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_FONT);
- if (!font)
- return SWFDEC_STATUS_OK;
- font->scale_factor = SWFDEC_TEXT_SCALE_FACTOR;
-
- offset = swfdec_bits_get_u16 (&s->b);
- if (offset % 2) {
- SWFDEC_ERROR ("first offset is odd?!");
- }
- n_glyphs = offset / 2;
- if (n_glyphs == 0)
- return SWFDEC_STATUS_OK;
- swfdec_bits_init_bits (&offsets, &s->b, offset - 2);
-
- g_array_set_size (font->glyphs, n_glyphs);
- for (i = 0; i < n_glyphs && swfdec_bits_left (&s->b); i++) {
- SwfdecFontEntry *entry = &g_array_index (font->glyphs, SwfdecFontEntry, i);
- if (i + 1 == n_glyphs)
- next_offset = offset + swfdec_bits_left (&s->b) / 8;
- else
- next_offset = swfdec_bits_get_u16 (&offsets);
- swfdec_font_parse_shape (s, entry, next_offset - offset);
- offset = next_offset;
- }
- if (i < n_glyphs) {
- SWFDEC_ERROR ("data was only enough for %u glyphs, not %u", i, n_glyphs);
- g_array_set_size (font->glyphs, i);
- }
-
- return SWFDEC_STATUS_OK;
-}
-
-static void
-swfdec_font_parse_kerning_table (SwfdecSwfDecoder *s, SwfdecFont *font, gboolean wide_codes)
-{
- SwfdecBits *bits = &s->b;
- guint n_kernings, i;
-
- n_kernings = swfdec_bits_get_u16 (bits);
- for (i = 0; i < n_kernings; i++) {
- if (wide_codes) {
- swfdec_bits_get_u16 (bits);
- swfdec_bits_get_u16 (bits);
- } else {
- swfdec_bits_get_u8 (bits);
- swfdec_bits_get_u8 (bits);
- }
- swfdec_bits_get_s16 (bits);
- }
-}
-
-int
-tag_func_define_font_2 (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecBits *bits = &s->b;
- SwfdecBits offset_bits;
- guint id;
- SwfdecFont *font;
- SwfdecRect rect;
-
- int has_layout;
- int shift_jis;
- int reserved;
- int ansi;
- int wide_offsets;
- int wide_codes;
- int italic;
- int bold;
- int langcode;
- int font_name_len;
- int n_glyphs;
- int font_ascent;
- int font_descent;
- int font_leading;
- int i;
- guint offset;
-
- id = swfdec_bits_get_u16 (bits);
- font = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_FONT);
- if (!font)
- return SWFDEC_STATUS_OK;
- font->scale_factor = SWFDEC_TEXT_SCALE_FACTOR;
-
- has_layout = swfdec_bits_getbit (bits);
- shift_jis = swfdec_bits_getbit (bits);
- reserved = swfdec_bits_getbit (bits);
- ansi = swfdec_bits_getbit (bits);
- wide_offsets = swfdec_bits_getbit (bits);
- wide_codes = swfdec_bits_getbit (bits);
- italic = swfdec_bits_getbit (bits);
- bold = swfdec_bits_getbit (bits);
-
- langcode = swfdec_bits_get_u8 (bits);
- SWFDEC_DEBUG("langcode %d", langcode);
-
- font_name_len = swfdec_bits_get_u8 (bits);
- font->name = swfdec_bits_get_string_length (bits, font_name_len, s->version);
- if (font->name == NULL) {
- SWFDEC_ERROR ("error reading font name");
- } else {
- SWFDEC_LOG (" font name = %s", font->name);
- }
-
- n_glyphs = swfdec_bits_get_u16 (bits);
- if (wide_offsets) {
- swfdec_bits_init_bits (&offset_bits, bits, 4 * n_glyphs + 4);
- offset = swfdec_bits_get_u32 (&offset_bits);
- } else {
- swfdec_bits_init_bits (&offset_bits, bits, 2 * n_glyphs + 2);
- offset = swfdec_bits_get_u16 (&offset_bits);
- }
-
- g_array_set_size (font->glyphs, n_glyphs);
-
- for (i = 0; i < n_glyphs && swfdec_bits_left (&s->b); i++) {
- SwfdecFontEntry *entry = &g_array_index (font->glyphs, SwfdecFontEntry, i);
- guint next_offset;
-
- if (wide_offsets)
- next_offset = swfdec_bits_get_u32 (&offset_bits);
- else
- next_offset = swfdec_bits_get_u16 (&offset_bits);
- swfdec_font_parse_shape (s, entry, next_offset - offset);
- offset = next_offset;
- }
- if (i < n_glyphs) {
- SWFDEC_ERROR ("data was only enough for %u glyphs, not %u", i, n_glyphs);
- g_array_set_size (font->glyphs, i);
- n_glyphs = i;
- }
- if (wide_codes) {
- swfdec_bits_skip_bytes (bits, 2 * n_glyphs);
- } else {
- swfdec_bits_skip_bytes (bits, 1 * n_glyphs);
- }
- if (has_layout) {
- font_ascent = swfdec_bits_get_s16 (bits);
- font_descent = swfdec_bits_get_s16 (bits);
- font_leading = swfdec_bits_get_s16 (bits);
- //font_advance_table = swfdec_bits_get_s16(bits);
- swfdec_bits_skip_bytes (bits, 2 * n_glyphs);
- for (i = 0; i < n_glyphs && swfdec_bits_left (bits); i++) {
- swfdec_bits_get_rect (bits, &rect);
- }
- swfdec_font_parse_kerning_table (s, font, wide_codes);
- }
-
- return SWFDEC_STATUS_OK;
-}
-
-int
-tag_func_define_font_3 (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecBits offsets, *bits = &s->b;
- SwfdecFont *font;
- SwfdecLanguage language;
- guint i, id, len, n_glyphs, offset, next_offset;
- gboolean layout, shift_jis, ansi, wide_offsets, wide_codes;
-
- id = swfdec_bits_get_u16 (bits);
- font = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_FONT);
- if (!font)
- return SWFDEC_STATUS_OK;
- SWFDEC_LOG (" id = %u", id);
- font->scale_factor = 20 * SWFDEC_TEXT_SCALE_FACTOR;
-
- layout = swfdec_bits_getbit (bits);
- SWFDEC_LOG (" layout = %d", layout);
- shift_jis = swfdec_bits_getbit (bits);
- SWFDEC_LOG (" JIS = %d", shift_jis);
- font->small = swfdec_bits_getbit (bits);
- SWFDEC_LOG (" small = %d", font->small);
- ansi = swfdec_bits_getbit (bits);
- SWFDEC_LOG (" ansi = %d", ansi);
- wide_offsets = swfdec_bits_getbit (bits);
- SWFDEC_LOG (" wide offsets = %d", wide_offsets);
- wide_codes = swfdec_bits_getbit (bits);
- SWFDEC_LOG (" wide codes = %d", wide_codes);
- if (wide_codes == 0) {
- SWFDEC_ERROR (" wide codes should be set in DefineFont3");
- }
- font->italic = swfdec_bits_getbit (bits);
- SWFDEC_LOG (" italic = %d", font->italic);
- font->bold = swfdec_bits_getbit (bits);
- SWFDEC_LOG (" bold = %d", font->bold);
- language = swfdec_bits_get_u8 (&s->b);
- SWFDEC_LOG (" language = %u", (guint) language);
- len = swfdec_bits_get_u8 (&s->b);
- font->name = swfdec_bits_get_string_length (&s->b, len, s->version);
- if (font->name == NULL) {
- SWFDEC_ERROR ("error reading font name");
- } else {
- SWFDEC_LOG (" font name = %s", font->name);
- }
- n_glyphs = swfdec_bits_get_u16 (&s->b);
- SWFDEC_LOG (" n_glyphs = %u", n_glyphs);
-
- if (wide_offsets) {
- offset = swfdec_bits_get_u32 (bits);
- swfdec_bits_init_bits (&offsets, bits, n_glyphs * 4);
- } else {
- offset = swfdec_bits_get_u16 (bits);
- swfdec_bits_init_bits (&offsets, bits, n_glyphs * 2);
- }
- g_array_set_size (font->glyphs, n_glyphs);
- for (i = 0; i < n_glyphs && swfdec_bits_left (bits); i++) {
- SwfdecFontEntry *entry = &g_array_index (font->glyphs, SwfdecFontEntry, i);
- if (wide_offsets)
- next_offset = swfdec_bits_get_u32 (&offsets);
- else
- next_offset = swfdec_bits_get_u16 (&offsets);
- swfdec_font_parse_shape (s, entry, next_offset - offset);
- offset = next_offset;
- }
- if (i < n_glyphs) {
- SWFDEC_ERROR ("data was only enough for %u glyphs, not %u", i, n_glyphs);
- g_array_set_size (font->glyphs, i);
- n_glyphs = i;
- }
- for (i = 0; i < n_glyphs && swfdec_bits_left (bits); i++) {
- SwfdecFontEntry *entry = &g_array_index (font->glyphs, SwfdecFontEntry, i);
- if (wide_codes)
- entry->value = swfdec_bits_get_u16 (bits);
- else
- entry->value = swfdec_bits_get_u8 (bits);
- }
- if (layout) {
- guint ascent, descent, leading;
-
- ascent = swfdec_bits_get_u16 (bits);
- descent = swfdec_bits_get_u16 (bits);
- leading = swfdec_bits_get_u16 (bits);
- for (i = 0; i < n_glyphs && swfdec_bits_left (bits); i++) {
- /* guint advance = */ swfdec_bits_get_u16 (bits);
- }
- for (i = 0; i < n_glyphs && swfdec_bits_left (bits); i++) {
- SwfdecRect rect;
- swfdec_bits_get_rect (bits, &rect);
- }
- swfdec_font_parse_kerning_table (s, font, wide_codes);
- }
-
- return SWFDEC_STATUS_OK;
-}
diff --git a/libswfdec/swfdec_font.h b/libswfdec/swfdec_font.h
deleted file mode 100644
index b9ff5d7..0000000
--- a/libswfdec/swfdec_font.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_FONT_H_
-#define _SWFDEC_FONT_H_
-
-#include <pango/pangocairo.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_character.h>
-
-G_BEGIN_DECLS
-//typedef struct _SwfdecFont SwfdecFont;
-typedef struct _SwfdecFontEntry SwfdecFontEntry;
-typedef struct _SwfdecFontClass SwfdecFontClass;
-
-#define SWFDEC_TEXT_SCALE_FACTOR (1024)
-
-typedef enum {
- SWFDEC_LANGUAGE_NONE = 0,
- SWFDEC_LANGUAGE_LATIN = 1,
- SWFDEC_LANGUAGE_JAPANESE = 2,
- SWFDEC_LANGUAGE_KOREAN = 3,
- SWFDEC_LANGUAGE_CHINESE = 4,
- SWFDEC_LANGUAGE_CHINESE_TRADITIONAL = 5
-} SwfdecLanguage;
-
-#define SWFDEC_TYPE_FONT (swfdec_font_get_type())
-#define SWFDEC_IS_FONT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_FONT))
-#define SWFDEC_IS_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_FONT))
-#define SWFDEC_FONT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_FONT, SwfdecFont))
-#define SWFDEC_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_FONT, SwfdecFontClass))
-
-struct _SwfdecFontEntry {
- SwfdecDraw * draw; /* drawing operation to do or %NULL if none (ie space character) */
- gunichar value; /* UCS2 value of glyph */
-};
-
-struct _SwfdecFont
-{
- SwfdecCharacter character;
-
- char * name; /* name of the font (FIXME: what name?) */
- PangoFontDescription *desc;
- gboolean bold; /* font is bold */
- gboolean italic; /* font is italic */
- gboolean small; /* font is rendered at small sizes */
- GArray * glyphs; /* SwfdecFontEntry */
- guint scale_factor; /* size of a font in glyph entry */
-};
-
-struct _SwfdecFontClass
-{
- SwfdecCharacterClass character_class;
-};
-
-GType swfdec_font_get_type (void);
-
-SwfdecDraw * swfdec_font_get_glyph (SwfdecFont * font,
- guint glyph);
-
-int tag_func_define_font_info (SwfdecSwfDecoder * s,
- guint tag);
-int tag_func_define_font (SwfdecSwfDecoder * s,
- guint tag);
-int tag_func_define_font_2 (SwfdecSwfDecoder * s,
- guint tag);
-int tag_func_define_font_3 (SwfdecSwfDecoder * s,
- guint tag);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_function_list.c b/libswfdec/swfdec_function_list.c
deleted file mode 100644
index 0b29b59..0000000
--- a/libswfdec/swfdec_function_list.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/* Swfdec
- * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include "swfdec_function_list.h"
-
-typedef struct _SwfdecFunctionListEntry SwfdecFunctionListEntry;
-struct _SwfdecFunctionListEntry {
- GFunc func;
- gpointer data;
- GDestroyNotify destroy;
-};
-
-void
-swfdec_function_list_clear (SwfdecFunctionList *list)
-{
- GList *walk;
-
- g_return_if_fail (list != NULL);
-
- for (walk = list->list; walk; walk = walk->next) {
- SwfdecFunctionListEntry *entry = walk->data;
- if (entry->destroy)
- entry->destroy (entry->data);
- g_slice_free (SwfdecFunctionListEntry, entry);
- }
- g_list_free (list->list);
- list->list = NULL;
-}
-
-void
-swfdec_function_list_add (SwfdecFunctionList *list, GFunc func,
- gpointer data, GDestroyNotify destroy)
-{
- SwfdecFunctionListEntry *entry;
-
- g_return_if_fail (list != NULL);
- g_return_if_fail (func);
-
- entry = g_slice_new (SwfdecFunctionListEntry);
- entry->func = func;
- entry->data = data;
- entry->destroy = destroy;
-
- list->list = g_list_append (list->list, entry);
-}
-
-static int
-swfdec_function_list_entry_compare (gconstpointer a, gconstpointer b)
-{
- a = ((const SwfdecFunctionListEntry *) a)->data;
- b = ((const SwfdecFunctionListEntry *) b)->data;
-
- if (a < b)
- return -1;
- if (a > b)
- return 1;
- return 0;
-}
-
-void
-swfdec_function_list_remove (SwfdecFunctionList *list, gpointer data)
-{
- SwfdecFunctionListEntry entry = { NULL, data, NULL };
- SwfdecFunctionListEntry *e;
- GList *node;
-
- g_return_if_fail (list != NULL);
-
- node = g_list_find_custom (list->list, &entry,
- swfdec_function_list_entry_compare);
- e = node->data;
- if (e->destroy)
- e->destroy (data);
- g_slice_free (SwfdecFunctionListEntry, e);
- list->list = g_list_delete_link (list->list, node);
-}
-
-void
-swfdec_function_list_execute (SwfdecFunctionList *list, gpointer data)
-{
- SwfdecFunctionListEntry *entry;
- GList *walk;
-
- g_return_if_fail (list != NULL);
-
- for (walk = list->list; walk; walk = walk->next) {
- entry = walk->data;
- entry->func (entry->data, data);
- }
-}
-
-void
-swfdec_function_list_execute_and_clear (SwfdecFunctionList *list, gpointer data)
-{
- SwfdecFunctionListEntry *entry;
- GList *old, *walk;
-
- g_return_if_fail (list != NULL);
-
- old = list->list;
- list->list = NULL;
- for (walk = old; walk; walk = walk->next) {
- entry = walk->data;
- entry->func (entry->data, data);
- if (entry->destroy)
- entry->destroy (entry->data);
- g_slice_free (SwfdecFunctionListEntry, entry);
- }
- g_list_free (old);
-}
-
diff --git a/libswfdec/swfdec_function_list.h b/libswfdec/swfdec_function_list.h
deleted file mode 100644
index f7e8691..0000000
--- a/libswfdec/swfdec_function_list.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* Swfdec
- * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef __SWFDEC_FUNCTION_LIST_H__
-#define __SWFDEC_FUNCTION_LIST_H__
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-
-typedef struct _SwfdecFunctionList SwfdecFunctionList;
-struct _SwfdecFunctionList {
- GList * list;
-};
-
-void swfdec_function_list_clear (SwfdecFunctionList * list);
-
-void swfdec_function_list_add (SwfdecFunctionList * list,
- GFunc func,
- gpointer data,
- GDestroyNotify destroy);
-void swfdec_function_list_remove (SwfdecFunctionList * list,
- gpointer data);
-
-void swfdec_function_list_execute (SwfdecFunctionList * list,
- gpointer data);
-void swfdec_function_list_execute_and_clear
- (SwfdecFunctionList * list,
- gpointer data);
-
-G_END_DECLS
-
-#endif
diff --git a/libswfdec/swfdec_glow_filter.c b/libswfdec/swfdec_glow_filter.c
deleted file mode 100644
index 2bc0784..0000000
--- a/libswfdec/swfdec_glow_filter.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (1103, 1, swfdec_glow_filter_get_distance)
-void
-swfdec_glow_filter_get_distance (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GlowFilter.distance (get)");
-}
-
-SWFDEC_AS_NATIVE (1103, 2, swfdec_glow_filter_set_distance)
-void
-swfdec_glow_filter_set_distance (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GlowFilter.distance (set)");
-}
-
-SWFDEC_AS_NATIVE (1103, 3, swfdec_glow_filter_get_alpha)
-void
-swfdec_glow_filter_get_alpha (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GlowFilter.alpha (get)");
-}
-
-SWFDEC_AS_NATIVE (1103, 4, swfdec_glow_filter_set_alpha)
-void
-swfdec_glow_filter_set_alpha (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GlowFilter.alpha (set)");
-}
-
-SWFDEC_AS_NATIVE (1103, 5, swfdec_glow_filter_get_quality)
-void
-swfdec_glow_filter_get_quality (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GlowFilter.quality (get)");
-}
-
-SWFDEC_AS_NATIVE (1103, 6, swfdec_glow_filter_set_quality)
-void
-swfdec_glow_filter_set_quality (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GlowFilter.quality (set)");
-}
-
-SWFDEC_AS_NATIVE (1103, 7, swfdec_glow_filter_get_inner)
-void
-swfdec_glow_filter_get_inner (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GlowFilter.inner (get)");
-}
-
-SWFDEC_AS_NATIVE (1103, 8, swfdec_glow_filter_set_inner)
-void
-swfdec_glow_filter_set_inner (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GlowFilter.inner (set)");
-}
-
-SWFDEC_AS_NATIVE (1103, 9, swfdec_glow_filter_get_knockout)
-void
-swfdec_glow_filter_get_knockout (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GlowFilter.knockout (get)");
-}
-
-SWFDEC_AS_NATIVE (1103, 10, swfdec_glow_filter_set_knockout)
-void
-swfdec_glow_filter_set_knockout (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GlowFilter.knockout (set)");
-}
-
-SWFDEC_AS_NATIVE (1103, 11, swfdec_glow_filter_get_blurX)
-void
-swfdec_glow_filter_get_blurX (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GlowFilter.blurX (get)");
-}
-
-SWFDEC_AS_NATIVE (1103, 12, swfdec_glow_filter_set_blurX)
-void
-swfdec_glow_filter_set_blurX (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GlowFilter.blurX (set)");
-}
-
-SWFDEC_AS_NATIVE (1103, 13, swfdec_glow_filter_get_blurY)
-void
-swfdec_glow_filter_get_blurY (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GlowFilter.blurY (get)");
-}
-
-SWFDEC_AS_NATIVE (1103, 14, swfdec_glow_filter_set_blurY)
-void
-swfdec_glow_filter_set_blurY (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GlowFilter.blurY (set)");
-}
-
-SWFDEC_AS_NATIVE (1103, 15, swfdec_glow_filter_get_strength)
-void
-swfdec_glow_filter_get_strength (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GlowFilter.strength (get)");
-}
-
-SWFDEC_AS_NATIVE (1103, 16, swfdec_glow_filter_set_strength)
-void
-swfdec_glow_filter_set_strength (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GlowFilter.strength (set)");
-}
-
-// constructor
-SWFDEC_AS_NATIVE (1103, 0, swfdec_glow_filter_construct)
-void
-swfdec_glow_filter_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GlowFilter");
-}
diff --git a/libswfdec/swfdec_gradient_filter.c b/libswfdec/swfdec_gradient_filter.c
deleted file mode 100644
index d32b113..0000000
--- a/libswfdec/swfdec_gradient_filter.c
+++ /dev/null
@@ -1,243 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (1108, 1, swfdec_gradient_filter_get_distance)
-void
-swfdec_gradient_filter_get_distance (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter/GradientGlowFilter.distance (get)");
-}
-
-SWFDEC_AS_NATIVE (1108, 2, swfdec_gradient_filter_set_distance)
-void
-swfdec_gradient_filter_set_distance (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter/GradientGlowFilter.distance (set)");
-}
-
-SWFDEC_AS_NATIVE (1108, 3, swfdec_gradient_filter_get_angle)
-void
-swfdec_gradient_filter_get_angle (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.angle (get)");
-}
-
-SWFDEC_AS_NATIVE (1108, 4, swfdec_gradient_filter_set_angle)
-void
-swfdec_gradient_filter_set_angle (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.angle (set)");
-}
-
-SWFDEC_AS_NATIVE (1108, 5, swfdec_gradient_filter_get_colors)
-void
-swfdec_gradient_filter_get_colors (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.colors (get)");
-}
-
-SWFDEC_AS_NATIVE (1108, 6, swfdec_gradient_filter_set_colors)
-void
-swfdec_gradient_filter_set_colors (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.colors (set)");
-}
-
-SWFDEC_AS_NATIVE (1108, 7, swfdec_gradient_filter_get_alphas)
-void
-swfdec_gradient_filter_get_alphas (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.alphas (get)");
-}
-
-SWFDEC_AS_NATIVE (1108, 8, swfdec_gradient_filter_set_alphas)
-void
-swfdec_gradient_filter_set_alphas (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.alphas (set)");
-}
-
-SWFDEC_AS_NATIVE (1108, 9, swfdec_gradient_filter_get_ratios)
-void
-swfdec_gradient_filter_get_ratios (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.ratios (get)");
-}
-
-SWFDEC_AS_NATIVE (1108, 10, swfdec_gradient_filter_set_ratios)
-void
-swfdec_gradient_filter_set_ratios (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.ratios (set)");
-}
-
-SWFDEC_AS_NATIVE (1108, 11, swfdec_gradient_filter_get_blurX)
-void
-swfdec_gradient_filter_get_blurX (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.blurX (get)");
-}
-
-SWFDEC_AS_NATIVE (1108, 12, swfdec_gradient_filter_set_blurX)
-void
-swfdec_gradient_filter_set_blurX (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.blurX (set)");
-}
-
-SWFDEC_AS_NATIVE (1108, 13, swfdec_gradient_filter_get_blurY)
-void
-swfdec_gradient_filter_get_blurY (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.blurY (get)");
-}
-
-SWFDEC_AS_NATIVE (1108, 14, swfdec_gradient_filter_set_blurY)
-void
-swfdec_gradient_filter_set_blurY (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.blurY (set)");
-}
-
-SWFDEC_AS_NATIVE (1108, 15, swfdec_gradient_filter_get_quality)
-void
-swfdec_gradient_filter_get_quality (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.quality (get)");
-}
-
-SWFDEC_AS_NATIVE (1108, 16, swfdec_gradient_filter_set_quality)
-void
-swfdec_gradient_filter_set_quality (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.quality (set)");
-}
-
-SWFDEC_AS_NATIVE (1108, 17, swfdec_gradient_filter_get_strength)
-void
-swfdec_gradient_filter_get_strength (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.strength (get)");
-}
-
-SWFDEC_AS_NATIVE (1108, 18, swfdec_gradient_filter_set_strength)
-void
-swfdec_gradient_filter_set_strength (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.strength (set)");
-}
-
-SWFDEC_AS_NATIVE (1108, 19, swfdec_gradient_filter_get_knockout)
-void
-swfdec_gradient_filter_get_knockout (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.knockout (get)");
-}
-
-SWFDEC_AS_NATIVE (1108, 20, swfdec_gradient_filter_set_knockout)
-void
-swfdec_gradient_filter_set_knockout (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.knockout (set)");
-}
-
-SWFDEC_AS_NATIVE (1108, 21, swfdec_gradient_filter_get_type)
-void
-swfdec_gradient_filter_get_type (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.type (get)");
-}
-
-SWFDEC_AS_NATIVE (1108, 22, swfdec_gradient_filter_set_type)
-void
-swfdec_gradient_filter_set_type (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.type (set)");
-}
-
-// constructors
-
-SWFDEC_AS_NATIVE (1108, 0, swfdec_gradient_glow_filter_construct)
-void
-swfdec_gradient_glow_filter_construct (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientGlowFilter");
-}
-
-SWFDEC_AS_NATIVE (1108, 1000, swfdec_gradient_bevel_filter_construct)
-void
-swfdec_gradient_bevel_filter_construct (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("GradientBevelFilter");
-}
diff --git a/libswfdec/swfdec_gradient_pattern.c b/libswfdec/swfdec_gradient_pattern.c
deleted file mode 100644
index 2f63634..0000000
--- a/libswfdec/swfdec_gradient_pattern.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-
-#include "swfdec_gradient_pattern.h"
-#include "swfdec_color.h"
-#include "swfdec_debug.h"
-#include "swfdec_path.h"
-
-G_DEFINE_TYPE (SwfdecGradientPattern, swfdec_gradient_pattern, SWFDEC_TYPE_PATTERN);
-
-static void
-swfdec_gradient_pattern_morph (SwfdecDraw *dest, SwfdecDraw *source, guint ratio)
-{
- guint i;
-
- SwfdecGradientPattern *dpattern = SWFDEC_GRADIENT_PATTERN (dest);
- SwfdecGradientPattern *spattern = SWFDEC_GRADIENT_PATTERN (source);
-
- g_return_if_fail (spattern->end_gradient != NULL);
- dpattern->radial = spattern->radial;
- dpattern->focus = spattern->focus;
- dpattern->extend = spattern->extend;
- dpattern->n_gradients = spattern->n_gradients;
- for (i = 0; i < spattern->n_gradients; i++) {
- dpattern->gradient[i].color = swfdec_color_apply_morph (spattern->gradient[i].color,
- spattern->end_gradient[i].color, ratio);
- dpattern->gradient[i].ratio = (spattern->gradient[i].ratio * (65535 - ratio) +
- spattern->end_gradient[i].ratio * ratio) / 65535;
- }
-
- SWFDEC_DRAW_CLASS (swfdec_gradient_pattern_parent_class)->morph (dest, source, ratio);
-}
-
-static cairo_pattern_t *
-swfdec_gradient_pattern_get_pattern (SwfdecPattern *pat, const SwfdecColorTransform *trans)
-{
- guint i, ratio;
- cairo_pattern_t *pattern;
- SwfdecColor color;
- double offset;
- SwfdecGradientPattern *gradient = SWFDEC_GRADIENT_PATTERN (pat);
-
- if (gradient->n_gradients == 0) {
- /* cairo interprets an empty gradient as translucent, not as solid black */
- return cairo_pattern_create_rgb (0, 0, 0);
- }
-#if 0
- /* use this when https://bugs.freedesktop.org/show_bug.cgi?id=8341 is fixed */
- if (gradient->radial)
- pattern = cairo_pattern_create_radial (0, 0, 0, 0, 0, 16384);
- else
- pattern = cairo_pattern_create_linear (-16384.0, 0, 16384.0, 0);
- cairo_pattern_set_matrix (pattern, &pat->transform);
-#else
- {
- cairo_matrix_t mat = pat->transform;
- if (gradient->radial) {
- pattern = cairo_pattern_create_radial ((16384.0 / 256.0) * gradient->focus,
- 0, 0, 0, 0, 16384 / 256.0);
- } else {
- pattern = cairo_pattern_create_linear (-16384.0 / 256.0, 0, 16384.0 / 256.0, 0);
- }
- cairo_matrix_scale (&mat, 1 / 256.0, 1 / 256.0);
- mat.x0 /= 256.0;
- mat.y0 /= 256.0;
- cairo_pattern_set_matrix (pattern, &mat);
- }
-#endif
- cairo_pattern_set_extend (pattern, gradient->extend);
- /* we check here that ratios increase linearly, because both gradients parsed
- * from the SWF and gradients created with beginGradientFill have this
- * behavior */
- ratio = 0;
- for (i = 0; i < gradient->n_gradients; i++){
- color = swfdec_color_apply_transform (gradient->gradient[i].color,
- trans);
- ratio = MAX (ratio, gradient->gradient[i].ratio);
- offset = ratio / 255.0;
- cairo_pattern_add_color_stop_rgba (pattern, offset,
- SWFDEC_COLOR_R(color) / 255.0, SWFDEC_COLOR_G(color) / 255.0,
- SWFDEC_COLOR_B(color) / 255.0, SWFDEC_COLOR_A(color) / 255.0);
- if (++ratio > 255)
- break;
- }
- return pattern;
-}
-
-static void
-swfdec_gradient_pattern_class_init (SwfdecGradientPatternClass *klass)
-{
- SWFDEC_DRAW_CLASS (klass)->morph = swfdec_gradient_pattern_morph;
-
- SWFDEC_PATTERN_CLASS (klass)->get_pattern = swfdec_gradient_pattern_get_pattern;
-}
-
-static void
-swfdec_gradient_pattern_init (SwfdecGradientPattern *gradient)
-{
- gradient->extend = CAIRO_EXTEND_PAD;
-}
-
-SwfdecDraw *
-swfdec_gradient_pattern_new (void)
-{
- return g_object_new (SWFDEC_TYPE_GRADIENT_PATTERN, NULL);
-}
-
diff --git a/libswfdec/swfdec_gradient_pattern.h b/libswfdec/swfdec_gradient_pattern.h
deleted file mode 100644
index 6b85608..0000000
--- a/libswfdec/swfdec_gradient_pattern.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_GRADIENT_PATTERN_H_
-#define _SWFDEC_GRADIENT_PATTERN_H_
-
-#include <libswfdec/swfdec_pattern.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecGradientPattern SwfdecGradientPattern;
-typedef struct _SwfdecGradientPatternClass SwfdecGradientPatternClass;
-
-typedef struct _SwfdecGradientEntry SwfdecGradientEntry;
-
-#define SWFDEC_TYPE_GRADIENT_PATTERN (swfdec_gradient_pattern_get_type())
-#define SWFDEC_IS_GRADIENT_PATTERN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_GRADIENT_PATTERN))
-#define SWFDEC_IS_GRADIENT_PATTERN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_GRADIENT_PATTERN))
-#define SWFDEC_GRADIENT_PATTERN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_GRADIENT_PATTERN, SwfdecGradientPattern))
-#define SWFDEC_GRADIENT_PATTERN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_GRADIENT_PATTERN, SwfdecGradientPatternClass))
-#define SWFDEC_GRADIENT_PATTERN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_GRADIENT_PATTERN, SwfdecGradientPatternClass))
-
-struct _SwfdecGradientEntry {
- guint ratio;
- SwfdecColor color;
-};
-
-struct _SwfdecGradientPattern
-{
- SwfdecPattern pattern;
-
- SwfdecGradientEntry gradient[16]; /* gradient to paint */
- SwfdecGradientEntry end_gradient[16]; /* end gradient for morphs */
- guint n_gradients; /* number of gradients */
- cairo_extend_t extend; /* extend of gradient */
- gboolean radial; /* TRUE for radial gradient, FALSE for linear gradient */
- double focus; /* focus point */
-};
-
-struct _SwfdecGradientPatternClass
-{
- SwfdecPatternClass pattern_class;
-};
-
-GType swfdec_gradient_pattern_get_type (void);
-
-SwfdecDraw * swfdec_gradient_pattern_new (void);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_graphic.c b/libswfdec/swfdec_graphic.c
deleted file mode 100644
index c316084..0000000
--- a/libswfdec/swfdec_graphic.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_graphic.h"
-#include "swfdec_graphic_movie.h"
-
-
-G_DEFINE_ABSTRACT_TYPE (SwfdecGraphic, swfdec_graphic, SWFDEC_TYPE_CHARACTER)
-
-static SwfdecMovie *
-swfdec_graphic_create_movie (SwfdecGraphic *graphic, gsize *size)
-{
- SwfdecGraphicMovie *movie = g_object_new (SWFDEC_TYPE_GRAPHIC_MOVIE, NULL);
-
- *size = sizeof (SwfdecGraphicMovie);
- return SWFDEC_MOVIE (movie);
-}
-
-static void
-swfdec_graphic_class_init (SwfdecGraphicClass *klass)
-{
- klass->create_movie = swfdec_graphic_create_movie;
-}
-
-static void
-swfdec_graphic_init (SwfdecGraphic *graphic)
-{
-}
-
-void
-swfdec_graphic_render (SwfdecGraphic *graphic, cairo_t *cr,
- const SwfdecColorTransform *trans, const SwfdecRect *inval)
-{
- SwfdecGraphicClass *klass = SWFDEC_GRAPHIC_GET_CLASS (graphic);
-
- if (klass->render)
- klass->render (graphic, cr, trans, inval);
-}
-
-gboolean
-swfdec_graphic_mouse_in (SwfdecGraphic *graphic, double x, double y)
-{
- SwfdecGraphicClass *klass = SWFDEC_GRAPHIC_GET_CLASS (graphic);
-
- if (klass->mouse_in)
- return klass->mouse_in (graphic, x, y);
- else
- return FALSE;
-}
diff --git a/libswfdec/swfdec_graphic.h b/libswfdec/swfdec_graphic.h
deleted file mode 100644
index 0b48d19..0000000
--- a/libswfdec/swfdec_graphic.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_GRAPHIC_H_
-#define _SWFDEC_GRAPHIC_H_
-
-#include <glib-object.h>
-#include <libswfdec/swfdec_character.h>
-#include <libswfdec/swfdec_rect.h>
-#include <libswfdec/swfdec_types.h>
-
-G_BEGIN_DECLS
-
-
-typedef struct _SwfdecGraphicClass SwfdecGraphicClass;
-
-#define SWFDEC_TYPE_GRAPHIC (swfdec_graphic_get_type())
-#define SWFDEC_IS_GRAPHIC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_GRAPHIC))
-#define SWFDEC_IS_GRAPHIC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_GRAPHIC))
-#define SWFDEC_GRAPHIC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_GRAPHIC, SwfdecGraphic))
-#define SWFDEC_GRAPHIC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_GRAPHIC, SwfdecGraphicClass))
-#define SWFDEC_GRAPHIC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_GRAPHIC, SwfdecGraphicClass))
-
-struct _SwfdecGraphic
-{
- SwfdecCharacter character;
-
- SwfdecRect extents; /* bounding box that encloses this graphic */
-};
-
-struct _SwfdecGraphicClass
-{
- SwfdecCharacterClass character_class;
-
- /* when creating a movie for this graphic, calls this function */
- SwfdecMovie * (*create_movie) (SwfdecGraphic * graphic,
- gsize * size);
- /* optional vfuncs */
- void (* render) (SwfdecGraphic * graphic,
- cairo_t * cr,
- const SwfdecColorTransform * trans,
- const SwfdecRect * inval);
- gboolean (* mouse_in) (SwfdecGraphic * graphic,
- double x,
- double y);
-};
-
-GType swfdec_graphic_get_type (void);
-
-void swfdec_graphic_render (SwfdecGraphic * graphic,
- cairo_t * cr,
- const SwfdecColorTransform * trans,
- const SwfdecRect * inval);
-gboolean swfdec_graphic_mouse_in (SwfdecGraphic * graphic,
- double x,
- double y);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_graphic_movie.c b/libswfdec/swfdec_graphic_movie.c
deleted file mode 100644
index 24e8a77..0000000
--- a/libswfdec/swfdec_graphic_movie.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_graphic_movie.h"
-#include "swfdec_button.h"
-#include "swfdec_debug.h"
-#include "swfdec_movie.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_shape.h"
-#include "swfdec_sprite.h"
-#include "swfdec_swf_decoder.h"
-#include "swfdec_resource.h"
-#include "swfdec_text.h"
-#include "swfdec_text_field.h"
-
-G_DEFINE_TYPE (SwfdecGraphicMovie, swfdec_graphic_movie, SWFDEC_TYPE_MOVIE)
-
-static void
-swfdec_graphic_movie_update_extents (SwfdecMovie *movie,
- SwfdecRect *extents)
-{
- swfdec_rect_union (extents, extents,
- &movie->graphic->extents);
-}
-
-static void
-swfdec_graphic_movie_render (SwfdecMovie *movie, cairo_t *cr,
- const SwfdecColorTransform *trans, const SwfdecRect *inval)
-{
- swfdec_graphic_render (movie->graphic, cr, trans, inval);
-}
-
-static void
-swfdec_graphic_movie_invalidate (SwfdecMovie *movie, const cairo_matrix_t *matrix, gboolean last)
-{
- SwfdecRect rect;
-
- swfdec_rect_transform (&rect, &movie->graphic->extents, matrix);
- swfdec_player_invalidate (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), &rect);
-}
-
-static SwfdecMovie *
-swfdec_graphic_movie_contains (SwfdecMovie *movie, double x, double y,
- gboolean events)
-{
- if (swfdec_graphic_mouse_in (movie->graphic, x, y))
- return movie;
- else
- return NULL;
-}
-
-static void
-swfdec_graphic_movie_replace (SwfdecMovie *movie, SwfdecGraphic *graphic)
-{
- if (SWFDEC_IS_SHAPE (graphic) ||
- SWFDEC_IS_TEXT (graphic)) {
- /* nothing to do here, please move along */
- } else if (SWFDEC_IS_SPRITE (graphic) ||
- SWFDEC_IS_BUTTON (graphic) ||
- SWFDEC_IS_TEXT_FIELD (graphic)) {
- SWFDEC_INFO ("can't replace with scriptable objects");
- return;
- } else {
- SWFDEC_FIXME ("Can we replace with %s objects?", G_OBJECT_TYPE_NAME (graphic));
- return;
- }
- if (movie->graphic == graphic)
- return;
- swfdec_movie_invalidate_next (movie);
- SWFDEC_LOG ("replacing %u with %u", SWFDEC_CHARACTER (movie->graphic)->id,
- SWFDEC_CHARACTER (graphic)->id);
- swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_EXTENTS);
- g_object_unref (movie->graphic);
- movie->graphic = g_object_ref (graphic);
-}
-
-static void
-swfdec_graphic_movie_class_init (SwfdecGraphicMovieClass * g_class)
-{
- SwfdecMovieClass *movie_class = SWFDEC_MOVIE_CLASS (g_class);
-
- movie_class->update_extents = swfdec_graphic_movie_update_extents;
- movie_class->replace = swfdec_graphic_movie_replace;
- movie_class->render = swfdec_graphic_movie_render;
- movie_class->invalidate = swfdec_graphic_movie_invalidate;
- movie_class->contains = swfdec_graphic_movie_contains;
-}
-
-static void
-swfdec_graphic_movie_init (SwfdecGraphicMovie * graphic_movie)
-{
-}
-
diff --git a/libswfdec/swfdec_graphic_movie.h b/libswfdec/swfdec_graphic_movie.h
deleted file mode 100644
index 4d6e454..0000000
--- a/libswfdec/swfdec_graphic_movie.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_GRAPHIC_MOVIE_H_
-#define _SWFDEC_GRAPHIC_MOVIE_H_
-
-#include <glib-object.h>
-#include <libswfdec/swfdec_movie.h>
-#include <libswfdec/swfdec_graphic.h>
-
-G_BEGIN_DECLS
-
-
-typedef struct _SwfdecGraphicMovie SwfdecGraphicMovie;
-typedef struct _SwfdecGraphicMovieClass SwfdecGraphicMovieClass;
-
-#define SWFDEC_TYPE_GRAPHIC_MOVIE (swfdec_graphic_movie_get_type())
-#define SWFDEC_IS_GRAPHIC_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_GRAPHIC_MOVIE))
-#define SWFDEC_IS_GRAPHIC_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_GRAPHIC_MOVIE))
-#define SWFDEC_GRAPHIC_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_GRAPHIC_MOVIE, SwfdecGraphicMovie))
-#define SWFDEC_GRAPHIC_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_GRAPHIC_MOVIE, SwfdecGraphicMovieClass))
-
-struct _SwfdecGraphicMovie {
- SwfdecMovie movie;
-};
-
-struct _SwfdecGraphicMovieClass {
- SwfdecMovieClass movie_class;
-};
-
-GType swfdec_graphic_movie_get_type (void);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_image.c b/libswfdec/swfdec_image.c
deleted file mode 100644
index 54e84ca..0000000
--- a/libswfdec/swfdec_image.c
+++ /dev/null
@@ -1,710 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <zlib.h>
-#include <string.h>
-
-#include "jpeg.h"
-#include "swfdec_image.h"
-#include "swfdec_cache.h"
-#include "swfdec_debug.h"
-#include "swfdec_swf_decoder.h"
-
-static const cairo_user_data_key_t key;
-
-static void merge_alpha (SwfdecImage * image, unsigned char *image_data,
- unsigned char *alpha);
-static void swfdec_image_colormap_decode (SwfdecImage * image,
- unsigned char *dest,
- unsigned char *src, unsigned char *colormap, int colormap_len);
-
-G_DEFINE_TYPE (SwfdecImage, swfdec_image, SWFDEC_TYPE_CACHED)
-
-static void
-swfdec_image_unload (SwfdecCached *cached)
-{
- SwfdecImage *image = SWFDEC_IMAGE (cached);
-
- if (image->surface) {
- cairo_surface_destroy (image->surface);
- image->surface = NULL;
- }
-}
-
-static void
-swfdec_image_dispose (GObject *object)
-{
- SwfdecImage * image = SWFDEC_IMAGE (object);
-
- if (image->jpegtables) {
- swfdec_buffer_unref (image->jpegtables);
- image->jpegtables = NULL;
- }
- if (image->raw_data) {
- swfdec_buffer_unref (image->raw_data);
- image->raw_data = NULL;
- }
-
- G_OBJECT_CLASS (swfdec_image_parent_class)->dispose (object);
-
- g_assert (image->surface == NULL);
-}
-
-static void
-swfdec_image_class_init (SwfdecImageClass * g_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (g_class);
- SwfdecCachedClass *cached_class = SWFDEC_CACHED_CLASS (g_class);
-
- object_class->dispose = swfdec_image_dispose;
-
- cached_class->unload = swfdec_image_unload;
-}
-
-static void
-swfdec_image_init (SwfdecImage * image)
-{
-}
-
-int
-swfdec_image_jpegtables (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecBits *bits = &s->b;
-
- SWFDEC_DEBUG ("swfdec_image_jpegtables");
-
- if (s->jpegtables) {
- SWFDEC_FIXME ("duplicate DefineJPEGTables tag. Deleting first one");
- swfdec_buffer_unref (s->jpegtables);
- }
- s->jpegtables = swfdec_bits_get_buffer (bits, -1);
-
- return SWFDEC_STATUS_OK;
-}
-
-int
-tag_func_define_bits_jpeg (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecBits *bits = &s->b;
- int id;
- SwfdecImage *image;
-
- SWFDEC_LOG ("tag_func_define_bits_jpeg");
- id = swfdec_bits_get_u16 (bits);
- SWFDEC_LOG (" id = %d", id);
-
- image = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_IMAGE);
- if (!image)
- return SWFDEC_STATUS_OK;
-
- image->type = SWFDEC_IMAGE_TYPE_JPEG;
- if (!s->jpegtables) {
- SWFDEC_ERROR("No global JPEG tables available");
- } else {
- image->jpegtables = swfdec_buffer_ref (s->jpegtables);
- }
- image->raw_data = swfdec_bits_get_buffer (bits, -1);
-
- return SWFDEC_STATUS_OK;
-}
-
-/**
- * swfdec_jpeg_decode_argb:
- *
- * This is a wrapper around jpeg_decode_argb() that takes two segments,
- * strips off (sometimes bogus) start-of-image and end-of-image codes,
- * concatenates them, and puts new SOI and EOI codes on the resulting
- * buffer. This makes a real JPEG image out of the crap in SWF files.
- */
-static gboolean
-swfdec_jpeg_decode_argb (unsigned char *data1, int length1,
- unsigned char *data2, int length2,
- void *outdata, int *width, int *height)
-{
- gboolean ret;
-
- if (data2) {
- unsigned char *tmpdata;
- int tmplength;
-
- tmplength = length1 + length2;
- tmpdata = g_malloc (tmplength);
-
- memcpy (tmpdata, data1, length1);
- memcpy (tmpdata + length1, data2, length2);
- ret = jpeg_decode_argb (tmpdata, tmplength, outdata, width, height);
-
- g_free (tmpdata);
- } else {
- ret = jpeg_decode_argb (data1, length1, outdata, width, height);
- }
-
- return ret;
-}
-
-static void
-swfdec_image_jpeg_load (SwfdecImage *image)
-{
- gboolean ret;
- guint8 *data;
-
- if (image->jpegtables) {
- ret = swfdec_jpeg_decode_argb (
- image->jpegtables->data, image->jpegtables->length,
- image->raw_data->data, image->raw_data->length,
- (void *) &data, &image->width, &image->height);
- } else {
- ret = swfdec_jpeg_decode_argb (
- image->raw_data->data, image->raw_data->length,
- NULL, 0,
- (void *)&data, &image->width, &image->height);
- }
-
- if (!ret)
- return;
-
- swfdec_cached_load (SWFDEC_CACHED (image), 4 * image->width * image->height);
- image->surface = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_RGB24,
- image->width, image->height, image->width * 4);
- cairo_surface_set_user_data (image->surface, &key, data, g_free);
-
- SWFDEC_LOG (" width = %d", image->width);
- SWFDEC_LOG (" height = %d", image->height);
-}
-
-int
-tag_func_define_bits_jpeg_2 (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecBits *bits = &s->b;
- int id;
- SwfdecImage *image;
-
- id = swfdec_bits_get_u16 (bits);
- SWFDEC_LOG (" id = %d", id);
-
- image = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_IMAGE);
- if (!image)
- return SWFDEC_STATUS_OK;
-
- image->type = SWFDEC_IMAGE_TYPE_JPEG2;
- image->raw_data = swfdec_bits_get_buffer (bits, -1);
-
- return SWFDEC_STATUS_OK;
-}
-
-static void
-swfdec_image_jpeg2_load (SwfdecImage *image)
-{
- gboolean ret;
- guint8 *data;
-
- ret = swfdec_jpeg_decode_argb (image->raw_data->data, image->raw_data->length,
- NULL, 0,
- (void *)&data, &image->width, &image->height);
- if (!ret)
- return;
-
- swfdec_cached_load (SWFDEC_CACHED (image), 4 * image->width * image->height);
- image->surface = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_RGB24,
- image->width, image->height, image->width * 4);
- cairo_surface_set_user_data (image->surface, &key, data, g_free);
-
- SWFDEC_LOG (" width = %d", image->width);
- SWFDEC_LOG (" height = %d", image->height);
-}
-
-int
-tag_func_define_bits_jpeg_3 (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecBits *bits = &s->b;
- guint id;
- SwfdecImage *image;
-
- id = swfdec_bits_get_u16 (bits);
- SWFDEC_LOG (" id = %d", id);
-
- image = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_IMAGE);
- if (!image)
- return SWFDEC_STATUS_OK;
-
- image->type = SWFDEC_IMAGE_TYPE_JPEG3;
- image->raw_data = swfdec_bits_get_buffer (bits, -1);
-
- return SWFDEC_STATUS_OK;
-}
-
-static void
-swfdec_image_jpeg3_load (SwfdecImage *image)
-{
- SwfdecBits bits;
- SwfdecBuffer *buffer;
- int jpeg_length;
- gboolean ret;
- guint8 *data;
-
- swfdec_bits_init (&bits, image->raw_data);
-
- jpeg_length = swfdec_bits_get_u32 (&bits);
- buffer = swfdec_bits_get_buffer (&bits, jpeg_length);
- if (buffer == NULL)
- return;
-
- ret = swfdec_jpeg_decode_argb (buffer->data, buffer->length,
- NULL, 0,
- (void *)&data, &image->width, &image->height);
- swfdec_buffer_unref (buffer);
-
- if (!ret)
- return;
-
- swfdec_cached_load (SWFDEC_CACHED (image), 4 * image->width * image->height);
-
- buffer = swfdec_bits_decompress (&bits, -1, image->width * image->height);
- if (buffer) {
- merge_alpha (image, data, buffer->data);
- swfdec_buffer_unref (buffer);
- } else {
- SWFDEC_WARNING ("cannot set alpha channel information, decompression failed");
- }
-
- SWFDEC_LOG (" width = %d", image->width);
- SWFDEC_LOG (" height = %d", image->height);
-
- image->surface = cairo_image_surface_create_for_data (data,
- CAIRO_FORMAT_ARGB32, image->width, image->height, image->width * 4);
- cairo_surface_set_user_data (image->surface, &key, data, g_free);
-}
-
-static void
-merge_alpha (SwfdecImage * image, unsigned char *image_data,
- unsigned char *alpha)
-{
- int x, y;
- unsigned char *p;
-
- for (y = 0; y < image->height; y++) {
- p = image_data + y * image->width * 4;
- for (x = 0; x < image->width; x++) {
- p[SWFDEC_COLOR_INDEX_ALPHA] = *alpha;
- p += 4;
- alpha++;
- }
- }
-}
-
-static void
-swfdec_image_lossless_load (SwfdecImage *image)
-{
- int format;
- guint color_table_size;
- unsigned char *ptr;
- SwfdecBits bits;
- guint8 *data;
- int have_alpha = (image->type == SWFDEC_IMAGE_TYPE_LOSSLESS2);
-
- swfdec_bits_init (&bits, image->raw_data);
-
- format = swfdec_bits_get_u8 (&bits);
- SWFDEC_LOG (" format = %d", format);
- image->width = swfdec_bits_get_u16 (&bits);
- SWFDEC_LOG (" width = %d", image->width);
- image->height = swfdec_bits_get_u16 (&bits);
- SWFDEC_LOG (" height = %d", image->height);
- if (format == 3) {
- color_table_size = swfdec_bits_get_u8 (&bits) + 1;
- } else {
- color_table_size = 0;
- }
-
- SWFDEC_LOG ("format = %d", format);
- SWFDEC_LOG ("width = %d", image->width);
- SWFDEC_LOG ("height = %d", image->height);
- SWFDEC_LOG ("color_table_size = %d", color_table_size);
-
- if (image->width == 0 || image->height == 0)
- return;
- swfdec_cached_load (SWFDEC_CACHED (image), 4 * image->width * image->height);
-
- if (format == 3) {
- SwfdecBuffer *buffer;
- unsigned char *indexed_data;
- guint i;
- guint rowstride = (image->width + 3) & ~3;
-
- data = g_malloc (4 * image->width * image->height);
-
- if (have_alpha) {
- buffer = swfdec_bits_decompress (&bits, -1, color_table_size * 4 + rowstride * image->height);
- if (buffer == NULL) {
- SWFDEC_ERROR ("failed to decompress data");
- memset (data, 0, 4 * image->width * image->height);
- goto out;
- }
- ptr = buffer->data;
- for (i = 0; i < color_table_size; i++) {
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
- guint8 tmp = ptr[i * 4 + 0];
- ptr[i * 4 + 0] = ptr[i * 4 + 2];
- ptr[i * 4 + 2] = tmp;
-#else
- guint8 tmp = ptr[i * 4 + 3];
- ptr[i * 4 + 3] = ptr[i * 4 + 2];
- ptr[i * 4 + 2] = ptr[i * 4 + 1];
- ptr[i * 4 + 1] = ptr[i * 4 + 0];
- ptr[i * 4 + 0] = tmp;
-#endif
- }
- indexed_data = ptr + color_table_size * 4;
- } else {
- buffer = swfdec_bits_decompress (&bits, -1, color_table_size * 3 + rowstride * image->height);
- if (buffer == NULL) {
- SWFDEC_ERROR ("failed to decompress data");
- memset (data, 0, 4 * image->width * image->height);
- goto out;
- }
- ptr = buffer->data;
- for (i = color_table_size - 1; i < color_table_size; i--) {
- guint8 color[3];
- color[0] = ptr[i * 3 + 0];
- color[1] = ptr[i * 3 + 1];
- color[2] = ptr[i * 3 + 2];
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
- ptr[i * 4 + 0] = color[2];
- ptr[i * 4 + 1] = color[1];
- ptr[i * 4 + 2] = color[0];
- ptr[i * 4 + 3] = 255;
-#else
- ptr[i * 4 + 0] = 255;
- ptr[i * 4 + 1] = color[0];
- ptr[i * 4 + 2] = color[1];
- ptr[i * 4 + 3] = color[2];
-#endif
- }
- indexed_data = ptr + color_table_size * 3;
- }
- swfdec_image_colormap_decode (image, data, indexed_data,
- ptr, color_table_size);
-
- swfdec_buffer_unref (buffer);
- } else if (format == 4) {
- int i, j;
- guint c;
- unsigned char *idata;
- SwfdecBuffer *buffer;
-
- if (have_alpha) {
- SWFDEC_INFO("16bit images aren't allowed to have alpha, ignoring");
- have_alpha = FALSE;
- }
-
- buffer = swfdec_bits_decompress (&bits, -1, 2 * ((image->width + 1) & ~1) * image->height);
- data = g_malloc (4 * image->width * image->height);
- idata = data;
- if (buffer == NULL) {
- SWFDEC_ERROR ("failed to decompress data");
- memset (data, 0, 4 * image->width * image->height);
- goto out;
- }
- ptr = buffer->data;
-
- /* 15 bit packed */
- for (j = 0; j < image->height; j++) {
- for (i = 0; i < image->width; i++) {
- c = ptr[1] | (ptr[0] << 8);
- idata[SWFDEC_COLOR_INDEX_BLUE] = (c << 3) | ((c >> 2) & 0x7);
- idata[SWFDEC_COLOR_INDEX_GREEN] = ((c >> 2) & 0xf8) | ((c >> 7) & 0x7);
- idata[SWFDEC_COLOR_INDEX_RED] = ((c >> 7) & 0xf8) | ((c >> 12) & 0x7);
- idata[SWFDEC_COLOR_INDEX_ALPHA] = 0xff;
- ptr += 2;
- idata += 4;
- }
- if (image->width & 1)
- ptr += 2;
- }
- swfdec_buffer_unref (buffer);
- } else if (format == 5) {
- SwfdecBuffer *buffer;
- int i, j;
- guint32 *p;
-
- buffer = swfdec_bits_decompress (&bits, -1, 4 * image->width * image->height);
- if (buffer == NULL) {
- SWFDEC_ERROR ("failed to decompress data");
- data = g_malloc0 (4 * image->width * image->height);
- goto out;
- }
- data = buffer->data;
- p = (void *) data;
- /* image is stored in 0RGB format. We use ARGB/BGRA. */
- for (j = 0; j < image->height; j++) {
- for (i = 0; i < image->width; i++) {
- *p = GUINT32_FROM_BE (*p);
- p++;
- }
- }
- /* FIXME: this can fail if the returned buffer does not contain malloc'd
- * data at some point in the future */
- buffer->data = NULL;
- buffer->length = 0;
- swfdec_buffer_unref (buffer);
- } else {
- SWFDEC_ERROR ("unknown lossless image format %u", format);
- return;
- }
-
-out:
- image->surface = cairo_image_surface_create_for_data (data,
- have_alpha ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24,
- image->width, image->height, image->width * 4);
- cairo_surface_set_user_data (image->surface, &key, data, g_free);
-}
-
-int
-tag_func_define_bits_lossless (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecImage *image;
- int id;
- SwfdecBits *bits = &s->b;
-
- id = swfdec_bits_get_u16 (bits);
- SWFDEC_LOG (" id = %d", id);
-
- image = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_IMAGE);
- if (!image)
- return SWFDEC_STATUS_OK;
-
- image->type = SWFDEC_IMAGE_TYPE_LOSSLESS;
- image->raw_data = swfdec_bits_get_buffer (bits, -1);
-
- return SWFDEC_STATUS_OK;
-}
-
-int
-tag_func_define_bits_lossless_2 (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecImage *image;
- int id;
- SwfdecBits *bits = &s->b;
-
- id = swfdec_bits_get_u16 (bits);
- SWFDEC_LOG (" id = %d", id);
-
- image = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_IMAGE);
- if (!image)
- return SWFDEC_STATUS_OK;
-
- image->type = SWFDEC_IMAGE_TYPE_LOSSLESS2;
- image->raw_data = swfdec_bits_get_buffer (bits, -1);
-
- return SWFDEC_STATUS_OK;
-}
-
-static void
-swfdec_image_colormap_decode (SwfdecImage * image,
- unsigned char *dest,
- unsigned char *src, unsigned char *colormap, int colormap_len)
-{
- int c;
- int i;
- int j;
- int rowstride;
-
- rowstride = (image->width + 3) & ~0x3;
- SWFDEC_DEBUG ("rowstride %d", rowstride);
-
- for (j = 0; j < image->height; j++) {
- for (i = 0; i < image->width; i++) {
- c = src[i];
- if (colormap_len < 256 && c == 255) {
- dest[0] = 0;
- dest[1] = 0;
- dest[2] = 0;
- dest[3] = 0;
- } else if (c >= colormap_len) {
- SWFDEC_ERROR ("colormap index out of range (%d>=%d) (%d,%d)",
- c, colormap_len, i, j);
- dest[0] = 0;
- dest[1] = 0;
- dest[2] = 0;
- dest[3] = 0;
- } else {
- memmove (dest, &colormap[c*4], 4);
- }
- dest += 4;
- }
- src += rowstride;
- }
-}
-
-static cairo_status_t
-swfdec_image_png_read (void *bitsp, unsigned char *data, unsigned int length)
-{
- SwfdecBits *bits = bitsp;
- const guint8 *ptr;
-
- ptr = bits->ptr;
- if (swfdec_bits_skip_bytes (bits, length) != length)
- return CAIRO_STATUS_READ_ERROR;
-
- memcpy (data, ptr, length);
- return CAIRO_STATUS_SUCCESS;
-}
-
-static void
-swfdec_image_png_load (SwfdecImage *image)
-{
- SwfdecBits bits;
-
- swfdec_bits_init (&bits, image->raw_data);
- image->surface = cairo_image_surface_create_from_png_stream (
- swfdec_image_png_read, &bits);
- image->width = cairo_image_surface_get_width (image->surface);
- image->height = cairo_image_surface_get_height (image->surface);
- swfdec_cached_load (SWFDEC_CACHED (image), image->height *
- cairo_image_surface_get_stride (image->surface));
-}
-
-cairo_surface_t *
-swfdec_image_create_surface (SwfdecImage *image)
-{
- if (image->raw_data == NULL)
- return NULL;
-
- if (image->surface == NULL) {
- switch (image->type) {
- case SWFDEC_IMAGE_TYPE_JPEG:
- swfdec_image_jpeg_load (image);
- break;
- case SWFDEC_IMAGE_TYPE_JPEG2:
- swfdec_image_jpeg2_load (image);
- break;
- case SWFDEC_IMAGE_TYPE_JPEG3:
- swfdec_image_jpeg3_load (image);
- break;
- case SWFDEC_IMAGE_TYPE_LOSSLESS:
- swfdec_image_lossless_load (image);
- break;
- case SWFDEC_IMAGE_TYPE_LOSSLESS2:
- swfdec_image_lossless_load (image);
- break;
- case SWFDEC_IMAGE_TYPE_PNG:
- swfdec_image_png_load (image);
- break;
- case SWFDEC_IMAGE_TYPE_UNKNOWN:
- default:
- g_assert_not_reached ();
- break;
- }
- if (image->surface == NULL) {
- SWFDEC_WARNING ("failed to decode image");
- return NULL;
- }
- } else {
- swfdec_cached_use (SWFDEC_CACHED (image));
- }
- return cairo_surface_reference (image->surface);
-}
-
-cairo_surface_t *
-swfdec_image_create_surface_transformed (SwfdecImage *image, const SwfdecColorTransform *trans)
-{
- cairo_surface_t *surface, *source;
- guint32 *tdata;
- const guint32 *sdata;
- guint i, n;
- gboolean has_alpha = FALSE;
-
- g_return_val_if_fail (SWFDEC_IS_IMAGE (image), NULL);
- g_return_val_if_fail (trans != NULL, NULL);
-
- /* obvious optimization */
- if (swfdec_color_transform_is_identity (trans))
- return swfdec_image_create_surface (image);
-
- source = swfdec_image_create_surface (image);
- tdata = g_try_malloc (image->width * image->height * 4);
- if (!tdata) {
- SWFDEC_ERROR ("failed to allocate memory for transformed image");
- cairo_surface_destroy (source);
- return NULL;
- }
- /* FIXME: This code assumes a rowstride of 4 * width */
- /* FIXME: This code assumes an alignment of 4 */
- sdata = (void *) cairo_image_surface_get_data (source);
- n = image->width * image->height;
- for (i = 0; i < n; i++) {
- tdata[i] = swfdec_color_apply_transform_premultiplied (sdata[i], trans);
- /* optimization: check for alpha channel to speed up compositing */
- has_alpha |= SWFDEC_COLOR_A (tdata[i]) != 0xFF;
- }
- cairo_surface_destroy (source);
- surface = cairo_image_surface_create_for_data ((unsigned char *) tdata,
- has_alpha ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24,
- image->width, image->height, image->width * 4);
- cairo_surface_set_user_data (surface, &key, tdata, g_free);
- return surface;
-}
-
-/* NB: must be at least SWFDEC_DECODER_DETECT_LENGTH bytes */
-SwfdecImageType
-swfdec_image_detect (const guint8 *data)
-{
- g_return_val_if_fail (data != NULL, SWFDEC_IMAGE_TYPE_UNKNOWN);
-
- if (data[0] == 0xFF && data[1] == 0xD8)
- return SWFDEC_IMAGE_TYPE_JPEG2;
- else if (data[0] == 0x89 && data[1] == 'P' &&
- data[2] == 'N' && data[3] == 'G')
- return SWFDEC_IMAGE_TYPE_PNG;
- else
- return SWFDEC_IMAGE_TYPE_UNKNOWN;
-}
-
-SwfdecImage *
-swfdec_image_new (SwfdecBuffer *buffer)
-{
- SwfdecImage *image;
- SwfdecImageType type;
-
- g_return_val_if_fail (buffer != NULL, NULL);
-
- /* check type of the image */
- if (buffer->length < 4)
- goto fail;
- type = swfdec_image_detect (buffer->data);
- if (type == SWFDEC_IMAGE_TYPE_UNKNOWN)
- goto fail;
-
- image = g_object_new (SWFDEC_TYPE_IMAGE, NULL);
- image->type = type;
- image->raw_data = buffer;
-
- return image;
-
-fail:
- swfdec_buffer_unref (buffer);
- return NULL;
-}
diff --git a/libswfdec/swfdec_image.h b/libswfdec/swfdec_image.h
deleted file mode 100644
index e648e08..0000000
--- a/libswfdec/swfdec_image.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_IMAGE_H_
-#define _SWFDEC_IMAGE_H_
-
-#include <cairo.h>
-#include <libswfdec/swfdec_cached.h>
-#include <libswfdec/swfdec_decoder.h>
-
-G_BEGIN_DECLS
-//typedef struct _SwfdecImage SwfdecImage;
-typedef struct _SwfdecImageClass SwfdecImageClass;
-
-#define SWFDEC_TYPE_IMAGE (swfdec_image_get_type())
-#define SWFDEC_IS_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_IMAGE))
-#define SWFDEC_IS_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_IMAGE))
-#define SWFDEC_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_IMAGE, SwfdecImage))
-#define SWFDEC_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_IMAGE, SwfdecImageClass))
-
-typedef enum {
- SWFDEC_IMAGE_TYPE_UNKNOWN = 0,
- SWFDEC_IMAGE_TYPE_JPEG,
- SWFDEC_IMAGE_TYPE_JPEG2,
- SWFDEC_IMAGE_TYPE_JPEG3,
- SWFDEC_IMAGE_TYPE_LOSSLESS,
- SWFDEC_IMAGE_TYPE_LOSSLESS2,
- /* those can only be created by loading from files */
- SWFDEC_IMAGE_TYPE_PNG
-} SwfdecImageType;
-
-struct _SwfdecImage {
- SwfdecCached cached;
-
- int width; /* width of image or 0 if not known yet */
- int height; /* height of image or 0 if not known yet */
- cairo_surface_t * surface; /* surface when cache loaded or NULL */
-
- SwfdecImageType type;
- SwfdecBuffer * jpegtables;
- SwfdecBuffer * raw_data;
-};
-
-struct _SwfdecImageClass {
- SwfdecCachedClass cached_class;
-
-};
-
-GType swfdec_image_get_type (void);
-
-SwfdecImageType swfdec_image_detect (const guint8 * data);
-SwfdecImage * swfdec_image_new (SwfdecBuffer * buffer);
-cairo_surface_t * swfdec_image_create_surface (SwfdecImage * image);
-cairo_surface_t * swfdec_image_create_surface_transformed
- (SwfdecImage * image,
- const SwfdecColorTransform *trans);
-
-int swfdec_image_jpegtables (SwfdecSwfDecoder * s, guint tag);
-int tag_func_define_bits_jpeg (SwfdecSwfDecoder * s, guint tag);
-int tag_func_define_bits_jpeg_2 (SwfdecSwfDecoder * s, guint tag);
-int tag_func_define_bits_jpeg_3 (SwfdecSwfDecoder * s, guint tag);
-int tag_func_define_bits_lossless (SwfdecSwfDecoder * s, guint tag);
-int tag_func_define_bits_lossless_2 (SwfdecSwfDecoder * s, guint tag);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_image_decoder.c b/libswfdec/swfdec_image_decoder.c
deleted file mode 100644
index 17edf90..0000000
--- a/libswfdec/swfdec_image_decoder.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_image_decoder.h"
-#include "swfdec_debug.h"
-#include "swfdec_image.h"
-
-G_DEFINE_TYPE (SwfdecImageDecoder, swfdec_image_decoder, SWFDEC_TYPE_DECODER)
-
-static void
-swfdec_image_decoder_dispose (GObject *object)
-{
- SwfdecImageDecoder *image = SWFDEC_IMAGE_DECODER (object);
-
- if (image->queue) {
- swfdec_buffer_queue_unref (image->queue);
- image->queue = NULL;
- }
-
- if (image->image) {
- g_object_unref (image->image);
- image->image = NULL;
- }
-
- G_OBJECT_CLASS (swfdec_image_decoder_parent_class)->dispose (object);
-}
-
-static SwfdecStatus
-swfdec_image_decoder_parse (SwfdecDecoder *dec, SwfdecBuffer *buffer)
-{
- SwfdecImageDecoder *image = SWFDEC_IMAGE_DECODER (dec);
-
- if (image->queue == NULL)
- image->queue = swfdec_buffer_queue_new ();
- swfdec_buffer_queue_push (image->queue, buffer);
- dec->bytes_loaded += buffer->length;
- if (dec->bytes_loaded < dec->bytes_total)
- dec->bytes_total = dec->bytes_loaded;
- return 0;
-}
-
-/* FIXME: move this to swfdec_image API? */
-static gboolean
-swfdec_image_get_size (SwfdecImage *image, guint *w, guint *h)
-{
- cairo_surface_t *surface;
-
- surface = swfdec_image_create_surface (image);
- if (surface == NULL)
- return FALSE;
-
- if (w)
- *w = cairo_image_surface_get_width (surface);
- if (h)
- *h = cairo_image_surface_get_width (surface);
-
- cairo_surface_destroy (surface);
-
- return TRUE;
-}
-
-static SwfdecStatus
-swfdec_image_decoder_eof (SwfdecDecoder *dec)
-{
- SwfdecImageDecoder *image = SWFDEC_IMAGE_DECODER (dec);
- SwfdecBuffer *buffer;
- guint depth;
-
- if (image->queue == NULL)
- return 0;
- depth = swfdec_buffer_queue_get_depth (image->queue);
- if (depth == 0) {
- swfdec_buffer_queue_unref (image->queue);
- image->queue = NULL;
- return SWFDEC_STATUS_ERROR;
- }
- buffer = swfdec_buffer_queue_pull (image->queue,
- swfdec_buffer_queue_get_depth (image->queue));
- swfdec_buffer_queue_unref (image->queue);
- image->queue = NULL;
- image->image = swfdec_image_new (buffer);
- if (!swfdec_image_get_size (image->image, &dec->width, &dec->height))
- return SWFDEC_STATUS_ERROR;
- dec->frames_loaded = 1;
- dec->frames_total = 1;
- if (image->image->type == SWFDEC_IMAGE_TYPE_JPEG)
- dec->data_type = SWFDEC_LOADER_DATA_JPEG;
- else if (image->image->type == SWFDEC_IMAGE_TYPE_PNG)
- dec->data_type = SWFDEC_LOADER_DATA_PNG;
-
-
- return SWFDEC_STATUS_INIT | SWFDEC_STATUS_IMAGE;
-}
-
-static void
-swfdec_image_decoder_class_init (SwfdecImageDecoderClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
- SwfdecDecoderClass *decoder_class = SWFDEC_DECODER_CLASS (class);
-
- object_class->dispose = swfdec_image_decoder_dispose;
-
- decoder_class->parse = swfdec_image_decoder_parse;
- decoder_class->eof = swfdec_image_decoder_eof;
-}
-
-static void
-swfdec_image_decoder_init (SwfdecImageDecoder *s)
-{
-}
-
diff --git a/libswfdec/swfdec_image_decoder.h b/libswfdec/swfdec_image_decoder.h
deleted file mode 100644
index b5f3a84..0000000
--- a/libswfdec/swfdec_image_decoder.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef __SWFDEC_IMAGE_DECODER_H__
-#define __SWFDEC_IMAGE_DECODER_H__
-
-#include <glib.h>
-
-#include <libswfdec/swfdec_decoder.h>
-#include <libswfdec/swfdec_bits.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_rect.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecImageDecoder SwfdecImageDecoder;
-typedef struct _SwfdecImageDecoderClass SwfdecImageDecoderClass;
-
-#define SWFDEC_TYPE_IMAGE_DECODER (swfdec_image_decoder_get_type())
-#define SWFDEC_IS_IMAGE_DECODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_IMAGE_DECODER))
-#define SWFDEC_IS_IMAGE_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_IMAGE_DECODER))
-#define SWFDEC_IMAGE_DECODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_IMAGE_DECODER, SwfdecImageDecoder))
-#define SWFDEC_IMAGE_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_IMAGE_DECODER, SwfdecImageDecoderClass))
-#define SWFDEC_IMAGE_DECODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_IMAGE_DECODER, SwfdecImageDecoderClass))
-
-struct _SwfdecImageDecoder
-{
- SwfdecDecoder decoder;
-
- SwfdecBufferQueue * queue; /* keeps the data while decoding */
- SwfdecImage * image; /* the image we display */
-};
-
-struct _SwfdecImageDecoderClass {
- SwfdecDecoderClass decoder_class;
-};
-
-GType swfdec_image_decoder_get_type (void);
-
-
-G_END_DECLS
-
-#endif
diff --git a/libswfdec/swfdec_initialize.as b/libswfdec/swfdec_initialize.as
deleted file mode 100644
index ed643b9..0000000
--- a/libswfdec/swfdec_initialize.as
+++ /dev/null
@@ -1,1521 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-/*** GENERAL ***/
-
-ASSetPropFlags = ASnative (1, 0);
-ASSetNative = ASnative (4, 0);
-ASSetNativeAccessor = ASnative (4, 1);
-
-flash = {};
-
-/*** Object ***/
-/* Only Flash extensions here, rest to swfdec_as_initialize.as */
-
-Object.registerClass = ASnative(101, 8);
-ASSetPropFlags (Object, null, 7);
-
-// so we can use it in this script
-ASSetPropFlags (Object, "addProperty", 0, 128);
-
-/*** Error ***/
-
-function Error (msg) {
- if (typeof (msg) != "undefined")
- this.message = msg;
-}
-Error.prototype.name = Error.prototype.message = "Error";
-Error.prototype.toString = function () {
- return this.message;
-};
-
-/*** ASBROADCASTER ***/
-
-function AsBroadcaster () { };
-
-AsBroadcaster.broadcastMessage = ASnative(101, 12);
-
-AsBroadcaster.addListener = function (x) {
- this.removeListener (x);
- this._listeners.push (x);
- return true;
-};
-
-AsBroadcaster.removeListener = function (x) {
- var l = this._listeners;
- var i;
-
- for (var i = 0; i < l.length; i++) {
- if (l[i] == x) {
- l.splice (i, 1);
- return true;
- }
- }
- return false;
-};
-
-AsBroadcaster.initialize = function (o) {
- o.broadcastMessage = ASnative(101, 12);
- o.addListener = AsBroadcaster.addListener;
- o.removeListener = AsBroadcaster.removeListener;
- o._listeners = [];
- ASSetPropFlags(o, "broadcastMessage,addListener,removeListener,_listeners", 131);
-};
-
-Key = { ALT: 18, BACKSPACE: 8, CAPSLOCK: 20, CONTROL: 17, DELETEKEY: 46,
- DOWN: 40, END: 35, ENTER: 13, ESCAPE: 27, HOME: 36, INSERT: 45, LEFT: 37,
- PGDN: 34, PGUP: 33, RIGHT: 39, SHIFT: 16, SPACE: 32, TAB: 9, UP: 38 };
-ASSetNative(Key, 800, "getAscii,getCode,isDown,isToggled,isAccessible");
-AsBroadcaster.initialize(Key);
-ASSetPropFlags(Key, null, 7);
-
-/*** MOUSE ***/
-
-Mouse = { };
-Mouse.show = ASnative (5, 0);
-Mouse.hide = ASnative (5, 1);
-AsBroadcaster.initialize (Mouse);
-ASSetPropFlags(Mouse, null, 7);
-
-/*** STAGE ***/
-
-Stage = { };
-AsBroadcaster.initialize (Stage);
-ASSetNativeAccessor (Stage, 666, "scaleMode,align,width,height,showMenu,displayState", 1);
-ASSetNativeAccessor (Stage, 666, "9fullScreenSourceRect,9fullScreenHeight,9fullScreenWidth", 100);
-
-/*** NetConnection ***/
-
-// FIXME: this should actually be a non-native function that calls the ASnative
-// function
-NetConnection = ASconstructor (2100, 200);
-
-ASSetNative (NetConnection.prototype, 2100, "6connect,6close,6call,6addHeader");
-NetConnection.prototype.addProperty ("connectedProxyType", ASnative (2100, 4), null);
-NetConnection.prototype.proxyType = "none";
-NetConnection.prototype.addProperty ("usingTLS", ASnative (2100, 5), null);
-ASSetPropFlags (NetConnection.prototype, null, 3);
-
-/*** NetStream ***/
-
-NetStream.prototype.publish = function () {
- var o = {}; o["Implement NetStream.publish"] ();
-};
-
-NetStream.prototype.receiveAudio = function (flag) {
- var o = {}; o["Implement NetStream.receiveAudio"] ();
-};
-
-NetStream.prototype.receiveVideo = function (flag) {
- var o = {}; o["Implement NetStream.receiveVideo"] ();
-};
-
-ASSetNative (NetStream.prototype, 2101, "6close,6attachAudio,6attachVideo,6send,6setBufferTime");
-ASSetNativeAccessor (NetStream.prototype, 2101, "checkPolicyFile", 5);
-ASSetPropFlags (NetStream.prototype, null, 3);
-
-/*** LOADVARS ***/
-
-function LoadVars () { };
-
-LoadVars.prototype.contentType = "application/x-www-form-urlencoded";
-
-LoadVars.prototype.load = ASnative (301, 0);
-LoadVars.prototype.send = ASnative (301, 1);
-LoadVars.prototype.sendAndLoad = ASnative (301, 2);
-LoadVars.prototype.decode = ASnative (301, 3);
-
-LoadVars.prototype.onLoad = function () {
-};
-
-LoadVars.prototype.onData = function (src) {
- this.loaded = true;
- if (src != null) {
- this.decode (src);
- this.onLoad (true);
- } else {
- this.onLoad (false);
- }
-};
-
-LoadVars.prototype.toString = function () {
- var str = null;
- for (var x in this) {
- if (str == null) {
- str = escape(x) + "=" + escape(this[x]);
- } else {
- str += "&" + escape(x) + "=" + escape(this[x]);
- }
- }
- return str;
-};
-
-LoadVars.prototype.getBytesLoaded = function () {
- return this._bytesLoaded;
-};
-
-LoadVars.prototype.getBytesTotal = function () {
- return this._bytesTotal;
-};
-
-LoadVars.prototype.addRequestHeader = function () {
- // Same as XML?
- var o = {}; o["Implement LoadVars.addRequestHeader"] ();
-};
-
-ASSetPropFlags(LoadVars.prototype, null, 131);
-
-/*** Sound ***/
-
-Sound = ASconstructor (500, 16);
-ASSetNative (Sound.prototype, 500, "getPan,getTransform,getVolume,setPan,setTransform,setVolume,stop,attachSound,start,6getDuration,6setDuration,6getPosition,6setPosition,6loadSound,6getBytesLoaded,6getBytesTotal,9areSoundsInaccessible");
-ASSetNativeAccessor (Sound.prototype, 500, "checkPolicyFile", 18);
-ASSetPropFlags (Sound.prototype, null, 7);
-
-/*** XMLNode ***/
-
-XMLNode = ASconstructor (253, 0);
-
-XMLNode.prototype.cloneNode = ASnative (253, 1);
-XMLNode.prototype.removeNode = ASnative (253, 2);
-XMLNode.prototype.insertBefore = ASnative (253, 3);
-XMLNode.prototype.appendChild = ASnative (253, 4);
-XMLNode.prototype.hasChildNodes = ASnative (253, 5);
-XMLNode.prototype.toString = ASnative (253, 6);
-XMLNode.prototype.getNamespaceForPrefix = ASnative (253, 7);
-XMLNode.prototype.getPrefixForNamespace = ASnative (253, 8);
-
-/*** XML ***/
-
-XML = ASconstructor (253, 9);
-
-XML.prototype = new XMLNode (1, "");
-delete XML.prototype.constructor;
-ASSetPropFlags (XML, "prototype", 3);
-
-XML.prototype.load = ASnative (301, 0);
-XML.prototype.send = ASnative (301, 1);
-XML.prototype.sendAndLoad = ASnative (301, 2);
-XML.prototype.createElement = ASnative (253, 10);
-XML.prototype.createTextNode = ASnative (253, 11);
-XML.prototype.parseXML = ASnative (253, 12);
-
-XML.prototype.onLoad = function () {
-};
-
-// Note: handling of loaded is different here than in LoadVars
-XML.prototype.onData = function (src) {
- if (src != null) {
- this.loaded = true;
- this.parseXML (src);
- this.onLoad (true);
- } else {
- this.loaded = false;
- this.onLoad (false);
- }
-};
-
-XML.prototype.getBytesLoaded = function () {
- return this._bytesLoaded;
-};
-
-XML.prototype.getBytesTotal = function () {
- return this._bytesTotal;
-};
-
-XML.prototype.addRequestHeader = function () {
- // Same as LoadVars?
- var o = {}; o["Implement XML.addRequestHeader"] ();
-};
-
-/*** System ***/
-
-System = {};
-
-System.capabilities = {};
-System.capabilities.Query = ASnative (11, 0);
-System.capabilities.Query ();
-delete System.capabilities.Query;
-
-System.setClipboard = ASnative (1066, 0);
-System.showSettings = ASnative (2107, 0);
-ASSetNativeAccessor (System, 2107, "exactSettings,useCodepage", 1);
-ASSetPropFlags (System, "exactSettings,useCodePage", 128);
-
-/*** System.security */
-
-System.security = new Object();
-delete System.security.constructor;
-ASSetNative (System.security, 12, "allowDomain,7allowInsecureDomain,loadPolicyFile,chooseLocalSwfPath,escapeDomain");
-ASSetNativeAccessor (System.security, 12, "sandboxType", 5);
-
-/*** System.security.PolicyFileResolver */
-
-System.security.PolicyFileResolver = function () {
- var o = {}; o["Implement System.security.PolicyFileResolver"] ();
-};
-System.security.PolicyFileResolver.prototype.resolve = ASnative (15, 0);
-AsBroadcaster.initialize (System.security.PolicyFileResolver.prototype);
-
-/*** System.Product ***/
-
-System.Product = function () {
- var o = {}; o["Implement System.Product"] ();
-};
-
-System.Product.prototype.isRunning = function () {
- var o = {}; o["Implement System.Product.isRunning"] ();
-};
-
-System.Product.prototype.isInstalled = function () {
- var o = {}; o["Implement System.Product.isInstalled"] ();
-};
-
-System.Product.prototype.launch = function () {
- var o = {}; o["Implement System.Product.launch"] ();
-};
-
-System.Product.prototype.download = function () {
- var o = {}; o["Implement System.Product.download"] ();
-};
-
-System.Product.prototype.installedVersion = function () {
- var o = {}; o["Implement System.Product.installedVersion"] ();
-};
-
-System.Product.prototype.validate = function () {
- var o = {}; o["Implement System.Product.validate"] ();
-};
-
-ASSetPropFlags (System.Product.prototype, null, 3);
-
-/*** System.IME ***/
-
-System.IME = {
- ALPHANUMERIC_FULL: "ALPHANUMERIC_FULL",
- ALPHANUMERIC_HALF: "ALPHANUMERIC_HALF",
- CHINESE: "CHINESE",
- JAPANESE_HIRAGANA: "JAPANESE_HIRAGANA",
- JAPANESE_KATAKANA_FULL: "JAPANESE_KATAKANA_FULL",
- JAPANESE_KATAKANA_HALF: "JAPANESE_KATAKANA_HALF",
- KOREAN: "KOREAN",
- UNKNOWN: "UNKNOWN"
-};
-
-AsBroadcaster.initialize (System.IME);
-
-ASSetNative (System.IME, 13, "8getEnabled,8setEnabled,8getConversionMode,8setConversionMode,8setCompositionString,8doConversion");
-ASSetPropFlags (System.IME, null, 7);
-
-/*** Color ***/
-
-Color = function (target) {
- this.target = target;
- ASSetPropFlags (this, null, 7);
-};
-ASSetNative (Color.prototype, 700, "setRGB,setTransform,getRGB,getTransform");
-ASSetPropFlags (Color.prototype, null, 7);
-
-/* TextSnapshot */
-
-TextSnapshot = ASconstructor (1067, 0);
-ASSetNative (TextSnapshot.prototype, 1067, "6getCount,6setSelected,6getSelected,6getText,6getSelectedText,6hitTestTextNearPos,6findText,6setSelectColor,6getTextRunInfo", 1);
-
-/* MovieClip */
-
-MovieClip.prototype.useHandCursor = true;
-MovieClip.prototype.enabled = true;
-
-MovieClip.prototype.meth = function (method) {
- var lower = method.toLowerCase ();
- if (lower == "post") {
- return 2;
- } else if (lower == "get") {
- return 1;
- } else {
- return 0;
- }
-};
-
-MovieClip.prototype.getURL = function (url, target, method) {
- if (typeof (target) == "undefined")
- target = ""; // undefined to empty string, even in version >= 7
-
- var type = this.meth (method);
- if (type == 0) {
- getURL (url, target);
- } else if (type == 1) {
- getURL (url, target, "GET");
- } else {
- getURL (url, target, "POST");
- }
-};
-
-// work around ming bug, causing loadVariables to be lower cased
-MovieClip.prototype["loadVariables"] = function (url, method) {
- var type = this.meth (method);
- setTarget (this);
- if (type == 0) {
- loadVariables (url, this._target);
- } else if (type == 1) {
- loadVariables (url, this._target, "GET");
- } else {
- loadVariables (url, this._target, "POST");
- }
- setTarget ("");
-};
-
-// work around ming bug, causing loadMovie to be lower cased
-MovieClip.prototype["loadMovie"] = function (url, method) {
- var type = this.meth (method);
- setTarget (this);
- if (type == 0) {
- loadMovie (url, this._target);
- } else if (type == 1) {
- loadMovie (url, this._target, "GET");
- } else {
- loadMovie (url, this._target, "POST");
- }
- setTarget ("");
-};
-
-MovieClip.prototype.unloadMovie = function () {
- setTarget (this);
- loadMovie ("", this._target);
- setTarget ("");
-};
-
-MovieClip.prototype.getTextSnapshot = function () {
- return new TextSnapshot(this);
-};
-ASSetPropFlags (MovieClip.prototype, "getTextSnapshot", 128);
-
-
-ASSetNative (MovieClip.prototype, 900, "attachMovie,swapDepths,localToGlobal,globalToLocal,hitTest,getBounds,getBytesTotal,getBytesLoaded,6attachAudio,6attachVideo,6getDepth,6setMask,play,stop,nextFrame,prevFrame,gotoAndPlay,gotoAndStop,duplicateMovieClip,removeMovieClip,startDrag,stopDrag,7getNextHighestDepth,7getInstanceAtDepth,getSWFVersion,8attachBitmap,8getRect");
-ASSetNativeAccessor (MovieClip.prototype, 900, "tabIndex", 200);
-ASSetNativeAccessor (MovieClip.prototype, 900, "_lockroot", 300);
-ASSetNativeAccessor (MovieClip.prototype, 900, "8cacheAsBitmap,8opaqueBackground,8scrollRect", 401);
-ASSetNativeAccessor (MovieClip.prototype, 900, "8filters,8transform", 417);
-ASSetNativeAccessor (MovieClip.prototype, 900, "8blendMode", 500);
-
-ASSetNative (MovieClip.prototype, 901, "6createEmptyMovieClip,6beginFill,6beginGradientFill,6moveTo,6lineTo,6curveTo,6lineStyle,6endFill,6clear,8lineGradientStyle,8beginMeshFill,8beginBitmapFill");
-ASSetNativeAccessor (MovieClip.prototype, 901, "8scale9Grid", 12);
-
-MovieClip.prototype.createTextField = ASnative (104, 200);
-
-ASSetPropFlags (MovieClip.prototype, null, 3);
-
-/* MovieClipLoader */
-
-MovieClipLoader = ASconstructor (112, 0);
-ASSetNative(MovieClipLoader.prototype, 112, "7loadClip,7getProgress,7unloadClip", 100);
-AsBroadcaster.initialize(MovieClipLoader.prototype);
-ASSetPropFlags(MovieClipLoader.prototype, null, 1027);
-
-/* TextField */
-
-TextField = ASconstructor (104, 0);
-TextField.getFontList = ASnative (104, 201);
-
-ASSetNative (TextField.prototype, 104, "6replaceSel,6getTextFormat,6setTextFormat,6removeTextField,6getNewTextFormat,6setNewTextFormat,6getDepth,7replaceText", 100);
-AsBroadcaster.initialize (TextField.prototype);
-
-ASSetPropFlags (TextField.prototype, null, 131);
-
-ASSetNativeAccessor (TextField.prototype, 104, "8gridFitType,8antiAliasType,8thickness,8sharpness,8filters", 300);
-// FIXME: this should be done inside the TextField constructor
-ASSetNativeAccessor (TextField.prototype, 900, "8tabIndex", 200);
-
-ASSetPropFlags (TextField, null, 131);
-
-/* TextFormat */
-
-TextFormat = ASconstructor (110, 0);
-
-/* TextField.Stylesheet */
-
-TextField.StyleSheet = ASconstructor (113, 0);
-
-TextField.StyleSheet.prototype._copy = function (o) {
- if (typeof (o) != "object")
- return null;
-
- var o_new = {};
- for (var prop in o) {
- o_new[prop] = o[prop];
- }
- return o_new;
-};
-
-TextField.StyleSheet.prototype.clear = function () {
- this._css = {};
- this._styles = {};
- this.update ();
-};
-
-TextField.StyleSheet.prototype.getStyle = function (name) {
- return (this._copy (this._css[name]));
-};
-
-TextField.StyleSheet.prototype.setStyle = function (name, style) {
- if (!this._css)
- this._css = {};
-
- this._css[name] = this._copy (style);
- this.doTransform (name);
- this.update ();
-};
-
-TextField.StyleSheet.prototype.getStyleNames = function () {
- var tmp = this._css; /* ming bug? */
- var names = [];
- for (var prop in tmp) {
- names.push (prop);
- }
- return names;
-};
-
-TextField.StyleSheet.prototype.doTransform = function (name) {
- if (!this._styles) {
- this._styles = {};
- }
- this._styles[name] = this.transform (this._css[name]);
-};
-
-TextField.StyleSheet.prototype.transform = function (style) {
- if (style == null)
- return null;
-
- var format = new TextFormat ();
-
- if (style.textAlign)
- format.align = style.textAlign;
-
- if (style.fontWeight == "bold") {
- format.bold = true;
- } else if (style.fontWeight == "normal") {
- format.bold = false;
- }
-
- if (style.color) {
- var tmp = this.parseColor (style.color);
- if (tmp != null)
- format.color = tmp;
- }
-
- format.display = style.display;
-
- if (style.fontFamily)
- format.font = this.parseCSSFontFamily (style.fontFamily);
-
- if (style.textIndent)
- format.indent = parseInt (style.textIndent);
-
- if (style.fontStyle == "italic") {
- format.italic = true;
- } else if (style.fontStyle == "normal") {
- format.italic = false;
- }
-
- if (style.kerning == "true") {
- format.kerning = true;
- } else if (style.kerning == "false") {
- format.kerning = false;
- } else {
- format.kerning = parseInt (style.kerning);
- }
-
- if (style.leading)
- format.leading = parseInt (style.leading);
-
- if (style.marginLeft)
- format.leftMargin = parseInt (style.marginLeft);
-
- if (style.letterSpacing)
- format.letterSpacing = parseInt (style.letterSpacing);
-
- if (style.marginRight)
- format.rightMargin = parseInt (style.marginRight);
-
- if (style.fontSize) {
- var tmp = parseInt (style.fontSize);
- if (tmp > 0)
- format.size = tmp;
- }
-
- if (style.textDecoration == "underline") {
- format.underline = true;
- } else if (style.textDecoration == "none") {
- format.underline = false;
- }
-
- return format;
-};
-
-TextField.StyleSheet.prototype.parseCSS = function (css) {
- var result = this.parseCSSInternal (css);
- if (typeof (result) == "null")
- return false;
-
- if (!this._css)
- this._css = {};
-
- for (var prop in result) {
- this._css[prop] = this._copy (result[prop]);
- this.doTransform (prop);
- }
- this.update ();
-
- return true;
-};
-
-TextField.StyleSheet.prototype.parse = TextField.StyleSheet.prototype.parseCSS;
-
-TextField.StyleSheet.prototype.load = ASnative (301, 0);
-
-TextField.StyleSheet.prototype.onLoad = function () {
-};
-
-TextField.StyleSheet.prototype.onData = function (src) {
- if (src != null) {
- var result = this.parse (src);
- this.loaded = result;
- this.onLoad (result);
- } else {
- this.onLoad (false);
- }
-};
-
-ASSetNative (TextField.StyleSheet.prototype, 113, "7update,7parseCSSInternal,7parseCSSFontFamily,7parseColor", 100);
-ASSetPropFlags (TextField.StyleSheet.prototype, null, 1027);
-ASSetPropFlags (TextField, "StyleSheet", 1027);
-
-/* Video */
-
-ASSetNative(Video.prototype, 667, "6attachVideo,6clear", 1);
-ASSetPropFlags(Video.prototype, null, 3);
-
-/* Accessibility */
-
-Accessibility = {};
-ASSetNative (Accessibility, 1999, "6isActive,6sendEvent,6updateProperties");
-ASSetPropFlags (Accessibility, null, 6);
-
-/* Camera */
-
-function Camera () {
-}
-
-Camera.get = function (index) {
- var get_func = ASnative (2102, 200);
- return get_func (index);
-};
-Camera.addProperty ("names", ASnative (2102, 201), null);
-ASSetNative (Camera.prototype, 2102, "6setMode,6setQuality,6setKeyFrameInterval,6setMotionLevel,6setLoopback,6setCursor");
-ASSetPropFlags (Camera.prototype, null, 3);
-
-/* ContextMenu */
-
-function ContextMenu (callback) {
- this.onSelect = callback;
- this.customItems = new Array ();
- this.builtInItems = {
- forward_back: true,
- loop: true,
- play: true,
- print: true,
- quality: true,
- rewind: true,
- save: true,
- zoom: true
- };
-}
-
-ContextMenu.prototype.copy = function () {
- var o = new ContextMenu ();
-
- o.onSelect = this.onSelect;
-
- o.customItems = new Array ();
- for (var i = 0; i < this.customItems.length; i++) {
- o.customItems.push (this.customItems[i].copy ());
- }
-
- o.builtInItems = this.builtInItems;
-
- return o;
-};
-
-ContextMenu.prototype.hideBuiltInItems = function () {
- this.builtInItems = {
- forward_back: false,
- loop: false,
- play: false,
- print: false,
- quality: false,
- rewind: false,
- save: false,
- zoom: false
- };
-};
-
-ASSetPropFlags (ContextMenu.prototype, null, 1027);
-
-/* ContextMenuItem */
-
-function ContextMenuItem (caption, callback, separatorBefore, enabled, visible)
-{
- this.caption = caption;
- this.onSelect = callback;
- if (separatorBefore == undefined) {
- this.separatorBefore = false;
- } else {
- this.separatorBefore = separatorBefore;
- }
- if (enabled == undefined) {
- this.enabled = true;
- } else {
- this.enabled = enabled;
- }
- if (visible == undefined) {
- this.visible = true;
- } else {
- this.visible = visible;
- }
-}
-
-ContextMenuItem.prototype.copy = function () {
- var o = new ContextMenuItem ();
-
- o.caption = this.caption;
- o.onSelect = this.onSelect;
- o.separatorBefore = this.separatorBefore;
- o.enabled = this.enabled;
- o.visible = this.visible;
-
- return o;
-};
-
-ASSetPropFlags (ContextMenuItem.prototype, null, 1027);
-
-/* FileReference */
-
-flash.net = {};
-flash.net.FileReference = function () {
- var c = ASnative (2204, 200);
- c (this);
- this._listeners = [];
-};
-
-AsBroadcaster.initialize(flash.net.FileReference.prototype);
-ASSetNative(flash.net.FileReference.prototype, 2204, "8browse,8upload,8download,8cancel");
-ASSetPropFlags(flash.net.FileReference.prototype, null, 3);
-
-/* FileReferenceList */
-
-flash.net.FileReferenceList = function () {
- this.fileList = new Array();
- this._listeners = [];
-};
-
-AsBroadcaster.initialize (flash.net.FileReferenceList.prototype);
-ASSetNative (flash.net.FileReferenceList.prototype, 2205, "8browse");
-ASSetPropFlags (flash.net.FileReferenceList.prototype, null, 3);
-
-/* LocalConnection */
-
-function LocalConnection () {
-}
-
-ASSetNative (LocalConnection.prototype, 2200, "6connect,6send,6close,6domain");
-ASSetPropFlags (LocalConnection.prototype, null, 3);
-
-/* Microphone */
-
-function Microphone () {
-}
-
-Microphone.get = function (index) {
- var get_func = ASnative (2104, 200);
- return get_func (index);
-};
-Microphone.addProperty ("names", ASnative (2104, 201), null);
-ASSetNative (Microphone.prototype, 2104, "6setSilenceLevel,6setRate,6setGain,6setUseEchoSuppression");
-ASSetPropFlags (Microphone.prototype, null, 3);
-
-/* PrintJob */
-
-PrintJob = ASconstructor(111, 0);
-ASSetNative (PrintJob.prototype, 111, "7start,7addPage,7send", 100);
-ASSetPropFlags (PrintJob.prototype, null, 1027);
-
-/* Selection */
-
-Selection = {};
-ASSetNative (Selection, 600, "getBeginIndex,getEndIndex,getCaretIndex,getFocus,setFocus,setSelection");
-AsBroadcaster.initialize (Selection);
-ASSetPropFlags (Selection, null, 7);
-
-/* TextRenderer */
-
-flash.text = {};
-flash.text.TextRenderer = ASconstructor (2150, 0);
-
-ASSetNative (flash.text.TextRenderer, 2150, "8setAdvancedAntialiasingTable", 1);
-ASSetNativeAccessor (flash.text.TextRenderer, 2150, "8maxLevel", 4);
-ASSetNativeAccessor (flash.text.TextRenderer, 2150, "8displayMode", 10);
-
-textRenderer = flash.text.TextRenderer; // awesome
-
-/* XMLSocket */
-
-function XMLSocket () {
-}
-
-XMLSocket.prototype.onData = function (src) {
- this.onXML (new XML (src));
-};
-
-ASSetNative (XMLSocket.prototype, 400, "connect,send,close");
-ASSetPropFlags (XMLSocket.prototype, null, 3);
-
-/* Point */
-
-flash.geom = {};
-
-flash.geom.Point = function () {
- if (arguments.length == 0) {
- this.x = 0;
- this.y = 0;
- } else {
- // Note: we don't check for length == 1
- this.x = arguments[0];
- this.y = arguments[1];
- }
-};
-
-flash.geom.Point.distance = function (a, b) {
- return a.subtract (b).length;
-};
-
-flash.geom.Point.interpolate = function (a, b, value) {
- return new flash.geom.Point (b.x + value * (a.x - b.x),
- b.y + value * (a.y - b.y));
-};
-
-flash.geom.Point.polar = function (length, angle) {
- return new flash.geom.Point (length * Math.cos (angle),
- length * Math.sin (angle));
-};
-
-flash.geom.Point.prototype.addProperty ("length",
- function () { return Math.sqrt (this.x * this.x + this.y * this.y); },
- null);
-
-flash.geom.Point.prototype.add = function (other) {
- return new flash.geom.Point (this.x + other.x, this.y + other.y);
-};
-
-flash.geom.Point.prototype.clone = function () {
- return new flash.geom.Point (this.x, this.y);
-};
-
-flash.geom.Point.prototype.equals = function (other) {
- if (!other instanceOf flash.geom.Point)
- return false;
-
- return (other.x == this.x && other.y == this.y);
-};
-
-flash.geom.Point.prototype.normalize = function (length) {
- if (this.length <= 0)
- return undefined;
-
- var factor = length / this.length;
- this.x = this.x * factor;
- this.y = this.y * factor;
-};
-
-flash.geom.Point.prototype.subtract = function (other) {
- return new flash.geom.Point (this.x - other.x, this.y - other.y);
-};
-
-flash.geom.Point.prototype.offset = function (x, y) {
- this.x += x;
- this.y += y;
-};
-
-flash.geom.Point.prototype.toString = function () {
- return "(x=" + this.x + ", y=" + this.y + ")";
-};
-
-/* Rectangle */
-
-flash.geom.Rectangle = function (x, y, width, height) {
- if (arguments.length == 0) {
- this.setEmpty ();
- } else {
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
- }
-};
-
-flash.geom.Rectangle.prototype.clone = function () {
- return new flash.geom.Rectangle (this.x, this.y, this.width, this.height);
-};
-
-flash.geom.Rectangle.prototype.toString = function () {
- return "(x=" + this.x + ", y=" + this.y + ", w=" + this.width + ", h=" + this.height + ")";
-};
-
-flash.geom.Rectangle.prototype.equals = function (rect) {
- return (rect instanceof flash.geom.Rectangle &&
- this.x == rect.x && this.y == rect.y &&
- this.width == rect.width && this.height == rect.height);
-};
-
-flash.geom.Rectangle.prototype.contains = function (x, y) {
- return (this.x <= x && this.y <= y &&
- this.x + this.width > x && this.y + this.height > y);
-};
-
-flash.geom.Rectangle.prototype.containsPoint = function (point) {
- return (this.x <= point.x && this.y <= point.y &&
- this.x + this.width > point.x && this.y + this.height > point.y);
-};
-
-flash.geom.Rectangle.prototype.containsRectangle = function (rect) {
- var tr = this.x + this.width;
- var tb = this.y + this.height;
- var rr = rect.x + rect.width;
- var rb = rect.y + rect.height;
- return (rect.x >= this.x && rect.x < tr && rect.y >= this.y && rect.y < tb &&
- rr > this.x && rr <= tr && rb > this.y && rb <= tb);
-};
-
-flash.geom.Rectangle.prototype.isEmpty = function () {
- return (this.width <= 0 || this.height <= 0);
-};
-
-flash.geom.Rectangle.prototype.setEmpty = function () {
- this.x = 0;
- this.y = 0;
- this.width = 0;
- this.height = 0;
-};
-
-flash.geom.Rectangle.prototype.intersection = function (rect) {
- var ints = new flash.geom.Rectangle ();
-
- if (this.isEmpty () || rect.isEmpty ()) {
- ints.setEmpty ();
- return ints;
- }
-
- ints.x = Math.max (this.x, rect.x);
- ints.y = Math.max (this.y, rect.y);
- ints.width = Math.min (this.x + this.width, rect.x + rect.width) - ints.x;
- ints.height = Math.min (this.y + this.height, rect.y + rect.height) - ints.y;
-
- if (ints.width <= 0 || ints.height <= 0)
- ints.setEmpty ();
-
- return ints;
-};
-
-flash.geom.Rectangle.prototype.intersects = function (rect) {
- return !this.intersection (rect).isEmpty ();
-};
-
-flash.geom.Rectangle.prototype.union = function (rect) {
- if (this.isEmpty ())
- return rect.clone ();
-
- if (rect.isEmpty ())
- return this.clone ();
-
- var union = new flash.geom.Rectangle ();
- union.x = Math.min (this.x, rect.x);
- union.y = Math.min (this.y, rect.y);
- union.width = Math.max (this.x + this.width, rect.x + rect.width) - union.x;
- union.height =
- Math.max (this.y + this.height, rect.y + rect.height) - union.y;
-
- return union;
-};
-
-flash.geom.Rectangle.prototype.offset = function (dx, dy) {
- this.x += dx;
- this.y += dy;
-};
-
-flash.geom.Rectangle.prototype.offsetPoint = function (d) {
- this.x += d.x;
- this.y += d.y;
-};
-
-flash.geom.Rectangle.prototype.inflate = function (dx, dy) {
- this.x -= dx;
- this.width += 2 * dx;
-
- this.y -= dy;
- this.height += 2 * dy;
-};
-
-flash.geom.Rectangle.prototype.inflatePoint = function (d) {
- this.x -= d.x;
- this.width += 2 * d.x;
-
- this.y -= d.y;
- this.height += 2 * d.y;
-};
-
-flash.geom.Rectangle.prototype.addProperty ("left",
- function () {
- return this.x;
- },
- function (left) {
- this.width += this.x - left;
- this.x = left;
- }
-);
-
-flash.geom.Rectangle.prototype.addProperty ("right",
- function () {
- return this.x + this.width;
- },
- function (right) {
- this.width = right - this.x;
- }
-);
-
-flash.geom.Rectangle.prototype.addProperty ("top",
- function () {
- return this.y;
- },
- function (top) {
- this.height += this.y - top;
- this.y = top;
- }
-);
-
-flash.geom.Rectangle.prototype.addProperty ("bottom",
- function () {
- return this.y + this.height;
- },
- function (bottom) {
- this.height = bottom - this.y;
- }
-);
-
-flash.geom.Rectangle.prototype.addProperty ("topLeft",
- function () {
- return new flash.geom.Point (this.x, this.y);
- },
- function (topLeft) {
- this.width += this.x - topLeft.x;
- this.height += this.y - topLeft.y;
- this.x = topLeft.x;
- this.y = topLeft.y;
- }
-);
-
-flash.geom.Rectangle.prototype.addProperty ("bottomRight",
- function () {
- return new flash.geom.Point (this.x + this.width, this.y + this.height);
- },
- function (bottomRight) {
- this.width = bottomRight.x - this.x;
- this.height = bottomRight.y - this.y;
- }
-);
-
-flash.geom.Rectangle.prototype.addProperty ("size",
- function () {
- return new flash.geom.Point (this.width, this.height);
- },
- function (size) {
- this.width = size.x;
- this.height = size.y;
- }
-);
-
-/* Matrix */
-
-flash.geom.Matrix = function () {
- var o = {}; o["Implement Matrix"] ();
-};
-
-flash.geom.Matrix.prototype.clone = function () {
- var o = {}; o["Implement Matrix.clone"] ();
-};
-
-flash.geom.Matrix.prototype.concat = function () {
- var o = {}; o["Implement Matrix.concat"] ();
-};
-
-flash.geom.Matrix.prototype.createBox = function () {
- var o = {}; o["Implement Matrix.createBox"] ();
-};
-
-flash.geom.Matrix.prototype.createGradientBox = function () {
- var o = {}; o["Implement Matrix.createGradientBox"] ();
-};
-
-flash.geom.Matrix.prototype.deltaTransformPoint = function () {
- var o = {}; o["Implement Matrix.deltaTransformPoint"] ();
-};
-
-flash.geom.Matrix.prototype.identity = function () {
- var o = {}; o["Implement Matrix.identity"] ();
-};
-
-flash.geom.Matrix.prototype.invert = function () {
- var o = {}; o["Implement Matrix.invert"] ();
-};
-
-flash.geom.Matrix.prototype.rotate = function () {
- var o = {}; o["Implement Matrix.rotate"] ();
-};
-
-flash.geom.Matrix.prototype.scale = function () {
- var o = {}; o["Implement Matrix.scale"] ();
-};
-
-flash.geom.Matrix.prototype.transformPoint = function () {
- var o = {}; o["Implement Matrix.transformPoint"] ();
-};
-
-flash.geom.Matrix.prototype.translate = function () {
- var o = {}; o["Implement Matrix.translate"] ();
-};
-
-flash.geom.Matrix.prototype.toString = function () {
- var o = {}; o["Implement Matrix.toString"] ();
-};
-
-/* ColorTransform */
-
-flash.geom.ColorTransform = ASconstructor (1105, 0);
-
-flash.geom.ColorTransform.prototype.toString = function () {
- var o = {}; o["Implement ColorTransform.toString"] ();
-};
-
-ASSetNative (flash.geom.ColorTransform.prototype, 1105, "8concat", 1);
-ASSetNativeAccessor (flash.geom.ColorTransform.prototype, 1105, "8alphaMultiplier,8redMultiplier,8greenMultiplier,8blueMultiplier,8alphaOffset,8redOffset,8greenOffset,8blueOffset,8rgb", 101);
-
-/* Transform */
-
-flash.geom.Transform = ASconstructor (1106, 0);
-
-ASSetNativeAccessor (flash.geom.Transform.prototype, 1106, "8matrix,8concatenatedMatrix,8colorTransform,8concatenatedColorTransform,8pixelBounds", 101);
-
-/* BitmapData */
-
-flash.display = {};
-flash.display.BitmapData = ASconstructor (1100, 0);
-
-flash.display.BitmapData.RED_CHANNEL = 1;
-flash.display.BitmapData.GREEN_CHANNEL = 2;
-flash.display.BitmapData.BLUE_CHANNEL = 4;
-flash.display.BitmapData.ALPHA_CHANNEL = 8;
-
-ASSetNative (flash.display.BitmapData, 1100, "8loadBitmap", 40);
-
-ASSetNative (flash.display.BitmapData.prototype, 1100, "8getPixel,8setPixel,8fillRect,8copyPixels,8applyFilter,8scroll,8threshold,8draw,8pixelDissolve,8getPixel32,8setPixel32,8floodFill,8getColorBoundsRect,8perlinNoise,8colorTransform,8hitTest,8paletteMap,8merge,8noise,8copyChannel,8clone,8dispose,8generateFilterRect,8compare", 1);
-ASSetNativeAccessor(flash.display.BitmapData.prototype, 1100, "8width,8height,8rectangle,8transparent", 100);
-
-/* ExternalInterface */
-
-flash.external = {};
-
-flash.external.ExternalInterface = function () {
-};
-
-flash.external.ExternalInterface.addCallback = function (name, instance, method) {
- if (!method || !flash.external.ExternalInterface.available)
- return false;
-
- flash.external.ExternalInterface._initJS ();
- return flash.external.ExternalInterface._addCallback (name, function (request) {
- return flash.external.ExternalInterface._callIn (instance, method, request);
- });
-};
-
-flash.external.ExternalInterface.call = function (name) {
- if (!flash.external.ExternalInterface.available)
- return null;
-
- flash.external.ExternalInterface._initJS ();
- var request = "try { ";
- var id = flash.external.ExternalInterface._objectID ();
- if (id != null)
- request += id + ".SetReturnValue(";
- request += "__flash__toXML (" + name + "(";
- for (var i = 1; i < arguments.length; i++) {
- if (i > 1)
- request += ",";
- request += flash.external.ExternalInterface._toJS (arguments[i]);
- }
- request += ")) ";
- if (id != null)
- request += ")";
- request += "; } catch (e) { ";
- if (id != null) {
- request += id + ".SetReturnValue(\"<undefined/>\"); }";
- } else {
- request += "\"<undefined/>\"; }";
- }
- var result = flash.external.ExternalInterface._evalJS (request);
- if (result == null) {
- request = "<invoke name=\"" + name + "\" returntype=\"xml\">" + flash.external.ExternalInterface._argumentsToXML (arguments) + "</invoke>";
- result = flash.external.ExternalInterface._callOut (request);
- }
- if (result == null)
- return null;
-
- var xml = new XML ();
- xml.ignoreWhite = true;
- xml.parseXML (result);
- return flash.external.ExternalInterface._toAS (xml.firstChild);
-};
-
-flash.external.ExternalInterface._callIn = function (instance, method, request) {
- var xml = new XML();
- xml.ignoreWhite = true;
- xml.parseXML (request);
- var args = null;
- for (var i = 0; i < xml.firstChild.childNodes.length; i++) {
- if (xml.firstChild.childNodes[i].nodeName == "arguments") {
- args = xml.firstChild.childNodes[i];
- break;
- }
- }
- var result = method.apply (instance, flash.external.ExternalInterface._argumentsToAS (args));
- if (xml.firstChild.attributes.returntype == "javascript")
- return flash.external.ExternalInterface._toJS (result);
- else
- return flash.external.ExternalInterface._toXML (result);
-};
-
-flash.external.ExternalInterface._arrayToXML = function (array) {
- var s = "<array>";
- for (var i = 0; i < array.length; i++) {
- s += "<property id=\"" + i + "\">" + flash.external.ExternalInterface._toXML (array[i]) + "</property>";
- }
- return s + "</array>";
-};
-
-flash.external.ExternalInterface._argumentsToXML = function (args) {
- var s = "<arguments>";
- for (var i = 0; i < args.length; i++) {
- s += flash.external.ExternalInterface._toXML (args[i]);
- }
- return s + "</arguments>";
-};
-
-flash.external.ExternalInterface._objectToXML = function (obj) {
- var s = "<object>";
- for (var prop in obj) {
- s += "<property id=\"" + prop + "\">" + flash.external.ExternalInterface._toXML (obj[prop]) + "</property>";
- }
- return s + "</object>";
-};
-
-flash.external.ExternalInterface._toXML = function (value) {
- var type = typeof(value);
- if (type == "string") {
- return "<string>" + flash.external.ExternalInterface._escapeXML(value) + "</string>";
- } else if (type == "undefined") {
- return "<undefined/>";
- } else if (type == "number") {
- return "<number>" + value + "</number>";
- } else if (value == null) {
- return "<null/>";
- } else if (type == "boolean") {
- return value ? "<true/>" : "<false/>";
- } else if (value.hasOwnProperty ("length")) {
- return flash.external.ExternalInterface._arrayToXML (value);
- } else if (type == "object") {
- return flash.external.ExternalInterface._objectToXML (value);
- } else {
- return "<null/>";
- }
-};
-
-flash.external.ExternalInterface._objectToAS = function (xml) {
- var o = {};
- for (i = 0; i < xml.childNodes.length; i++) {
- if (xml.childNodes[i].nodeName == "property")
- o[xml.childNodes[i].attributes.id] = flash.external.ExternalInterface._toAS (xml.childNodes[i].firstChild);
- }
- return o;
-};
-
-flash.external.ExternalInterface._arrayToAS = function (xml) {
- var a = [];
- for (i = 0; i < xml.childNodes.length; i++) {
- if (xml.childNodes[i].nodeName == "property")
- a[xml.childNodes[i].attributes.id] = flash.external.ExternalInterface._toAS (xml.childNodes[i].firstChild);
- }
- return a;
-};
-
-flash.external.ExternalInterface._toAS = function (xml) {
- var type = xml.nodeName;
- if (type == "number") {
- return Number (xml.firstChild.toString());
- } else if (type == "string") {
- return flash.external.ExternalInterface._unescapeXML (String (xml.firstChild));
- } else if (type == "false") {
- return false;
- } else if (type == "true") {
- return true;
- } else if (type == "null") {
- return null;
- } else if (type == "undefined") {
- return undefined;
- } else if (type == "object") {
- return flash.external.ExternalInterface._objectToAS (xml);
- } else if (type == "array") {
- return flash.external.ExternalInterface._arrayToAS (xml);
- } else if (type == "class") {
- return String (xml.firstChild);
- } else {
- return undefined;
- }
-};
-
-flash.external.ExternalInterface._argumentsToAS = function (xml) {
- var args = [];
- for (var i = 0; i < xml.childNodes.length; i++) {
- args.push (flash.external.ExternalInterface._toAS (xml.childNodes [i]));
- }
- return args;
-};
-
-flash.external.ExternalInterface._arrayToJS = function (array) {
- var s = "[";
- for (var i = 0; i < array.length; i++) {
- if (i != 0)
- s += ",";
- s += flash.external.ExternalInterface._toJS (array[_l1]);
- }
- return s + "]";
-};
-
-flash.external.ExternalInterface._objectToJS = function (obj) {
- var s = "({";
- var needs_comma = false;
- for (var prop in obj) {
- if (needs_comma) {
- s += ",";
- }
- needs_comma = true;
- s += prop + ":" + flash.external.ExternalInterface._toJS (obj[prop]);
- }
- return s + "})";
-};
-
-flash.external.ExternalInterface._toJS = function (value) {
- var type = typeof (value);
- if (type == "string") {
- return "\"" + flash.external.ExternalInterface._jsQuoteString (flash.external.ExternalInterface._unescapeXML (value)) + "\"";
- } else if (type == "object") {
- if (value instanceof Array) {
- return flash.external.ExternalInterface._arrayToJS (value);
- } else {
- return flash.external.ExternalInterface._objectToJS (value);
- }
- } else {
- return String (value);
- }
-};
-
-ASSetNative (flash.external.ExternalInterface, 14, "8_initJS,8_objectID,8_addCallback,8_evalJS,8_callOut,8_escapeXML,8_unescapeXML,8_jsQuoteString");
-ASSetNativeAccessor (flash.external.ExternalInterface, 14, "8available", 100);
-
-ASSetPropFlags (flash.external.ExternalInterface, null, 4103);
-
-/* SharedObject */
-
-function SharedObject () {
-};
-
-SharedObject.deleteAll = function () {
- var o = {}; o["Implement SharedObject.deleteAll (static)"] ();
-};
-
-SharedObject.getDiskUsage = function () {
- var o = {}; o["Implement SharedObject.getDiskUsage (static)"] ();
-};
-
-SharedObject.getLocal = function () {
- var o = {}; o["Implement SharedObject.getLocal (static)"] ();
-};
-
-SharedObject.getRemote = function () {
- var o = {}; o["Implement SharedObject.getRemote (static)"] ();
-};
-
-ASSetPropFlags (SharedObject, "deleteAll,getDiskUsage", 1);
-
-ASSetNative (SharedObject.prototype, 2106, "6connect,6send,6flush,6close,6getSize,6setFps,6clear");
-ASSetPropFlags (SharedObject.prototype, null, 3);
-
-/* AsSetupError */
-
-/* This function added new Error classes in Flash player 7, in Flash player 9
- * it seems to be just broken, we just call new Error based on the number of
- * ,-characters in the given string */
-function AsSetupError (names) {
- var count = names.split (",").length;
- for (var i = 0; i < count; i++) {
- var tmp = new Error ();
- }
-}
-
-/* RemoteLSOUsage */
-
-function RemoteLSOUsage () {
-};
-
-RemoteLSOUsage.getURLPageSupport = function () {
- var o = {}; o["Implement RemoteLSOUsage.getURLPageSupport (static)"] ();
-};
-ASSetPropFlags (RemoteLSOUsage, "getURLPageSupport", 1);
-
-/* Button */
-
-Button = ASconstructor (105, 0);
-
-Button.prototype.useHandCursor = true;
-Button.prototype.enabled = true;
-
-Button.prototype.getDepth = ASnative (105, 3);
-ASSetNativeAccessor (Button.prototype, 105, "8scale9Grid,8filters,8cacheAsBitmap,8blendMode", 4);
-// FIXME: this should be done inside the Button constructor
-ASSetNativeAccessor (Button.prototype, 900, "8tabIndex", 200);
-
-/* BitmapFilter */
-
-flash.filters = {};
-
-flash.filters.BitmapFilter = ASconstructor(1112, 0);
-
-ASSetNative(flash.filters.BitmapFilter.prototype, 1112, "8clone", 1);
-
-/* BevelFilter */
-
-flash.filters.BevelFilter = ASconstructor (1107, 0);
-flash.filters.BevelFilter.prototype = new flash.filters.BitmapFilter ();
-delete flash.filters.BevelFilter.prototype.constructor;
-
-ASSetNativeAccessor (flash.filters.BevelFilter.prototype, 1107, "8distance,8angle,8highlightColor,8highlightAlpha,8shadowColor,8shadowAlpha,8quality,8strength,8knockout,8blurX,8blurY,8type", 1);
-
-/* BlurFilter */
-
-flash.filters.BlurFilter = ASconstructor (1102, 0);
-flash.filters.BlurFilter.prototype = new flash.filters.BitmapFilter ();
-delete flash.filters.BlurFilter.prototype.constructor;
-
-ASSetNativeAccessor (flash.filters.BlurFilter.prototype, 1102, "8blurX,8blurY,8quality", 1);
-
-/* ColorMatrixFilter */
-
-flash.filters.ColorMatrixFilter = ASconstructor (1110, 0);
-flash.filters.ColorMatrixFilter.prototype = new flash.filters.BitmapFilter ();
-delete flash.filters.ColorMatrixFilter.prototype.constructor;
-
-ASSetNativeAccessor (flash.filters.ColorMatrixFilter.prototype, 1110, "8matrix", 1);
-
-/* ConvolutionFilter */
-
-flash.filters.ConvolutionFilter = ASconstructor (1109, 0);
-flash.filters.ConvolutionFilter.prototype = new flash.filters.BitmapFilter ();
-delete flash.filters.ConvolutionFilter.prototype.constructor;
-
-ASSetNativeAccessor (flash.filters.ConvolutionFilter.prototype, 1109, "8matrixX,8matrixY,8matrix,8divisor,8bias,8preserveAlpha,8clamp,8color,8alpha", 1);
-
-/* DisplacementMapFilter */
-
-flash.filters.DisplacementMapFilter = ASconstructor (1111, 0);
-flash.filters.DisplacementMapFilter.prototype = new flash.filters.BitmapFilter ();
-delete flash.filters.DisplacementMapFilter.prototype.constructor;
-
-ASSetNativeAccessor (flash.filters.DisplacementMapFilter.prototype, 1111, "8mapBitmap,8mapPoint,8componentX,8componentY,8scaleX,8scaleY,8mode,8color,8alpha", 1);
-
-/* DropShadowFilter */
-
-flash.filters.DropShadowFilter = ASconstructor (1101, 0);
-flash.filters.DropShadowFilter.prototype = new flash.filters.BitmapFilter();
-delete flash.filters.DropShadowFilter.prototype.constructor;
-
-ASSetNativeAccessor (flash.filters.DropShadowFilter.prototype, 1101, "8distance,8angle,8color,8alpha,8quality,8inner,8knockout,8blurX,8blurY,8strength,8hideObject", 1);
-
-/* GlowFilter */
-
-flash.filters.GlowFilter = ASconstructor (1103, 0);
-flash.filters.GlowFilter.prototype = new flash.filters.BitmapFilter ();
-delete flash.filters.GlowFilter.prototype.constructor;
-
-ASSetNativeAccessor (flash.filters.GlowFilter.prototype, 1103, "8color,8alpha,8quality,8inner,8knockout,8blurX,8blurY,8strength", 1);
-
-/* GradientBevelFilter */
-
-flash.filters.GradientBevelFilter = ASconstructor (1108, 1000);
-flash.filters.GradientBevelFilter.prototype = new flash.filters.BitmapFilter ();
-delete flash.filters.GradientBevelFilter.prototype.constructor;
-
-ASSetNativeAccessor (flash.filters.GradientBevelFilter.prototype, 1108, "8distance,8angle,8colors,8alphas,8ratios,8blurX,8blurY,8quality,8strength,8knockout,8type", 1);
-
-/* GradientGlowFilter */
-
-flash.filters.GradientGlowFilter = ASconstructor (1108, 0);
-flash.filters.GradientGlowFilter.prototype = o = new flash.filters.BitmapFilter ();
-delete flash.filters.GradientGlowFilter.prototype.constructor;
-ASSetNativeAccessor (flash.filters.GradientGlowFilter.prototype, 1108, "8distance,8angle,8colors,8alphas,8ratios,8blurX,8blurY,8quality,8strength,8knockout,8type", 1);
-
-/* Global Functions */
-
-setInterval = ASnative (250, 0);
-clearInterval = ASnative (250, 1);
-setTimeout = ASnative(250, 2);
-clearTimeout = clearInterval;
-showRedrawRegions = ASnative (1021, 1);
-trace = ASnative (100, 4);
-updateAfterEvent = ASnative (9, 0);
-
-/*** OH THE HUMANITY ***/
-
-o = null;
-
-/*** Set propflags that would have interfered with running this script */
-
-ASSetPropFlags (this, "flash", 4096);
-ASSetPropFlags (Object, "addProperty", 128);
-ASSetPropFlags (AsBroadcaster, null, 131);
-
-/*** GLOBAL PROPFLAGS */
-
-ASSetPropFlags (this, null, 1, 6);
diff --git a/libswfdec/swfdec_initialize.h b/libswfdec/swfdec_initialize.h
deleted file mode 100644
index cc9af3c..0000000
--- a/libswfdec/swfdec_initialize.h
+++ /dev/null
@@ -1,2196 +0,0 @@
-/* This file is autogenerated, do not edit! */
-
-/* compiled from swfdec_initialize.as */
-static const unsigned char swfdec_initialize[] = {
- 0x88, 0xB3, 0x21, 0x0D, 0x02, 0x41, 0x53, 0x53, 0x65, 0x74, 0x50, 0x72, 0x6F, 0x70, 0x46, 0x6C,
- 0x61, 0x67, 0x73, 0x00, 0x41, 0x53, 0x6E, 0x61, 0x74, 0x69, 0x76, 0x65, 0x00, 0x41, 0x53, 0x53,
- 0x65, 0x74, 0x4E, 0x61, 0x74, 0x69, 0x76, 0x65, 0x00, 0x41, 0x53, 0x53, 0x65, 0x74, 0x4E, 0x61,
- 0x74, 0x69, 0x76, 0x65, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x6F, 0x72, 0x00, 0x66, 0x6C, 0x61,
- 0x73, 0x68, 0x00, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74,
- 0x65, 0x72, 0x43, 0x6C, 0x61, 0x73, 0x73, 0x00, 0x61, 0x64, 0x64, 0x50, 0x72, 0x6F, 0x70, 0x65,
- 0x72, 0x74, 0x79, 0x00, 0x6D, 0x73, 0x67, 0x00, 0x75, 0x6E, 0x64, 0x65, 0x66, 0x69, 0x6E, 0x65,
- 0x64, 0x00, 0x74, 0x68, 0x69, 0x73, 0x00, 0x6D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x00, 0x45,
- 0x72, 0x72, 0x6F, 0x72, 0x00, 0x70, 0x72, 0x6F, 0x74, 0x6F, 0x74, 0x79, 0x70, 0x65, 0x00, 0x6E,
- 0x61, 0x6D, 0x65, 0x00, 0x74, 0x6F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x41, 0x73, 0x42,
- 0x72, 0x6F, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x65, 0x72, 0x00, 0x62, 0x72, 0x6F, 0x61, 0x64,
- 0x63, 0x61, 0x73, 0x74, 0x4D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x00, 0x61, 0x64, 0x64, 0x4C,
- 0x69, 0x73, 0x74, 0x65, 0x6E, 0x65, 0x72, 0x00, 0x78, 0x00, 0x72, 0x65, 0x6D, 0x6F, 0x76, 0x65,
- 0x4C, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x65, 0x72, 0x00, 0x5F, 0x6C, 0x69, 0x73, 0x74, 0x65, 0x6E,
- 0x65, 0x72, 0x73, 0x00, 0x70, 0x75, 0x73, 0x68, 0x00, 0x6C, 0x00, 0x69, 0x00, 0x6C, 0x65, 0x6E,
- 0x67, 0x74, 0x68, 0x00, 0x73, 0x70, 0x6C, 0x69, 0x63, 0x65, 0x00, 0x69, 0x6E, 0x69, 0x74, 0x69,
- 0x61, 0x6C, 0x69, 0x7A, 0x65, 0x00, 0x6F, 0x00, 0x62, 0x72, 0x6F, 0x61, 0x64, 0x63, 0x61, 0x73,
- 0x74, 0x4D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2C, 0x61, 0x64, 0x64, 0x4C, 0x69, 0x73, 0x74,
- 0x65, 0x6E, 0x65, 0x72, 0x2C, 0x72, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x4C, 0x69, 0x73, 0x74, 0x65,
- 0x6E, 0x65, 0x72, 0x2C, 0x5F, 0x6C, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x65, 0x72, 0x73, 0x00, 0x4B,
- 0x65, 0x79, 0x00, 0x41, 0x4C, 0x54, 0x00, 0x42, 0x41, 0x43, 0x4B, 0x53, 0x50, 0x41, 0x43, 0x45,
- 0x00, 0x43, 0x41, 0x50, 0x53, 0x4C, 0x4F, 0x43, 0x4B, 0x00, 0x43, 0x4F, 0x4E, 0x54, 0x52, 0x4F,
- 0x4C, 0x00, 0x44, 0x45, 0x4C, 0x45, 0x54, 0x45, 0x4B, 0x45, 0x59, 0x00, 0x44, 0x4F, 0x57, 0x4E,
- 0x00, 0x45, 0x4E, 0x44, 0x00, 0x45, 0x4E, 0x54, 0x45, 0x52, 0x00, 0x45, 0x53, 0x43, 0x41, 0x50,
- 0x45, 0x00, 0x48, 0x4F, 0x4D, 0x45, 0x00, 0x49, 0x4E, 0x53, 0x45, 0x52, 0x54, 0x00, 0x4C, 0x45,
- 0x46, 0x54, 0x00, 0x50, 0x47, 0x44, 0x4E, 0x00, 0x50, 0x47, 0x55, 0x50, 0x00, 0x52, 0x49, 0x47,
- 0x48, 0x54, 0x00, 0x53, 0x48, 0x49, 0x46, 0x54, 0x00, 0x53, 0x50, 0x41, 0x43, 0x45, 0x00, 0x54,
- 0x41, 0x42, 0x00, 0x55, 0x50, 0x00, 0x67, 0x65, 0x74, 0x41, 0x73, 0x63, 0x69, 0x69, 0x2C, 0x67,
- 0x65, 0x74, 0x43, 0x6F, 0x64, 0x65, 0x2C, 0x69, 0x73, 0x44, 0x6F, 0x77, 0x6E, 0x2C, 0x69, 0x73,
- 0x54, 0x6F, 0x67, 0x67, 0x6C, 0x65, 0x64, 0x2C, 0x69, 0x73, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73,
- 0x69, 0x62, 0x6C, 0x65, 0x00, 0x4D, 0x6F, 0x75, 0x73, 0x65, 0x00, 0x73, 0x68, 0x6F, 0x77, 0x00,
- 0x68, 0x69, 0x64, 0x65, 0x00, 0x53, 0x74, 0x61, 0x67, 0x65, 0x00, 0x73, 0x63, 0x61, 0x6C, 0x65,
- 0x4D, 0x6F, 0x64, 0x65, 0x2C, 0x61, 0x6C, 0x69, 0x67, 0x6E, 0x2C, 0x77, 0x69, 0x64, 0x74, 0x68,
- 0x2C, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x2C, 0x73, 0x68, 0x6F, 0x77, 0x4D, 0x65, 0x6E, 0x75,
- 0x2C, 0x64, 0x69, 0x73, 0x70, 0x6C, 0x61, 0x79, 0x53, 0x74, 0x61, 0x74, 0x65, 0x00, 0x39, 0x66,
- 0x75, 0x6C, 0x6C, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6E, 0x53, 0x6F, 0x75, 0x72, 0x63, 0x65, 0x52,
- 0x65, 0x63, 0x74, 0x2C, 0x39, 0x66, 0x75, 0x6C, 0x6C, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6E, 0x48,
- 0x65, 0x69, 0x67, 0x68, 0x74, 0x2C, 0x39, 0x66, 0x75, 0x6C, 0x6C, 0x53, 0x63, 0x72, 0x65, 0x65,
- 0x6E, 0x57, 0x69, 0x64, 0x74, 0x68, 0x00, 0x4E, 0x65, 0x74, 0x43, 0x6F, 0x6E, 0x6E, 0x65, 0x63,
- 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x41, 0x53, 0x63, 0x6F, 0x6E, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74,
- 0x6F, 0x72, 0x00, 0x36, 0x63, 0x6F, 0x6E, 0x6E, 0x65, 0x63, 0x74, 0x2C, 0x36, 0x63, 0x6C, 0x6F,
- 0x73, 0x65, 0x2C, 0x36, 0x63, 0x61, 0x6C, 0x6C, 0x2C, 0x36, 0x61, 0x64, 0x64, 0x48, 0x65, 0x61,
- 0x64, 0x65, 0x72, 0x00, 0x63, 0x6F, 0x6E, 0x6E, 0x65, 0x63, 0x74, 0x65, 0x64, 0x50, 0x72, 0x6F,
- 0x78, 0x79, 0x54, 0x79, 0x70, 0x65, 0x00, 0x70, 0x72, 0x6F, 0x78, 0x79, 0x54, 0x79, 0x70, 0x65,
- 0x00, 0x6E, 0x6F, 0x6E, 0x65, 0x00, 0x75, 0x73, 0x69, 0x6E, 0x67, 0x54, 0x4C, 0x53, 0x00, 0x4E,
- 0x65, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6D, 0x00, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x73, 0x68,
- 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x4E, 0x65, 0x74, 0x53, 0x74,
- 0x72, 0x65, 0x61, 0x6D, 0x2E, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x73, 0x68, 0x00, 0x72, 0x65, 0x63,
- 0x65, 0x69, 0x76, 0x65, 0x41, 0x75, 0x64, 0x69, 0x6F, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D,
- 0x65, 0x6E, 0x74, 0x20, 0x4E, 0x65, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6D, 0x2E, 0x72, 0x65,
- 0x63, 0x65, 0x69, 0x76, 0x65, 0x41, 0x75, 0x64, 0x69, 0x6F, 0x00, 0x72, 0x65, 0x63, 0x65, 0x69,
- 0x76, 0x65, 0x56, 0x69, 0x64, 0x65, 0x6F, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E,
- 0x74, 0x20, 0x4E, 0x65, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6D, 0x2E, 0x72, 0x65, 0x63, 0x65,
- 0x69, 0x76, 0x65, 0x56, 0x69, 0x64, 0x65, 0x6F, 0x00, 0x36, 0x63, 0x6C, 0x6F, 0x73, 0x65, 0x2C,
- 0x36, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x41, 0x75, 0x64, 0x69, 0x6F, 0x2C, 0x36, 0x61, 0x74,
- 0x74, 0x61, 0x63, 0x68, 0x56, 0x69, 0x64, 0x65, 0x6F, 0x2C, 0x36, 0x73, 0x65, 0x6E, 0x64, 0x2C,
- 0x36, 0x73, 0x65, 0x74, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x54, 0x69, 0x6D, 0x65, 0x00, 0x63,
- 0x68, 0x65, 0x63, 0x6B, 0x50, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x46, 0x69, 0x6C, 0x65, 0x00, 0x4C,
- 0x6F, 0x61, 0x64, 0x56, 0x61, 0x72, 0x73, 0x00, 0x63, 0x6F, 0x6E, 0x74, 0x65, 0x6E, 0x74, 0x54,
- 0x79, 0x70, 0x65, 0x00, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2F,
- 0x78, 0x2D, 0x77, 0x77, 0x77, 0x2D, 0x66, 0x6F, 0x72, 0x6D, 0x2D, 0x75, 0x72, 0x6C, 0x65, 0x6E,
- 0x63, 0x6F, 0x64, 0x65, 0x64, 0x00, 0x6C, 0x6F, 0x61, 0x64, 0x00, 0x73, 0x65, 0x6E, 0x64, 0x00,
- 0x73, 0x65, 0x6E, 0x64, 0x41, 0x6E, 0x64, 0x4C, 0x6F, 0x61, 0x64, 0x00, 0x64, 0x65, 0x63, 0x6F,
- 0x64, 0x65, 0x00, 0x6F, 0x6E, 0x4C, 0x6F, 0x61, 0x64, 0x00, 0x6F, 0x6E, 0x44, 0x61, 0x74, 0x61,
- 0x00, 0x6C, 0x6F, 0x61, 0x64, 0x65, 0x64, 0x00, 0x73, 0x72, 0x63, 0x00, 0x73, 0x74, 0x72, 0x00,
- 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x00, 0x3D, 0x00, 0x26, 0x00, 0x67, 0x65, 0x74, 0x42, 0x79,
- 0x74, 0x65, 0x73, 0x4C, 0x6F, 0x61, 0x64, 0x65, 0x64, 0x00, 0x5F, 0x62, 0x79, 0x74, 0x65, 0x73,
- 0x4C, 0x6F, 0x61, 0x64, 0x65, 0x64, 0x00, 0x67, 0x65, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x54,
- 0x6F, 0x74, 0x61, 0x6C, 0x00, 0x5F, 0x62, 0x79, 0x74, 0x65, 0x73, 0x54, 0x6F, 0x74, 0x61, 0x6C,
- 0x00, 0x61, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65,
- 0x72, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x4C, 0x6F, 0x61, 0x64,
- 0x56, 0x61, 0x72, 0x73, 0x2E, 0x61, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48,
- 0x65, 0x61, 0x64, 0x65, 0x72, 0x00, 0x53, 0x6F, 0x75, 0x6E, 0x64, 0x00, 0x67, 0x65, 0x74, 0x50,
- 0x61, 0x6E, 0x2C, 0x67, 0x65, 0x74, 0x54, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x2C,
- 0x67, 0x65, 0x74, 0x56, 0x6F, 0x6C, 0x75, 0x6D, 0x65, 0x2C, 0x73, 0x65, 0x74, 0x50, 0x61, 0x6E,
- 0x2C, 0x73, 0x65, 0x74, 0x54, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x2C, 0x73, 0x65,
- 0x74, 0x56, 0x6F, 0x6C, 0x75, 0x6D, 0x65, 0x2C, 0x73, 0x74, 0x6F, 0x70, 0x2C, 0x61, 0x74, 0x74,
- 0x61, 0x63, 0x68, 0x53, 0x6F, 0x75, 0x6E, 0x64, 0x2C, 0x73, 0x74, 0x61, 0x72, 0x74, 0x2C, 0x36,
- 0x67, 0x65, 0x74, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2C, 0x36, 0x73, 0x65, 0x74,
- 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2C, 0x36, 0x67, 0x65, 0x74, 0x50, 0x6F, 0x73,
- 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x50, 0x6F, 0x73, 0x69, 0x74, 0x69,
- 0x6F, 0x6E, 0x2C, 0x36, 0x6C, 0x6F, 0x61, 0x64, 0x53, 0x6F, 0x75, 0x6E, 0x64, 0x2C, 0x36, 0x67,
- 0x65, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x4C, 0x6F, 0x61, 0x64, 0x65, 0x64, 0x2C, 0x36, 0x67,
- 0x65, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x54, 0x6F, 0x74, 0x61, 0x6C, 0x2C, 0x39, 0x61, 0x72,
- 0x65, 0x53, 0x6F, 0x75, 0x6E, 0x64, 0x73, 0x49, 0x6E, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69,
- 0x62, 0x6C, 0x65, 0x00, 0x58, 0x4D, 0x4C, 0x4E, 0x6F, 0x64, 0x65, 0x00, 0x63, 0x6C, 0x6F, 0x6E,
- 0x65, 0x4E, 0x6F, 0x64, 0x65, 0x00, 0x72, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x4E, 0x6F, 0x64, 0x65,
- 0x00, 0x69, 0x6E, 0x73, 0x65, 0x72, 0x74, 0x42, 0x65, 0x66, 0x6F, 0x72, 0x65, 0x00, 0x61, 0x70,
- 0x70, 0x65, 0x6E, 0x64, 0x43, 0x68, 0x69, 0x6C, 0x64, 0x00, 0x68, 0x61, 0x73, 0x43, 0x68, 0x69,
- 0x6C, 0x64, 0x4E, 0x6F, 0x64, 0x65, 0x73, 0x00, 0x67, 0x65, 0x74, 0x4E, 0x61, 0x6D, 0x65, 0x73,
- 0x70, 0x61, 0x63, 0x65, 0x46, 0x6F, 0x72, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x00, 0x67, 0x65,
- 0x74, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x46, 0x6F, 0x72, 0x4E, 0x61, 0x6D, 0x65, 0x73, 0x70,
- 0x61, 0x63, 0x65, 0x00, 0x58, 0x4D, 0x4C, 0x00, 0x00, 0x63, 0x6F, 0x6E, 0x73, 0x74, 0x72, 0x75,
- 0x63, 0x74, 0x6F, 0x72, 0x00, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x6C, 0x65, 0x6D, 0x65,
- 0x6E, 0x74, 0x00, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, 0x78, 0x74, 0x4E, 0x6F, 0x64,
- 0x65, 0x00, 0x70, 0x61, 0x72, 0x73, 0x65, 0x58, 0x4D, 0x4C, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65,
- 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x58, 0x4D, 0x4C, 0x2E, 0x61, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75,
- 0x65, 0x73, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x00, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D,
- 0x00, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6C, 0x69, 0x74, 0x69, 0x65, 0x73, 0x00, 0x51, 0x75,
- 0x65, 0x72, 0x79, 0x00, 0x73, 0x65, 0x74, 0x43, 0x6C, 0x69, 0x70, 0x62, 0x6F, 0x61, 0x72, 0x64,
- 0x00, 0x73, 0x68, 0x6F, 0x77, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6E, 0x67, 0x73, 0x00, 0x65, 0x78,
- 0x61, 0x63, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6E, 0x67, 0x73, 0x2C, 0x75, 0x73, 0x65, 0x43,
- 0x6F, 0x64, 0x65, 0x70, 0x61, 0x67, 0x65, 0x00, 0x65, 0x78, 0x61, 0x63, 0x74, 0x53, 0x65, 0x74,
- 0x74, 0x69, 0x6E, 0x67, 0x73, 0x2C, 0x75, 0x73, 0x65, 0x43, 0x6F, 0x64, 0x65, 0x50, 0x61, 0x67,
- 0x65, 0x00, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x00, 0x61, 0x6C, 0x6C, 0x6F, 0x77,
- 0x44, 0x6F, 0x6D, 0x61, 0x69, 0x6E, 0x2C, 0x37, 0x61, 0x6C, 0x6C, 0x6F, 0x77, 0x49, 0x6E, 0x73,
- 0x65, 0x63, 0x75, 0x72, 0x65, 0x44, 0x6F, 0x6D, 0x61, 0x69, 0x6E, 0x2C, 0x6C, 0x6F, 0x61, 0x64,
- 0x50, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x46, 0x69, 0x6C, 0x65, 0x2C, 0x63, 0x68, 0x6F, 0x6F, 0x73,
- 0x65, 0x4C, 0x6F, 0x63, 0x61, 0x6C, 0x53, 0x77, 0x66, 0x50, 0x61, 0x74, 0x68, 0x2C, 0x65, 0x73,
- 0x63, 0x61, 0x70, 0x65, 0x44, 0x6F, 0x6D, 0x61, 0x69, 0x6E, 0x00, 0x73, 0x61, 0x6E, 0x64, 0x62,
- 0x6F, 0x78, 0x54, 0x79, 0x70, 0x65, 0x00, 0x50, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x46, 0x69, 0x6C,
- 0x65, 0x52, 0x65, 0x73, 0x6F, 0x6C, 0x76, 0x65, 0x72, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D,
- 0x65, 0x6E, 0x74, 0x20, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x73, 0x65, 0x63, 0x75, 0x72,
- 0x69, 0x74, 0x79, 0x2E, 0x50, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x46, 0x69, 0x6C, 0x65, 0x52, 0x65,
- 0x73, 0x6F, 0x6C, 0x76, 0x65, 0x72, 0x00, 0x72, 0x65, 0x73, 0x6F, 0x6C, 0x76, 0x65, 0x00, 0x50,
- 0x72, 0x6F, 0x64, 0x75, 0x63, 0x74, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74,
- 0x20, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x50, 0x72, 0x6F, 0x64, 0x75, 0x63, 0x74, 0x00,
- 0x69, 0x73, 0x52, 0x75, 0x6E, 0x6E, 0x69, 0x6E, 0x67, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D,
- 0x65, 0x6E, 0x74, 0x20, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x50, 0x72, 0x6F, 0x64, 0x75,
- 0x63, 0x74, 0x2E, 0x69, 0x73, 0x52, 0x75, 0x6E, 0x6E, 0x69, 0x6E, 0x67, 0x00, 0x69, 0x73, 0x49,
- 0x6E, 0x73, 0x74, 0x61, 0x6C, 0x6C, 0x65, 0x64, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65,
- 0x6E, 0x74, 0x20, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x50, 0x72, 0x6F, 0x64, 0x75, 0x63,
- 0x74, 0x2E, 0x69, 0x73, 0x49, 0x6E, 0x73, 0x74, 0x61, 0x6C, 0x6C, 0x65, 0x64, 0x00, 0x6C, 0x61,
- 0x75, 0x6E, 0x63, 0x68, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53,
- 0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x50, 0x72, 0x6F, 0x64, 0x75, 0x63, 0x74, 0x2E, 0x6C, 0x61,
- 0x75, 0x6E, 0x63, 0x68, 0x00, 0x64, 0x6F, 0x77, 0x6E, 0x6C, 0x6F, 0x61, 0x64, 0x00, 0x49, 0x6D,
- 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x50,
- 0x72, 0x6F, 0x64, 0x75, 0x63, 0x74, 0x2E, 0x64, 0x6F, 0x77, 0x6E, 0x6C, 0x6F, 0x61, 0x64, 0x00,
- 0x69, 0x6E, 0x73, 0x74, 0x61, 0x6C, 0x6C, 0x65, 0x64, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E,
- 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53, 0x79, 0x73, 0x74, 0x65,
- 0x6D, 0x2E, 0x50, 0x72, 0x6F, 0x64, 0x75, 0x63, 0x74, 0x2E, 0x69, 0x6E, 0x73, 0x74, 0x61, 0x6C,
- 0x6C, 0x65, 0x64, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x00, 0x76, 0x61, 0x6C, 0x69, 0x64,
- 0x61, 0x74, 0x65, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53, 0x79,
- 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x50, 0x72, 0x6F, 0x64, 0x75, 0x63, 0x74, 0x2E, 0x76, 0x61, 0x6C,
- 0x69, 0x64, 0x61, 0x74, 0x65, 0x00, 0x49, 0x4D, 0x45, 0x00, 0x41, 0x4C, 0x50, 0x48, 0x41, 0x4E,
- 0x55, 0x4D, 0x45, 0x52, 0x49, 0x43, 0x5F, 0x46, 0x55, 0x4C, 0x4C, 0x00, 0x41, 0x4C, 0x50, 0x48,
- 0x41, 0x4E, 0x55, 0x4D, 0x45, 0x52, 0x49, 0x43, 0x5F, 0x48, 0x41, 0x4C, 0x46, 0x00, 0x43, 0x48,
- 0x49, 0x4E, 0x45, 0x53, 0x45, 0x00, 0x4A, 0x41, 0x50, 0x41, 0x4E, 0x45, 0x53, 0x45, 0x5F, 0x48,
- 0x49, 0x52, 0x41, 0x47, 0x41, 0x4E, 0x41, 0x00, 0x4A, 0x41, 0x50, 0x41, 0x4E, 0x45, 0x53, 0x45,
- 0x5F, 0x4B, 0x41, 0x54, 0x41, 0x4B, 0x41, 0x4E, 0x41, 0x5F, 0x46, 0x55, 0x4C, 0x4C, 0x00, 0x4A,
- 0x41, 0x50, 0x41, 0x4E, 0x45, 0x53, 0x45, 0x5F, 0x4B, 0x41, 0x54, 0x41, 0x4B, 0x41, 0x4E, 0x41,
- 0x5F, 0x48, 0x41, 0x4C, 0x46, 0x00, 0x4B, 0x4F, 0x52, 0x45, 0x41, 0x4E, 0x00, 0x55, 0x4E, 0x4B,
- 0x4E, 0x4F, 0x57, 0x4E, 0x00, 0x38, 0x67, 0x65, 0x74, 0x45, 0x6E, 0x61, 0x62, 0x6C, 0x65, 0x64,
- 0x2C, 0x38, 0x73, 0x65, 0x74, 0x45, 0x6E, 0x61, 0x62, 0x6C, 0x65, 0x64, 0x2C, 0x38, 0x67, 0x65,
- 0x74, 0x43, 0x6F, 0x6E, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x4D, 0x6F, 0x64, 0x65, 0x2C,
- 0x38, 0x73, 0x65, 0x74, 0x43, 0x6F, 0x6E, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x4D, 0x6F,
- 0x64, 0x65, 0x2C, 0x38, 0x73, 0x65, 0x74, 0x43, 0x6F, 0x6D, 0x70, 0x6F, 0x73, 0x69, 0x74, 0x69,
- 0x6F, 0x6E, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x2C, 0x38, 0x64, 0x6F, 0x43, 0x6F, 0x6E, 0x76,
- 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x00, 0x43, 0x6F, 0x6C, 0x6F, 0x72, 0x00, 0x74, 0x61, 0x72,
- 0x67, 0x65, 0x74, 0x00, 0x73, 0x65, 0x74, 0x52, 0x47, 0x42, 0x2C, 0x73, 0x65, 0x74, 0x54, 0x72,
- 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x2C, 0x67, 0x65, 0x74, 0x52, 0x47, 0x42, 0x2C, 0x67,
- 0x65, 0x74, 0x54, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x00, 0x54, 0x65, 0x78, 0x74,
- 0x53, 0x6E, 0x61, 0x70, 0x73, 0x68, 0x6F, 0x74, 0x00, 0x36, 0x67, 0x65, 0x74, 0x43, 0x6F, 0x75,
- 0x6E, 0x74, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x53, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x65, 0x64, 0x2C,
- 0x36, 0x67, 0x65, 0x74, 0x53, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x65, 0x64, 0x2C, 0x36, 0x67, 0x65,
- 0x74, 0x54, 0x65, 0x78, 0x74, 0x2C, 0x36, 0x67, 0x65, 0x74, 0x53, 0x65, 0x6C, 0x65, 0x63, 0x74,
- 0x65, 0x64, 0x54, 0x65, 0x78, 0x74, 0x2C, 0x36, 0x68, 0x69, 0x74, 0x54, 0x65, 0x73, 0x74, 0x54,
- 0x65, 0x78, 0x74, 0x4E, 0x65, 0x61, 0x72, 0x50, 0x6F, 0x73, 0x2C, 0x36, 0x66, 0x69, 0x6E, 0x64,
- 0x54, 0x65, 0x78, 0x74, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x53, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x43,
- 0x6F, 0x6C, 0x6F, 0x72, 0x2C, 0x36, 0x67, 0x65, 0x74, 0x54, 0x65, 0x78, 0x74, 0x52, 0x75, 0x6E,
- 0x49, 0x6E, 0x66, 0x6F, 0x00, 0x4D, 0x6F, 0x76, 0x69, 0x65, 0x43, 0x6C, 0x69, 0x70, 0x00, 0x75,
- 0x73, 0x65, 0x48, 0x61, 0x6E, 0x64, 0x43, 0x75, 0x72, 0x73, 0x6F, 0x72, 0x00, 0x65, 0x6E, 0x61,
- 0x62, 0x6C, 0x65, 0x64, 0x00, 0x6D, 0x65, 0x74, 0x68, 0x00, 0x6D, 0x65, 0x74, 0x68, 0x6F, 0x64,
- 0x00, 0x74, 0x6F, 0x4C, 0x6F, 0x77, 0x65, 0x72, 0x43, 0x61, 0x73, 0x65, 0x00, 0x6C, 0x6F, 0x77,
- 0x65, 0x72, 0x00, 0x70, 0x6F, 0x73, 0x74, 0x00, 0x67, 0x65, 0x74, 0x00, 0x67, 0x65, 0x74, 0x55,
- 0x52, 0x4C, 0x00, 0x74, 0x79, 0x70, 0x65, 0x00, 0x75, 0x72, 0x6C, 0x00, 0x6C, 0x6F, 0x61, 0x64,
- 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6C, 0x65, 0x73, 0x00, 0x5F, 0x74, 0x61, 0x72, 0x67, 0x65,
- 0x74, 0x00, 0x6C, 0x6F, 0x61, 0x64, 0x4D, 0x6F, 0x76, 0x69, 0x65, 0x00, 0x75, 0x6E, 0x6C, 0x6F,
- 0x61, 0x64, 0x4D, 0x6F, 0x76, 0x69, 0x65, 0x00, 0x67, 0x65, 0x74, 0x54, 0x65, 0x78, 0x74, 0x53,
- 0x6E, 0x61, 0x70, 0x73, 0x68, 0x6F, 0x74, 0x00, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x4D, 0x6F,
- 0x76, 0x69, 0x65, 0x2C, 0x73, 0x77, 0x61, 0x70, 0x44, 0x65, 0x70, 0x74, 0x68, 0x73, 0x2C, 0x6C,
- 0x6F, 0x63, 0x61, 0x6C, 0x54, 0x6F, 0x47, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x2C, 0x67, 0x6C, 0x6F,
- 0x62, 0x61, 0x6C, 0x54, 0x6F, 0x4C, 0x6F, 0x63, 0x61, 0x6C, 0x2C, 0x68, 0x69, 0x74, 0x54, 0x65,
- 0x73, 0x74, 0x2C, 0x67, 0x65, 0x74, 0x42, 0x6F, 0x75, 0x6E, 0x64, 0x73, 0x2C, 0x67, 0x65, 0x74,
- 0x42, 0x79, 0x74, 0x65, 0x73, 0x54, 0x6F, 0x74, 0x61, 0x6C, 0x2C, 0x67, 0x65, 0x74, 0x42, 0x79,
- 0x74, 0x65, 0x73, 0x4C, 0x6F, 0x61, 0x64, 0x65, 0x64, 0x2C, 0x36, 0x61, 0x74, 0x74, 0x61, 0x63,
- 0x68, 0x41, 0x75, 0x64, 0x69, 0x6F, 0x2C, 0x36, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x56, 0x69,
- 0x64, 0x65, 0x6F, 0x2C, 0x36, 0x67, 0x65, 0x74, 0x44, 0x65, 0x70, 0x74, 0x68, 0x2C, 0x36, 0x73,
- 0x65, 0x74, 0x4D, 0x61, 0x73, 0x6B, 0x2C, 0x70, 0x6C, 0x61, 0x79, 0x2C, 0x73, 0x74, 0x6F, 0x70,
- 0x2C, 0x6E, 0x65, 0x78, 0x74, 0x46, 0x72, 0x61, 0x6D, 0x65, 0x2C, 0x70, 0x72, 0x65, 0x76, 0x46,
- 0x72, 0x61, 0x6D, 0x65, 0x2C, 0x67, 0x6F, 0x74, 0x6F, 0x41, 0x6E, 0x64, 0x50, 0x6C, 0x61, 0x79,
- 0x2C, 0x67, 0x6F, 0x74, 0x6F, 0x41, 0x6E, 0x64, 0x53, 0x74, 0x6F, 0x70, 0x2C, 0x64, 0x75, 0x70,
- 0x6C, 0x69, 0x63, 0x61, 0x74, 0x65, 0x4D, 0x6F, 0x76, 0x69, 0x65, 0x43, 0x6C, 0x69, 0x70, 0x2C,
- 0x72, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x4D, 0x6F, 0x76, 0x69, 0x65, 0x43, 0x6C, 0x69, 0x70, 0x2C,
- 0x73, 0x74, 0x61, 0x72, 0x74, 0x44, 0x72, 0x61, 0x67, 0x2C, 0x73, 0x74, 0x6F, 0x70, 0x44, 0x72,
- 0x61, 0x67, 0x2C, 0x37, 0x67, 0x65, 0x74, 0x4E, 0x65, 0x78, 0x74, 0x48, 0x69, 0x67, 0x68, 0x65,
- 0x73, 0x74, 0x44, 0x65, 0x70, 0x74, 0x68, 0x2C, 0x37, 0x67, 0x65, 0x74, 0x49, 0x6E, 0x73, 0x74,
- 0x61, 0x6E, 0x63, 0x65, 0x41, 0x74, 0x44, 0x65, 0x70, 0x74, 0x68, 0x2C, 0x67, 0x65, 0x74, 0x53,
- 0x57, 0x46, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x2C, 0x38, 0x61, 0x74, 0x74, 0x61, 0x63,
- 0x68, 0x42, 0x69, 0x74, 0x6D, 0x61, 0x70, 0x2C, 0x38, 0x67, 0x65, 0x74, 0x52, 0x65, 0x63, 0x74,
- 0x00, 0x74, 0x61, 0x62, 0x49, 0x6E, 0x64, 0x65, 0x78, 0x00, 0x5F, 0x6C, 0x6F, 0x63, 0x6B, 0x72,
- 0x6F, 0x6F, 0x74, 0x00, 0x38, 0x63, 0x61, 0x63, 0x68, 0x65, 0x41, 0x73, 0x42, 0x69, 0x74, 0x6D,
- 0x61, 0x70, 0x2C, 0x38, 0x6F, 0x70, 0x61, 0x71, 0x75, 0x65, 0x42, 0x61, 0x63, 0x6B, 0x67, 0x72,
- 0x6F, 0x75, 0x6E, 0x64, 0x2C, 0x38, 0x73, 0x63, 0x72, 0x6F, 0x6C, 0x6C, 0x52, 0x65, 0x63, 0x74,
- 0x00, 0x38, 0x66, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x73, 0x2C, 0x38, 0x74, 0x72, 0x61, 0x6E, 0x73,
- 0x66, 0x6F, 0x72, 0x6D, 0x00, 0x38, 0x62, 0x6C, 0x65, 0x6E, 0x64, 0x4D, 0x6F, 0x64, 0x65, 0x00,
- 0x36, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x6D, 0x70, 0x74, 0x79, 0x4D, 0x6F, 0x76, 0x69,
- 0x65, 0x43, 0x6C, 0x69, 0x70, 0x2C, 0x36, 0x62, 0x65, 0x67, 0x69, 0x6E, 0x46, 0x69, 0x6C, 0x6C,
- 0x2C, 0x36, 0x62, 0x65, 0x67, 0x69, 0x6E, 0x47, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6E, 0x74, 0x46,
- 0x69, 0x6C, 0x6C, 0x2C, 0x36, 0x6D, 0x6F, 0x76, 0x65, 0x54, 0x6F, 0x2C, 0x36, 0x6C, 0x69, 0x6E,
- 0x65, 0x54, 0x6F, 0x2C, 0x36, 0x63, 0x75, 0x72, 0x76, 0x65, 0x54, 0x6F, 0x2C, 0x36, 0x6C, 0x69,
- 0x6E, 0x65, 0x53, 0x74, 0x79, 0x6C, 0x65, 0x2C, 0x36, 0x65, 0x6E, 0x64, 0x46, 0x69, 0x6C, 0x6C,
- 0x2C, 0x36, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x2C, 0x38, 0x6C, 0x69, 0x6E, 0x65, 0x47, 0x72, 0x61,
- 0x64, 0x69, 0x65, 0x6E, 0x74, 0x53, 0x74, 0x79, 0x6C, 0x65, 0x2C, 0x38, 0x62, 0x65, 0x67, 0x69,
- 0x6E, 0x4D, 0x65, 0x73, 0x68, 0x46, 0x69, 0x6C, 0x6C, 0x2C, 0x38, 0x62, 0x65, 0x67, 0x69, 0x6E,
- 0x42, 0x69, 0x74, 0x6D, 0x61, 0x70, 0x46, 0x69, 0x6C, 0x6C, 0x00, 0x38, 0x73, 0x63, 0x61, 0x6C,
- 0x65, 0x39, 0x47, 0x72, 0x69, 0x64, 0x00, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, 0x78,
- 0x74, 0x46, 0x69, 0x65, 0x6C, 0x64, 0x00, 0x4D, 0x6F, 0x76, 0x69, 0x65, 0x43, 0x6C, 0x69, 0x70,
- 0x4C, 0x6F, 0x61, 0x64, 0x65, 0x72, 0x00, 0x37, 0x6C, 0x6F, 0x61, 0x64, 0x43, 0x6C, 0x69, 0x70,
- 0x2C, 0x37, 0x67, 0x65, 0x74, 0x50, 0x72, 0x6F, 0x67, 0x72, 0x65, 0x73, 0x73, 0x2C, 0x37, 0x75,
- 0x6E, 0x6C, 0x6F, 0x61, 0x64, 0x43, 0x6C, 0x69, 0x70, 0x00, 0x54, 0x65, 0x78, 0x74, 0x46, 0x69,
- 0x65, 0x6C, 0x64, 0x00, 0x67, 0x65, 0x74, 0x46, 0x6F, 0x6E, 0x74, 0x4C, 0x69, 0x73, 0x74, 0x00,
- 0x36, 0x72, 0x65, 0x70, 0x6C, 0x61, 0x63, 0x65, 0x53, 0x65, 0x6C, 0x2C, 0x36, 0x67, 0x65, 0x74,
- 0x54, 0x65, 0x78, 0x74, 0x46, 0x6F, 0x72, 0x6D, 0x61, 0x74, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x54,
- 0x65, 0x78, 0x74, 0x46, 0x6F, 0x72, 0x6D, 0x61, 0x74, 0x2C, 0x36, 0x72, 0x65, 0x6D, 0x6F, 0x76,
- 0x65, 0x54, 0x65, 0x78, 0x74, 0x46, 0x69, 0x65, 0x6C, 0x64, 0x2C, 0x36, 0x67, 0x65, 0x74, 0x4E,
- 0x65, 0x77, 0x54, 0x65, 0x78, 0x74, 0x46, 0x6F, 0x72, 0x6D, 0x61, 0x74, 0x2C, 0x36, 0x73, 0x65,
- 0x74, 0x4E, 0x65, 0x77, 0x54, 0x65, 0x78, 0x74, 0x46, 0x6F, 0x72, 0x6D, 0x61, 0x74, 0x2C, 0x36,
- 0x67, 0x65, 0x74, 0x44, 0x65, 0x70, 0x74, 0x68, 0x2C, 0x37, 0x72, 0x65, 0x70, 0x6C, 0x61, 0x63,
- 0x65, 0x54, 0x65, 0x78, 0x74, 0x00, 0x38, 0x67, 0x72, 0x69, 0x64, 0x46, 0x69, 0x74, 0x54, 0x79,
- 0x70, 0x65, 0x2C, 0x38, 0x61, 0x6E, 0x74, 0x69, 0x41, 0x6C, 0x69, 0x61, 0x73, 0x54, 0x79, 0x70,
- 0x65, 0x2C, 0x38, 0x74, 0x68, 0x69, 0x63, 0x6B, 0x6E, 0x65, 0x73, 0x73, 0x2C, 0x38, 0x73, 0x68,
- 0x61, 0x72, 0x70, 0x6E, 0x65, 0x73, 0x73, 0x2C, 0x38, 0x66, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x73,
- 0x00, 0x38, 0x74, 0x61, 0x62, 0x49, 0x6E, 0x64, 0x65, 0x78, 0x00, 0x54, 0x65, 0x78, 0x74, 0x46,
- 0x6F, 0x72, 0x6D, 0x61, 0x74, 0x00, 0x53, 0x74, 0x79, 0x6C, 0x65, 0x53, 0x68, 0x65, 0x65, 0x74,
- 0x00, 0x5F, 0x63, 0x6F, 0x70, 0x79, 0x00, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x6F, 0x5F,
- 0x6E, 0x65, 0x77, 0x00, 0x70, 0x72, 0x6F, 0x70, 0x00, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x00, 0x5F,
- 0x63, 0x73, 0x73, 0x00, 0x5F, 0x73, 0x74, 0x79, 0x6C, 0x65, 0x73, 0x00, 0x75, 0x70, 0x64, 0x61,
- 0x74, 0x65, 0x00, 0x67, 0x65, 0x74, 0x53, 0x74, 0x79, 0x6C, 0x65, 0x00, 0x73, 0x65, 0x74, 0x53,
- 0x74, 0x79, 0x6C, 0x65, 0x00, 0x73, 0x74, 0x79, 0x6C, 0x65, 0x00, 0x64, 0x6F, 0x54, 0x72, 0x61,
- 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x00, 0x67, 0x65, 0x74, 0x53, 0x74, 0x79, 0x6C, 0x65, 0x4E,
- 0x61, 0x6D, 0x65, 0x73, 0x00, 0x74, 0x6D, 0x70, 0x00, 0x6E, 0x61, 0x6D, 0x65, 0x73, 0x00, 0x74,
- 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x00, 0x66, 0x6F, 0x72, 0x6D, 0x61, 0x74, 0x00,
- 0x74, 0x65, 0x78, 0x74, 0x41, 0x6C, 0x69, 0x67, 0x6E, 0x00, 0x61, 0x6C, 0x69, 0x67, 0x6E, 0x00,
- 0x66, 0x6F, 0x6E, 0x74, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x00, 0x62, 0x6F, 0x6C, 0x64, 0x00,
- 0x6E, 0x6F, 0x72, 0x6D, 0x61, 0x6C, 0x00, 0x63, 0x6F, 0x6C, 0x6F, 0x72, 0x00, 0x70, 0x61, 0x72,
- 0x73, 0x65, 0x43, 0x6F, 0x6C, 0x6F, 0x72, 0x00, 0x64, 0x69, 0x73, 0x70, 0x6C, 0x61, 0x79, 0x00,
- 0x66, 0x6F, 0x6E, 0x74, 0x46, 0x61, 0x6D, 0x69, 0x6C, 0x79, 0x00, 0x66, 0x6F, 0x6E, 0x74, 0x00,
- 0x70, 0x61, 0x72, 0x73, 0x65, 0x43, 0x53, 0x53, 0x46, 0x6F, 0x6E, 0x74, 0x46, 0x61, 0x6D, 0x69,
- 0x6C, 0x79, 0x00, 0x74, 0x65, 0x78, 0x74, 0x49, 0x6E, 0x64, 0x65, 0x6E, 0x74, 0x00, 0x69, 0x6E,
- 0x64, 0x65, 0x6E, 0x74, 0x00, 0x70, 0x61, 0x72, 0x73, 0x65, 0x49, 0x6E, 0x74, 0x00, 0x66, 0x6F,
- 0x6E, 0x74, 0x53, 0x74, 0x79, 0x6C, 0x65, 0x00, 0x69, 0x74, 0x61, 0x6C, 0x69, 0x63, 0x00, 0x6B,
- 0x65, 0x72, 0x6E, 0x69, 0x6E, 0x67, 0x00, 0x74, 0x72, 0x75, 0x65, 0x00, 0x66, 0x61, 0x6C, 0x73,
- 0x65, 0x00, 0x6C, 0x65, 0x61, 0x64, 0x69, 0x6E, 0x67, 0x00, 0x6D, 0x61, 0x72, 0x67, 0x69, 0x6E,
- 0x4C, 0x65, 0x66, 0x74, 0x00, 0x6C, 0x65, 0x66, 0x74, 0x4D, 0x61, 0x72, 0x67, 0x69, 0x6E, 0x00,
- 0x6C, 0x65, 0x74, 0x74, 0x65, 0x72, 0x53, 0x70, 0x61, 0x63, 0x69, 0x6E, 0x67, 0x00, 0x6D, 0x61,
- 0x72, 0x67, 0x69, 0x6E, 0x52, 0x69, 0x67, 0x68, 0x74, 0x00, 0x72, 0x69, 0x67, 0x68, 0x74, 0x4D,
- 0x61, 0x72, 0x67, 0x69, 0x6E, 0x00, 0x66, 0x6F, 0x6E, 0x74, 0x53, 0x69, 0x7A, 0x65, 0x00, 0x73,
- 0x69, 0x7A, 0x65, 0x00, 0x74, 0x65, 0x78, 0x74, 0x44, 0x65, 0x63, 0x6F, 0x72, 0x61, 0x74, 0x69,
- 0x6F, 0x6E, 0x00, 0x75, 0x6E, 0x64, 0x65, 0x72, 0x6C, 0x69, 0x6E, 0x65, 0x00, 0x70, 0x61, 0x72,
- 0x73, 0x65, 0x43, 0x53, 0x53, 0x00, 0x63, 0x73, 0x73, 0x00, 0x70, 0x61, 0x72, 0x73, 0x65, 0x43,
- 0x53, 0x53, 0x49, 0x6E, 0x74, 0x65, 0x72, 0x6E, 0x61, 0x6C, 0x00, 0x72, 0x65, 0x73, 0x75, 0x6C,
- 0x74, 0x00, 0x6E, 0x75, 0x6C, 0x6C, 0x00, 0x70, 0x61, 0x72, 0x73, 0x65, 0x00, 0x37, 0x75, 0x70,
- 0x64, 0x61, 0x74, 0x65, 0x2C, 0x37, 0x70, 0x61, 0x72, 0x73, 0x65, 0x43, 0x53, 0x53, 0x49, 0x6E,
- 0x74, 0x65, 0x72, 0x6E, 0x61, 0x6C, 0x2C, 0x37, 0x70, 0x61, 0x72, 0x73, 0x65, 0x43, 0x53, 0x53,
- 0x46, 0x6F, 0x6E, 0x74, 0x46, 0x61, 0x6D, 0x69, 0x6C, 0x79, 0x2C, 0x37, 0x70, 0x61, 0x72, 0x73,
- 0x65, 0x43, 0x6F, 0x6C, 0x6F, 0x72, 0x00, 0x56, 0x69, 0x64, 0x65, 0x6F, 0x00, 0x36, 0x61, 0x74,
- 0x74, 0x61, 0x63, 0x68, 0x56, 0x69, 0x64, 0x65, 0x6F, 0x2C, 0x36, 0x63, 0x6C, 0x65, 0x61, 0x72,
- 0x00, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x62, 0x69, 0x6C, 0x69, 0x74, 0x79, 0x00, 0x36,
- 0x69, 0x73, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x2C, 0x36, 0x73, 0x65, 0x6E, 0x64, 0x45, 0x76,
- 0x65, 0x6E, 0x74, 0x2C, 0x36, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6F, 0x70, 0x65,
- 0x72, 0x74, 0x69, 0x65, 0x73, 0x00, 0x43, 0x61, 0x6D, 0x65, 0x72, 0x61, 0x00, 0x67, 0x65, 0x74,
- 0x5F, 0x66, 0x75, 0x6E, 0x63, 0x00, 0x69, 0x6E, 0x64, 0x65, 0x78, 0x00, 0x36, 0x73, 0x65, 0x74,
- 0x4D, 0x6F, 0x64, 0x65, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x51, 0x75, 0x61, 0x6C, 0x69, 0x74, 0x79,
- 0x2C, 0x36, 0x73, 0x65, 0x74, 0x4B, 0x65, 0x79, 0x46, 0x72, 0x61, 0x6D, 0x65, 0x49, 0x6E, 0x74,
- 0x65, 0x72, 0x76, 0x61, 0x6C, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x4D, 0x6F, 0x74, 0x69, 0x6F, 0x6E,
- 0x4C, 0x65, 0x76, 0x65, 0x6C, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x4C, 0x6F, 0x6F, 0x70, 0x62, 0x61,
- 0x63, 0x6B, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x43, 0x75, 0x72, 0x73, 0x6F, 0x72, 0x00, 0x6F, 0x6E,
- 0x53, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x00, 0x63, 0x61, 0x6C, 0x6C, 0x62, 0x61, 0x63, 0x6B, 0x00,
- 0x63, 0x75, 0x73, 0x74, 0x6F, 0x6D, 0x49, 0x74, 0x65, 0x6D, 0x73, 0x00, 0x41, 0x72, 0x72, 0x61,
- 0x79, 0x00, 0x62, 0x75, 0x69, 0x6C, 0x74, 0x49, 0x6E, 0x49, 0x74, 0x65, 0x6D, 0x73, 0x00, 0x66,
- 0x6F, 0x72, 0x77, 0x61, 0x72, 0x64, 0x5F, 0x62, 0x61, 0x63, 0x6B, 0x00, 0x6C, 0x6F, 0x6F, 0x70,
- 0x00, 0x70, 0x6C, 0x61, 0x79, 0x00, 0x70, 0x72, 0x69, 0x6E, 0x74, 0x00, 0x71, 0x75, 0x61, 0x6C,
- 0x69, 0x74, 0x79, 0x00, 0x72, 0x65, 0x77, 0x69, 0x6E, 0x64, 0x00, 0x73, 0x61, 0x76, 0x65, 0x00,
- 0x7A, 0x6F, 0x6F, 0x6D, 0x00, 0x43, 0x6F, 0x6E, 0x74, 0x65, 0x78, 0x74, 0x4D, 0x65, 0x6E, 0x75,
- 0x00, 0x63, 0x6F, 0x70, 0x79, 0x00, 0x68, 0x69, 0x64, 0x65, 0x42, 0x75, 0x69, 0x6C, 0x74, 0x49,
- 0x6E, 0x49, 0x74, 0x65, 0x6D, 0x73, 0x00, 0x63, 0x61, 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x73,
- 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x6F, 0x72, 0x42, 0x65, 0x66, 0x6F, 0x72, 0x65, 0x00, 0x76,
- 0x69, 0x73, 0x69, 0x62, 0x6C, 0x65, 0x00, 0x43, 0x6F, 0x6E, 0x74, 0x65, 0x78, 0x74, 0x4D, 0x65,
- 0x6E, 0x75, 0x49, 0x74, 0x65, 0x6D, 0x00, 0x6E, 0x65, 0x74, 0x00, 0x46, 0x69, 0x6C, 0x65, 0x52,
- 0x65, 0x66, 0x65, 0x72, 0x65, 0x6E, 0x63, 0x65, 0x00, 0x63, 0x00, 0x38, 0x62, 0x72, 0x6F, 0x77,
- 0x73, 0x65, 0x2C, 0x38, 0x75, 0x70, 0x6C, 0x6F, 0x61, 0x64, 0x2C, 0x38, 0x64, 0x6F, 0x77, 0x6E,
- 0x6C, 0x6F, 0x61, 0x64, 0x2C, 0x38, 0x63, 0x61, 0x6E, 0x63, 0x65, 0x6C, 0x00, 0x46, 0x69, 0x6C,
- 0x65, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6E, 0x63, 0x65, 0x4C, 0x69, 0x73, 0x74, 0x00, 0x66,
- 0x69, 0x6C, 0x65, 0x4C, 0x69, 0x73, 0x74, 0x00, 0x38, 0x62, 0x72, 0x6F, 0x77, 0x73, 0x65, 0x00,
- 0x4C, 0x6F, 0x63, 0x61, 0x6C, 0x43, 0x6F, 0x6E, 0x6E, 0x65, 0x63, 0x74, 0x69, 0x6F, 0x6E, 0x00,
- 0x36, 0x63, 0x6F, 0x6E, 0x6E, 0x65, 0x63, 0x74, 0x2C, 0x36, 0x73, 0x65, 0x6E, 0x64, 0x2C, 0x36,
- 0x63, 0x6C, 0x6F, 0x73, 0x65, 0x2C, 0x36, 0x64, 0x6F, 0x6D, 0x61, 0x69, 0x6E, 0x00, 0x4D, 0x69,
- 0x63, 0x72, 0x6F, 0x70, 0x68, 0x6F, 0x6E, 0x65, 0x00, 0x36, 0x73, 0x65, 0x74, 0x53, 0x69, 0x6C,
- 0x65, 0x6E, 0x63, 0x65, 0x4C, 0x65, 0x76, 0x65, 0x6C, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x52, 0x61,
- 0x74, 0x65, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x47, 0x61, 0x69, 0x6E, 0x2C, 0x36, 0x73, 0x65, 0x74,
- 0x55, 0x73, 0x65, 0x45, 0x63, 0x68, 0x6F, 0x53, 0x75, 0x70, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69,
- 0x6F, 0x6E, 0x00, 0x50, 0x72, 0x69, 0x6E, 0x74, 0x4A, 0x6F, 0x62, 0x00, 0x37, 0x73, 0x74, 0x61,
- 0x72, 0x74, 0x2C, 0x37, 0x61, 0x64, 0x64, 0x50, 0x61, 0x67, 0x65, 0x2C, 0x37, 0x73, 0x65, 0x6E,
- 0x64, 0x00, 0x53, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x67, 0x65, 0x74, 0x42,
- 0x65, 0x67, 0x69, 0x6E, 0x49, 0x6E, 0x64, 0x65, 0x78, 0x2C, 0x67, 0x65, 0x74, 0x45, 0x6E, 0x64,
- 0x49, 0x6E, 0x64, 0x65, 0x78, 0x2C, 0x67, 0x65, 0x74, 0x43, 0x61, 0x72, 0x65, 0x74, 0x49, 0x6E,
- 0x64, 0x65, 0x78, 0x2C, 0x67, 0x65, 0x74, 0x46, 0x6F, 0x63, 0x75, 0x73, 0x2C, 0x73, 0x65, 0x74,
- 0x46, 0x6F, 0x63, 0x75, 0x73, 0x2C, 0x73, 0x65, 0x74, 0x53, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x69,
- 0x6F, 0x6E, 0x00, 0x74, 0x65, 0x78, 0x74, 0x00, 0x54, 0x65, 0x78, 0x74, 0x52, 0x65, 0x6E, 0x64,
- 0x65, 0x72, 0x65, 0x72, 0x00, 0x38, 0x73, 0x65, 0x74, 0x41, 0x64, 0x76, 0x61, 0x6E, 0x63, 0x65,
- 0x64, 0x41, 0x6E, 0x74, 0x69, 0x61, 0x6C, 0x69, 0x61, 0x73, 0x69, 0x6E, 0x67, 0x54, 0x61, 0x62,
- 0x6C, 0x65, 0x00, 0x38, 0x6D, 0x61, 0x78, 0x4C, 0x65, 0x76, 0x65, 0x6C, 0x00, 0x38, 0x64, 0x69,
- 0x73, 0x70, 0x6C, 0x61, 0x79, 0x4D, 0x6F, 0x64, 0x65, 0x00, 0x74, 0x65, 0x78, 0x74, 0x52, 0x65,
- 0x6E, 0x64, 0x65, 0x72, 0x65, 0x72, 0x00, 0x58, 0x4D, 0x4C, 0x53, 0x6F, 0x63, 0x6B, 0x65, 0x74,
- 0x00, 0x6F, 0x6E, 0x58, 0x4D, 0x4C, 0x00, 0x63, 0x6F, 0x6E, 0x6E, 0x65, 0x63, 0x74, 0x2C, 0x73,
- 0x65, 0x6E, 0x64, 0x2C, 0x63, 0x6C, 0x6F, 0x73, 0x65, 0x00, 0x67, 0x65, 0x6F, 0x6D, 0x00, 0x50,
- 0x6F, 0x69, 0x6E, 0x74, 0x00, 0x61, 0x72, 0x67, 0x75, 0x6D, 0x65, 0x6E, 0x74, 0x73, 0x00, 0x79,
- 0x00, 0x64, 0x69, 0x73, 0x74, 0x61, 0x6E, 0x63, 0x65, 0x00, 0x61, 0x00, 0x62, 0x00, 0x73, 0x75,
- 0x62, 0x74, 0x72, 0x61, 0x63, 0x74, 0x00, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x70, 0x6F, 0x6C, 0x61,
- 0x74, 0x65, 0x00, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x00, 0x70, 0x6F, 0x6C, 0x61, 0x72, 0x00, 0x4D,
- 0x61, 0x74, 0x68, 0x00, 0x61, 0x6E, 0x67, 0x6C, 0x65, 0x00, 0x63, 0x6F, 0x73, 0x00, 0x73, 0x69,
- 0x6E, 0x00, 0x73, 0x71, 0x72, 0x74, 0x00, 0x61, 0x64, 0x64, 0x00, 0x6F, 0x74, 0x68, 0x65, 0x72,
- 0x00, 0x63, 0x6C, 0x6F, 0x6E, 0x65, 0x00, 0x65, 0x71, 0x75, 0x61, 0x6C, 0x73, 0x00, 0x6E, 0x6F,
- 0x72, 0x6D, 0x61, 0x6C, 0x69, 0x7A, 0x65, 0x00, 0x66, 0x61, 0x63, 0x74, 0x6F, 0x72, 0x00, 0x6F,
- 0x66, 0x66, 0x73, 0x65, 0x74, 0x00, 0x28, 0x78, 0x3D, 0x00, 0x2C, 0x20, 0x79, 0x3D, 0x00, 0x29,
- 0x00, 0x52, 0x65, 0x63, 0x74, 0x61, 0x6E, 0x67, 0x6C, 0x65, 0x00, 0x73, 0x65, 0x74, 0x45, 0x6D,
- 0x70, 0x74, 0x79, 0x00, 0x77, 0x69, 0x64, 0x74, 0x68, 0x00, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74,
- 0x00, 0x2C, 0x20, 0x77, 0x3D, 0x00, 0x2C, 0x20, 0x68, 0x3D, 0x00, 0x72, 0x65, 0x63, 0x74, 0x00,
- 0x63, 0x6F, 0x6E, 0x74, 0x61, 0x69, 0x6E, 0x73, 0x00, 0x63, 0x6F, 0x6E, 0x74, 0x61, 0x69, 0x6E,
- 0x73, 0x50, 0x6F, 0x69, 0x6E, 0x74, 0x00, 0x70, 0x6F, 0x69, 0x6E, 0x74, 0x00, 0x63, 0x6F, 0x6E,
- 0x74, 0x61, 0x69, 0x6E, 0x73, 0x52, 0x65, 0x63, 0x74, 0x61, 0x6E, 0x67, 0x6C, 0x65, 0x00, 0x74,
- 0x72, 0x00, 0x74, 0x62, 0x00, 0x72, 0x72, 0x00, 0x72, 0x62, 0x00, 0x69, 0x73, 0x45, 0x6D, 0x70,
- 0x74, 0x79, 0x00, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x73, 0x65, 0x63, 0x74, 0x69, 0x6F, 0x6E, 0x00,
- 0x69, 0x6E, 0x74, 0x73, 0x00, 0x6D, 0x61, 0x78, 0x00, 0x6D, 0x69, 0x6E, 0x00, 0x69, 0x6E, 0x74,
- 0x65, 0x72, 0x73, 0x65, 0x63, 0x74, 0x73, 0x00, 0x75, 0x6E, 0x69, 0x6F, 0x6E, 0x00, 0x64, 0x78,
- 0x00, 0x64, 0x79, 0x00, 0x6F, 0x66, 0x66, 0x73, 0x65, 0x74, 0x50, 0x6F, 0x69, 0x6E, 0x74, 0x00,
- 0x64, 0x00, 0x69, 0x6E, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x00, 0x69, 0x6E, 0x66, 0x6C, 0x61, 0x74,
- 0x65, 0x50, 0x6F, 0x69, 0x6E, 0x74, 0x00, 0x6C, 0x65, 0x66, 0x74, 0x00, 0x72, 0x69, 0x67, 0x68,
- 0x74, 0x00, 0x74, 0x6F, 0x70, 0x00, 0x62, 0x6F, 0x74, 0x74, 0x6F, 0x6D, 0x00, 0x74, 0x6F, 0x70,
- 0x4C, 0x65, 0x66, 0x74, 0x00, 0x62, 0x6F, 0x74, 0x74, 0x6F, 0x6D, 0x52, 0x69, 0x67, 0x68, 0x74,
- 0x00, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E,
- 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65,
- 0x6E, 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x63, 0x6C, 0x6F, 0x6E, 0x65, 0x00,
- 0x63, 0x6F, 0x6E, 0x63, 0x61, 0x74, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74,
- 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x63, 0x6F, 0x6E, 0x63, 0x61, 0x74, 0x00, 0x63,
- 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6F, 0x78, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65,
- 0x6E, 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65,
- 0x42, 0x6F, 0x78, 0x00, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x61, 0x64, 0x69, 0x65,
- 0x6E, 0x74, 0x42, 0x6F, 0x78, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20,
- 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x61,
- 0x64, 0x69, 0x65, 0x6E, 0x74, 0x42, 0x6F, 0x78, 0x00, 0x64, 0x65, 0x6C, 0x74, 0x61, 0x54, 0x72,
- 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x50, 0x6F, 0x69, 0x6E, 0x74, 0x00, 0x49, 0x6D, 0x70,
- 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x64, 0x65,
- 0x6C, 0x74, 0x61, 0x54, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x50, 0x6F, 0x69, 0x6E,
- 0x74, 0x00, 0x69, 0x64, 0x65, 0x6E, 0x74, 0x69, 0x74, 0x79, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65,
- 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x69, 0x64, 0x65, 0x6E,
- 0x74, 0x69, 0x74, 0x79, 0x00, 0x69, 0x6E, 0x76, 0x65, 0x72, 0x74, 0x00, 0x49, 0x6D, 0x70, 0x6C,
- 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x69, 0x6E, 0x76,
- 0x65, 0x72, 0x74, 0x00, 0x72, 0x6F, 0x74, 0x61, 0x74, 0x65, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65,
- 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x72, 0x6F, 0x74, 0x61,
- 0x74, 0x65, 0x00, 0x73, 0x63, 0x61, 0x6C, 0x65, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65,
- 0x6E, 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x73, 0x63, 0x61, 0x6C, 0x65, 0x00,
- 0x74, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x50, 0x6F, 0x69, 0x6E, 0x74, 0x00, 0x49,
- 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E,
- 0x74, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x50, 0x6F, 0x69, 0x6E, 0x74, 0x00, 0x74,
- 0x72, 0x61, 0x6E, 0x73, 0x6C, 0x61, 0x74, 0x65, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65,
- 0x6E, 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x74, 0x72, 0x61, 0x6E, 0x73, 0x6C,
- 0x61, 0x74, 0x65, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x4D, 0x61,
- 0x74, 0x72, 0x69, 0x78, 0x2E, 0x74, 0x6F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x43, 0x6F,
- 0x6C, 0x6F, 0x72, 0x54, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x00, 0x49, 0x6D, 0x70,
- 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x43, 0x6F, 0x6C, 0x6F, 0x72, 0x54, 0x72, 0x61, 0x6E,
- 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x2E, 0x74, 0x6F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x38,
- 0x63, 0x6F, 0x6E, 0x63, 0x61, 0x74, 0x00, 0x38, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x4D, 0x75, 0x6C,
- 0x74, 0x69, 0x70, 0x6C, 0x69, 0x65, 0x72, 0x2C, 0x38, 0x72, 0x65, 0x64, 0x4D, 0x75, 0x6C, 0x74,
- 0x69, 0x70, 0x6C, 0x69, 0x65, 0x72, 0x2C, 0x38, 0x67, 0x72, 0x65, 0x65, 0x6E, 0x4D, 0x75, 0x6C,
- 0x74, 0x69, 0x70, 0x6C, 0x69, 0x65, 0x72, 0x2C, 0x38, 0x62, 0x6C, 0x75, 0x65, 0x4D, 0x75, 0x6C,
- 0x74, 0x69, 0x70, 0x6C, 0x69, 0x65, 0x72, 0x2C, 0x38, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x4F, 0x66,
- 0x66, 0x73, 0x65, 0x74, 0x2C, 0x38, 0x72, 0x65, 0x64, 0x4F, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2C,
- 0x38, 0x67, 0x72, 0x65, 0x65, 0x6E, 0x4F, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2C, 0x38, 0x62, 0x6C,
- 0x75, 0x65, 0x4F, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2C, 0x38, 0x72, 0x67, 0x62, 0x00, 0x54, 0x72,
- 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x00, 0x38, 0x6D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2C,
- 0x38, 0x63, 0x6F, 0x6E, 0x63, 0x61, 0x74, 0x65, 0x6E, 0x61, 0x74, 0x65, 0x64, 0x4D, 0x61, 0x74,
- 0x72, 0x69, 0x78, 0x2C, 0x38, 0x63, 0x6F, 0x6C, 0x6F, 0x72, 0x54, 0x72, 0x61, 0x6E, 0x73, 0x66,
- 0x6F, 0x72, 0x6D, 0x2C, 0x38, 0x63, 0x6F, 0x6E, 0x63, 0x61, 0x74, 0x65, 0x6E, 0x61, 0x74, 0x65,
- 0x64, 0x43, 0x6F, 0x6C, 0x6F, 0x72, 0x54, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x2C,
- 0x38, 0x70, 0x69, 0x78, 0x65, 0x6C, 0x42, 0x6F, 0x75, 0x6E, 0x64, 0x73, 0x00, 0x42, 0x69, 0x74,
- 0x6D, 0x61, 0x70, 0x44, 0x61, 0x74, 0x61, 0x00, 0x52, 0x45, 0x44, 0x5F, 0x43, 0x48, 0x41, 0x4E,
- 0x4E, 0x45, 0x4C, 0x00, 0x47, 0x52, 0x45, 0x45, 0x4E, 0x5F, 0x43, 0x48, 0x41, 0x4E, 0x4E, 0x45,
- 0x4C, 0x00, 0x42, 0x4C, 0x55, 0x45, 0x5F, 0x43, 0x48, 0x41, 0x4E, 0x4E, 0x45, 0x4C, 0x00, 0x41,
- 0x4C, 0x50, 0x48, 0x41, 0x5F, 0x43, 0x48, 0x41, 0x4E, 0x4E, 0x45, 0x4C, 0x00, 0x38, 0x6C, 0x6F,
- 0x61, 0x64, 0x42, 0x69, 0x74, 0x6D, 0x61, 0x70, 0x00, 0x38, 0x67, 0x65, 0x74, 0x50, 0x69, 0x78,
- 0x65, 0x6C, 0x2C, 0x38, 0x73, 0x65, 0x74, 0x50, 0x69, 0x78, 0x65, 0x6C, 0x2C, 0x38, 0x66, 0x69,
- 0x6C, 0x6C, 0x52, 0x65, 0x63, 0x74, 0x2C, 0x38, 0x63, 0x6F, 0x70, 0x79, 0x50, 0x69, 0x78, 0x65,
- 0x6C, 0x73, 0x2C, 0x38, 0x61, 0x70, 0x70, 0x6C, 0x79, 0x46, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x2C,
- 0x38, 0x73, 0x63, 0x72, 0x6F, 0x6C, 0x6C, 0x2C, 0x38, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6F,
- 0x6C, 0x64, 0x2C, 0x38, 0x64, 0x72, 0x61, 0x77, 0x2C, 0x38, 0x70, 0x69, 0x78, 0x65, 0x6C, 0x44,
- 0x69, 0x73, 0x73, 0x6F, 0x6C, 0x76, 0x65, 0x2C, 0x38, 0x67, 0x65, 0x74, 0x50, 0x69, 0x78, 0x65,
- 0x6C, 0x33, 0x32, 0x2C, 0x38, 0x73, 0x65, 0x74, 0x50, 0x69, 0x78, 0x65, 0x6C, 0x33, 0x32, 0x2C,
- 0x38, 0x66, 0x6C, 0x6F, 0x6F, 0x64, 0x46, 0x69, 0x6C, 0x6C, 0x2C, 0x38, 0x67, 0x65, 0x74, 0x43,
- 0x6F, 0x6C, 0x6F, 0x72, 0x42, 0x6F, 0x75, 0x6E, 0x64, 0x73, 0x52, 0x65, 0x63, 0x74, 0x2C, 0x38,
- 0x70, 0x65, 0x72, 0x6C, 0x69, 0x6E, 0x4E, 0x6F, 0x69, 0x73, 0x65, 0x2C, 0x38, 0x63, 0x6F, 0x6C,
- 0x6F, 0x72, 0x54, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x2C, 0x38, 0x68, 0x69, 0x74,
- 0x54, 0x65, 0x73, 0x74, 0x2C, 0x38, 0x70, 0x61, 0x6C, 0x65, 0x74, 0x74, 0x65, 0x4D, 0x61, 0x70,
- 0x2C, 0x38, 0x6D, 0x65, 0x72, 0x67, 0x65, 0x2C, 0x38, 0x6E, 0x6F, 0x69, 0x73, 0x65, 0x2C, 0x38,
- 0x63, 0x6F, 0x70, 0x79, 0x43, 0x68, 0x61, 0x6E, 0x6E, 0x65, 0x6C, 0x2C, 0x38, 0x63, 0x6C, 0x6F,
- 0x6E, 0x65, 0x2C, 0x38, 0x64, 0x69, 0x73, 0x70, 0x6F, 0x73, 0x65, 0x2C, 0x38, 0x67, 0x65, 0x6E,
- 0x65, 0x72, 0x61, 0x74, 0x65, 0x46, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x52, 0x65, 0x63, 0x74, 0x2C,
- 0x38, 0x63, 0x6F, 0x6D, 0x70, 0x61, 0x72, 0x65, 0x00, 0x38, 0x77, 0x69, 0x64, 0x74, 0x68, 0x2C,
- 0x38, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x2C, 0x38, 0x72, 0x65, 0x63, 0x74, 0x61, 0x6E, 0x67,
- 0x6C, 0x65, 0x2C, 0x38, 0x74, 0x72, 0x61, 0x6E, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6E, 0x74, 0x00,
- 0x65, 0x78, 0x74, 0x65, 0x72, 0x6E, 0x61, 0x6C, 0x00, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6E, 0x61,
- 0x6C, 0x49, 0x6E, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x00, 0x61, 0x64, 0x64, 0x43, 0x61,
- 0x6C, 0x6C, 0x62, 0x61, 0x63, 0x6B, 0x00, 0x61, 0x76, 0x61, 0x69, 0x6C, 0x61, 0x62, 0x6C, 0x65,
- 0x00, 0x5F, 0x69, 0x6E, 0x69, 0x74, 0x4A, 0x53, 0x00, 0x69, 0x6E, 0x73, 0x74, 0x61, 0x6E, 0x63,
- 0x65, 0x00, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x00, 0x5F, 0x63, 0x61, 0x6C, 0x6C, 0x49,
- 0x6E, 0x00, 0x5F, 0x61, 0x64, 0x64, 0x43, 0x61, 0x6C, 0x6C, 0x62, 0x61, 0x63, 0x6B, 0x00, 0x63,
- 0x61, 0x6C, 0x6C, 0x00, 0x74, 0x72, 0x79, 0x20, 0x7B, 0x20, 0x00, 0x5F, 0x6F, 0x62, 0x6A, 0x65,
- 0x63, 0x74, 0x49, 0x44, 0x00, 0x69, 0x64, 0x00, 0x2E, 0x53, 0x65, 0x74, 0x52, 0x65, 0x74, 0x75,
- 0x72, 0x6E, 0x56, 0x61, 0x6C, 0x75, 0x65, 0x28, 0x00, 0x5F, 0x5F, 0x66, 0x6C, 0x61, 0x73, 0x68,
- 0x5F, 0x5F, 0x74, 0x6F, 0x58, 0x4D, 0x4C, 0x20, 0x28, 0x00, 0x28, 0x00, 0x2C, 0x00, 0x5F, 0x74,
- 0x6F, 0x4A, 0x53, 0x00, 0x29, 0x29, 0x20, 0x00, 0x3B, 0x20, 0x7D, 0x20, 0x63, 0x61, 0x74, 0x63,
- 0x68, 0x20, 0x28, 0x65, 0x29, 0x20, 0x7B, 0x20, 0x00, 0x2E, 0x53, 0x65, 0x74, 0x52, 0x65, 0x74,
- 0x75, 0x72, 0x6E, 0x56, 0x61, 0x6C, 0x75, 0x65, 0x28, 0x22, 0x3C, 0x75, 0x6E, 0x64, 0x65, 0x66,
- 0x69, 0x6E, 0x65, 0x64, 0x2F, 0x3E, 0x22, 0x29, 0x3B, 0x20, 0x7D, 0x00, 0x22, 0x3C, 0x75, 0x6E,
- 0x64, 0x65, 0x66, 0x69, 0x6E, 0x65, 0x64, 0x2F, 0x3E, 0x22, 0x3B, 0x20, 0x7D, 0x00, 0x5F, 0x65,
- 0x76, 0x61, 0x6C, 0x4A, 0x53, 0x00, 0x3C, 0x69, 0x6E, 0x76, 0x6F, 0x6B, 0x65, 0x20, 0x6E, 0x61,
- 0x6D, 0x65, 0x3D, 0x22, 0x00, 0x22, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6E, 0x74, 0x79, 0x70,
- 0x65, 0x3D, 0x22, 0x78, 0x6D, 0x6C, 0x22, 0x3E, 0x00, 0x5F, 0x61, 0x72, 0x67, 0x75, 0x6D, 0x65,
- 0x6E, 0x74, 0x73, 0x54, 0x6F, 0x58, 0x4D, 0x4C, 0x00, 0x3C, 0x2F, 0x69, 0x6E, 0x76, 0x6F, 0x6B,
- 0x65, 0x3E, 0x00, 0x5F, 0x63, 0x61, 0x6C, 0x6C, 0x4F, 0x75, 0x74, 0x00, 0x78, 0x6D, 0x6C, 0x00,
- 0x69, 0x67, 0x6E, 0x6F, 0x72, 0x65, 0x57, 0x68, 0x69, 0x74, 0x65, 0x00, 0x66, 0x69, 0x72, 0x73,
- 0x74, 0x43, 0x68, 0x69, 0x6C, 0x64, 0x00, 0x5F, 0x74, 0x6F, 0x41, 0x53, 0x00, 0x61, 0x72, 0x67,
- 0x73, 0x00, 0x63, 0x68, 0x69, 0x6C, 0x64, 0x4E, 0x6F, 0x64, 0x65, 0x73, 0x00, 0x6E, 0x6F, 0x64,
- 0x65, 0x4E, 0x61, 0x6D, 0x65, 0x00, 0x5F, 0x61, 0x72, 0x67, 0x75, 0x6D, 0x65, 0x6E, 0x74, 0x73,
- 0x54, 0x6F, 0x41, 0x53, 0x00, 0x61, 0x70, 0x70, 0x6C, 0x79, 0x00, 0x61, 0x74, 0x74, 0x72, 0x69,
- 0x62, 0x75, 0x74, 0x65, 0x73, 0x00, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6E, 0x74, 0x79, 0x70, 0x65,
- 0x00, 0x6A, 0x61, 0x76, 0x61, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x00, 0x5F, 0x74, 0x6F, 0x58,
- 0x4D, 0x4C, 0x00, 0x5F, 0x61, 0x72, 0x72, 0x61, 0x79, 0x54, 0x6F, 0x58, 0x4D, 0x4C, 0x00, 0x3C,
- 0x61, 0x72, 0x72, 0x61, 0x79, 0x3E, 0x00, 0x73, 0x00, 0x61, 0x72, 0x72, 0x61, 0x79, 0x00, 0x3C,
- 0x70, 0x72, 0x6F, 0x70, 0x65, 0x72, 0x74, 0x79, 0x20, 0x69, 0x64, 0x3D, 0x22, 0x00, 0x22, 0x3E,
- 0x00, 0x3C, 0x2F, 0x70, 0x72, 0x6F, 0x70, 0x65, 0x72, 0x74, 0x79, 0x3E, 0x00, 0x3C, 0x2F, 0x61,
- 0x72, 0x72, 0x61, 0x79, 0x3E, 0x00, 0x3C, 0x61, 0x72, 0x67, 0x75, 0x6D, 0x65, 0x6E, 0x74, 0x73,
- 0x3E, 0x00, 0x3C, 0x2F, 0x61, 0x72, 0x67, 0x75, 0x6D, 0x65, 0x6E, 0x74, 0x73, 0x3E, 0x00, 0x5F,
- 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x54, 0x6F, 0x58, 0x4D, 0x4C, 0x00, 0x3C, 0x6F, 0x62, 0x6A,
- 0x65, 0x63, 0x74, 0x3E, 0x00, 0x6F, 0x62, 0x6A, 0x00, 0x3C, 0x2F, 0x6F, 0x62, 0x6A, 0x65, 0x63,
- 0x74, 0x3E, 0x00, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x3C, 0x73, 0x74, 0x72, 0x69, 0x6E,
- 0x67, 0x3E, 0x00, 0x5F, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x58, 0x4D, 0x4C, 0x00, 0x3C, 0x2F,
- 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x3E, 0x00, 0x3C, 0x75, 0x6E, 0x64, 0x65, 0x66, 0x69, 0x6E,
- 0x65, 0x64, 0x2F, 0x3E, 0x00, 0x6E, 0x75, 0x6D, 0x62, 0x65, 0x72, 0x00, 0x3C, 0x6E, 0x75, 0x6D,
- 0x62, 0x65, 0x72, 0x3E, 0x00, 0x3C, 0x2F, 0x6E, 0x75, 0x6D, 0x62, 0x65, 0x72, 0x3E, 0x00, 0x3C,
- 0x6E, 0x75, 0x6C, 0x6C, 0x2F, 0x3E, 0x00, 0x62, 0x6F, 0x6F, 0x6C, 0x65, 0x61, 0x6E, 0x00, 0x3C,
- 0x74, 0x72, 0x75, 0x65, 0x2F, 0x3E, 0x00, 0x3C, 0x66, 0x61, 0x6C, 0x73, 0x65, 0x2F, 0x3E, 0x00,
- 0x68, 0x61, 0x73, 0x4F, 0x77, 0x6E, 0x50, 0x72, 0x6F, 0x70, 0x65, 0x72, 0x74, 0x79, 0x00, 0x5F,
- 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x54, 0x6F, 0x41, 0x53, 0x00, 0x70, 0x72, 0x6F, 0x70, 0x65,
- 0x72, 0x74, 0x79, 0x00, 0x5F, 0x61, 0x72, 0x72, 0x61, 0x79, 0x54, 0x6F, 0x41, 0x53, 0x00, 0x4E,
- 0x75, 0x6D, 0x62, 0x65, 0x72, 0x00, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x5F, 0x75, 0x6E,
- 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x58, 0x4D, 0x4C, 0x00, 0x63, 0x6C, 0x61, 0x73, 0x73, 0x00,
- 0x5F, 0x61, 0x72, 0x72, 0x61, 0x79, 0x54, 0x6F, 0x4A, 0x53, 0x00, 0x5B, 0x00, 0x5F, 0x6C, 0x31,
- 0x00, 0x5D, 0x00, 0x5F, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x54, 0x6F, 0x4A, 0x53, 0x00, 0x28,
- 0x7B, 0x00, 0x6E, 0x65, 0x65, 0x64, 0x73, 0x5F, 0x63, 0x6F, 0x6D, 0x6D, 0x61, 0x00, 0x3A, 0x00,
- 0x7D, 0x29, 0x00, 0x22, 0x00, 0x5F, 0x6A, 0x73, 0x51, 0x75, 0x6F, 0x74, 0x65, 0x53, 0x74, 0x72,
- 0x69, 0x6E, 0x67, 0x00, 0x38, 0x5F, 0x69, 0x6E, 0x69, 0x74, 0x4A, 0x53, 0x2C, 0x38, 0x5F, 0x6F,
- 0x62, 0x6A, 0x65, 0x63, 0x74, 0x49, 0x44, 0x2C, 0x38, 0x5F, 0x61, 0x64, 0x64, 0x43, 0x61, 0x6C,
- 0x6C, 0x62, 0x61, 0x63, 0x6B, 0x2C, 0x38, 0x5F, 0x65, 0x76, 0x61, 0x6C, 0x4A, 0x53, 0x2C, 0x38,
- 0x5F, 0x63, 0x61, 0x6C, 0x6C, 0x4F, 0x75, 0x74, 0x2C, 0x38, 0x5F, 0x65, 0x73, 0x63, 0x61, 0x70,
- 0x65, 0x58, 0x4D, 0x4C, 0x2C, 0x38, 0x5F, 0x75, 0x6E, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x58,
- 0x4D, 0x4C, 0x2C, 0x38, 0x5F, 0x6A, 0x73, 0x51, 0x75, 0x6F, 0x74, 0x65, 0x53, 0x74, 0x72, 0x69,
- 0x6E, 0x67, 0x00, 0x38, 0x61, 0x76, 0x61, 0x69, 0x6C, 0x61, 0x62, 0x6C, 0x65, 0x00, 0x53, 0x68,
- 0x61, 0x72, 0x65, 0x64, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x64, 0x65, 0x6C, 0x65, 0x74,
- 0x65, 0x41, 0x6C, 0x6C, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53,
- 0x68, 0x61, 0x72, 0x65, 0x64, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x2E, 0x64, 0x65, 0x6C, 0x65,
- 0x74, 0x65, 0x41, 0x6C, 0x6C, 0x20, 0x28, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x29, 0x00, 0x67,
- 0x65, 0x74, 0x44, 0x69, 0x73, 0x6B, 0x55, 0x73, 0x61, 0x67, 0x65, 0x00, 0x49, 0x6D, 0x70, 0x6C,
- 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x4F, 0x62, 0x6A, 0x65,
- 0x63, 0x74, 0x2E, 0x67, 0x65, 0x74, 0x44, 0x69, 0x73, 0x6B, 0x55, 0x73, 0x61, 0x67, 0x65, 0x20,
- 0x28, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x29, 0x00, 0x67, 0x65, 0x74, 0x4C, 0x6F, 0x63, 0x61,
- 0x6C, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53, 0x68, 0x61, 0x72,
- 0x65, 0x64, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x2E, 0x67, 0x65, 0x74, 0x4C, 0x6F, 0x63, 0x61,
- 0x6C, 0x20, 0x28, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x29, 0x00, 0x67, 0x65, 0x74, 0x52, 0x65,
- 0x6D, 0x6F, 0x74, 0x65, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53,
- 0x68, 0x61, 0x72, 0x65, 0x64, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x2E, 0x67, 0x65, 0x74, 0x52,
- 0x65, 0x6D, 0x6F, 0x74, 0x65, 0x20, 0x28, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x29, 0x00, 0x64,
- 0x65, 0x6C, 0x65, 0x74, 0x65, 0x41, 0x6C, 0x6C, 0x2C, 0x67, 0x65, 0x74, 0x44, 0x69, 0x73, 0x6B,
- 0x55, 0x73, 0x61, 0x67, 0x65, 0x00, 0x36, 0x63, 0x6F, 0x6E, 0x6E, 0x65, 0x63, 0x74, 0x2C, 0x36,
- 0x73, 0x65, 0x6E, 0x64, 0x2C, 0x36, 0x66, 0x6C, 0x75, 0x73, 0x68, 0x2C, 0x36, 0x63, 0x6C, 0x6F,
- 0x73, 0x65, 0x2C, 0x36, 0x67, 0x65, 0x74, 0x53, 0x69, 0x7A, 0x65, 0x2C, 0x36, 0x73, 0x65, 0x74,
- 0x46, 0x70, 0x73, 0x2C, 0x36, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x00, 0x73, 0x70, 0x6C, 0x69, 0x74,
- 0x00, 0x63, 0x6F, 0x75, 0x6E, 0x74, 0x00, 0x52, 0x65, 0x6D, 0x6F, 0x74, 0x65, 0x4C, 0x53, 0x4F,
- 0x55, 0x73, 0x61, 0x67, 0x65, 0x00, 0x67, 0x65, 0x74, 0x55, 0x52, 0x4C, 0x50, 0x61, 0x67, 0x65,
- 0x53, 0x75, 0x70, 0x70, 0x6F, 0x72, 0x74, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E,
- 0x74, 0x20, 0x52, 0x65, 0x6D, 0x6F, 0x74, 0x65, 0x4C, 0x53, 0x4F, 0x55, 0x73, 0x61, 0x67, 0x65,
- 0x2E, 0x67, 0x65, 0x74, 0x55, 0x52, 0x4C, 0x50, 0x61, 0x67, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6F,
- 0x72, 0x74, 0x20, 0x28, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x29, 0x00, 0x42, 0x75, 0x74, 0x74,
- 0x6F, 0x6E, 0x00, 0x67, 0x65, 0x74, 0x44, 0x65, 0x70, 0x74, 0x68, 0x00, 0x38, 0x73, 0x63, 0x61,
- 0x6C, 0x65, 0x39, 0x47, 0x72, 0x69, 0x64, 0x2C, 0x38, 0x66, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x73,
- 0x2C, 0x38, 0x63, 0x61, 0x63, 0x68, 0x65, 0x41, 0x73, 0x42, 0x69, 0x74, 0x6D, 0x61, 0x70, 0x2C,
- 0x38, 0x62, 0x6C, 0x65, 0x6E, 0x64, 0x4D, 0x6F, 0x64, 0x65, 0x00, 0x66, 0x69, 0x6C, 0x74, 0x65,
- 0x72, 0x73, 0x00, 0x42, 0x69, 0x74, 0x6D, 0x61, 0x70, 0x46, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x00,
- 0x38, 0x63, 0x6C, 0x6F, 0x6E, 0x65, 0x00, 0x42, 0x65, 0x76, 0x65, 0x6C, 0x46, 0x69, 0x6C, 0x74,
- 0x65, 0x72, 0x00, 0x38, 0x64, 0x69, 0x73, 0x74, 0x61, 0x6E, 0x63, 0x65, 0x2C, 0x38, 0x61, 0x6E,
- 0x67, 0x6C, 0x65, 0x2C, 0x38, 0x68, 0x69, 0x67, 0x68, 0x6C, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6F,
- 0x6C, 0x6F, 0x72, 0x2C, 0x38, 0x68, 0x69, 0x67, 0x68, 0x6C, 0x69, 0x67, 0x68, 0x74, 0x41, 0x6C,
- 0x70, 0x68, 0x61, 0x2C, 0x38, 0x73, 0x68, 0x61, 0x64, 0x6F, 0x77, 0x43, 0x6F, 0x6C, 0x6F, 0x72,
- 0x2C, 0x38, 0x73, 0x68, 0x61, 0x64, 0x6F, 0x77, 0x41, 0x6C, 0x70, 0x68, 0x61, 0x2C, 0x38, 0x71,
- 0x75, 0x61, 0x6C, 0x69, 0x74, 0x79, 0x2C, 0x38, 0x73, 0x74, 0x72, 0x65, 0x6E, 0x67, 0x74, 0x68,
- 0x2C, 0x38, 0x6B, 0x6E, 0x6F, 0x63, 0x6B, 0x6F, 0x75, 0x74, 0x2C, 0x38, 0x62, 0x6C, 0x75, 0x72,
- 0x58, 0x2C, 0x38, 0x62, 0x6C, 0x75, 0x72, 0x59, 0x2C, 0x38, 0x74, 0x79, 0x70, 0x65, 0x00, 0x42,
- 0x6C, 0x75, 0x72, 0x46, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x00, 0x38, 0x62, 0x6C, 0x75, 0x72, 0x58,
- 0x2C, 0x38, 0x62, 0x6C, 0x75, 0x72, 0x59, 0x2C, 0x38, 0x71, 0x75, 0x61, 0x6C, 0x69, 0x74, 0x79,
- 0x00, 0x43, 0x6F, 0x6C, 0x6F, 0x72, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x46, 0x69, 0x6C, 0x74,
- 0x65, 0x72, 0x00, 0x38, 0x6D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x00, 0x43, 0x6F, 0x6E, 0x76, 0x6F,
- 0x6C, 0x75, 0x74, 0x69, 0x6F, 0x6E, 0x46, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x00, 0x38, 0x6D, 0x61,
- 0x74, 0x72, 0x69, 0x78, 0x58, 0x2C, 0x38, 0x6D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x59, 0x2C, 0x38,
- 0x6D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2C, 0x38, 0x64, 0x69, 0x76, 0x69, 0x73, 0x6F, 0x72, 0x2C,
- 0x38, 0x62, 0x69, 0x61, 0x73, 0x2C, 0x38, 0x70, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x41,
- 0x6C, 0x70, 0x68, 0x61, 0x2C, 0x38, 0x63, 0x6C, 0x61, 0x6D, 0x70, 0x2C, 0x38, 0x63, 0x6F, 0x6C,
- 0x6F, 0x72, 0x2C, 0x38, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x00, 0x44, 0x69, 0x73, 0x70, 0x6C, 0x61,
- 0x63, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x4D, 0x61, 0x70, 0x46, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x00,
- 0x38, 0x6D, 0x61, 0x70, 0x42, 0x69, 0x74, 0x6D, 0x61, 0x70, 0x2C, 0x38, 0x6D, 0x61, 0x70, 0x50,
- 0x6F, 0x69, 0x6E, 0x74, 0x2C, 0x38, 0x63, 0x6F, 0x6D, 0x70, 0x6F, 0x6E, 0x65, 0x6E, 0x74, 0x58,
- 0x2C, 0x38, 0x63, 0x6F, 0x6D, 0x70, 0x6F, 0x6E, 0x65, 0x6E, 0x74, 0x59, 0x2C, 0x38, 0x73, 0x63,
- 0x61, 0x6C, 0x65, 0x58, 0x2C, 0x38, 0x73, 0x63, 0x61, 0x6C, 0x65, 0x59, 0x2C, 0x38, 0x6D, 0x6F,
- 0x64, 0x65, 0x2C, 0x38, 0x63, 0x6F, 0x6C, 0x6F, 0x72, 0x2C, 0x38, 0x61, 0x6C, 0x70, 0x68, 0x61,
- 0x00, 0x44, 0x72, 0x6F, 0x70, 0x53, 0x68, 0x61, 0x64, 0x6F, 0x77, 0x46, 0x69, 0x6C, 0x74, 0x65,
- 0x72, 0x00, 0x38, 0x64, 0x69, 0x73, 0x74, 0x61, 0x6E, 0x63, 0x65, 0x2C, 0x38, 0x61, 0x6E, 0x67,
- 0x6C, 0x65, 0x2C, 0x38, 0x63, 0x6F, 0x6C, 0x6F, 0x72, 0x2C, 0x38, 0x61, 0x6C, 0x70, 0x68, 0x61,
- 0x2C, 0x38, 0x71, 0x75, 0x61, 0x6C, 0x69, 0x74, 0x79, 0x2C, 0x38, 0x69, 0x6E, 0x6E, 0x65, 0x72,
- 0x2C, 0x38, 0x6B, 0x6E, 0x6F, 0x63, 0x6B, 0x6F, 0x75, 0x74, 0x2C, 0x38, 0x62, 0x6C, 0x75, 0x72,
- 0x58, 0x2C, 0x38, 0x62, 0x6C, 0x75, 0x72, 0x59, 0x2C, 0x38, 0x73, 0x74, 0x72, 0x65, 0x6E, 0x67,
- 0x74, 0x68, 0x2C, 0x38, 0x68, 0x69, 0x64, 0x65, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x47,
- 0x6C, 0x6F, 0x77, 0x46, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x00, 0x38, 0x63, 0x6F, 0x6C, 0x6F, 0x72,
- 0x2C, 0x38, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x2C, 0x38, 0x71, 0x75, 0x61, 0x6C, 0x69, 0x74, 0x79,
- 0x2C, 0x38, 0x69, 0x6E, 0x6E, 0x65, 0x72, 0x2C, 0x38, 0x6B, 0x6E, 0x6F, 0x63, 0x6B, 0x6F, 0x75,
- 0x74, 0x2C, 0x38, 0x62, 0x6C, 0x75, 0x72, 0x58, 0x2C, 0x38, 0x62, 0x6C, 0x75, 0x72, 0x59, 0x2C,
- 0x38, 0x73, 0x74, 0x72, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x00, 0x47, 0x72, 0x61, 0x64, 0x69, 0x65,
- 0x6E, 0x74, 0x42, 0x65, 0x76, 0x65, 0x6C, 0x46, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x00, 0x38, 0x64,
- 0x69, 0x73, 0x74, 0x61, 0x6E, 0x63, 0x65, 0x2C, 0x38, 0x61, 0x6E, 0x67, 0x6C, 0x65, 0x2C, 0x38,
- 0x63, 0x6F, 0x6C, 0x6F, 0x72, 0x73, 0x2C, 0x38, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x73, 0x2C, 0x38,
- 0x72, 0x61, 0x74, 0x69, 0x6F, 0x73, 0x2C, 0x38, 0x62, 0x6C, 0x75, 0x72, 0x58, 0x2C, 0x38, 0x62,
- 0x6C, 0x75, 0x72, 0x59, 0x2C, 0x38, 0x71, 0x75, 0x61, 0x6C, 0x69, 0x74, 0x79, 0x2C, 0x38, 0x73,
- 0x74, 0x72, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x2C, 0x38, 0x6B, 0x6E, 0x6F, 0x63, 0x6B, 0x6F, 0x75,
- 0x74, 0x2C, 0x38, 0x74, 0x79, 0x70, 0x65, 0x00, 0x47, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6E, 0x74,
- 0x47, 0x6C, 0x6F, 0x77, 0x46, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x00, 0x73, 0x65, 0x74, 0x49, 0x6E,
- 0x74, 0x65, 0x72, 0x76, 0x61, 0x6C, 0x00, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x49, 0x6E, 0x74, 0x65,
- 0x72, 0x76, 0x61, 0x6C, 0x00, 0x73, 0x65, 0x74, 0x54, 0x69, 0x6D, 0x65, 0x6F, 0x75, 0x74, 0x00,
- 0x63, 0x6C, 0x65, 0x61, 0x72, 0x54, 0x69, 0x6D, 0x65, 0x6F, 0x75, 0x74, 0x00, 0x73, 0x68, 0x6F,
- 0x77, 0x52, 0x65, 0x64, 0x72, 0x61, 0x77, 0x52, 0x65, 0x67, 0x69, 0x6F, 0x6E, 0x73, 0x00, 0x74,
- 0x72, 0x61, 0x63, 0x65, 0x00, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x66, 0x74, 0x65, 0x72,
- 0x45, 0x76, 0x65, 0x6E, 0x74, 0x00, 0x8E, 0x12, 0x00, 0x45, 0x72, 0x72, 0x6F, 0x72, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x6D, 0x73, 0x67, 0x00, 0x23, 0x00, 0x96, 0x02, 0x00, 0x08, 0x08,
- 0x1C, 0x44, 0x96, 0x02, 0x00, 0x08, 0x09, 0x49, 0x12, 0x12, 0x9D, 0x02, 0x00, 0x0F, 0x00, 0x96,
- 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x0B, 0x08, 0x08, 0x1C, 0x4F, 0x8E, 0x15,
- 0x00, 0x41, 0x73, 0x42, 0x72, 0x6F, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x65, 0x72, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8E, 0x10, 0x00, 0x4C, 0x6F, 0x61, 0x64, 0x56, 0x61, 0x72,
- 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8E, 0x0E, 0x00, 0x43, 0x61, 0x6D, 0x65,
- 0x72, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8E, 0x1D, 0x00, 0x43, 0x6F, 0x6E,
- 0x74, 0x65, 0x78, 0x74, 0x4D, 0x65, 0x6E, 0x75, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63,
- 0x61, 0x6C, 0x6C, 0x62, 0x61, 0x63, 0x6B, 0x00, 0x5B, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C,
- 0x96, 0x04, 0x00, 0x08, 0xF9, 0x08, 0xFA, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96,
- 0x09, 0x00, 0x08, 0xFB, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFC, 0x40, 0x4F, 0x96, 0x02, 0x00,
- 0x08, 0x0A, 0x1C, 0x96, 0x2D, 0x00, 0x08, 0xFD, 0x08, 0xFE, 0x05, 0x01, 0x08, 0xFF, 0x05, 0x01,
- 0x09, 0x00, 0x01, 0x05, 0x01, 0x09, 0x01, 0x01, 0x05, 0x01, 0x09, 0x02, 0x01, 0x05, 0x01, 0x09,
- 0x03, 0x01, 0x05, 0x01, 0x09, 0x04, 0x01, 0x05, 0x01, 0x09, 0x05, 0x01, 0x05, 0x01, 0x07, 0x08,
- 0x00, 0x00, 0x00, 0x43, 0x4F, 0x8E, 0x4D, 0x00, 0x43, 0x6F, 0x6E, 0x74, 0x65, 0x78, 0x74, 0x4D,
- 0x65, 0x6E, 0x75, 0x49, 0x74, 0x65, 0x6D, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x61,
- 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x00, 0x63, 0x61, 0x6C, 0x6C, 0x62, 0x61, 0x63, 0x6B, 0x00,
- 0x00, 0x73, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x6F, 0x72, 0x42, 0x65, 0x66, 0x6F, 0x72, 0x65,
- 0x00, 0x00, 0x65, 0x6E, 0x61, 0x62, 0x6C, 0x65, 0x64, 0x00, 0x00, 0x76, 0x69, 0x73, 0x69, 0x62,
- 0x6C, 0x65, 0x00, 0xBE, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x09,
- 0x01, 0x09, 0x09, 0x01, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08,
- 0xF9, 0x08, 0xFA, 0x1C, 0x4F, 0x96, 0x03, 0x00, 0x09, 0x0A, 0x01, 0x1C, 0x96, 0x01, 0x00, 0x03,
- 0x49, 0x9D, 0x02, 0x00, 0x16, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09,
- 0x0A, 0x01, 0x09, 0x0A, 0x01, 0x1C, 0x4F, 0x99, 0x02, 0x00, 0x0F, 0x00, 0x96, 0x02, 0x00, 0x08,
- 0x0A, 0x1C, 0x96, 0x05, 0x00, 0x09, 0x0A, 0x01, 0x05, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x9B,
- 0x1C, 0x96, 0x01, 0x00, 0x03, 0x49, 0x9D, 0x02, 0x00, 0x14, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A,
- 0x1C, 0x96, 0x04, 0x00, 0x08, 0x9B, 0x08, 0x9B, 0x1C, 0x4F, 0x99, 0x02, 0x00, 0x0E, 0x00, 0x96,
- 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x9B, 0x05, 0x01, 0x4F, 0x96, 0x03, 0x00,
- 0x09, 0x0B, 0x01, 0x1C, 0x96, 0x01, 0x00, 0x03, 0x49, 0x9D, 0x02, 0x00, 0x16, 0x00, 0x96, 0x02,
- 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x0B, 0x01, 0x09, 0x0B, 0x01, 0x1C, 0x4F, 0x99,
- 0x02, 0x00, 0x0F, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x05, 0x00, 0x09, 0x0B, 0x01,
- 0x05, 0x01, 0x4F, 0x8E, 0x17, 0x00, 0x4C, 0x6F, 0x63, 0x61, 0x6C, 0x43, 0x6F, 0x6E, 0x6E, 0x65,
- 0x63, 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8E, 0x12, 0x00,
- 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x70, 0x68, 0x6F, 0x6E, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x8E, 0x11, 0x00, 0x58, 0x4D, 0x4C, 0x53, 0x6F, 0x63, 0x6B, 0x65, 0x74, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8E, 0x14, 0x00, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x4F,
- 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8E, 0x1B, 0x00,
- 0x41, 0x73, 0x53, 0x65, 0x74, 0x75, 0x70, 0x45, 0x72, 0x72, 0x6F, 0x72, 0x00, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x6E, 0x61, 0x6D, 0x65, 0x73, 0x00, 0x5F, 0x00, 0x96, 0x0D, 0x00, 0x09, 0xEB,
- 0x01, 0x09, 0x97, 0x01, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0xCA, 0x1C, 0x96, 0x03, 0x00, 0x09,
- 0xEA, 0x01, 0x52, 0x96, 0x02, 0x00, 0x08, 0x19, 0x4E, 0x3C, 0x96, 0x07, 0x00, 0x08, 0x18, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0x3C, 0x99, 0x02, 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C,
- 0x1C, 0x50, 0x1D, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xEB, 0x01, 0x1C,
- 0x48, 0x12, 0x9D, 0x02, 0x00, 0x13, 0x00, 0x96, 0x09, 0x00, 0x08, 0xC9, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x08, 0x0C, 0x40, 0x3C, 0x99, 0x02, 0x00, 0xD0, 0xFF, 0x8E, 0x16, 0x00, 0x52, 0x65, 0x6D,
- 0x6F, 0x74, 0x65, 0x4C, 0x53, 0x4F, 0x55, 0x73, 0x61, 0x67, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x96, 0x13, 0x00, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0x00,
- 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13, 0x00, 0x08, 0x02,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08,
- 0x01, 0x3D, 0x1D, 0x96, 0x13, 0x00, 0x08, 0x03, 0x07, 0x01, 0x00, 0x00, 0x00, 0x07, 0x04, 0x00,
- 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x07, 0x00, 0x08, 0x04,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x1D, 0x96, 0x02, 0x00, 0x08, 0x05, 0x1C, 0x96, 0x13, 0x00,
- 0x08, 0x06, 0x07, 0x08, 0x00, 0x00, 0x00, 0x07, 0x65, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00,
- 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x08, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x05,
- 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x0E, 0x00,
- 0x07, 0x80, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x07, 0x08, 0x05, 0x1C, 0x96,
- 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x0C,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x04, 0x00, 0x08, 0x0E, 0x08, 0x0C, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x04, 0x00, 0x08, 0x0B, 0x08, 0x0C, 0x87, 0x01, 0x00, 0x00,
- 0x4F, 0x96, 0x02, 0x00, 0x04, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0C, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x0D, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0B, 0x4E, 0x3E,
- 0x4F, 0x96, 0x02, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x13, 0x00, 0x08, 0x11, 0x07, 0x0C, 0x00, 0x00,
- 0x00, 0x07, 0x65, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96,
- 0x02, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x12, 0x8E, 0x0B, 0x00, 0x00, 0x01, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x3C, 0x00, 0x96, 0x02, 0x00, 0x08, 0x13, 0x1C, 0x96, 0x07,
- 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x14, 0x52, 0x17,
- 0x96, 0x02, 0x00, 0x08, 0x13, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x15, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x16, 0x52, 0x17, 0x96, 0x02,
- 0x00, 0x05, 0x01, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x14,
- 0x8E, 0x0B, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x8F, 0x00, 0x96, 0x04,
- 0x00, 0x08, 0x17, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x15, 0x4E, 0x3C, 0x96, 0x02, 0x00,
- 0x08, 0x18, 0x41, 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x99, 0x02,
- 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C, 0x50, 0x1D, 0x96, 0x02, 0x00, 0x08,
- 0x18, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x17, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x19, 0x4E, 0x48, 0x12,
- 0x9D, 0x02, 0x00, 0x42, 0x00, 0x96, 0x02, 0x00, 0x08, 0x17, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x18,
- 0x1C, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x13, 0x1C, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x23, 0x00, 0x96,
- 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x18, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x02, 0x00,
- 0x00, 0x00, 0x08, 0x17, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1A, 0x52, 0x17, 0x96, 0x02, 0x00, 0x05,
- 0x01, 0x3E, 0x99, 0x02, 0x00, 0x9C, 0xFF, 0x96, 0x02, 0x00, 0x05, 0x00, 0x3E, 0x4F, 0x96, 0x02,
- 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1B, 0x8E, 0x0B, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x6F, 0x00, 0x73, 0x00, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x13, 0x00,
- 0x08, 0x11, 0x07, 0x0C, 0x00, 0x00, 0x00, 0x07, 0x65, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00,
- 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x12,
- 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x12, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C,
- 0x96, 0x04, 0x00, 0x08, 0x14, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x14, 0x4E, 0x4F, 0x96,
- 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x15, 0x07, 0x00, 0x00, 0x00, 0x00, 0x42,
- 0x4F, 0x96, 0x09, 0x00, 0x07, 0x83, 0x00, 0x00, 0x00, 0x08, 0x1D, 0x08, 0x1C, 0x1C, 0x96, 0x07,
- 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x4F, 0x96, 0x8C, 0x00, 0x08, 0x1E,
- 0x08, 0x1F, 0x07, 0x12, 0x00, 0x00, 0x00, 0x08, 0x20, 0x07, 0x08, 0x00, 0x00, 0x00, 0x08, 0x21,
- 0x07, 0x14, 0x00, 0x00, 0x00, 0x08, 0x22, 0x07, 0x11, 0x00, 0x00, 0x00, 0x08, 0x23, 0x07, 0x2E,
- 0x00, 0x00, 0x00, 0x08, 0x24, 0x07, 0x28, 0x00, 0x00, 0x00, 0x08, 0x25, 0x07, 0x23, 0x00, 0x00,
- 0x00, 0x08, 0x26, 0x07, 0x0D, 0x00, 0x00, 0x00, 0x08, 0x27, 0x07, 0x1B, 0x00, 0x00, 0x00, 0x08,
- 0x28, 0x07, 0x24, 0x00, 0x00, 0x00, 0x08, 0x29, 0x07, 0x2D, 0x00, 0x00, 0x00, 0x08, 0x2A, 0x07,
- 0x25, 0x00, 0x00, 0x00, 0x08, 0x2B, 0x07, 0x22, 0x00, 0x00, 0x00, 0x08, 0x2C, 0x07, 0x21, 0x00,
- 0x00, 0x00, 0x08, 0x2D, 0x07, 0x27, 0x00, 0x00, 0x00, 0x08, 0x2E, 0x07, 0x10, 0x00, 0x00, 0x00,
- 0x08, 0x2F, 0x07, 0x20, 0x00, 0x00, 0x00, 0x08, 0x30, 0x07, 0x09, 0x00, 0x00, 0x00, 0x08, 0x31,
- 0x07, 0x26, 0x00, 0x00, 0x00, 0x07, 0x13, 0x00, 0x00, 0x00, 0x43, 0x1D, 0x96, 0x09, 0x00, 0x08,
- 0x32, 0x07, 0x20, 0x03, 0x00, 0x00, 0x08, 0x1E, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00,
- 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x1E, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01,
- 0x00, 0x00, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1B, 0x52, 0x17, 0x96, 0x08, 0x00,
- 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x1E, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00,
- 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x07, 0x00, 0x08, 0x33, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43,
- 0x1D, 0x96, 0x02, 0x00, 0x08, 0x33, 0x1C, 0x96, 0x13, 0x00, 0x08, 0x34, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x07, 0x05, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96,
- 0x02, 0x00, 0x08, 0x33, 0x1C, 0x96, 0x13, 0x00, 0x08, 0x35, 0x07, 0x01, 0x00, 0x00, 0x00, 0x07,
- 0x05, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00,
- 0x08, 0x33, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02,
- 0x00, 0x08, 0x1B, 0x52, 0x17, 0x96, 0x08, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x33,
- 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x07, 0x00,
- 0x08, 0x36, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x1D, 0x96, 0x02, 0x00, 0x08, 0x36, 0x1C, 0x96,
- 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1B, 0x52,
- 0x17, 0x96, 0x0E, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x37, 0x07, 0x9A, 0x02, 0x00, 0x00,
- 0x08, 0x36, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96,
- 0x0E, 0x00, 0x07, 0x64, 0x00, 0x00, 0x00, 0x08, 0x38, 0x07, 0x9A, 0x02, 0x00, 0x00, 0x08, 0x36,
- 0x1C, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x13, 0x00,
- 0x08, 0x39, 0x07, 0xC8, 0x00, 0x00, 0x00, 0x07, 0x34, 0x08, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00,
- 0x00, 0x08, 0x3A, 0x3D, 0x1D, 0x96, 0x09, 0x00, 0x08, 0x3B, 0x07, 0x34, 0x08, 0x00, 0x00, 0x08,
- 0x39, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00,
- 0x08, 0x02, 0x3D, 0x17, 0x96, 0x12, 0x00, 0x02, 0x07, 0x04, 0x00, 0x00, 0x00, 0x07, 0x34, 0x08,
- 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x96, 0x09, 0x00, 0x08, 0x3C, 0x07,
- 0x03, 0x00, 0x00, 0x00, 0x08, 0x39, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00,
- 0x08, 0x07, 0x52, 0x17, 0x96, 0x02, 0x00, 0x08, 0x39, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
- 0x96, 0x04, 0x00, 0x08, 0x3D, 0x08, 0x3E, 0x4F, 0x96, 0x12, 0x00, 0x02, 0x07, 0x05, 0x00, 0x00,
- 0x00, 0x07, 0x34, 0x08, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x96, 0x09,
- 0x00, 0x08, 0x3F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x39, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52, 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00,
- 0x02, 0x08, 0x39, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00,
- 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x40, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x41, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07,
- 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x42, 0x52, 0x17,
- 0x4F, 0x96, 0x02, 0x00, 0x08, 0x40, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00,
- 0x08, 0x43, 0x8E, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x6C, 0x61, 0x67,
- 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96,
- 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x44, 0x52,
- 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x40, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02,
- 0x00, 0x08, 0x45, 0x8E, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x6C, 0x61,
- 0x67, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C,
- 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x46,
- 0x52, 0x17, 0x4F, 0x96, 0x09, 0x00, 0x08, 0x47, 0x07, 0x35, 0x08, 0x00, 0x00, 0x08, 0x40, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02,
- 0x3D, 0x17, 0x96, 0x0E, 0x00, 0x07, 0x05, 0x00, 0x00, 0x00, 0x08, 0x48, 0x07, 0x35, 0x08, 0x00,
- 0x00, 0x08, 0x40, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00,
- 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08,
- 0x40, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x49, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
- 0x96, 0x04, 0x00, 0x08, 0x4A, 0x08, 0x4B, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x49, 0x1C, 0x96, 0x02,
- 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x4C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x2D,
- 0x01, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0x49, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x4D, 0x07, 0x01, 0x00,
- 0x00, 0x00, 0x07, 0x2D, 0x01, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F,
- 0x96, 0x02, 0x00, 0x08, 0x49, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08,
- 0x4E, 0x07, 0x02, 0x00, 0x00, 0x00, 0x07, 0x2D, 0x01, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00,
- 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x49, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
- 0x96, 0x13, 0x00, 0x08, 0x4F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x07, 0x2D, 0x01, 0x00, 0x00, 0x07,
- 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x49, 0x1C, 0x96, 0x02,
- 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x50, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x49, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x51, 0x8E, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x73, 0x72, 0x63, 0x00, 0x64, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08,
- 0x52, 0x05, 0x01, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x53, 0x1C, 0x96, 0x01, 0x00, 0x02, 0x49, 0x12,
- 0x9D, 0x02, 0x00, 0x19, 0x00, 0x96, 0x09, 0x00, 0x05, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08,
- 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x50, 0x52, 0x17, 0x99, 0x02, 0x00, 0x2C, 0x00, 0x96, 0x02,
- 0x00, 0x08, 0x53, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x4F, 0x52, 0x17, 0x96, 0x09, 0x00, 0x05, 0x01, 0x07, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x50, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x49,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x8E, 0x08, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0xB3, 0x00, 0x96, 0x03, 0x00, 0x08, 0x54, 0x02, 0x3C, 0x96, 0x02,
- 0x00, 0x08, 0x0A, 0x46, 0x87, 0x01, 0x00, 0x00, 0x96, 0x01, 0x00, 0x02, 0x49, 0x9D, 0x02, 0x00,
- 0x91, 0x00, 0x96, 0x04, 0x00, 0x08, 0x13, 0x04, 0x00, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x54, 0x1C,
- 0x96, 0x01, 0x00, 0x02, 0x49, 0x9D, 0x02, 0x00, 0x41, 0x00, 0x96, 0x02, 0x00, 0x08, 0x54, 0x4C,
- 0x1C, 0x96, 0x04, 0x00, 0x08, 0x57, 0x08, 0x13, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00,
- 0x00, 0x08, 0x55, 0x3D, 0x47, 0x96, 0x02, 0x00, 0x08, 0x56, 0x47, 0x96, 0x02, 0x00, 0x08, 0x0A,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x1C, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x55, 0x3D, 0x47, 0x47, 0x1D, 0x99, 0x02, 0x00, 0x33, 0x00, 0x96, 0x04, 0x00, 0x08, 0x54,
- 0x08, 0x13, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x55, 0x3D, 0x96, 0x02,
- 0x00, 0x08, 0x56, 0x47, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x1C,
- 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x55, 0x3D, 0x47, 0x1D, 0x99, 0x02,
- 0x00, 0x61, 0xFF, 0x96, 0x02, 0x00, 0x08, 0x54, 0x1C, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x49,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x58, 0x8E, 0x08, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0x59, 0x4E, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x49, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x5A, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D,
- 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x5B, 0x4E, 0x3E, 0x4F, 0x96,
- 0x02, 0x00, 0x08, 0x49, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x5C,
- 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08,
- 0x1C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x5D, 0x52, 0x17, 0x4F, 0x96, 0x08, 0x00, 0x07, 0x83, 0x00,
- 0x00, 0x00, 0x02, 0x08, 0x49, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07,
- 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x13, 0x00, 0x08, 0x5E, 0x07, 0x10, 0x00,
- 0x00, 0x00, 0x07, 0xF4, 0x01, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x1D,
- 0x96, 0x09, 0x00, 0x08, 0x5F, 0x07, 0xF4, 0x01, 0x00, 0x00, 0x08, 0x5E, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96,
- 0x0E, 0x00, 0x07, 0x12, 0x00, 0x00, 0x00, 0x08, 0x48, 0x07, 0xF4, 0x01, 0x00, 0x00, 0x08, 0x5E,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08,
- 0x03, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x5E, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D,
- 0x17, 0x96, 0x13, 0x00, 0x08, 0x60, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00,
- 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x1D, 0x96, 0x02, 0x00, 0x08, 0x60, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x61, 0x07, 0x01, 0x00, 0x00, 0x00, 0x07,
- 0xFD, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00,
- 0x08, 0x60, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x62, 0x07, 0x02,
- 0x00, 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D,
- 0x4F, 0x96, 0x02, 0x00, 0x08, 0x60, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00,
- 0x08, 0x63, 0x07, 0x03, 0x00, 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00,
- 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x60, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
- 0x4E, 0x96, 0x13, 0x00, 0x08, 0x64, 0x07, 0x04, 0x00, 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00,
- 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x60, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x65, 0x07, 0x05, 0x00, 0x00, 0x00, 0x07,
- 0xFD, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00,
- 0x08, 0x60, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x0F, 0x07, 0x06,
- 0x00, 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D,
- 0x4F, 0x96, 0x02, 0x00, 0x08, 0x60, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00,
- 0x08, 0x66, 0x07, 0x07, 0x00, 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00,
- 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x60, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
- 0x4E, 0x96, 0x13, 0x00, 0x08, 0x67, 0x07, 0x08, 0x00, 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00,
- 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x13, 0x00, 0x08, 0x68, 0x07, 0x09,
- 0x00, 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D,
- 0x1D, 0x96, 0x02, 0x00, 0x08, 0x68, 0x1C, 0x96, 0x10, 0x00, 0x08, 0x0D, 0x08, 0x69, 0x07, 0x01,
- 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x60, 0x40, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0x68, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x6A, 0x3A, 0x17, 0x96,
- 0x09, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x0D, 0x08, 0x68, 0x1C, 0x96, 0x07, 0x00, 0x07,
- 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x68, 0x1C, 0x96, 0x02,
- 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x4C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x2D,
- 0x01, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0x68, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x4D, 0x07, 0x01, 0x00,
- 0x00, 0x00, 0x07, 0x2D, 0x01, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F,
- 0x96, 0x02, 0x00, 0x08, 0x68, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08,
- 0x4E, 0x07, 0x02, 0x00, 0x00, 0x00, 0x07, 0x2D, 0x01, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00,
- 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x68, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
- 0x96, 0x13, 0x00, 0x08, 0x6B, 0x07, 0x0A, 0x00, 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00, 0x07,
- 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x68, 0x1C, 0x96, 0x02,
- 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x6C, 0x07, 0x0B, 0x00, 0x00, 0x00, 0x07, 0xFD,
- 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0x68, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x6D, 0x07, 0x0C, 0x00,
- 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F,
- 0x96, 0x02, 0x00, 0x08, 0x68, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08,
- 0x50, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00,
- 0x08, 0x68, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x51, 0x8E, 0x0D,
- 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x72, 0x63, 0x00, 0x72, 0x00, 0x96, 0x02,
- 0x00, 0x08, 0x53, 0x1C, 0x96, 0x01, 0x00, 0x02, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x27, 0x00, 0x96,
- 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x52, 0x05, 0x00, 0x4F, 0x96, 0x09, 0x00,
- 0x05, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x50, 0x52,
- 0x17, 0x99, 0x02, 0x00, 0x3A, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08,
- 0x52, 0x05, 0x01, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x53, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00,
- 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x6D, 0x52, 0x17, 0x96, 0x09, 0x00, 0x05,
- 0x01, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x50, 0x52, 0x17,
- 0x4F, 0x96, 0x02, 0x00, 0x08, 0x68, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00,
- 0x08, 0x58, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x96, 0x02, 0x00,
- 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x59, 0x4E, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x68,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x5A, 0x8E, 0x08, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0x5B, 0x4E, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x68, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x5C, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E,
- 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x6E, 0x52, 0x17, 0x4F,
- 0x96, 0x07, 0x00, 0x08, 0x6F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x1D, 0x96, 0x02, 0x00, 0x08,
- 0x6F, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x70, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02,
- 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x70, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x71, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0x07, 0x0B, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01,
- 0x3D, 0x4F, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0x70, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x71, 0x52, 0x17, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0x70, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x71, 0x3A, 0x17, 0x96, 0x02, 0x00,
- 0x08, 0x6F, 0x1C, 0x96, 0x13, 0x00, 0x08, 0x72, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x2A, 0x04,
- 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F,
- 0x1C, 0x96, 0x13, 0x00, 0x08, 0x73, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x3B, 0x08, 0x00, 0x00,
- 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x0E, 0x00, 0x07, 0x01, 0x00, 0x00,
- 0x00, 0x08, 0x74, 0x07, 0x3B, 0x08, 0x00, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x04,
- 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x09, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x08,
- 0x75, 0x08, 0x6F, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17,
- 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x09, 0x00, 0x08, 0x76, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x08, 0x05, 0x40, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x76, 0x4E,
- 0x96, 0x02, 0x00, 0x08, 0x6A, 0x3A, 0x17, 0x96, 0x09, 0x00, 0x08, 0x77, 0x07, 0x0C, 0x00, 0x00,
- 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x76, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00,
- 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x0E, 0x00, 0x07, 0x05, 0x00, 0x00, 0x00, 0x08, 0x78,
- 0x07, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x76, 0x4E, 0x96, 0x07,
- 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0x76, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x79, 0x8E, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0x7A, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x76,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x79, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00,
- 0x08, 0x7B, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0F, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00,
- 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x76,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x79, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00,
- 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1B, 0x52, 0x17, 0x96,
- 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x7C, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43,
- 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0x7D, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x7C, 0x4E,
- 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x7E, 0x8E, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0x7F, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x7C,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x80, 0x8E, 0x08, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x02,
- 0x00, 0x08, 0x81, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0x7C, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x82, 0x8E, 0x08, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00,
- 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x83, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0x7C, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x84, 0x8E, 0x08,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0x85, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02,
- 0x00, 0x08, 0x7C, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x86, 0x8E,
- 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x87, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x7C, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x88,
- 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08,
- 0x1C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x89, 0x52, 0x17, 0x4F, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00,
- 0x00, 0x00, 0x02, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x7C, 0x4E, 0x96, 0x02, 0x00, 0x08,
- 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02,
- 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x27, 0x00, 0x08, 0x8A, 0x08, 0x8B, 0x08, 0x8B, 0x08, 0x8C, 0x08,
- 0x8C, 0x08, 0x8D, 0x08, 0x8D, 0x08, 0x8E, 0x08, 0x8E, 0x08, 0x8F, 0x08, 0x8F, 0x08, 0x90, 0x08,
- 0x90, 0x08, 0x91, 0x08, 0x91, 0x08, 0x92, 0x08, 0x92, 0x07, 0x08, 0x00, 0x00, 0x00, 0x43, 0x4F,
- 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x8A, 0x4E, 0x96, 0x07, 0x00, 0x07,
- 0x01, 0x00, 0x00, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1B, 0x52, 0x17, 0x96, 0x09,
- 0x00, 0x08, 0x93, 0x07, 0x0D, 0x00, 0x00, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x8A,
- 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x08, 0x00,
- 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x8A, 0x4E, 0x96,
- 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x94,
- 0x8E, 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74,
- 0x00, 0x27, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x95, 0x08, 0x95,
- 0x1C, 0x4F, 0x96, 0x08, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x0A, 0x1C, 0x96, 0x07,
- 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x1D, 0x96, 0x09, 0x00, 0x08, 0x96,
- 0x07, 0xBC, 0x02, 0x00, 0x00, 0x08, 0x94, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07,
- 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x07, 0x00,
- 0x00, 0x00, 0x02, 0x08, 0x94, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07,
- 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x13, 0x00, 0x08, 0x97, 0x07, 0x00, 0x00,
- 0x00, 0x00, 0x07, 0x2B, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x1D,
- 0x96, 0x0E, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x98, 0x07, 0x2B, 0x04, 0x00, 0x00, 0x08,
- 0x97, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00,
- 0x08, 0x02, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
- 0x96, 0x04, 0x00, 0x08, 0x9A, 0x05, 0x01, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02,
- 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x04, 0x00, 0x08, 0x9B, 0x05, 0x01, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x9C, 0x8E, 0x10, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6D, 0x65, 0x74, 0x68, 0x6F, 0x64, 0x00, 0x5B, 0x00,
- 0x96, 0x09, 0x00, 0x08, 0x9F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x9D, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0x9E, 0x52, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x9F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xA0, 0x49,
- 0x9D, 0x02, 0x00, 0x2D, 0x00, 0x96, 0x02, 0x00, 0x08, 0x9F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xA1,
- 0x49, 0x9D, 0x02, 0x00, 0x0E, 0x00, 0x96, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x99,
- 0x02, 0x00, 0x09, 0x00, 0x96, 0x05, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x3E, 0x99, 0x02, 0x00,
- 0x09, 0x00, 0x96, 0x05, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xA2, 0x8E, 0x1D, 0x00,
- 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x72, 0x6C, 0x00, 0x00, 0x74, 0x61, 0x72, 0x67,
- 0x65, 0x74, 0x00, 0x00, 0x6D, 0x65, 0x74, 0x68, 0x6F, 0x64, 0x00, 0x97, 0x00, 0x96, 0x02, 0x00,
- 0x08, 0x95, 0x1C, 0x44, 0x96, 0x02, 0x00, 0x08, 0x09, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x08, 0x00,
- 0x96, 0x04, 0x00, 0x08, 0x95, 0x08, 0x69, 0x1D, 0x96, 0x04, 0x00, 0x08, 0xA3, 0x08, 0x9D, 0x1C,
- 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x9C,
- 0x52, 0x3C, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x49, 0x9D, 0x02, 0x00, 0x3E, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x05, 0x00, 0x07,
- 0x01, 0x00, 0x00, 0x00, 0x49, 0x9D, 0x02, 0x00, 0x15, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA4, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0x95, 0x1C, 0x9A, 0x01, 0x00, 0x02, 0x99, 0x02, 0x00, 0x10, 0x00, 0x96,
- 0x02, 0x00, 0x08, 0xA4, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x95, 0x1C, 0x9A, 0x01, 0x00, 0x01, 0x99,
- 0x02, 0x00, 0x10, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA4, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x95, 0x1C,
- 0x9A, 0x01, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0xA5, 0x8E, 0x15, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x75, 0x72, 0x6C, 0x00, 0x00, 0x6D, 0x65, 0x74, 0x68, 0x6F, 0x64, 0x00, 0x99, 0x00, 0x96, 0x04,
- 0x00, 0x08, 0xA3, 0x08, 0x9D, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x9C, 0x52, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x20, 0x96,
- 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x49, 0x9D, 0x02,
- 0x00, 0x4A, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x05, 0x00, 0x07, 0x01, 0x00, 0x00,
- 0x00, 0x49, 0x9D, 0x02, 0x00, 0x1B, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA4, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xA6, 0x4E, 0x9A, 0x01, 0x00, 0xC2, 0x99, 0x02, 0x00,
- 0x16, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA4, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02,
- 0x00, 0x08, 0xA6, 0x4E, 0x9A, 0x01, 0x00, 0xC1, 0x99, 0x02, 0x00, 0x16, 0x00, 0x96, 0x02, 0x00,
- 0x08, 0xA4, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xA6, 0x4E, 0x9A,
- 0x01, 0x00, 0xC0, 0x8B, 0x01, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02,
- 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xA7, 0x8E, 0x15, 0x00, 0x00, 0x02, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x75, 0x72, 0x6C, 0x00, 0x00, 0x6D, 0x65, 0x74, 0x68, 0x6F, 0x64, 0x00, 0x99,
- 0x00, 0x96, 0x04, 0x00, 0x08, 0xA3, 0x08, 0x9D, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00,
- 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x9C, 0x52, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x0A,
- 0x1C, 0x20, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x49, 0x9D, 0x02, 0x00, 0x4A, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x05, 0x00, 0x07,
- 0x01, 0x00, 0x00, 0x00, 0x49, 0x9D, 0x02, 0x00, 0x1B, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA4, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xA6, 0x4E, 0x9A, 0x01, 0x00, 0x42,
- 0x99, 0x02, 0x00, 0x16, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA4, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0xA6, 0x4E, 0x9A, 0x01, 0x00, 0x41, 0x99, 0x02, 0x00, 0x16, 0x00,
- 0x96, 0x02, 0x00, 0x08, 0xA4, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0xA6, 0x4E, 0x9A, 0x01, 0x00, 0x40, 0x8B, 0x01, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x99,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xA8, 0x8E, 0x08, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x20, 0x96, 0x04,
- 0x00, 0x08, 0x69, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xA6, 0x4E, 0x9A, 0x01, 0x00, 0x40,
- 0x8B, 0x01, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0xA9, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12,
- 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08,
- 0x97, 0x40, 0x3E, 0x4F, 0x96, 0x09, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x08, 0xA9, 0x08, 0x99,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08,
- 0x00, 0x3D, 0x17, 0x96, 0x09, 0x00, 0x08, 0xAA, 0x07, 0x84, 0x03, 0x00, 0x00, 0x08, 0x99, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02,
- 0x3D, 0x17, 0x96, 0x0E, 0x00, 0x07, 0xC8, 0x00, 0x00, 0x00, 0x08, 0xAB, 0x07, 0x84, 0x03, 0x00,
- 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00,
- 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x0E, 0x00, 0x07, 0x2C, 0x01, 0x00, 0x00, 0x08, 0xAC,
- 0x07, 0x84, 0x03, 0x00, 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07,
- 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x0E, 0x00, 0x07, 0x91, 0x01,
- 0x00, 0x00, 0x08, 0xAD, 0x07, 0x84, 0x03, 0x00, 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x0E,
- 0x00, 0x07, 0xA1, 0x01, 0x00, 0x00, 0x08, 0xAE, 0x07, 0x84, 0x03, 0x00, 0x00, 0x08, 0x99, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03,
- 0x3D, 0x17, 0x96, 0x0E, 0x00, 0x07, 0xF4, 0x01, 0x00, 0x00, 0x08, 0xAF, 0x07, 0x84, 0x03, 0x00,
- 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00,
- 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x09, 0x00, 0x08, 0xB0, 0x07, 0x85, 0x03, 0x00, 0x00,
- 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00,
- 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x0E, 0x00, 0x07, 0x0C, 0x00, 0x00, 0x00, 0x08, 0xB1, 0x07,
- 0x85, 0x03, 0x00, 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00,
- 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x99, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0xB2, 0x07, 0xC8, 0x00, 0x00, 0x00, 0x07,
- 0x68, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x08, 0x00,
- 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96,
- 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x13, 0x00, 0x08, 0xB3,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x70, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08,
- 0x3A, 0x3D, 0x1D, 0x96, 0x0E, 0x00, 0x07, 0x64, 0x00, 0x00, 0x00, 0x08, 0xB4, 0x07, 0x70, 0x00,
- 0x00, 0x00, 0x08, 0xB3, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04,
- 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0xB3, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02,
- 0x00, 0x08, 0x1B, 0x52, 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x04, 0x00, 0x00, 0x02, 0x08, 0xB3,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08,
- 0x00, 0x3D, 0x17, 0x96, 0x13, 0x00, 0x08, 0xB5, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x68, 0x00,
- 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x1D, 0x96, 0x02, 0x00, 0x08, 0xB5,
- 0x1C, 0x96, 0x13, 0x00, 0x08, 0xB6, 0x07, 0xC9, 0x00, 0x00, 0x00, 0x07, 0x68, 0x00, 0x00, 0x00,
- 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x0E, 0x00, 0x07, 0x64, 0x00, 0x00,
- 0x00, 0x08, 0xB7, 0x07, 0x68, 0x00, 0x00, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
- 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x02, 0x00,
- 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00,
- 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1B, 0x52, 0x17, 0x96, 0x08, 0x00, 0x07, 0x83,
- 0x00, 0x00, 0x00, 0x02, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00,
- 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x0E, 0x00, 0x07, 0x2C, 0x01, 0x00,
- 0x00, 0x08, 0xB8, 0x07, 0x68, 0x00, 0x00, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
- 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x0E, 0x00,
- 0x07, 0xC8, 0x00, 0x00, 0x00, 0x08, 0xB9, 0x07, 0x84, 0x03, 0x00, 0x00, 0x08, 0xB5, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D,
- 0x17, 0x96, 0x08, 0x00, 0x07, 0x83, 0x00, 0x00, 0x00, 0x02, 0x08, 0xB5, 0x1C, 0x96, 0x07, 0x00,
- 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x13, 0x00, 0x08, 0xBA, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x07, 0x6E, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D,
- 0x1D, 0x96, 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x13, 0x00, 0x08, 0xBB, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x07, 0x71, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96,
- 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0xBC, 0x8E, 0x0B, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x6F, 0x00, 0x67, 0x00, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x44, 0x96, 0x02, 0x00, 0x08, 0xBD,
- 0x49, 0x12, 0x12, 0x9D, 0x02, 0x00, 0x05, 0x00, 0x96, 0x01, 0x00, 0x02, 0x3E, 0x96, 0x07, 0x00,
- 0x08, 0xBE, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x46, 0x87,
- 0x01, 0x00, 0x00, 0x96, 0x01, 0x00, 0x02, 0x49, 0x9D, 0x02, 0x00, 0x27, 0x00, 0x96, 0x04, 0x00,
- 0x08, 0xBF, 0x04, 0x00, 0x3C, 0x96, 0x02, 0x00, 0x08, 0xBE, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBF,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBF, 0x1C, 0x4E, 0x4F, 0x99,
- 0x02, 0x00, 0xCB, 0xFF, 0x96, 0x02, 0x00, 0x08, 0xBE, 0x1C, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02,
- 0x00, 0x08, 0xC0, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x96, 0x02,
- 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x08, 0xC1, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F,
- 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x08, 0xC2, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x43, 0x4F, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0xC3, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xC4, 0x8E, 0x0E, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6E, 0x61, 0x6D, 0x65, 0x00, 0x25, 0x00, 0x96, 0x02, 0x00,
- 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC1, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C, 0x4E,
- 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBC,
- 0x52, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96,
- 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xC5, 0x8E, 0x15, 0x00, 0x00, 0x02, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x6E, 0x61, 0x6D, 0x65, 0x00, 0x00, 0x73, 0x74, 0x79, 0x6C, 0x65, 0x00,
- 0x79, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC1, 0x4E, 0x12, 0x12,
- 0x9D, 0x02, 0x00, 0x12, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x08, 0xC1,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0xC1, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96,
- 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBC, 0x52,
- 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08,
- 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC7, 0x52, 0x17, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC3, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02,
- 0x00, 0x08, 0xC8, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5B, 0x00, 0x96, 0x04,
- 0x00, 0x08, 0xC9, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC1, 0x4E, 0x3C, 0x96, 0x07, 0x00,
- 0x08, 0xCA, 0x07, 0x00, 0x00, 0x00, 0x00, 0x42, 0x3C, 0x96, 0x02, 0x00, 0x08, 0xC9, 0x46, 0x87,
- 0x01, 0x00, 0x00, 0x96, 0x01, 0x00, 0x02, 0x49, 0x9D, 0x02, 0x00, 0x25, 0x00, 0x96, 0x04, 0x00,
- 0x08, 0xBF, 0x04, 0x00, 0x3C, 0x96, 0x02, 0x00, 0x08, 0xBF, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01,
- 0x00, 0x00, 0x00, 0x08, 0xCA, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x16, 0x52, 0x17, 0x99, 0x02, 0x00,
- 0xCD, 0xFF, 0x96, 0x02, 0x00, 0x08, 0xCA, 0x1C, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xB5, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08,
- 0xC7, 0x8E, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6E, 0x61, 0x6D, 0x65, 0x00,
- 0x5C, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC2, 0x4E, 0x12, 0x12,
- 0x9D, 0x02, 0x00, 0x12, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x08, 0xC2,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0xC2, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0xC1, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C, 0x4E, 0x96, 0x07, 0x00, 0x07,
- 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xCB, 0x52, 0x4F, 0x4F, 0x96,
- 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0xCB, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x73, 0x74, 0x79, 0x6C, 0x65, 0x00, 0x9D, 0x03, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x01,
- 0x00, 0x02, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x05, 0x00, 0x96, 0x01, 0x00, 0x02, 0x3E, 0x96, 0x09,
- 0x00, 0x08, 0xCC, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0xBA, 0x40, 0x3C, 0x96, 0x02, 0x00, 0x08,
- 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xCD, 0x4E, 0x12, 0x9D, 0x02, 0x00, 0x15, 0x00, 0x96, 0x02,
- 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xCE, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0xCD, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xCF, 0x4E, 0x96,
- 0x02, 0x00, 0x08, 0xD0, 0x49, 0x9D, 0x02, 0x00, 0x2B, 0x00, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0xCF, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xD1, 0x49, 0x12, 0x9D, 0x02, 0x00,
- 0x0E, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xD0, 0x05, 0x00, 0x4F,
- 0x99, 0x02, 0x00, 0x0E, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xD0,
- 0x05, 0x01, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD2, 0x4E, 0x12,
- 0x9D, 0x02, 0x00, 0x41, 0x00, 0x96, 0x04, 0x00, 0x08, 0xC9, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0xD2, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02,
- 0x00, 0x08, 0xD3, 0x52, 0x3C, 0x96, 0x02, 0x00, 0x08, 0xC9, 0x1C, 0x96, 0x01, 0x00, 0x02, 0x49,
- 0x12, 0x12, 0x9D, 0x02, 0x00, 0x0F, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00,
- 0x08, 0xD2, 0x08, 0xC9, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08,
- 0xD4, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD4, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xC6,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD5, 0x4E, 0x12, 0x9D, 0x02, 0x00, 0x26, 0x00, 0x96, 0x02, 0x00,
- 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xD6, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD5,
- 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0xD7, 0x52, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD8, 0x4E, 0x12,
- 0x9D, 0x02, 0x00, 0x20, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xD9,
- 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD8, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00,
- 0x00, 0x08, 0xDA, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xDB,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0xDC, 0x49, 0x9D, 0x02, 0x00, 0x2B, 0x00, 0x96, 0x02, 0x00, 0x08,
- 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xDB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xD1, 0x49, 0x12, 0x9D,
- 0x02, 0x00, 0x0E, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xDC, 0x05,
- 0x00, 0x4F, 0x99, 0x02, 0x00, 0x0E, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00,
- 0x08, 0xDC, 0x05, 0x01, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xDD,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0xDE, 0x49, 0x9D, 0x02, 0x00, 0x4F, 0x00, 0x96, 0x02, 0x00, 0x08,
- 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xDD, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xDF, 0x49, 0x9D, 0x02,
- 0x00, 0x25, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xDD, 0x08, 0xC6,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0xDD, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08,
- 0xDA, 0x3D, 0x4F, 0x99, 0x02, 0x00, 0x0E, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04,
- 0x00, 0x08, 0xDD, 0x05, 0x00, 0x4F, 0x99, 0x02, 0x00, 0x0E, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC,
- 0x1C, 0x96, 0x04, 0x00, 0x08, 0xDD, 0x05, 0x01, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0xE0, 0x4E, 0x12, 0x9D, 0x02, 0x00, 0x20, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC,
- 0x1C, 0x96, 0x04, 0x00, 0x08, 0xE0, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xE0, 0x4E, 0x96,
- 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0xDA, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xC6,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0xE1, 0x4E, 0x12, 0x9D, 0x02, 0x00, 0x20, 0x00, 0x96, 0x02, 0x00,
- 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xE2, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xE1,
- 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0xDA, 0x3D, 0x4F, 0x96, 0x02, 0x00,
- 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xE3, 0x4E, 0x12, 0x9D, 0x02, 0x00, 0x20, 0x00, 0x96,
- 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xE3, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0xE3, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0xDA, 0x3D, 0x4F, 0x96,
- 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xE4, 0x4E, 0x12, 0x9D, 0x02, 0x00, 0x20,
- 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xE5, 0x08, 0xC6, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0xE4, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0xDA, 0x3D,
- 0x4F, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xE6, 0x4E, 0x12, 0x9D, 0x02,
- 0x00, 0x3B, 0x00, 0x96, 0x04, 0x00, 0x08, 0xC9, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xE6,
- 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0xDA, 0x3D, 0x3C, 0x96, 0x07, 0x00,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0xC9, 0x1C, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x0F, 0x00, 0x96,
- 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xE7, 0x08, 0xC9, 0x1C, 0x4F, 0x96, 0x02,
- 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xE8, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xE9, 0x49,
- 0x9D, 0x02, 0x00, 0x2B, 0x00, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xE8,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x3E, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x0E, 0x00, 0x96, 0x02, 0x00,
- 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xE9, 0x05, 0x00, 0x4F, 0x99, 0x02, 0x00, 0x0E, 0x00,
- 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xE9, 0x05, 0x01, 0x4F, 0x96, 0x02,
- 0x00, 0x08, 0xCC, 0x1C, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0xBB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xEA, 0x8E, 0x0D, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x73, 0x73, 0x00, 0xDA, 0x00, 0x96, 0x04, 0x00,
- 0x08, 0xED, 0x08, 0xEB, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0xEC, 0x52, 0x3C, 0x96, 0x02, 0x00, 0x08, 0xED, 0x1C, 0x44, 0x96, 0x02,
- 0x00, 0x08, 0xEE, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x06, 0x00, 0x96, 0x02, 0x00, 0x05, 0x00, 0x3E,
- 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC1, 0x4E, 0x12, 0x12, 0x9D, 0x02,
- 0x00, 0x12, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x08, 0xC1, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xED, 0x46, 0x87, 0x01, 0x00, 0x00, 0x96,
- 0x01, 0x00, 0x02, 0x49, 0x9D, 0x02, 0x00, 0x56, 0x00, 0x96, 0x04, 0x00, 0x08, 0xBF, 0x04, 0x00,
- 0x3C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC1, 0x4E, 0x96, 0x02, 0x00,
- 0x08, 0xBF, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xED, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBF, 0x1C, 0x4E,
- 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBC,
- 0x52, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xBF, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC7, 0x52, 0x17, 0x99, 0x02, 0x00, 0x9C, 0xFF, 0x96,
- 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC3, 0x52,
- 0x17, 0x96, 0x02, 0x00, 0x05, 0x01, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02,
- 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x04, 0x00, 0x08, 0xEF, 0x08,
- 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02,
- 0x00, 0x08, 0xEA, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x4C, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x07, 0x2D, 0x01, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96,
- 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x50, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02,
- 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x51, 0x8E, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x73, 0x72, 0x63, 0x00, 0x6B, 0x00, 0x96, 0x02, 0x00, 0x08, 0x53, 0x1C, 0x96,
- 0x01, 0x00, 0x02, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x19, 0x00, 0x96, 0x09, 0x00, 0x05, 0x00, 0x07,
- 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x50, 0x52, 0x17, 0x99, 0x02,
- 0x00, 0x41, 0x00, 0x96, 0x04, 0x00, 0x08, 0xED, 0x08, 0x53, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01,
- 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xEF, 0x52, 0x3C, 0x96, 0x02, 0x00,
- 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x52, 0x08, 0xED, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0xED, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0x50, 0x52, 0x17, 0x4F, 0x96, 0x0E, 0x00, 0x07, 0x64, 0x00, 0x00, 0x00, 0x08, 0xF0, 0x07,
- 0x71, 0x00, 0x00, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02, 0x00,
- 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96,
- 0x08, 0x00, 0x07, 0x03, 0x04, 0x00, 0x00, 0x02, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08,
- 0x00, 0x3D, 0x17, 0x96, 0x09, 0x00, 0x07, 0x03, 0x04, 0x00, 0x00, 0x08, 0xBB, 0x08, 0xB5, 0x1C,
- 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x0E, 0x00, 0x07,
- 0x01, 0x00, 0x00, 0x00, 0x08, 0xF2, 0x07, 0x9B, 0x02, 0x00, 0x00, 0x08, 0xF1, 0x1C, 0x96, 0x02,
- 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17,
- 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0xF1, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x07,
- 0x00, 0x08, 0xF3, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x1D, 0x96, 0x09, 0x00, 0x08, 0xF4, 0x07,
- 0xCF, 0x07, 0x00, 0x00, 0x08, 0xF3, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08,
- 0x02, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x06, 0x00, 0x00, 0x00, 0x02, 0x08, 0xF3, 0x1C, 0x96,
- 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0xF5,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0xA1, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x69, 0x6E, 0x64, 0x65, 0x78, 0x00, 0x2A, 0x00, 0x96, 0x13, 0x00, 0x08, 0xF6, 0x07, 0xC8, 0x00,
- 0x00, 0x00, 0x07, 0x36, 0x08, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x3C,
- 0x96, 0x02, 0x00, 0x08, 0xF7, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0xF6,
- 0x3D, 0x3E, 0x4F, 0x96, 0x12, 0x00, 0x02, 0x07, 0xC9, 0x00, 0x00, 0x00, 0x07, 0x36, 0x08, 0x00,
- 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x96, 0x09, 0x00, 0x08, 0xCA, 0x07, 0x03,
- 0x00, 0x00, 0x00, 0x08, 0xF5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52, 0x17, 0x96, 0x09, 0x00,
- 0x08, 0xF8, 0x07, 0x36, 0x08, 0x00, 0x00, 0x08, 0xF5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
- 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07,
- 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0xF5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07,
- 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x03, 0x00, 0x09, 0x06, 0x01,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x07, 0x01, 0x8E, 0x08, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC8, 0x00, 0x96, 0x0A, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00,
- 0x00, 0x00, 0x09, 0x06, 0x01, 0x40, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x04, 0x00,
- 0x08, 0xF9, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xF9, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0x1C, 0x1C, 0x96, 0x09, 0x00, 0x08, 0xFB, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFC, 0x40, 0x4F,
- 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x99, 0x02, 0x00, 0x09, 0x00,
- 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C, 0x50, 0x1D, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xFB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x19,
- 0x4E, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x3C, 0x00, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xFB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x4E,
- 0x96, 0x03, 0x00, 0x09, 0x07, 0x01, 0x52, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08,
- 0x1C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xFB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x16, 0x52, 0x17, 0x99,
- 0x02, 0x00, 0x9C, 0xFF, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xFD, 0x08,
- 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xFD, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x3E,
- 0x4F, 0x96, 0x03, 0x00, 0x09, 0x06, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0x08, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x96,
- 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x2D, 0x00, 0x08, 0xFD, 0x08, 0xFE, 0x05, 0x00, 0x08, 0xFF,
- 0x05, 0x00, 0x09, 0x00, 0x01, 0x05, 0x00, 0x09, 0x01, 0x01, 0x05, 0x00, 0x09, 0x02, 0x01, 0x05,
- 0x00, 0x09, 0x03, 0x01, 0x05, 0x00, 0x09, 0x04, 0x01, 0x05, 0x00, 0x09, 0x05, 0x01, 0x05, 0x00,
- 0x07, 0x08, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x4F, 0x96, 0x09, 0x00, 0x07, 0x03, 0x04, 0x00, 0x00,
- 0x02, 0x09, 0x06, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03,
- 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x03, 0x00, 0x09, 0x0C, 0x01, 0x1C, 0x96, 0x02,
- 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x07, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x85, 0x00, 0x96, 0x0A, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x09,
- 0x0C, 0x01, 0x40, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x05, 0x00, 0x09, 0x09, 0x01,
- 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x09, 0x01, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x1C,
- 0x1C, 0x96, 0x04, 0x00, 0x08, 0xF9, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xF9, 0x4E, 0x4F,
- 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x05, 0x00, 0x09, 0x0A, 0x01, 0x08, 0x0A, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x0A, 0x01, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x04, 0x00,
- 0x08, 0x9B, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x9B, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0x1C, 0x1C, 0x96, 0x05, 0x00, 0x09, 0x0B, 0x01, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x0B,
- 0x01, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x3E, 0x4F, 0x96, 0x09, 0x00, 0x07, 0x03,
- 0x04, 0x00, 0x00, 0x02, 0x09, 0x0C, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07,
- 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C,
- 0x96, 0x08, 0x00, 0x09, 0x0D, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02, 0x00,
- 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x0D, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x0E, 0x01,
- 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x96, 0x14, 0x00, 0x09, 0x0F,
- 0x01, 0x07, 0xC8, 0x00, 0x00, 0x00, 0x07, 0x9C, 0x08, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00,
- 0x08, 0x01, 0x3D, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x08, 0x00, 0x07, 0x01, 0x00,
- 0x00, 0x00, 0x09, 0x0F, 0x01, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00,
- 0x08, 0x15, 0x07, 0x00, 0x00, 0x00, 0x00, 0x42, 0x4F, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0x0D, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x0E, 0x01, 0x4E, 0x96, 0x02,
- 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x10, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x1B, 0x52, 0x17, 0x96, 0x0A, 0x00, 0x09, 0x10, 0x01, 0x07, 0x9C, 0x08, 0x00,
- 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x0D, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x0E,
- 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00,
- 0x08, 0x02, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0x04, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0x0D, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x0E, 0x01, 0x4E, 0x96, 0x02,
- 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17,
- 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x0D, 0x01, 0x4E, 0x96, 0x03, 0x00,
- 0x09, 0x11, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27, 0x00, 0x96, 0x02,
- 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x0A, 0x00, 0x09, 0x12, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08,
- 0xFC, 0x40, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x15, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x42, 0x4F, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09,
- 0x0D, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x11, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
- 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1B,
- 0x52, 0x17, 0x96, 0x0A, 0x00, 0x09, 0x13, 0x01, 0x07, 0x9D, 0x08, 0x00, 0x00, 0x08, 0x04, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0x0D, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x11, 0x01, 0x4E, 0x96, 0x02,
- 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17,
- 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09,
- 0x0D, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x11, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
- 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x0B, 0x00, 0x09,
- 0x15, 0x01, 0x07, 0x98, 0x08, 0x00, 0x00, 0x09, 0x14, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
- 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x09, 0x00,
- 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x09, 0x14, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
- 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x03, 0x00, 0x09,
- 0x16, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xA1, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x69, 0x6E, 0x64, 0x65, 0x78, 0x00, 0x2A, 0x00, 0x96, 0x13, 0x00, 0x08, 0xF6, 0x07,
- 0xC8, 0x00, 0x00, 0x00, 0x07, 0x38, 0x08, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01,
- 0x3D, 0x3C, 0x96, 0x02, 0x00, 0x08, 0xF7, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0xF6, 0x3D, 0x3E, 0x4F, 0x96, 0x12, 0x00, 0x02, 0x07, 0xC9, 0x00, 0x00, 0x00, 0x07, 0x38,
- 0x08, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x96, 0x0A, 0x00, 0x08, 0xCA,
- 0x07, 0x03, 0x00, 0x00, 0x00, 0x09, 0x16, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52, 0x17,
- 0x96, 0x0B, 0x00, 0x09, 0x17, 0x01, 0x07, 0x38, 0x08, 0x00, 0x00, 0x09, 0x16, 0x01, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D,
- 0x17, 0x96, 0x09, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x09, 0x16, 0x01, 0x1C, 0x96, 0x02,
- 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17,
- 0x96, 0x14, 0x00, 0x09, 0x18, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x6F, 0x00, 0x00, 0x00,
- 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x1D, 0x96, 0x10, 0x00, 0x07, 0x64, 0x00, 0x00,
- 0x00, 0x09, 0x19, 0x01, 0x07, 0x6F, 0x00, 0x00, 0x00, 0x09, 0x18, 0x01, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96,
- 0x09, 0x00, 0x07, 0x03, 0x04, 0x00, 0x00, 0x02, 0x09, 0x18, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x08,
- 0x00, 0x09, 0x1A, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x1D, 0x96, 0x0B, 0x00, 0x09, 0x1B,
- 0x01, 0x07, 0x58, 0x02, 0x00, 0x00, 0x09, 0x1A, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00,
- 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x03, 0x00, 0x09, 0x1A, 0x01, 0x1C, 0x96, 0x07, 0x00,
- 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1B, 0x52, 0x17, 0x96,
- 0x09, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x09, 0x1A, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07,
- 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x08,
- 0x00, 0x09, 0x1C, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0x1C, 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09, 0x1D, 0x01, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x07, 0x66, 0x08, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D,
- 0x4F, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0x1E, 0x01, 0x07, 0x66, 0x08, 0x00,
- 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x1C, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x1D,
- 0x01, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x0F,
- 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x09, 0x1F, 0x01, 0x07, 0x66, 0x08, 0x00, 0x00, 0x08, 0x04,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0x1C, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x1D, 0x01, 0x4E, 0x96,
- 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x0A,
- 0x00, 0x00, 0x00, 0x09, 0x20, 0x01, 0x07, 0x66, 0x08, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x1C, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x1D, 0x01, 0x4E, 0x96, 0x07, 0x00, 0x07,
- 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x05, 0x00, 0x09, 0x21, 0x01, 0x08, 0x04,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0x1C, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x1D, 0x01, 0x4E, 0x1D,
- 0x96, 0x03, 0x00, 0x09, 0x22, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00,
- 0x08, 0x51, 0x8E, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x72, 0x63, 0x00,
- 0x24, 0x00, 0x96, 0x02, 0x00, 0x08, 0x53, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00,
- 0x08, 0x68, 0x40, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x23, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x0B, 0x00, 0x09, 0x24, 0x01, 0x07, 0x90, 0x01,
- 0x00, 0x00, 0x09, 0x22, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07,
- 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x09, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00,
- 0x02, 0x09, 0x22, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03,
- 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x08, 0x00,
- 0x09, 0x25, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x8E, 0x08, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x00, 0x96, 0x03, 0x00, 0x09, 0x27, 0x01, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x19, 0x4E, 0x96, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x49, 0x9D, 0x02,
- 0x00, 0x38, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x05, 0x00, 0x08, 0x13, 0x09, 0x27,
- 0x01, 0x1C, 0x96, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x28, 0x01, 0x09, 0x27, 0x01, 0x1C, 0x96, 0x05, 0x00, 0x07,
- 0x01, 0x00, 0x00, 0x00, 0x4E, 0x4F, 0x99, 0x02, 0x00, 0x23, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A,
- 0x1C, 0x96, 0x07, 0x00, 0x08, 0x13, 0x07, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0x0A, 0x1C, 0x96, 0x08, 0x00, 0x09, 0x28, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x4F, 0x96,
- 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0x26, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x29, 0x01, 0x8E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x62, 0x00, 0x21, 0x00, 0x96, 0x03, 0x00, 0x09, 0x2B, 0x01,
- 0x1C, 0x96, 0x08, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0x2A, 0x01, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x2C, 0x01, 0x52, 0x96, 0x02, 0x00, 0x08, 0x19, 0x4E, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x4E,
- 0x96, 0x03, 0x00, 0x09, 0x2D, 0x01, 0x8E, 0x15, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x61, 0x00, 0x00, 0x62, 0x00, 0x00, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x00, 0x7F, 0x00, 0x96, 0x03,
- 0x00, 0x09, 0x2B, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0x2E, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x2A, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0x2B, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x0B,
- 0x0C, 0x47, 0x96, 0x03, 0x00, 0x09, 0x2B, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96,
- 0x03, 0x00, 0x09, 0x2E, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x2A, 0x01, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x2B, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E,
- 0x0B, 0x0C, 0x47, 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x53, 0x3E, 0x4F, 0x96, 0x02,
- 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26,
- 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x2F, 0x01, 0x8E, 0x17, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x6C, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x00, 0x00, 0x61, 0x6E, 0x67, 0x6C, 0x65, 0x00,
- 0x5C, 0x00, 0x96, 0x02, 0x00, 0x08, 0x19, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x31, 0x01, 0x1C, 0x96,
- 0x08, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x33,
- 0x01, 0x52, 0x0C, 0x96, 0x02, 0x00, 0x08, 0x19, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x31, 0x01, 0x1C,
- 0x96, 0x08, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09,
- 0x32, 0x01, 0x52, 0x0C, 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x53, 0x3E, 0x4F, 0x96,
- 0x01, 0x00, 0x02, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x96, 0x02,
- 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x0C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01,
- 0x4E, 0x0C, 0x47, 0x96, 0x08, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x34, 0x01, 0x52, 0x3E, 0x96, 0x09, 0x00, 0x08, 0x19, 0x07, 0x03, 0x00, 0x00,
- 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26,
- 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52, 0x17, 0x96,
- 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0x26, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x35, 0x01, 0x8E,
- 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0x74, 0x68, 0x65, 0x72, 0x00, 0x50,
- 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0x36, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x47, 0x96, 0x02, 0x00,
- 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x36, 0x01, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x47, 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08,
- 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x53,
- 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96,
- 0x03, 0x00, 0x09, 0x26, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0x37, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x96, 0x02, 0x00,
- 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x04,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x53, 0x3E,
- 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0x26, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x38,
- 0x01, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0x74, 0x68, 0x65, 0x72,
- 0x00, 0x68, 0x00, 0x96, 0x03, 0x00, 0x09, 0x36, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x4E, 0x54, 0x12,
- 0x12, 0x9D, 0x02, 0x00, 0x06, 0x00, 0x96, 0x02, 0x00, 0x05, 0x00, 0x3E, 0x96, 0x03, 0x00, 0x09,
- 0x36, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x13, 0x4E, 0x49, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x1D, 0x00, 0x17, 0x96, 0x03,
- 0x00, 0x09, 0x36, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08,
- 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x49, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x4E,
- 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x39, 0x01, 0x8E, 0x10, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x00, 0x71, 0x00, 0x96,
- 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x19, 0x4E,
- 0x48, 0x12, 0x12, 0x9D, 0x02, 0x00, 0x05, 0x00, 0x96, 0x01, 0x00, 0x03, 0x3E, 0x96, 0x05, 0x00,
- 0x09, 0x3A, 0x01, 0x08, 0x19, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0x19, 0x4E, 0x0D, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x13, 0x08,
- 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3A, 0x01, 0x1C, 0x0C,
- 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x05, 0x00, 0x09, 0x28, 0x01, 0x08, 0x0A, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3A, 0x01, 0x1C, 0x0C, 0x4F,
- 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0x26, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x2C,
- 0x01, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0x74, 0x68, 0x65, 0x72,
- 0x00, 0x50, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E,
- 0x96, 0x03, 0x00, 0x09, 0x36, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x0B, 0x96,
- 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x36,
- 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x0B, 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00,
- 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26,
- 0x01, 0x53, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0x3B, 0x01, 0x8E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00,
- 0x00, 0x79, 0x00, 0x39, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x02, 0x00, 0x08,
- 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x13, 0x1C, 0x47, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4D, 0x4F,
- 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0x28, 0x01, 0x1C, 0x47, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4D, 0x4F, 0x4F, 0x96,
- 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0x26, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x8E, 0x08,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2D, 0x00, 0x96, 0x05, 0x00, 0x09, 0x3C, 0x01, 0x08,
- 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x47, 0x96, 0x03, 0x00, 0x09, 0x3D, 0x01, 0x47,
- 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x47, 0x96, 0x03,
- 0x00, 0x09, 0x3E, 0x01, 0x47, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x8E, 0x1D, 0x00, 0x00, 0x04, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x79, 0x00, 0x00, 0x77, 0x69, 0x64, 0x74, 0x68, 0x00,
- 0x00, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x00, 0x75, 0x00, 0x96, 0x03, 0x00, 0x09, 0x27, 0x01,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x19, 0x4E, 0x96, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x49,
- 0x9D, 0x02, 0x00, 0x47, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x13,
- 0x08, 0x13, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x28, 0x01,
- 0x09, 0x28, 0x01, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x41,
- 0x01, 0x09, 0x41, 0x01, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09,
- 0x42, 0x01, 0x09, 0x42, 0x01, 0x1C, 0x4F, 0x99, 0x02, 0x00, 0x13, 0x00, 0x96, 0x07, 0x00, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x40, 0x01, 0x52, 0x17, 0x4F,
- 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00,
- 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x37, 0x01,
- 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x41, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28,
- 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x07,
- 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E,
- 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x53, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00,
- 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x57, 0x00, 0x96, 0x05, 0x00, 0x09, 0x3C, 0x01, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0x13, 0x4E, 0x47, 0x96, 0x03, 0x00, 0x09, 0x3D, 0x01, 0x47, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x47, 0x96, 0x03, 0x00, 0x09, 0x43, 0x01, 0x47, 0x96,
- 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01, 0x4E, 0x47, 0x96, 0x03, 0x00,
- 0x09, 0x44, 0x01, 0x47, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01,
- 0x4E, 0x47, 0x96, 0x03, 0x00, 0x09, 0x3E, 0x01, 0x47, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96,
- 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x38, 0x01, 0x8E, 0x0E, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x65, 0x63, 0x74, 0x00, 0xAB, 0x00, 0x96, 0x03, 0x00, 0x09,
- 0x45, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E,
- 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x54, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x1B, 0x00, 0x17,
- 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0x45, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x49, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x1D,
- 0x00, 0x17, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96,
- 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x49, 0x4C, 0x12,
- 0x9D, 0x02, 0x00, 0x1D, 0x00, 0x17, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09,
- 0x41, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01,
- 0x4E, 0x49, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x1D, 0x00, 0x17, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x42, 0x01, 0x4E, 0x49, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08,
- 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x46, 0x01, 0x8E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x78, 0x00, 0x00, 0x79, 0x00, 0x87, 0x00, 0x96, 0x02, 0x00, 0x08, 0x13, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x48, 0x12, 0x4C, 0x12, 0x9D,
- 0x02, 0x00, 0x17, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x48, 0x12, 0x4C, 0x12, 0x9D, 0x02, 0x00,
- 0x22, 0x00, 0x17, 0x96, 0x02, 0x00, 0x08, 0x13, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x41,
- 0x01, 0x4E, 0x47, 0x48, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x24, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09,
- 0x28, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E,
- 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x47, 0x48, 0x3E,
- 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x47,
- 0x01, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x6F, 0x69, 0x6E, 0x74,
- 0x00, 0xA3, 0x00, 0x96, 0x03, 0x00, 0x09, 0x48, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E,
- 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x48, 0x12, 0x4C, 0x12,
- 0x9D, 0x02, 0x00, 0x1E, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09, 0x48, 0x01, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01,
- 0x4E, 0x48, 0x12, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x29, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09, 0x48,
- 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02,
- 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01,
- 0x4E, 0x47, 0x48, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x2B, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09, 0x48,
- 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09,
- 0x42, 0x01, 0x4E, 0x47, 0x48, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0x49, 0x01, 0x8E, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x72, 0x65, 0x63, 0x74, 0x00, 0x63, 0x01, 0x96, 0x05, 0x00, 0x09, 0x4A, 0x01, 0x08, 0x0A,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x41, 0x01, 0x4E, 0x47, 0x3C, 0x96, 0x05, 0x00, 0x09, 0x4B, 0x01, 0x08, 0x0A, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09,
- 0x42, 0x01, 0x4E, 0x47, 0x3C, 0x96, 0x06, 0x00, 0x09, 0x4C, 0x01, 0x09, 0x45, 0x01, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09,
- 0x41, 0x01, 0x4E, 0x47, 0x3C, 0x96, 0x06, 0x00, 0x09, 0x4D, 0x01, 0x09, 0x45, 0x01, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x42, 0x01, 0x4E, 0x47, 0x3C, 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x48,
- 0x12, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x16, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x4A, 0x01, 0x1C, 0x48, 0x4C, 0x12,
- 0x9D, 0x02, 0x00, 0x1E, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01,
- 0x4E, 0x48, 0x12, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x17, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09, 0x45,
- 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x4B, 0x01, 0x1C,
- 0x48, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x15, 0x00, 0x17, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x4C, 0x01, 0x1C, 0x48, 0x4C, 0x12, 0x9D,
- 0x02, 0x00, 0x11, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09, 0x4A, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09,
- 0x4C, 0x01, 0x1C, 0x48, 0x12, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x16, 0x00, 0x17, 0x96, 0x02, 0x00,
- 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x4D, 0x01,
- 0x1C, 0x48, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x11, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09, 0x4B, 0x01,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0x4D, 0x01, 0x1C, 0x48, 0x12, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E,
- 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x4E, 0x01, 0x8E, 0x08, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08,
- 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01, 0x4E, 0x48, 0x12, 0x4C, 0x9D, 0x02, 0x00, 0x15,
- 0x00, 0x17, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x42, 0x01, 0x4E, 0x48, 0x12, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08,
- 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x40, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x47, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x13, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x08, 0x00, 0x09, 0x28, 0x01,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x08, 0x00, 0x09,
- 0x41, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x08,
- 0x00, 0x09, 0x42, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96,
- 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x4F, 0x01, 0x8E, 0x0E, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x65, 0x63, 0x74, 0x00, 0xF4, 0x01, 0x96, 0x0A, 0x00, 0x09,
- 0x50, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x53, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x4E, 0x01, 0x52, 0x4C, 0x9D, 0x02, 0x00, 0x14,
- 0x00, 0x17, 0x96, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x4E, 0x01, 0x52, 0x12, 0x9D, 0x02, 0x00, 0x1C, 0x00, 0x96, 0x08, 0x00, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x09, 0x50, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x40, 0x01, 0x52, 0x17, 0x96,
- 0x03, 0x00, 0x09, 0x50, 0x01, 0x1C, 0x3E, 0x96, 0x03, 0x00, 0x09, 0x50, 0x01, 0x1C, 0x96, 0x05,
- 0x00, 0x08, 0x13, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00,
- 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x08, 0x00, 0x07, 0x02, 0x00, 0x00,
- 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x51, 0x01, 0x52, 0x4F, 0x96, 0x03, 0x00,
- 0x09, 0x50, 0x01, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x28, 0x01, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28,
- 0x01, 0x4E, 0x96, 0x08, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x51, 0x01, 0x52, 0x4F, 0x96, 0x03, 0x00, 0x09, 0x50, 0x01, 0x1C, 0x96, 0x06, 0x00,
- 0x09, 0x41, 0x01, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00,
- 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01, 0x4E, 0x47, 0x96, 0x02, 0x00, 0x08,
- 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x41, 0x01, 0x4E, 0x47, 0x96, 0x08, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x09, 0x30,
- 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x52, 0x01, 0x52, 0x96, 0x03, 0x00, 0x09, 0x50, 0x01, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x0B, 0x4F, 0x96, 0x03, 0x00, 0x09, 0x50, 0x01, 0x1C, 0x96,
- 0x06, 0x00, 0x09, 0x42, 0x01, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E,
- 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x47, 0x96,
- 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08,
- 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x47, 0x96, 0x08, 0x00, 0x07, 0x02, 0x00,
- 0x00, 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x52, 0x01, 0x52, 0x96, 0x03, 0x00,
- 0x09, 0x50, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x0B, 0x4F, 0x96, 0x08, 0x00,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x09, 0x50, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01, 0x4E,
- 0x48, 0x12, 0x4C, 0x9D, 0x02, 0x00, 0x16, 0x00, 0x17, 0x96, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x09, 0x50, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x48, 0x12, 0x12, 0x9D,
- 0x02, 0x00, 0x14, 0x00, 0x96, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x09, 0x50, 0x01, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0x40, 0x01, 0x52, 0x17, 0x96, 0x03, 0x00, 0x09, 0x50, 0x01, 0x1C, 0x3E,
- 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x53,
- 0x01, 0x8E, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x65, 0x63, 0x74, 0x00,
- 0x27, 0x00, 0x96, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x07,
- 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x4F, 0x01, 0x52,
- 0x96, 0x03, 0x00, 0x09, 0x4E, 0x01, 0x52, 0x12, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02,
- 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x54, 0x01, 0x8E, 0x0E, 0x00, 0x00, 0x01, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x72, 0x65, 0x63, 0x74, 0x00, 0xB3, 0x01, 0x96, 0x07, 0x00, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x4E, 0x01, 0x52, 0x12, 0x9D, 0x02,
- 0x00, 0x14, 0x00, 0x96, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x37, 0x01, 0x52, 0x3E, 0x96, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x09,
- 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x4E, 0x01, 0x52, 0x12, 0x9D, 0x02, 0x00, 0x13, 0x00,
- 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x37,
- 0x01, 0x52, 0x3E, 0x96, 0x0A, 0x00, 0x09, 0x54, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x53, 0x3C,
- 0x96, 0x03, 0x00, 0x09, 0x54, 0x01, 0x1C, 0x96, 0x05, 0x00, 0x08, 0x13, 0x09, 0x45, 0x01, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0x13, 0x4E, 0x96, 0x08, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x52, 0x01, 0x52, 0x4F, 0x96, 0x03, 0x00, 0x09, 0x54, 0x01, 0x1C, 0x96, 0x06, 0x00,
- 0x09, 0x28, 0x01, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02,
- 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x08, 0x00, 0x07, 0x02,
- 0x00, 0x00, 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x52, 0x01, 0x52, 0x4F, 0x96,
- 0x03, 0x00, 0x09, 0x54, 0x01, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x41, 0x01, 0x09, 0x45, 0x01, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x41, 0x01, 0x4E, 0x47, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01, 0x4E, 0x47, 0x96,
- 0x08, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x51,
- 0x01, 0x52, 0x96, 0x03, 0x00, 0x09, 0x54, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x0B,
- 0x4F, 0x96, 0x03, 0x00, 0x09, 0x54, 0x01, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x42, 0x01, 0x09, 0x45,
- 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x47, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x42,
- 0x01, 0x4E, 0x47, 0x96, 0x08, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x51, 0x01, 0x52, 0x96, 0x03, 0x00, 0x09, 0x54, 0x01, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x28, 0x01, 0x4E, 0x0B, 0x4F, 0x96, 0x03, 0x00, 0x09, 0x54, 0x01, 0x1C, 0x3E, 0x4F, 0x96,
- 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3B, 0x01, 0x8E,
- 0x10, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x78, 0x00, 0x00, 0x64, 0x79, 0x00,
- 0x3A, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96,
- 0x03, 0x00, 0x09, 0x55, 0x01, 0x1C, 0x47, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4D, 0x4F, 0x96, 0x02,
- 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0x56, 0x01, 0x1C, 0x47, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4D, 0x4F, 0x4F, 0x96, 0x02, 0x00,
- 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x57, 0x01, 0x8E, 0x0B, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x47, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A,
- 0x1C, 0x4C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x58, 0x01, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x13, 0x4E, 0x47, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4D, 0x4F, 0x96, 0x02, 0x00,
- 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x58,
- 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x47, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01,
- 0x4D, 0x4F, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E,
- 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00,
- 0x09, 0x59, 0x01, 0x8E, 0x10, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x78, 0x00,
- 0x00, 0x64, 0x79, 0x00, 0x82, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x02, 0x00,
- 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x55, 0x01, 0x1C, 0x0B, 0x96, 0x02, 0x00, 0x08, 0x13,
- 0x4D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01, 0x4E,
- 0x96, 0x08, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x09, 0x55, 0x01, 0x1C, 0x0C, 0x47, 0x96, 0x03,
- 0x00, 0x09, 0x41, 0x01, 0x4D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00,
- 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x56, 0x01, 0x1C, 0x0B, 0x96, 0x03, 0x00, 0x09,
- 0x28, 0x01, 0x4D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00, 0x09, 0x42,
- 0x01, 0x4E, 0x96, 0x08, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x09, 0x56, 0x01, 0x1C, 0x0C, 0x47,
- 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4D, 0x4F, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00,
- 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x5A, 0x01, 0x8E, 0x0B, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x64, 0x00, 0x9C, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x02,
- 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x58, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13,
- 0x4E, 0x0B, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C,
- 0x96, 0x03, 0x00, 0x09, 0x41, 0x01, 0x4E, 0x96, 0x08, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x09,
- 0x58, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x0C, 0x47, 0x96, 0x03, 0x00, 0x09, 0x41,
- 0x01, 0x4D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0x58, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x0B,
- 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96,
- 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x96, 0x08, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x09, 0x58,
- 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x0C, 0x47, 0x96, 0x03, 0x00, 0x09, 0x42,
- 0x01, 0x4D, 0x4F, 0x4F, 0x8E, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0x65,
- 0x66, 0x74, 0x00, 0x3B, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00, 0x09,
- 0x41, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96,
- 0x03, 0x00, 0x09, 0x5B, 0x01, 0x1C, 0x0B, 0x47, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01, 0x4D, 0x4F,
- 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x05, 0x00, 0x08, 0x13, 0x09, 0x5B, 0x01, 0x1C, 0x4F,
- 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x3E, 0x96, 0x0A, 0x00, 0x09, 0x5B, 0x01, 0x07, 0x03,
- 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00,
- 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52,
- 0x17, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x69, 0x67, 0x68, 0x74,
- 0x00, 0x1E, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x41, 0x01, 0x09,
- 0x5C, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x0B,
- 0x4F, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x96, 0x02, 0x00, 0x08,
- 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x41, 0x01, 0x4E, 0x47, 0x3E, 0x96, 0x0A, 0x00, 0x09, 0x5C, 0x01, 0x07, 0x03, 0x00,
- 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52, 0x17,
- 0x8E, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x6F, 0x70, 0x00, 0x3D, 0x00,
- 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x96, 0x02,
- 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x5D,
- 0x01, 0x1C, 0x0B, 0x47, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4D, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x28, 0x01, 0x09, 0x5D, 0x01, 0x1C, 0x4F, 0x8E, 0x08, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x28, 0x01, 0x4E, 0x3E, 0x96, 0x0A, 0x00, 0x09, 0x5D, 0x01, 0x07, 0x03, 0x00, 0x00,
- 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F,
- 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52, 0x17, 0x8E,
- 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x6F, 0x74, 0x74, 0x6F, 0x6D, 0x00,
- 0x1F, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x42, 0x01, 0x09, 0x5E,
- 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x0B,
- 0x4F, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x96, 0x02, 0x00, 0x08,
- 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x47, 0x3E, 0x96, 0x0A, 0x00, 0x09, 0x5E, 0x01, 0x07, 0x03,
- 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00,
- 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52,
- 0x17, 0x8E, 0x11, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x6F, 0x70, 0x4C, 0x65,
- 0x66, 0x74, 0x00, 0x92, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00, 0x09,
- 0x41, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96,
- 0x03, 0x00, 0x09, 0x5F, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x0B, 0x47, 0x96, 0x03,
- 0x00, 0x09, 0x41, 0x01, 0x4D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00,
- 0x09, 0x42, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0x5F, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x0B,
- 0x47, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96,
- 0x05, 0x00, 0x08, 0x13, 0x09, 0x5F, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x4F, 0x96,
- 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x28, 0x01, 0x09, 0x5F, 0x01, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x4F, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x33, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96,
- 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x02,
- 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00,
- 0x09, 0x26, 0x01, 0x53, 0x3E, 0x96, 0x0A, 0x00, 0x09, 0x5F, 0x01, 0x07, 0x03, 0x00, 0x00, 0x00,
- 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52, 0x17, 0x8E, 0x15,
- 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x6F, 0x74, 0x74, 0x6F, 0x6D, 0x52, 0x69,
- 0x67, 0x68, 0x74, 0x00, 0x4A, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09,
- 0x41, 0x01, 0x09, 0x60, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08,
- 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x0B, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C,
- 0x96, 0x06, 0x00, 0x09, 0x42, 0x01, 0x09, 0x60, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x0B, 0x4F,
- 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x42, 0x01, 0x4E, 0x47, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01, 0x4E, 0x47,
- 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25,
- 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x53, 0x3E, 0x96, 0x0A, 0x00, 0x09, 0x60, 0x01,
- 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96,
- 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08,
- 0x07, 0x52, 0x17, 0x8E, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x69, 0x7A,
- 0x65, 0x00, 0x2D, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x05, 0x00, 0x09, 0x41, 0x01,
- 0x08, 0xE7, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C,
- 0x96, 0x05, 0x00, 0x09, 0x42, 0x01, 0x08, 0xE7, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E,
- 0x4F, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x96, 0x02, 0x00, 0x08,
- 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x41, 0x01, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x04,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x53, 0x3E,
- 0x96, 0x09, 0x00, 0x08, 0xE7, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x61, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x62, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09,
- 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x61, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
- 0x96, 0x03, 0x00, 0x09, 0x37, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F,
- 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x63, 0x01, 0x52, 0x17,
- 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0x61, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x64,
- 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08,
- 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x65, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x61, 0x01, 0x4E,
- 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x66, 0x01, 0x8E, 0x08, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x67, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x61, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0x68, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07,
- 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x69, 0x01, 0x52,
- 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96,
- 0x03, 0x00, 0x09, 0x61, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0x6A, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00,
- 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x6B, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00,
- 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x61, 0x01,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x6C, 0x01, 0x8E, 0x08, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00,
- 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x6D, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x61, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08,
- 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x6E, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96,
- 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x6F, 0x01,
- 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E,
- 0x96, 0x03, 0x00, 0x09, 0x61, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00,
- 0x09, 0x70, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07,
- 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00,
- 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x71, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x02,
- 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x61,
- 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x72, 0x01, 0x8E, 0x08,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0x73, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x61, 0x01, 0x4E, 0x96, 0x02, 0x00,
- 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x74, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C,
- 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x75,
- 0x01, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0x61, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0x76, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96,
- 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x77, 0x01, 0x52, 0x17, 0x4F, 0x96,
- 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0x61, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x8E, 0x08,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0x78, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09, 0x79, 0x01, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x07, 0x51, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96,
- 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0x79, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x8E, 0x08,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0x7A, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00,
- 0x00, 0x09, 0x7B, 0x01, 0x07, 0x51, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09,
- 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x79, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
- 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x0F, 0x00, 0x07,
- 0x65, 0x00, 0x00, 0x00, 0x09, 0x7C, 0x01, 0x07, 0x51, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x79, 0x01, 0x4E, 0x96, 0x02, 0x00,
- 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96,
- 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09,
- 0x7D, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x52, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00,
- 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96, 0x0F, 0x00, 0x07, 0x65, 0x00, 0x00, 0x00, 0x09, 0x7E, 0x01,
- 0x07, 0x52, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96,
- 0x03, 0x00, 0x09, 0x7D, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07,
- 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x07,
- 0x00, 0x08, 0xD4, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0xD4, 0x4E, 0x96, 0x14, 0x00, 0x09, 0x7F, 0x01, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x07, 0x4C, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96,
- 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD4, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x7F,
- 0x01, 0x4E, 0x96, 0x08, 0x00, 0x09, 0x80, 0x01, 0x07, 0x01, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02,
- 0x00, 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD4, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x7F, 0x01,
- 0x4E, 0x96, 0x08, 0x00, 0x09, 0x81, 0x01, 0x07, 0x02, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00,
- 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD4, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x7F, 0x01, 0x4E,
- 0x96, 0x08, 0x00, 0x09, 0x82, 0x01, 0x07, 0x04, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD4, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x7F, 0x01, 0x4E, 0x96,
- 0x08, 0x00, 0x09, 0x83, 0x01, 0x07, 0x08, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x0F, 0x00, 0x07, 0x28,
- 0x00, 0x00, 0x00, 0x09, 0x84, 0x01, 0x07, 0x4C, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x02,
- 0x00, 0x08, 0xD4, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x7F, 0x01, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04,
- 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09,
- 0x85, 0x01, 0x07, 0x4C, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD4, 0x4E,
- 0x96, 0x03, 0x00, 0x09, 0x7F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00,
- 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x64, 0x00, 0x00,
- 0x00, 0x09, 0x86, 0x01, 0x07, 0x4C, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0xD4, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x7F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96,
- 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04,
- 0x1C, 0x96, 0x08, 0x00, 0x09, 0x87, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02,
- 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88,
- 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00,
- 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0x89, 0x01, 0x8E, 0x20, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x6E, 0x61, 0x6D, 0x65, 0x00, 0x00, 0x69, 0x6E, 0x73, 0x74, 0x61, 0x6E, 0x63, 0x65, 0x00,
- 0x00, 0x6D, 0x65, 0x74, 0x68, 0x6F, 0x64, 0x00, 0xC7, 0x00, 0x96, 0x02, 0x00, 0x08, 0x9D, 0x1C,
- 0x12, 0x4C, 0x9D, 0x02, 0x00, 0x1D, 0x00, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0x8A, 0x01, 0x4E, 0x12, 0x12, 0x9D, 0x02, 0x00, 0x06, 0x00, 0x96, 0x02, 0x00, 0x05, 0x00, 0x3E,
- 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87,
- 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x8B, 0x01, 0x52,
- 0x17, 0x8E, 0x11, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x65, 0x71, 0x75, 0x65,
- 0x73, 0x74, 0x00, 0x35, 0x00, 0x96, 0x03, 0x00, 0x09, 0x8D, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0x9D, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x8C, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00,
- 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88,
- 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x8E, 0x01, 0x52, 0x3E, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C,
- 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87,
- 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x8F, 0x01, 0x52,
- 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96,
- 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x90, 0x01, 0x8E, 0x0E, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6E, 0x61, 0x6D, 0x65, 0x00, 0xF6, 0x02, 0x96, 0x02, 0x00,
- 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0x8A, 0x01, 0x4E, 0x12, 0x12, 0x9D, 0x02, 0x00, 0x05, 0x00, 0x96,
- 0x01, 0x00, 0x02, 0x3E, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00,
- 0x09, 0x8B, 0x01, 0x52, 0x17, 0x96, 0x06, 0x00, 0x09, 0x8D, 0x01, 0x09, 0x91, 0x01, 0x3C, 0x96,
- 0x0A, 0x00, 0x09, 0x93, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x92,
- 0x01, 0x52, 0x3C, 0x96, 0x03, 0x00, 0x09, 0x93, 0x01, 0x1C, 0x96, 0x01, 0x00, 0x02, 0x49, 0x12,
- 0x12, 0x9D, 0x02, 0x00, 0x18, 0x00, 0x96, 0x03, 0x00, 0x09, 0x8D, 0x01, 0x4C, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x93, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x94, 0x01, 0x47, 0x47, 0x1D, 0x96, 0x03,
- 0x00, 0x09, 0x8D, 0x01, 0x4C, 0x1C, 0x96, 0x05, 0x00, 0x09, 0x95, 0x01, 0x08, 0x0E, 0x1C, 0x47,
- 0x96, 0x03, 0x00, 0x09, 0x96, 0x01, 0x47, 0x47, 0x1D, 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x01,
- 0x00, 0x00, 0x00, 0x3C, 0x99, 0x02, 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C,
- 0x50, 0x1D, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x27, 0x01, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x19, 0x4E, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x5F, 0x00, 0x96, 0x07, 0x00, 0x07,
- 0x01, 0x00, 0x00, 0x00, 0x08, 0x18, 0x1C, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x10, 0x00, 0x96, 0x03,
- 0x00, 0x09, 0x8D, 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x97, 0x01, 0x47, 0x1D, 0x96, 0x03,
- 0x00, 0x09, 0x8D, 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x27, 0x01, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0x18, 0x1C, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00,
- 0x09, 0x98, 0x01, 0x52, 0x47, 0x1D, 0x99, 0x02, 0x00, 0x7E, 0xFF, 0x96, 0x03, 0x00, 0x09, 0x8D,
- 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x99, 0x01, 0x47, 0x1D, 0x96, 0x03, 0x00, 0x09, 0x93,
- 0x01, 0x1C, 0x96, 0x01, 0x00, 0x02, 0x49, 0x12, 0x12, 0x9D, 0x02, 0x00, 0x10, 0x00, 0x96, 0x03,
- 0x00, 0x09, 0x8D, 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x3E, 0x01, 0x47, 0x1D, 0x96, 0x03,
- 0x00, 0x09, 0x8D, 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x9A, 0x01, 0x47, 0x1D, 0x96, 0x03,
- 0x00, 0x09, 0x93, 0x01, 0x1C, 0x96, 0x01, 0x00, 0x02, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x15, 0x00,
- 0x96, 0x03, 0x00, 0x09, 0x8D, 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x9C, 0x01, 0x47, 0x1D,
- 0x99, 0x02, 0x00, 0x18, 0x00, 0x96, 0x03, 0x00, 0x09, 0x8D, 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x93, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x9B, 0x01, 0x47, 0x47, 0x1D, 0x96, 0x05, 0x00,
- 0x08, 0xED, 0x09, 0x8D, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96,
- 0x03, 0x00, 0x09, 0x9D, 0x01, 0x52, 0x3C, 0x96, 0x02, 0x00, 0x08, 0xED, 0x1C, 0x96, 0x01, 0x00,
- 0x02, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x6E, 0x00, 0x96, 0x08, 0x00, 0x09, 0x8D, 0x01, 0x09, 0x9E,
- 0x01, 0x08, 0x0E, 0x1C, 0x47, 0x96, 0x03, 0x00, 0x09, 0x9F, 0x01, 0x47, 0x96, 0x03, 0x00, 0x09,
- 0x27, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0xA0, 0x01, 0x52, 0x47, 0x96, 0x03, 0x00, 0x09, 0xA1, 0x01, 0x47, 0x1D, 0x96, 0x05, 0x00, 0x08,
- 0xED, 0x09, 0x8D, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0xA2, 0x01, 0x52, 0x1D, 0x96, 0x02, 0x00, 0x08, 0xED, 0x1C, 0x96, 0x01, 0x00, 0x02,
- 0x49, 0x12, 0x9D, 0x02, 0x00, 0x05, 0x00, 0x96, 0x01, 0x00, 0x02, 0x3E, 0x96, 0x0A, 0x00, 0x09,
- 0xA3, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x68, 0x40, 0x3C, 0x96, 0x03, 0x00, 0x09, 0xA3,
- 0x01, 0x1C, 0x96, 0x05, 0x00, 0x09, 0xA4, 0x01, 0x05, 0x01, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xED,
- 0x1C, 0x96, 0x08, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x02, 0x00,
- 0x08, 0x6D, 0x52, 0x17, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA5,
- 0x01, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA6,
- 0x01, 0x52, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x8E, 0x01, 0x8E, 0x23,
- 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x69, 0x6E, 0x73, 0x74, 0x61, 0x6E, 0x63, 0x65,
- 0x00, 0x00, 0x6D, 0x65, 0x74, 0x68, 0x6F, 0x64, 0x00, 0x00, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73,
- 0x74, 0x00, 0x9A, 0x01, 0x96, 0x0A, 0x00, 0x09, 0xA3, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08,
- 0x68, 0x40, 0x3C, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x05, 0x00, 0x09, 0xA4, 0x01,
- 0x05, 0x01, 0x4F, 0x96, 0x03, 0x00, 0x09, 0x8D, 0x01, 0x1C, 0x96, 0x08, 0x00, 0x07, 0x01, 0x00,
- 0x00, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x6D, 0x52, 0x17, 0x96, 0x04, 0x00,
- 0x09, 0xA7, 0x01, 0x02, 0x3C, 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3C,
- 0x99, 0x02, 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C, 0x50, 0x1D, 0x96, 0x02,
- 0x00, 0x08, 0x18, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA5,
- 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x19, 0x4E, 0x48,
- 0x12, 0x9D, 0x02, 0x00, 0x5A, 0x00, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0xA5, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x18,
- 0x1C, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA9, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x27, 0x01, 0x49,
- 0x12, 0x9D, 0x02, 0x00, 0x25, 0x00, 0x96, 0x06, 0x00, 0x09, 0xA7, 0x01, 0x09, 0xA3, 0x01, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0xA5, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96, 0x02,
- 0x00, 0x08, 0x18, 0x1C, 0x4E, 0x1D, 0x99, 0x02, 0x00, 0x05, 0x00, 0x99, 0x02, 0x00, 0x75, 0xFF,
- 0x96, 0x05, 0x00, 0x08, 0xED, 0x09, 0xA7, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00,
- 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88,
- 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xAA, 0x01, 0x52, 0x96, 0x03, 0x00, 0x09, 0x8C, 0x01, 0x1C,
- 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x9D, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xAB,
- 0x01, 0x52, 0x3C, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA5, 0x01,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0xAC, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xAD, 0x01, 0x4E, 0x96,
- 0x03, 0x00, 0x09, 0xAE, 0x01, 0x49, 0x9D, 0x02, 0x00, 0x2C, 0x00, 0x96, 0x02, 0x00, 0x08, 0xED,
- 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09,
- 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xAF, 0x01,
- 0x52, 0x3E, 0x99, 0x02, 0x00, 0x27, 0x00, 0x96, 0x02, 0x00, 0x08, 0xED, 0x1C, 0x96, 0x07, 0x00,
- 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96,
- 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x98, 0x01, 0x52, 0x3E, 0x4F, 0x96,
- 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xB0, 0x01, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x61, 0x72, 0x72, 0x61, 0x79, 0x00, 0xA2, 0x00, 0x96, 0x06, 0x00, 0x09, 0xB2,
- 0x01, 0x09, 0xB1, 0x01, 0x3C, 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3C,
- 0x99, 0x02, 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C, 0x50, 0x1D, 0x96, 0x02,
- 0x00, 0x08, 0x18, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xB3, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x19,
- 0x4E, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x56, 0x00, 0x96, 0x03, 0x00, 0x09, 0xB2, 0x01, 0x4C, 0x1C,
- 0x96, 0x05, 0x00, 0x09, 0xB4, 0x01, 0x08, 0x18, 0x1C, 0x47, 0x96, 0x03, 0x00, 0x09, 0xB5, 0x01,
- 0x47, 0x96, 0x03, 0x00, 0x09, 0xB3, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x4E, 0x96,
- 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xAF, 0x01, 0x52, 0x47,
- 0x96, 0x03, 0x00, 0x09, 0xB6, 0x01, 0x47, 0x47, 0x1D, 0x99, 0x02, 0x00, 0x87, 0xFF, 0x96, 0x03,
- 0x00, 0x09, 0xB2, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xB7, 0x01, 0x47, 0x3E, 0x4F, 0x96, 0x02,
- 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88,
- 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA0, 0x01, 0x8E, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x61, 0x72, 0x67, 0x73, 0x00, 0x89, 0x00, 0x96, 0x06, 0x00, 0x09, 0xB2, 0x01, 0x09,
- 0xB8, 0x01, 0x3C, 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x99, 0x02,
- 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C, 0x50, 0x1D, 0x96, 0x02, 0x00, 0x08,
- 0x18, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA7, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x19, 0x4E, 0x48,
- 0x12, 0x9D, 0x02, 0x00, 0x3D, 0x00, 0x96, 0x03, 0x00, 0x09, 0xB2, 0x01, 0x4C, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0xA7, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x4E, 0x96, 0x07, 0x00, 0x07,
- 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xAF, 0x01, 0x52, 0x47, 0x1D, 0x99, 0x02,
- 0x00, 0xA0, 0xFF, 0x96, 0x03, 0x00, 0x09, 0xB2, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xB9, 0x01,
- 0x47, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E,
- 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xBA, 0x01, 0x8E, 0x0D, 0x00,
- 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0x62, 0x6A, 0x00, 0x8C, 0x00, 0x96, 0x06, 0x00,
- 0x09, 0xB2, 0x01, 0x09, 0xBB, 0x01, 0x3C, 0x96, 0x03, 0x00, 0x09, 0xBC, 0x01, 0x46, 0x87, 0x01,
- 0x00, 0x00, 0x96, 0x01, 0x00, 0x02, 0x49, 0x9D, 0x02, 0x00, 0x5E, 0x00, 0x96, 0x04, 0x00, 0x08,
- 0xBF, 0x04, 0x00, 0x3C, 0x96, 0x03, 0x00, 0x09, 0xB2, 0x01, 0x4C, 0x1C, 0x96, 0x05, 0x00, 0x09,
- 0xB4, 0x01, 0x08, 0xBF, 0x1C, 0x47, 0x96, 0x03, 0x00, 0x09, 0xB5, 0x01, 0x47, 0x96, 0x03, 0x00,
- 0x09, 0xBC, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBF, 0x1C, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01,
- 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00,
- 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xAF, 0x01, 0x52, 0x47, 0x96, 0x03, 0x00, 0x09,
- 0xB6, 0x01, 0x47, 0x47, 0x1D, 0x99, 0x02, 0x00, 0x94, 0xFF, 0x96, 0x03, 0x00, 0x09, 0xB2, 0x01,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0xBD, 0x01, 0x47, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0xAF, 0x01, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x61,
- 0x6C, 0x75, 0x65, 0x00, 0x7A, 0x01, 0x96, 0x05, 0x00, 0x08, 0xA3, 0x09, 0x2E, 0x01, 0x1C, 0x44,
- 0x3C, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xBE, 0x01, 0x49, 0x9D, 0x02,
- 0x00, 0x2A, 0x01, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x09, 0x49, 0x9D,
- 0x02, 0x00, 0x0D, 0x01, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xC3, 0x01,
- 0x49, 0x9D, 0x02, 0x00, 0xE3, 0x00, 0x96, 0x03, 0x00, 0x09, 0x2E, 0x01, 0x1C, 0x96, 0x01, 0x00,
- 0x02, 0x49, 0x9D, 0x02, 0x00, 0xC6, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0xC7, 0x01, 0x49, 0x9D, 0x02, 0x00, 0x91, 0x00, 0x96, 0x0A, 0x00, 0x08, 0x19, 0x07, 0x01,
- 0x00, 0x00, 0x00, 0x09, 0x2E, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xCA, 0x01, 0x52, 0x9D, 0x02,
- 0x00, 0x4A, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBD, 0x49, 0x9D,
- 0x02, 0x00, 0x0C, 0x00, 0x96, 0x03, 0x00, 0x09, 0xC6, 0x01, 0x3E, 0x99, 0x02, 0x00, 0x28, 0x00,
- 0x96, 0x03, 0x00, 0x09, 0x2E, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08,
- 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E,
- 0x96, 0x03, 0x00, 0x09, 0xBA, 0x01, 0x52, 0x3E, 0x99, 0x02, 0x00, 0x28, 0x00, 0x96, 0x03, 0x00,
- 0x09, 0x2E, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00,
- 0x09, 0xB0, 0x01, 0x52, 0x3E, 0x99, 0x02, 0x00, 0x1E, 0x00, 0x96, 0x03, 0x00, 0x09, 0x2E, 0x01,
- 0x1C, 0x9D, 0x02, 0x00, 0x0B, 0x00, 0x96, 0x03, 0x00, 0x09, 0xC9, 0x01, 0x99, 0x02, 0x00, 0x06,
- 0x00, 0x96, 0x03, 0x00, 0x09, 0xC8, 0x01, 0x3E, 0x99, 0x02, 0x00, 0x07, 0x00, 0x96, 0x03, 0x00,
- 0x09, 0xC6, 0x01, 0x3E, 0x99, 0x02, 0x00, 0x13, 0x00, 0x96, 0x06, 0x00, 0x09, 0xC4, 0x01, 0x09,
- 0x2E, 0x01, 0x1C, 0x47, 0x96, 0x03, 0x00, 0x09, 0xC5, 0x01, 0x47, 0x3E, 0x99, 0x02, 0x00, 0x07,
- 0x00, 0x96, 0x03, 0x00, 0x09, 0xC2, 0x01, 0x3E, 0x99, 0x02, 0x00, 0x33, 0x00, 0x96, 0x06, 0x00,
- 0x09, 0xBF, 0x01, 0x09, 0x2E, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08,
- 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E,
- 0x96, 0x03, 0x00, 0x09, 0xC0, 0x01, 0x52, 0x47, 0x96, 0x03, 0x00, 0x09, 0xC1, 0x01, 0x47, 0x3E,
- 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xCB, 0x01, 0x8E, 0x0D, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x6D, 0x6C, 0x00, 0xE1, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x1D, 0x99, 0x02, 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C, 0x50, 0x1D,
- 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0xA8, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x19, 0x4E, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x94,
- 0x00, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96,
- 0x02, 0x00, 0x08, 0x18, 0x1C, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA9, 0x01, 0x4E, 0x96, 0x03, 0x00,
- 0x09, 0xCC, 0x01, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x66, 0x00, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96, 0x02,
- 0x00, 0x08, 0x18, 0x1C, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xAC, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0x93, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA5, 0x01, 0x4E, 0x96,
- 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA6, 0x01, 0x52, 0x4F,
- 0x99, 0x02, 0x00, 0x42, 0xFF, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x3E, 0x4F, 0x96, 0x02, 0x00,
- 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0xCD, 0x01, 0x8E, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x78, 0x6D, 0x6C, 0x00, 0xE4, 0x00, 0x96, 0x08, 0x00, 0x09, 0x2A, 0x01, 0x07, 0x00, 0x00,
- 0x00, 0x00, 0x42, 0x3C, 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x1D, 0x99,
- 0x02, 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C, 0x50, 0x1D, 0x96, 0x02, 0x00,
- 0x08, 0x18, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x19, 0x4E, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x95, 0x00, 0x96, 0x03,
- 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08,
- 0x18, 0x1C, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA9, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xCC, 0x01,
- 0x49, 0x12, 0x9D, 0x02, 0x00, 0x67, 0x00, 0x96, 0x03, 0x00, 0x09, 0x2A, 0x01, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08,
- 0x18, 0x1C, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xAC, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x93, 0x01,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96,
- 0x02, 0x00, 0x08, 0x18, 0x1C, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA5, 0x01, 0x4E, 0x96, 0x07, 0x00,
- 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96,
- 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA6, 0x01, 0x52, 0x4F, 0x99, 0x02,
- 0x00, 0x41, 0xFF, 0x96, 0x03, 0x00, 0x09, 0x2A, 0x01, 0x1C, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E,
- 0x96, 0x03, 0x00, 0x09, 0xA6, 0x01, 0x8E, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x78, 0x6D, 0x6C, 0x00, 0xC2, 0x01, 0x96, 0x05, 0x00, 0x08, 0xA3, 0x09, 0xA3, 0x01, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0xA9, 0x01, 0x4E, 0x3C, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0xC3, 0x01, 0x49, 0x9D, 0x02, 0x00, 0x79, 0x01, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0xBE, 0x01, 0x49, 0x9D, 0x02, 0x00, 0x27, 0x01, 0x96, 0x02, 0x00, 0x08, 0xA3,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0xDF, 0x49, 0x9D, 0x02, 0x00, 0x0B, 0x01, 0x96, 0x02, 0x00, 0x08,
- 0xA3, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xDE, 0x49, 0x9D, 0x02, 0x00, 0xEF, 0x00, 0x96, 0x02, 0x00,
- 0x08, 0xA3, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xEE, 0x49, 0x9D, 0x02, 0x00, 0xD4, 0x00, 0x96, 0x02,
- 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x09, 0x49, 0x9D, 0x02, 0x00, 0xB9, 0x00, 0x96,
- 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBD, 0x49, 0x9D, 0x02, 0x00, 0x7B, 0x00,
- 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xB3, 0x01, 0x49, 0x9D, 0x02, 0x00,
- 0x3C, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xD1, 0x01, 0x49, 0x9D,
- 0x02, 0x00, 0x0A, 0x00, 0x96, 0x01, 0x00, 0x03, 0x3E, 0x99, 0x02, 0x00, 0x1B, 0x00, 0x96, 0x03,
- 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA5, 0x01, 0x4E, 0x96, 0x08, 0x00, 0x07,
- 0x01, 0x00, 0x00, 0x00, 0x09, 0xCF, 0x01, 0x3D, 0x3E, 0x99, 0x02, 0x00, 0x28, 0x00, 0x96, 0x03,
- 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0xCD, 0x01, 0x52, 0x3E, 0x99, 0x02, 0x00, 0x28, 0x00, 0x96, 0x03, 0x00, 0x09, 0xA3,
- 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xCB,
- 0x01, 0x52, 0x3E, 0x99, 0x02, 0x00, 0x05, 0x00, 0x96, 0x01, 0x00, 0x03, 0x3E, 0x99, 0x02, 0x00,
- 0x05, 0x00, 0x96, 0x01, 0x00, 0x02, 0x3E, 0x99, 0x02, 0x00, 0x06, 0x00, 0x96, 0x02, 0x00, 0x05,
- 0x01, 0x3E, 0x99, 0x02, 0x00, 0x06, 0x00, 0x96, 0x02, 0x00, 0x05, 0x00, 0x3E, 0x99, 0x02, 0x00,
- 0x3B, 0x00, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA5, 0x01, 0x4E,
- 0x96, 0x08, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0xCF, 0x01, 0x3D, 0x96, 0x07, 0x00, 0x07,
- 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xD0, 0x01, 0x52, 0x3E, 0x99, 0x02, 0x00,
- 0x26, 0x00, 0x96, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0xA5, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x52, 0x96, 0x08, 0x00, 0x07, 0x01,
- 0x00, 0x00, 0x00, 0x09, 0xCE, 0x01, 0x3D, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00,
- 0x09, 0xAA, 0x01, 0x8E, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x6D, 0x6C,
- 0x00, 0x9C, 0x00, 0x96, 0x08, 0x00, 0x09, 0xA7, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x42, 0x3C,
- 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x99, 0x02, 0x00, 0x09, 0x00,
- 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C, 0x50, 0x1D, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96, 0x02, 0x00,
- 0x08, 0x19, 0x4E, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x4D, 0x00, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x4E, 0x96,
- 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA6, 0x01, 0x52, 0x96,
- 0x08, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0xA7, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x16,
- 0x52, 0x17, 0x99, 0x02, 0x00, 0x89, 0xFF, 0x96, 0x03, 0x00, 0x09, 0xA7, 0x01, 0x1C, 0x3E, 0x4F,
- 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00,
- 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xD2, 0x01, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x61, 0x72, 0x72, 0x61, 0x79, 0x00, 0xB0, 0x00, 0x96, 0x06, 0x00, 0x09,
- 0xB2, 0x01, 0x09, 0xD3, 0x01, 0x3C, 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x3C, 0x99, 0x02, 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C, 0x50, 0x1D, 0x96,
- 0x02, 0x00, 0x08, 0x18, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xB3, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08,
- 0x19, 0x4E, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x64, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x96,
- 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x49, 0x12, 0x12, 0x9D, 0x02, 0x00, 0x10, 0x00, 0x96,
- 0x03, 0x00, 0x09, 0xB2, 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x97, 0x01, 0x47, 0x1D, 0x96,
- 0x03, 0x00, 0x09, 0xB2, 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xB3, 0x01, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0xD4, 0x01, 0x1C, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96,
- 0x03, 0x00, 0x09, 0x98, 0x01, 0x52, 0x47, 0x1D, 0x99, 0x02, 0x00, 0x79, 0xFF, 0x96, 0x03, 0x00,
- 0x09, 0xB2, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xD5, 0x01, 0x47, 0x3E, 0x4F, 0x96, 0x02, 0x00,
- 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0xD6, 0x01, 0x8E, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x6F, 0x62, 0x6A, 0x00, 0xB0, 0x00, 0x96, 0x06, 0x00, 0x09, 0xB2, 0x01, 0x09, 0xD7, 0x01,
- 0x3C, 0x96, 0x05, 0x00, 0x09, 0xD8, 0x01, 0x05, 0x00, 0x3C, 0x96, 0x03, 0x00, 0x09, 0xBC, 0x01,
- 0x46, 0x87, 0x01, 0x00, 0x00, 0x96, 0x01, 0x00, 0x02, 0x49, 0x9D, 0x02, 0x00, 0x79, 0x00, 0x96,
- 0x04, 0x00, 0x08, 0xBF, 0x04, 0x00, 0x3C, 0x96, 0x03, 0x00, 0x09, 0xD8, 0x01, 0x1C, 0x12, 0x9D,
- 0x02, 0x00, 0x10, 0x00, 0x96, 0x03, 0x00, 0x09, 0xB2, 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00, 0x09,
- 0x97, 0x01, 0x47, 0x1D, 0x96, 0x05, 0x00, 0x09, 0xD8, 0x01, 0x05, 0x01, 0x1D, 0x96, 0x03, 0x00,
- 0x09, 0xB2, 0x01, 0x4C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBF, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xD9,
- 0x01, 0x47, 0x96, 0x03, 0x00, 0x09, 0xBC, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBF, 0x1C, 0x4E,
- 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87,
- 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x98, 0x01, 0x52,
- 0x47, 0x47, 0x1D, 0x99, 0x02, 0x00, 0x79, 0xFF, 0x96, 0x03, 0x00, 0x09, 0xB2, 0x01, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0xDA, 0x01, 0x47, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0x98, 0x01, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x61, 0x6C, 0x75,
- 0x65, 0x00, 0x07, 0x01, 0x96, 0x05, 0x00, 0x08, 0xA3, 0x09, 0x2E, 0x01, 0x1C, 0x44, 0x3C, 0x96,
- 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xBE, 0x01, 0x49, 0x9D, 0x02, 0x00, 0x97,
- 0x00, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBD, 0x49, 0x9D, 0x02, 0x00,
- 0x19, 0x00, 0x96, 0x03, 0x00, 0x09, 0x2E, 0x01, 0x1C, 0x96, 0x08, 0x00, 0x07, 0x01, 0x00, 0x00,
- 0x00, 0x09, 0xCF, 0x01, 0x3D, 0x3E, 0x99, 0x02, 0x00, 0x68, 0x00, 0x96, 0x03, 0x00, 0x09, 0x2E,
- 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xFC, 0x1C, 0x54, 0x9D, 0x02, 0x00, 0x2D, 0x00, 0x96, 0x03,
- 0x00, 0x09, 0x2E, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0xD6, 0x01, 0x52, 0x3E, 0x99, 0x02, 0x00, 0x28, 0x00, 0x96, 0x03, 0x00, 0x09, 0x2E,
- 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xD2,
- 0x01, 0x52, 0x3E, 0x99, 0x02, 0x00, 0x53, 0x00, 0x96, 0x06, 0x00, 0x09, 0xDB, 0x01, 0x09, 0x2E,
- 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xD0,
- 0x01, 0x52, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xDC,
- 0x01, 0x52, 0x47, 0x96, 0x03, 0x00, 0x09, 0xDB, 0x01, 0x47, 0x3E, 0x4F, 0x96, 0x0A, 0x00, 0x09,
- 0xDD, 0x01, 0x07, 0x0E, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00,
- 0x08, 0x02, 0x3D, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x64, 0x00, 0x00, 0x00, 0x09, 0xDE, 0x01, 0x07,
- 0x0E, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D,
- 0x17, 0x96, 0x08, 0x00, 0x07, 0x07, 0x10, 0x00, 0x00, 0x02, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03,
- 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x03, 0x00, 0x09, 0xDF, 0x01, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0xE0, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96,
- 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xE1, 0x01, 0x52, 0x17, 0x4F, 0x96,
- 0x03, 0x00, 0x09, 0xDF, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xE2, 0x01, 0x8E, 0x08, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0xE3, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x03, 0x00, 0x09, 0xDF, 0x01, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0xE4, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96,
- 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xE5, 0x01, 0x52, 0x17, 0x4F, 0x96,
- 0x03, 0x00, 0x09, 0xDF, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xE6, 0x01, 0x8E, 0x08, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0xE7, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x0B, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09,
- 0xE8, 0x01, 0x09, 0xDF, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00,
- 0x3D, 0x17, 0x96, 0x0B, 0x00, 0x09, 0xE9, 0x01, 0x07, 0x3A, 0x08, 0x00, 0x00, 0x09, 0xDF, 0x01,
- 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08,
- 0x02, 0x3D, 0x17, 0x96, 0x09, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x09, 0xDF, 0x01, 0x1C,
- 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00,
- 0x3D, 0x17, 0x96, 0x03, 0x00, 0x09, 0xEC, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xED, 0x01, 0x8E,
- 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0xEE, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x0B, 0x00, 0x07, 0x01, 0x00,
- 0x00, 0x00, 0x09, 0xED, 0x01, 0x09, 0xEC, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00,
- 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x14, 0x00, 0x09, 0xEF, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x07, 0x69, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x1D, 0x96, 0x03,
- 0x00, 0x09, 0xEF, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x04, 0x00, 0x08, 0x9A,
- 0x05, 0x01, 0x4F, 0x96, 0x03, 0x00, 0x09, 0xEF, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
- 0x96, 0x04, 0x00, 0x08, 0x9B, 0x05, 0x01, 0x4F, 0x96, 0x03, 0x00, 0x09, 0xEF, 0x01, 0x1C, 0x96,
- 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x14, 0x00, 0x09, 0xF0, 0x01, 0x07, 0x03, 0x00, 0x00, 0x00,
- 0x07, 0x69, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x10,
- 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x09, 0xF1, 0x01, 0x07, 0x69, 0x00, 0x00, 0x00, 0x09, 0xEF,
- 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00,
- 0x08, 0x03, 0x3D, 0x17, 0x96, 0x0F, 0x00, 0x07, 0xC8, 0x00, 0x00, 0x00, 0x08, 0xB9, 0x07, 0x84,
- 0x03, 0x00, 0x00, 0x09, 0xEF, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00,
- 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96,
- 0x08, 0x00, 0x09, 0xF2, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02, 0x00, 0x08,
- 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09, 0xF3, 0x01, 0x07,
- 0x00, 0x00, 0x00, 0x00, 0x07, 0x58, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A,
- 0x3D, 0x4F, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0xF4, 0x01, 0x07, 0x58, 0x04,
- 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0xF3, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00,
- 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2,
- 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09, 0xF5, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x53, 0x04,
- 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF5, 0x01, 0x4E, 0x96,
- 0x09, 0x00, 0x08, 0x0D, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09,
- 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF3, 0x01, 0x53, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF5, 0x01, 0x4E, 0x96,
- 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x6A, 0x3A, 0x17, 0x96, 0x0F, 0x00, 0x07,
- 0x01, 0x00, 0x00, 0x00, 0x09, 0xF6, 0x01, 0x07, 0x53, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF5, 0x01, 0x4E, 0x96, 0x02, 0x00,
- 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96,
- 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09,
- 0xF7, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x4E, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00,
- 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2,
- 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF7, 0x01, 0x4E, 0x96, 0x09, 0x00, 0x08, 0x0D, 0x07, 0x00,
- 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00,
- 0x09, 0xF3, 0x01, 0x53, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2,
- 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF7, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96,
- 0x02, 0x00, 0x08, 0x6A, 0x3A, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0xF8,
- 0x01, 0x07, 0x4E, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E,
- 0x96, 0x03, 0x00, 0x09, 0xF7, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00,
- 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09, 0xF9, 0x01, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x07, 0x56, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96,
- 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0xF9, 0x01, 0x4E, 0x96, 0x09, 0x00, 0x08, 0x0D, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C,
- 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF3, 0x01, 0x53, 0x4F, 0x96,
- 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0xF9, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x6A, 0x3A, 0x17,
- 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0xFA, 0x01, 0x07, 0x56, 0x04, 0x00, 0x00,
- 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF9, 0x01,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08,
- 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E,
- 0x96, 0x14, 0x00, 0x09, 0xFB, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x55, 0x04, 0x00, 0x00,
- 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xFB, 0x01, 0x4E, 0x96, 0x09, 0x00,
- 0x08, 0x0D, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01,
- 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF3, 0x01, 0x53, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96,
- 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xFB, 0x01, 0x4E, 0x96, 0x02, 0x00,
- 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x6A, 0x3A, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00,
- 0x00, 0x00, 0x09, 0xFC, 0x01, 0x07, 0x55, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xFB, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D,
- 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00,
- 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09, 0xFD, 0x01,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x57, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08,
- 0x3A, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E,
- 0x96, 0x03, 0x00, 0x09, 0xFD, 0x01, 0x4E, 0x96, 0x09, 0x00, 0x08, 0x0D, 0x07, 0x00, 0x00, 0x00,
- 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF3,
- 0x01, 0x53, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E,
- 0x96, 0x03, 0x00, 0x09, 0xFD, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00,
- 0x08, 0x6A, 0x3A, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0xFE, 0x01, 0x07,
- 0x57, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0xFD, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04,
- 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09, 0xFF, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07,
- 0x4D, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96, 0x02, 0x00,
- 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xFF, 0x01,
- 0x4E, 0x96, 0x09, 0x00, 0x08, 0x0D, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
- 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF3, 0x01, 0x53, 0x4F, 0x96, 0x02, 0x00,
- 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xFF, 0x01,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x6A, 0x3A, 0x17, 0x96, 0x0F,
- 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x02, 0x07, 0x4D, 0x04, 0x00, 0x00, 0x08, 0x04,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xFF, 0x01, 0x4E, 0x96,
- 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D,
- 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x14,
- 0x00, 0x09, 0x01, 0x02, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x4F, 0x04, 0x00, 0x00, 0x07, 0x02,
- 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x01, 0x02, 0x4E, 0x96, 0x09, 0x00, 0x08, 0x0D,
- 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96,
- 0x03, 0x00, 0x09, 0xF3, 0x01, 0x53, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
- 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x01, 0x02, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D,
- 0x4E, 0x96, 0x02, 0x00, 0x08, 0x6A, 0x3A, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00,
- 0x09, 0x02, 0x02, 0x07, 0x4F, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2,
- 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x01, 0x02, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96,
- 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09, 0x03, 0x02, 0x07, 0xE8,
- 0x03, 0x00, 0x00, 0x07, 0x54, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D,
- 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0x03, 0x02, 0x4E, 0x96, 0x09, 0x00, 0x08, 0x0D, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08,
- 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF3, 0x01, 0x53,
- 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0x03, 0x02, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x6A,
- 0x3A, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0x04, 0x02, 0x07, 0x54, 0x04,
- 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
- 0x03, 0x02, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00,
- 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2,
- 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09, 0x05, 0x02, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x54, 0x04,
- 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04,
- 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x05, 0x02, 0x4E, 0x96,
- 0x09, 0x00, 0x08, 0x0D, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09,
- 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF3, 0x01, 0x53, 0x4C, 0x96, 0x02, 0x00, 0x08, 0x1C,
- 0x4D, 0x1D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E,
- 0x96, 0x03, 0x00, 0x09, 0x05, 0x02, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00,
- 0x08, 0x6A, 0x3A, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0x04, 0x02, 0x07,
- 0x54, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03,
- 0x00, 0x09, 0x05, 0x02, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04,
- 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x14, 0x00, 0x09, 0x06, 0x02, 0x07, 0x00, 0x00,
- 0x00, 0x00, 0x07, 0xFA, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D,
- 0x96, 0x14, 0x00, 0x09, 0x07, 0x02, 0x07, 0x01, 0x00, 0x00, 0x00, 0x07, 0xFA, 0x00, 0x00, 0x00,
- 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x14, 0x00, 0x09, 0x08, 0x02, 0x07,
- 0x02, 0x00, 0x00, 0x00, 0x07, 0xFA, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01,
- 0x3D, 0x1D, 0x96, 0x06, 0x00, 0x09, 0x09, 0x02, 0x09, 0x07, 0x02, 0x1C, 0x1D, 0x96, 0x14, 0x00,
- 0x09, 0x0A, 0x02, 0x07, 0x01, 0x00, 0x00, 0x00, 0x07, 0xFD, 0x03, 0x00, 0x00, 0x07, 0x02, 0x00,
- 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x14, 0x00, 0x09, 0x0B, 0x02, 0x07, 0x04, 0x00, 0x00,
- 0x00, 0x07, 0x64, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96,
- 0x14, 0x00, 0x09, 0x0C, 0x02, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x09, 0x00, 0x00, 0x00, 0x07,
- 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x03, 0x00, 0x08, 0x1C, 0x02, 0x1D, 0x96,
- 0x09, 0x00, 0x07, 0x00, 0x10, 0x00, 0x00, 0x08, 0x04, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x07,
- 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x09, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00,
- 0x08, 0x07, 0x08, 0x05, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D,
- 0x17, 0x96, 0x08, 0x00, 0x07, 0x83, 0x00, 0x00, 0x00, 0x02, 0x08, 0x10, 0x1C, 0x96, 0x07, 0x00,
- 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x0D, 0x00, 0x07, 0x06, 0x00, 0x00,
- 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x02, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00,
- 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x00
-};
-
diff --git a/libswfdec/swfdec_internal.h b/libswfdec/swfdec_internal.h
deleted file mode 100644
index 79d49c1..0000000
--- a/libswfdec/swfdec_internal.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_INTERNAL_H_
-#define _SWFDEC_INTERNAL_H_
-
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_codec_audio.h>
-#include <libswfdec/swfdec_codec_video.h>
-
-G_BEGIN_DECLS
-
-
-/* audio codecs */
-
-SwfdecAudioDecoder * swfdec_audio_decoder_adpcm_new (guint type,
- SwfdecAudioFormat format);
-#ifdef HAVE_MAD
-SwfdecAudioDecoder * swfdec_audio_decoder_mad_new (guint type,
- SwfdecAudioFormat format);
-#endif
-#ifdef HAVE_FFMPEG
-SwfdecAudioDecoder * swfdec_audio_decoder_ffmpeg_new (guint type,
- SwfdecAudioFormat format);
-#endif
-#ifdef HAVE_GST
-SwfdecAudioDecoder * swfdec_audio_decoder_gst_new (guint type,
- SwfdecAudioFormat format);
-#endif
-
-/* video codecs */
-
-SwfdecVideoDecoder * swfdec_video_decoder_screen_new (guint format);
-SwfdecVideoDecoder * swfdec_video_decoder_vp6_alpha_new (guint format);
-#ifdef HAVE_FFMPEG
-SwfdecVideoDecoder * swfdec_video_decoder_ffmpeg_new (guint format);
-#endif
-#ifdef HAVE_GST
-SwfdecVideoDecoder * swfdec_video_decoder_gst_new (guint format);
-#endif
-
-/* AS engine setup code */
-
-void swfdec_player_preinit_global (SwfdecAsContext * context);
-void swfdec_net_stream_init_context (SwfdecPlayer * player);
-void swfdec_sprite_movie_init_context (SwfdecPlayer * player);
-void swfdec_video_movie_init_context (SwfdecPlayer * player);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_interval.c b/libswfdec/swfdec_interval.c
deleted file mode 100644
index 88a2ca4..0000000
--- a/libswfdec/swfdec_interval.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "swfdec_interval.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_frame_internal.h"
-#include "swfdec_as_function.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_resource.h"
-
-G_DEFINE_TYPE (SwfdecInterval, swfdec_interval, SWFDEC_TYPE_AS_OBJECT)
-
-static void
-swfdec_interval_mark (SwfdecAsObject *object)
-{
- guint i;
- SwfdecInterval *interval = SWFDEC_INTERVAL (object);
-
- swfdec_as_object_mark (interval->object);
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (interval->sandbox));
- if (interval->fun_name)
- swfdec_as_string_mark (interval->fun_name);
- for (i = 0; i < interval->n_args; i++) {
- swfdec_as_value_mark (&interval->args[i]);
- }
-
- SWFDEC_AS_OBJECT_CLASS (swfdec_interval_parent_class)->mark (object);
-}
-
-static void
-swfdec_interval_dispose (GObject *object)
-{
- SwfdecInterval *interval = SWFDEC_INTERVAL (object);
-
- g_free (interval->args);
- interval->args = NULL;
- /* needed here when GC'ed by closing the player */
- if (interval->timeout.callback != NULL) {
- swfdec_player_remove_timeout (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (object)->context), &interval->timeout);
- interval->timeout.callback = NULL;
- }
-
- G_OBJECT_CLASS (swfdec_interval_parent_class)->dispose (object);
-}
-
-static void
-swfdec_interval_class_init (SwfdecIntervalClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
-
- object_class->dispose = swfdec_interval_dispose;
-
- asobject_class->mark = swfdec_interval_mark;
-}
-
-static void
-swfdec_interval_init (SwfdecInterval *array)
-{
-}
-
-static void
-swfdec_interval_trigger (SwfdecTimeout *timeout)
-{
- SwfdecAsValue ret;
- SwfdecInterval *interval = SWFDEC_INTERVAL ((void *) (((guchar *) timeout)
- - G_STRUCT_OFFSET (SwfdecInterval, timeout)));
- SwfdecAsContext *context = SWFDEC_AS_OBJECT (interval)->context;
- SwfdecPlayer *player = SWFDEC_PLAYER (context);
-
- if (interval->repeat) {
- timeout->timestamp += SWFDEC_MSECS_TO_TICKS (interval->msecs);
- swfdec_player_add_timeout (SWFDEC_PLAYER (context), timeout);
- } else {
- player->priv->intervals = g_list_remove (player->priv->intervals, interval);
- interval->timeout.callback = NULL;
- }
- swfdec_sandbox_use (interval->sandbox);
- if (interval->fun_name) {
- swfdec_as_object_call (interval->object,
- interval->fun_name, interval->n_args, interval->args, &ret);
- } else {
- swfdec_as_function_call (SWFDEC_AS_FUNCTION (interval->object), NULL,
- interval->n_args, interval->args, &ret);
- swfdec_as_context_run (context);
- }
- swfdec_sandbox_unuse (interval->sandbox);
-}
-
-static guint
-swfdec_interval_new (SwfdecPlayer *player, guint msecs, gboolean repeat,
- SwfdecAsObject *object, const char *fun_name,
- guint n_args, const SwfdecAsValue *args)
-{
- SwfdecAsContext *context;
- SwfdecInterval *interval;
- guint size;
-
- context = SWFDEC_AS_CONTEXT (player);
- size = sizeof (SwfdecInterval) + n_args * sizeof (SwfdecAsValue);
- if (!swfdec_as_context_use_mem (context, size))
- return 0;
- interval = g_object_new (SWFDEC_TYPE_INTERVAL, NULL);
- swfdec_as_object_add (SWFDEC_AS_OBJECT (interval), context, size);
-
- interval->id = ++player->priv->interval_id;
- interval->sandbox = SWFDEC_SANDBOX (context->global);
- interval->msecs = msecs;
- interval->repeat = repeat;
- interval->object = object;
- interval->fun_name = fun_name;
- interval->n_args = n_args;
- interval->args = g_memdup (args, n_args * sizeof (SwfdecAsValue));
- interval->timeout.timestamp = player->priv->time + SWFDEC_MSECS_TO_TICKS (interval->msecs);
- interval->timeout.callback = swfdec_interval_trigger;
- swfdec_player_add_timeout (player, &interval->timeout);
-
- player->priv->intervals =
- g_list_prepend (player->priv->intervals, interval);
-
- return interval->id;
-}
-
-guint
-swfdec_interval_new_function (SwfdecPlayer *player, guint msecs, gboolean repeat,
- SwfdecAsFunction *fun, guint n_args, const SwfdecAsValue *args)
-{
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), 0);
- g_return_val_if_fail (msecs > 0, 0);
- g_return_val_if_fail (SWFDEC_IS_AS_FUNCTION (fun), 0);
- g_return_val_if_fail (n_args == 0 || args != NULL, 0);
-
- return swfdec_interval_new (player, msecs, repeat, SWFDEC_AS_OBJECT (fun), NULL, n_args, args);
-}
-
-guint
-swfdec_interval_new_object (SwfdecPlayer *player, guint msecs, gboolean repeat,
- SwfdecAsObject *thisp, const char *fun_name,
- guint n_args, const SwfdecAsValue *args)
-{
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), 0);
- g_return_val_if_fail (msecs > 0, 0);
- g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (thisp), 0);
- g_return_val_if_fail (fun_name != NULL, 0);
- g_return_val_if_fail (n_args == 0 || args != NULL, 0);
-
- return swfdec_interval_new (player, msecs, repeat, thisp, fun_name, n_args, args);
-}
-
-void
-swfdec_interval_remove (SwfdecPlayer *player, guint id)
-{
- GList *walk;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
-
- for (walk = player->priv->intervals; walk; walk = walk->next) {
- SwfdecInterval *interval = walk->data;
- if (interval->id != id)
- continue;
-
- player->priv->intervals = g_list_delete_link (player->priv->intervals, walk);
- swfdec_player_remove_timeout (player, &interval->timeout);
- interval->timeout.callback = NULL;
- return;
- }
-}
-
diff --git a/libswfdec/swfdec_interval.h b/libswfdec/swfdec_interval.h
deleted file mode 100644
index 48941bf..0000000
--- a/libswfdec/swfdec_interval.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_INTERVAL_H_
-#define _SWFDEC_INTERVAL_H_
-
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_player_internal.h>
-#include <libswfdec/swfdec_sandbox.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecInterval SwfdecInterval;
-typedef struct _SwfdecIntervalClass SwfdecIntervalClass;
-
-#define SWFDEC_TYPE_INTERVAL (swfdec_interval_get_type())
-#define SWFDEC_IS_INTERVAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_INTERVAL))
-#define SWFDEC_IS_INTERVAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_INTERVAL))
-#define SWFDEC_INTERVAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_INTERVAL, SwfdecInterval))
-#define SWFDEC_INTERVAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_INTERVAL, SwfdecIntervalClass))
-#define SWFDEC_INTERVAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_INTERVAL, SwfdecIntervalClass))
-
-struct _SwfdecInterval {
- SwfdecAsObject asobject;
-
- SwfdecTimeout timeout;
- SwfdecSandbox * sandbox; /* sandbox we run the script in */
- guint id; /* id this interval is identified with */
- guint msecs; /* interval in milliseconds */
- gboolean repeat; /* TRUE for calling in intervals, FALSE for single-shot */
- /* if calling named function */
- SwfdecAsObject * object; /* this object or function to call (depending on fun_name) */
- const char * fun_name; /* name of function or NULL if object is function */
-
- guint n_args; /* number of arguments to call function with */
- SwfdecAsValue * args; /* arguments for function */
-};
-
-struct _SwfdecIntervalClass {
- SwfdecAsObjectClass asobject_class;
-};
-
-GType swfdec_interval_get_type (void);
-
-guint swfdec_interval_new_function (SwfdecPlayer * player,
- guint msecs,
- gboolean repeat,
- SwfdecAsFunction * fun,
- guint n_args,
- const SwfdecAsValue * args);
-guint swfdec_interval_new_object (SwfdecPlayer * player,
- guint msecs,
- gboolean repeat,
- SwfdecAsObject * thisp,
- const char * fun_name,
- guint n_args,
- const SwfdecAsValue * args);
-void swfdec_interval_remove (SwfdecPlayer * player,
- guint id);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_key_as.c b/libswfdec/swfdec_key_as.c
deleted file mode 100644
index ca7a949..0000000
--- a/libswfdec/swfdec_key_as.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_as_object.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-#include "swfdec_player_internal.h"
-
-SWFDEC_AS_NATIVE (800, 0, swfdec_key_getAscii)
-void
-swfdec_key_getAscii (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
-
- SWFDEC_AS_VALUE_SET_INT (retval, player->priv->last_character);
-}
-
-SWFDEC_AS_NATIVE (800, 1, swfdec_key_getCode)
-void
-swfdec_key_getCode (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
-
- SWFDEC_AS_VALUE_SET_INT (retval, player->priv->last_keycode);
-}
-
-SWFDEC_AS_NATIVE (800, 2, swfdec_key_isDown)
-void
-swfdec_key_isDown (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- guint id;
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
-
- if (argc < 1)
- return;
-
- id = swfdec_as_value_to_integer (cx, &argv[0]);
- if (id >= 256) {
- SWFDEC_FIXME ("id %u too big for a keycode", id);
- id %= 256;
- }
- SWFDEC_AS_VALUE_SET_BOOLEAN (retval, (player->priv->key_pressed[id / 8] & (1 << (id % 8))) ? TRUE : FALSE);
-}
-
-SWFDEC_AS_NATIVE (800, 3, swfdec_key_isToggled)
-void
-swfdec_key_isToggled (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- SWFDEC_STUB ("Key.isToggled (static)");
-}
-
-SWFDEC_AS_NATIVE (800, 4, swfdec_key_isAccessible)
-void
-swfdec_key_isAccessible (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- SWFDEC_STUB ("Key.isAccessible (static)");
-}
diff --git a/libswfdec/swfdec_keys.h b/libswfdec/swfdec_keys.h
deleted file mode 100644
index a32e546..0000000
--- a/libswfdec/swfdec_keys.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_KEYS_H_
-#define _SWFDEC_KEYS_H_
-
-G_BEGIN_DECLS
-
-typedef enum {
- SWFDEC_KEY_BACKSPACE = 8,
- SWFDEC_KEY_TAB = 9,
- SWFDEC_KEY_CLEAR = 12,
- SWFDEC_KEY_ENTER = 13,
- SWFDEC_KEY_SHIFT = 16,
- SWFDEC_KEY_CONTROL = 17,
- SWFDEC_KEY_ALT = 18,
- SWFDEC_KEY_CAPS_LOCK = 20,
- SWFDEC_KEY_ESCAPE = 27,
- SWFDEC_KEY_SPACE = 32,
- SWFDEC_KEY_PAGE_UP = 33,
- SWFDEC_KEY_PAGE_DOWN = 34,
- SWFDEC_KEY_END = 35,
- SWFDEC_KEY_HOME = 36,
- SWFDEC_KEY_LEFT = 37,
- SWFDEC_KEY_UP = 38,
- SWFDEC_KEY_RIGHT = 39,
- SWFDEC_KEY_DOWN = 40,
- SWFDEC_KEY_INSERT = 45,
- SWFDEC_KEY_DELETE = 46,
- SWFDEC_KEY_HELP = 47,
- SWFDEC_KEY_0 = 48,
- SWFDEC_KEY_1 = 49,
- SWFDEC_KEY_2 = 50,
- SWFDEC_KEY_3 = 51,
- SWFDEC_KEY_4 = 52,
- SWFDEC_KEY_5 = 53,
- SWFDEC_KEY_6 = 54,
- SWFDEC_KEY_7 = 55,
- SWFDEC_KEY_8 = 56,
- SWFDEC_KEY_9 = 57,
- SWFDEC_KEY_A = 65,
- SWFDEC_KEY_B = 66,
- SWFDEC_KEY_C = 67,
- SWFDEC_KEY_D = 68,
- SWFDEC_KEY_E = 69,
- SWFDEC_KEY_F = 70,
- SWFDEC_KEY_G = 71,
- SWFDEC_KEY_H = 72,
- SWFDEC_KEY_I = 73,
- SWFDEC_KEY_J = 74,
- SWFDEC_KEY_K = 75,
- SWFDEC_KEY_L = 76,
- SWFDEC_KEY_M = 77,
- SWFDEC_KEY_N = 78,
- SWFDEC_KEY_O = 79,
- SWFDEC_KEY_P = 80,
- SWFDEC_KEY_Q = 81,
- SWFDEC_KEY_R = 82,
- SWFDEC_KEY_S = 83,
- SWFDEC_KEY_T = 84,
- SWFDEC_KEY_U = 85,
- SWFDEC_KEY_V = 86,
- SWFDEC_KEY_W = 87,
- SWFDEC_KEY_X = 88,
- SWFDEC_KEY_Y = 89,
- SWFDEC_KEY_Z = 90,
- SWFDEC_KEY_NUMPAD_0 = 96,
- SWFDEC_KEY_NUMPAD_1 = 97,
- SWFDEC_KEY_NUMPAD_2 = 98,
- SWFDEC_KEY_NUMPAD_3 = 99,
- SWFDEC_KEY_NUMPAD_4 = 100,
- SWFDEC_KEY_NUMPAD_5 = 101,
- SWFDEC_KEY_NUMPAD_6 = 102,
- SWFDEC_KEY_NUMPAD_7 = 103,
- SWFDEC_KEY_NUMPAD_8 = 104,
- SWFDEC_KEY_NUMPAD_9 = 105,
- SWFDEC_KEY_NUMPAD_MULTIPLY = 106,
- SWFDEC_KEY_NUMPAD_ADD = 107,
- SWFDEC_KEY_NUMPAD_SUBTRACT = 109,
- SWFDEC_KEY_NUMPAD_DECIMAL = 110,
- SWFDEC_KEY_NUMPAD_DIVIDE = 111,
- SWFDEC_KEY_F1 = 112,
- SWFDEC_KEY_F2 = 113,
- SWFDEC_KEY_F3 = 114,
- SWFDEC_KEY_F4 = 115,
- SWFDEC_KEY_F5 = 116,
- SWFDEC_KEY_F6 = 117,
- SWFDEC_KEY_F7 = 118,
- SWFDEC_KEY_F8 = 119,
- SWFDEC_KEY_F9 = 120,
- SWFDEC_KEY_F10 = 121,
- SWFDEC_KEY_F11 = 122,
- SWFDEC_KEY_F12 = 123,
- SWFDEC_KEY_F13 = 124,
- SWFDEC_KEY_F14 = 125,
- SWFDEC_KEY_F15 = 126,
- SWFDEC_KEY_NUM_LOCK = 144,
- SWFDEC_KEY_SEMICOLON = 186,
- SWFDEC_KEY_EQUAL = 187,
- SWFDEC_KEY_MINUS = 189,
- SWFDEC_KEY_SLASH = 191,
- SWFDEC_KEY_GRAVE = 192,
- SWFDEC_KEY_LEFT_BRACKET = 219,
- SWFDEC_KEY_BACKSLASH = 220,
- SWFDEC_KEY_RIGHT_BRACKET = 221,
- SWFDEC_KEY_APOSTROPHE = 222,
-} SwfdecKey;
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_load_object.c b/libswfdec/swfdec_load_object.c
deleted file mode 100644
index 0e6e58d..0000000
--- a/libswfdec/swfdec_load_object.c
+++ /dev/null
@@ -1,259 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007-2008 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include "swfdec_load_object.h"
-#include "swfdec_as_frame_internal.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-#include "swfdec_loader_internal.h"
-#include "swfdec_stream_target.h"
-#include "swfdec_player_internal.h"
-
-/*** SWFDEC_STREAM_TARGET ***/
-
-static SwfdecPlayer *
-swfdec_load_object_stream_target_get_player (SwfdecStreamTarget *target)
-{
- return SWFDEC_PLAYER (SWFDEC_LOAD_OBJECT (target)->target->context);
-}
-
-static void
-swfdec_load_object_stream_target_parse (SwfdecStreamTarget *target,
- SwfdecStream *stream)
-{
- SwfdecLoader *loader = SWFDEC_LOADER (stream);
- SwfdecLoadObject *load_object = SWFDEC_LOAD_OBJECT (target);
-
- if (load_object->progress != NULL) {
- swfdec_sandbox_use (load_object->sandbox);
- load_object->progress (load_object->target,
- swfdec_loader_get_loaded (loader), swfdec_loader_get_size (loader));
- swfdec_sandbox_unuse (load_object->sandbox);
- }
-}
-
-static void
-swfdec_load_object_stream_target_error (SwfdecStreamTarget *target,
- SwfdecStream *stream)
-{
- SwfdecLoader *loader = SWFDEC_LOADER (stream);
- SwfdecLoadObject *load_object = SWFDEC_LOAD_OBJECT (target);
-
- /* break reference to the loader */
- swfdec_stream_set_target (SWFDEC_STREAM (loader), NULL);
- load_object->loader = NULL;
- g_object_unref (loader);
-
- /* call finish */
- swfdec_sandbox_use (load_object->sandbox);
- load_object->finish (load_object->target, NULL);
- swfdec_sandbox_unuse (load_object->sandbox);
-
- /* unroot */
- swfdec_player_unroot (SWFDEC_PLAYER (
- SWFDEC_AS_OBJECT (load_object->sandbox)->context), load_object);
-}
-
-static void
-swfdec_load_object_stream_target_close (SwfdecStreamTarget *target,
- SwfdecStream *stream)
-{
- SwfdecLoader *loader = SWFDEC_LOADER (stream);
- SwfdecLoadObject *load_object = SWFDEC_LOAD_OBJECT (target);
- char *text;
-
- // get text
- text =
- swfdec_loader_get_text (loader, load_object->version);
-
- /* break reference to the loader */
- swfdec_stream_set_target (stream, NULL);
- load_object->loader = NULL;
- g_object_unref (loader);
-
- /* call finish */
- swfdec_sandbox_use (load_object->sandbox);
- if (text != NULL) {
- load_object->finish (load_object->target,
- swfdec_as_context_give_string (load_object->target->context, text));
- } else {
- load_object->finish (load_object->target, SWFDEC_AS_STR_EMPTY);
- }
- swfdec_sandbox_unuse (load_object->sandbox);
-
- /* unroot */
- swfdec_player_unroot (SWFDEC_PLAYER (
- SWFDEC_AS_OBJECT (load_object->sandbox)->context), load_object);
-}
-
-static void
-swfdec_load_object_stream_target_init (SwfdecStreamTargetInterface *iface)
-{
- iface->get_player = swfdec_load_object_stream_target_get_player;
- iface->parse = swfdec_load_object_stream_target_parse;
- iface->close = swfdec_load_object_stream_target_close;
- iface->error = swfdec_load_object_stream_target_error;
-}
-
-/*** SWFDEC_LOAD_OBJECT ***/
-
-G_DEFINE_TYPE_WITH_CODE (SwfdecLoadObject, swfdec_load_object, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (SWFDEC_TYPE_STREAM_TARGET, swfdec_load_object_stream_target_init))
-
-static void
-swfdec_load_object_dispose (GObject *object)
-{
- SwfdecLoadObject *load = SWFDEC_LOAD_OBJECT (object);
-
- if (load->loader) {
- swfdec_stream_set_target (SWFDEC_STREAM (load->loader), NULL);
- g_object_unref (load->loader);
- load->loader = NULL;
- }
- if (load->buffer) {
- swfdec_buffer_unref (load->buffer);
- load->buffer = NULL;
- }
-
- G_OBJECT_CLASS (swfdec_load_object_parent_class)->dispose (object);
-}
-
-static void
-swfdec_load_object_class_init (SwfdecLoadObjectClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->dispose = swfdec_load_object_dispose;
-}
-
-static void
-swfdec_load_object_init (SwfdecLoadObject *load_object)
-{
-}
-
-static void
-swfdec_load_object_load (SwfdecPlayer *player, gboolean allow, gpointer obj)
-{
- SwfdecLoadObject *load = SWFDEC_LOAD_OBJECT (obj);
-
- if (!allow) {
- SWFDEC_WARNING ("SECURITY: no access to %s from %s",
- load->url, swfdec_url_get_url (load->sandbox->url));
-
- /* unroot */
- swfdec_player_unroot (player, load);
- return;
- }
-
- load->loader = swfdec_player_load (player, load->url, load->request, load->buffer);
-
- swfdec_stream_set_target (SWFDEC_STREAM (load->loader), SWFDEC_STREAM_TARGET (load));
- swfdec_loader_set_data_type (load->loader, SWFDEC_LOADER_DATA_TEXT);
-}
-
-/* perform security checks */
-static void
-swfdec_load_object_request (gpointer objectp, gpointer playerp)
-{
- SwfdecLoadObject *load = SWFDEC_LOAD_OBJECT (objectp);
- SwfdecPlayer *player = SWFDEC_PLAYER (playerp);
- SwfdecURL *url;
-
- if (swfdec_url_path_is_relative (load->url)) {
- swfdec_load_object_load (player, TRUE, load);
- return;
- }
- /* FIXME: or is this relative to the player? */
- url = swfdec_player_create_url (player, load->url);
- if (url == NULL) {
- swfdec_load_object_load (player, FALSE, load);
- return;
- }
- switch (load->sandbox->type) {
- case SWFDEC_SANDBOX_REMOTE:
- case SWFDEC_SANDBOX_LOCAL_NETWORK:
- case SWFDEC_SANDBOX_LOCAL_TRUSTED:
- if (swfdec_url_is_local (url)) {
- swfdec_load_object_load (player, swfdec_url_is_local (url), load);
- } else {
- SwfdecURL *load_url = swfdec_url_new_components (
- swfdec_url_get_protocol (url), swfdec_url_get_host (url),
- swfdec_url_get_port (url), "crossdomain.xml", NULL);
- swfdec_player_allow_or_load (player, url, load_url,
- swfdec_load_object_load, load);
- swfdec_url_free (load_url);
- }
- break;
- case SWFDEC_SANDBOX_LOCAL_FILE:
- swfdec_load_object_load (player, swfdec_url_is_local (url), load);
- break;
- case SWFDEC_SANDBOX_NONE:
- default:
- g_assert_not_reached ();
- break;
- }
-
- swfdec_url_free (url);
-}
-
-static void
-swfdec_load_object_mark (gpointer object, gpointer player)
-{
- SwfdecLoadObject *load = object;
-
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (load->sandbox));
- if (load->url)
- swfdec_as_string_mark (load->url);
- swfdec_as_object_mark (load->target);
-}
-
-void
-swfdec_load_object_create (SwfdecAsObject *target, const char *url,
- SwfdecLoaderRequest request, SwfdecBuffer *data,
- SwfdecLoadObjectProgress progress, SwfdecLoadObjectFinish finish)
-{
- SwfdecPlayer *player;
- SwfdecLoadObject *load;
-
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (target));
- g_return_if_fail (url != NULL);
- g_return_if_fail (finish != NULL);
-
- player = SWFDEC_PLAYER (target->context);
- load = g_object_new (SWFDEC_TYPE_LOAD_OBJECT, NULL);
- swfdec_player_root_full (player, load, swfdec_load_object_mark, g_object_unref);
-
- load->target = target;
- load->url = url;
- load->request = request;
- load->buffer = data;
- load->progress = progress;
- load->finish = finish;
- /* get the current security */
- g_assert (SWFDEC_AS_CONTEXT (player)->frame);
- load->sandbox = SWFDEC_SANDBOX (SWFDEC_AS_CONTEXT (player)->global);
- load->version = SWFDEC_AS_CONTEXT (player)->version;
- swfdec_player_request_resource (player, swfdec_load_object_request, load, NULL);
-}
diff --git a/libswfdec/swfdec_load_object.h b/libswfdec/swfdec_load_object.h
deleted file mode 100644
index 51b3baa..0000000
--- a/libswfdec/swfdec_load_object.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007-2008 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_LOAD_OBJECT_H_
-#define _SWFDEC_LOAD_OBJECT_H_
-
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_resource.h>
-
-G_BEGIN_DECLS
-
-
-typedef struct _SwfdecLoadObject SwfdecLoadObject;
-typedef struct _SwfdecLoadObjectClass SwfdecLoadObjectClass;
-
-typedef void (* SwfdecLoadObjectProgress) (SwfdecAsObject *target,
- glong loaded, glong size);
-typedef void (* SwfdecLoadObjectFinish) (SwfdecAsObject *target,
- const char *text);
-
-#define SWFDEC_TYPE_LOAD_OBJECT (swfdec_load_object_get_type())
-#define SWFDEC_IS_LOAD_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_LOAD_OBJECT))
-#define SWFDEC_IS_LOAD_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_LOAD_OBJECT))
-#define SWFDEC_LOAD_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_LOAD_OBJECT, SwfdecLoadObject))
-#define SWFDEC_LOAD_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_LOAD_OBJECT, SwfdecLoadObjectClass))
-#define SWFDEC_LOAD_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_LOAD_OBJECT, SwfdecLoadObjectClass))
-
-struct _SwfdecLoadObject {
- GObject object;
-
- const char * url; /* GC'ed url to request */
- SwfdecLoaderRequest request; /* type of request */
- SwfdecBuffer * buffer; /* data to send */
- SwfdecLoader * loader; /* loader when loading or NULL */
-
- SwfdecSandbox * sandbox; /* sandbox that inited the loading */
- guint version; /* version used when initiating the load - for parsing the data */
- SwfdecAsObject * target; /* target object */
- SwfdecLoadObjectProgress progress; /* progress callback */
- SwfdecLoadObjectFinish finish; /* finish callback */
-};
-
-struct _SwfdecLoadObjectClass {
- GObjectClass object_class;
-};
-
-GType swfdec_load_object_get_type (void);
-
-void swfdec_load_object_create (SwfdecAsObject * target,
- const char * url,
- SwfdecLoaderRequest request,
- SwfdecBuffer * data,
- SwfdecLoadObjectProgress progress,
- SwfdecLoadObjectFinish finish);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_load_object_as.c b/libswfdec/swfdec_load_object_as.c
deleted file mode 100644
index 012249e..0000000
--- a/libswfdec/swfdec_load_object_as.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include "swfdec_load_object.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-#include "swfdec_loader_internal.h"
-#include "swfdec_player_internal.h"
-
-static void
-swfdec_load_object_on_finish (SwfdecAsObject *target, const char *text)
-{
- SwfdecAsValue val;
-
- if (text != NULL) {
- SWFDEC_AS_VALUE_SET_STRING (&val, text);
- } else {
- SWFDEC_AS_VALUE_SET_UNDEFINED (&val);
- }
-
- swfdec_as_object_call (target, SWFDEC_AS_STR_onData, 1, &val, NULL);
-}
-
-static void
-swfdec_load_object_on_progress (SwfdecAsObject *target, glong size,
- glong loaded)
-{
- SwfdecAsValue val;
-
- SWFDEC_AS_VALUE_SET_NUMBER (&val, loaded);
- swfdec_as_object_set_variable_and_flags (target, SWFDEC_AS_STR__bytesLoaded,
- &val, SWFDEC_AS_VARIABLE_HIDDEN);
-
- if (size >= 0) {
- SWFDEC_AS_VALUE_SET_NUMBER (&val, size);
- } else {
- SWFDEC_AS_VALUE_SET_NUMBER (&val, loaded);
- }
- swfdec_as_object_set_variable_and_flags (target, SWFDEC_AS_STR__bytesTotal,
- &val, SWFDEC_AS_VARIABLE_HIDDEN);
-}
-
-SWFDEC_AS_NATIVE (301, 0, swfdec_load_object_as_load)
-void
-swfdec_load_object_as_load (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecAsValue val;
- const char *url;
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (rval, FALSE);
- SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_OBJECT, &object, "s", &url);
-
- swfdec_load_object_create (object, url, SWFDEC_LOADER_REQUEST_DEFAULT, NULL,
- swfdec_load_object_on_progress, swfdec_load_object_on_finish);
-
- SWFDEC_AS_VALUE_SET_INT (&val, 0);
- swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR__bytesLoaded,
- &val, SWFDEC_AS_VARIABLE_HIDDEN);
- SWFDEC_AS_VALUE_SET_UNDEFINED (&val);
- swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR__bytesTotal,
- &val, SWFDEC_AS_VARIABLE_HIDDEN);
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (&val, FALSE);
- swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR_loaded, &val,
- SWFDEC_AS_VARIABLE_HIDDEN);
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (rval, TRUE);
-}
-
-SWFDEC_AS_NATIVE (301, 1, swfdec_load_object_as_send)
-void
-swfdec_load_object_as_send (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("LoadVars/XML.send");
-}
-
-SWFDEC_AS_NATIVE (301, 2, swfdec_load_object_as_sendAndLoad)
-void
-swfdec_load_object_as_sendAndLoad (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- const char *url, *data, *method_string;
- SwfdecAsObject *target;
- SwfdecAsValue val;
- SwfdecBuffer *buffer;
- SwfdecLoaderRequest method;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_OBJECT, &object, "sO|s", &url, &target, &method_string);
-
- SWFDEC_FIXME ("support for contentType is missing");
-
- if (method_string == NULL || g_ascii_strcasecmp (method_string, "get") == 0) {
- method = SWFDEC_LOADER_REQUEST_GET;
- } else {
- method = SWFDEC_LOADER_REQUEST_POST;
- }
- SWFDEC_AS_VALUE_SET_OBJECT (&val, object);
- data = swfdec_as_value_to_string (cx, &val);
- buffer = swfdec_buffer_new_for_data (g_memdup (data, strlen (data) + 1),
- strlen (data) + 1);
- swfdec_load_object_create (target, url, method, buffer,
- swfdec_load_object_on_progress, swfdec_load_object_on_finish);
-
- SWFDEC_AS_VALUE_SET_INT (&val, 0);
- swfdec_as_object_set_variable_and_flags (target, SWFDEC_AS_STR__bytesLoaded,
- &val, SWFDEC_AS_VARIABLE_HIDDEN);
- SWFDEC_AS_VALUE_SET_UNDEFINED (&val);
- swfdec_as_object_set_variable_and_flags (target, SWFDEC_AS_STR__bytesTotal,
- &val, SWFDEC_AS_VARIABLE_HIDDEN);
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (&val, FALSE);
- swfdec_as_object_set_variable_and_flags (target, SWFDEC_AS_STR_loaded, &val,
- SWFDEC_AS_VARIABLE_HIDDEN);
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (rval, TRUE);
-}
diff --git a/libswfdec/swfdec_loader.c b/libswfdec/swfdec_loader.c
deleted file mode 100644
index 9868eac..0000000
--- a/libswfdec/swfdec_loader.c
+++ /dev/null
@@ -1,443 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include "swfdec_loader_internal.h"
-#include "swfdec_buffer.h"
-#include "swfdec_debug.h"
-#include "swfdec_player_internal.h"
-
-/*** gtk-doc ***/
-
-/**
- * SECTION:SwfdecLoader
- * @title: SwfdecLoader
- * @short_description: object used for input
- *
- * SwfdecLoader is the base class used for reading input. Since developers
- * normally need to adapt input to the needs of their application, this class
- * is provided to be adapted to their needs. It is used both for HTTP and
- * RTMP access.
- *
- * Since Flash files can load new resources while operating, a #SwfdecLoader
- * can be instructed to load another resource.
- *
- * For convenience, a #SwfdecLoader for file access is provided by Swfdec.
- */
-
-/**
- * SwfdecLoader:
- *
- * This is the base object used for providing input. It is abstract, use a
- * subclass to provide your input.
- */
-
-/**
- * SwfdecLoaderClass:
- * @load: initialize a new loader based on a parent loader object. The new
- * loader will already have its URL set.
- *
- * This is the base class used for input. If you create a subclass, you are
- * supposed to set the function pointers listed above.
- */
-
-/**
- * SwfdecLoaderDataType:
- * @SWFDEC_LOADER_DATA_UNKNOWN: Unidentified data or data that cannot be
- * identified.
- * @SWFDEC_LOADER_DATA_SWF: Data describing a normal Flash file.
- * @SWFDEC_LOADER_DATA_FLV: Data describing a Flash video stream.
- * @SWFDEC_LOADER_DATA_XML: Data in XML format.
- * @SWFDEC_LOADER_DATA_TEXT: Textual data.
- * @SWFDEC_LOADER_DATA_JPEG: a JPEG image
- * @SWFDEC_LOADER_DATA_PNG: a PNG image
- *
- * This type describes the different types of data that can be loaded inside
- * Swfdec. Swfdec identifies its data streams and you can use the
- * swfdec_loader_get_data_type() to acquire more information about the data
- * inside a #SwfdecLoader.
- */
-
-/**
- * SwfdecLoaderRequest:
- * @SWFDEC_LOADER_REQUEST_DEFAULT: Use the default method (this most likely is
- * equal to HTTPget)
- * @SWFDEC_LOADER_REQUEST_GET: Use HTTP get
- * @SWFDEC_LOADER_REQUEST_POST: Use HTTP post
- *
- * Describes the moethod to use for requesting a given URL. These methods map
- * naturally to HTTP methods, since HTTP is the common method for requesting
- * Flash content.
- */
-
-/*** SwfdecLoader ***/
-
-enum {
- PROP_0,
- PROP_DATA_TYPE,
- PROP_SIZE,
- PROP_LOADED,
- PROP_URL
-};
-
-G_DEFINE_ABSTRACT_TYPE (SwfdecLoader, swfdec_loader, SWFDEC_TYPE_STREAM)
-
-static const char *
-swfdec_loader_describe (SwfdecStream *stream)
-{
- const SwfdecURL *url = SWFDEC_LOADER (stream)->url;
-
- if (url) {
- return swfdec_url_get_url (url);
- } else {
- return "unknown url";
- }
-}
-
-static void
-swfdec_loader_get_property (GObject *object, guint param_id, GValue *value,
- GParamSpec * pspec)
-{
- SwfdecLoader *loader = SWFDEC_LOADER (object);
-
- switch (param_id) {
- case PROP_DATA_TYPE:
- g_value_set_enum (value, loader->data_type);
- break;
- case PROP_SIZE:
- g_value_set_long (value, loader->size);
- break;
- case PROP_LOADED:
- g_value_set_ulong (value, swfdec_loader_get_loaded (loader));
- break;
- case PROP_URL:
- g_value_set_boxed (value, loader->url);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-swfdec_loader_set_property (GObject *object, guint param_id, const GValue *value,
- GParamSpec *pspec)
-{
- SwfdecLoader *loader = SWFDEC_LOADER (object);
-
- switch (param_id) {
- case PROP_SIZE:
- if (loader->size == -1 && g_value_get_long (value) >= 0)
- swfdec_loader_set_size (loader, g_value_get_long (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-swfdec_loader_dispose (GObject *object)
-{
- SwfdecLoader *loader = SWFDEC_LOADER (object);
-
- if (loader->url) {
- swfdec_url_free (loader->url);
- loader->url = NULL;
- }
-
- G_OBJECT_CLASS (swfdec_loader_parent_class)->dispose (object);
-}
-
-static void
-swfdec_loader_class_init (SwfdecLoaderClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- SwfdecStreamClass *stream_class = SWFDEC_STREAM_CLASS (klass);
-
- object_class->dispose = swfdec_loader_dispose;
- object_class->get_property = swfdec_loader_get_property;
- object_class->set_property = swfdec_loader_set_property;
-
- 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_long ("size", "size", "amount of bytes in loader",
- -1, G_MAXLONG, -1, G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_LOADED,
- g_param_spec_ulong ("loaded", "loaded", "bytes already loaded",
- 0, G_MAXULONG, 0, G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_URL,
- g_param_spec_boxed ("url", "url", "URL for this file",
- SWFDEC_TYPE_URL, G_PARAM_READABLE));
-
- stream_class->describe = swfdec_loader_describe;
-}
-
-static void
-swfdec_loader_init (SwfdecLoader *loader)
-{
- loader->data_type = SWFDEC_LOADER_DATA_UNKNOWN;
-
- loader->size = -1;
-}
-
-/** PUBLIC API ***/
-
-/**
- * swfdec_loader_set_url:
- * @loader: the loader to update
- * @url: string specifying the new URL. The url must be a valid absolute URL.
- *
- * Updates the url of the given @loader to point to the new @url. This is useful
- * whe encountering HTTP redirects, as the loader is supposed to reference the
- * final URL after all rdirections.
- * This function may only be called once and must have been called before
- * calling swfdec_stream_open() on @loader.
- **/
-void
-swfdec_loader_set_url (SwfdecLoader *loader, const char *url)
-{
- SwfdecURL *real;
-
- g_return_if_fail (SWFDEC_IS_LOADER (loader));
- g_return_if_fail (loader->url == NULL);
- g_return_if_fail (url != NULL);
-
- real = swfdec_url_new (url);
- g_return_if_fail (real != NULL);
- loader->url = real;
-}
-
-/**
- * swfdec_loader_get_url:
- * @loader: a #SwfdecLoader
- *
- * Gets the url this loader is handling. This is mostly useful for writing
- * subclasses of #SwfdecLoader.
- *
- * Returns: a #SwfdecURL describing @loader or %NULL if the @url is not known
- * yet.
- **/
-const SwfdecURL *
-swfdec_loader_get_url (SwfdecLoader *loader)
-{
- g_return_val_if_fail (SWFDEC_IS_LOADER (loader), NULL);
-
- return loader->url;
-}
-
-/**
- * swfdec_loader_get_data_type:
- * @loader: a #SwfdecLoader
- *
- * Queries the type of data this loader provides. The type is determined
- * automatically by Swfdec.
- *
- * Returns: the type this data was identified to be in or
- * #SWFDEC_LOADER_DATA_UNKNOWN if not identified
- **/
-SwfdecLoaderDataType
-swfdec_loader_get_data_type (SwfdecLoader *loader)
-{
- g_return_val_if_fail (SWFDEC_IS_LOADER (loader), SWFDEC_LOADER_DATA_UNKNOWN);
-
- return loader->data_type;
-}
-
-void
-swfdec_loader_set_data_type (SwfdecLoader *loader, SwfdecLoaderDataType type)
-{
- g_return_if_fail (SWFDEC_IS_LOADER (loader));
- g_return_if_fail (loader->data_type == SWFDEC_LOADER_DATA_UNKNOWN);
- g_return_if_fail (type != SWFDEC_LOADER_DATA_UNKNOWN);
-
- loader->data_type = type;
- g_object_notify (G_OBJECT (loader), "data-type");
-}
-
-/**
- * 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 == -1);
- g_return_if_fail (size <= G_MAXLONG);
-
- 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, -1 is
- * returned. Otherwise the number is greater or equal to 0.
- *
- * Returns: the total number of bytes for this loader or -1 if unknown
- **/
-glong
-swfdec_loader_get_size (SwfdecLoader *loader)
-{
- g_return_val_if_fail (SWFDEC_IS_LOADER (loader), -1);
-
- return loader->size;
-}
-
-/**
- * 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)
-{
- SwfdecBufferQueue *queue;
-
- g_return_val_if_fail (SWFDEC_IS_LOADER (loader), 0);
-
- queue = swfdec_stream_get_queue (SWFDEC_STREAM (loader));
- return swfdec_buffer_queue_get_depth (queue) +
- swfdec_buffer_queue_get_offset (queue);
-}
-
-/**
- * swfdec_loader_data_type_get_extension:
- * @type: a #SwfdecLoaderDataType
- *
- * Queries the extension to be used for data of the given @type.
- *
- * Returns: the typical extension for this data type or the empty string
- * if the type has no extension
- **/
-const char *
-swfdec_loader_data_type_get_extension (SwfdecLoaderDataType type)
-{
- switch (type) {
- case SWFDEC_LOADER_DATA_UNKNOWN:
- return "";
- case SWFDEC_LOADER_DATA_SWF:
- return "swf";
- case SWFDEC_LOADER_DATA_FLV:
- return "flv";
- case SWFDEC_LOADER_DATA_XML:
- return "xml";
- case SWFDEC_LOADER_DATA_TEXT:
- return "txt";
- case SWFDEC_LOADER_DATA_JPEG:
- return "jpg";
- case SWFDEC_LOADER_DATA_PNG:
- return "png";
- default:
- g_warning ("unknown data type %u", type);
- return "";
- }
-}
-
-typedef struct {
- const char *name;
- guint length;
- guchar data[4];
-} ByteOrderMark;
-
-static ByteOrderMark boms[] = {
- { "UTF-8", 3, {0xEF, 0xBB, 0xBF, 0} },
- { "UTF-16BE", 2, {0xFE, 0xFF, 0, 0} },
- { "UTF-16LE", 2, {0xFF, 0xFE, 0, 0} },
- { "UTF-8", 0, {0, 0, 0, 0} }
-};
-
-char *
-swfdec_loader_get_text (SwfdecLoader *loader, guint version)
-{
- SwfdecBufferQueue *queue;
- SwfdecBuffer *buffer;
- char *text;
- guint size, i, j;
-
- /* get the text from the loader */
- queue = swfdec_stream_get_queue (SWFDEC_STREAM (loader));
- size = swfdec_buffer_queue_get_depth (queue);
- if (size == 0) {
- SWFDEC_LOG ("empty loader, returning empty string");
- return g_strdup ("");
- }
-
- buffer = swfdec_buffer_queue_peek (queue, size);
- if (!buffer)
- return NULL;
-
- if (version > 5) {
- for (i = 0; boms[i].length > 0; i++) {
- // FIXME: test what happens if we have BOM and nothing else
- if (size < boms[i].length)
- continue;
-
- for (j = 0; j < boms[i].length; j++) {
- if (buffer->data[j] != boms[i].data[j])
- break;
- }
- if (j == boms[i].length)
- break;
- }
-
- if (!strcmp (boms[i].name, "UTF-8")) {
- if (!g_utf8_validate ((char *)buffer->data + boms[i].length,
- size - boms[i].length, NULL)) {
- SWFDEC_ERROR ("downloaded data is not valid UTF-8");
- text = NULL;
- } else {
- text =
- g_strndup ((char *)buffer->data + boms[i].length,
- size - boms[i].length);
- }
- } else {
- text = g_convert ((char *)buffer->data + boms[i].length,
- size - boms[i].length, "UTF-8", boms[i].name, NULL, NULL, NULL);
- if (text == NULL)
- SWFDEC_ERROR ("downloaded data is not valid %s", boms[i].name);
- }
- } else {
- text = g_convert ((char *)buffer->data, size, "UTF-8", "LATIN1", NULL,
- NULL, NULL);
- if (text == NULL)
- SWFDEC_ERROR ("downloaded data is not valid LATIN1");
- }
-
- swfdec_buffer_unref (buffer);
-
- return text;
-}
-
diff --git a/libswfdec/swfdec_loader.h b/libswfdec/swfdec_loader.h
deleted file mode 100644
index 3d0ebff..0000000
--- a/libswfdec/swfdec_loader.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_LOADER_H_
-#define _SWFDEC_LOADER_H_
-
-#include <glib-object.h>
-#include <libswfdec/swfdec_buffer.h>
-#include <libswfdec/swfdec_player.h>
-#include <libswfdec/swfdec_stream.h>
-#include <libswfdec/swfdec_url.h>
-
-G_BEGIN_DECLS
-
-typedef enum {
- SWFDEC_LOADER_DATA_UNKNOWN,
- SWFDEC_LOADER_DATA_SWF,
- SWFDEC_LOADER_DATA_FLV,
- SWFDEC_LOADER_DATA_XML,
- SWFDEC_LOADER_DATA_TEXT,
- SWFDEC_LOADER_DATA_JPEG,
- SWFDEC_LOADER_DATA_PNG
-} SwfdecLoaderDataType;
-
-/* NB: actal numbers in SwfdecLoaderRequest are important for GetURL2 action */
-typedef enum {
- SWFDEC_LOADER_REQUEST_DEFAULT = 0,
- SWFDEC_LOADER_REQUEST_GET = 1,
- SWFDEC_LOADER_REQUEST_POST = 2
-} SwfdecLoaderRequest;
-
-typedef struct _SwfdecLoader SwfdecLoader;
-typedef struct _SwfdecLoaderClass SwfdecLoaderClass;
-
-#define SWFDEC_TYPE_LOADER (swfdec_loader_get_type())
-#define SWFDEC_IS_LOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_LOADER))
-#define SWFDEC_IS_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_LOADER))
-#define SWFDEC_LOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_LOADER, SwfdecLoader))
-#define SWFDEC_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_LOADER, SwfdecLoaderClass))
-#define SWFDEC_LOADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_LOADER, SwfdecLoaderClass))
-
-struct _SwfdecLoader
-{
- SwfdecStream stream;
-
- /*< protected >*/
- SwfdecURL * url; /* the URL for this loader in UTF-8 - must be set on creation */
- glong size; /* number of bytes in stream or -1 if unknown */
- SwfdecLoaderDataType data_type; /* type this stream is in (identified by swfdec) */
-};
-
-struct _SwfdecLoaderClass
-{
- SwfdecStreamClass stream_class;
-
- void (* load) (SwfdecLoader * loader,
- SwfdecPlayer * player,
- const char * url,
- SwfdecLoaderRequest request,
- SwfdecBuffer * buffer);
-};
-
-GType swfdec_loader_get_type (void);
-
-void swfdec_loader_set_url (SwfdecLoader * loader,
- const char * url);
-const SwfdecURL *
- swfdec_loader_get_url (SwfdecLoader * loader);
-void swfdec_loader_set_size (SwfdecLoader * loader,
- gulong size);
-glong swfdec_loader_get_size (SwfdecLoader * loader);
-gulong swfdec_loader_get_loaded (SwfdecLoader * loader);
-SwfdecLoaderDataType
- swfdec_loader_get_data_type (SwfdecLoader * loader);
-
-const char * swfdec_loader_data_type_get_extension
- (SwfdecLoaderDataType type);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_loader_internal.h b/libswfdec/swfdec_loader_internal.h
deleted file mode 100644
index c19ba9f..0000000
--- a/libswfdec/swfdec_loader_internal.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_LOADER_INTERNAL_H_
-#define _SWFDEC_LOADER_INTERNAL_H_
-
-#include "swfdec_loader.h"
-#include "swfdec_stream_target.h"
-
-G_BEGIN_DECLS
-
-/* swfdec_stream.c */
-SwfdecBufferQueue * swfdec_stream_get_queue (SwfdecStream * stream);
-const char * swfdec_stream_describe (SwfdecStream * stream);
-void swfdec_stream_close (SwfdecStream * stream);
-void swfdec_stream_set_target (SwfdecStream * stream,
- SwfdecStreamTarget * target);
-
-/* swfdec_loader.c */
-void swfdec_loader_set_data_type (SwfdecLoader * loader,
- SwfdecLoaderDataType type);
-char * swfdec_loader_get_text (SwfdecLoader * loader,
- guint version);
-
-/* swfdec_socket.c */
-void swfdec_socket_send (SwfdecSocket * sock,
- SwfdecBuffer * buffer);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_loadvars_as.c b/libswfdec/swfdec_loadvars_as.c
deleted file mode 100644
index 600dcb0..0000000
--- a/libswfdec/swfdec_loadvars_as.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "swfdec_debug.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_object.h"
-#include "swfdec_as_string.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_as_types.h"
-
-/*** AS CODE ***/
-
-SWFDEC_AS_NATIVE (301, 3, swfdec_loadvars_decode)
-void
-swfdec_loadvars_decode (SwfdecAsContext *cx, SwfdecAsObject *obj,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- if (argc < 1 || obj == NULL)
- return;
-
- swfdec_as_object_decode (obj, swfdec_as_value_to_string (cx, &argv[0]));
-}
diff --git a/libswfdec/swfdec_local_connection.c b/libswfdec/swfdec_local_connection.c
deleted file mode 100644
index 99d9d1d..0000000
--- a/libswfdec/swfdec_local_connection.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (2200, 0, swfdec_local_connection_connect)
-void
-swfdec_local_connection_connect (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("LocalConnection.connect");
-}
-
-SWFDEC_AS_NATIVE (2200, 1, swfdec_local_connection_send)
-void
-swfdec_local_connection_send (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("LocalConnection.send");
-}
-
-SWFDEC_AS_NATIVE (2200, 2, swfdec_local_connection_close)
-void
-swfdec_local_connection_close (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("LocalConnection.close");
-}
-
-SWFDEC_AS_NATIVE (2200, 3, swfdec_local_connection_domain)
-void
-swfdec_local_connection_domain (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("LocalConnection.domain");
-}
diff --git a/libswfdec/swfdec_marshal.list b/libswfdec/swfdec_marshal.list
deleted file mode 100644
index 5aeeb44..0000000
--- a/libswfdec/swfdec_marshal.list
+++ /dev/null
@@ -1,6 +0,0 @@
-BOOLEAN:DOUBLE,DOUBLE,INT
-BOOLEAN:UINT,UINT,BOOLEAN
-VOID:BOXED,POINTER,UINT
-VOID:ENUM,STRING,STRING,BOXED
-VOID:STRING,STRING
-VOID:ULONG,UINT
diff --git a/libswfdec/swfdec_microphone.c b/libswfdec/swfdec_microphone.c
deleted file mode 100644
index fe31a2c..0000000
--- a/libswfdec/swfdec_microphone.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (2104, 200, swfdec_microphone_get)
-void
-swfdec_microphone_get (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Microphone.get (static)");
-}
-
-SWFDEC_AS_NATIVE (2104, 201, swfdec_microphone_names_get)
-void
-swfdec_microphone_names_get (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Microphone.names (static, get)");
-}
-
-SWFDEC_AS_NATIVE (2104, 0, swfdec_microphone_setSilenceLevel)
-void
-swfdec_microphone_setSilenceLevel (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Microphone.setSilenceLevel");
-}
-
-SWFDEC_AS_NATIVE (2104, 1, swfdec_microphone_setRate)
-void
-swfdec_microphone_setRate (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Microphone.setRate");
-}
-
-SWFDEC_AS_NATIVE (2104, 2, swfdec_microphone_setGain)
-void
-swfdec_microphone_setGain (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Microphone.setGain");
-}
-
-SWFDEC_AS_NATIVE (2104, 3, swfdec_microphone_setUseEchoSuppression)
-void
-swfdec_microphone_setUseEchoSuppression (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Microphone.setUseEchoSuppression");
-}
diff --git a/libswfdec/swfdec_morph_movie.c b/libswfdec/swfdec_morph_movie.c
deleted file mode 100644
index e53f881..0000000
--- a/libswfdec/swfdec_morph_movie.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_morph_movie.h"
-#include "swfdec_debug.h"
-#include "swfdec_draw.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_stroke.h"
-
-G_DEFINE_TYPE (SwfdecMorphMovie, swfdec_morph_movie, SWFDEC_TYPE_MOVIE)
-
-static void
-swfdec_morph_movie_update_extents (SwfdecMovie *movie,
- SwfdecRect *extents)
-{
- guint ratio = movie->original_ratio;
- SwfdecMorphMovie *mmovie = SWFDEC_MORPH_MOVIE (movie);
- SwfdecMorphShape *morph = mmovie->morph;
- SwfdecGraphic *graphic = SWFDEC_GRAPHIC (morph);
- extents->x0 = ((65535 - ratio) * graphic->extents.x0 + ratio * morph->end_extents.x0) / 65535;
- extents->x1 = ((65535 - ratio) * graphic->extents.x1 + ratio * morph->end_extents.x1) / 65535;
- extents->y0 = ((65535 - ratio) * graphic->extents.y0 + ratio * morph->end_extents.y0) / 65535;
- extents->y1 = ((65535 - ratio) * graphic->extents.y1 + ratio * morph->end_extents.y1) / 65535;
-}
-
-static void
-swfdec_morph_movie_set_ratio (SwfdecMovie *movie)
-{
- SwfdecMorphMovie *mmovie = SWFDEC_MORPH_MOVIE (movie);
-
- swfdec_movie_invalidate_next (movie);
- g_slist_foreach (mmovie->draws, (GFunc) g_object_unref, NULL);
- g_slist_free (mmovie->draws);
- mmovie->draws = NULL;
- swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_EXTENTS);
-}
-
-static void
-swfdec_morph_movie_create_morphs (SwfdecMorphMovie *mmovie)
-{
- SwfdecShape *shape = SWFDEC_SHAPE (mmovie->morph);
- guint ratio = SWFDEC_MOVIE (mmovie)->original_ratio;
- GSList *walk;
-
- for (walk = shape->draws; walk; walk = walk->next) {
- mmovie->draws = g_slist_prepend (mmovie->draws, swfdec_draw_morph (walk->data, ratio));
- }
- mmovie->draws = g_slist_reverse (mmovie->draws);
-}
-
-static void
-swfdec_morph_movie_render (SwfdecMovie *movie, cairo_t *cr,
- const SwfdecColorTransform *trans, const SwfdecRect *inval)
-{
- SwfdecMorphMovie *morph = SWFDEC_MORPH_MOVIE (movie);
- GSList *walk;
-
- if (morph->draws == NULL)
- swfdec_morph_movie_create_morphs (morph);
-
- for (walk = morph->draws; walk; walk = walk->next) {
- SwfdecDraw *draw = walk->data;
-
- if (!swfdec_rect_intersect (NULL, &draw->extents, inval))
- continue;
-
- swfdec_draw_paint (draw, cr, trans);
- }
-}
-
-static void
-swfdec_morph_movie_invalidate (SwfdecMovie *movie, const cairo_matrix_t *matrix, gboolean last)
-{
- SwfdecRect rect;
-
- swfdec_rect_transform (&rect, &movie->original_extents, matrix);
- swfdec_player_invalidate (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), &rect);
-}
-
-static void
-swfdec_morph_movie_dispose (GObject *object)
-{
- SwfdecMorphMovie *morph = SWFDEC_MORPH_MOVIE (object);
-
- g_slist_foreach (morph->draws, (GFunc) g_object_unref, NULL);
- g_slist_free (morph->draws);
- morph->draws = NULL;
- g_object_unref (morph->morph);
-
- G_OBJECT_CLASS (swfdec_morph_movie_parent_class)->dispose (object);
-}
-
-static void
-swfdec_morph_movie_class_init (SwfdecMorphMovieClass * g_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (g_class);
- SwfdecMovieClass *movie_class = SWFDEC_MOVIE_CLASS (g_class);
-
- object_class->dispose = swfdec_morph_movie_dispose;
-
- movie_class->update_extents = swfdec_morph_movie_update_extents;
- movie_class->render = swfdec_morph_movie_render;
- movie_class->invalidate = swfdec_morph_movie_invalidate;
- movie_class->set_ratio = swfdec_morph_movie_set_ratio;
- /* FIXME */
- //movie_class->handle_mouse = swfdec_morph_movie_handle_mouse;
-}
-
-static void
-swfdec_morph_movie_init (SwfdecMorphMovie *morph)
-{
-}
-
diff --git a/libswfdec/swfdec_morph_movie.h b/libswfdec/swfdec_morph_movie.h
deleted file mode 100644
index c8dd6cc..0000000
--- a/libswfdec/swfdec_morph_movie.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_MORPH_MOVIE_H_
-#define _SWFDEC_MORPH_MOVIE_H_
-
-#include <glib-object.h>
-#include <libswfdec/swfdec_movie.h>
-#include <libswfdec/swfdec_morphshape.h>
-
-G_BEGIN_DECLS
-
-
-typedef struct _SwfdecMorphMovie SwfdecMorphMovie;
-typedef struct _SwfdecMorphMovieClass SwfdecMorphMovieClass;
-
-#define SWFDEC_TYPE_MORPH_MOVIE (swfdec_morph_movie_get_type())
-#define SWFDEC_IS_MORPH_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_MORPH_MOVIE))
-#define SWFDEC_IS_MORPH_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_MORPH_MOVIE))
-#define SWFDEC_MORPH_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_MORPH_MOVIE, SwfdecMorphMovie))
-#define SWFDEC_MORPH_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_MORPH_MOVIE, SwfdecMorphMovieClass))
-
-struct _SwfdecMorphMovie {
- SwfdecMovie movie;
-
- SwfdecMorphShape * morph;
- GSList * draws; /* drawing operations to use or NULL if not yet created */
-};
-
-struct _SwfdecMorphMovieClass {
- SwfdecMovieClass movie_class;
-};
-
-GType swfdec_morph_movie_get_type (void);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_morphshape.c b/libswfdec/swfdec_morphshape.c
deleted file mode 100644
index 5252804..0000000
--- a/libswfdec/swfdec_morphshape.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_morphshape.h"
-#include "swfdec_debug.h"
-#include "swfdec_image.h"
-#include "swfdec_morph_movie.h"
-#include "swfdec_shape_parser.h"
-
-G_DEFINE_TYPE (SwfdecMorphShape, swfdec_morph_shape, SWFDEC_TYPE_SHAPE)
-
-static SwfdecMovie *
-swfdec_graphic_create_movie (SwfdecGraphic *graphic, gsize *size)
-{
- SwfdecMorphShape *morph = SWFDEC_MORPH_SHAPE (graphic);
- SwfdecMorphMovie *movie = g_object_new (SWFDEC_TYPE_MORPH_MOVIE, NULL);
-
- movie->morph = morph;
- g_object_ref (morph);
-
- *size = sizeof (SwfdecMorphMovie);
-
- return SWFDEC_MOVIE (movie);
-}
-
-static void
-swfdec_morph_shape_class_init (SwfdecMorphShapeClass * g_class)
-{
- SwfdecGraphicClass *graphic_class = SWFDEC_GRAPHIC_CLASS (g_class);
-
- graphic_class->create_movie = swfdec_graphic_create_movie;
-}
-
-static void
-swfdec_morph_shape_init (SwfdecMorphShape * morph)
-{
-}
-
-
-int
-tag_define_morph_shape (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecShapeParser *parser;
- SwfdecBits bits2;
- SwfdecBits *bits = &s->b;
- SwfdecMorphShape *morph;
- guint offset;
- int id;
-
- id = swfdec_bits_get_u16 (bits);
-
- morph = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_MORPH_SHAPE);
- if (!morph)
- return SWFDEC_STATUS_OK;
-
- SWFDEC_INFO ("id=%d", id);
-
- swfdec_bits_get_rect (bits, &SWFDEC_GRAPHIC (morph)->extents);
- swfdec_bits_get_rect (bits, &morph->end_extents);
- offset = swfdec_bits_get_u32 (bits);
- swfdec_bits_init_bits (&bits2, bits, offset);
-
- parser = swfdec_shape_parser_new ((SwfdecParseDrawFunc) swfdec_pattern_parse_morph,
- (SwfdecParseDrawFunc) swfdec_stroke_parse_morph, s);
- swfdec_shape_parser_parse_morph (parser, &bits2, bits);
- SWFDEC_SHAPE (morph)->draws = swfdec_shape_parser_free (parser);
-
- if (swfdec_bits_left (&bits2)) {
- SWFDEC_WARNING ("early finish when parsing start shapes: %u bytes",
- swfdec_bits_left (&bits2));
- }
-
- return SWFDEC_STATUS_OK;
-}
diff --git a/libswfdec/swfdec_morphshape.h b/libswfdec/swfdec_morphshape.h
deleted file mode 100644
index e460109..0000000
--- a/libswfdec/swfdec_morphshape.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_MORPH_SHAPE_H_
-#define _SWFDEC_MORPH_SHAPE_H_
-
-#include <libswfdec/swfdec_shape.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecMorphShape SwfdecMorphShape;
-typedef struct _SwfdecMorphShapeClass SwfdecMorphShapeClass;
-
-#define SWFDEC_TYPE_MORPH_SHAPE (swfdec_morph_shape_get_type())
-#define SWFDEC_IS_MORPH_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_MORPH_SHAPE))
-#define SWFDEC_IS_MORPH_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_MORPH_SHAPE))
-#define SWFDEC_MORPH_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_MORPH_SHAPE, SwfdecMorphShape))
-#define SWFDEC_MORPH_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_MORPH_SHAPE, SwfdecMorphShapeClass))
-
-struct _SwfdecMorphShape {
- SwfdecShape shape;
-
- SwfdecRect end_extents; /* extents at end of morph (compare with graphic->extents for start) */
-};
-
-struct _SwfdecMorphShapeClass {
- SwfdecShapeClass shape_class;
-};
-
-GType swfdec_morph_shape_get_type (void);
-
-int tag_define_morph_shape (SwfdecSwfDecoder * s,
- guint tag);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_mouse_as.c b/libswfdec/swfdec_mouse_as.c
deleted file mode 100644
index 88ee046..0000000
--- a/libswfdec/swfdec_mouse_as.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_as_object.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-#include "swfdec_player_internal.h"
-
-SWFDEC_AS_NATIVE (5, 0, swfdec_mouse_show)
-void
-swfdec_mouse_show (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
-
- SWFDEC_AS_VALUE_SET_INT (retval, player->priv->mouse_visible ? 1 : 0);
- player->priv->mouse_visible = TRUE;
-}
-
-SWFDEC_AS_NATIVE (5, 1, swfdec_mouse_hide)
-void
-swfdec_mouse_hide (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
-
- SWFDEC_AS_VALUE_SET_INT (retval, player->priv->mouse_visible ? 1 : 0);
- player->priv->mouse_visible = FALSE;
-}
-
diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
deleted file mode 100644
index 278a067..0000000
--- a/libswfdec/swfdec_movie.c
+++ /dev/null
@@ -1,1815 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include <errno.h>
-
-#include "swfdec_movie.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_button_movie.h"
-#include "swfdec_debug.h"
-#include "swfdec_draw.h"
-#include "swfdec_event.h"
-#include "swfdec_graphic.h"
-#include "swfdec_image.h"
-#include "swfdec_loader_internal.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_sprite.h"
-#include "swfdec_sprite_movie.h"
-#include "swfdec_resource.h"
-#include "swfdec_system.h"
-#include "swfdec_utils.h"
-#include "swfdec_as_internal.h"
-
-/*** MOVIE ***/
-
-enum {
- PROP_0,
- PROP_DEPTH
-};
-
-G_DEFINE_ABSTRACT_TYPE (SwfdecMovie, swfdec_movie, SWFDEC_TYPE_AS_OBJECT)
-
-static void
-swfdec_movie_init (SwfdecMovie * movie)
-{
- movie->blend_mode = 1;
-
- movie->xscale = 100;
- movie->yscale = 100;
- cairo_matrix_init_identity (&movie->original_transform);
- cairo_matrix_init_identity (&movie->matrix);
- cairo_matrix_init_identity (&movie->inverse_matrix);
-
- swfdec_color_transform_init_identity (&movie->color_transform);
- swfdec_color_transform_init_identity (&movie->original_ctrans);
-
- movie->visible = TRUE;
- movie->cache_state = SWFDEC_MOVIE_INVALID_EXTENTS;
- movie->invalidate_last = TRUE;
- movie->invalidate_next = TRUE;
-
- swfdec_rect_init_empty (&movie->extents);
-}
-
-/**
- * swfdec_movie_invalidate:
- * @movie: a #SwfdecMovie
- * @parent_to_global: This is the matrix from the parent to the global matrix.
- * It is only used for caching reasons
- * @new_contents: %TRUE if this is the invalidation of the new contents, %FALSE
- * if the old contents are invalidated.
- *
- * Performs an instant invalidation on @movie. You most likely don't want to
- * call this function directly, but use swfdec_movie_invalidate_last_last() or
- * swfdec_movie_invalidate_next() instead.
- **/
-void
-swfdec_movie_invalidate (SwfdecMovie *movie, const cairo_matrix_t *parent_to_global,
- gboolean new_contents)
-{
- SwfdecMovieClass *klass;
- cairo_matrix_t matrix;
-
- if (new_contents) {
- movie->invalidate_next = FALSE;
- } else {
- if (movie->invalidate_last)
- return;
- movie->invalidate_last = TRUE;
- }
- g_assert (movie->cache_state <= SWFDEC_MOVIE_INVALID_CHILDREN);
- SWFDEC_LOG ("invalidating %s %s at %s", G_OBJECT_TYPE_NAME (movie),
- movie->name, new_contents ? "end" : "start");
- cairo_matrix_multiply (&matrix, &movie->matrix, parent_to_global);
- klass = SWFDEC_MOVIE_GET_CLASS (movie);
- klass->invalidate (movie, &matrix, new_contents);
-}
-
-/**
- * swfdec_movie_invalidate_last:
- * @movie: a #SwfdecMovie
- *
- * Ensures the movie's contents are invalidated. This function must be called
- * before changing the movie or the output will have artifacts.
- **/
-void
-swfdec_movie_invalidate_last (SwfdecMovie *movie)
-{
- cairo_matrix_t matrix;
-
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
-
- if (movie->invalidate_last)
- return;
-
- if (movie->parent)
- swfdec_movie_local_to_global_matrix (movie->parent, &matrix);
- else
- cairo_matrix_init_identity (&matrix);
- swfdec_movie_invalidate (movie, &matrix, FALSE);
- g_assert (movie->invalidate_last);
-}
-
-/**
- * swfdec_movie_invalidate_last_next:
- * @movie: a #SwfdecMovie
- *
- * Ensures the movie will be invalidated after script execution is done. So
- * after calling this function you can modify position and contents of the
- * @movie in any way.
- **/
-void
-swfdec_movie_invalidate_next (SwfdecMovie *movie)
-{
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
-
- swfdec_movie_invalidate_last (movie);
- movie->invalidate_next = TRUE;
-}
-
-/**
- * swfdec_movie_queue_update:
- * @movie: a #SwfdecMovie
- * @state: how much needs to be updated
- *
- * Queues an update of all cached values inside @movie and invalidates it.
- **/
-void
-swfdec_movie_queue_update (SwfdecMovie *movie, SwfdecMovieCacheState state)
-{
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
-
- if (state > SWFDEC_MOVIE_INVALID_EXTENTS) {
- swfdec_movie_invalidate_next (movie);
- }
- while (movie && movie->cache_state < state) {
- movie->cache_state = state;
- movie = movie->parent;
- state = SWFDEC_MOVIE_INVALID_CHILDREN;
- }
-}
-
-static void
-swfdec_movie_update_extents (SwfdecMovie *movie)
-{
- SwfdecMovieClass *klass;
- GList *walk;
- SwfdecRect *rect = &movie->original_extents;
- SwfdecRect *extents = &movie->extents;
-
- *rect = movie->draw_extents;
- if (movie->image) {
- SwfdecRect image_extents = { 0, 0,
- movie->image->width * SWFDEC_TWIPS_SCALE_FACTOR,
- movie->image->height * SWFDEC_TWIPS_SCALE_FACTOR };
- swfdec_rect_union (rect, rect, &image_extents);
- }
- for (walk = movie->list; walk; walk = walk->next) {
- swfdec_rect_union (rect, rect, &SWFDEC_MOVIE (walk->data)->extents);
- }
- klass = SWFDEC_MOVIE_GET_CLASS (movie);
- if (klass->update_extents)
- klass->update_extents (movie, rect);
- if (swfdec_rect_is_empty (rect)) {
- *extents = *rect;
- return;
- }
- swfdec_rect_transform (extents, rect, &movie->matrix);
- if (movie->parent && movie->parent->cache_state < SWFDEC_MOVIE_INVALID_EXTENTS) {
- /* no need to invalidate here */
- movie->parent->cache_state = SWFDEC_MOVIE_INVALID_EXTENTS;
- }
-}
-
-static void
-swfdec_movie_update_matrix (SwfdecMovie *movie)
-{
- double d, e;
-
- /* we operate on x0 and y0 when setting movie._x and movie._y */
- if (movie->modified) {
- movie->matrix.xx = movie->original_transform.xx;
- movie->matrix.yx = movie->original_transform.yx;
- movie->matrix.xy = movie->original_transform.xy;
- movie->matrix.yy = movie->original_transform.yy;
- } else {
- movie->matrix = movie->original_transform;
- }
-
- d = movie->xscale / swfdec_matrix_get_xscale (&movie->original_transform);
- e = movie->yscale / swfdec_matrix_get_yscale (&movie->original_transform);
- cairo_matrix_scale (&movie->matrix, d, e);
- if (isfinite (movie->rotation)) {
- d = movie->rotation - swfdec_matrix_get_rotation (&movie->original_transform);
- cairo_matrix_rotate (&movie->matrix, d * G_PI / 180);
- }
- swfdec_matrix_ensure_invertible (&movie->matrix, &movie->inverse_matrix);
-}
-
-static void
-swfdec_movie_do_update (SwfdecMovie *movie)
-{
- GList *walk;
-
- for (walk = movie->list; walk; walk = walk->next) {
- SwfdecMovie *child = walk->data;
-
- if (child->cache_state != SWFDEC_MOVIE_UP_TO_DATE)
- swfdec_movie_do_update (child);
- }
-
- switch (movie->cache_state) {
- case SWFDEC_MOVIE_INVALID_MATRIX:
- swfdec_movie_update_matrix (movie);
- /* fall through */
- case SWFDEC_MOVIE_INVALID_EXTENTS:
- swfdec_movie_update_extents (movie);
- /* fall through */
- case SWFDEC_MOVIE_INVALID_CHILDREN:
- break;
- case SWFDEC_MOVIE_UP_TO_DATE:
- default:
- g_assert_not_reached ();
- }
- movie->cache_state = SWFDEC_MOVIE_UP_TO_DATE;
-}
-
-/**
- * swfdec_movie_update:
- * @movie: a #SwfdecMovie
- *
- * Brings the cached values of @movie up-to-date if they are not. This includes
- * transformation matrices and extents. It needs to be called before accessing
- * the relevant values.
- **/
-void
-swfdec_movie_update (SwfdecMovie *movie)
-{
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
-
- if (movie->cache_state == SWFDEC_MOVIE_UP_TO_DATE)
- return;
-
- if (movie->parent && movie->parent->cache_state != SWFDEC_MOVIE_UP_TO_DATE) {
- swfdec_movie_update (movie->parent);
- } else {
- swfdec_movie_do_update (movie);
- }
-}
-
-SwfdecMovie *
-swfdec_movie_find (SwfdecMovie *movie, int depth)
-{
- GList *walk;
-
- g_return_val_if_fail (SWFDEC_IS_MOVIE (movie), NULL);
-
- for (walk = movie->list; walk; walk = walk->next) {
- SwfdecMovie *cur= walk->data;
-
- if (cur->depth < depth)
- continue;
- if (cur->depth == depth)
- return cur;
- break;
- }
- return NULL;
-}
-
-static gboolean
-swfdec_movie_do_remove (SwfdecMovie *movie, gboolean destroy)
-{
- SwfdecPlayerPrivate *priv;
- SwfdecPlayer *player;
-
- SWFDEC_LOG ("removing %s %s", G_OBJECT_TYPE_NAME (movie), movie->name);
-
- player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
- while (movie->list) {
- GList *walk = movie->list;
- while (walk && SWFDEC_MOVIE (walk->data)->state >= SWFDEC_MOVIE_STATE_REMOVED)
- walk = walk->next;
- if (walk == NULL)
- break;
- destroy &= swfdec_movie_do_remove (walk->data, destroy);
- }
- /* FIXME: all of this here or in destroy callback? */
- priv = player->priv;
- if (priv->mouse_grab == movie)
- priv->mouse_grab = NULL;
- if (priv->mouse_drag == movie)
- priv->mouse_drag = NULL;
- swfdec_movie_invalidate_last (movie);
- movie->state = SWFDEC_MOVIE_STATE_REMOVED;
-
- if ((movie->events &&
- swfdec_event_list_has_conditions (movie->events, SWFDEC_AS_OBJECT (movie), SWFDEC_EVENT_UNLOAD, 0)) ||
- swfdec_as_object_has_variable (SWFDEC_AS_OBJECT (movie), SWFDEC_AS_STR_onUnload)) {
- swfdec_movie_queue_script (movie, SWFDEC_EVENT_UNLOAD);
- destroy = FALSE;
- }
- if (destroy)
- swfdec_movie_destroy (movie);
- return destroy;
-}
-
-/**
- * swfdec_movie_remove:
- * @movie: #SwfdecMovie to remove
- *
- * Removes this movie from its parent. In contrast to swfdec_movie_destroy (),
- * it will definitely cause a removal from the display list, but depending on
- * movie, it might still be possible to reference it from Actionscript.
- **/
-void
-swfdec_movie_remove (SwfdecMovie *movie)
-{
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
-
- if (movie->state > SWFDEC_MOVIE_STATE_RUNNING)
- return;
- if (swfdec_movie_do_remove (movie, TRUE))
- return;
-
- swfdec_movie_set_depth (movie, -32769 - movie->depth); /* don't ask me why... */
-}
-
-/**
- * swfdec_movie_destroy:
- * @movie: #SwfdecMovie to destroy
- *
- * Removes this movie from its parent. After this it will no longer be present,
- * neither visually nor via ActionScript. This function will not cause an
- * unload event. Compare with swfdec_movie_remove ().
- **/
-void
-swfdec_movie_destroy (SwfdecMovie *movie)
-{
- SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (movie);
- SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
-
- g_assert (movie->state < SWFDEC_MOVIE_STATE_DESTROYED);
- SWFDEC_LOG ("destroying movie %s", movie->name);
- while (movie->list) {
- swfdec_movie_destroy (movie->list->data);
- }
- if (movie->parent) {
- movie->parent->list = g_list_remove (movie->parent->list, movie);
- } else {
- player->priv->roots = g_list_remove (player->priv->roots, movie);
- }
- /* unset masks */
- if (movie->masked_by)
- movie->masked_by->mask_of = NULL;
- if (movie->mask_of)
- movie->mask_of->masked_by = NULL;
- movie->masked_by = NULL;
- movie->mask_of = NULL;
- /* FIXME: figure out how to handle destruction pre-init/construct.
- * This is just a stop-gap measure to avoid dead movies in those queues */
- swfdec_player_remove_all_actions (player, movie);
- if (klass->finish_movie)
- klass->finish_movie (movie);
- player->priv->movies = g_list_remove (player->priv->movies, movie);
- movie->state = SWFDEC_MOVIE_STATE_DESTROYED;
- /* unset prototype here, so we don't work in AS anymore */
- SWFDEC_AS_OBJECT (movie)->prototype = NULL;
- g_object_unref (movie);
-}
-
-static void
-swfdec_movie_set_constructor (SwfdecSpriteMovie *movie)
-{
- SwfdecMovie *mov = SWFDEC_MOVIE (movie);
- SwfdecAsContext *context = SWFDEC_AS_OBJECT (movie)->context;
- SwfdecAsObject *constructor = NULL;
-
- g_assert (mov->resource != NULL);
-
- if (movie->sprite) {
- const char *name;
-
- name = swfdec_resource_get_export_name (mov->resource,
- SWFDEC_CHARACTER (movie->sprite));
- if (name != NULL) {
- name = swfdec_as_context_get_string (context, name);
- constructor = swfdec_player_get_export_class (SWFDEC_PLAYER (context),
- name);
- }
- }
- if (constructor == NULL)
- constructor = mov->resource->sandbox->MovieClip;
-
- swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (movie), constructor);
-}
-
-/**
- * swfdec_movie_resolve:
- * @movie: movie to resolve
- *
- * Resolves a movie clip to its real version. Since movie clips can be
- * explicitly destroyed, they have problems with references to them. In the
- * case of destruction, these references will remain as "dangling pointers".
- * However, if a movie with the same name is later created again, the reference
- * will point to that movie. This function does this resolving.
- *
- * Returns: The movie clip @movie resolves to or %NULL if none.
- **/
-SwfdecMovie *
-swfdec_movie_resolve (SwfdecMovie *movie)
-{
- g_return_val_if_fail (SWFDEC_IS_MOVIE (movie), NULL);
-
- if (movie->state != SWFDEC_MOVIE_STATE_DESTROYED)
- return movie;
- if (movie->parent == NULL) {
- SWFDEC_FIXME ("figure out how to resolve root movies");
- return NULL;
- }
- /* FIXME: include unnamed ones? */
- return swfdec_movie_get_by_name (movie->parent, movie->original_name, FALSE);
-}
-
-guint
-swfdec_movie_get_version (SwfdecMovie *movie)
-{
- return movie->resource->version;
-}
-
-void
-swfdec_movie_execute (SwfdecMovie *movie, SwfdecEventType condition)
-{
- SwfdecAsObject *thisp;
- const char *name;
-
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
-
- if (SWFDEC_IS_BUTTON_MOVIE (movie)) {
- /* these conditions don't exist for buttons */
- if (condition == SWFDEC_EVENT_CONSTRUCT || condition < SWFDEC_EVENT_PRESS)
- return;
- thisp = SWFDEC_AS_OBJECT (movie->parent);
- if (swfdec_movie_get_version (movie) <= 5) {
- while (!SWFDEC_IS_SPRITE_MOVIE (thisp))
- thisp = SWFDEC_AS_OBJECT (SWFDEC_MOVIE (thisp)->parent);
- }
- g_assert (thisp);
- } else {
- thisp = SWFDEC_AS_OBJECT (movie);
- }
-
- /* special cases */
- if (condition == SWFDEC_EVENT_CONSTRUCT) {
- if (swfdec_movie_get_version (movie) <= 5)
- return;
- swfdec_movie_set_constructor (SWFDEC_SPRITE_MOVIE (movie));
- } else if (condition == SWFDEC_EVENT_ENTER) {
- if (movie->state >= SWFDEC_MOVIE_STATE_REMOVED)
- return;
- }
-
- swfdec_sandbox_use (movie->resource->sandbox);
- if (movie->events) {
- swfdec_event_list_execute (movie->events, thisp, condition, 0);
- }
- /* FIXME: how do we compute the version correctly here? */
- if (swfdec_movie_get_version (movie) > 5) {
- name = swfdec_event_type_get_name (condition);
- if (name != NULL) {
- swfdec_as_object_call (SWFDEC_AS_OBJECT (movie), name, 0, NULL, NULL);
- }
- if (condition == SWFDEC_EVENT_CONSTRUCT)
- swfdec_as_object_call (thisp, SWFDEC_AS_STR_constructor, 0, NULL, NULL);
- }
- swfdec_sandbox_unuse (movie->resource->sandbox);
-}
-
-/**
- * swfdec_movie_queue_script:
- * @movie: a #SwfdecMovie
- * @condition: the event that should happen
- *
- * Queues execution of all scripts associated with the given event.
- **/
-void
-swfdec_movie_queue_script (SwfdecMovie *movie, SwfdecEventType condition)
-{
- SwfdecPlayer *player;
- guint importance;
-
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
-
- if (!SWFDEC_IS_SPRITE_MOVIE (movie) && !SWFDEC_IS_BUTTON_MOVIE (movie))
- return;
-
- switch (condition) {
- case SWFDEC_EVENT_INITIALIZE:
- importance = 0;
- break;
- case SWFDEC_EVENT_CONSTRUCT:
- importance = 1;
- break;
- case SWFDEC_EVENT_LOAD:
- case SWFDEC_EVENT_ENTER:
- case SWFDEC_EVENT_UNLOAD:
- case SWFDEC_EVENT_MOUSE_MOVE:
- case SWFDEC_EVENT_MOUSE_DOWN:
- case SWFDEC_EVENT_MOUSE_UP:
- case SWFDEC_EVENT_KEY_UP:
- case SWFDEC_EVENT_KEY_DOWN:
- case SWFDEC_EVENT_DATA:
- case SWFDEC_EVENT_PRESS:
- case SWFDEC_EVENT_RELEASE:
- case SWFDEC_EVENT_RELEASE_OUTSIDE:
- case SWFDEC_EVENT_ROLL_OVER:
- case SWFDEC_EVENT_ROLL_OUT:
- case SWFDEC_EVENT_DRAG_OVER:
- case SWFDEC_EVENT_DRAG_OUT:
- case SWFDEC_EVENT_KEY_PRESS:
- importance = 2;
- break;
- default:
- g_return_if_reached ();
- }
-
- player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
- swfdec_player_add_action (player, movie, condition, importance);
-}
-
-void
-swfdec_movie_local_to_global (SwfdecMovie *movie, double *x, double *y)
-{
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
- g_return_if_fail (x != NULL);
- g_return_if_fail (y != NULL);
-
- do {
- cairo_matrix_transform_point (&movie->matrix, x, y);
- } while ((movie = movie->parent));
-}
-
-void
-swfdec_movie_rect_local_to_global (SwfdecMovie *movie, SwfdecRect *rect)
-{
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
- g_return_if_fail (rect != NULL);
-
- swfdec_movie_local_to_global (movie, &rect->x0, &rect->y0);
- swfdec_movie_local_to_global (movie, &rect->x1, &rect->y1);
- if (rect->x0 > rect->x1) {
- double tmp = rect->x1;
- rect->x1 = rect->x0;
- rect->x0 = tmp;
- }
- if (rect->y0 > rect->y1) {
- double tmp = rect->y1;
- rect->y1 = rect->y0;
- rect->y0 = tmp;
- }
-}
-
-void
-swfdec_movie_global_to_local_matrix (SwfdecMovie *movie, cairo_matrix_t *matrix)
-{
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
- g_return_if_fail (matrix != NULL);
-
- cairo_matrix_init_identity (matrix);
- while (movie) {
- if (movie->cache_state >= SWFDEC_MOVIE_INVALID_MATRIX)
- swfdec_movie_update (movie);
- cairo_matrix_multiply (matrix, &movie->inverse_matrix, matrix);
- movie = movie->parent;
- }
-}
-
-void
-swfdec_movie_local_to_global_matrix (SwfdecMovie *movie, cairo_matrix_t *matrix)
-{
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
- g_return_if_fail (matrix != NULL);
-
- cairo_matrix_init_identity (matrix);
- while (movie) {
- if (movie->cache_state >= SWFDEC_MOVIE_INVALID_MATRIX)
- swfdec_movie_update (movie);
- cairo_matrix_multiply (matrix, matrix, &movie->matrix);
- movie = movie->parent;
- }
-}
-
-void
-swfdec_movie_global_to_local (SwfdecMovie *movie, double *x, double *y)
-{
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
- g_return_if_fail (x != NULL);
- g_return_if_fail (y != NULL);
-
- if (movie->parent) {
- swfdec_movie_global_to_local (movie->parent, x, y);
- }
- if (movie->cache_state >= SWFDEC_MOVIE_INVALID_MATRIX)
- swfdec_movie_update (movie);
- cairo_matrix_transform_point (&movie->inverse_matrix, x, y);
-}
-
-void
-swfdec_movie_rect_global_to_local (SwfdecMovie *movie, SwfdecRect *rect)
-{
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
- g_return_if_fail (rect != NULL);
-
- swfdec_movie_global_to_local (movie, &rect->x0, &rect->y0);
- swfdec_movie_global_to_local (movie, &rect->x1, &rect->y1);
- if (rect->x0 > rect->x1) {
- double tmp = rect->x1;
- rect->x1 = rect->x0;
- rect->x0 = tmp;
- }
- if (rect->y0 > rect->y1) {
- double tmp = rect->y1;
- rect->y1 = rect->y0;
- rect->y0 = tmp;
- }
-}
-
-/**
- * swfdec_movie_get_mouse:
- * @movie: a #SwfdecMovie
- * @x: pointer to hold result of X coordinate
- * @y: pointer to hold result of y coordinate
- *
- * Gets the mouse coordinates in the coordinate space of @movie.
- **/
-void
-swfdec_movie_get_mouse (SwfdecMovie *movie, double *x, double *y)
-{
- SwfdecPlayer *player;
-
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
- g_return_if_fail (x != NULL);
- g_return_if_fail (y != NULL);
-
- player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
- *x = player->priv->mouse_x;
- *y = player->priv->mouse_y;
- swfdec_player_stage_to_global (player, x, y);
- swfdec_movie_global_to_local (movie, x, y);
-}
-
-/**
- * swfdec_movie_get_mouse_events:
- * @movie: a #SwfdecMovie
- *
- * Checks if this movie should respond to mouse events.
- *
- * Returns: %TRUE if this movie can receive mouse events
- **/
-gboolean
-swfdec_movie_get_mouse_events (SwfdecMovie *movie)
-{
- SwfdecMovieClass *klass;
-
- g_return_val_if_fail (SWFDEC_IS_MOVIE (movie), FALSE);
-
- klass = SWFDEC_MOVIE_GET_CLASS (movie);
- if (klass->mouse_events)
- return klass->mouse_events (movie);
- else
- return FALSE;
-}
-
-/**
- * swfdec_movie_get_movie_at:
- * @movie: a #SwfdecMovie
- * @x: x coordinate in parent's coordinate space
- * @y: y coordinate in the parent's coordinate space
- * @events: %TRUE to only prefer movies that receive events
- *
- * Gets the child at the given coordinates. The coordinates are in the
- * coordinate system of @movie's parent (or the global coordinate system for
- * root movies). The @events parameter determines if movies that don't receive
- * events should be respected.
- *
- * Returns: the child of @movie at the given coordinates or %NULL if none
- **/
-SwfdecMovie *
-swfdec_movie_get_movie_at (SwfdecMovie *movie, double x, double y, gboolean events)
-{
- SwfdecMovie *ret;
- SwfdecMovieClass *klass;
-
- g_return_val_if_fail (SWFDEC_IS_MOVIE (movie), NULL);
-
- SWFDEC_LOG ("%s %p getting mouse at: %g %g", G_OBJECT_TYPE_NAME (movie), movie, x, y);
- if (!swfdec_rect_contains (&movie->extents, x, y)) {
- return NULL;
- }
- cairo_matrix_transform_point (&movie->inverse_matrix, &x, &y);
-
- klass = SWFDEC_MOVIE_GET_CLASS (movie);
- g_return_val_if_fail (klass->contains, NULL);
- ret = klass->contains (movie, x, y, events);
-
- return ret;
-}
-
-static SwfdecMovie *
-swfdec_movie_do_contains (SwfdecMovie *movie, double x, double y, gboolean events)
-{
- GList *walk;
- GSList *walk2;
- SwfdecMovie *ret, *got;
-
- ret = NULL;
- for (walk = movie->list; walk; walk = walk->next) {
- SwfdecMovie *child = walk->data;
-
- if (!child->visible) {
- SWFDEC_LOG ("%s %s (depth %d) is invisible, ignoring", G_OBJECT_TYPE_NAME (movie), movie->name, movie->depth);
- continue;
- }
- got = swfdec_movie_get_movie_at (child, x, y, events);
- if (got != NULL) {
- if (events) {
- /* set the return value to the topmost movie */
- if (swfdec_movie_get_mouse_events (got)) {
- ret = got;
- } else if (ret == NULL) {
- ret = movie;
- }
- } else {
- /* if thie is not a clipped movie, we've found something */
- if (child->clip_depth == 0)
- return movie;
- }
- } else {
- if (child->clip_depth) {
- /* skip obscured movies */
- SwfdecMovie *tmp = walk->next ? walk->next->data : NULL;
- while (tmp && tmp->depth <= child->clip_depth) {
- walk = walk->next;
- tmp = walk->next ? walk->next->data : NULL;
- }
- }
- }
- }
- if (ret)
- return ret;
-
- for (walk2 = movie->draws; walk2; walk2 = walk2->next) {
- SwfdecDraw *draw = walk2->data;
-
- if (swfdec_draw_contains (draw, x, y))
- return movie;
- }
-
- return NULL;
-}
-
-static gboolean
-swfdec_movie_needs_group (SwfdecMovie *movie)
-{
- return (movie->blend_mode > 1);
-}
-
-static cairo_operator_t
-swfdec_movie_get_operator_for_blend_mode (guint blend_mode)
-{
- switch (blend_mode) {
- case SWFDEC_BLEND_MODE_NORMAL:
- SWFDEC_ERROR ("shouldn't need to get operator without blend mode?!");
- case SWFDEC_BLEND_MODE_LAYER:
- return CAIRO_OPERATOR_OVER;
- case SWFDEC_BLEND_MODE_ADD:
- return CAIRO_OPERATOR_ADD;
- case SWFDEC_BLEND_MODE_ALPHA:
- return CAIRO_OPERATOR_DEST_IN;
- case SWFDEC_BLEND_MODE_ERASE:
- return CAIRO_OPERATOR_DEST_OUT;
- case SWFDEC_BLEND_MODE_MULTIPLY:
- case SWFDEC_BLEND_MODE_SCREEN:
- case SWFDEC_BLEND_MODE_LIGHTEN:
- case SWFDEC_BLEND_MODE_DARKEN:
- case SWFDEC_BLEND_MODE_DIFFERENCE:
- case SWFDEC_BLEND_MODE_SUBTRACT:
- case SWFDEC_BLEND_MODE_INVERT:
- case SWFDEC_BLEND_MODE_OVERLAY:
- case SWFDEC_BLEND_MODE_HARDLIGHT:
- SWFDEC_WARNING ("blend mode %u unimplemented in cairo", blend_mode);
- return CAIRO_OPERATOR_OVER;
- default:
- SWFDEC_WARNING ("invalid blend mode %u", blend_mode);
- return CAIRO_OPERATOR_OVER;
- }
-}
-
-/**
- * swfdec_movie_mask:
- * @movie: The movie to act as the mask
- * @cr: a cairo context which should be used for masking. The cairo context's
- * matrix is assumed to be in the coordinate system of the movie's parent.
- * @inval: The region that is relevant for masking
- *
- * Creates a pattern suitable for masking. To do rendering using the returned
- * mask, you want to use code like this:
- * <informalexample><programlisting>
- * mask = swfdec_movie_mask (cr, movie, inval);
- * cairo_push_group (cr);
- * // do rendering here
- * cairo_pop_group_to_source (cr);
- * cairo_mask (cr, mask);
- * cairo_pattern_destroy (mask);
- * </programlisting></informalexample>
- *
- * Returns: A new cairo_patten_t to be used as the mask.
- **/
-cairo_pattern_t *
-swfdec_movie_mask (cairo_t *cr, SwfdecMovie *movie, const SwfdecRect *inval)
-{
- SwfdecColorTransform black;
-
- swfdec_color_transform_init_mask (&black);
- cairo_push_group_with_content (cr, CAIRO_CONTENT_ALPHA);
- swfdec_movie_render (movie, cr, &black, inval);
- return cairo_pop_group (cr);
-}
-
-void
-swfdec_movie_render (SwfdecMovie *movie, cairo_t *cr,
- const SwfdecColorTransform *color_transform, const SwfdecRect *inval)
-{
- SwfdecMovieClass *klass;
- SwfdecColorTransform trans;
- SwfdecRect rect;
- gboolean group;
-
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
- g_return_if_fail (cr != NULL);
- if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
- g_warning ("%s", cairo_status_to_string (cairo_status (cr)));
- }
- g_return_if_fail (color_transform != NULL);
- g_return_if_fail (inval != NULL);
-
- if (movie->mask_of != NULL && !swfdec_color_transform_is_mask (color_transform)) {
- SWFDEC_LOG ("not rendering %s %p, movie is a mask",
- G_OBJECT_TYPE_NAME (movie), movie->name);
- return;
- }
- if (!swfdec_rect_intersect (NULL, &movie->extents, inval)) {
- SWFDEC_LOG ("not rendering %s %s, extents %g %g %g %g are not in invalid area %g %g %g %g",
- G_OBJECT_TYPE_NAME (movie), movie->name,
- movie->extents.x0, movie->extents.y0, movie->extents.x1, movie->extents.y1,
- inval->x0, inval->y0, inval->x1, inval->y1);
- return;
- }
- if (!movie->visible) {
- SWFDEC_LOG ("not rendering %s %p, movie is invisible",
- G_OBJECT_TYPE_NAME (movie), movie->name);
- return;
- }
-
- cairo_save (cr);
- if (movie->masked_by != NULL) {
- cairo_push_group (cr);
- }
- group = swfdec_movie_needs_group (movie);
- if (group) {
- SWFDEC_DEBUG ("pushing group for blend mode %u", movie->blend_mode);
- cairo_push_group (cr);
- }
-
- SWFDEC_LOG ("transforming movie, transform: %g %g %g %g %g %g",
- movie->matrix.xx, movie->matrix.yy,
- movie->matrix.xy, movie->matrix.yx,
- movie->matrix.x0, movie->matrix.y0);
- cairo_transform (cr, &movie->matrix);
- swfdec_rect_transform (&rect, inval, &movie->inverse_matrix);
- SWFDEC_LOG ("%sinvalid area is now: %g %g %g %g", movie->parent ? " " : "",
- rect.x0, rect.y0, rect.x1, rect.y1);
- swfdec_color_transform_chain (&trans, &movie->original_ctrans, color_transform);
- swfdec_color_transform_chain (&trans, &movie->color_transform, &trans);
-
- klass = SWFDEC_MOVIE_GET_CLASS (movie);
- g_return_if_fail (klass->render);
- klass->render (movie, cr, &trans, &rect);
-#if 0
- /* code to draw a red rectangle around the area occupied by this movie clip */
- {
- double x = 1.0, y = 0.0;
- cairo_transform (cr, &movie->inverse_transform);
- cairo_user_to_device_distance (cr, &x, &y);
- cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
- cairo_set_line_width (cr, 1 / sqrt (x * x + y * y));
- cairo_rectangle (cr, object->extents.x0 + 10, object->extents.y0 + 10,
- object->extents.x1 - object->extents.x0 - 20,
- object->extents.y1 - object->extents.y0 - 20);
- cairo_stroke (cr);
- }
-#endif
- if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
- g_warning ("error rendering with cairo: %s", cairo_status_to_string (cairo_status (cr)));
- }
- if (group) {
- cairo_pattern_t *pattern;
-
- pattern = cairo_pop_group (cr);
- cairo_set_source (cr, pattern);
- cairo_set_operator (cr, swfdec_movie_get_operator_for_blend_mode (movie->blend_mode));
- cairo_paint (cr);
- cairo_pattern_destroy (pattern);
- }
- if (movie->masked_by) {
- cairo_pattern_t *mask;
- if (movie->parent == movie->masked_by->parent) {
- cairo_transform (cr, &movie->inverse_matrix);
- rect = *inval;
- } else {
- cairo_matrix_t mat, mat2;
- swfdec_movie_local_to_global_matrix (movie, &mat);
- swfdec_movie_global_to_local_matrix (movie->masked_by, &mat2);
- cairo_matrix_multiply (&mat, &mat2, &mat);
- cairo_transform (cr, &mat);
- if (cairo_matrix_invert (&mat) == CAIRO_STATUS_SUCCESS && FALSE) {
- swfdec_rect_transform (&rect, &rect, &mat);
- } else {
- SWFDEC_INFO ("non-invertible matrix when computing invalid area");
- rect.x0 = rect.y0 = -G_MAXDOUBLE;
- rect.x1 = rect.y1 = G_MAXDOUBLE;
- }
- }
- mask = swfdec_movie_mask (cr, movie->masked_by, &rect);
- cairo_pop_group_to_source (cr);
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
- cairo_mask (cr, mask);
- cairo_pattern_destroy (mask);
- }
- cairo_restore (cr);
-}
-
-static void
-swfdec_movie_get_property (GObject *object, guint param_id, GValue *value,
- GParamSpec * pspec)
-{
- SwfdecMovie *movie = SWFDEC_MOVIE (object);
-
- switch (param_id) {
- case PROP_DEPTH:
- g_value_set_int (value, movie->depth);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-swfdec_movie_set_property (GObject *object, guint param_id, const GValue *value,
- GParamSpec * pspec)
-{
- SwfdecMovie *movie = SWFDEC_MOVIE (object);
-
- switch (param_id) {
- case PROP_DEPTH:
- movie->depth = g_value_get_int (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-swfdec_movie_dispose (GObject *object)
-{
- SwfdecMovie * movie = SWFDEC_MOVIE (object);
- GSList *iter;
-
- g_assert (movie->list == NULL);
-
- SWFDEC_LOG ("disposing movie %s (depth %d)", movie->name, movie->depth);
- if (movie->events) {
- swfdec_event_list_free (movie->events);
- movie->events = NULL;
- }
- if (movie->graphic) {
- g_object_unref (movie->graphic);
- movie->graphic = NULL;
- }
- for (iter = movie->variable_listeners; iter != NULL; iter = iter->next) {
- g_free (iter->data);
- }
- g_slist_free (movie->variable_listeners);
- movie->variable_listeners = NULL;
-
- if (movie->image) {
- g_object_unref (movie->image);
- movie->image = NULL;
- }
- g_slist_foreach (movie->draws, (GFunc) g_object_unref, NULL);
- g_slist_free (movie->draws);
- movie->draws = NULL;
-
- G_OBJECT_CLASS (swfdec_movie_parent_class)->dispose (G_OBJECT (movie));
-}
-
-static void
-swfdec_movie_mark (SwfdecAsObject *object)
-{
- SwfdecMovie *movie = SWFDEC_MOVIE (object);
- GList *walk;
- GSList *iter;
-
- if (movie->parent)
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (movie->parent));
- swfdec_as_string_mark (movie->original_name);
- swfdec_as_string_mark (movie->name);
- for (walk = movie->list; walk; walk = walk->next) {
- swfdec_as_object_mark (walk->data);
- }
- for (iter = movie->variable_listeners; iter != NULL; iter = iter->next) {
- SwfdecMovieVariableListener *listener = iter->data;
- swfdec_as_object_mark (listener->object);
- swfdec_as_string_mark (listener->name);
- }
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (movie->resource));
-
- SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->mark (object);
-}
-
-/* FIXME: This function can definitely be implemented easier */
-SwfdecMovie *
-swfdec_movie_get_by_name (SwfdecMovie *movie, const char *name, gboolean unnamed)
-{
- GList *walk;
- int i;
- gulong l;
- guint version = SWFDEC_AS_OBJECT (movie)->context->version;
- char *end;
- SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
-
- if ((version >= 7 && g_str_has_prefix (name, "_level")) ||
- (version < 7 && strncasecmp (name, "_level", 6) == 0)) {
- errno = 0;
- l = strtoul (name + 6, &end, 10);
- if (errno != 0 || *end != 0 || l > G_MAXINT)
- return NULL;
- i = l - 16384;
- for (walk = player->priv->roots; walk; walk = walk->next) {
- SwfdecMovie *cur = walk->data;
- if (cur->depth < i)
- continue;
- if (cur->depth == i)
- return cur;
- break;
- }
- }
-
- for (walk = movie->list; walk; walk = walk->next) {
- SwfdecMovie *cur = walk->data;
- if (cur->original_name == SWFDEC_AS_STR_EMPTY && !unnamed)
- continue;
- if (swfdec_strcmp (version, cur->name, name) == 0)
- return cur;
- }
- return NULL;
-}
-
-SwfdecMovie *
-swfdec_movie_get_root (SwfdecMovie *movie)
-{
- g_return_val_if_fail (SWFDEC_IS_MOVIE (movie), NULL);
-
- while (movie->parent)
- movie = movie->parent;
-
- return movie;
-}
-
-static gboolean
-swfdec_movie_get_variable (SwfdecAsObject *object, SwfdecAsObject *orig,
- const char *variable, SwfdecAsValue *val, guint *flags)
-{
- SwfdecMovie *movie = SWFDEC_MOVIE (object);
-
- movie = swfdec_movie_resolve (movie);
- if (movie == NULL)
- return FALSE;
-
- if (SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->get (object, orig, variable, val, flags))
- return TRUE;
-
- if (swfdec_movie_get_asprop (movie, variable, val)) {
- *flags = 0;
- return TRUE;
- }
-
- /* FIXME: check that this is correct */
- if (object->context->version > 5 && variable == SWFDEC_AS_STR__global) {
- SWFDEC_AS_VALUE_SET_OBJECT (val, object->context->global);
- *flags = 0;
- return TRUE;
- }
-
- movie = swfdec_movie_get_by_name (movie, variable, FALSE);
- if (movie) {
- SWFDEC_AS_VALUE_SET_OBJECT (val, SWFDEC_AS_OBJECT (movie));
- *flags = 0;
- return TRUE;
- }
- return FALSE;
-}
-
-void
-swfdec_movie_add_variable_listener (SwfdecMovie *movie, SwfdecAsObject *object,
- const char *name, const SwfdecMovieVariableListenerFunction function)
-{
- SwfdecMovieVariableListener *listener;
- GSList *iter;
-
- for (iter = movie->variable_listeners; iter != NULL; iter = iter->next) {
- listener = iter->data;
-
- if (listener->object == object && listener->name == name &&
- listener->function == function)
- break;
- }
- if (iter != NULL)
- return;
-
- listener = g_new0 (SwfdecMovieVariableListener, 1);
- listener->object = object;
- listener->name = name;
- listener->function = function;
-
- movie->variable_listeners = g_slist_prepend (movie->variable_listeners,
- listener);
-}
-
-void
-swfdec_movie_remove_variable_listener (SwfdecMovie *movie,
- SwfdecAsObject *object, const char *name,
- const SwfdecMovieVariableListenerFunction function)
-{
- GSList *iter;
-
- for (iter = movie->variable_listeners; iter != NULL; iter = iter->next) {
- SwfdecMovieVariableListener *listener = iter->data;
-
- if (listener->object == object && listener->name == name &&
- listener->function == function)
- break;
- }
- if (iter == NULL)
- return;
-
- g_free (iter->data);
- movie->variable_listeners =
- g_slist_remove (movie->variable_listeners, iter->data);
-}
-
-static void
-swfdec_movie_call_variable_listeners (SwfdecMovie *movie, const char *name,
- const SwfdecAsValue *val)
-{
- GSList *iter;
-
- for (iter = movie->variable_listeners; iter != NULL; iter = iter->next) {
- SwfdecMovieVariableListener *listener = iter->data;
-
- if (listener->name != name &&
- (SWFDEC_AS_OBJECT (movie)->context->version >= 7 ||
- !swfdec_str_case_equal (listener->name, name)))
- continue;
-
- listener->function (listener->object, name, val);
- }
-}
-
-static void
-swfdec_movie_set_variable (SwfdecAsObject *object, const char *variable,
- const SwfdecAsValue *val, guint flags)
-{
- SwfdecMovie *movie = SWFDEC_MOVIE (object);
-
- movie = swfdec_movie_resolve (movie);
- if (movie == NULL)
- return;
-
- if (swfdec_movie_set_asprop (movie, variable, val))
- return;
-
- swfdec_movie_call_variable_listeners (movie, variable, val);
-
- SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->set (object, variable, val, flags);
-}
-
-static gboolean
-swfdec_movie_foreach_variable (SwfdecAsObject *object, SwfdecAsVariableForeach func, gpointer data)
-{
- SwfdecMovie *movie = SWFDEC_MOVIE (object);
- SwfdecAsValue val;
- GList *walk;
- gboolean ret;
-
- ret = SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->foreach (object, func, data);
-
- for (walk = movie->list; walk && ret; walk = walk->next) {
- SwfdecMovie *cur = walk->data;
- if (cur->original_name == SWFDEC_AS_STR_EMPTY)
- continue;
- SWFDEC_AS_VALUE_SET_OBJECT (&val, walk->data);
- ret &= func (object, cur->name, &val, 0, data);
- }
-
- return ret;
-}
-
-static char *
-swfdec_movie_get_debug (SwfdecAsObject *object)
-{
- SwfdecMovie *movie = SWFDEC_MOVIE (object);
-
- return swfdec_movie_get_path (movie, TRUE);
-}
-
-static gboolean
-swfdec_movie_iterate_end (SwfdecMovie *movie)
-{
- return movie->parent == NULL ||
- movie->state < SWFDEC_MOVIE_STATE_REMOVED;
-}
-
-typedef struct {
- SwfdecMovie * movie;
- int depth;
-} ClipEntry;
-
-static void
-swfdec_movie_do_render (SwfdecMovie *movie, cairo_t *cr,
- const SwfdecColorTransform *ctrans, const SwfdecRect *inval)
-{
- GList *g;
- GSList *walk;
- GSList *clips = NULL;
- ClipEntry *clip = NULL;
-
- /* exeute the movie's drawing commands */
- for (walk = movie->draws; walk; walk = walk->next) {
- SwfdecDraw *draw = walk->data;
-
- if (!swfdec_rect_intersect (NULL, &draw->extents, inval))
- continue;
-
- swfdec_draw_paint (draw, cr, ctrans);
- }
-
- /* if the movie loaded an image, draw it here now */
- if (movie->image) {
- cairo_surface_t *surface = swfdec_image_create_surface_transformed (movie->image,
- ctrans);
- if (surface) {
- static const cairo_matrix_t matrix = { 1.0 / SWFDEC_TWIPS_SCALE_FACTOR, 0, 0, 1.0 / SWFDEC_TWIPS_SCALE_FACTOR, 0, 0 };
- cairo_pattern_t *pattern = cairo_pattern_create_for_surface (surface);
- SWFDEC_LOG ("rendering loaded image");
- cairo_pattern_set_matrix (pattern, &matrix);
- cairo_set_source (cr, pattern);
- cairo_paint (cr);
- cairo_pattern_destroy (pattern);
- cairo_surface_destroy (surface);
- }
- }
-
- /* draw the children movies */
- for (g = movie->list; g; g = g_list_next (g)) {
- SwfdecMovie *child = g->data;
-
- while (clip && clip->depth < child->depth) {
- cairo_pattern_t *mask;
- SWFDEC_INFO ("unsetting clip depth %d for depth %d", clip->depth, child->depth);
- mask = swfdec_movie_mask (cr, clip->movie, inval);
- cairo_pop_group_to_source (cr);
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
- cairo_mask (cr, mask);
- cairo_pattern_destroy (mask);
- g_slice_free (ClipEntry, clip);
- clips = g_slist_delete_link (clips, clips);
- clip = clips ? clips->data : NULL;
- }
-
- if (child->clip_depth) {
- clip = g_slice_new (ClipEntry);
- clips = g_slist_prepend (clips, clip);
- clip->movie = child;
- clip->depth = child->clip_depth;
- SWFDEC_INFO ("clipping up to depth %d by using %s with depth %d", child->clip_depth,
- child->name, child->depth);
- cairo_push_group (cr);
- continue;
- }
-
- SWFDEC_LOG ("rendering %p with depth %d", child, child->depth);
- swfdec_movie_render (child, cr, ctrans, inval);
- }
- while (clip) {
- cairo_pattern_t *mask;
- SWFDEC_INFO ("unsetting clip depth %d", clip->depth);
- mask = swfdec_movie_mask (cr, clip->movie, inval);
- cairo_pop_group_to_source (cr);
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
- cairo_mask (cr, mask);
- cairo_pattern_destroy (mask);
- g_slice_free (ClipEntry, clip);
- clips = g_slist_delete_link (clips, clips);
- clip = clips ? clips->data : NULL;
- }
- g_assert (clips == NULL);
-}
-
-static gboolean
-swfdec_movie_mouse_events (SwfdecMovie *movie)
-{
- SwfdecAsObject *object;
-
- /* root movies don't get event */
- if (movie->parent == NULL)
- return FALSE;
- /* look if we have a script that gets events */
- if (movie->events && swfdec_event_list_has_mouse_events (movie->events))
- return TRUE;
- /* otherwise, require at least one of the custom script handlers */
- object = SWFDEC_AS_OBJECT (movie);
- if (swfdec_as_object_has_variable (object, SWFDEC_AS_STR_onRollOver) ||
- swfdec_as_object_has_variable (object, SWFDEC_AS_STR_onRollOut) ||
- swfdec_as_object_has_variable (object, SWFDEC_AS_STR_onDragOver) ||
- swfdec_as_object_has_variable (object, SWFDEC_AS_STR_onDragOut) ||
- swfdec_as_object_has_variable (object, SWFDEC_AS_STR_onPress) ||
- swfdec_as_object_has_variable (object, SWFDEC_AS_STR_onRelease) ||
- swfdec_as_object_has_variable (object, SWFDEC_AS_STR_onReleaseOutside))
- return TRUE;
- return FALSE;
-}
-
-static void
-swfdec_movie_mouse_in (SwfdecMovie *movie)
-{
- if (swfdec_player_is_mouse_pressed (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context)))
- swfdec_movie_queue_script (movie, SWFDEC_EVENT_DRAG_OVER);
- else
- swfdec_movie_queue_script (movie, SWFDEC_EVENT_ROLL_OVER);
-}
-
-static void
-swfdec_movie_mouse_out (SwfdecMovie *movie)
-{
- if (swfdec_player_is_mouse_pressed (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context)))
- swfdec_movie_queue_script (movie, SWFDEC_EVENT_DRAG_OUT);
- else
- swfdec_movie_queue_script (movie, SWFDEC_EVENT_ROLL_OUT);
-}
-
-static void
-swfdec_movie_mouse_press (SwfdecMovie *movie, guint button)
-{
- if (button != 0)
- return;
- swfdec_movie_queue_script (movie, SWFDEC_EVENT_PRESS);
-}
-
-static void
-swfdec_movie_mouse_release (SwfdecMovie *movie, guint button)
-{
- SwfdecPlayer *player;
-
- if (button != 0)
- return;
-
- player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
- if (player->priv->mouse_below == movie)
- swfdec_movie_queue_script (movie, SWFDEC_EVENT_RELEASE);
- else
- swfdec_movie_queue_script (movie, SWFDEC_EVENT_RELEASE_OUTSIDE);
-}
-
-static void
-swfdec_movie_mouse_move (SwfdecMovie *movie, double x, double y)
-{
- /* nothing to do here, it's just there so we don't need to check for NULL */
-}
-
-static void
-swfdec_movie_do_invalidate (SwfdecMovie *movie, const cairo_matrix_t *matrix, gboolean last)
-{
- GList *walk;
- SwfdecRect rect;
-
- if (movie->image) {
- rect.x0 = rect.y0 = 0;
- rect.x1 = movie->image->width * SWFDEC_TWIPS_SCALE_FACTOR;
- rect.y1 = movie->image->height * SWFDEC_TWIPS_SCALE_FACTOR;
- } else {
- swfdec_rect_init_empty (&rect);
- }
- swfdec_rect_union (&rect, &rect, &movie->draw_extents);
- swfdec_rect_transform (&rect, &rect, matrix);
- swfdec_player_invalidate (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), &rect);
-
- for (walk = movie->list; walk; walk = walk->next) {
- swfdec_movie_invalidate (walk->data, matrix, last);
- }
-}
-
-static void
-swfdec_movie_class_init (SwfdecMovieClass * movie_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (movie_class);
- SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (movie_class);
-
- object_class->dispose = swfdec_movie_dispose;
- object_class->get_property = swfdec_movie_get_property;
- object_class->set_property = swfdec_movie_set_property;
-
- asobject_class->mark = swfdec_movie_mark;
- asobject_class->get = swfdec_movie_get_variable;
- asobject_class->set = swfdec_movie_set_variable;
- asobject_class->foreach = swfdec_movie_foreach_variable;
- asobject_class->debug = swfdec_movie_get_debug;
-
- g_object_class_install_property (object_class, PROP_DEPTH,
- g_param_spec_int ("depth", "depth", "z order inside the parent",
- G_MININT, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- movie_class->render = swfdec_movie_do_render;
- movie_class->invalidate = swfdec_movie_do_invalidate;
- movie_class->contains = swfdec_movie_do_contains;
- movie_class->iterate_end = swfdec_movie_iterate_end;
- movie_class->mouse_events = swfdec_movie_mouse_events;
- movie_class->mouse_in = swfdec_movie_mouse_in;
- movie_class->mouse_out = swfdec_movie_mouse_out;
- movie_class->mouse_press = swfdec_movie_mouse_press;
- movie_class->mouse_release = swfdec_movie_mouse_release;
- movie_class->mouse_move = swfdec_movie_mouse_move;
-}
-
-void
-swfdec_movie_initialize (SwfdecMovie *movie)
-{
- SwfdecMovieClass *klass;
-
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
-
- klass = SWFDEC_MOVIE_GET_CLASS (movie);
- if (klass->init_movie)
- klass->init_movie (movie);
-}
-
-void
-swfdec_movie_set_depth (SwfdecMovie *movie, int depth)
-{
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
-
- if (movie->depth == depth)
- return;
-
- swfdec_movie_invalidate_last (movie);
- movie->depth = depth;
- if (movie->parent) {
- movie->parent->list = g_list_sort (movie->parent->list, swfdec_movie_compare_depths);
- } else {
- SwfdecPlayerPrivate *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context)->priv;
- player->roots = g_list_sort (player->roots, swfdec_movie_compare_depths);
- }
- g_object_notify (G_OBJECT (movie), "depth");
-}
-
-static void
-swfdec_movie_set_version (SwfdecMovie *movie)
-{
- SwfdecAsObject *o;
- SwfdecAsContext *cx;
- SwfdecAsValue val;
-
- if (movie->parent != NULL)
- return;
-
- o = SWFDEC_AS_OBJECT (movie);
- cx = o->context;
- SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_get_string (cx, SWFDEC_PLAYER (cx)->priv->system->version));
- swfdec_as_object_set_variable (o, SWFDEC_AS_STR_$version, &val);
-}
-
-/**
- * swfdec_movie_new:
- * @player: a #SwfdecPlayer
- * @depth: depth of movie
- * @parent: the parent movie or %NULL to make this a root movie
- * @resource: the resource that is responsible for this movie
- * @graphic: the graphic that is displayed by this movie or %NULL to create an
- * empty movieclip
- * @name: a garbage-collected string to be used as the name for this movie or
- * %NULL for a default one.
- *
- * Creates a new movie #SwfdecMovie for the given properties. No movie may exist
- * at the given @depth. The actual type of
- * this movie depends on the @graphic parameter. The movie will be initialized
- * with default properties. No script execution will be scheduled. After all
- * properties are set, the new-movie signal will be emitted if @player is a
- * debugger.
- *
- * Returns: a new #SwfdecMovie
- **/
-SwfdecMovie *
-swfdec_movie_new (SwfdecPlayer *player, int depth, SwfdecMovie *parent, SwfdecResource *resource,
- SwfdecGraphic *graphic, const char *name)
-{
- SwfdecMovie *movie;
- gsize size;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (parent == NULL || SWFDEC_IS_MOVIE (parent), NULL);
- g_return_val_if_fail (SWFDEC_IS_RESOURCE (resource), NULL);
- g_return_val_if_fail (graphic == NULL || SWFDEC_IS_GRAPHIC (graphic), NULL);
-
- /* create the right movie */
- if (graphic == NULL) {
- movie = g_object_new (SWFDEC_TYPE_SPRITE_MOVIE, "depth", depth, NULL);
- size = sizeof (SwfdecSpriteMovie);
- } else {
- SwfdecGraphicClass *klass = SWFDEC_GRAPHIC_GET_CLASS (graphic);
- g_return_val_if_fail (klass->create_movie != NULL, NULL);
- movie = klass->create_movie (graphic, &size);
- movie->graphic = g_object_ref (graphic);
- movie->depth = depth;
- }
- /* register it to the VM */
- /* FIXME: It'd be nice if we'd not overuse memory here when calling this function from a script */
- if (!swfdec_as_context_use_mem (SWFDEC_AS_CONTEXT (player), size)) {
- size = 0;
- }
- g_object_ref (movie);
- /* set essential properties */
- movie->parent = parent;
- movie->resource = resource;
- if (parent) {
- parent->list = g_list_insert_sorted (parent->list, movie, swfdec_movie_compare_depths);
- SWFDEC_DEBUG ("inserting %s %s (depth %d) into %s %p", G_OBJECT_TYPE_NAME (movie), movie->name,
- movie->depth, G_OBJECT_TYPE_NAME (parent), parent);
- /* invalidate the parent, so it gets visible */
- swfdec_movie_queue_update (parent, SWFDEC_MOVIE_INVALID_CHILDREN);
- } else {
- player->priv->roots = g_list_insert_sorted (player->priv->roots, movie, swfdec_movie_compare_depths);
- }
- /* set its name */
- if (name) {
- movie->original_name = name;
- movie->name = name;
- } else {
- movie->original_name = SWFDEC_AS_STR_EMPTY;
- if (SWFDEC_IS_SPRITE_MOVIE (movie) || SWFDEC_IS_BUTTON_MOVIE (movie)) {
- movie->name = swfdec_as_context_give_string (SWFDEC_AS_CONTEXT (player),
- g_strdup_printf ("instance%u", ++player->priv->unnamed_count));
- } else {
- movie->name = SWFDEC_AS_STR_EMPTY;
- }
- }
- /* add the movie to the global movies list */
- /* NB: adding to the movies list happens before setting the parent.
- * Setting the parent does a gotoAndPlay(0) for Sprites which can cause
- * new movies to be created (and added to this list)
- */
- player->priv->movies = g_list_prepend (player->priv->movies, movie);
- /* only add the movie here, because it needs to be setup for the debugger */
- swfdec_as_object_add (SWFDEC_AS_OBJECT (movie), SWFDEC_AS_CONTEXT (player), size);
- swfdec_movie_set_version (movie);
- /* only setup here, the resource assumes it can access the player via the movie */
- if (resource->movie == NULL) {
- g_assert (SWFDEC_IS_SPRITE_MOVIE (movie));
- resource->movie = SWFDEC_SPRITE_MOVIE (movie);
- }
-
- return movie;
-}
-
-/* FIXME: since this is only used in PlaceObject, wouldn't it be easier to just have
- * swfdec_movie_update_static_properties (movie); that's notified when any of these change
- * and let PlaceObject modify the movie directly?
- */
-void
-swfdec_movie_set_static_properties (SwfdecMovie *movie, const cairo_matrix_t *transform,
- const SwfdecColorTransform *ctrans, int ratio, int clip_depth, guint blend_mode,
- SwfdecEventList *events)
-{
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
- g_return_if_fail (clip_depth >= -16384 || clip_depth <= 0);
- g_return_if_fail (ratio >= -1);
-
- if (movie->modified) {
- SWFDEC_LOG ("%s has already been modified by scripts, ignoring updates", movie->name);
- return;
- }
- if (transform) {
- swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
- movie->original_transform = *transform;
- movie->matrix.x0 = movie->original_transform.x0;
- movie->matrix.y0 = movie->original_transform.y0;
- movie->xscale = swfdec_matrix_get_xscale (&movie->original_transform);
- movie->yscale = swfdec_matrix_get_yscale (&movie->original_transform);
- movie->rotation = swfdec_matrix_get_rotation (&movie->original_transform);
- }
- if (ctrans) {
- swfdec_movie_invalidate_last (movie);
- movie->original_ctrans = *ctrans;
- }
- if (ratio >= 0 && (guint) ratio != movie->original_ratio) {
- SwfdecMovieClass *klass;
- movie->original_ratio = ratio;
- klass = SWFDEC_MOVIE_GET_CLASS (movie);
- if (klass->set_ratio)
- klass->set_ratio (movie);
- }
- if (clip_depth && clip_depth != movie->clip_depth) {
- movie->clip_depth = clip_depth;
- /* FIXME: is this correct? */
- swfdec_movie_invalidate_last (movie->parent ? movie->parent : movie);
- }
- if (blend_mode != movie->blend_mode) {
- movie->blend_mode = blend_mode;
- swfdec_movie_invalidate_last (movie);
- }
- if (events) {
- if (SWFDEC_IS_SPRITE_MOVIE (movie)) {
- if (movie->events)
- swfdec_event_list_free (movie->events);
- movie->events = swfdec_event_list_copy (events);
- } else {
- SWFDEC_WARNING ("trying to set events on a %s, not allowed", G_OBJECT_TYPE_NAME (movie));
- }
- }
-}
-
-/**
- * swfdec_movie_duplicate:
- * @movie: #SwfdecMovie to copy
- * @name: garbage-collected name for the new copy
- * @depth: depth to put this movie in
- *
- * Creates a duplicate of @movie. The duplicate will not be initialized or
- * queued up for any events. You have to do this manually. In particular calling
- * swfdec_movie_initialize() on the returned movie must be done.
- * This function must be called from within a script.
- *
- * Returns: a newly created movie or %NULL on error
- **/
-SwfdecMovie *
-swfdec_movie_duplicate (SwfdecMovie *movie, const char *name, int depth)
-{
- SwfdecMovie *parent, *copy;
- SwfdecSandbox *sandbox;
-
- g_return_val_if_fail (SWFDEC_IS_MOVIE (movie), NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- parent = movie->parent;
- if (movie->parent == NULL) {
- SWFDEC_FIXME ("don't know how to duplicate root movies");
- return NULL;
- }
- copy = swfdec_movie_find (movie->parent, depth);
- if (copy) {
- SWFDEC_LOG ("depth %d already occupied while duplicating, removing old movie", depth);
- swfdec_movie_remove (copy);
- }
- copy = swfdec_movie_new (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), depth,
- parent, movie->resource, movie->graphic, name);
- if (copy == NULL)
- return NULL;
- swfdec_movie_set_static_properties (copy, &movie->original_transform,
- &movie->original_ctrans, movie->original_ratio, movie->clip_depth,
- movie->blend_mode, movie->events);
- sandbox = SWFDEC_SANDBOX (SWFDEC_AS_OBJECT (movie)->context->global);
- swfdec_sandbox_unuse (sandbox);
- if (SWFDEC_IS_SPRITE_MOVIE (copy)) {
- swfdec_movie_queue_script (copy, SWFDEC_EVENT_INITIALIZE);
- swfdec_movie_queue_script (copy, SWFDEC_EVENT_LOAD);
- swfdec_movie_execute (copy, SWFDEC_EVENT_CONSTRUCT);
- }
- swfdec_movie_initialize (copy);
- swfdec_sandbox_use (sandbox);
- return copy;
-}
-
-char *
-swfdec_movie_get_path (SwfdecMovie *movie, gboolean dot)
-{
- GString *s;
-
- g_return_val_if_fail (SWFDEC_IS_MOVIE (movie), NULL);
-
- s = g_string_new ("");
- do {
- if (movie->parent) {
- g_string_prepend (s, movie->name);
- g_string_prepend_c (s, (dot ? '.' : '/'));
- } else {
- char *ret;
- if (dot) {
- ret = g_strdup_printf ("_level%u%s", movie->depth + 16384, s->str);
- g_string_free (s, TRUE);
- } else {
- if (s->str[0] != '/')
- g_string_prepend_c (s, '/');
- ret = g_string_free (s, FALSE);
- }
- return ret;
- }
- movie = movie->parent;
- } while (TRUE);
-
- g_assert_not_reached ();
-
- return NULL;
-}
-
-int
-swfdec_movie_compare_depths (gconstpointer a, gconstpointer b)
-{
- if (SWFDEC_MOVIE (a)->depth < SWFDEC_MOVIE (b)->depth)
- return -1;
- if (SWFDEC_MOVIE (a)->depth > SWFDEC_MOVIE (b)->depth)
- return 1;
- return 0;
-}
-
-/**
- * swfdec_depth_classify:
- * @depth: the depth to classify
- *
- * Classifies a depth. This classification is mostly used when deciding if
- * certain operations are valid in ActionScript.
- *
- * Returns: the classification of the depth.
- **/
-SwfdecDepthClass
-swfdec_depth_classify (int depth)
-{
- if (depth < -16384)
- return SWFDEC_DEPTH_CLASS_EMPTY;
- if (depth < 0)
- return SWFDEC_DEPTH_CLASS_TIMELINE;
- if (depth < 1048576)
- return SWFDEC_DEPTH_CLASS_DYNAMIC;
- if (depth < 2130690046)
- return SWFDEC_DEPTH_CLASS_RESERVED;
- return SWFDEC_DEPTH_CLASS_EMPTY;
-}
-
-/**
- * swfdec_movie_get_own_resource:
- * @movie: movie to query
- *
- * Queries the movie for his own resource. A movie only has its own resource if
- * it contains data loaded with the loadMovie() function, or if it is the root
- * movie.
- *
- * Returns: The own resource of @movie or %NULL
- **/
-SwfdecResource *
-swfdec_movie_get_own_resource (SwfdecMovie *movie)
-{
- g_return_val_if_fail (SWFDEC_IS_MOVIE (movie), NULL);
-
- if (!SWFDEC_IS_SPRITE_MOVIE (movie))
- return NULL;
-
- if (SWFDEC_MOVIE (movie->resource->movie) != movie)
- return NULL;
-
- return movie->resource;
-}
-
diff --git a/libswfdec/swfdec_movie.h b/libswfdec/swfdec_movie.h
deleted file mode 100644
index 623707f..0000000
--- a/libswfdec/swfdec_movie.h
+++ /dev/null
@@ -1,306 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_MOVIE_H_
-#define _SWFDEC_MOVIE_H_
-
-#include <glib-object.h>
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_color.h>
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_event.h>
-#include <libswfdec/swfdec_rect.h>
-#include <libswfdec/swfdec_types.h>
-
-G_BEGIN_DECLS
-
-
-typedef struct _SwfdecMovieClass SwfdecMovieClass;
-
-/* descriptions taken from http://www.kirupa.com/developer/actionscript/depths2.htm */
-typedef enum {
- SWFDEC_DEPTH_CLASS_EMPTY,
- SWFDEC_DEPTH_CLASS_TIMELINE,
- SWFDEC_DEPTH_CLASS_DYNAMIC,
- SWFDEC_DEPTH_CLASS_RESERVED
-} SwfdecDepthClass;
-
-typedef enum {
- SWFDEC_MOVIE_STATE_RUNNING = 0, /* the movie has been created */
- SWFDEC_MOVIE_STATE_REMOVED, /* swfdec_movie_remove has been called */
- SWFDEC_MOVIE_STATE_DESTROYED /* swfdec_movie_destroy has been called */
-} SwfdecMovieState;
-
-#define SWFDEC_BLEND_MODE_NORMAL 1
-#define SWFDEC_BLEND_MODE_LAYER 2
-#define SWFDEC_BLEND_MODE_MULTIPLY 3
-#define SWFDEC_BLEND_MODE_SCREEN 4
-#define SWFDEC_BLEND_MODE_LIGHTEN 5
-#define SWFDEC_BLEND_MODE_DARKEN 6
-#define SWFDEC_BLEND_MODE_DIFFERENCE 7
-#define SWFDEC_BLEND_MODE_ADD 8
-#define SWFDEC_BLEND_MODE_SUBTRACT 9
-#define SWFDEC_BLEND_MODE_INVERT 10
-#define SWFDEC_BLEND_MODE_ALPHA 11
-#define SWFDEC_BLEND_MODE_ERASE 12
-#define SWFDEC_BLEND_MODE_OVERLAY 13
-#define SWFDEC_BLEND_MODE_HARDLIGHT 14
-
-#define SWFDEC_TYPE_MOVIE (swfdec_movie_get_type())
-#define SWFDEC_IS_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_MOVIE))
-#define SWFDEC_IS_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_MOVIE))
-#define SWFDEC_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_MOVIE, SwfdecMovie))
-#define SWFDEC_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_MOVIE, SwfdecMovieClass))
-#define SWFDEC_MOVIE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_MOVIE, SwfdecMovieClass))
-
-/* NB: each following state includes the previous */
-typedef enum {
- SWFDEC_MOVIE_UP_TO_DATE = 0, /* everything OK */
- SWFDEC_MOVIE_INVALID_CHILDREN, /* call update on children */
- SWFDEC_MOVIE_INVALID_EXTENTS, /* recalculate extents */
- SWFDEC_MOVIE_INVALID_MATRIX /* matrix is invalid, recalculate */
-} SwfdecMovieCacheState;
-
-typedef void (*SwfdecMovieVariableListenerFunction) (SwfdecAsObject *object,
- const char *name, const SwfdecAsValue *val);
-
-typedef struct {
- SwfdecAsObject * object;
- const char * name;
- SwfdecMovieVariableListenerFunction function;
-} SwfdecMovieVariableListener;
-
-struct _SwfdecMovie {
- SwfdecAsObject object;
-
- SwfdecGraphic * graphic; /* graphic represented by this movie or NULL if script-created */
- const char * name; /* name of movie - GC'd */
- GList * list; /* our contained movie clips (ordered by depth) */
- int depth; /* depth of movie (equals content->depth unless explicitly set) */
- SwfdecMovieCacheState cache_state; /* whether we are up to date */
- SwfdecMovieState state; /* state the movie is in */
- GSList *variable_listeners; /* textfield's listening to changes in variables - SwfdecMovieVariableListener */
-
- /* static properties (set by PlaceObject tags) */
- const char * original_name; /* the original name - GC'd and static */
- SwfdecColorTransform original_ctrans; /* color transform set on this movie */
- cairo_matrix_t original_transform; /* initial transform used */
- guint original_ratio; /* ratio used in this movie */
- int clip_depth; /* up to which movie this movie clips */
- SwfdecEventList * events; /* events queued on this movie */
-
- /* parenting information */
- SwfdecMovie * parent; /* movie that contains us or NULL for root movies */
- SwfdecResource * resource; /* the resource that created us */
-
- /* positioning - the values are applied in this order */
- SwfdecRect extents; /* the extents occupied after transform is applied */
- SwfdecRect original_extents; /* the extents from all children - unmodified */
- gboolean modified; /* TRUE if the transform has been modified by scripts */
- double xscale; /* x scale in percent */
- double yscale; /* y scale in percent */
- double rotation; /* rotation in degrees [-180, 180] */
- cairo_matrix_t matrix; /* cairo matrix computed from above and content->transform */
- cairo_matrix_t inverse_matrix; /* the inverse of the cairo matrix */
- SwfdecColorTransform color_transform; /* scripted color transformation */
- guint blend_mode; /* blend mode to use - see to-cairo conversion code for what they mean */
-
- /* iteration state */
- gboolean visible; /* whether we currently can be seen or iterate */
-
- /* drawing state */
- SwfdecMovie * mask_of; /* movie this movie is a mask of or NULL if none */
- SwfdecMovie * masked_by; /* movie we are masked by or NULL if none */
- /* FIXME: could it be that shape drawing (SwfdecGraphicMovie etc) uses these same objects? */
- SwfdecImage * image; /* image loaded via loadMovie */
- SwfdecRect draw_extents; /* extents of the items in the following list */
- GSList * draws; /* all the items to draw */
- SwfdecDraw * draw_fill; /* current fill style or NULL */
- SwfdecDraw * draw_line; /* current line style or NULL */
- int draw_x; /* current x position for drawing */
- int draw_y; /* current y position for drawing */
-
- /* invalidatation state */
- gboolean invalidate_last; /* TRUE if this movie's previous contents are already invalidated */
- gboolean invalidate_next; /* TRUE if this movie should be invalidated before unlocking */
-
- /* leftover unimplemented variables from the Actionscript spec */
-#if 0
- int droptarget;
-#endif
-};
-
-struct _SwfdecMovieClass {
- SwfdecAsObjectClass object_class;
-
- /* general vfuncs */
- void (* init_movie) (SwfdecMovie * movie);
- void (* finish_movie) (SwfdecMovie * movie);
- void (* replace) (SwfdecMovie * movie,
- SwfdecGraphic * graphic);
- void (* set_ratio) (SwfdecMovie * movie);
- void (* update_extents) (SwfdecMovie * movie,
- SwfdecRect * extents);
- void (* render) (SwfdecMovie * movie,
- cairo_t * cr,
- const SwfdecColorTransform *trans,
- const SwfdecRect * inval);
- void (* invalidate) (SwfdecMovie * movie,
- const cairo_matrix_t * movie_to_global,
- gboolean new_contents);
-
- SwfdecMovie * (* contains) (SwfdecMovie * movie,
- double x,
- double y,
- gboolean events);
- /* mouse handling */
- gboolean (* mouse_events) (SwfdecMovie * movie);
- SwfdecMouseCursor (* mouse_cursor) (SwfdecMovie * movie);
- void (* mouse_in) (SwfdecMovie * movie);
- void (* mouse_out) (SwfdecMovie * movie);
- void (* mouse_press) (SwfdecMovie * movie,
- guint button);
- void (* mouse_release) (SwfdecMovie * movie,
- guint button);
- void (* mouse_move) (SwfdecMovie * movie,
- double x,
- double y);
- /* keyboard handling */
- void (* focus_in) (SwfdecMovie * movie,
- SwfdecMovie * previous);
- void (* focus_out) (SwfdecMovie * movie,
- SwfdecMovie * next);
- void (* key_pressed) (SwfdecMovie * movie,
- guint keycode,
- guint character);
- void (* key_released) (SwfdecMovie * movie,
- guint keycode,
- guint character);
-
- /* iterating */
- void (* iterate_start) (SwfdecMovie * movie);
- gboolean (* iterate_end) (SwfdecMovie * movie);
-};
-
-GType swfdec_movie_get_type (void);
-
-SwfdecMovie * swfdec_movie_new (SwfdecPlayer * player,
- int depth,
- SwfdecMovie * parent,
- SwfdecResource * resource,
- SwfdecGraphic * graphic,
- const char * name);
-SwfdecMovie * swfdec_movie_duplicate (SwfdecMovie * movie,
- const char * name,
- int depth);
-void swfdec_movie_initialize (SwfdecMovie * movie);
-SwfdecMovie * swfdec_movie_find (SwfdecMovie * movie,
- int depth);
-SwfdecMovie * swfdec_movie_get_by_name (SwfdecMovie * movie,
- const char * name,
- gboolean unnamed);
-SwfdecMovie * swfdec_movie_get_root (SwfdecMovie * movie);
-void swfdec_movie_remove (SwfdecMovie * movie);
-void swfdec_movie_destroy (SwfdecMovie * movie);
-void swfdec_movie_set_static_properties
- (SwfdecMovie * movie,
- const cairo_matrix_t * transform,
- const SwfdecColorTransform *ctrans,
- int ratio,
- int clip_depth,
- guint blend_mode,
- SwfdecEventList * events);
-void swfdec_movie_invalidate_last (SwfdecMovie * movie);
-void swfdec_movie_invalidate_next (SwfdecMovie * movie);
-void swfdec_movie_invalidate (SwfdecMovie * movie,
- const cairo_matrix_t * parent_to_global,
- gboolean last);
-void swfdec_movie_queue_update (SwfdecMovie * movie,
- SwfdecMovieCacheState state);
-void swfdec_movie_update (SwfdecMovie * movie);
-void swfdec_movie_local_to_global (SwfdecMovie * movie,
- double * x,
- double * y);
-void swfdec_movie_global_to_local (SwfdecMovie * movie,
- double * x,
- double * y);
-void swfdec_movie_global_to_local_matrix
- (SwfdecMovie * movie,
- cairo_matrix_t * matrix);
-void swfdec_movie_local_to_global_matrix
- (SwfdecMovie * movie,
- cairo_matrix_t * matrix);
-void swfdec_movie_rect_local_to_global (SwfdecMovie * movie,
- SwfdecRect * rect);
-void swfdec_movie_rect_global_to_local (SwfdecMovie * movie,
- SwfdecRect * rect);
-void swfdec_movie_set_depth (SwfdecMovie * movie,
- int depth);
-
-void swfdec_movie_get_mouse (SwfdecMovie * movie,
- double * x,
- double * y);
-gboolean swfdec_movie_get_mouse_events (SwfdecMovie * movie);
-#define swfdec_movie_contains(movie, x, y) \
- (swfdec_movie_get_movie_at ((movie), (x), (y), FALSE) != NULL)
-SwfdecMovie * swfdec_movie_get_movie_at (SwfdecMovie * movie,
- double x,
- double y,
- gboolean events);
-char * swfdec_movie_get_path (SwfdecMovie * movie,
- gboolean dot);
-void swfdec_movie_render (SwfdecMovie * movie,
- cairo_t * cr,
- const SwfdecColorTransform *trans,
- const SwfdecRect * inval);
-cairo_pattern_t *swfdec_movie_mask (cairo_t * cr,
- SwfdecMovie * movie,
- const SwfdecRect * inval);
-SwfdecMovie * swfdec_movie_resolve (SwfdecMovie * movie);
-guint swfdec_movie_get_version (SwfdecMovie * movie);
-void swfdec_movie_execute (SwfdecMovie * movie,
- SwfdecEventType condition);
-void swfdec_movie_queue_script (SwfdecMovie * movie,
- SwfdecEventType condition);
-
-int swfdec_movie_compare_depths (gconstpointer a,
- gconstpointer b);
-SwfdecDepthClass
- swfdec_depth_classify (int depth);
-
-/* in swfdec_movie_asprops.c */
-gboolean swfdec_movie_set_asprop (SwfdecMovie * movie,
- const char * name,
- const SwfdecAsValue * val);
-gboolean swfdec_movie_get_asprop (SwfdecMovie * movie,
- const char * name,
- SwfdecAsValue * val);
-
-void swfdec_movie_add_variable_listener (SwfdecMovie * movie,
- SwfdecAsObject * object,
- const char * name,
- const SwfdecMovieVariableListenerFunction function);
-void swfdec_movie_remove_variable_listener (SwfdecMovie * movie,
- SwfdecAsObject * object,
- const char * name,
- const SwfdecMovieVariableListenerFunction function);
-SwfdecResource *swfdec_movie_get_own_resource (SwfdecMovie * movie);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_movie_as_drawing.c b/libswfdec/swfdec_movie_as_drawing.c
deleted file mode 100644
index bcedce6..0000000
--- a/libswfdec/swfdec_movie_as_drawing.c
+++ /dev/null
@@ -1,456 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_movie.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_color.h"
-#include "swfdec_debug.h"
-#include "swfdec_gradient_pattern.h"
-#include "swfdec_path.h"
-#include "swfdec_pattern.h"
-#include "swfdec_stroke.h"
-
-/* FIXME: This whole code assumes it works for MovieClip, Button and TextField
- * objects. If it only works for MovieClip objects, fix this. */
-
-static SwfdecDraw *
-swfdec_stroke_copy (SwfdecDraw *draw)
-{
- SwfdecStroke *sstroke = SWFDEC_STROKE (draw);
- SwfdecStroke *dstroke = g_object_new (SWFDEC_TYPE_STROKE, NULL);
-
- dstroke->start_width = sstroke->start_width;
- dstroke->start_color = sstroke->start_color;
- if (sstroke->pattern)
- dstroke->pattern = g_object_ref (sstroke->pattern);
- dstroke->start_cap = sstroke->start_cap;
- dstroke->end_cap = sstroke->end_cap;
- dstroke->join = sstroke->join;
- dstroke->miter_limit = sstroke->miter_limit;
- dstroke->no_vscale = sstroke->no_vscale;
- dstroke->no_hscale = sstroke->no_hscale;
-
- return SWFDEC_DRAW (dstroke);
-}
-
-static void
-swfdec_sprite_movie_end_fill (SwfdecMovie *movie, SwfdecDraw *new)
-{
- /* FIXME: need to cairo_close_path()? */
- movie->draw_fill = new;
- if (new == NULL)
- return;
-
- movie->draws = g_slist_append (movie->draws, new);
-
- /* need to begin a new line segment to ensure proper stacking order */
- if (movie->draw_line) {
- movie->draw_line = swfdec_stroke_copy (movie->draw_line);
- movie->draws = g_slist_append (movie->draws, movie->draw_line);
- }
-}
-
-#define SWFDEC_COLOR_FROM_COLOR_ALPHA(color, alpha) \
- (((color) & 0xFFFFFF) | SWFDEC_COLOR_COMBINE (0, 0, 0, CLAMP ((alpha), 0, 100) * 255 / 100))
-
-SWFDEC_AS_NATIVE (901, 1, swfdec_sprite_movie_beginFill)
-void
-swfdec_sprite_movie_beginFill (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
- SwfdecDraw *draw;
- int color, alpha;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "|ii", &color, &alpha);
- movie->draw_fill = NULL;
-
- if (argc == 0)
- return;
- color = color & 0xFFFFFF;
- if (argc <= 1) {
- alpha = 255;
- }
- color = SWFDEC_COLOR_FROM_COLOR_ALPHA (color, alpha);
- draw = SWFDEC_DRAW (swfdec_pattern_new_color (color));
- swfdec_path_move_to (&draw->path, movie->draw_x, movie->draw_y);
- swfdec_sprite_movie_end_fill (movie, draw);
-}
-
-static inline guint
-swfdec_sprite_movie_gradient_fill_get_length (SwfdecAsObject *o)
-{
- int length;
- SwfdecAsValue val;
-
- swfdec_as_object_get_variable (o, SWFDEC_AS_STR_length, &val);
- length = swfdec_as_value_to_integer (o->context, &val);
- return MAX (length, 0);
-}
-
-static int
-swfdec_sprite_movie_gradient_fill_check_length (SwfdecAsObject *colors, SwfdecAsObject *alphas, SwfdecAsObject *ratios)
-{
- guint c, a, r;
-
- c = swfdec_sprite_movie_gradient_fill_get_length (colors);
- a = swfdec_sprite_movie_gradient_fill_get_length (alphas);
- r = swfdec_sprite_movie_gradient_fill_get_length (ratios);
- if (c != a || a != r)
- return -1;
- return c;
-}
-
-static void
-swfdec_sprite_movie_extract_matrix (SwfdecAsObject *o, cairo_matrix_t *mat)
-{
- SwfdecAsContext *cx = o->context;
- SwfdecAsValue val;
-
- /* FIXME: This function does not call valueOf in the right order */
- if (swfdec_as_object_get_variable (o, SWFDEC_AS_STR_matrixType, &val)) {
- const char *s = swfdec_as_value_to_string (cx, &val);
- cairo_matrix_init_translate (mat, SWFDEC_TWIPS_SCALE_FACTOR / 2.0, SWFDEC_TWIPS_SCALE_FACTOR / 2.0);
- cairo_matrix_scale (mat, SWFDEC_TWIPS_SCALE_FACTOR / 32768.0, SWFDEC_TWIPS_SCALE_FACTOR / 32768.0);
- if (s == SWFDEC_AS_STR_box) {
- double x, y, w, h, r;
- cairo_matrix_t input;
- swfdec_as_object_get_variable (o, SWFDEC_AS_STR_x, &val);
- x = swfdec_as_value_to_number (cx, &val);
- swfdec_as_object_get_variable (o, SWFDEC_AS_STR_y, &val);
- y = swfdec_as_value_to_number (cx, &val);
- swfdec_as_object_get_variable (o, SWFDEC_AS_STR_w, &val);
- w = swfdec_as_value_to_number (cx, &val);
- swfdec_as_object_get_variable (o, SWFDEC_AS_STR_h, &val);
- h = swfdec_as_value_to_number (cx, &val);
- swfdec_as_object_get_variable (o, SWFDEC_AS_STR_r, &val);
- r = swfdec_as_value_to_number (cx, &val);
- cairo_matrix_init_translate (&input, (x + w) / 2, (y + h) / 2);
- cairo_matrix_scale (&input, w, h);
- cairo_matrix_rotate (&input, r);
- cairo_matrix_multiply (mat, mat, &input);
- } else {
- SWFDEC_WARNING ("my friend, there's no other matrixType than \"box\"");
- }
- } else {
- cairo_matrix_t input;
- swfdec_as_object_get_variable (o, SWFDEC_AS_STR_a, &val);
- input.xx = swfdec_as_value_to_number (cx, &val);
- swfdec_as_object_get_variable (o, SWFDEC_AS_STR_b, &val);
- input.yx = swfdec_as_value_to_number (cx, &val);
- swfdec_as_object_get_variable (o, SWFDEC_AS_STR_d, &val);
- input.xy = swfdec_as_value_to_number (cx, &val);
- swfdec_as_object_get_variable (o, SWFDEC_AS_STR_e, &val);
- input.yy = swfdec_as_value_to_number (cx, &val);
- swfdec_as_object_get_variable (o, SWFDEC_AS_STR_g, &val);
- input.x0 = swfdec_as_value_to_number (cx, &val) * SWFDEC_TWIPS_SCALE_FACTOR;
- swfdec_as_object_get_variable (o, SWFDEC_AS_STR_h, &val);
- input.y0 = swfdec_as_value_to_number (cx, &val) * SWFDEC_TWIPS_SCALE_FACTOR;
- cairo_matrix_init_scale (mat, SWFDEC_TWIPS_SCALE_FACTOR / 32768.0, SWFDEC_TWIPS_SCALE_FACTOR / 32768.0);
- cairo_matrix_multiply (mat, mat, &input);
- }
-}
-
-SWFDEC_AS_NATIVE (901, 2, swfdec_sprite_movie_beginGradientFill)
-void
-swfdec_sprite_movie_beginGradientFill (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecGradientPattern *gradient;
- SwfdecPattern *pattern;
- SwfdecMovie *movie;
- SwfdecDraw *draw;
- SwfdecAsObject *colors, *alphas, *ratios, *matrix;
- const char *s;
- gboolean radial;
- int i, len;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "|sOOOO", &s, &colors, &alphas, &ratios, &matrix);
- movie->draw_fill = NULL;
-
- if (colors == NULL || alphas == NULL || ratios == NULL || matrix == NULL) {
- SWFDEC_ERROR ("could not convert one of the parameters to an object");
- return;
- }
- if (s == SWFDEC_AS_STR_linear) {
- radial = FALSE;
- } else if (s == SWFDEC_AS_STR_radial) {
- radial = TRUE;
- } else {
- SWFDEC_WARNING ("invalid fill type %s", s);
- return;
- }
- len = swfdec_sprite_movie_gradient_fill_check_length (colors, alphas, ratios);
- if (len < 0) {
- SWFDEC_ERROR ("different lengths for colors, alphas and ratios, aborting");
- return;
- }
- draw = swfdec_gradient_pattern_new ();
- pattern = SWFDEC_PATTERN (draw);
- gradient = SWFDEC_GRADIENT_PATTERN (draw);
- gradient->radial = radial;
- len = MIN (len, 8);
- gradient->n_gradients = len;
- for (i = 0; i < len; i++) {
- int c, a, r;
- SwfdecAsValue v;
- int check = swfdec_sprite_movie_gradient_fill_check_length (colors, alphas, ratios);
- if (check > i) {
- const char *name = swfdec_as_integer_to_string (cx, i);
- if (swfdec_as_object_get_variable (colors, name, &v)
- && SWFDEC_AS_VALUE_IS_NUMBER (&v))
- c = swfdec_as_value_to_integer (cx, &v);
- else
- c = 0;
- if (!swfdec_as_object_get_variable (alphas, name, &v)) {
- a = c;
- } else if (!SWFDEC_AS_VALUE_IS_NUMBER (&v)) {
- a = 0;
- } else {
- a = swfdec_as_value_to_integer (cx, &v);
- }
- if (!swfdec_as_object_get_variable (ratios, name, &v))
- r = CLAMP (a, 0, 255);
- else if (!SWFDEC_AS_VALUE_IS_NUMBER (&v))
- r = 0;
- else
- r = swfdec_as_value_to_integer (cx, &v);
- } else {
- c = a = r = 0;
- }
- if (r > 255 || r < 0) {
- SWFDEC_WARNING ("ratio %d not in [0, 255], ignoring gradient", r);
- g_object_unref (draw);
- return;
- } else if (r < 0) {
- r = 0;
- }
- gradient->gradient[i].color = SWFDEC_COLOR_FROM_COLOR_ALPHA (c, a);
- gradient->gradient[i].ratio = r;
- }
- swfdec_sprite_movie_extract_matrix (matrix, &pattern->start_transform);
- pattern->transform = pattern->start_transform;
- if (cairo_matrix_invert (&pattern->transform)) {
- SWFDEC_ERROR ("gradient transform matrix not invertible, resetting");
- cairo_matrix_init_identity (&pattern->transform);
- }
-
- swfdec_path_move_to (&draw->path, movie->draw_x, movie->draw_y);
- swfdec_sprite_movie_end_fill (movie, draw);
-}
-
-SWFDEC_AS_NATIVE (901, 3, swfdec_sprite_movie_moveTo)
-void
-swfdec_sprite_movie_moveTo (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
- double x, y;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "|nn", &x, &y);
-
- x = SWFDEC_DOUBLE_TO_TWIPS (x);
- y = SWFDEC_DOUBLE_TO_TWIPS (y);
- /* NB: moves do not extend extents */
- if (movie->draw_fill) {
- swfdec_path_move_to (&movie->draw_fill->path, x, y);
- }
- if (movie->draw_line) {
- swfdec_path_move_to (&movie->draw_line->path, x, y);
- }
- movie->draw_x = x;
- movie->draw_y = y;
-}
-
-static void
-swfdec_spite_movie_recompute_draw (SwfdecMovie *movie, SwfdecDraw *draw)
-{
- swfdec_draw_recompute (draw);
- if (swfdec_rect_inside (&movie->draw_extents, &draw->extents)) {
- swfdec_movie_invalidate_last (movie);
- } else {
- swfdec_movie_invalidate_next (movie);
- swfdec_rect_union (&movie->draw_extents, &movie->draw_extents, &draw->extents);
- swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_EXTENTS);
- }
-}
-
-SWFDEC_AS_NATIVE (901, 4, swfdec_sprite_movie_lineTo)
-void
-swfdec_sprite_movie_lineTo (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
- double x, y;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "nn", &x, &y);
-
- x = SWFDEC_DOUBLE_TO_TWIPS (x);
- y = SWFDEC_DOUBLE_TO_TWIPS (y);
- if (movie->draw_fill) {
- swfdec_path_line_to (&movie->draw_fill->path, x, y);
- swfdec_spite_movie_recompute_draw (movie, movie->draw_fill);
- }
- if (movie->draw_line) {
- swfdec_path_line_to (&movie->draw_line->path, x, y);
- swfdec_spite_movie_recompute_draw (movie, movie->draw_line);
- }
- movie->draw_x = x;
- movie->draw_y = y;
-}
-
-SWFDEC_AS_NATIVE (901, 5, swfdec_sprite_movie_curveTo)
-void
-swfdec_sprite_movie_curveTo (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
- double x, y, c_x, c_y;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "nnnn", &c_x, &c_y, &x, &y);
-
- x = SWFDEC_DOUBLE_TO_TWIPS (x);
- y = SWFDEC_DOUBLE_TO_TWIPS (y);
- c_x = SWFDEC_DOUBLE_TO_TWIPS (c_x);
- c_y = SWFDEC_DOUBLE_TO_TWIPS (c_y);
- if (movie->draw_fill) {
- swfdec_path_curve_to (&movie->draw_fill->path, movie->draw_x, movie->draw_y,
- c_x, c_y, x, y);
- swfdec_spite_movie_recompute_draw (movie, movie->draw_fill);
- }
- if (movie->draw_line) {
- swfdec_path_curve_to (&movie->draw_line->path, movie->draw_x, movie->draw_y,
- c_x, c_y, x, y);
- swfdec_spite_movie_recompute_draw (movie, movie->draw_line);
- }
- movie->draw_x = x;
- movie->draw_y = y;
-}
-
-SWFDEC_AS_NATIVE (901, 6, swfdec_sprite_movie_lineStyle)
-void
-swfdec_sprite_movie_lineStyle (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
- SwfdecStroke *stroke;
- int width, color, alpha;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "|iii", &width, &color, &alpha);
-
- movie->draw_line = NULL;
- if (argc < 1 || SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
- return;
- if (argc < 3)
- alpha = 100;
- if (argc > 3) {
- SWFDEC_FIXME ("implement Flash 8 arguments to lineStyle");
- }
- color = color & 0xFFFFFF;
- alpha = CLAMP (alpha, 0, 100);
- alpha = SWFDEC_COLOR_COMBINE (0, 0, 0, alpha * 255 / 100);
- color = color | alpha;
- stroke = g_object_new (SWFDEC_TYPE_STROKE, NULL);
- stroke->start_color = color;
- stroke->start_width = SWFDEC_DOUBLE_TO_TWIPS (width);
- movie->draw_line = SWFDEC_DRAW (stroke);
- swfdec_path_move_to (&movie->draw_line->path, movie->draw_x, movie->draw_y);
- movie->draws = g_slist_append (movie->draws, movie->draw_line);
-}
-
-SWFDEC_AS_NATIVE (901, 7, swfdec_sprite_movie_endFill)
-void
-swfdec_sprite_movie_endFill (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "");
- swfdec_sprite_movie_end_fill (movie, NULL);
-}
-
-SWFDEC_AS_NATIVE (901, 8, swfdec_sprite_movie_clear)
-void
-swfdec_sprite_movie_clear (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "");
- if (movie->draws == NULL)
- return;
- swfdec_movie_invalidate_last (movie);
- swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_EXTENTS);
- swfdec_rect_init_empty (&movie->draw_extents);
- g_slist_foreach (movie->draws, (GFunc) g_object_unref, NULL);
- g_slist_free (movie->draws);
- movie->draws = NULL;
- movie->draw_fill = NULL;
- movie->draw_line = NULL;
-}
-
-SWFDEC_AS_NATIVE (901, 9, swfdec_sprite_movie_lineGradientStyle)
-void
-swfdec_sprite_movie_lineGradientStyle (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.lineGradientStyle");
-}
-
-SWFDEC_AS_NATIVE (901, 10, swfdec_sprite_movie_beginMeshFill)
-void
-swfdec_sprite_movie_beginMeshFill (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.beginMeshFill");
-}
-
-SWFDEC_AS_NATIVE (901, 11, swfdec_sprite_movie_beginBitmapFill)
-void
-swfdec_sprite_movie_beginBitmapFill (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.beginBitmapFill");
-}
-
-SWFDEC_AS_NATIVE (901, 12, swfdec_sprite_movie_get_scale9Grid)
-void
-swfdec_sprite_movie_get_scale9Grid (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.scale9Grid (get)");
-}
-
-SWFDEC_AS_NATIVE (901, 13, swfdec_sprite_movie_set_scale9Grid)
-void
-swfdec_sprite_movie_set_scale9Grid (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.scale9Grid (set)");
-}
diff --git a/libswfdec/swfdec_movie_asprops.c b/libswfdec/swfdec_movie_asprops.c
deleted file mode 100644
index c2985a5..0000000
--- a/libswfdec/swfdec_movie_asprops.c
+++ /dev/null
@@ -1,484 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <string.h>
-#include <math.h>
-
-#include "swfdec_movie.h"
-#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"
-#include "swfdec_resource.h"
-
-static void
-mc_x_get (SwfdecMovie *movie, SwfdecAsValue *rval)
-{
- double d;
-
- swfdec_movie_update (movie);
- d = SWFDEC_TWIPS_TO_DOUBLE (movie->matrix.x0);
- SWFDEC_AS_VALUE_SET_NUMBER (rval, d);
-}
-
-static void
-mc_x_set (SwfdecMovie *movie, const SwfdecAsValue *val)
-{
- double d;
-
- d = swfdec_as_value_to_number (SWFDEC_AS_OBJECT (movie)->context, val);
- if (!isfinite (d)) {
- SWFDEC_WARNING ("trying to move %s._x to a non-finite value, ignoring", movie->name);
- return;
- }
- movie->modified = TRUE;
- d = SWFDEC_DOUBLE_TO_TWIPS (d);
- if (d != movie->matrix.x0) {
- swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
- movie->matrix.x0 = d;
- }
-}
-
-static void
-mc_y_get (SwfdecMovie *movie, SwfdecAsValue *rval)
-{
- double d;
-
- swfdec_movie_update (movie);
- d = SWFDEC_TWIPS_TO_DOUBLE (movie->matrix.y0);
- SWFDEC_AS_VALUE_SET_NUMBER (rval, d);
-}
-
-static void
-mc_y_set (SwfdecMovie *movie, const SwfdecAsValue *val)
-{
- double d;
-
- d = swfdec_as_value_to_number (SWFDEC_AS_OBJECT (movie)->context, val);
- if (!isfinite (d)) {
- SWFDEC_WARNING ("trying to move %s._y to a non-finite value, ignoring", movie->name);
- return;
- }
- movie->modified = TRUE;
- d = SWFDEC_DOUBLE_TO_TWIPS (d);
- if (d != movie->matrix.y0) {
- swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
- movie->matrix.y0 = d;
- }
-}
-
-static void
-mc_xscale_get (SwfdecMovie *movie, SwfdecAsValue *rval)
-{
- SWFDEC_AS_VALUE_SET_NUMBER (rval, movie->xscale);
-}
-
-static void
-mc_xscale_set (SwfdecMovie *movie, const SwfdecAsValue *val)
-{
- double d;
-
- d = swfdec_as_value_to_number (SWFDEC_AS_OBJECT (movie)->context, val);
- if (!isfinite (d)) {
- SWFDEC_WARNING ("trying to set xscale to a non-finite value, ignoring");
- return;
- }
- movie->modified = TRUE;
- if (movie->xscale != d) {
- swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
- movie->xscale = d;
- }
-}
-
-static void
-mc_yscale_get (SwfdecMovie *movie, SwfdecAsValue *rval)
-{
- SWFDEC_AS_VALUE_SET_NUMBER (rval, movie->yscale);
-}
-
-static void
-mc_yscale_set (SwfdecMovie *movie, const SwfdecAsValue *val)
-{
- double d;
-
- d = swfdec_as_value_to_number (SWFDEC_AS_OBJECT (movie)->context, val);
- if (!isfinite (d)) {
- SWFDEC_WARNING ("trying to set yscale to a non-finite value, ignoring");
- return;
- }
- movie->modified = TRUE;
- if (movie->yscale != d) {
- swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
- movie->yscale = d;
- }
-}
-
-static void
-mc_name_get (SwfdecMovie *movie, SwfdecAsValue *rval)
-{
- SWFDEC_AS_VALUE_SET_STRING (rval, movie->name);
-}
-
-static void
-mc_name_set (SwfdecMovie *movie, const SwfdecAsValue *val)
-{
- movie->name = swfdec_as_value_to_string (SWFDEC_AS_OBJECT (movie)->context, val);
-}
-
-static void
-mc_currentframe (SwfdecMovie *movie, SwfdecAsValue *rval)
-{
- g_assert (SWFDEC_IS_SPRITE_MOVIE (movie));
- SWFDEC_AS_VALUE_SET_NUMBER (rval, SWFDEC_SPRITE_MOVIE (movie)->frame);
-}
-
-static void
-mc_framesloaded (SwfdecMovie *mov, SwfdecAsValue *rval)
-{
- SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov);
-
- SWFDEC_AS_VALUE_SET_INT (rval,
- swfdec_sprite_movie_get_frames_loaded (movie));
-}
-
-static void
-mc_totalframes (SwfdecMovie *mov, SwfdecAsValue *rval)
-{
- SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov);
-
- SWFDEC_AS_VALUE_SET_INT (rval,
- swfdec_sprite_movie_get_frames_total (movie));
-}
-
-static void
-mc_alpha_get (SwfdecMovie *movie, SwfdecAsValue *rval)
-{
- SWFDEC_AS_VALUE_SET_NUMBER (rval,
- movie->color_transform.aa * 100.0 / 256.0);
-}
-
-static void
-mc_alpha_set (SwfdecMovie *movie, const SwfdecAsValue *val)
-{
- double d;
- int alpha;
-
- d = swfdec_as_value_to_number (SWFDEC_AS_OBJECT (movie)->context, val);
- if (!isfinite (d)) {
- SWFDEC_WARNING ("trying to set alpha to a non-finite value, ignoring");
- return;
- }
- alpha = d * 256.0 / 100.0;
- if (alpha != movie->color_transform.aa) {
- movie->color_transform.aa = alpha;
- swfdec_movie_invalidate_last (movie);
- }
-}
-
-static void
-mc_visible_get (SwfdecMovie *movie, SwfdecAsValue *rval)
-{
- SWFDEC_AS_VALUE_SET_BOOLEAN (rval, movie->visible);
-}
-
-static void
-mc_visible_set (SwfdecMovie *movie, const SwfdecAsValue *val)
-{
- gboolean b;
-
- b = swfdec_as_value_to_boolean (SWFDEC_AS_OBJECT (movie)->context, val);
- if (b != movie->visible) {
- movie->visible = b;
- swfdec_movie_invalidate_last (movie);
- }
-}
-
-static void
-mc_width_get (SwfdecMovie *movie, SwfdecAsValue *rval)
-{
- double d;
-
- swfdec_movie_update (movie);
- d = rint (movie->extents.x1 - movie->extents.x0);
- d = SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) d);
- SWFDEC_AS_VALUE_SET_NUMBER (rval, d);
-}
-
-static void
-mc_width_set (SwfdecMovie *movie, const SwfdecAsValue *val)
-{
- double d, cur;
-
- /* property was readonly in Flash 4 and before */
- if (SWFDEC_AS_OBJECT (movie)->context->version < 5)
- return;
- d = swfdec_as_value_to_number (SWFDEC_AS_OBJECT (movie)->context, val);
- if (!isfinite (d)) {
- SWFDEC_WARNING ("trying to set width to a non-finite value, ignoring");
- return;
- }
- swfdec_movie_update (movie);
- movie->modified = TRUE;
- cur = rint (movie->original_extents.x1 - movie->original_extents.x0);
- cur = SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) cur);
- if (cur != 0) {
- d = 100 * d / cur;
- if (d == movie->xscale)
- return;
- swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
- movie->xscale = d;
- } else {
- swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
- movie->xscale = 0;
- movie->yscale = 0;
- }
-}
-
-static void
-mc_height_get (SwfdecMovie *movie, SwfdecAsValue *rval)
-{
- double d;
-
- swfdec_movie_update (movie);
- d = rint (movie->extents.y1 - movie->extents.y0);
- d = SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) d);
- SWFDEC_AS_VALUE_SET_NUMBER (rval, d);
-}
-
-static void
-mc_height_set (SwfdecMovie *movie, const SwfdecAsValue *val)
-{
- double d, cur;
-
- /* property was readonly in Flash 4 and before */
- if (SWFDEC_AS_OBJECT (movie)->context->version < 5)
- return;
- d = swfdec_as_value_to_number (SWFDEC_AS_OBJECT (movie)->context, val);
- if (!isfinite (d)) {
- SWFDEC_WARNING ("trying to set height to a non-finite value, ignoring");
- return;
- }
- swfdec_movie_update (movie);
- movie->modified = TRUE;
- cur = rint (movie->original_extents.y1 - movie->original_extents.y0);
- cur = SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) cur);
- if (cur != 0) {
- d = 100 * d / cur;
- if (d == movie->yscale)
- return;
- swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
- movie->yscale = d;
- } else {
- swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
- movie->xscale = 0;
- movie->yscale = 0;
- }
-}
-
-static void
-mc_rotation_get (SwfdecMovie *movie, SwfdecAsValue *rval)
-{
- SWFDEC_AS_VALUE_SET_NUMBER (rval, movie->rotation);
-}
-
-static void
-mc_rotation_set (SwfdecMovie *movie, const SwfdecAsValue *val)
-{
- double d;
-
- /* FIXME: Flash 4 handles this differently */
- d = swfdec_as_value_to_number (SWFDEC_AS_OBJECT (movie)->context, val);
- if (isnan (d)) {
- SWFDEC_WARNING ("setting rotation to NaN - not allowed");
- return;
- }
- d = fmod (d, 360.0);
- if (d > 180.0)
- d -= 360.0;
- if (d < -180.0)
- d += 360.0;
- if (SWFDEC_AS_OBJECT (movie)->context->version < 5) {
- if (!isfinite (d))
- return;
- SWFDEC_ERROR ("FIXME: implement correct rounding errors here");
- }
- movie->modified = TRUE;
- if (movie->rotation != d) {
- swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
- movie->rotation = d;
- }
-}
-
-static void
-mc_xmouse_get (SwfdecMovie *movie, SwfdecAsValue *rval)
-{
- double x, y;
-
- swfdec_movie_get_mouse (movie, &x, &y);
- x = SWFDEC_TWIPS_TO_DOUBLE (rint (x));
- SWFDEC_AS_VALUE_SET_NUMBER (rval, x);
-}
-
-static void
-mc_ymouse_get (SwfdecMovie *movie, SwfdecAsValue *rval)
-{
- double x, y;
-
- swfdec_movie_get_mouse (movie, &x, &y);
- y = SWFDEC_TWIPS_TO_DOUBLE (rint (y));
- SWFDEC_AS_VALUE_SET_NUMBER (rval, y);
-}
-
-static void
-mc_parent (SwfdecMovie *movie, SwfdecAsValue *rval)
-{
- if (movie->parent) {
- SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (movie->parent));
- } else {
- SWFDEC_AS_VALUE_SET_UNDEFINED (rval);
- }
-}
-
-static void
-mc_root (SwfdecMovie *movie, SwfdecAsValue *rval)
-{
- movie = swfdec_movie_get_root (movie);
- SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (movie));
-}
-
-static void
-mc_target_get (SwfdecMovie *movie, SwfdecAsValue *rval)
-{
- GString *s;
-
- s = g_string_new ("");
- while (movie->parent) {
- g_string_prepend (s, movie->name);
- g_string_prepend_c (s, '/');
- movie = movie->parent;
- }
- if (s->len == 0) {
- SWFDEC_AS_VALUE_SET_STRING (rval, SWFDEC_AS_STR_SLASH);
- g_string_free (s, TRUE);
- } else {
- SWFDEC_AS_VALUE_SET_STRING (rval, swfdec_as_context_give_string (
- SWFDEC_AS_OBJECT (movie)->context, g_string_free (s, FALSE)));
- }
-}
-
-static void
-mc_url_get (SwfdecMovie *movie, SwfdecAsValue *rval)
-{
- SWFDEC_AS_VALUE_SET_STRING (rval, swfdec_as_context_get_string (
- SWFDEC_AS_OBJECT (movie)->context,
- swfdec_url_get_url (swfdec_loader_get_url (movie->resource->loader))));
-}
-
-struct {
- gboolean needs_movie;
- const char *name;
- void (* get) (SwfdecMovie *movie, SwfdecAsValue *ret);
- void (* set) (SwfdecMovie *movie, const SwfdecAsValue *val);
-} swfdec_movieclip_props[] = {
- { 0, SWFDEC_AS_STR__x, mc_x_get, mc_x_set },
- { 0, SWFDEC_AS_STR__y, mc_y_get, mc_y_set },
- { 0, SWFDEC_AS_STR__xscale, mc_xscale_get, mc_xscale_set },
- { 0, SWFDEC_AS_STR__yscale, mc_yscale_get, mc_yscale_set },
- { 1, SWFDEC_AS_STR__currentframe,mc_currentframe, NULL },
- { 1, SWFDEC_AS_STR__totalframes, mc_totalframes, NULL },
- { 0, SWFDEC_AS_STR__alpha, mc_alpha_get, mc_alpha_set },
- { 0, SWFDEC_AS_STR__visible, mc_visible_get, mc_visible_set },
- { 0, SWFDEC_AS_STR__width, mc_width_get, mc_width_set },
- { 0, SWFDEC_AS_STR__height, mc_height_get, mc_height_set },
- { 0, SWFDEC_AS_STR__rotation, mc_rotation_get, mc_rotation_set },
- { 1, SWFDEC_AS_STR__target, mc_target_get, NULL }, //"_target"
- { 1, SWFDEC_AS_STR__framesloaded,mc_framesloaded, NULL},
- { 0, SWFDEC_AS_STR__name, mc_name_get, mc_name_set },
- { 1, SWFDEC_AS_STR__droptarget, NULL, NULL }, //"_droptarget"
- { 0, SWFDEC_AS_STR__url, mc_url_get, NULL },
- { 0, SWFDEC_AS_STR__highquality, NULL, NULL }, //"_highquality"
- { 0, SWFDEC_AS_STR__focusrect, NULL, NULL }, //"_focusrect"
- { 0, SWFDEC_AS_STR__soundbuftime,NULL, NULL }, //"_soundbuftime"
- { 0, SWFDEC_AS_STR__quality, NULL, NULL }, //"_quality"
- { 0, SWFDEC_AS_STR__xmouse, mc_xmouse_get, NULL },
- { 0, SWFDEC_AS_STR__ymouse, mc_ymouse_get, NULL },
- { 0, SWFDEC_AS_STR__parent, mc_parent, NULL },
- { 0, SWFDEC_AS_STR__root, mc_root, NULL },
-};
-
-static inline int
-swfdec_movie_get_asprop_index (SwfdecMovie *movie, const char *name)
-{
- guint i;
-
- if (name < SWFDEC_AS_STR__x || name > SWFDEC_AS_STR__root)
- return -1;
-
- for (i = 0; i < G_N_ELEMENTS (swfdec_movieclip_props); i++) {
- if (swfdec_movieclip_props[i].name == name) {
- if (swfdec_movieclip_props[i].needs_movie && !SWFDEC_IS_SPRITE_MOVIE (movie))
- return -1;
- if (swfdec_movieclip_props[i].get == NULL) {
- SWFDEC_ERROR ("property %s not implemented", name);
- }
- return i;
- }
- }
- g_assert_not_reached ();
- return -1;
-}
-
-gboolean
-swfdec_movie_set_asprop (SwfdecMovie *movie, const char *name, const SwfdecAsValue *val)
-{
- int i;
-
- i = swfdec_movie_get_asprop_index (movie, name);
- if (i == -1)
- return FALSE;
- if (swfdec_movieclip_props[i].set != NULL) {
- swfdec_movieclip_props[i].set (movie, val);
- }
- return TRUE;
-}
-
-gboolean
-swfdec_movie_get_asprop (SwfdecMovie *movie, const char *name, SwfdecAsValue *val)
-{
- int i;
-
- i = swfdec_movie_get_asprop_index (movie, name);
- if (i == -1)
- return FALSE;
- if (swfdec_movieclip_props[i].get != NULL) {
- swfdec_movieclip_props[i].get (movie, val);
- } else {
- SWFDEC_AS_VALUE_SET_UNDEFINED (val);
- }
- return TRUE;
-}
-
diff --git a/libswfdec/swfdec_movie_clip_loader.c b/libswfdec/swfdec_movie_clip_loader.c
deleted file mode 100644
index 77d8704..0000000
--- a/libswfdec/swfdec_movie_clip_loader.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_movie_clip_loader.h"
-#include "swfdec_as_array.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-#include "swfdec_decoder.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_resource.h"
-
-
-G_DEFINE_TYPE (SwfdecMovieClipLoader, swfdec_movie_clip_loader, SWFDEC_TYPE_AS_OBJECT)
-
-static void
-swfdec_movie_clip_loader_class_init (SwfdecMovieClipLoaderClass *klass)
-{
-}
-
-static void
-swfdec_movie_clip_loader_init (SwfdecMovieClipLoader *movie_clip_loader)
-{
-}
-
-SWFDEC_AS_CONSTRUCTOR (112, 0, swfdec_movie_clip_loader_construct, swfdec_movie_clip_loader_get_type)
-void
-swfdec_movie_clip_loader_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecAsValue val;
- SwfdecAsObject *array;
-
- if (!swfdec_as_context_is_constructing (cx))
- return;
-
- array = swfdec_as_array_new (cx);
- if (array == NULL)
- return;
- SWFDEC_AS_VALUE_SET_OBJECT (&val, object);
- swfdec_as_array_push (SWFDEC_AS_ARRAY (array), &val);
- SWFDEC_AS_VALUE_SET_OBJECT (&val, array);
- swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR__listeners,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
-}
-
-SWFDEC_AS_NATIVE (112, 100, swfdec_movie_clip_loader_loadClip)
-void
-swfdec_movie_clip_loader_loadClip (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovieClipLoader *loader;
- const char *url, *target;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE_CLIP_LOADER, &loader, "ss", &url, &target);
-
- swfdec_resource_load (SWFDEC_PLAYER (cx), target, url,
- SWFDEC_LOADER_REQUEST_DEFAULT, NULL, loader, TRUE);
-}
-
-SWFDEC_AS_NATIVE (112, 102, swfdec_movie_clip_loader_unloadClip)
-void
-swfdec_movie_clip_loader_unloadClip (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovieClipLoader *loader;
- const char *target;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE_CLIP_LOADER, &loader, "s", &target);
-
- swfdec_resource_load (SWFDEC_PLAYER (cx), target, "",
- SWFDEC_LOADER_REQUEST_DEFAULT, NULL, loader, TRUE);
-}
-
-SWFDEC_AS_NATIVE (112, 101, swfdec_movie_clip_loader_getProgress)
-void
-swfdec_movie_clip_loader_getProgress (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovieClipLoader *loader;
- SwfdecMovie *movie;
- SwfdecAsObject *ret;
- const char *target;
- SwfdecResource *resource;
- SwfdecAsValue loaded, total;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE_CLIP_LOADER, &loader, "s", &target);
-
- movie = swfdec_player_get_movie_from_string (SWFDEC_PLAYER (cx), target);
- if (movie == NULL)
- return;
- ret = swfdec_as_object_new_empty (cx);
- if (ret == NULL)
- return;
- SWFDEC_AS_VALUE_SET_OBJECT (rval, ret);
- resource = swfdec_movie_get_own_resource (movie);
- if (resource == NULL || resource->decoder == NULL) {
- SWFDEC_AS_VALUE_SET_INT (&loaded, 0);
- SWFDEC_AS_VALUE_SET_INT (&total, 0);
- } else {
- SWFDEC_AS_VALUE_SET_INT (&loaded, resource->decoder->bytes_loaded);
- SWFDEC_AS_VALUE_SET_INT (&total, resource->decoder->bytes_total);
- }
- swfdec_as_object_set_variable (ret, SWFDEC_AS_STR_bytesLoaded, &loaded);
- swfdec_as_object_set_variable (ret, SWFDEC_AS_STR_bytesTotal, &total);
-}
-
diff --git a/libswfdec/swfdec_movie_clip_loader.h b/libswfdec/swfdec_movie_clip_loader.h
deleted file mode 100644
index 9ef0d1c..0000000
--- a/libswfdec/swfdec_movie_clip_loader.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_MOVIE_CLIP_LOADER_H_
-#define _SWFDEC_MOVIE_CLIP_LOADER_H_
-
-#include <libswfdec/swfdec_as_object.h>
-
-G_BEGIN_DECLS
-
-//typedef struct _SwfdecMovieClipLoader SwfdecMovieClipLoader;
-typedef struct _SwfdecMovieClipLoaderClass SwfdecMovieClipLoaderClass;
-
-#define SWFDEC_TYPE_MOVIE_CLIP_LOADER (swfdec_movie_clip_loader_get_type())
-#define SWFDEC_IS_MOVIE_CLIP_LOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_MOVIE_CLIP_LOADER))
-#define SWFDEC_IS_MOVIE_CLIP_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_MOVIE_CLIP_LOADER))
-#define SWFDEC_MOVIE_CLIP_LOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_MOVIE_CLIP_LOADER, SwfdecMovieClipLoader))
-#define SWFDEC_MOVIE_CLIP_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_MOVIE_CLIP_LOADER, SwfdecMovieClipLoaderClass))
-#define SWFDEC_MOVIE_CLIP_LOADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_MOVIE_CLIP_LOADER, SwfdecMovieClipLoaderClass))
-
-struct _SwfdecMovieClipLoader
-{
- SwfdecAsObject object;
-};
-
-struct _SwfdecMovieClipLoaderClass
-{
- SwfdecAsObjectClass object_class;
-};
-
-GType swfdec_movie_clip_loader_get_type (void);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_net_connection.c b/libswfdec/swfdec_net_connection.c
deleted file mode 100644
index ad16614..0000000
--- a/libswfdec/swfdec_net_connection.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include "swfdec_net_connection.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_native_function.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_object.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-#include "swfdec_internal.h"
-
-/*** SwfdecNetConnection ***/
-
-G_DEFINE_TYPE (SwfdecNetConnection, swfdec_net_connection, SWFDEC_TYPE_AS_OBJECT)
-
-static void
-swfdec_net_connection_dispose (GObject *object)
-{
- SwfdecNetConnection *net_connection = SWFDEC_NET_CONNECTION (object);
-
- g_free (net_connection->url);
- net_connection->url = NULL;
-
- G_OBJECT_CLASS (swfdec_net_connection_parent_class)->dispose (object);
-}
-
-static void
-swfdec_net_connection_class_init (SwfdecNetConnectionClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->dispose = swfdec_net_connection_dispose;
-}
-
-static void
-swfdec_net_connection_init (SwfdecNetConnection *net_connection)
-{
-}
-
-static void
-swfdec_net_connection_onstatus (SwfdecNetConnection *conn, const char *code,
- const char *level, const char *description)
-{
- SwfdecAsValue value;
- SwfdecAsObject *info;
-
- info = swfdec_as_object_new (SWFDEC_AS_OBJECT (conn)->context);
- if (info == NULL)
- return;
- SWFDEC_AS_VALUE_SET_STRING (&value, code);
- swfdec_as_object_set_variable (info, SWFDEC_AS_STR_code, &value);
- SWFDEC_AS_VALUE_SET_STRING (&value, level);
- swfdec_as_object_set_variable (info, SWFDEC_AS_STR_level, &value);
- if (description) {
- SWFDEC_AS_VALUE_SET_STRING (&value, description);
- swfdec_as_object_set_variable (info, SWFDEC_AS_STR_description, &value);
- }
- SWFDEC_AS_VALUE_SET_OBJECT (&value, info);
- swfdec_as_object_call (SWFDEC_AS_OBJECT (conn), SWFDEC_AS_STR_onStatus, 1, &value, NULL);
-}
-
-SwfdecNetConnection *
-swfdec_net_connection_new (SwfdecAsContext *context)
-{
- SwfdecNetConnection *conn;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
-
- if (!swfdec_as_context_use_mem (context, sizeof (SwfdecNetConnection)))
- return NULL;
- conn = g_object_new (SWFDEC_TYPE_NET_CONNECTION, NULL);
- swfdec_as_object_add (SWFDEC_AS_OBJECT (conn), context, sizeof (SwfdecNetConnection));
-
- return conn;
-}
-
-void
-swfdec_net_connection_connect (SwfdecNetConnection *conn, const char *url)
-{
- g_return_if_fail (SWFDEC_IS_NET_CONNECTION (conn));
-
- g_free (conn->url);
- conn->url = g_strdup (url);
- if (url) {
- SWFDEC_ERROR ("FIXME: using NetConnection with non-null URLs is not implemented");
- }
- swfdec_net_connection_onstatus (conn, SWFDEC_AS_STR_NetConnection_Connect_Success,
- SWFDEC_AS_STR_status, NULL);
-}
-
-/*** AS CODE ***/
-
-SWFDEC_AS_NATIVE (2100, 0, swfdec_net_connection_do_connect)
-void
-swfdec_net_connection_do_connect (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecNetConnection *conn;
- SwfdecAsValue val;
- const char *url;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_NET_CONNECTION, &conn, "v", &val);
-
- if (SWFDEC_AS_VALUE_IS_STRING (&val)) {
- url = SWFDEC_AS_VALUE_GET_STRING (&val);
- } else if (SWFDEC_AS_VALUE_IS_NULL (&val)) {
- url = NULL;
- } else {
- SWFDEC_FIXME ("untested argument to NetConnection.connect: type %u", val.type);
- url = NULL;
- }
- swfdec_net_connection_connect (conn, url);
-}
-
-SWFDEC_AS_NATIVE (2100, 1, swfdec_net_connection_do_close)
-void
-swfdec_net_connection_do_close (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("NetConnection.close");
-}
-
-SWFDEC_AS_NATIVE (2100, 2, swfdec_net_connection_do_call)
-void
-swfdec_net_connection_do_call (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("NetConnection.call");
-}
-
-SWFDEC_AS_NATIVE (2100, 3, swfdec_net_connection_do_addHeader)
-void
-swfdec_net_connection_do_addHeader (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("NetConnection.addHeader");
-}
-
-SWFDEC_AS_NATIVE (2100, 4, swfdec_net_connection_get_connectedProxyType)
-void
-swfdec_net_connection_get_connectedProxyType (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("NetConnection.connectedProxyType (get)");
-}
-
-SWFDEC_AS_NATIVE (2100, 5, swfdec_net_connection_get_usingTLS)
-void
-swfdec_net_connection_get_usingTLS (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("NetConnection.usingTLS (get)");
-}
-
-// not actually the constructor, but called from the constructor
-SWFDEC_AS_CONSTRUCTOR (2100, 200, swfdec_net_connection_construct, swfdec_net_connection_get_type)
-void
-swfdec_net_connection_construct (SwfdecAsContext *cx, SwfdecAsObject *obj,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- // FIXME: Set contentType and possible do some other stuff too
-}
diff --git a/libswfdec/swfdec_net_connection.h b/libswfdec/swfdec_net_connection.h
deleted file mode 100644
index e7bd3fa..0000000
--- a/libswfdec/swfdec_net_connection.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_NET_CONNECTION_H_
-#define _SWFDEC_NET_CONNECTION_H_
-
-#include <libswfdec/swfdec_as_object.h>
-
-G_BEGIN_DECLS
-
-
-typedef struct _SwfdecNetConnection SwfdecNetConnection;
-typedef struct _SwfdecNetConnectionClass SwfdecNetConnectionClass;
-
-#define SWFDEC_TYPE_NET_CONNECTION (swfdec_net_connection_get_type())
-#define SWFDEC_IS_NET_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_NET_CONNECTION))
-#define SWFDEC_IS_NET_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_NET_CONNECTION))
-#define SWFDEC_NET_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_NET_CONNECTION, SwfdecNetConnection))
-#define SWFDEC_NET_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_NET_CONNECTION, SwfdecNetConnectionClass))
-#define SWFDEC_NET_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_NET_CONNECTION, SwfdecNetConnectionClass))
-
-struct _SwfdecNetConnection {
- SwfdecAsObject object;
-
- char * url; /* url for this net_connection or NULL for none */
-};
-
-struct _SwfdecNetConnectionClass {
- SwfdecAsObjectClass object_class;
-};
-
-GType swfdec_net_connection_get_type (void);
-
-SwfdecNetConnection * swfdec_net_connection_new (SwfdecAsContext * context);
-
-void swfdec_net_connection_connect (SwfdecNetConnection * conn,
- const char * url);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_net_stream.c b/libswfdec/swfdec_net_stream.c
deleted file mode 100644
index a8ec140..0000000
--- a/libswfdec/swfdec_net_stream.c
+++ /dev/null
@@ -1,662 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-#include "swfdec_net_stream.h"
-#include "swfdec_amf.h"
-#include "swfdec_as_frame_internal.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_audio_flv.h"
-#include "swfdec_debug.h"
-#include "swfdec_loader_internal.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_resource.h"
-#include "swfdec_sandbox.h"
-#include "swfdec_stream_target.h"
-
-/* NB: code and level must be rooted gc-strings */
-static void
-swfdec_net_stream_onstatus (SwfdecNetStream *stream, const char *code, const char *level)
-{
- SwfdecAsValue val;
- SwfdecAsObject *object;
-
- swfdec_sandbox_use (stream->sandbox);
- object = swfdec_as_object_new (SWFDEC_AS_OBJECT (stream)->context);
- if (!object) {
- swfdec_sandbox_unuse (stream->sandbox);
- return;
- }
- SWFDEC_INFO ("emitting onStatus for %s %s", level, code);
- SWFDEC_AS_VALUE_SET_STRING (&val, code);
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_code, &val);
- SWFDEC_AS_VALUE_SET_STRING (&val, level);
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_level, &val);
-
- SWFDEC_AS_VALUE_SET_OBJECT (&val, object);
- swfdec_as_object_call (SWFDEC_AS_OBJECT (stream), SWFDEC_AS_STR_onStatus, 1, &val, NULL);
- swfdec_sandbox_unuse (stream->sandbox);
-}
-
-static cairo_surface_t *
-swfdec_net_stream_decode_video (SwfdecNetStream *stream, SwfdecBuffer *buffer)
-{
- SwfdecVideoDecoder *decoder = stream->decoder;
- cairo_surface_t *surface;
-
- if (decoder == NULL)
- return NULL;
-
- if (decoder->codec == SWFDEC_VIDEO_CODEC_VP6 ||
- decoder->codec == SWFDEC_VIDEO_CODEC_VP6_ALPHA) {
- guint wsub, hsub;
- SwfdecBuffer *tmp;
- if (buffer->length == 0) {
- SWFDEC_ERROR ("0-byte VP6 video image buffer?");
- return NULL;
- }
- wsub = *buffer->data;
- hsub = wsub & 0xF;
- wsub >>= 4;
- tmp = swfdec_buffer_new_subbuffer (buffer, 1, buffer->length - 1);
- surface = swfdec_video_decoder_decode (decoder, tmp);
- swfdec_buffer_unref (tmp);
- if (hsub || wsub) {
- SWFDEC_FIXME ("need to subtract %ux%u pixels", wsub, hsub);
- }
- } else {
- surface = swfdec_video_decoder_decode (decoder, buffer);
- }
- return surface;
-}
-
-static void swfdec_net_stream_update_playing (SwfdecNetStream *stream);
-static void
-swfdec_net_stream_video_goto (SwfdecNetStream *stream, guint timestamp)
-{
- SwfdecBuffer *buffer;
- guint format;
- cairo_surface_t *old;
- gboolean process_events;
- guint process_events_from;
-
- SWFDEC_LOG ("goto %ums", timestamp);
- process_events = timestamp == stream->next_time;
- process_events_from = MIN (stream->next_time, stream->current_time + 1);
- old = stream->surface;
- if (stream->surface) {
- cairo_surface_destroy (stream->surface);
- stream->surface = NULL;
- }
- if (stream->flvdecoder->video) {
- buffer = swfdec_flv_decoder_get_video (stream->flvdecoder, timestamp,
- FALSE, &format, &stream->current_time, &stream->next_time);
- } else {
- buffer = NULL;
- }
- if (buffer == NULL) {
- SWFDEC_ERROR ("got no buffer - no video available?");
- } else {
- if (format != stream->format) {
- if (stream->decoder)
- swfdec_video_decoder_free (stream->decoder);
- stream->format = format;
- stream->decoder = swfdec_video_decoder_new (format);
- }
- stream->surface = swfdec_net_stream_decode_video (stream, buffer);
- if (stream->surface) {
- GList *walk;
- for (walk = stream->movies; walk; walk = walk->next) {
- swfdec_video_movie_new_image (walk->data);
- }
- }
- }
- if (stream->next_time <= stream->current_time) {
- if (swfdec_flv_decoder_is_eof (stream->flvdecoder)) {
- swfdec_net_stream_onstatus (stream, SWFDEC_AS_STR_NetStream_Play_Stop, SWFDEC_AS_STR_status);
- } else {
- stream->buffering = TRUE;
- swfdec_net_stream_onstatus (stream, SWFDEC_AS_STR_NetStream_Buffer_Empty,
- SWFDEC_AS_STR_status);
- }
- swfdec_net_stream_update_playing (stream);
- }
- if (process_events) {
- while (process_events_from <= stream->current_time) {
- SwfdecAsValue name, value;
- SwfdecBits bits;
- SwfdecBuffer *event = swfdec_flv_decoder_get_data (stream->flvdecoder, process_events_from, &process_events_from);
- if (!event)
- break;
- SWFDEC_LOG ("processing event from timestamp %u", process_events_from);
- process_events_from++; /* increase so we get the next event next time */
- swfdec_bits_init (&bits, event);
- swfdec_sandbox_use (stream->sandbox);
- if (swfdec_amf_parse (SWFDEC_AS_OBJECT (stream)->context, &bits, 2,
- SWFDEC_AMF_STRING, &name, SWFDEC_AMF_MIXED_ARRAY, &value) != 2) {
- SWFDEC_ERROR ("could not parse data tag");
- } else {
- swfdec_as_object_call (SWFDEC_AS_OBJECT (stream),
- SWFDEC_AS_VALUE_GET_STRING (&name), 1, &value, NULL);
- }
- swfdec_sandbox_unuse (stream->sandbox);
- }
- }
-}
-
-static void
-swfdec_net_stream_timeout (SwfdecTimeout *timeout)
-{
- SwfdecNetStream *stream = SWFDEC_NET_STREAM ((void *) ((guchar *) timeout - G_STRUCT_OFFSET (SwfdecNetStream, timeout)));
-
- SWFDEC_LOG ("timeout fired");
- stream->timeout.callback = NULL;
- swfdec_net_stream_video_goto (stream, stream->next_time);
- if (stream->next_time > stream->current_time) {
- SWFDEC_LOG ("readding timeout");
- stream->timeout.timestamp += SWFDEC_MSECS_TO_TICKS (stream->next_time - stream->current_time);
- stream->timeout.callback = swfdec_net_stream_timeout;
- swfdec_player_add_timeout (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (stream)->context), &stream->timeout);
- } else {
- if (stream->audio) {
- /* FIXME: just unref and let it take care of removing itself? */
- SWFDEC_LOG ("stopping audio due to EOS");
- swfdec_audio_remove (stream->audio);
- g_object_unref (stream->audio);
- stream->audio = NULL;
- }
- }
-}
-
-static void
-swfdec_net_stream_update_playing (SwfdecNetStream *stream)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (stream)->context);
- gboolean should_play;
-
- should_play = stream->playing; /* checks user-set play/pause */
- should_play &= !stream->buffering; /* checks enough data is available */
- should_play &= stream->flvdecoder != NULL; /* checks there even is something to play */
- should_play &= stream->next_time > stream->current_time; /* checks if EOF */
- if (should_play && stream->timeout.callback == NULL) {
- SWFDEC_DEBUG ("starting playback");
- stream->timeout.callback = swfdec_net_stream_timeout;
- stream->timeout.timestamp = player->priv->time + SWFDEC_MSECS_TO_TICKS (stream->next_time - stream->current_time);
- swfdec_player_add_timeout (player, &stream->timeout);
- if (stream->flvdecoder->audio) {
- g_assert (stream->audio == NULL);
- SWFDEC_LOG ("starting audio");
- stream->audio = swfdec_audio_flv_new (player,
- stream->flvdecoder, stream->current_time);
- } else {
- SWFDEC_LOG ("no audio");
- }
- } else if (!should_play && stream->timeout.callback != NULL) {
- if (stream->audio) {
- SWFDEC_LOG ("stopping audio");
- swfdec_audio_remove (stream->audio);
- g_object_unref (stream->audio);
- stream->audio = NULL;
- }
- swfdec_player_remove_timeout (player, &stream->timeout);
- stream->timeout.callback = NULL;
- SWFDEC_DEBUG ("stopping playback");
- }
-}
-
-/*** SWFDEC_STREAM_TARGET interface ***/
-
-static SwfdecPlayer *
-swfdec_net_stream_stream_target_get_player (SwfdecStreamTarget *target)
-{
- return SWFDEC_PLAYER (SWFDEC_AS_OBJECT (target)->context);
-}
-
-static void
-swfdec_net_stream_stream_target_error (SwfdecStreamTarget *target,
- SwfdecStream *stream)
-{
- SwfdecNetStream *ns = SWFDEC_NET_STREAM (target);
-
- if (ns->flvdecoder == NULL)
- swfdec_net_stream_onstatus (ns, SWFDEC_AS_STR_NetStream_Play_StreamNotFound,
- SWFDEC_AS_STR_error);
-}
-
-static void
-swfdec_net_stream_stream_target_recheck (SwfdecNetStream *stream)
-{
- if (stream->buffering) {
- guint first, last;
- if (swfdec_flv_decoder_get_video_info (stream->flvdecoder, &first, &last)) {
- guint current = MAX (first, stream->current_time);
- if (current + stream->buffer_time <= last) {
- swfdec_net_stream_video_goto (stream, current);
- stream->buffering = FALSE;
- swfdec_net_stream_onstatus (stream, SWFDEC_AS_STR_NetStream_Buffer_Full,
- SWFDEC_AS_STR_status);
- }
- } else {
- SWFDEC_ERROR ("no video stream, how do we update buffering?");
- }
- }
- swfdec_net_stream_update_playing (stream);
-}
-
-static void
-swfdec_net_stream_stream_target_parse (SwfdecStreamTarget *target,
- SwfdecStream *stream)
-{
- SwfdecNetStream *ns = SWFDEC_NET_STREAM (target);
- SwfdecBufferQueue *queue;
- SwfdecStatus status;
-
- if (ns->flvdecoder == NULL) {
- /* FIXME: add mp3 support */
- ns->flvdecoder = g_object_new (SWFDEC_TYPE_FLV_DECODER, NULL);
- SWFDEC_DECODER (ns->flvdecoder)->player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (ns)->context);
- swfdec_net_stream_onstatus (ns, SWFDEC_AS_STR_NetStream_Play_Start,
- SWFDEC_AS_STR_status);
- swfdec_loader_set_data_type (SWFDEC_LOADER (stream), SWFDEC_LOADER_DATA_FLV);
- }
-
- status = SWFDEC_STATUS_OK;
- queue = swfdec_stream_get_queue (stream);
- do {
- SwfdecBuffer *buffer = swfdec_buffer_queue_pull_buffer (queue);
- if (buffer == NULL)
- break;
- status &= ~SWFDEC_STATUS_NEEDBITS;
- status |= swfdec_decoder_parse (SWFDEC_DECODER (ns->flvdecoder), buffer);
- } while ((status & (SWFDEC_STATUS_ERROR | SWFDEC_STATUS_EOF)) == 0);
-
- if (status & SWFDEC_STATUS_IMAGE)
- swfdec_net_stream_stream_target_recheck (ns);
-}
-
-static void
-swfdec_net_stream_stream_target_close (SwfdecStreamTarget *target,
- SwfdecStream *stream)
-{
- SwfdecNetStream *ns = SWFDEC_NET_STREAM (target);
- guint first, last;
-
- swfdec_decoder_eof (SWFDEC_DECODER (ns->flvdecoder));
- swfdec_net_stream_onstatus (ns, SWFDEC_AS_STR_NetStream_Buffer_Flush,
- SWFDEC_AS_STR_status);
- swfdec_net_stream_video_goto (ns, ns->current_time);
- ns->buffering = FALSE;
- if (swfdec_flv_decoder_get_video_info (ns->flvdecoder, &first, &last) &&
- ns->current_time + ns->buffer_time <= last) {
- swfdec_net_stream_onstatus (ns, SWFDEC_AS_STR_NetStream_Buffer_Full,
- SWFDEC_AS_STR_status);
- }
- swfdec_net_stream_stream_target_recheck (ns);
-}
-
-static void
-swfdec_net_stream_stream_target_init (SwfdecStreamTargetInterface *iface)
-{
- iface->get_player = swfdec_net_stream_stream_target_get_player;
- iface->parse = swfdec_net_stream_stream_target_parse;
- iface->close = swfdec_net_stream_stream_target_close;
- iface->error = swfdec_net_stream_stream_target_error;
-}
-
-/*** SWFDEC VIDEO MOVIE INPUT ***/
-
-static void
-swfdec_net_stream_input_connect (SwfdecVideoMovieInput *input, SwfdecVideoMovie *movie)
-{
- SwfdecNetStream *stream = SWFDEC_NET_STREAM ((void *)((guchar *) input - G_STRUCT_OFFSET (SwfdecNetStream, input)));
-
- stream->movies = g_list_prepend (stream->movies, movie);
- g_object_ref (stream);
-}
-
-static void
-swfdec_net_stream_input_disconnect (SwfdecVideoMovieInput *input, SwfdecVideoMovie *movie)
-{
- SwfdecNetStream *stream = SWFDEC_NET_STREAM ((void *)((guchar *) input - G_STRUCT_OFFSET (SwfdecNetStream, input)));
-
- stream->movies = g_list_remove (stream->movies, movie);
- g_object_unref (stream);
-}
-
-static cairo_surface_t *
-swfdec_net_stream_input_get_image (SwfdecVideoMovieInput *input)
-{
- SwfdecNetStream *stream = SWFDEC_NET_STREAM ((void *)((guchar *) input - G_STRUCT_OFFSET (SwfdecNetStream, input)));
-
- return stream->surface;
-}
-
-/*** SWFDEC_NET_STREAM ***/
-
-G_DEFINE_TYPE_WITH_CODE (SwfdecNetStream, swfdec_net_stream, SWFDEC_TYPE_AS_OBJECT,
- G_IMPLEMENT_INTERFACE (SWFDEC_TYPE_STREAM_TARGET, swfdec_net_stream_stream_target_init))
-
-static void
-swfdec_net_stream_dispose (GObject *object)
-{
- SwfdecNetStream *stream = SWFDEC_NET_STREAM (object);
-
- swfdec_net_stream_set_playing (stream, FALSE);
- if (stream->surface) {
- cairo_surface_destroy (stream->surface);
- stream->surface = NULL;
- }
- if (stream->decoder) {
- swfdec_video_decoder_free (stream->decoder);
- stream->decoder = NULL;
- }
- swfdec_net_stream_set_loader (stream, NULL);
- g_assert (stream->movies == NULL);
- g_free (stream->requested_url);
- stream->requested_url = NULL;
-
- G_OBJECT_CLASS (swfdec_net_stream_parent_class)->dispose (object);
-}
-
-static gboolean
-swfdec_net_stream_get_variable (SwfdecAsObject *object, SwfdecAsObject *orig,
- const char *variable, SwfdecAsValue *val, guint *flags)
-{
- SwfdecNetStream *stream;
-
- if (SWFDEC_AS_OBJECT_CLASS (swfdec_net_stream_parent_class)->get (object, orig, variable, val, flags))
- return TRUE;
-
- stream = SWFDEC_NET_STREAM (object);
- /* FIXME: need case insensitive comparisons? */
- if (variable == SWFDEC_AS_STR_time) {
- guint msecs;
- if (stream->flvdecoder == NULL ||
- !swfdec_flv_decoder_get_video_info (stream->flvdecoder, &msecs, NULL)) {
- SWFDEC_AS_VALUE_SET_INT (val, 0);
- } else {
- if (msecs >= stream->current_time)
- msecs = 0;
- else
- msecs = stream->current_time - msecs;
- SWFDEC_AS_VALUE_SET_NUMBER (val, msecs / 1000.);
- }
- *flags = 0;
- return TRUE;
- } else if (variable == SWFDEC_AS_STR_bytesLoaded) {
- if (stream->loader == NULL)
- SWFDEC_AS_VALUE_SET_INT (val, 0);
- else
- SWFDEC_AS_VALUE_SET_NUMBER (val, swfdec_loader_get_loaded (stream->loader));
- *flags = 0;
- return TRUE;
- } else if (variable == SWFDEC_AS_STR_bytesTotal) {
- glong bytes;
- if (stream->loader == NULL) {
- bytes = 0;
- } else {
- bytes = swfdec_loader_get_size (stream->loader);
- if (bytes < 0)
- bytes = swfdec_loader_get_loaded (stream->loader);
- }
- SWFDEC_AS_VALUE_SET_NUMBER (val, bytes);
- *flags = 0;
- return TRUE;
- }
- return FALSE;
-}
-
-static void
-swfdec_net_stream_mark (SwfdecAsObject *object)
-{
- SwfdecNetStream *stream = SWFDEC_NET_STREAM (object);
-
- if (stream->conn)
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (stream->conn));
- if (stream->sandbox)
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (stream->sandbox));
-
- SWFDEC_AS_OBJECT_CLASS (swfdec_net_stream_parent_class)->mark (object);
-}
-
-static void
-swfdec_net_stream_class_init (SwfdecNetStreamClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
-
- object_class->dispose = swfdec_net_stream_dispose;
-
- asobject_class->get = swfdec_net_stream_get_variable;
- asobject_class->mark = swfdec_net_stream_mark;
-}
-
-static void
-swfdec_net_stream_init (SwfdecNetStream *stream)
-{
- stream->input.connect = swfdec_net_stream_input_connect;
- stream->input.disconnect = swfdec_net_stream_input_disconnect;
- stream->input.get_image = swfdec_net_stream_input_get_image;
-
- stream->buffer_time = 100; /* msecs */
-}
-
-SwfdecNetStream *
-swfdec_net_stream_new (SwfdecNetConnection *conn)
-{
- SwfdecAsContext *context;
- SwfdecNetStream *stream;
-
- g_return_val_if_fail (SWFDEC_IS_NET_CONNECTION (conn), NULL);
-
- context = SWFDEC_AS_OBJECT (conn)->context;
- if (!swfdec_as_context_use_mem (context, sizeof (SwfdecNetStream)))
- return NULL;
- stream = g_object_new (SWFDEC_TYPE_NET_STREAM, NULL);
- swfdec_as_object_add (SWFDEC_AS_OBJECT (stream), context, sizeof (SwfdecNetStream));
- stream->conn = conn;
-
- return stream;
-}
-
-static void
-swfdec_net_stream_load (SwfdecPlayer *player, gboolean allowed, gpointer streamp)
-{
- SwfdecNetStream *stream = streamp;
- SwfdecLoader *loader;
-
- if (allowed) {
- loader = swfdec_player_load (player, stream->requested_url,
- SWFDEC_LOADER_REQUEST_DEFAULT, NULL);
- swfdec_net_stream_set_loader (stream, loader);
- g_object_unref (loader);
- } else {
- SWFDEC_WARNING ("SECURITY: no access to %s from NetStream",
- stream->requested_url);
- stream->sandbox = NULL;
- }
- g_free (stream->requested_url);
- stream->requested_url = NULL;
-}
-
-void
-swfdec_net_stream_set_url (SwfdecNetStream *stream, SwfdecSandbox *sandbox, const char *url_string)
-{
- SwfdecPlayer *player;
- SwfdecAsContext *cx;
- SwfdecURL *url;
-
- g_return_if_fail (SWFDEC_IS_NET_STREAM (stream));
- g_return_if_fail (SWFDEC_IS_SANDBOX (sandbox));
-
- cx = SWFDEC_AS_OBJECT (stream)->context;
- player = SWFDEC_PLAYER (cx);
-
- if (stream->requested_url != NULL) {
- SWFDEC_FIXME ("can't load %s - already loading %s, what now?",
- url_string, stream->requested_url);
- return;
- }
- stream->requested_url = g_strdup (url_string);
- stream->sandbox = sandbox;
- if (swfdec_url_path_is_relative (url_string)) {
- swfdec_net_stream_load (player, TRUE, stream);
- return;
- }
- url = swfdec_player_create_url (player, url_string);
- if (url == NULL) {
- swfdec_net_stream_load (player, FALSE, stream);
- return;
- }
- if (swfdec_url_is_local (url)) {
- swfdec_net_stream_load (player, TRUE, stream);
- } else {
- switch (sandbox->type) {
- case SWFDEC_SANDBOX_REMOTE:
- swfdec_net_stream_load (player, TRUE, stream);
- break;
- case SWFDEC_SANDBOX_LOCAL_NETWORK:
- case SWFDEC_SANDBOX_LOCAL_TRUSTED:
- {
- SwfdecURL *load_url = swfdec_url_new_components (
- swfdec_url_get_protocol (url), swfdec_url_get_host (url),
- swfdec_url_get_port (url), "crossdomain.xml", NULL);
- swfdec_player_allow_or_load (player, url, load_url,
- swfdec_net_stream_load, stream);
- swfdec_url_free (load_url);
- }
- break;
- case SWFDEC_SANDBOX_LOCAL_FILE:
- swfdec_net_stream_load (player, FALSE, stream);
- break;
- case SWFDEC_SANDBOX_NONE:
- default:
- g_assert_not_reached ();
- break;
- }
- }
-
- swfdec_url_free (url);
-}
-
-void
-swfdec_net_stream_set_loader (SwfdecNetStream *stream, SwfdecLoader *loader)
-{
- g_return_if_fail (SWFDEC_IS_NET_STREAM (stream));
- g_return_if_fail (loader == NULL || SWFDEC_IS_SANDBOX (stream->sandbox));
- g_return_if_fail (loader == NULL || SWFDEC_IS_LOADER (loader));
-
- if (stream->loader) {
- SwfdecStream *lstream = SWFDEC_STREAM (stream->loader);
- swfdec_stream_close (lstream);
- swfdec_stream_set_target (lstream, NULL);
- g_object_unref (lstream);
- }
- if (stream->flvdecoder) {
- g_object_unref (stream->flvdecoder);
- stream->flvdecoder = NULL;
- }
- stream->loader = loader;
- stream->buffering = TRUE;
- if (loader) {
- g_object_ref (loader);
- swfdec_stream_set_target (SWFDEC_STREAM (loader), SWFDEC_STREAM_TARGET (stream));
- }
- swfdec_net_stream_set_playing (stream, TRUE);
-}
-
-void
-swfdec_net_stream_set_playing (SwfdecNetStream *stream, gboolean playing)
-{
- g_return_if_fail (SWFDEC_IS_NET_STREAM (stream));
-
- stream->playing = playing;
-
- swfdec_net_stream_update_playing (stream);
-}
-
-gboolean
-swfdec_net_stream_get_playing (SwfdecNetStream *stream)
-{
- g_return_val_if_fail (SWFDEC_IS_NET_STREAM (stream), FALSE);
-
- return stream->playing;
-}
-
-void
-swfdec_net_stream_set_buffer_time (SwfdecNetStream *stream, double secs)
-{
- g_return_if_fail (SWFDEC_IS_NET_STREAM (stream));
-
- /* FIXME: is this correct? */
- if (secs <= 0)
- return;
-
- stream->buffer_time = secs * 1000;
-}
-
-double
-swfdec_net_stream_get_buffer_time (SwfdecNetStream *stream)
-{
- g_return_val_if_fail (SWFDEC_IS_NET_STREAM (stream), 0.1);
-
- return (double) stream->buffer_time / 1000.0;
-}
-
-void
-swfdec_net_stream_seek (SwfdecNetStream *stream, double secs)
-{
- guint first, last, msecs;
-
- g_return_if_fail (SWFDEC_IS_NET_STREAM (stream));
-
- if (stream->flvdecoder == NULL)
- return;
- if (!isfinite (secs) || secs < 0) {
- SWFDEC_ERROR ("seeking to %g doesn't work", secs);
- return;
- }
- if (!swfdec_flv_decoder_get_video_info (stream->flvdecoder, &first, &last)) {
- SWFDEC_ERROR ("FIXME: implement seeking in audio only NetStream");
- return;
- }
- msecs = secs * 1000;
- msecs += first;
- if (msecs > last)
- msecs = last;
- swfdec_flv_decoder_get_video (stream->flvdecoder, msecs, TRUE, NULL, &msecs, NULL);
- swfdec_net_stream_video_goto (stream, msecs);
- /* FIXME: this needs to be implemented correctly, but requires changes to audio handling:
- * - creating a new audio stream will cause attachAudio scripts to lose information
- * - implementing seek on audio stream requires a SwfdecAudio::changed signal so audio
- * backends can react correctly.
- */
- if (stream->audio) {
- SWFDEC_WARNING ("FIXME: restarting audio after seek");
- swfdec_audio_remove (stream->audio);
- g_object_unref (stream->audio);
- stream->audio = swfdec_audio_flv_new (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (stream)->context),
- stream->flvdecoder, stream->current_time);
- }
-}
-
diff --git a/libswfdec/swfdec_net_stream.h b/libswfdec/swfdec_net_stream.h
deleted file mode 100644
index 943c834..0000000
--- a/libswfdec/swfdec_net_stream.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_NET_STREAM_H_
-#define _SWFDEC_NET_STREAM_H_
-
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_codec_video.h>
-#include <libswfdec/swfdec_net_connection.h>
-#include <libswfdec/swfdec_flv_decoder.h>
-#include <libswfdec/swfdec_player_internal.h>
-#include <libswfdec/swfdec_sandbox.h>
-#include <libswfdec/swfdec_video_movie.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecNetStream SwfdecNetStream;
-typedef struct _SwfdecNetStreamClass SwfdecNetStreamClass;
-
-#define SWFDEC_TYPE_NET_STREAM (swfdec_net_stream_get_type())
-#define SWFDEC_IS_NET_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_NET_STREAM))
-#define SWFDEC_IS_NET_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_NET_STREAM))
-#define SWFDEC_NET_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_NET_STREAM, SwfdecNetStream))
-#define SWFDEC_NET_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_NET_STREAM, SwfdecNetStreamClass))
-#define SWFDEC_NET_STREAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_NET_STREAM, SwfdecNetStreamClass))
-
-struct _SwfdecNetStream
-{
- SwfdecAsObject object;
-
- SwfdecNetConnection * conn; /* connection used for opening streams */
- char * requested_url; /* URL we have requested that isn't loaded yet */
- SwfdecLoader * loader; /* input stream */
- SwfdecSandbox * sandbox; /* sandbox to emit events in */
- SwfdecFlvDecoder * flvdecoder; /* flv decoder */
- gboolean playing; /* TRUE if this stream is playing */
- gboolean buffering; /* TRUE if we're waiting for more input data */
- gboolean error; /* in error */
-
- /* properties */
- guint buffer_time; /* buffering time in msecs */
-
- /* video decoding */
- guint current_time; /* current playback timestamp */
- guint next_time; /* next video image at this timestamp */
- guint format; /* current format */
- SwfdecVideoDecoder * decoder; /* decoder used for decoding */
- cairo_surface_t * surface; /* current image */
- SwfdecTimeout timeout; /* timeout to advance to */
- SwfdecVideoMovieInput input; /* used when attaching to a video movie */
- GList * movies; /* movies we're connected to */
-
- /* audio */
- SwfdecAudio * audio; /* audio stream or NULL when not playing */
-};
-
-struct _SwfdecNetStreamClass
-{
- SwfdecAsObjectClass object_class;
-};
-
-GType swfdec_net_stream_get_type (void);
-
-SwfdecNetStream * swfdec_net_stream_new (SwfdecNetConnection * conn);
-
-void swfdec_net_stream_set_url (SwfdecNetStream * stream,
- SwfdecSandbox * sandbox,
- const char * url);
-void swfdec_net_stream_set_loader (SwfdecNetStream * stream,
- SwfdecLoader * loader);
-void swfdec_net_stream_set_playing (SwfdecNetStream * stream,
- gboolean playing);
-gboolean swfdec_net_stream_get_playing (SwfdecNetStream * stream);
-void swfdec_net_stream_set_buffer_time (SwfdecNetStream * stream,
- double secs);
-double swfdec_net_stream_get_buffer_time (SwfdecNetStream * stream);
-void swfdec_net_stream_seek (SwfdecNetStream * stream,
- double secs);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_net_stream_as.c b/libswfdec/swfdec_net_stream_as.c
deleted file mode 100644
index 1dce4ba..0000000
--- a/libswfdec/swfdec_net_stream_as.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_net_stream.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_native_function.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-#include "swfdec_internal.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_player_internal.h"
-
-SWFDEC_AS_NATIVE (2101, 0, swfdec_net_stream_close)
-void
-swfdec_net_stream_close (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecNetStream *stream;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_NET_STREAM, &stream, "");
-
- swfdec_net_stream_set_loader (stream, NULL);
- swfdec_net_stream_set_playing (stream, TRUE);
-}
-
-static void
-swfdec_net_stream_play (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecNetStream *stream = SWFDEC_NET_STREAM (obj);
- const char *url;
-
- url = swfdec_as_value_to_string (cx, &argv[0]);
- swfdec_net_stream_set_url (stream, SWFDEC_SANDBOX (cx->global), url);
- swfdec_net_stream_set_playing (stream, TRUE);
-}
-
-static void
-swfdec_net_stream_pause (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecNetStream *stream = SWFDEC_NET_STREAM (obj);
- gboolean playing;
-
- if (argc == 0) {
- playing = !swfdec_net_stream_get_playing (stream);
- } else {
- playing = !swfdec_as_value_to_boolean (cx, &argv[0]);
- }
- SWFDEC_LOG ("%s stream %p", playing ? "playing" : "pausing", stream);
- swfdec_net_stream_set_playing (stream, playing);
-}
-
-SWFDEC_AS_NATIVE (2101, 1, swfdec_net_stream_attachAudio)
-void
-swfdec_net_stream_attachAudio (SwfdecAsContext *cx, SwfdecAsObject *obj,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("NetStream.attachAudio");
-}
-
-SWFDEC_AS_NATIVE (2101, 2, swfdec_net_stream_attachVideo)
-void
-swfdec_net_stream_attachVideo (SwfdecAsContext *cx, SwfdecAsObject *obj,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("NetStream.attachVideo");
-}
-
-SWFDEC_AS_NATIVE (2101, 3, swfdec_net_stream_send)
-void
-swfdec_net_stream_send (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("NetStream.send");
-}
-
-SWFDEC_AS_NATIVE (2101, 4, swfdec_net_stream_setBufferTime)
-void
-swfdec_net_stream_setBufferTime (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecNetStream *stream;
- double d;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_NET_STREAM, &stream, "n", &d);
-
- swfdec_net_stream_set_buffer_time (stream, d);
-}
-
-SWFDEC_AS_NATIVE (2101, 5, swfdec_net_stream_get_checkPolicyFile)
-void
-swfdec_net_stream_get_checkPolicyFile (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("NetStream.checkPolicyFile (get)");
-}
-
-SWFDEC_AS_NATIVE (2101, 6, swfdec_net_stream_set_checkPolicyFile)
-void
-swfdec_net_stream_set_checkPolicyFile (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("NetStream.checkPolicyFile (set)");
-}
-
-static void
-swfdec_net_stream_do_seek (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecNetStream *stream = SWFDEC_NET_STREAM (obj);
- double d;
-
- d = swfdec_as_value_to_number (cx, &argv[0]);
- swfdec_net_stream_seek (stream, d);
-}
-
-static void
-swfdec_net_stream_construct (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecNetStream *stream = SWFDEC_NET_STREAM (obj);
- SwfdecNetConnection *conn;
-
- if (!swfdec_as_context_is_constructing (cx)) {
- SWFDEC_FIXME ("What do we do if not constructing?");
- return;
- }
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]) ||
- !SWFDEC_IS_NET_CONNECTION ((conn = (SwfdecNetConnection *) SWFDEC_AS_VALUE_GET_OBJECT (&argv[0])))) {
- SWFDEC_WARNING ("no connection passed to NetStream ()");
- return;
- }
- stream->conn = conn;
-}
-
-void
-swfdec_net_stream_init_context (SwfdecPlayer *player)
-{
- SwfdecAsContext *context;
- SwfdecAsObject *stream, *proto;
- SwfdecAsValue val;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
-
- context = SWFDEC_AS_CONTEXT (player);
- proto = swfdec_as_object_new_empty (context);
- if (proto == NULL)
- return;
- stream = SWFDEC_AS_OBJECT (swfdec_as_object_add_constructor (context->global,
- SWFDEC_AS_STR_NetStream, SWFDEC_TYPE_NET_STREAM, SWFDEC_TYPE_NET_STREAM,
- swfdec_net_stream_construct, 1, proto));
- if (stream == NULL)
- return;
- /* set the right properties on the NetStream.prototype object */
- swfdec_as_object_add_function (proto, SWFDEC_AS_STR_pause, SWFDEC_TYPE_NET_STREAM,
- swfdec_net_stream_pause, 0);
- swfdec_as_object_add_function (proto, SWFDEC_AS_STR_play, SWFDEC_TYPE_NET_STREAM,
- swfdec_net_stream_play, 1);
- swfdec_as_object_add_function (proto, SWFDEC_AS_STR_seek, SWFDEC_TYPE_NET_STREAM,
- swfdec_net_stream_do_seek, 1);
- SWFDEC_AS_VALUE_SET_OBJECT (&val, stream);
- swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
- SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object_prototype);
- swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR___proto__, &val,
- SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
-}
-
diff --git a/libswfdec/swfdec_path.c b/libswfdec/swfdec_path.c
deleted file mode 100644
index d2da710..0000000
--- a/libswfdec/swfdec_path.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "swfdec_path.h"
-#include "swfdec_debug.h"
-
-void
-swfdec_path_init (cairo_path_t *path)
-{
- path->status = CAIRO_STATUS_SUCCESS;
- path->data = NULL;
- path->num_data = 0;
-}
-
-void
-swfdec_path_reset (cairo_path_t *path)
-{
- path->status = CAIRO_STATUS_SUCCESS;
- g_free (path->data);
- path->data = NULL;
- path->num_data = 0;
-}
-
-void
-swfdec_path_ensure_size (cairo_path_t *path, int size)
-{
-#define SWFDEC_PATH_STEPS 32
- /* round up to next multiple of SWFDEC_PATH_STEPS */
- int current_size = path->num_data - path->num_data % SWFDEC_PATH_STEPS;
- if (path->num_data % SWFDEC_PATH_STEPS)
- current_size += SWFDEC_PATH_STEPS;
-
- if (size % SWFDEC_PATH_STEPS)
- size += SWFDEC_PATH_STEPS - size % SWFDEC_PATH_STEPS;
- g_assert (current_size % SWFDEC_PATH_STEPS == 0);
- g_assert (size % SWFDEC_PATH_STEPS == 0);
- while (size <= current_size)
- return;
- SWFDEC_LOG ("extending size of %p from %u to %u", path, current_size, size);
- path->data = g_renew (cairo_path_data_t, path->data, size);
-}
-
-void
-swfdec_path_move_to (cairo_path_t *path, double x, double y)
-{
- cairo_path_data_t *cur;
-
- swfdec_path_require_size (path, 2);
- cur = &path->data[path->num_data++];
- cur->header.type = CAIRO_PATH_MOVE_TO;
- cur->header.length = 2;
- cur = &path->data[path->num_data++];
- cur->point.x = x;
- cur->point.y = y;
-}
-
-void
-swfdec_path_line_to (cairo_path_t *path, double x, double y)
-{
- cairo_path_data_t *cur;
-
- swfdec_path_require_size (path, 2);
- cur = &path->data[path->num_data++];
- cur->header.type = CAIRO_PATH_LINE_TO;
- cur->header.length = 2;
- cur = &path->data[path->num_data++];
- cur->point.x = x;
- cur->point.y = y;
-}
-
-void
-swfdec_path_curve_to (cairo_path_t *path, double start_x, double start_y,
- double control_x, double control_y, double end_x, double end_y)
-{
- cairo_path_data_t *cur;
-
- swfdec_path_require_size (path, 4);
- cur = &path->data[path->num_data++];
- cur->header.type = CAIRO_PATH_CURVE_TO;
- cur->header.length = 4;
-#define WEIGHT (2.0/3.0)
- cur = &path->data[path->num_data++];
- cur->point.x = control_x * WEIGHT + (1-WEIGHT) * start_x;
- cur->point.y = control_y * WEIGHT + (1-WEIGHT) * start_y;
- cur = &path->data[path->num_data++];
- cur->point.x = control_x * WEIGHT + (1-WEIGHT) * end_x;
- cur->point.y = control_y * WEIGHT + (1-WEIGHT) * end_y;
- cur = &path->data[path->num_data++];
- cur->point.x = end_x;
- cur->point.y = end_y;
-}
-
-void
-swfdec_path_append (cairo_path_t *path, const cairo_path_t *append)
-{
- swfdec_path_require_size (path, append->num_data);
- memcpy (&path->data[path->num_data], append->data, sizeof (cairo_path_data_t) * append->num_data);
- path->num_data += append->num_data;
-}
-
-void
-swfdec_path_append_reverse (cairo_path_t *path, const cairo_path_t *append,
- double x, double y)
-{
- cairo_path_data_t *out, *in;
- int i;
-
- swfdec_path_require_size (path, append->num_data);
- path->num_data += append->num_data;
- out = &path->data[path->num_data - 1];
- in = append->data;
- for (i = 0; i < append->num_data; i++) {
- switch (in[i].header.type) {
- case CAIRO_PATH_LINE_TO:
- out[-i].point.x = x;
- out[-i].point.y = y;
- out[-i - 1].header = in[i].header;
- i++;
- break;
- case CAIRO_PATH_CURVE_TO:
- out[-i].point.x = x;
- out[-i].point.y = y;
- out[-i - 3].header = in[i].header;
- out[-i - 1].point = in[i + 1].point;
- out[-i - 2].point = in[i + 2].point;
- i += 3;
- break;
- case CAIRO_PATH_CLOSE_PATH:
- case CAIRO_PATH_MOVE_TO:
- /* these two don't exist in our code */
- default:
- g_assert_not_reached ();
- }
- x = in[i].point.x;
- y = in[i].point.y;
- }
-}
-
-void
-swfdec_path_get_extents (const cairo_path_t *path, SwfdecRect *extents)
-{
- cairo_path_data_t *data = path->data;
- int i;
- double x = 0, y = 0;
- gboolean need_current = TRUE;
- gboolean start = TRUE;
-#define ADD_POINT(extents, x, y) G_STMT_START { \
- if (x < extents->x0) \
- extents->x0 = x; \
- else if (x > extents->x1) \
- extents->x1 = x; \
- if (y < extents->y0) \
- extents->y0 = y; \
- else if (y > extents->y1) \
- extents->y1 = y; \
-} G_STMT_END
- for (i = 0; i < path->num_data; i++) {
- switch (data[i].header.type) {
- case CAIRO_PATH_CURVE_TO:
- if (need_current) {
- if (start) {
- start = FALSE;
- extents->x0 = x;
- extents->x1 = x;
- extents->y0 = y;
- extents->y1 = y;
- } else {
- ADD_POINT (extents, x, y);
- }
- need_current = FALSE;
- }
- ADD_POINT (extents, data[i+1].point.x, data[i+1].point.y);
- ADD_POINT (extents, data[i+2].point.x, data[i+2].point.y);
- ADD_POINT (extents, data[i+3].point.x, data[i+3].point.y);
- i += 3;
- break;
- case CAIRO_PATH_LINE_TO:
- if (need_current) {
- if (start) {
- start = FALSE;
- extents->x0 = x;
- extents->x1 = x;
- extents->y0 = y;
- extents->y1 = y;
- } else {
- ADD_POINT (extents, x, y);
- }
- need_current = FALSE;
- }
- ADD_POINT (extents, data[i+1].point.x, data[i+1].point.y);
- i++;
- break;
- case CAIRO_PATH_CLOSE_PATH:
- x = 0;
- y = 0;
- need_current = TRUE;
- break;
- case CAIRO_PATH_MOVE_TO:
- x = data[i+1].point.x;
- y = data[i+1].point.y;
- need_current = TRUE;
- i++;
- break;
- default:
- g_assert_not_reached ();
- }
- }
-#undef ADD_POINT
-}
-
-void
-swfdec_path_merge (cairo_path_t *dest, const cairo_path_t *start,
- const cairo_path_t *end, double ratio)
-{
- int i;
- cairo_path_data_t *ddata, *sdata, *edata;
- double inv = 1.0 - ratio;
-
- g_assert (start->num_data == end->num_data);
-
- swfdec_path_reset (dest);
- swfdec_path_ensure_size (dest, start->num_data);
- dest->num_data = start->num_data;
- ddata = dest->data;
- sdata = start->data;
- edata = end->data;
- for (i = 0; i < dest->num_data; i++) {
- g_assert (sdata[i].header.type == edata[i].header.type);
- ddata[i] = sdata[i];
- switch (sdata[i].header.type) {
- case CAIRO_PATH_CURVE_TO:
- ddata[i+1].point.x = sdata[i+1].point.x * inv + edata[i+1].point.x * ratio;
- ddata[i+1].point.y = sdata[i+1].point.y * inv + edata[i+1].point.y * ratio;
- ddata[i+2].point.x = sdata[i+2].point.x * inv + edata[i+2].point.x * ratio;
- ddata[i+2].point.y = sdata[i+2].point.y * inv + edata[i+2].point.y * ratio;
- i += 2;
- case CAIRO_PATH_MOVE_TO:
- case CAIRO_PATH_LINE_TO:
- ddata[i+1].point.x = sdata[i+1].point.x * inv + edata[i+1].point.x * ratio;
- ddata[i+1].point.y = sdata[i+1].point.y * inv + edata[i+1].point.y * ratio;
- i++;
- case CAIRO_PATH_CLOSE_PATH:
- break;
- default:
- g_assert_not_reached ();
- }
- }
-}
-
diff --git a/libswfdec/swfdec_path.h b/libswfdec/swfdec_path.h
deleted file mode 100644
index 502a049..0000000
--- a/libswfdec/swfdec_path.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_PATH_H_
-#define _SWFDEC_PATH_H_
-
-#include <cairo.h>
-#include <libswfdec/swfdec_rect.h>
-
-G_BEGIN_DECLS
-
-/* FIXME: Shouldn't this code be in cairo somewhere? */
-
-void swfdec_path_init (cairo_path_t * path);
-void swfdec_path_reset (cairo_path_t * path);
-
-#define swfdec_path_require_size(path, steps) \
- swfdec_path_ensure_size ((path), (path)->num_data + steps)
-void swfdec_path_ensure_size (cairo_path_t * path,
- int size);
-void swfdec_path_move_to (cairo_path_t * path,
- double x,
- double y);
-void swfdec_path_line_to (cairo_path_t * path,
- double x,
- double y);
-void swfdec_path_curve_to (cairo_path_t * path,
- double start_x,
- double start_y,
- double control_x,
- double control_y,
- double end_x,
- double end_y);
-void swfdec_path_append (cairo_path_t * path,
- const cairo_path_t * append);
-void swfdec_path_append_reverse (cairo_path_t * path,
- const cairo_path_t * append,
- double x,
- double y);
-
-void swfdec_path_get_extents (const cairo_path_t * path,
- SwfdecRect * extents);
-
-void swfdec_path_merge (cairo_path_t * dest,
- const cairo_path_t * start,
- const cairo_path_t * end,
- double ratio);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_pattern.c b/libswfdec/swfdec_pattern.c
deleted file mode 100644
index d641556..0000000
--- a/libswfdec/swfdec_pattern.c
+++ /dev/null
@@ -1,559 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-
-#include "swfdec_pattern.h"
-#include "swfdec_bits.h"
-#include "swfdec_color.h"
-#include "swfdec_debug.h"
-#include "swfdec_decoder.h"
-#include "swfdec_gradient_pattern.h"
-#include "swfdec_image.h"
-#include "swfdec_path.h"
-#include "swfdec_stroke.h"
-
-/*** PATTERN ***/
-
-G_DEFINE_ABSTRACT_TYPE (SwfdecPattern, swfdec_pattern, SWFDEC_TYPE_DRAW);
-
-static void
-swfdec_pattern_compute_extents (SwfdecDraw *draw)
-{
- swfdec_path_get_extents (&draw->path, &draw->extents);
-}
-
-static void
-swfdec_pattern_paint (SwfdecDraw *draw, cairo_t *cr, const SwfdecColorTransform *trans)
-{
- cairo_pattern_t *pattern;
-
- pattern = swfdec_pattern_get_pattern (SWFDEC_PATTERN (draw), trans);
- if (pattern == NULL)
- return;
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
- cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
- cairo_append_path (cr, &draw->path);
- cairo_set_source (cr, pattern);
- cairo_pattern_destroy (pattern);
- cairo_fill (cr);
-}
-
-static void
-swfdec_pattern_morph (SwfdecDraw *dest, SwfdecDraw *source, guint ratio)
-{
- SwfdecPattern *dpattern = SWFDEC_PATTERN (dest);
- SwfdecPattern *spattern = SWFDEC_PATTERN (source);
-
- swfdec_matrix_morph (&dpattern->start_transform,
- &spattern->start_transform, &spattern->end_transform, ratio);
- dpattern->transform = dpattern->start_transform;
- if (cairo_matrix_invert (&dpattern->transform)) {
- SWFDEC_ERROR ("morphed paint transform matrix not invertible, using default");
- dpattern->transform = spattern->transform;
- }
-
- SWFDEC_DRAW_CLASS (swfdec_pattern_parent_class)->morph (dest, source, ratio);
-}
-
-static gboolean
-swfdec_pattern_contains (SwfdecDraw *draw, cairo_t *cr, double x, double y)
-{
- cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
- cairo_append_path (cr, &draw->path);
- return cairo_in_fill (cr, x, y);
-}
-
-static void
-swfdec_pattern_class_init (SwfdecPatternClass *klass)
-{
- SwfdecDrawClass *draw_class = SWFDEC_DRAW_CLASS (klass);
-
- draw_class->morph = swfdec_pattern_morph;
- draw_class->paint = swfdec_pattern_paint;
- draw_class->compute_extents = swfdec_pattern_compute_extents;
- draw_class->contains = swfdec_pattern_contains;
-}
-
-static void
-swfdec_pattern_init (SwfdecPattern *pattern)
-{
- cairo_matrix_init_identity (&pattern->transform);
- cairo_matrix_init_identity (&pattern->start_transform);
- cairo_matrix_init_identity (&pattern->end_transform);
-}
-
-/*** COLOR PATTERN ***/
-
-typedef struct _SwfdecColorPattern SwfdecColorPattern;
-typedef struct _SwfdecColorPatternClass SwfdecColorPatternClass;
-
-#define SWFDEC_TYPE_COLOR_PATTERN (swfdec_color_pattern_get_type())
-#define SWFDEC_IS_COLOR_PATTERN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_COLOR_PATTERN))
-#define SWFDEC_IS_COLOR_PATTERN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_COLOR_PATTERN))
-#define SWFDEC_COLOR_PATTERN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_COLOR_PATTERN, SwfdecColorPattern))
-#define SWFDEC_COLOR_PATTERN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_COLOR_PATTERN, SwfdecColorPatternClass))
-#define SWFDEC_COLOR_PATTERN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_COLOR_PATTERN, SwfdecColorPatternClass))
-
-struct _SwfdecColorPattern
-{
- SwfdecPattern pattern;
-
- SwfdecColor start_color; /* color to paint with at the beginning */
- SwfdecColor end_color; /* color to paint with in the end */
-};
-
-struct _SwfdecColorPatternClass
-{
- SwfdecPatternClass pattern_class;
-};
-
-GType swfdec_color_pattern_get_type (void);
-G_DEFINE_TYPE (SwfdecColorPattern, swfdec_color_pattern, SWFDEC_TYPE_PATTERN);
-
-static void
-swfdec_color_pattern_morph (SwfdecDraw *dest, SwfdecDraw *source, guint ratio)
-{
- SwfdecColorPattern *dpattern = SWFDEC_COLOR_PATTERN (dest);
- SwfdecColorPattern *spattern = SWFDEC_COLOR_PATTERN (source);
-
- dpattern->start_color = swfdec_color_apply_morph (spattern->start_color, spattern->end_color, ratio);
-
- SWFDEC_DRAW_CLASS (swfdec_color_pattern_parent_class)->morph (dest, source, ratio);
-}
-
-static cairo_pattern_t *
-swfdec_color_pattern_get_pattern (SwfdecPattern *pat, const SwfdecColorTransform *trans)
-{
- SwfdecColor color = SWFDEC_COLOR_PATTERN (pat)->start_color;
-
- color = swfdec_color_apply_transform (color, trans);
- return cairo_pattern_create_rgba (
- SWFDEC_COLOR_R (color) / 255.0, SWFDEC_COLOR_G (color) / 255.0,
- SWFDEC_COLOR_B (color) / 255.0, SWFDEC_COLOR_A (color) / 255.0);
-}
-
-static void
-swfdec_color_pattern_class_init (SwfdecColorPatternClass *klass)
-{
- SWFDEC_DRAW_CLASS (klass)->morph = swfdec_color_pattern_morph;
-
- SWFDEC_PATTERN_CLASS (klass)->get_pattern = swfdec_color_pattern_get_pattern;
-}
-
-static void
-swfdec_color_pattern_init (SwfdecColorPattern *pattern)
-{
-}
-
-/*** IMAGE PATTERN ***/
-
-typedef struct _SwfdecImagePattern SwfdecImagePattern;
-typedef struct _SwfdecImagePatternClass SwfdecImagePatternClass;
-
-#define SWFDEC_TYPE_IMAGE_PATTERN (swfdec_image_pattern_get_type())
-#define SWFDEC_IS_IMAGE_PATTERN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_IMAGE_PATTERN))
-#define SWFDEC_IS_IMAGE_PATTERN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_IMAGE_PATTERN))
-#define SWFDEC_IMAGE_PATTERN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_IMAGE_PATTERN, SwfdecImagePattern))
-#define SWFDEC_IMAGE_PATTERN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_IMAGE_PATTERN, SwfdecImagePatternClass))
-#define SWFDEC_IMAGE_PATTERN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_IMAGE_PATTERN, SwfdecImagePatternClass))
-
-struct _SwfdecImagePattern
-{
- SwfdecPattern pattern;
-
- SwfdecImage * image; /* image to paint */
- cairo_extend_t extend;
- cairo_filter_t filter;
-};
-
-struct _SwfdecImagePatternClass
-{
- SwfdecPatternClass pattern_class;
-};
-
-GType swfdec_image_pattern_get_type (void);
-G_DEFINE_TYPE (SwfdecImagePattern, swfdec_image_pattern, SWFDEC_TYPE_PATTERN);
-
-static void
-swfdec_image_pattern_morph (SwfdecDraw *dest, SwfdecDraw *source, guint ratio)
-{
- SwfdecImagePattern *dpattern = SWFDEC_IMAGE_PATTERN (dest);
- SwfdecImagePattern *spattern = SWFDEC_IMAGE_PATTERN (source);
-
- dpattern->image = g_object_ref (spattern->image);
- dpattern->extend = spattern->extend;
- dpattern->filter = spattern->filter;
-
- SWFDEC_DRAW_CLASS (swfdec_image_pattern_parent_class)->morph (dest, source, ratio);
-}
-
-static cairo_pattern_t *
-swfdec_image_pattern_get_pattern (SwfdecPattern *pat, const SwfdecColorTransform *trans)
-{
- SwfdecImagePattern *image = SWFDEC_IMAGE_PATTERN (pat);
- cairo_pattern_t *pattern;
- cairo_surface_t *surface;
-
- surface = swfdec_image_create_surface_transformed (image->image, trans);
- if (surface == NULL)
- return NULL;
- pattern = cairo_pattern_create_for_surface (surface);
- cairo_surface_destroy (surface);
- cairo_pattern_set_matrix (pattern, &pat->transform);
- cairo_pattern_set_extend (pattern, image->extend);
- cairo_pattern_set_filter (pattern, image->filter);
- return pattern;
-}
-
-static void
-swfdec_image_pattern_class_init (SwfdecImagePatternClass *klass)
-{
- SWFDEC_DRAW_CLASS (klass)->morph = swfdec_image_pattern_morph;
-
- SWFDEC_PATTERN_CLASS (klass)->get_pattern = swfdec_image_pattern_get_pattern;
-}
-
-static void
-swfdec_image_pattern_init (SwfdecImagePattern *pattern)
-{
-}
-
-/*** EXPORTED API ***/
-
-static SwfdecDraw *
-swfdec_pattern_do_parse (SwfdecBits *bits, SwfdecSwfDecoder *dec, gboolean rgba)
-{
- guint paint_style_type;
- SwfdecPattern *pattern;
-
- paint_style_type = swfdec_bits_get_u8 (bits);
- SWFDEC_LOG (" type 0x%02x", paint_style_type);
-
- if (paint_style_type == 0x00) {
- pattern = g_object_new (SWFDEC_TYPE_COLOR_PATTERN, NULL);
- if (rgba) {
- SWFDEC_COLOR_PATTERN (pattern)->start_color = swfdec_bits_get_rgba (bits);
- } else {
- SWFDEC_COLOR_PATTERN (pattern)->start_color = swfdec_bits_get_color (bits);
- }
- SWFDEC_COLOR_PATTERN (pattern)->end_color = SWFDEC_COLOR_PATTERN (pattern)->start_color;
- SWFDEC_LOG (" color %08x", SWFDEC_COLOR_PATTERN (pattern)->start_color);
- } else if (paint_style_type == 0x10 || paint_style_type == 0x12 || paint_style_type == 0x13) {
- SwfdecGradientPattern *gradient;
- guint i, interpolation;
- pattern = SWFDEC_PATTERN (swfdec_gradient_pattern_new ());
- gradient = SWFDEC_GRADIENT_PATTERN (pattern);
- swfdec_bits_get_matrix (bits, &pattern->start_transform, NULL);
- pattern->end_transform = pattern->start_transform;
- switch (swfdec_bits_getbits (bits, 2)) {
- case 0:
- gradient->extend = CAIRO_EXTEND_PAD;
- break;
- case 1:
- gradient->extend = CAIRO_EXTEND_REFLECT;
- break;
- case 2:
- gradient->extend = CAIRO_EXTEND_REPEAT;
- break;
- case 3:
- SWFDEC_ERROR ("spread mode 3 is undefined for gradients");
- gradient->extend = CAIRO_EXTEND_PAD;
- break;
- default:
- g_assert_not_reached ();
- }
- interpolation = swfdec_bits_getbits (bits, 2);
- if (interpolation) {
- SWFDEC_FIXME ("only normal interpolation is implemented, mode %u is not", interpolation);
- }
- gradient->n_gradients = swfdec_bits_getbits (bits, 4);
- for (i = 0; i < gradient->n_gradients; i++) {
- gradient->gradient[i].ratio = swfdec_bits_get_u8 (bits);
- if (rgba)
- gradient->gradient[i].color = swfdec_bits_get_rgba (bits);
- else
- gradient->gradient[i].color = swfdec_bits_get_color (bits);
- }
- gradient->radial = (paint_style_type != 0x10);
- /* FIXME: need a way to ensure 0x13 only happens in Flash 8 */
- if (paint_style_type == 0x13) {
- gradient->focus = swfdec_bits_get_s16 (bits) / 256.0;
- }
- } else if (paint_style_type >= 0x40 && paint_style_type <= 0x43) {
- guint paint_id = swfdec_bits_get_u16 (bits);
- SWFDEC_LOG (" background paint id = %d (type 0x%02x)",
- paint_id, paint_style_type);
- if (paint_id == 65535) {
- /* FIXME: someone explain this magic paint id here */
- pattern = g_object_new (SWFDEC_TYPE_COLOR_PATTERN, NULL);
- SWFDEC_COLOR_PATTERN (pattern)->start_color = SWFDEC_COLOR_COMBINE (0, 255, 255, 255);
- SWFDEC_COLOR_PATTERN (pattern)->end_color = SWFDEC_COLOR_PATTERN (pattern)->start_color;
- swfdec_bits_get_matrix (bits, &pattern->start_transform, NULL);
- pattern->end_transform = pattern->start_transform;
- } else {
- pattern = g_object_new (SWFDEC_TYPE_IMAGE_PATTERN, NULL);
- swfdec_bits_get_matrix (bits, &pattern->start_transform, NULL);
- pattern->end_transform = pattern->start_transform;
- SWFDEC_IMAGE_PATTERN (pattern)->image = swfdec_swf_decoder_get_character (dec, paint_id);
- if (!SWFDEC_IS_IMAGE (SWFDEC_IMAGE_PATTERN (pattern)->image)) {
- g_object_unref (pattern);
- SWFDEC_ERROR ("could not find image with id %u for pattern", paint_id);
- return NULL;
- }
- if (paint_style_type == 0x40 || paint_style_type == 0x42) {
- SWFDEC_IMAGE_PATTERN (pattern)->extend = CAIRO_EXTEND_REPEAT;
- } else {
-#if 0
- /* not implemented yet in cairo */
- SWFDEC_IMAGE_PATTERN (pattern)->extend = CAIRO_EXTEND_PAD;
-#else
- SWFDEC_FIXME ("CAIRO_EXTEND_PAD is not yet implemented");
- SWFDEC_IMAGE_PATTERN (pattern)->extend = CAIRO_EXTEND_NONE;
-#endif
- }
- if (paint_style_type == 0x40 || paint_style_type == 0x41) {
- SWFDEC_IMAGE_PATTERN (pattern)->filter = CAIRO_FILTER_BILINEAR;
- } else {
- SWFDEC_IMAGE_PATTERN (pattern)->filter = CAIRO_FILTER_NEAREST;
- }
- }
- } else {
- SWFDEC_ERROR ("unknown paint style type 0x%02x", paint_style_type);
- return NULL;
- }
- pattern->transform = pattern->start_transform;
- if (cairo_matrix_invert (&pattern->transform)) {
- SWFDEC_ERROR ("paint transform matrix not invertible, resetting");
- cairo_matrix_init_identity (&pattern->transform);
- }
- swfdec_bits_syncbits (bits);
- return SWFDEC_DRAW (pattern);
-}
-
-/**
- * swfdec_pattern_parse:
- * @bits: the bits to parse from
- * @dec: a #SwfdecDecoder to take context from
- * @rgba: TRUE if colors are RGBA, FALSE if they're just RGB
- *
- * Continues parsing @dec into a new #SwfdecPattern
- *
- * Returns: a new #SwfdecPattern or NULL on error
- **/
-SwfdecDraw *
-swfdec_pattern_parse (SwfdecBits *bits, SwfdecSwfDecoder *dec)
-{
- g_return_val_if_fail (bits != NULL, NULL);
- g_return_val_if_fail (SWFDEC_IS_SWF_DECODER (dec), NULL);
-
- return swfdec_pattern_do_parse (bits, dec, FALSE);
-}
-
-SwfdecDraw *
-swfdec_pattern_parse_rgba (SwfdecBits *bits, SwfdecSwfDecoder *dec)
-{
- g_return_val_if_fail (bits != NULL, NULL);
- g_return_val_if_fail (SWFDEC_IS_SWF_DECODER (dec), NULL);
-
- return swfdec_pattern_do_parse (bits, dec, TRUE);
-}
-
-/**
- * swfdec_pattern_parse_morph:
- * @dec: a #SwfdecDecoder to parse from
- *
- * Continues parsing @dec into a new #SwfdecPattern. This function is used by
- * morph shapes.
- *
- * Returns: a new #SwfdecPattern or NULL on error
- **/
-SwfdecDraw *
-swfdec_pattern_parse_morph (SwfdecBits *bits, SwfdecSwfDecoder *dec)
-{
- guint paint_style_type;
- SwfdecPattern *pattern;
-
- g_return_val_if_fail (bits != NULL, NULL);
- g_return_val_if_fail (SWFDEC_IS_SWF_DECODER (dec), NULL);
-
- paint_style_type = swfdec_bits_get_u8 (bits);
- SWFDEC_LOG (" type 0x%02x", paint_style_type);
-
- if (paint_style_type == 0x00) {
- pattern = g_object_new (SWFDEC_TYPE_COLOR_PATTERN, NULL);
- SWFDEC_COLOR_PATTERN (pattern)->start_color = swfdec_bits_get_rgba (bits);
- SWFDEC_COLOR_PATTERN (pattern)->end_color = swfdec_bits_get_rgba (bits);
- SWFDEC_LOG (" color %08x => %08x", SWFDEC_COLOR_PATTERN (pattern)->start_color,
- SWFDEC_COLOR_PATTERN (pattern)->end_color);
- } else if (paint_style_type == 0x10 || paint_style_type == 0x12 || paint_style_type == 0x13) {
- SwfdecGradientPattern *gradient;
- guint i, interpolation;
- pattern = SWFDEC_PATTERN (swfdec_gradient_pattern_new ());
- gradient = SWFDEC_GRADIENT_PATTERN (pattern);
- swfdec_bits_get_matrix (bits, &pattern->start_transform, NULL);
- swfdec_bits_get_matrix (bits, &pattern->end_transform, NULL);
- switch (swfdec_bits_getbits (bits, 2)) {
- case 0:
- gradient->extend = CAIRO_EXTEND_PAD;
- break;
- case 1:
- gradient->extend = CAIRO_EXTEND_REFLECT;
- break;
- case 2:
- gradient->extend = CAIRO_EXTEND_REPEAT;
- break;
- case 3:
- SWFDEC_ERROR ("spread mode 3 is undefined for gradients");
- gradient->extend = CAIRO_EXTEND_PAD;
- break;
- default:
- g_assert_not_reached ();
- }
- interpolation = swfdec_bits_getbits (bits, 2);
- if (interpolation) {
- SWFDEC_FIXME ("only normal interpolation is implemented, mode %u is not", interpolation);
- }
- gradient->n_gradients = swfdec_bits_getbits (bits, 4);
- for (i = 0; i < gradient->n_gradients; i++) {
- gradient->gradient[i].ratio = swfdec_bits_get_u8 (bits);
- gradient->gradient[i].color = swfdec_bits_get_rgba (bits);
- gradient->end_gradient[i].ratio = swfdec_bits_get_u8 (bits);
- gradient->end_gradient[i].color = swfdec_bits_get_rgba (bits);
- }
- gradient->radial = (paint_style_type != 0x10);
- /* FIXME: need a way to ensure 0x13 only happens in Flash 8 */
- if (paint_style_type == 0x13) {
- gradient->focus = swfdec_bits_get_s16 (bits) / 256.0;
- }
- } else if (paint_style_type >= 0x40 && paint_style_type <= 0x43) {
- guint paint_id = swfdec_bits_get_u16 (bits);
- SWFDEC_LOG (" background paint id = %d (type 0x%02x)",
- paint_id, paint_style_type);
- if (paint_id == 65535) {
- /* FIXME: someone explain this magic paint id here */
- pattern = g_object_new (SWFDEC_TYPE_COLOR_PATTERN, NULL);
- SWFDEC_COLOR_PATTERN (pattern)->start_color = SWFDEC_COLOR_COMBINE (0, 255, 255, 255);
- SWFDEC_COLOR_PATTERN (pattern)->end_color = SWFDEC_COLOR_PATTERN (pattern)->start_color;
- swfdec_bits_get_matrix (bits, &pattern->start_transform, NULL);
- swfdec_bits_get_matrix (bits, &pattern->end_transform, NULL);
- } else {
- pattern = g_object_new (SWFDEC_TYPE_IMAGE_PATTERN, NULL);
- swfdec_bits_get_matrix (bits, &pattern->start_transform, NULL);
- swfdec_bits_get_matrix (bits, &pattern->end_transform, NULL);
- SWFDEC_IMAGE_PATTERN (pattern)->image = swfdec_swf_decoder_get_character (dec, paint_id);
- if (!SWFDEC_IS_IMAGE (SWFDEC_IMAGE_PATTERN (pattern)->image)) {
- g_object_unref (pattern);
- SWFDEC_ERROR ("could not find image with id %u for pattern", paint_id);
- return NULL;
- }
- if (paint_style_type == 0x40 || paint_style_type == 0x42) {
- SWFDEC_IMAGE_PATTERN (pattern)->extend = CAIRO_EXTEND_REPEAT;
- } else {
-#if 0
- /* not implemented yet in cairo */
- SWFDEC_IMAGE_PATTERN (pattern)->extend = CAIRO_EXTEND_PAD;
-#else
- SWFDEC_FIXME ("CAIRO_EXTEND_PAD is not yet implemented");
- SWFDEC_IMAGE_PATTERN (pattern)->extend = CAIRO_EXTEND_NONE;
-#endif
- }
- if (paint_style_type == 0x40 || paint_style_type == 0x41) {
- SWFDEC_IMAGE_PATTERN (pattern)->filter = CAIRO_FILTER_BILINEAR;
- } else {
- SWFDEC_IMAGE_PATTERN (pattern)->filter = CAIRO_FILTER_NEAREST;
- }
- }
- } else {
- SWFDEC_ERROR ("unknown paint style type 0x%02x", paint_style_type);
- return NULL;
- }
- pattern->transform = pattern->start_transform;
- if (cairo_matrix_invert (&pattern->transform)) {
- SWFDEC_ERROR ("paint transform matrix not invertible, resetting");
- cairo_matrix_init_identity (&pattern->transform);
- }
- swfdec_bits_syncbits (bits);
- return SWFDEC_DRAW (pattern);
-}
-
-/**
- * swfdec_pattern_new_color:
- * @color: color to paint in
- *
- * Creates a new pattern to paint with the given color
- *
- * Returns: a new @SwfdecPattern to paint with
- */
-SwfdecPattern *
-swfdec_pattern_new_color (SwfdecColor color)
-{
- SwfdecPattern *pattern = g_object_new (SWFDEC_TYPE_COLOR_PATTERN, NULL);
-
- SWFDEC_COLOR_PATTERN (pattern)->start_color = color;
- SWFDEC_COLOR_PATTERN (pattern)->end_color = color;
-
- return pattern;
-}
-
-char *
-swfdec_pattern_to_string (SwfdecPattern *pattern)
-{
- g_return_val_if_fail (SWFDEC_IS_PATTERN (pattern), NULL);
-
- if (SWFDEC_IS_IMAGE_PATTERN (pattern)) {
- SwfdecImagePattern *image = SWFDEC_IMAGE_PATTERN (pattern);
- if (image->image->width == 0)
- cairo_surface_destroy (swfdec_image_create_surface (image->image));
- return g_strdup_printf ("%ux%u image %u (%s, %s)", image->image->width,
- image->image->height, SWFDEC_CHARACTER (image->image)->id,
- image->extend == CAIRO_EXTEND_REPEAT ? "repeat" : "no repeat",
- image->filter == CAIRO_FILTER_BILINEAR ? "bilinear" : "nearest");
- } else if (SWFDEC_IS_COLOR_PATTERN (pattern)) {
- if (SWFDEC_COLOR_PATTERN (pattern)->start_color == SWFDEC_COLOR_PATTERN (pattern)->end_color)
- return g_strdup_printf ("color #%08X", SWFDEC_COLOR_PATTERN (pattern)->start_color);
- else
- return g_strdup_printf ("color #%08X => #%08X", SWFDEC_COLOR_PATTERN (pattern)->start_color,
- SWFDEC_COLOR_PATTERN (pattern)->end_color);
- } else if (SWFDEC_IS_GRADIENT_PATTERN (pattern)) {
- SwfdecGradientPattern *gradient = SWFDEC_GRADIENT_PATTERN (pattern);
- return g_strdup_printf ("%s gradient (%u colors)", gradient->radial ? "radial" : "linear",
- gradient->n_gradients);
- } else {
- return g_strdup_printf ("%s", G_OBJECT_TYPE_NAME (pattern));
- }
-}
-
-cairo_pattern_t *
-swfdec_pattern_get_pattern (SwfdecPattern *pattern, const SwfdecColorTransform *trans)
-{
- SwfdecPatternClass *klass;
-
- g_return_val_if_fail (SWFDEC_IS_PATTERN (pattern), NULL);
- g_return_val_if_fail (trans != NULL, NULL);
-
- klass = SWFDEC_PATTERN_GET_CLASS (pattern);
- g_assert (klass->get_pattern);
- return klass->get_pattern (pattern, trans);
-}
-
diff --git a/libswfdec/swfdec_pattern.h b/libswfdec/swfdec_pattern.h
deleted file mode 100644
index 3fdcf99..0000000
--- a/libswfdec/swfdec_pattern.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_PATTERN_H_
-#define _SWFDEC_PATTERN_H_
-
-#include <glib-object.h>
-#include <cairo.h>
-#include <libswfdec/swfdec_draw.h>
-#include <libswfdec/swfdec_swf_decoder.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecPattern SwfdecPattern;
-typedef struct _SwfdecPatternClass SwfdecPatternClass;
-
-#define SWFDEC_TYPE_PATTERN (swfdec_pattern_get_type())
-#define SWFDEC_IS_PATTERN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_PATTERN))
-#define SWFDEC_IS_PATTERN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_PATTERN))
-#define SWFDEC_PATTERN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_PATTERN, SwfdecPattern))
-#define SWFDEC_PATTERN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_PATTERN, SwfdecPatternClass))
-#define SWFDEC_PATTERN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_PATTERN, SwfdecPatternClass))
-
-struct _SwfdecPattern
-{
- SwfdecDraw draw;
-
- cairo_matrix_t transform; /* user-to-pattern transform */
- cairo_matrix_t start_transform; /* start transform */
- cairo_matrix_t end_transform; /* end transform (if morph) */
-};
-
-struct _SwfdecPatternClass
-{
- SwfdecDrawClass draw_class;
-
- /* create a cairo pattern for the given values */
- cairo_pattern_t * (* get_pattern) (SwfdecPattern * pattern,
- const SwfdecColorTransform * trans);
-};
-
-GType swfdec_pattern_get_type (void);
-
-SwfdecPattern * swfdec_pattern_new_color (SwfdecColor color);
-SwfdecDraw * swfdec_pattern_parse (SwfdecBits * bits,
- SwfdecSwfDecoder * dec);
-SwfdecDraw * swfdec_pattern_parse_rgba (SwfdecBits * bits,
- SwfdecSwfDecoder * dec);
-SwfdecDraw * swfdec_pattern_parse_morph (SwfdecBits * bits,
- SwfdecSwfDecoder * dec);
-
-cairo_pattern_t *swfdec_pattern_get_pattern (SwfdecPattern * pattern,
- const SwfdecColorTransform * trans);
-
-/* debug */
-char * swfdec_pattern_to_string (SwfdecPattern * pattern);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
deleted file mode 100644
index 5b996ef..0000000
--- a/libswfdec/swfdec_player.c
+++ /dev/null
@@ -1,3030 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <errno.h>
-#include <math.h>
-#include <string.h>
-#include <stdlib.h>
-#include <liboil/liboil.h>
-
-#include "swfdec_player_internal.h"
-#include "swfdec_as_frame_internal.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_audio_internal.h"
-#include "swfdec_button_movie.h" /* for mouse cursor */
-#include "swfdec_cache.h"
-#include "swfdec_debug.h"
-#include "swfdec_enums.h"
-#include "swfdec_event.h"
-#include "swfdec_loader_internal.h"
-#include "swfdec_marshal.h"
-#include "swfdec_movie.h"
-#include "swfdec_resource.h"
-#include "swfdec_script_internal.h"
-#include "swfdec_sprite_movie.h"
-#include "swfdec_utils.h"
-
-/*** gtk-doc ***/
-
-/**
- * SECTION:SwfdecPlayer
- * @title: SwfdecPlayer
- * @short_description: main playback object
- *
- * A #SwfdecPlayer is the main object used for playing back Flash files through
- * Swfdec.
- *
- * A player interacts with the outside world in a multitude of ways. The most
- * important ones are described below.
- *
- * Input is handled via the
- * <link linkend="swfdec-SwfdecLoader">SwfdecLoader</link> class. A
- * #SwfdecLoader is set on a new player using swfdec_player_set_loader().
- *
- * When the loader has provided enough data, you can start playing the file.
- * This is done in steps by calling swfdec_player_advance() - preferrably as
- * often as swfdec_player_get_next_event() indicates. Or you can provide user input
- * to the player by calling for example swfdec_player_handle_mouse().
- *
- * You can use swfdec_player_render() to draw the current state of the player.
- * After that, connect to the SwfdecPlayer::invalidate signal to be notified of
- * changes.
- *
- * Audio output is handled via the
- * <link linkend="swfdec-SwfdecAudio">SwfdecAudio</link> class. One
- * #SwfdecAudio object is created for every output using the
- * SwfdecPlayer::audio-added signal.
- */
-
-/**
- * SwfdecPlayer:
- *
- * This is the base object used for playing Flash files.
- */
-
-/**
- * SECTION:Enumerations
- * @title: Enumerations
- * @short_description: enumerations used in Swfdec
- *
- * This file lists all of the enumerations used in various parts of Swfdec.
- */
-
-/**
- * SwfdecMouseCursor:
- * @SWFDEC_MOUSE_CURSOR_NORMAL: a normal mouse cursor
- * @SWFDEC_MOUSE_CURSOR_NONE: no mouse image
- * @SWFDEC_MOUSE_CURSOR_TEXT: a mouse cursor suitable for text editing
- * @SWFDEC_MOUSE_CURSOR_CLICK: a mouse cursor for clicking a hyperlink or a
- * button
- *
- * This enumeration describes the possible types for the SwfdecPlayer::mouse-cursor
- * property.
- */
-
-/**
- * SwfdecAlignment:
- * @SWFDEC_ALIGNMENT_TOP_LEFT: top left
- * @SWFDEC_ALIGNMENT_TOP: top
- * @SWFDEC_ALIGNMENT_TOP_RIGHT: top right
- * @SWFDEC_ALIGNMENT_LEFT: left
- * @SWFDEC_ALIGNMENT_CENTER: center
- * @SWFDEC_ALIGNMENT_RIGHT: right
- * @SWFDEC_ALIGNMENT_BOTTOM_LEFT: left
- * @SWFDEC_ALIGNMENT_BOTTOM: bottom
- * @SWFDEC_ALIGNMENT_BOTTOM_RIGHT: bottom right
- *
- * These are the possible values for the alignment of an unscaled movie.
- */
-
-/**
- * SwfdecScaleMode:
- * @SWFDEC_SCALE_SHOW_ALL: Show the whole content as large as possible
- * @SWFDEC_SCALE_NO_BORDER: Fill the whole area, possibly cropping parts
- * @SWFDEC_SCALE_EXACT_FIT: Fill the whole area, don't keep aspect ratio
- * @SWFDEC_SCALE_NONE: Do not scale the movie at all
- *
- * Describes how the movie should be scaled if the given size doesn't equal the
- * movie's size.
- */
-
-/**
- * SwfdecKey:
- * @SWFDEC_KEY_BACKSPACE: the backspace key
- * @SWFDEC_KEY_TAB: the tab key
- * @SWFDEC_KEY_CLEAR: the clear key
- * @SWFDEC_KEY_ENTER: the enter key
- * @SWFDEC_KEY_SHIFT: the shift key
- * @SWFDEC_KEY_CONTROL: the control key
- * @SWFDEC_KEY_ALT: the alt key
- * @SWFDEC_KEY_CAPS_LOCK: the caps lock key
- * @SWFDEC_KEY_ESCAPE: the escape key
- * @SWFDEC_KEY_SPACE: the space key
- * @SWFDEC_KEY_PAGE_UP: the page up key
- * @SWFDEC_KEY_PAGE_DOWN: the page down key
- * @SWFDEC_KEY_END: the end key
- * @SWFDEC_KEY_HOME: the home key
- * @SWFDEC_KEY_LEFT: the left key
- * @SWFDEC_KEY_UP: the up key
- * @SWFDEC_KEY_RIGHT: the right key
- * @SWFDEC_KEY_DOWN: the down key
- * @SWFDEC_KEY_INSERT: the insert key
- * @SWFDEC_KEY_DELETE: the delete key
- * @SWFDEC_KEY_HELP: the help key
- * @SWFDEC_KEY_0: the 0 key
- * @SWFDEC_KEY_1: the 1 key
- * @SWFDEC_KEY_2: the 2 key
- * @SWFDEC_KEY_3: the 3 key
- * @SWFDEC_KEY_4: the 4 key
- * @SWFDEC_KEY_5: the 5 key
- * @SWFDEC_KEY_6: the 6 key
- * @SWFDEC_KEY_7: the 7 key
- * @SWFDEC_KEY_8: the 8 key
- * @SWFDEC_KEY_9: the 9 key
- * @SWFDEC_KEY_A: the ! key
- * @SWFDEC_KEY_B: the B key
- * @SWFDEC_KEY_C: the C key
- * @SWFDEC_KEY_D: the D key
- * @SWFDEC_KEY_E: the E key
- * @SWFDEC_KEY_F: the F key
- * @SWFDEC_KEY_G: the G key
- * @SWFDEC_KEY_H: the H key
- * @SWFDEC_KEY_I: the I key
- * @SWFDEC_KEY_J: the J key
- * @SWFDEC_KEY_K: the K key
- * @SWFDEC_KEY_L: the L key
- * @SWFDEC_KEY_M: the M key
- * @SWFDEC_KEY_N: the N key
- * @SWFDEC_KEY_O: the O key
- * @SWFDEC_KEY_P: the P key
- * @SWFDEC_KEY_Q: the Q key
- * @SWFDEC_KEY_R: the R key
- * @SWFDEC_KEY_S: the S key
- * @SWFDEC_KEY_T: the T key
- * @SWFDEC_KEY_U: the U key
- * @SWFDEC_KEY_V: the V key
- * @SWFDEC_KEY_W: the W key
- * @SWFDEC_KEY_X: the X key
- * @SWFDEC_KEY_Y: the Y key
- * @SWFDEC_KEY_Z: the Z key
- * @SWFDEC_KEY_NUMPAD_0: the 0 key on the numeric keypad
- * @SWFDEC_KEY_NUMPAD_1: the 1 key on the numeric keypad
- * @SWFDEC_KEY_NUMPAD_2: the 2 key on the numeric keypad
- * @SWFDEC_KEY_NUMPAD_3: the 3 key on the numeric keypad
- * @SWFDEC_KEY_NUMPAD_4: the 4 key on the numeric keypad
- * @SWFDEC_KEY_NUMPAD_5: the 5 key on the numeric keypad
- * @SWFDEC_KEY_NUMPAD_6: the 6 key on the numeric keypad
- * @SWFDEC_KEY_NUMPAD_7: the 7 key on the numeric keypad
- * @SWFDEC_KEY_NUMPAD_8: the 8 key on the numeric keypad
- * @SWFDEC_KEY_NUMPAD_9: the 9 key on the numeric keypad
- * @SWFDEC_KEY_NUMPAD_MULTIPLY: the multiply key on the numeric keypad
- * @SWFDEC_KEY_NUMPAD_ADD: the add key on the numeric keypad
- * @SWFDEC_KEY_NUMPAD_SUBTRACT: the subtract key on the numeric keypad
- * @SWFDEC_KEY_NUMPAD_DECIMAL: the decimal key on the numeric keypad
- * @SWFDEC_KEY_NUMPAD_DIVIDE: the divide key on the numeric keypad
- * @SWFDEC_KEY_F1: the F1 key
- * @SWFDEC_KEY_F2: the F2 key
- * @SWFDEC_KEY_F3: the F3 key
- * @SWFDEC_KEY_F4: the F4 key
- * @SWFDEC_KEY_F5: the F5 key
- * @SWFDEC_KEY_F6: the F6 key
- * @SWFDEC_KEY_F7: the F7 key
- * @SWFDEC_KEY_F8: the F8 key
- * @SWFDEC_KEY_F9: the F9 key
- * @SWFDEC_KEY_F10: the F10 key
- * @SWFDEC_KEY_F11: the F11 key
- * @SWFDEC_KEY_F12: the F12 key
- * @SWFDEC_KEY_F13: the F13 key
- * @SWFDEC_KEY_F14: the F14 key
- * @SWFDEC_KEY_F15: the F15 key
- * @SWFDEC_KEY_NUM_LOCK: the num lock key
- * @SWFDEC_KEY_SEMICOLON: the semicolon key (on English keyboards)
- * @SWFDEC_KEY_EQUAL: the equal key (on English keyboards)
- * @SWFDEC_KEY_MINUS: the minus key (on English keyboards)
- * @SWFDEC_KEY_SLASH: the slash key (on English keyboards)
- * @SWFDEC_KEY_GRAVE: the grave key (on English keyboards)
- * @SWFDEC_KEY_LEFT_BRACKET: the left bracket key (on English keyboards)
- * @SWFDEC_KEY_BACKSLASH: the backslash key (on English keyboards)
- * @SWFDEC_KEY_RIGHT_BRACKET: the right bracket key (on English keyboards)
- * @SWFDEC_KEY_APOSTROPHE: the apostrophe key (on English keyboards)
- *
- * Lists all known key codes in Swfdec and their meanings on an English
- * keyboard.
- */
-
-/*** Timeouts ***/
-
-static SwfdecTick
-swfdec_player_get_next_event_time (SwfdecPlayer *player)
-{
- SwfdecPlayerPrivate *priv = player->priv;
-
- if (priv->timeouts) {
- return ((SwfdecTimeout *) priv->timeouts->data)->timestamp - priv->time;
- } else {
- return G_MAXUINT64;
- }
-}
-
-/**
- * swfdec_player_add_timeout:
- * @player: a #SwfdecPlayer
- * @timeout: timeout to add
- *
- * Adds a timeout to @player. The timeout will be removed automatically when
- * triggered, so you need to use swfdec_player_add_timeout() to add it again.
- * The #SwfdecTimeout struct and callback does not use a data callback pointer.
- * It's suggested that you use the struct as part of your own bigger struct
- * and get it back like this:
- * <programlisting>
- * typedef struct {
- * // ...
- * SwfdecTimeout timeout;
- * } MyStruct;
- *
- * static void
- * my_struct_timeout_callback (SwfdecTimeout *timeout)
- * {
- * MyStruct *mystruct = (MyStruct *) ((void *) timeout - G_STRUCT_OFFSET (MyStruct, timeout));
- *
- * // do stuff
- * }
- * </programlisting>
- **/
-void
-swfdec_player_add_timeout (SwfdecPlayer *player, SwfdecTimeout *timeout)
-{
- SwfdecPlayerPrivate *priv;
- GList *walk;
- SwfdecTick next_tick;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (timeout != NULL);
- g_return_if_fail (timeout->timestamp >= player->priv->time);
- g_return_if_fail (timeout->callback != NULL);
-
- priv = player->priv;
- SWFDEC_LOG ("adding timeout %p in %"G_GUINT64_FORMAT" msecs", timeout,
- SWFDEC_TICKS_TO_MSECS (timeout->timestamp - priv->time));
- next_tick = swfdec_player_get_next_event_time (player);
- /* the order is important, on events with the same time, we make sure the new one is last */
- for (walk = priv->timeouts; walk; walk = walk->next) {
- SwfdecTimeout *cur = walk->data;
- if (cur->timestamp > timeout->timestamp)
- break;
- }
- priv->timeouts = g_list_insert_before (priv->timeouts, walk, timeout);
- if (next_tick != swfdec_player_get_next_event_time (player))
- g_object_notify (G_OBJECT (player), "next-event");
-}
-
-/**
- * swfdec_player_remove_timeout:
- * @player: a #SwfdecPlayer
- * @timeout: a timeout that should be removed
- *
- * Removes the @timeout from the list of scheduled timeouts. The timeout must
- * have been added with swfdec_player_add_timeout() before.
- **/
-void
-swfdec_player_remove_timeout (SwfdecPlayer *player, SwfdecTimeout *timeout)
-{
- SwfdecPlayerPrivate *priv;
- SwfdecTick next_tick;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (timeout != NULL);
- g_return_if_fail (timeout->timestamp >= player->priv->time);
- g_return_if_fail (timeout->callback != NULL);
-
- SWFDEC_LOG ("removing timeout %p", timeout);
- priv = player->priv;
- next_tick = swfdec_player_get_next_event_time (player);
- priv->timeouts = g_list_remove (priv->timeouts, timeout);
- if (next_tick != swfdec_player_get_next_event_time (player))
- g_object_notify (G_OBJECT (player), "next-event");
-}
-
-/*** Actions ***/
-
-typedef struct {
- SwfdecMovie * movie; /* the movie to trigger the action on */
- SwfdecScript * script; /* script to execute or NULL to trigger action */
- SwfdecEventType event; /* the action to trigger */
-} SwfdecPlayerAction;
-
-typedef struct {
- gpointer object;
- SwfdecActionFunc func;
- gpointer data;
-} SwfdecPlayerExternalAction;
-
-static void
-swfdec_player_compress_actions (SwfdecRingBuffer *buffer)
-{
- SwfdecPlayerAction *action, tmp;
- guint i = 0;
-
- for (i = swfdec_ring_buffer_get_n_elements (buffer); i > 0; i--) {
- action = swfdec_ring_buffer_pop (buffer);
- g_assert (action);
- if (action->movie == NULL)
- continue;
- tmp = *action;
- action = swfdec_ring_buffer_push (buffer);
- *action = tmp;
- }
- SWFDEC_INFO ("compresed action queue to %u elements",
- swfdec_ring_buffer_get_n_elements (buffer));
- for (i = 0; i < swfdec_ring_buffer_get_n_elements (buffer); i++) {
- action = swfdec_ring_buffer_peek_nth (buffer, i);
- g_assert (action->movie != NULL);
- }
-}
-
-static void
-swfdec_player_do_add_action (SwfdecPlayer *player, guint importance, SwfdecPlayerAction *act)
-{
- SwfdecPlayerPrivate *priv = player->priv;
- SwfdecPlayerAction *action = swfdec_ring_buffer_push (priv->actions[importance]);
- if (action == NULL) {
- /* try to get rid of freed actions */
- swfdec_player_compress_actions (priv->actions[importance]);
- action = swfdec_ring_buffer_push (priv->actions[importance]);
- if (action == NULL) {
- if (swfdec_ring_buffer_get_size (priv->actions[importance]) == 256) {
- SWFDEC_WARNING ("256 levels of recursion were exceeded in one action list.");
- }
- swfdec_ring_buffer_set_size (priv->actions[importance],
- swfdec_ring_buffer_get_size (priv->actions[importance]) + 16);
- action = swfdec_ring_buffer_push (priv->actions[importance]);
- g_assert (action);
- }
- }
- *action = *act;
-}
-
-/**
- * swfdec_player_add_event:
- * @player: a #SwfdecPlayer
- * @movie: the movie on which to trigger the event
- * @type: type of the event
- * @importance: importance of the event
- *
- * Adds an action to the @player. Actions are used by Flash player to solve
- * reentrancy issues. Instead of calling back into the Actionscript engine,
- * an action is queued for later execution. So if you're writing code that
- * is calling Actionscript code, you want to do this by using actions.
- **/
-void
-swfdec_player_add_action (SwfdecPlayer *player, SwfdecMovie *movie, SwfdecEventType type,
- guint importance)
-{
- SwfdecPlayerAction action = { movie, NULL, type };
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
- g_return_if_fail (importance < SWFDEC_PLAYER_N_ACTION_QUEUES);
-
- SWFDEC_LOG ("adding action %s %u", movie->name, type);
- swfdec_player_do_add_action (player, importance, &action);
-}
-
-void
-swfdec_player_add_action_script (SwfdecPlayer *player, SwfdecMovie *movie,
- SwfdecScript *script, guint importance)
-{
- SwfdecPlayerAction action = { movie, script, 0 };
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
- g_return_if_fail (script != NULL);
- g_return_if_fail (importance < SWFDEC_PLAYER_N_ACTION_QUEUES);
-
- SWFDEC_LOG ("adding action script %s %s", movie->name, script->name);
- swfdec_player_do_add_action (player, importance, &action);
-}
-
-/**
- * swfdec_player_remove_all_actions:
- * @player: a #SwfdecPlayer
- * @movie: movie pointer identifying the actions to be removed
- *
- * Removes all actions associated with @movie that have not yet been executed.
- * See swfdec_player_add_action() for details about actions.
- **/
-void
-swfdec_player_remove_all_actions (SwfdecPlayer *player, SwfdecMovie *movie)
-{
- SwfdecPlayerAction *action;
- SwfdecPlayerPrivate *priv;
- guint i, j;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
-
- priv = player->priv;
- for (i = 0; i < SWFDEC_PLAYER_N_ACTION_QUEUES; i++) {
- for (j = 0; j < swfdec_ring_buffer_get_n_elements (priv->actions[i]); j++) {
- action = swfdec_ring_buffer_peek_nth (priv->actions[i], j);
-
- if (action->movie == movie) {
- SWFDEC_LOG ("removing action %p %u",
- action->movie, action->event);
- action->movie = NULL;
- }
- }
- }
-}
-
-static gboolean
-swfdec_player_do_action (SwfdecPlayer *player)
-{
- SwfdecPlayerAction *action;
- SwfdecPlayerPrivate *priv;
- guint i;
-
- priv = player->priv;
- for (i = 0; i < SWFDEC_PLAYER_N_ACTION_QUEUES; i++) {
- do {
- action = swfdec_ring_buffer_pop (priv->actions[i]);
- if (action == NULL)
- break;
- } while (action->movie == NULL); /* skip removed actions */
- if (action) {
- if (action->script) {
- SwfdecSandbox *sandbox = action->movie->resource->sandbox;
- swfdec_sandbox_use (sandbox);
- swfdec_as_object_run (SWFDEC_AS_OBJECT (action->movie), action->script);
- swfdec_sandbox_unuse (sandbox);
- } else {
- swfdec_movie_execute (action->movie, action->event);
- }
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-static void
-swfdec_player_perform_external_actions (SwfdecPlayer *player)
-{
- SwfdecPlayerExternalAction *action;
- SwfdecPlayerPrivate *priv = player->priv;
- guint i;
-
- /* remove timeout if it exists - do this before executing stuff below */
- if (priv->external_timeout.callback) {
- swfdec_player_remove_timeout (player, &priv->external_timeout);
- priv->external_timeout.callback = NULL;
- }
-
- /* we need to query the number of current actions so newly added ones aren't
- * executed in here */
- for (i = swfdec_ring_buffer_get_n_elements (priv->external_actions); i > 0; i--) {
- action = swfdec_ring_buffer_pop (priv->external_actions);
- g_assert (action != NULL);
- /* skip removed actions */
- if (action->object == NULL)
- continue;
- action->func (action->object, action->data);
- swfdec_player_perform_actions (player);
- }
-}
-
-static void
-swfdec_player_trigger_external_actions (SwfdecTimeout *advance)
-{
- SwfdecPlayerPrivate *priv = (SwfdecPlayerPrivate *) ((void *) ((guint8 *) advance - G_STRUCT_OFFSET (SwfdecPlayerPrivate, external_timeout)));
-
- priv->external_timeout.callback = NULL;
- swfdec_player_perform_external_actions (priv->player);
-}
-
-void
-swfdec_player_add_external_action (SwfdecPlayer *player, gpointer object,
- SwfdecActionFunc action_func, gpointer action_data)
-{
- SwfdecPlayerExternalAction *action;
- SwfdecPlayerPrivate *priv;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (object != NULL);
- g_return_if_fail (action_func != NULL);
-
- SWFDEC_LOG ("adding external action %p %p %p", object, action_func, action_data);
- priv = player->priv;
- action = swfdec_ring_buffer_push (priv->external_actions);
- if (action == NULL) {
- /* FIXME: limit number of actions to not get inf loops due to scripts? */
- swfdec_ring_buffer_set_size (priv->external_actions,
- swfdec_ring_buffer_get_size (priv->external_actions) + 16);
- action = swfdec_ring_buffer_push (priv->external_actions);
- g_assert (action);
- }
- action->object = object;
- action->func = action_func;
- action->data = action_data;
- if (!priv->external_timeout.callback) {
- /* trigger execution immediately.
- * But if initialized, keep at least 100ms from when the last external
- * timeout triggered. This is a crude method to get around infinite loops
- * when script actions executed by external actions trigger another external
- * action that would execute instantly.
- */
- if (priv->initialized) {
- priv->external_timeout.timestamp = MAX (priv->time,
- priv->external_timeout.timestamp + SWFDEC_MSECS_TO_TICKS (100));
- } else {
- priv->external_timeout.timestamp = priv->time;
- }
- priv->external_timeout.callback = swfdec_player_trigger_external_actions;
- swfdec_player_add_timeout (player, &priv->external_timeout);
- }
-}
-
-void
-swfdec_player_remove_all_external_actions (SwfdecPlayer *player, gpointer object)
-{
- SwfdecPlayerExternalAction *action;
- SwfdecPlayerPrivate *priv;
- guint i;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (object != NULL);
-
- priv = player->priv;
- for (i = 0; i < swfdec_ring_buffer_get_n_elements (priv->external_actions); i++) {
- action = swfdec_ring_buffer_peek_nth (priv->external_actions, i);
-
- if (action->object == object) {
- SWFDEC_LOG ("removing external action %p %p %p",
- action->object, action->func, action->data);
- action->object = NULL;
- }
- }
-}
-
-/*** SwfdecPlayer ***/
-
-enum {
- INVALIDATE,
- ADVANCE,
- HANDLE_KEY,
- HANDLE_MOUSE,
- AUDIO_ADDED,
- AUDIO_REMOVED,
- LAUNCH,
- FSCOMMAND,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0, };
-
-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,
- PROP_WIDTH,
- PROP_HEIGHT,
- PROP_ALIGNMENT,
- PROP_SCALE,
- PROP_SCRIPTING,
- PROP_SYSTEM,
- PROP_MAX_RUNTIME,
- PROP_LOADER_TYPE,
- PROP_SOCKET_TYPE,
- PROP_BASE_URL,
- PROP_URL,
- PROP_VARIABLES
-};
-
-G_DEFINE_TYPE (SwfdecPlayer, swfdec_player, SWFDEC_TYPE_AS_CONTEXT)
-
-void
-swfdec_player_remove_movie (SwfdecPlayer *player, SwfdecMovie *movie)
-{
- SwfdecPlayerPrivate *priv = player->priv;
-
- swfdec_movie_remove (movie);
- priv->movies = g_list_remove (priv->movies, movie);
-}
-
-static guint
-swfdec_player_alignment_to_flags (SwfdecAlignment alignment)
-{
- static const guint align_flags[9] = {
- SWFDEC_ALIGN_FLAG_TOP | SWFDEC_ALIGN_FLAG_LEFT,
- SWFDEC_ALIGN_FLAG_TOP,
- SWFDEC_ALIGN_FLAG_TOP | SWFDEC_ALIGN_FLAG_RIGHT,
- SWFDEC_ALIGN_FLAG_LEFT,
- 0,
- SWFDEC_ALIGN_FLAG_RIGHT,
- SWFDEC_ALIGN_FLAG_BOTTOM | SWFDEC_ALIGN_FLAG_LEFT,
- SWFDEC_ALIGN_FLAG_BOTTOM,
- SWFDEC_ALIGN_FLAG_BOTTOM | SWFDEC_ALIGN_FLAG_RIGHT
- };
- return align_flags[alignment];
-}
-
-static SwfdecAlignment
-swfdec_player_alignment_from_flags (guint flags)
-{
- if (flags & SWFDEC_ALIGN_FLAG_TOP) {
- if (flags & SWFDEC_ALIGN_FLAG_LEFT) {
- return SWFDEC_ALIGNMENT_TOP_LEFT;
- } else if (flags & SWFDEC_ALIGN_FLAG_RIGHT) {
- return SWFDEC_ALIGNMENT_TOP_RIGHT;
- } else {
- return SWFDEC_ALIGNMENT_TOP;
- }
- } else if (flags & SWFDEC_ALIGN_FLAG_BOTTOM) {
- if (flags & SWFDEC_ALIGN_FLAG_LEFT) {
- return SWFDEC_ALIGNMENT_BOTTOM_LEFT;
- } else if (flags & SWFDEC_ALIGN_FLAG_RIGHT) {
- return SWFDEC_ALIGNMENT_BOTTOM_RIGHT;
- } else {
- return SWFDEC_ALIGNMENT_BOTTOM;
- }
- } else {
- if (flags & SWFDEC_ALIGN_FLAG_LEFT) {
- return SWFDEC_ALIGNMENT_LEFT;
- } else if (flags & SWFDEC_ALIGN_FLAG_RIGHT) {
- return SWFDEC_ALIGNMENT_RIGHT;
- } else {
- return SWFDEC_ALIGNMENT_CENTER;
- }
- }
-}
-
-static void
-swfdec_player_get_property (GObject *object, guint param_id, GValue *value,
- GParamSpec * pspec)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (object);
- SwfdecPlayerPrivate *priv = player->priv;
-
- switch (param_id) {
- case PROP_BACKGROUND_COLOR:
- g_value_set_uint (value, swfdec_player_get_background_color (player));
- break;
- case PROP_CACHE_SIZE:
- g_value_set_ulong (value, swfdec_cache_get_size (priv->cache));
- break;
- case PROP_INITIALIZED:
- g_value_set_boolean (value, swfdec_player_is_initialized (player));
- break;
- case PROP_DEFAULT_WIDTH:
- g_value_set_uint (value, priv->width);
- break;
- case PROP_DEFAULT_HEIGHT:
- g_value_set_uint (value, priv->height);
- break;
- case PROP_RATE:
- g_value_set_double (value, priv->rate / 256.0);
- break;
- case PROP_MOUSE_CURSOR:
- g_value_set_enum (value, priv->mouse_cursor);
- break;
- case PROP_NEXT_EVENT:
- g_value_set_uint (value, swfdec_player_get_next_event (player));
- break;
- case PROP_WIDTH:
- g_value_set_int (value, priv->stage_width);
- break;
- case PROP_HEIGHT:
- g_value_set_int (value, priv->stage_height);
- break;
- case PROP_ALIGNMENT:
- g_value_set_enum (value, swfdec_player_alignment_from_flags (priv->align_flags));
- break;
- case PROP_SCALE:
- g_value_set_enum (value, priv->scale_mode);
- break;
- case PROP_SCRIPTING:
- g_value_set_object (value, priv->scripting);
- break;
- case PROP_SYSTEM:
- g_value_set_object (value, priv->system);
- break;
- case PROP_MAX_RUNTIME:
- g_value_set_ulong (value, priv->max_runtime);
- break;
- case PROP_LOADER_TYPE:
- g_value_set_gtype (value, priv->loader_type);
- break;
- case PROP_SOCKET_TYPE:
- g_value_set_gtype (value, priv->socket_type);
- break;
- case PROP_URL:
- g_value_set_boxed (value, priv->url);
- break;
- case PROP_BASE_URL:
- g_value_set_boxed (value, priv->base_url);
- break;
- case PROP_VARIABLES:
- g_value_set_string (value, priv->variables);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-void
-swfdec_player_update_scale (SwfdecPlayer *player)
-{
- SwfdecPlayerPrivate *priv = player->priv;
- int width, height;
- double scale_x, scale_y;
-
- priv->stage.width = priv->stage_width >= 0 ? priv->stage_width : (int) priv->width;
- priv->stage.height = priv->stage_height >= 0 ? priv->stage_height : (int) priv->height;
- if (priv->stage.height == 0 || priv->stage.width == 0) {
- priv->scale_x = 1.0;
- priv->scale_y = 1.0;
- priv->offset_x = 0;
- priv->offset_y = 0;
- return;
- }
- if (priv->width == 0 || priv->height == 0) {
- scale_x = 1.0;
- scale_y = 1.0;
- } else {
- scale_x = (double) priv->stage.width / priv->width;
- scale_y = (double) priv->stage.height / priv->height;
- }
- switch (priv->scale_mode) {
- case SWFDEC_SCALE_SHOW_ALL:
- priv->scale_x = MIN (scale_x, scale_y);
- priv->scale_y = priv->scale_x;
- break;
- case SWFDEC_SCALE_NO_BORDER:
- priv->scale_x = MAX (scale_x, scale_y);
- priv->scale_y = priv->scale_x;
- break;
- case SWFDEC_SCALE_EXACT_FIT:
- priv->scale_x = scale_x;
- priv->scale_y = scale_y;
- break;
- case SWFDEC_SCALE_NONE:
- priv->scale_x = 1.0;
- priv->scale_y = 1.0;
- break;
- default:
- g_assert_not_reached ();
- }
- width = priv->stage.width - ceil (priv->width * priv->scale_x);
- height = priv->stage.height - ceil (priv->height * priv->scale_y);
- if (priv->align_flags & SWFDEC_ALIGN_FLAG_LEFT) {
- priv->offset_x = 0;
- } else if (priv->align_flags & SWFDEC_ALIGN_FLAG_RIGHT) {
- priv->offset_x = width;
- } else {
- priv->offset_x = width / 2;
- }
- if (priv->align_flags & SWFDEC_ALIGN_FLAG_TOP) {
- priv->offset_y = 0;
- } else if (priv->align_flags & SWFDEC_ALIGN_FLAG_BOTTOM) {
- priv->offset_y = height;
- } else {
- priv->offset_y = height / 2;
- }
- SWFDEC_LOG ("coordinate translation is %g * x + %d - %g * y + %d",
- priv->scale_x, priv->offset_x, priv->scale_y, priv->offset_y);
-#if 0
- /* FIXME: make this emit the signal at the right time */
- priv->invalid.x0 = 0;
- priv->invalid.y0 = 0;
- priv->invalid.x1 = priv->stage_width;
- priv->invalid.y1 = priv->stage_height;
-#endif
-}
-
-static void
-swfdec_player_set_property (GObject *object, guint param_id, const GValue *value,
- GParamSpec *pspec)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (object);
- SwfdecPlayerPrivate *priv = player->priv;
-
- switch (param_id) {
- case PROP_BACKGROUND_COLOR:
- swfdec_player_set_background_color (player, g_value_get_uint (value));
- break;
- case PROP_CACHE_SIZE:
- swfdec_cache_set_size (priv->cache, g_value_get_ulong (value));
- break;
- case PROP_WIDTH:
- swfdec_player_set_size (player, g_value_get_int (value), priv->stage_height);
- break;
- case PROP_HEIGHT:
- swfdec_player_set_size (player, priv->stage_width, g_value_get_int (value));
- break;
- case PROP_ALIGNMENT:
- priv->align_flags = swfdec_player_alignment_to_flags (g_value_get_enum (value));
- swfdec_player_update_scale (player);
- break;
- case PROP_SCALE:
- swfdec_player_set_scale_mode (player, g_value_get_enum (value));
- break;
- case PROP_SCRIPTING:
- swfdec_player_set_scripting (player, g_value_get_object (value));
- break;
- case PROP_SYSTEM:
- g_object_unref (priv->system);
- if (g_value_get_object (value)) {
- priv->system = SWFDEC_SYSTEM (g_value_dup_object (value));
- } else {
- priv->system = swfdec_system_new ();
- }
- break;
- case PROP_MAX_RUNTIME:
- swfdec_player_set_maximum_runtime (player, g_value_get_ulong (value));
- break;
- case PROP_LOADER_TYPE:
- g_return_if_fail (G_TYPE_IS_INSTANTIATABLE (g_value_get_gtype (value)));
- priv->loader_type = g_value_get_gtype (value);
- break;
- case PROP_SOCKET_TYPE:
- priv->socket_type = g_value_get_gtype (value);
- break;
- case PROP_URL:
- swfdec_player_set_url (player, g_value_get_boxed (value));
- break;
- case PROP_BASE_URL:
- swfdec_player_set_base_url (player, g_value_get_boxed (value));
- break;
- case PROP_VARIABLES:
- swfdec_player_set_variables (player, g_value_get_boxed (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-swfdec_player_dispose (GObject *object)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (object);
- SwfdecPlayerPrivate *priv = player->priv;
- guint i;
-
- swfdec_player_stop_all_sounds (player);
- swfdec_function_list_clear (&priv->resource_requests);
- g_hash_table_destroy (priv->registered_classes);
- g_hash_table_destroy (priv->scripting_callbacks);
-
- g_list_foreach (priv->loading_policy_files, (GFunc) g_object_unref, NULL);
- g_list_free (priv->loading_policy_files);
- priv->loading_policy_files = NULL;
- g_slist_foreach (priv->policy_files, (GFunc) g_object_unref, NULL);
- g_slist_free (priv->policy_files);
- priv->policy_files = NULL;
-
- while (priv->roots)
- swfdec_movie_destroy (priv->roots->data);
-
- swfdec_function_list_clear (&priv->rooted);
- /* we do this here so references to GC'd objects get freed */
- G_OBJECT_CLASS (swfdec_player_parent_class)->dispose (object);
-
- swfdec_player_remove_all_external_actions (player, player);
-#ifndef G_DISABLE_ASSERT
- {
- SwfdecPlayerExternalAction *action;
- while ((action = swfdec_ring_buffer_pop (priv->external_actions)) != NULL) {
- g_assert (action->object == NULL); /* skip removed actions */
- }
- }
- {
- SwfdecPlayerAction *action;
- for (i = 0; i < SWFDEC_PLAYER_N_ACTION_QUEUES; i++) {
- while ((action = swfdec_ring_buffer_pop (priv->actions[i])) != NULL) {
- g_assert (action->movie == NULL); /* skip removed actions */
- }
- }
- }
-#endif
- swfdec_ring_buffer_free (priv->external_actions);
- for (i = 0; i < SWFDEC_PLAYER_N_ACTION_QUEUES; i++) {
- swfdec_ring_buffer_free (priv->actions[i]);
- }
- g_assert (priv->movies == NULL);
- g_assert (priv->audio == NULL);
- g_slist_free (priv->sandboxes);
- if (priv->external_timeout.callback)
- swfdec_player_remove_timeout (player, &priv->external_timeout);
- if (priv->rate) {
- swfdec_player_remove_timeout (player, &priv->iterate_timeout);
- }
- g_assert (priv->timeouts == NULL);
- g_list_free (priv->intervals);
- priv->intervals = NULL;
- swfdec_cache_unref (priv->cache);
- if (priv->system) {
- g_object_unref (priv->system);
- priv->system = NULL;
- }
- g_array_free (priv->invalidations, TRUE);
- priv->invalidations = NULL;
- if (priv->runtime) {
- g_timer_destroy (priv->runtime);
- priv->runtime = NULL;
- }
- if (priv->base_url) {
- swfdec_url_free (priv->base_url);
- priv->base_url = NULL;
- }
- if (priv->url) {
- swfdec_url_free (priv->url);
- priv->url = NULL;
- }
- g_free (priv->variables);
- priv->variables = NULL;
-}
-
-static void
-swfdec_player_broadcast (SwfdecPlayer *player, const char *object_name, const char *signal)
-{
- GSList *walk;
- SwfdecAsValue val;
- SwfdecAsObject *obj;
-
- SWFDEC_DEBUG ("broadcasting message %s.%s", object_name, signal);
- for (walk = player->priv->sandboxes; walk; walk = walk->next) {
- SwfdecSandbox *sandbox = walk->data;
- swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (sandbox), object_name, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return;
- obj = SWFDEC_AS_VALUE_GET_OBJECT (&val);
- SWFDEC_AS_VALUE_SET_STRING (&val, signal);
- swfdec_sandbox_use (sandbox);
- swfdec_as_object_call (obj, SWFDEC_AS_STR_broadcastMessage, 1, &val, NULL);
- swfdec_sandbox_unuse (sandbox);
- }
-}
-
-static void
-swfdec_player_update_mouse_cursor (SwfdecPlayer *player)
-{
- SwfdecPlayerPrivate *priv = player->priv;
- SwfdecMouseCursor new = SWFDEC_MOUSE_CURSOR_NORMAL;
-
- if (!priv->mouse_visible) {
- new = SWFDEC_MOUSE_CURSOR_NONE;
- } else if (priv->mouse_grab != NULL) {
- SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (priv->mouse_grab);
-
- if (klass->mouse_cursor)
- new = klass->mouse_cursor (priv->mouse_grab);
- else
- new = SWFDEC_MOUSE_CURSOR_CLICK;
- }
-
- if (new != priv->mouse_cursor) {
- priv->mouse_cursor = new;
- g_object_notify (G_OBJECT (player), "mouse-cursor");
- }
-}
-
-static void
-swfdec_player_update_drag_movie (SwfdecPlayer *player)
-{
- SwfdecPlayerPrivate *priv = player->priv;
- double x, y;
- SwfdecMovie *movie;
-
- if (priv->mouse_drag == NULL)
- return;
-
- movie = priv->mouse_drag;
- g_assert (movie->cache_state == SWFDEC_MOVIE_UP_TO_DATE);
- x = priv->mouse_x;
- y = priv->mouse_y;
- swfdec_player_stage_to_global (player, &x, &y);
- if (movie->parent)
- swfdec_movie_global_to_local (movie->parent, &x, &y);
- if (priv->mouse_drag_center) {
- x -= (movie->extents.x1 - movie->extents.x0) / 2;
- y -= (movie->extents.y1 - movie->extents.y0) / 2;
- } else {
- x -= priv->mouse_drag_x;
- y -= priv->mouse_drag_y;
- }
- x = CLAMP (x, priv->mouse_drag_rect.x0, priv->mouse_drag_rect.x1);
- y = CLAMP (y, priv->mouse_drag_rect.y0, priv->mouse_drag_rect.y1);
- SWFDEC_LOG ("mouse is at %g %g, originally (%g %g)", x, y, priv->mouse_x, priv->mouse_y);
- if (x != movie->matrix.x0 || y != movie->matrix.y0) {
- swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
- movie->matrix.x0 = x;
- movie->matrix.y0 = y;
- }
-}
-
-/**
- * swfdec_player_set_drag_movie:
- * @player: a #SwfdecPlayer
- * @drag: the movie to be dragged by the mouse or NULL to unset
- * @center: TRUE if the center of @drag should be at the mouse pointer, FALSE if (0,0)
- * of @drag should be at the mouse pointer.
- * @rect: NULL or the rectangle that clips the mouse position. The coordinates
- * are in the coordinate system of the parent of @drag.
- *
- * Sets or unsets the movie that is dragged by the mouse.
- **/
-void
-swfdec_player_set_drag_movie (SwfdecPlayer *player, SwfdecMovie *drag, gboolean center,
- SwfdecRect *rect)
-{
- SwfdecPlayerPrivate *priv;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (drag == NULL || SWFDEC_IS_MOVIE (drag));
-
- /* FIXME: need to do anything with old drag? */
- priv = player->priv;
- priv->mouse_drag = drag;
- priv->mouse_drag_center = center;
- if (drag && !center) {
- priv->mouse_drag_x = priv->mouse_x;
- priv->mouse_drag_y = priv->mouse_y;
- swfdec_player_stage_to_global (player, &priv->mouse_drag_x, &priv->mouse_drag_y);
- if (drag->parent)
- swfdec_movie_global_to_local (drag->parent, &priv->mouse_drag_x, &priv->mouse_drag_y);
- priv->mouse_drag_x -= drag->matrix.x0;
- priv->mouse_drag_y -= drag->matrix.y0;
- }
- if (rect) {
- priv->mouse_drag_rect = *rect;
- } else {
- priv->mouse_drag_rect.x0 = -G_MAXDOUBLE;
- priv->mouse_drag_rect.y0 = -G_MAXDOUBLE;
- priv->mouse_drag_rect.x1 = G_MAXDOUBLE;
- priv->mouse_drag_rect.y1 = G_MAXDOUBLE;
- }
- SWFDEC_DEBUG ("starting drag in %g %g %g %g",
- priv->mouse_drag_rect.x0, priv->mouse_drag_rect.y0,
- priv->mouse_drag_rect.x1, priv->mouse_drag_rect.y1);
- /* FIXME: need a way to make sure we get updated */
- if (drag) {
- swfdec_movie_update (drag);
- drag->modified = TRUE;
- swfdec_player_update_drag_movie (player);
- }
-}
-
-static void
-swfdec_player_grab_mouse_movie (SwfdecPlayer *player)
-{
- SwfdecPlayerPrivate *priv = player->priv;
- GList *walk;
- double x, y;
- SwfdecMovie *below_mouse = NULL;
-
- x = priv->mouse_x;
- y = priv->mouse_y;
- swfdec_player_stage_to_global (player, &x, &y);
- for (walk = g_list_last (priv->roots); walk; walk = walk->prev) {
- below_mouse = swfdec_movie_get_movie_at (walk->data, x, y, TRUE);
- if (below_mouse) {
- if (swfdec_movie_get_mouse_events (below_mouse))
- break;
- below_mouse = NULL;
- }
- }
- if (swfdec_player_is_mouse_pressed (player)) {
- /* a mouse grab is active */
- if (priv->mouse_grab) {
- if (below_mouse == priv->mouse_grab &&
- priv->mouse_below != priv->mouse_grab) {
- SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (priv->mouse_grab);
- if (klass->mouse_in)
- klass->mouse_in (priv->mouse_grab);
- } else if (below_mouse != priv->mouse_grab &&
- priv->mouse_below == priv->mouse_grab) {
- SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (priv->mouse_grab);
- if (klass->mouse_out)
- klass->mouse_out (priv->mouse_grab);
- }
- }
- } else {
- /* no mouse grab is active */
- if (below_mouse != priv->mouse_grab) {
- if (priv->mouse_grab) {
- SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (priv->mouse_grab);
- if (klass->mouse_out)
- klass->mouse_out (priv->mouse_grab);
- }
- if (below_mouse) {
- SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (below_mouse);
- if (klass->mouse_in)
- klass->mouse_in (below_mouse);
- }
- }
- priv->mouse_grab = below_mouse;
- }
- priv->mouse_below = below_mouse;
- SWFDEC_DEBUG ("%s %p has mouse at %g %g",
- priv->mouse_grab ? G_OBJECT_TYPE_NAME (priv->mouse_grab) : "---",
- priv->mouse_grab, priv->mouse_x, priv->mouse_y);
-}
-
-static gboolean
-swfdec_player_do_mouse_move (SwfdecPlayer *player, double x, double y)
-{
- SwfdecPlayerPrivate *priv = player->priv;
- GList *walk;
-
- if (priv->mouse_x != x || priv->mouse_y != y) {
- priv->mouse_x = x;
- priv->mouse_y = y;
- for (walk = priv->movies; walk; walk = walk->next) {
- swfdec_movie_queue_script (walk->data, SWFDEC_EVENT_MOUSE_MOVE);
- }
- swfdec_player_broadcast (player, SWFDEC_AS_STR_Mouse, SWFDEC_AS_STR_onMouseMove);
- }
- swfdec_player_grab_mouse_movie (player);
- swfdec_player_update_drag_movie (player);
-
- /* FIXME: allow events to pass through */
- return TRUE;
-}
-
-static gboolean
-swfdec_player_do_mouse_press (SwfdecPlayer *player, guint button)
-{
- SwfdecPlayerPrivate *priv = player->priv;
- GList *walk;
-
- priv->mouse_button |= 1 << button;
- if (button == 0) {
- for (walk = priv->movies; walk; walk = walk->next) {
- swfdec_movie_queue_script (walk->data, SWFDEC_EVENT_MOUSE_DOWN);
- }
- swfdec_player_broadcast (player, SWFDEC_AS_STR_Mouse, SWFDEC_AS_STR_onMouseDown);
- }
- if (priv->mouse_grab) {
- SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (priv->mouse_grab);
- if (klass->mouse_press)
- klass->mouse_press (priv->mouse_grab, button);
- }
-
- /* FIXME: allow events to pass through */
- return TRUE;
-}
-
-static gboolean
-swfdec_player_do_mouse_release (SwfdecPlayer *player, guint button)
-{
- SwfdecPlayerPrivate *priv = player->priv;
- GList *walk;
-
- priv->mouse_button &= ~(1 << button);
- if (button == 0) {
- for (walk = priv->movies; walk; walk = walk->next) {
- swfdec_movie_queue_script (walk->data, SWFDEC_EVENT_MOUSE_UP);
- }
- swfdec_player_broadcast (player, SWFDEC_AS_STR_Mouse, SWFDEC_AS_STR_onMouseUp);
- }
- if (priv->mouse_grab) {
- SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (priv->mouse_grab);
- if (klass->mouse_release)
- klass->mouse_release (priv->mouse_grab, button);
- if (button == 0 && priv->mouse_grab != priv->mouse_below) {
- priv->mouse_grab = priv->mouse_below;
- if (priv->mouse_grab) {
- klass = SWFDEC_MOVIE_GET_CLASS (priv->mouse_grab);
- if (klass->mouse_in)
- klass->mouse_in (priv->mouse_grab);
- }
- }
- }
-
- /* FIXME: allow events to pass through */
- return TRUE;
-}
-
-static void
-swfdec_player_emit_signals (SwfdecPlayer *player)
-{
- SwfdecPlayerPrivate *priv = player->priv;
- GList *walk;
-
- /* emit invalidate signal */
- if (!swfdec_rectangle_is_empty (&priv->invalid_extents)) {
- g_signal_emit (player, signals[INVALIDATE], 0, &priv->invalid_extents,
- priv->invalidations->data, priv->invalidations->len);
- swfdec_rectangle_init_empty (&priv->invalid_extents);
- g_array_set_size (priv->invalidations, 0);
- }
-
- /* emit audio-added for all added audio streams */
- for (walk = priv->audio; walk; walk = walk->next) {
- SwfdecAudio *audio = walk->data;
-
- if (audio->added)
- continue;
- g_signal_emit (player, signals[AUDIO_ADDED], 0, audio);
- audio->added = TRUE;
- }
-}
-
-static gboolean
-swfdec_player_do_handle_key (SwfdecPlayer *player, guint keycode, guint character, gboolean down)
-{
- SwfdecPlayerPrivate *priv = player->priv;
- g_assert (keycode < 256);
-
- if (!swfdec_player_lock (player))
- return FALSE;
- /* set the correct variables */
- priv->last_keycode = keycode;
- priv->last_character = character;
- if (down) {
- priv->key_pressed[keycode / 8] |= 1 << keycode % 8;
- } else {
- priv->key_pressed[keycode / 8] &= ~(1 << keycode % 8);
- }
- swfdec_player_broadcast (player, SWFDEC_AS_STR_Key, down ? SWFDEC_AS_STR_onKeyDown : SWFDEC_AS_STR_onKeyUp);
- swfdec_player_perform_actions (player);
- swfdec_player_unlock (player);
-
- return TRUE;
-}
-
-static gboolean
-swfdec_player_do_handle_mouse (SwfdecPlayer *player,
- double x, double y, int button)
-{
- gboolean ret;
-
- if (!swfdec_player_lock (player))
- return FALSE;
-
- SWFDEC_LOG ("handling mouse for %g %g %d", x, y, button);
- ret = swfdec_player_do_mouse_move (player, x, y);
- if (button > 0) {
- ret |= swfdec_player_do_mouse_press (player, button - 1);
- } else if (button < 0) {
- ret |= swfdec_player_do_mouse_release (player, -button - 1);
- }
- swfdec_player_perform_actions (player);
- swfdec_player_unlock (player);
-
- return ret;
-}
-
-void
-swfdec_player_global_to_stage (SwfdecPlayer *player, double *x, double *y)
-{
- SwfdecPlayerPrivate *priv = player->priv;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (x != NULL);
- g_return_if_fail (y != NULL);
-
- *x = *x / SWFDEC_TWIPS_SCALE_FACTOR * priv->scale_x + priv->offset_x;
- *y = *y / SWFDEC_TWIPS_SCALE_FACTOR * priv->scale_y + priv->offset_y;
-}
-
-void
-swfdec_player_stage_to_global (SwfdecPlayer *player, double *x, double *y)
-{
- SwfdecPlayerPrivate *priv = player->priv;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (x != NULL);
- g_return_if_fail (y != NULL);
-
- *x = (*x - priv->offset_x) / priv->scale_x * SWFDEC_TWIPS_SCALE_FACTOR;
- *y = (*y - priv->offset_y) / priv->scale_y * SWFDEC_TWIPS_SCALE_FACTOR;
-}
-
-static void
-swfdec_player_execute_on_load_init (SwfdecPlayer *player)
-{
- GList *walk;
-
- /* FIXME: This can be made a LOT faster with correct caching, but I'm lazy */
- do {
- for (walk = player->priv->movies; walk; walk = walk->next) {
- SwfdecMovie *movie = walk->data;
- SwfdecResource *resource = swfdec_movie_get_own_resource (movie);
- if (resource == NULL)
- continue;
- if (swfdec_resource_emit_on_load_init (resource))
- break;
- }
- } while (walk != NULL);
-}
-
-static void
-swfdec_player_iterate (SwfdecTimeout *timeout)
-{
- SwfdecPlayerPrivate *priv = (SwfdecPlayerPrivate *) ((void *) ((guint8 *) timeout - G_STRUCT_OFFSET (SwfdecPlayerPrivate, iterate_timeout)));
- SwfdecPlayer *player = priv->player;
- GList *walk;
-
- /* add timeout again - do this first because later code can change it */
- /* FIXME: rounding issues? */
- priv->iterate_timeout.timestamp += SWFDEC_TICKS_PER_SECOND * 256 / priv->rate;
- swfdec_player_add_timeout (player, &priv->iterate_timeout);
- swfdec_player_perform_external_actions (player);
- SWFDEC_INFO ("=== START ITERATION ===");
- /* start the iteration. This performs a goto next frame on all
- * movies that are not stopped. It also queues onEnterFrame.
- */
- for (walk = priv->movies; walk; walk = walk->next) {
- SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (walk->data);
- if (klass->iterate_start)
- klass->iterate_start (walk->data);
- }
- swfdec_player_perform_actions (player);
- SWFDEC_INFO ("=== STOP ITERATION ===");
- /* this loop allows removal of walk->data */
- walk = priv->movies;
- while (walk) {
- SwfdecMovie *cur = walk->data;
- SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (cur);
- walk = walk->next;
- g_assert (klass->iterate_end);
- if (!klass->iterate_end (cur))
- swfdec_movie_destroy (cur);
- }
- swfdec_player_execute_on_load_init (player);
- swfdec_function_list_execute_and_clear (&priv->resource_requests, player);
- swfdec_player_perform_actions (player);
-}
-
-static void
-swfdec_player_advance_audio (SwfdecPlayer *player, guint samples)
-{
- SwfdecAudio *audio;
- GList *walk;
-
- if (samples == 0)
- return;
-
- /* don't use for loop here, because we need to advance walk before
- * removing the audio */
- walk = player->priv->audio;
- while (walk) {
- audio = walk->data;
- walk = walk->next;
- if (swfdec_audio_iterate (audio, samples) == 0)
- swfdec_audio_remove (audio);
- }
-}
-
-static void
-swfdec_player_do_advance (SwfdecPlayer *player, gulong msecs, guint audio_samples)
-{
- SwfdecPlayerPrivate *priv = player->priv;
- SwfdecTimeout *timeout;
- SwfdecTick target_time;
- guint frames_now;
-
- if (!swfdec_player_lock (player))
- return;
-
- target_time = priv->time + SWFDEC_MSECS_TO_TICKS (msecs);
- SWFDEC_DEBUG ("advancing %lu msecs (%u audio frames)", msecs, audio_samples);
-
- for (timeout = priv->timeouts ? priv->timeouts->data : NULL;
- timeout && timeout->timestamp <= target_time;
- timeout = priv->timeouts ? priv->timeouts->data : NULL) {
- priv->timeouts = g_list_remove (priv->timeouts, timeout);
- frames_now = SWFDEC_TICKS_TO_SAMPLES (timeout->timestamp) -
- SWFDEC_TICKS_TO_SAMPLES (priv->time);
- priv->time = timeout->timestamp;
- swfdec_player_advance_audio (player, frames_now);
- audio_samples -= frames_now;
- SWFDEC_LOG ("activating timeout %p now (timeout is %"G_GUINT64_FORMAT", target time is %"G_GUINT64_FORMAT,
- timeout, timeout->timestamp, target_time);
- timeout->callback (timeout);
- swfdec_player_perform_actions (player);
- }
- if (target_time > priv->time) {
- frames_now = SWFDEC_TICKS_TO_SAMPLES (target_time) -
- SWFDEC_TICKS_TO_SAMPLES (priv->time);
- priv->time = target_time;
- swfdec_player_advance_audio (player, frames_now);
- audio_samples -= frames_now;
- }
- g_assert (audio_samples == 0);
-
- g_object_notify (G_OBJECT (player), "next-event");
- swfdec_player_unlock (player);
-}
-
-void
-swfdec_player_perform_actions (SwfdecPlayer *player)
-{
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
-
- while (swfdec_player_do_action (player));
-}
-
-/* used for breakpoints */
-void
-swfdec_player_lock_soft (SwfdecPlayer *player)
-{
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_assert (swfdec_rectangle_is_empty (&player->priv->invalid_extents));
-
- g_object_freeze_notify (G_OBJECT (player));
- g_timer_start (player->priv->runtime);
- SWFDEC_DEBUG ("LOCKED");
-}
-
-gboolean
-swfdec_player_lock (SwfdecPlayer *player)
-{
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE);
- g_assert (swfdec_ring_buffer_get_n_elements (player->priv->actions[0]) == 0);
- g_assert (swfdec_ring_buffer_get_n_elements (player->priv->actions[1]) == 0);
- g_assert (swfdec_ring_buffer_get_n_elements (player->priv->actions[2]) == 0);
- g_assert (swfdec_ring_buffer_get_n_elements (player->priv->actions[3]) == 0);
-
- if (swfdec_as_context_is_aborted (SWFDEC_AS_CONTEXT (player)))
- return FALSE;
-
- g_object_ref (player);
- swfdec_player_lock_soft (player);
- return TRUE;
-}
-
-/* runs queued invalidations for all movies and resets the movies */
-static void
-swfdec_player_update_movies (SwfdecPlayer *player)
-{
- SwfdecMovie *movie;
- GList *walk;
-
- /* FIXME: This g_list_last could be slow */
- for (walk = g_list_last (player->priv->movies); walk; walk = walk->prev) {
- movie = walk->data;
-
- swfdec_movie_update (movie);
- if (movie->invalidate_last) {
- cairo_matrix_t matrix;
-
- if (movie->parent)
- swfdec_movie_local_to_global_matrix (movie->parent, &matrix);
- else
- cairo_matrix_init_identity (&matrix);
- swfdec_movie_invalidate (movie, &matrix, TRUE);
- movie->invalidate_last = FALSE;
- }
- }
-}
-
-/* used for breakpoints */
-void
-swfdec_player_unlock_soft (SwfdecPlayer *player)
-{
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
-
- SWFDEC_DEBUG ("UNLOCK");
- g_timer_stop (player->priv->runtime);
- swfdec_player_update_movies (player);
- swfdec_player_update_mouse_cursor (player);
- g_object_thaw_notify (G_OBJECT (player));
- swfdec_player_emit_signals (player);
-}
-
-void
-swfdec_player_unlock (SwfdecPlayer *player)
-{
- SwfdecAsContext *context;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_assert (swfdec_ring_buffer_get_n_elements (player->priv->actions[0]) == 0);
- g_assert (swfdec_ring_buffer_get_n_elements (player->priv->actions[1]) == 0);
- g_assert (swfdec_ring_buffer_get_n_elements (player->priv->actions[2]) == 0);
- g_assert (swfdec_ring_buffer_get_n_elements (player->priv->actions[3]) == 0);
- context = SWFDEC_AS_CONTEXT (player);
- g_return_if_fail (context->state != SWFDEC_AS_CONTEXT_INTERRUPTED);
-
- if (context->state == SWFDEC_AS_CONTEXT_RUNNING)
- swfdec_as_context_maybe_gc (SWFDEC_AS_CONTEXT (player));
- swfdec_player_unlock_soft (player);
- g_object_unref (player);
-}
-
-static gboolean
-swfdec_accumulate_or (GSignalInvocationHint *ihint, GValue *return_accu,
- const GValue *handler_return, gpointer data)
-{
- if (g_value_get_boolean (handler_return))
- g_value_set_boolean (return_accu, TRUE);
- return TRUE;
-}
-
-static void
-swfdec_player_mark_string_object (gpointer key, gpointer value, gpointer data)
-{
- swfdec_as_string_mark (key);
- swfdec_as_object_mark (value);
-}
-
-static void
-swfdec_player_mark (SwfdecAsContext *context)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (context);
- SwfdecPlayerPrivate *priv = player->priv;
-
- g_hash_table_foreach (priv->registered_classes, swfdec_player_mark_string_object, NULL);
- g_hash_table_foreach (priv->scripting_callbacks, swfdec_player_mark_string_object, NULL);
- g_list_foreach (priv->roots, (GFunc) swfdec_as_object_mark, NULL);
- g_list_foreach (priv->intervals, (GFunc) swfdec_as_object_mark, NULL);
- g_slist_foreach (priv->sandboxes, (GFunc) swfdec_as_object_mark, NULL);
- swfdec_function_list_execute (&priv->rooted, player);
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (priv->resource));
-
- SWFDEC_AS_CONTEXT_CLASS (swfdec_player_parent_class)->mark (context);
-}
-
-static void
-swfdec_player_get_time (SwfdecAsContext *context, GTimeVal *tv)
-{
- *tv = context->start_time;
-
- /* FIXME: what granularity do we want? Currently it's milliseconds */
- g_time_val_add (tv, SWFDEC_TICKS_TO_MSECS (SWFDEC_PLAYER (context)->priv->time) * 1000);
-}
-
-static gboolean
-swfdec_player_check_continue (SwfdecAsContext *context)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (context);
- SwfdecPlayerPrivate *priv = player->priv;
-
- if (priv->max_runtime == 0)
- return TRUE;
- return g_timer_elapsed (priv->runtime, NULL) * 1000 <= priv->max_runtime;
-}
-
-static void
-swfdec_player_class_init (SwfdecPlayerClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- SwfdecAsContextClass *context_class = SWFDEC_AS_CONTEXT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (SwfdecPlayerPrivate));
-
- object_class->get_property = swfdec_player_get_property;
- object_class->set_property = swfdec_player_set_property;
- object_class->dispose = swfdec_player_dispose;
-
- 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));
- g_object_class_install_property (object_class, PROP_NEXT_EVENT,
- g_param_spec_long ("next-event", "next event", "how many milliseconds until the next event or -1 when no event pending",
- -1, G_MAXLONG, -1, G_PARAM_READABLE));
- g_object_class_install_property (object_class, PROP_CACHE_SIZE,
- g_param_spec_ulong ("cache-size", "cache size", "maximum cache size in bytes",
- 0, G_MAXUINT, 50 * 1024 * 1024, G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_BACKGROUND_COLOR,
- g_param_spec_uint ("background-color", "background color", "ARGB color used to draw the background",
- 0, G_MAXUINT, SWFDEC_COLOR_COMBINE (0xFF, 0xFF, 0xFF, 0xFF), G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_WIDTH,
- g_param_spec_int ("width", "width", "current width of the movie",
- -1, G_MAXINT, -1, G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_HEIGHT,
- g_param_spec_int ("height", "height", "current height of the movie",
- -1, G_MAXINT, -1, G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_ALIGNMENT,
- g_param_spec_enum ("alignment", "alignment", "point of the screen to align the output to",
- SWFDEC_TYPE_ALIGNMENT, SWFDEC_ALIGNMENT_CENTER, G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_SCALE,
- g_param_spec_enum ("scale-mode", "scale mode", "method used to scale the movie",
- SWFDEC_TYPE_SCALE_MODE, SWFDEC_SCALE_SHOW_ALL, G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_SCRIPTING,
- g_param_spec_object ("scripting", "scripting", "external scripting implementation",
- SWFDEC_TYPE_PLAYER_SCRIPTING, G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_SCALE,
- g_param_spec_object ("system", "system", "object holding system information",
- SWFDEC_TYPE_SYSTEM, G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_MAX_RUNTIME,
- g_param_spec_ulong ("max-runtime", "maximum runtime", "maximum time in msecs scripts may run in the player before aborting",
- 0, G_MAXULONG, 10 * 1000, G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_LOADER_TYPE,
- g_param_spec_gtype ("loader-type", "loader type", "type to use for creating loaders",
- SWFDEC_TYPE_LOADER, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class, PROP_SOCKET_TYPE,
- g_param_spec_gtype ("socket-type", "socket type", "type to use for creating sockets",
- SWFDEC_TYPE_SOCKET, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class, PROP_URL,
- g_param_spec_boxed ("url", "url", "URL of resource currently played back or NULL if not set",
- SWFDEC_TYPE_URL, G_PARAM_READABLE));
- g_object_class_install_property (object_class, PROP_BASE_URL,
- g_param_spec_boxed ("base-url", "base url", "base URL for creating new resource or NULL if not set yet",
- SWFDEC_TYPE_URL, G_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_VARIABLES,
- g_param_spec_string ("variables", "variables", "variables to use when setting the URL",
- NULL, G_PARAM_READWRITE));
-
- /**
- * SwfdecPlayer::invalidate:
- * @player: the #SwfdecPlayer affected
- * @extents: the smallest rectangle enclosing the full region of changes
- * @rectangles: a number of smaller rectangles for fine-grained control over
- * changes
- * @n_rectangles: number of rectangles in @rectangles
- *
- * This signal is emitted whenever graphical elements inside the player have
- * changed. It provides two ways to look at the changes: By looking at the
- * @extents parameter, it provides a simple way to get a single rectangle that
- * encloses all changes. By looking at the @rectangles array, you can get
- * finer control over changes which is very useful if your rendering system
- * provides a way to handle regions.
- */
- signals[INVALIDATE] = g_signal_new ("invalidate", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL, swfdec_marshal_VOID__BOXED_POINTER_UINT,
- G_TYPE_NONE, 3, SWFDEC_TYPE_RECTANGLE, G_TYPE_POINTER, G_TYPE_UINT);
- /**
- * SwfdecPlayer::advance:
- * @player: the #SwfdecPlayer affected
- * @msecs: the amount of milliseconds the player will advance
- * @audio_samples: number of frames the audio is advanced (in 44100Hz steps)
- *
- * Emitted whenever the player advances.
- */
- signals[ADVANCE] = g_signal_new ("advance", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (SwfdecPlayerClass, advance),
- NULL, NULL, swfdec_marshal_VOID__ULONG_UINT,
- G_TYPE_NONE, 2, G_TYPE_ULONG, G_TYPE_UINT);
- /**
- * SwfdecPlayer::handle-key:
- * @player: the #SwfdecPlayer affected
- * @key: #SwfdecKey that was pressed or released
- * @pressed: %TRUE if the @key was pressed or %FALSE if it was released
- *
- * This signal is emitted whenever @player should respond to a key event. If
- * any of the handlers returns TRUE, swfdec_player_key_press() or
- * swfdec_player_key_release() will return TRUE. Note that unlike many event
- * handlers in gtk, returning TRUE will not stop further event handlers from
- * being invoked. Use g_signal_stop_emission() in that case.
- *
- * Returns: TRUE if this handler handles the event.
- **/
- signals[HANDLE_KEY] = g_signal_new ("handle-key", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (SwfdecPlayerClass, handle_key),
- swfdec_accumulate_or, NULL, swfdec_marshal_BOOLEAN__UINT_UINT_BOOLEAN,
- G_TYPE_BOOLEAN, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_BOOLEAN);
- /**
- * SwfdecPlayer::handle-mouse:
- * @player: the #SwfdecPlayer affected
- * @x: new x coordinate of the mouse
- * @y: new y coordinate of the mouse
- * @button: 0 for a mouse move, a positive number if a button was pressed,
- * a negative number if a button was released
- *
- * This signal is emitted whenever @player should respond to a mouse event. If
- * any of the handlers returns TRUE, swfdec_player_handle_mouse() will return
- * TRUE. Note that unlike many event handlers in gtk, returning TRUE will not
- * stop further event handlers from being invoked. Use g_signal_stop_emission()
- * in that case.
- *
- * Returns: TRUE if this handler handles the event.
- **/
- signals[HANDLE_MOUSE] = g_signal_new ("handle-mouse", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (SwfdecPlayerClass, handle_mouse),
- swfdec_accumulate_or, NULL, swfdec_marshal_BOOLEAN__DOUBLE_DOUBLE_INT,
- G_TYPE_BOOLEAN, 3, G_TYPE_DOUBLE, G_TYPE_DOUBLE, G_TYPE_INT);
- /**
- * SwfdecPlayer::audio-added:
- * @player: the #SwfdecPlayer affected
- * @audio: the audio stream that was added
- *
- * Emitted whenever a new audio stream was added to @player.
- */
- signals[AUDIO_ADDED] = g_signal_new ("audio-added", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, SWFDEC_TYPE_AUDIO);
- /**
- * SwfdecPlayer::audio-removed:
- * @player: the #SwfdecPlayer affected
- * @audio: the audio stream that was removed
- *
- * Emitted whenever an audio stream was removed from @player. The stream will
- * have been added with the SwfdecPlayer::audio-added signal previously.
- */
- signals[AUDIO_REMOVED] = g_signal_new ("audio-removed", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, SWFDEC_TYPE_AUDIO);
- /**
- * SwfdecPlayer::fscommand:
- * @player: the #SwfdecPlayer affected
- * @command: the command to execute. This is a lower case string.
- * @parameter: parameter to pass to the command. The parameter depends on the
- * function.
- *
- * This signal is emited whenever a Flash script command (also known as
- * fscommand) is encountered. This method is ued by the Flash file to
- * communicate with the hosting environment. In web browsers it is used to
- * call Javascript functions. Standalone Flash players understand a limited
- * set of functions. They vary from player to player, but the most common are
- * listed here: <itemizedlist>
- * <listitem><para>"quit": quits the player.</para></listitem>
- * <listitem><para>"fullscreen": A boolean setting (parameter is "true" or
- * "false") that sets the player into fullscreen mode.</para></listitem>
- * <listitem><para>"allowscale": A boolean setting that tells the player to
- * not scale the Flash application.</para></listitem>
- * <listitem><para>"showmenu": A boolean setting that tells the Flash player
- * to not show its own entries in the right-click menu.</para></listitem>
- * <listitem><para>"exec": Run an external executable. The parameter
- * specifies the path.</para></listitem>
- * <listitem><para>"trapallkeys": A boolean setting that tells the Flash
- * player to pass all key events to the Flash application instead of using it
- * for keyboard shortcuts or similar.</para></listitem>
- * </itemizedlist>
- */
- /* FIXME: document fscommand:toggle */
- signals[FSCOMMAND] = g_signal_new ("fscommand", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL, swfdec_marshal_VOID__STRING_STRING,
- G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
- /**
- * SwfdecPlayer::launch:
- * @player: the #SwfdecPlayer affected
- * @request: the type of request
- * @url: URL to open
- * @target: target to load the URL into
- * @data: optional data to pass on with the request. Will be of mime type
- * application/x-www-form-urlencoded. Can be %NULL indicating no data
- * should be passed.
- *
- * Emitted whenever the @player encounters an URL that should be loaded into
- * a target the Flash player does not recognize. In most cases this happens
- * when the user clicks a link in an embedded Flash movie that should open a
- * new web page.
- * The effect of calling any swfdec functions on the emitting @player is undefined.
- */
- signals[LAUNCH] = g_signal_new ("launch", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL, swfdec_marshal_VOID__ENUM_STRING_STRING_BOXED,
- G_TYPE_NONE, 4, SWFDEC_TYPE_LOADER_REQUEST, G_TYPE_STRING, G_TYPE_STRING,
- SWFDEC_TYPE_BUFFER);
-
- context_class->mark = swfdec_player_mark;
- context_class->get_time = swfdec_player_get_time;
- context_class->check_continue = swfdec_player_check_continue;
-
- klass->advance = swfdec_player_do_advance;
- klass->handle_key = swfdec_player_do_handle_key;
- klass->handle_mouse = swfdec_player_do_handle_mouse;
-}
-
-static void
-swfdec_player_init (SwfdecPlayer *player)
-{
- SwfdecPlayerPrivate *priv;
- guint i;
-
- player->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (player, SWFDEC_TYPE_PLAYER, SwfdecPlayerPrivate);
- priv->player = player;
-
- priv->system = swfdec_system_new ();
- priv->registered_classes = g_hash_table_new (g_direct_hash, g_direct_equal);
- priv->scripting_callbacks = g_hash_table_new (g_direct_hash, g_direct_equal);
-
- for (i = 0; i < SWFDEC_PLAYER_N_ACTION_QUEUES; i++) {
- priv->actions[i] = swfdec_ring_buffer_new_for_type (SwfdecPlayerAction, 16);
- }
- priv->external_actions = swfdec_ring_buffer_new_for_type (SwfdecPlayerExternalAction, 8);
- priv->cache = swfdec_cache_new (50 * 1024 * 1024); /* 100 MB */
- priv->bgcolor = SWFDEC_COLOR_COMBINE (0xFF, 0xFF, 0xFF, 0xFF);
- priv->socket_type = SWFDEC_TYPE_SOCKET;
-
- priv->runtime = g_timer_new ();
- g_timer_stop (priv->runtime);
- priv->max_runtime = 10 * 1000;
- priv->invalidations = g_array_new (FALSE, FALSE, sizeof (SwfdecRectangle));
- priv->mouse_visible = TRUE;
- priv->mouse_cursor = SWFDEC_MOUSE_CURSOR_NORMAL;
- priv->iterate_timeout.callback = swfdec_player_iterate;
- priv->stage_width = -1;
- priv->stage_height = -1;
-}
-
-void
-swfdec_player_stop_all_sounds (SwfdecPlayer *player)
-{
- SwfdecPlayerPrivate *priv;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
-
- priv = player->priv;
- while (priv->audio) {
- swfdec_audio_remove (priv->audio->data);
- }
-}
-
-void
-swfdec_player_stop_sounds (SwfdecPlayer *player, SwfdecAudioRemoveFunc func, gpointer data)
-{
- GList *walk;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (func);
-
- walk = player->priv->audio;
- while (walk) {
- SwfdecAudio *audio = walk->data;
- walk = walk->next;
- if (func (audio, data))
- swfdec_audio_remove (audio);
- }
-}
-
-/* rect is in global coordinates */
-void
-swfdec_player_invalidate (SwfdecPlayer *player, const SwfdecRect *rect)
-{
- SwfdecPlayerPrivate *priv = player->priv;
- SwfdecRectangle r;
- SwfdecRect tmp;
- guint i;
-
- if (swfdec_rect_is_empty (rect))
- return;
-
- tmp = *rect;
- swfdec_player_global_to_stage (player, &tmp.x0, &tmp.y0);
- swfdec_player_global_to_stage (player, &tmp.x1, &tmp.y1);
- swfdec_rectangle_init_rect (&r, &tmp);
- /* FIXME: currently we clamp the rectangle to the visible area, it might
- * be useful to allow out-of-bounds drawing. In that case this needs to be
- * changed */
- swfdec_rectangle_intersect (&r, &r, &priv->stage);
- if (swfdec_rectangle_is_empty (&r))
- return;
-
- SWFDEC_LOG (" invalidating %d %d %d %d", r.x, r.y, r.width, r.height);
- /* FIXME: get region code into swfdec? */
- for (i = 0; i < priv->invalidations->len; i++) {
- SwfdecRectangle *cur = &g_array_index (priv->invalidations, SwfdecRectangle, i);
- if (swfdec_rectangle_contains (cur, &r))
- break;
- if (swfdec_rectangle_contains (&r, cur)) {
- *cur = r;
- swfdec_rectangle_union (&priv->invalid_extents, &priv->invalid_extents, &r);
- }
- }
- if (i == priv->invalidations->len) {
- g_array_append_val (priv->invalidations, r);
- swfdec_rectangle_union (&priv->invalid_extents, &priv->invalid_extents, &r);
- }
- SWFDEC_DEBUG ("toplevel invalidation of %g %g %g %g - invalid region now %d %d %d %d (%u subregions)",
- rect->x0, rect->y0, rect->x1, rect->y1,
- priv->invalid_extents.x, priv->invalid_extents.y,
- priv->invalid_extents.x + priv->invalid_extents.width,
- priv->invalid_extents.y + priv->invalid_extents.height,
- priv->invalidations->len);
-}
-
-/**
- * swfdec_player_get_level:
- * @player: a #SwfdecPlayer
- * @name: a name that is supposed to refer to a level
- *
- * Checks if the given @name refers to a level, and if so, returns the level.
- * An example for such a name is "_level5". These strings are used to refer to
- * root movies inside the Flash player.
- *
- * Returns: the level referred to by @name or -1 if none
- **/
-int
-swfdec_player_get_level (SwfdecPlayer *player, const char *name)
-{
- char *end;
- gulong l;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), -1);
- g_return_val_if_fail (name != NULL, -1);
-
- /* check name starts with "_level" */
- if (swfdec_strncmp (SWFDEC_AS_CONTEXT (player)->version, name, "_level", 6) != 0)
- return -1;
- name += 6;
- /* extract depth from rest string (or fail if it's not a depth) */
- errno = 0;
- l = strtoul (name, &end, 10);
- if (errno != 0 || *end != 0 || l > G_MAXINT)
- return -1;
- return l;
-}
-
-SwfdecSpriteMovie *
-swfdec_player_create_movie_at_level (SwfdecPlayer *player, SwfdecResource *resource,
- int level)
-{
- SwfdecMovie *movie;
- const char *s;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (level >= 0, NULL);
- g_return_val_if_fail (swfdec_player_get_movie_at_level (player, level) == NULL, NULL);
-
- /* create new root movie */
- s = swfdec_as_context_give_string (SWFDEC_AS_CONTEXT (player), g_strdup_printf ("_level%d", level));
- movie = swfdec_movie_new (player, level - 16384, NULL, resource, NULL, s);
- if (movie == NULL)
- return NULL;
- movie->name = SWFDEC_AS_STR_EMPTY;
- return SWFDEC_SPRITE_MOVIE (movie);
-}
-
-/**
- * swfdec_player_get_movie_at_level:
- * @player: a #SwfdecPlayer
- * @level: number of the level
- *
- * This function is used to look up root movies in the given @player.
- *
- * Returns: the #SwfdecMovie located at the given level or %NULL if there is no
- * movie at that level.
- **/
-SwfdecSpriteMovie *
-swfdec_player_get_movie_at_level (SwfdecPlayer *player, int level)
-{
- GList *walk;
- int depth;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (level >= 0, NULL);
-
- depth = level - 16384;
- /* find movie */
- for (walk = player->priv->roots; walk; walk = walk->next) {
- SwfdecMovie *cur = walk->data;
- if (cur->depth < depth)
- continue;
- if (cur->depth == depth)
- return SWFDEC_SPRITE_MOVIE (cur);
- break;
- }
- return NULL;
-}
-
-void
-swfdec_player_launch (SwfdecPlayer *player, SwfdecLoaderRequest request, const char *url,
- const char *target, SwfdecBuffer *data)
-{
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (url != NULL);
- g_return_if_fail (target != NULL);
-
- if (!g_ascii_strncasecmp (url, "FSCommand:", strlen ("FSCommand:"))) {
- const char *command = url + strlen ("FSCommand:");
- g_signal_emit (player, signals[FSCOMMAND], 0, command, target);
- return;
- }
- g_signal_emit (player, signals[LAUNCH], 0, (int) request, url, target, data);
-}
-
-/**
- * swfdec_player_initialize:
- * @player: a #SwfdecPlayer
- * @version: Flash version to use
- * @rate: framerate in 256th or 0 for undefined
- * @width: width of movie
- * @height: height of movie
- *
- * Initializes the player to the given @version, @width, @height and @rate. If
- * the player is already initialized, this function does nothing.
- **/
-void
-swfdec_player_initialize (SwfdecPlayer *player, guint rate, guint width, guint height)
-{
- SwfdecPlayerPrivate *priv;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (rate > 0);
-
- priv = player->priv;
- if (!priv->initialized) {
- priv->initialized = TRUE;
- g_object_notify (G_OBJECT (player), "initialized");
- } else {
- /* FIXME: need to kick all other movies out here */
- swfdec_player_remove_timeout (player, &priv->iterate_timeout);
- }
-
- SWFDEC_INFO ("initializing player to size %ux%u and rate %u/256", width, height, rate);
- if (rate != priv->rate) {
- priv->rate = rate;
- g_object_notify (G_OBJECT (player), "rate");
- }
- if (priv->width != width) {
- priv->width = width;
- g_object_notify (G_OBJECT (player), "default-width");
- }
- if (priv->height != height) {
- priv->height = height;
- g_object_notify (G_OBJECT (player), "default-height");
- }
- priv->broadcasted_width = priv->internal_width = priv->stage_width >= 0 ? (guint) priv->stage_width : priv->width;
- priv->broadcasted_height = priv->internal_height = priv->stage_height >= 0 ? (guint) priv->stage_height : priv->height;
- swfdec_player_update_scale (player);
-
- priv->iterate_timeout.timestamp = priv->time + SWFDEC_TICKS_PER_SECOND * 256 / priv->rate / 10;
- swfdec_player_add_timeout (player, &priv->iterate_timeout);
- SWFDEC_LOG ("initialized iterate timeout %p to %"G_GUINT64_FORMAT" (now %"G_GUINT64_FORMAT")",
- &priv->iterate_timeout, priv->iterate_timeout.timestamp, priv->time);
-}
-
-/**
- * swfdec_player_get_export_class:
- * @player: a #SwfdecPlayer
- * @name: garbage-collected string naming the export
- *
- * Looks up the constructor for characters that are exported using @name.
- *
- * Returns: a #SwfdecAsObject naming the constructor or %NULL if none
- **/
-SwfdecAsObject *
-swfdec_player_get_export_class (SwfdecPlayer *player, const char *name)
-{
- SwfdecPlayerPrivate *priv = player->priv;
- SwfdecAsObject *ret;
-
- ret = g_hash_table_lookup (priv->registered_classes, name);
- if (ret) {
- SWFDEC_LOG ("found registered class %p for %s", ret, name);
- return ret;
- }
- return NULL;
-}
-
-/**
- * swfdec_player_set_export_class:
- * @player: a #SwfdecPlayer
- * @name: garbage-collected string naming the export
- * @object: object to use as constructor or %NULL for none
- *
- * Sets the constructor to be used for instances created using the object
- * exported with @name.
- **/
-void
-swfdec_player_set_export_class (SwfdecPlayer *player, const char *name, SwfdecAsObject *object)
-{
- SwfdecPlayerPrivate *priv;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (name != NULL);
- g_return_if_fail (object == NULL || SWFDEC_IS_AS_OBJECT (object));
-
- priv = player->priv;
- if (object) {
- SWFDEC_LOG ("setting class %p for %s", object, name);
- g_hash_table_insert (priv->registered_classes, (gpointer) name, object);
- } else {
- g_hash_table_remove (priv->registered_classes, name);
- }
-}
-
-/**
- * swfdec_player_create_socket:
- * @player: a #SwfdecPlayer
- * @hostname: the host name to connect to.
- * @port: the port to connect to
- *
- * Creates a new socket connecting to the given hostname and port.
- *
- * Returns: a new socket or %NULL if no socket implementation exists
- **/
-/* FIXME: always return a socket? */
-SwfdecSocket *
-swfdec_player_create_socket (SwfdecPlayer *player, const char *hostname, guint port)
-{
- SwfdecSocket *sock;
- SwfdecSocketClass *klass;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (hostname != NULL, NULL);
- g_return_val_if_fail (port > 0, NULL);
-
- if (!G_TYPE_IS_INSTANTIATABLE (player->priv->socket_type)) {
- SWFDEC_INFO ("can't create socket, no socket type set.");
- return NULL;
- }
- klass = g_type_class_ref (player->priv->socket_type);
- sock = klass->create (hostname, port);
- g_type_class_unref (klass);
-
- return sock;
-}
-
-SwfdecURL *
-swfdec_player_create_url (SwfdecPlayer *player, const char *string)
-{
- SwfdecURL *url;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (string != NULL, NULL);
-
- url = swfdec_url_new_relative (player->priv->base_url, string);
- /* FIXME: check that we don't go below base for local urls */
- return url;
-}
-
-SwfdecLoader *
-swfdec_player_load (SwfdecPlayer *player, const char *url,
- SwfdecLoaderRequest request, SwfdecBuffer *buffer)
-{
- SwfdecLoader *loader;
- SwfdecLoaderClass *klass;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (url != NULL, NULL);
-
- loader = g_object_new (player->priv->loader_type, NULL);
- klass = SWFDEC_LOADER_GET_CLASS (loader);
- g_return_val_if_fail (klass->load != NULL, NULL);
- klass->load (loader, player, url, request, buffer);
-
- return loader;
-}
-
-/** PUBLIC API ***/
-
-/**
- * swfdec_player_new:
- * @debugger: %NULL or a #SwfdecAsDebugger to use for debugging this player.
- *
- * Creates a new player. This function is supposed to be used for testing.
- * Because of this, the created player will behave as predictable as possible.
- * For example, it will generate the same random number sequence every time.
- * The function calls swfdec_init () for you if it wasn't called before.
- *
- * Returns: The new player
- **/
-SwfdecPlayer *
-swfdec_player_new (SwfdecAsDebugger *debugger)
-{
- static const GTimeVal the_beginning = { 1035840244, 0 };
- SwfdecPlayer *player;
-
- g_return_val_if_fail (debugger == NULL || SWFDEC_IS_AS_DEBUGGER (debugger), NULL);
-
- swfdec_init ();
- player = g_object_new (SWFDEC_TYPE_PLAYER, "random-seed", 0,
- "loader-type", SWFDEC_TYPE_FILE_LOADER, "socket-type", SWFDEC_TYPE_SOCKET,
- "max-runtime", 0,
- "debugger", debugger, NULL);
- /* FIXME: make this a property or something and don't set it here */
- SWFDEC_AS_CONTEXT (player)->start_time = the_beginning;
-
- return player;
-}
-
-/**
- * swfdec_init:
- *
- * Initializes the Swfdec library.
- **/
-void
-swfdec_init (void)
-{
- static gboolean _inited = FALSE;
- const char *s;
-
- if (_inited)
- return;
-
- _inited = TRUE;
-
- if (!g_thread_supported ())
- g_thread_init (NULL);
- g_type_init ();
- oil_init ();
-
- s = g_getenv ("SWFDEC_DEBUG");
- if (s && s[0]) {
- char *end;
- int level;
-
- level = strtoul (s, &end, 0);
- if (end[0] == 0) {
- swfdec_debug_set_level (level);
- }
- }
-}
-
-/**
- * swfdec_player_mouse_move:
- * @player: a #SwfdecPlayer
- * @x: x coordinate of mouse
- * @y: y coordinate of mouse
- *
- * Updates the current mouse position. If the mouse has left the area of @player,
- * you should pass values outside the movie size for @x and @y. You will
- * probably want to call swfdec_player_advance() before to update the player to
- * the correct time when calling this function.
- *
- * Returns: %TRUE if the mouse event was handled. %FALSE if the event should be
- * propagated further. A mouse event may not be handled if the user
- * clicked on a translucent area.
- **/
-gboolean
-swfdec_player_mouse_move (SwfdecPlayer *player, double x, double y)
-{
- gboolean ret;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE);
-
- g_signal_emit (player, signals[HANDLE_MOUSE], 0, x, y, 0, &ret);
-
- return ret;
-}
-
-/**
- * swfdec_player_mouse_press:
- * @player: a #SwfdecPlayer
- * @x: x coordinate of mouse
- * @y: y coordinate of mouse
- * @button: number of the button that was pressed. Swfdec supports up to 32
- * buttons.
- *
- * Tells the @player that the mouse button @button was pressed at the given
- * coordinate.
- *
- * Returns: %TRUE if the mouse event was handled. %FALSE if the event should be
- * propagated further. A mouse event may not be handled if the user
- * clicked on a translucent area.
- **/
-gboolean
-swfdec_player_mouse_press (SwfdecPlayer *player, double x, double y,
- guint button)
-{
- gboolean ret;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE);
- g_return_val_if_fail (button > 0 && button <= 32, FALSE);
-
- g_signal_emit (player, signals[HANDLE_MOUSE], 0, x, y, button, &ret);
-
- return ret;
-}
-
-/**
- * swfdec_player_mouse_release:
- * @player: a #SwfdecPlayer
- * @x: x coordinate of mouse
- * @y: y coordinate of mouse
- * @button: number of the button that was released. Swfdec supports up to 32
- * buttons.
- *
- * Tells the @player that the mouse button @button was released at the given
- * coordinate.
- *
- * Returns: %TRUE if the mouse event was handled. %FALSE if the event should be
- * propagated further. A mouse event may not be handled if the user
- * clicked on a translucent area.
- **/
-gboolean
-swfdec_player_mouse_release (SwfdecPlayer *player, double x, double y,
- guint button)
-{
- gboolean ret;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE);
- g_return_val_if_fail (button > 0 && button <= 32, FALSE);
-
- g_signal_emit (player, signals[HANDLE_MOUSE], 0, x, y, -button, &ret);
-
- return ret;
-}
-
-/**
- * swfdec_player_key_press:
- * @player: a #SwfdecPlayer
- * @keycode: the key that was pressed
- * @character: UCS4 of the character that was inserted or 0 if none
- *
- * Call this function to make the @player react to a key press. Be sure to
- * check that keycode transformations are done correctly. For a list of
- * keycodes see FIXME.
- *
- * Returns: %TRUE if the key press was handled by the @player, %FALSE if it
- * should be propagated further
- **/
-gboolean
-swfdec_player_key_press (SwfdecPlayer *player, guint keycode, guint character)
-{
- gboolean ret;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE);
- g_return_val_if_fail (keycode < 256, FALSE);
-
- g_signal_emit (player, signals[HANDLE_KEY], 0, keycode, character, TRUE, &ret);
-
- return ret;
-}
-
-/**
- * swfdec_player_key_release:
- * @player: a #SwfdecPlayer
- * @keycode: the key that was released
- * @character: UCS4 of the character that was inserted or 0 if none
- *
- * Call this function to make the @player react to a key being released. See
- * swfdec_player_key_press() for details.
- *
- * Returns: %TRUE if the key press was handled by the @player, %FALSE if it
- * should be propagated further
- **/
-gboolean
-swfdec_player_key_release (SwfdecPlayer *player, guint keycode, guint character)
-{
- gboolean ret;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE);
- g_return_val_if_fail (keycode < 256, FALSE);
-
- g_signal_emit (player, signals[HANDLE_KEY], 0, keycode, character, FALSE, &ret);
-
- return ret;
-}
-
-/**
- * swfdec_player_render:
- * @player: a #SwfdecPlayer
- * @cr: #cairo_t to render to
- * @x: x coordinate of top left position to render
- * @y: y coordinate of top left position to render
- * @width: width of area to render or 0 for full width
- * @height: height of area to render or 0 for full height
- *
- * Renders the given area of the current frame to @cr.
- **/
-void
-swfdec_player_render (SwfdecPlayer *player, cairo_t *cr,
- double x, double y, double width, double height)
-{
- static const SwfdecColorTransform trans = { FALSE, 256, 0, 256, 0, 256, 0, 256, 0 };
- SwfdecPlayerPrivate *priv;
- GList *walk;
- SwfdecRect real;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (cr != NULL);
- g_return_if_fail (width >= 0.0);
- g_return_if_fail (height >= 0.0);
-
- /* FIXME: fail when !initialized? */
- if (!swfdec_player_is_initialized (player))
- return;
-
- priv = player->priv;
- if (width == 0.0)
- width = priv->stage_width;
- if (height == 0.0)
- height = priv->stage_height;
- /* clip the area */
- cairo_save (cr);
- cairo_rectangle (cr, x, y, width, height);
- cairo_clip (cr);
- /* compute the rectangle */
- x -= priv->offset_x;
- y -= priv->offset_y;
- real.x0 = floor (x * SWFDEC_TWIPS_SCALE_FACTOR) / priv->scale_x;
- real.y0 = floor (y * SWFDEC_TWIPS_SCALE_FACTOR) / priv->scale_y;
- real.x1 = ceil ((x + width) * SWFDEC_TWIPS_SCALE_FACTOR) / priv->scale_x;
- real.y1 = ceil ((y + height) * SWFDEC_TWIPS_SCALE_FACTOR) / priv->scale_y;
- SWFDEC_INFO ("=== %p: START RENDER, area %g %g %g %g ===", player,
- real.x0, real.y0, real.x1, real.y1);
- /* convert the cairo matrix */
- cairo_translate (cr, priv->offset_x, priv->offset_y);
- cairo_scale (cr, priv->scale_x / SWFDEC_TWIPS_SCALE_FACTOR, priv->scale_y / SWFDEC_TWIPS_SCALE_FACTOR);
- swfdec_color_set_source (cr, priv->bgcolor);
- cairo_paint (cr);
-
- for (walk = priv->roots; walk; walk = walk->next) {
- swfdec_movie_render (walk->data, cr, &trans, &real);
- }
- SWFDEC_INFO ("=== %p: END RENDER ===", player);
- cairo_restore (cr);
-}
-
-/**
- * swfdec_player_advance:
- * @player: the #SwfdecPlayer to advance
- * @msecs: number of milliseconds to advance
- *
- * Advances @player by @msecs. You should make sure to call this function as
- * often as the SwfdecPlayer::next-event property indicates.
- **/
-void
-swfdec_player_advance (SwfdecPlayer *player, gulong msecs)
-{
- SwfdecPlayerPrivate *priv;
- guint frames;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
-
- priv = player->priv;
- frames = SWFDEC_TICKS_TO_SAMPLES (priv->time + SWFDEC_MSECS_TO_TICKS (msecs))
- - SWFDEC_TICKS_TO_SAMPLES (priv->time);
- g_signal_emit (player, signals[ADVANCE], 0, msecs, frames);
-}
-
-/**
- * swfdec_player_is_initialized:
- * @player: a #SwfdecPlayer
- *
- * Determines if the @player is initalized yet. An initialized player is able
- * to provide basic values like width, height or rate. A player may not be
- * initialized if the loader it was started with does not reference a Flash
- * resources or it did not provide enough data yet. If a player is initialized,
- * it will never be uninitialized again.
- *
- * Returns: TRUE if the basic values are known.
- **/
-gboolean
-swfdec_player_is_initialized (SwfdecPlayer *player)
-{
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE);
-
- return player->priv->initialized;
-}
-
-/**
- * swfdec_player_get_next_event:
- * @player: ia #SwfdecPlayer
- *
- * Queries how long to the next event. This is the next time when you should
- * call swfdec_player_advance() to forward to.
- *
- * Returns: number of milliseconds until next event or -1 if no outstanding event
- **/
-glong
-swfdec_player_get_next_event (SwfdecPlayer *player)
-{
- SwfdecTick tick;
- guint ret;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), 0);
-
- if (swfdec_as_context_is_aborted (SWFDEC_AS_CONTEXT (player)))
- return -1;
-
- tick = swfdec_player_get_next_event_time (player);
- if (tick == G_MAXUINT64)
- return -1;
- /* round up to full msecs */
- ret = SWFDEC_TICKS_TO_MSECS (tick + SWFDEC_TICKS_PER_SECOND / 1000 - 1);
-
- return ret;
-}
-
-/**
- * swfdec_player_get_rate:
- * @player: a #SwfdecPlayer
- *
- * Queries the framerate of this movie. This number specifies the number
- * of frames that are supposed to pass per second. It is a
- * multiple of 1/256. It is possible that the movie has no framerate if it does
- * not display a Flash movie but an FLV video for example. This does not mean
- * it will not change however.
- *
- * Returns: The framerate of this movie or 0 if it isn't known yet or the
- * movie doesn't have a framerate.
- **/
-double
-swfdec_player_get_rate (SwfdecPlayer *player)
-{
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), 0.0);
-
- return player->priv->rate / 256.0;
-}
-
-/**
- * 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
- *
- * If the default size of the movie is initialized, fills in @width and @height
- * with the size. Otherwise @width and @height are set to 0.
- **/
-void
-swfdec_player_get_default_size (SwfdecPlayer *player, guint *width, guint *height)
-{
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
-
- if (width)
- *width = player->priv->width;
- if (height)
- *height = player->priv->height;
-}
-
-/**
- * swfdec_player_get_size:
- * @player: a #SwfdecPlayer
- * @width: integer to store the width in or %NULL
- * @height: integer to store the height in or %NULL
- *
- * Gets the currently set image size. If the default width or height should be
- * used, the width or height respectively is set to -1.
- **/
-void
-swfdec_player_get_size (SwfdecPlayer *player, int *width, int *height)
-{
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
-
- if (width)
- *width = player->priv->stage_width;
- if (height)
- *height = player->priv->stage_height;
-}
-
-static void
-swfdec_player_update_size (gpointer playerp, gpointer unused)
-{
- SwfdecPlayer *player = playerp;
- SwfdecPlayerPrivate *priv = player->priv;
-
- /* FIXME: only update if not fullscreen */
- priv->internal_width = priv->stage_width >=0 ? (guint) priv->stage_width : priv->width;
- priv->internal_height = priv->stage_height >=0 ? (guint) priv->stage_height : priv->height;
-
- if (priv->scale_mode != SWFDEC_SCALE_NONE)
- return;
-
- /* only broadcast once */
- if (priv->internal_width == priv->broadcasted_width &&
- priv->internal_height == priv->broadcasted_height)
- return;
-
- priv->broadcasted_width = priv->internal_width;
- priv->broadcasted_height = priv->internal_height;
- swfdec_player_broadcast (player, SWFDEC_AS_STR_Stage, SWFDEC_AS_STR_onResize);
-}
-
-/**
- * swfdec_player_set_size:
- * @player: a #SwfdecPlayer
- * @width: desired width of the movie or -1 for default
- * @height: desired height of the movie or -1 for default
- *
- * Sets the image size to the given values. The image size is what the area that
- * the @player will render and advocate with scripts.
- **/
-void
-swfdec_player_set_size (SwfdecPlayer *player, int width, int height)
-{
- SwfdecPlayerPrivate *priv;
- gboolean changed = FALSE;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (width >= -1);
- g_return_if_fail (height >= -1);
-
- priv = player->priv;
- if (priv->stage_width != width) {
- priv->stage_width = width;
- g_object_notify (G_OBJECT (player), "width");
- changed = TRUE;
- }
- if (priv->stage_height != height) {
- priv->stage_height = height;
- g_object_notify (G_OBJECT (player), "height");
- changed = TRUE;
- }
- swfdec_player_update_scale (player);
- if (changed)
- swfdec_player_add_external_action (player, player, swfdec_player_update_size, NULL);
-}
-
-/**
- * swfdec_player_get_audio:
- * @player: a #SwfdecPlayer
- *
- * Returns a list of all currently active audio streams in @player.
- *
- * Returns: A #GList of #SwfdecAudio. You must not modify or free this list.
- **/
-/* FIXME: I don't like this function */
-const GList *
-swfdec_player_get_audio (SwfdecPlayer * player)
-{
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
-
- return player->priv->audio;
-}
-
-/**
- * swfdec_player_get_background_color:
- * @player: a #SwfdecPlayer
- *
- * Gets the current background color. The color will be an ARGB-quad, with the
- * MSB being the alpha value.
- *
- * Returns: the background color as an ARGB value
- **/
-guint
-swfdec_player_get_background_color (SwfdecPlayer *player)
-{
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), SWFDEC_COLOR_COMBINE (0xFF, 0xFF, 0xFF, 0xFF));
-
- return player->priv->bgcolor;
-}
-
-/**
- * swfdec_player_set_background_color:
- * @player: a #SwfdecPlayer
- * @color: new color to use as background color
- *
- * Sets a new background color as an ARGB value. To get transparency, set the
- * value to 0. To get a black beackground, use 0xFF000000.
- **/
-void
-swfdec_player_set_background_color (SwfdecPlayer *player, guint color)
-{
- SwfdecPlayerPrivate *priv;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
-
- priv = player->priv;
- priv->bgcolor_set = TRUE;
- if (priv->bgcolor == color)
- return;
- priv->bgcolor = color;
- g_object_notify (G_OBJECT (player), "background-color");
- if (swfdec_player_is_initialized (player)) {
- g_signal_emit (player, signals[INVALIDATE], 0, 0.0, 0.0,
- (double) priv->width, (double) priv->height);
- }
-}
-
-/**
- * swfdec_player_get_scale_mode:
- * @player: a #SwfdecPlayer
- *
- * Gets the currrent mode used for scaling the movie. See #SwfdecScaleMode for
- * the different modes.
- *
- * Returns: the current scale mode
- **/
-SwfdecScaleMode
-swfdec_player_get_scale_mode (SwfdecPlayer *player)
-{
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), SWFDEC_SCALE_SHOW_ALL);
-
- return player->priv->scale_mode;
-}
-
-/**
- * swfdec_player_set_scale_mode:
- * @player: a #SwfdecPlayer
- * @mode: a #SwfdecScaleMode
- *
- * Sets the currrent mode used for scaling the movie. See #SwfdecScaleMode for
- * the different modes.
- **/
-void
-swfdec_player_set_scale_mode (SwfdecPlayer *player, SwfdecScaleMode mode)
-{
- SwfdecPlayerPrivate *priv;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
-
- priv = player->priv;
- if (priv->scale_mode != mode) {
- priv->scale_mode = mode;
- swfdec_player_update_scale (player);
- g_object_notify (G_OBJECT (player), "scale-mode");
- swfdec_player_add_external_action (player, player, swfdec_player_update_size, NULL);
- }
-}
-
-/**
- * swfdec_player_get_alignment:
- * @player: a #SwfdecPlayer
- *
- * Gets the alignment of the player. The alignment describes what point is used
- * as the anchor for drawing the contents. See #SwfdecAlignment for possible
- * values.
- *
- * Returns: the current alignment
- **/
-SwfdecAlignment
-swfdec_player_get_alignment (SwfdecPlayer *player)
-{
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), SWFDEC_ALIGNMENT_CENTER);
-
- return swfdec_player_alignment_from_flags (player->priv->align_flags);
-}
-
-/**
- * swfdec_player_set_alignment:
- * @player: a #SwfdecPlayer
- * @align: #SwfdecAlignment to set
- *
- * Sets the alignment to @align. For details about alignment, see
- * swfdec_player_get_alignment() and #SwfdecAlignment.
- **/
-void
-swfdec_player_set_alignment (SwfdecPlayer *player, SwfdecAlignment align)
-{
- guint flags;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
-
- flags = swfdec_player_alignment_to_flags (align);
- swfdec_player_set_align_flags (player, flags);
-}
-
-void
-swfdec_player_set_align_flags (SwfdecPlayer *player, guint flags)
-{
- SwfdecPlayerPrivate *priv;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
-
- priv = player->priv;
- if (flags != priv->align_flags) {
- priv->align_flags = flags;
- swfdec_player_update_scale (player);
- g_object_notify (G_OBJECT (player), "alignment");
- }
-}
-
-/**
- * swfdec_player_get_maximum_runtime:
- * @player: a #SwfdecPlayer
- *
- * Queries the given @player for how long scripts may run. see
- * swfdec_player_set_maximum_runtime() for a longer discussion of this value.
- *
- * Returns: the maximum time in milliseconds that scripts are allowed to run or
- * 0 for infinite.
- **/
-gulong
-swfdec_player_get_maximum_runtime (SwfdecPlayer *player)
-{
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), 0);
-
- return player->priv->max_runtime;
-}
-
-/**
- * swfdec_player_set_maximum_runtime:
- * @player: a #SwfdecPlayer
- * @msecs: time in milliseconds that scripts are allowed to run or 0 for
- * infinite
- *
- * Sets the time that the player may use to let internal scripts run. If the
- * Flash file that is currently played back does not manage to complete its
- * scripts in the given time, it is aborted. You cannot continue the scripts at
- * a later point in time. However, your application may become unresponsive and
- * your users annoyed if they cannot interact with it for too long. To give a
- * reference point, the Adobe Flash player usually sets this value to 10
- * seconds. Note that this time determines the maximum time calling
- * swfdec_player_advance() may take, even if it is called with a large value.
- * Also note that this setting is ignored when running inside a debugger.
- **/
-void
-swfdec_player_set_maximum_runtime (SwfdecPlayer *player, gulong msecs)
-{
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
-
- player->priv->max_runtime = msecs;
- g_object_notify (G_OBJECT (player), "max-runtime");
-}
-
-/**
- * swfdec_player_get_scripting:
- * @player: a #SwfdecPlayer
- *
- * Gets the current scripting implementation in use. If no implementation is in
- * use (the default), %NULL is returned.
- *
- * Returns: the current scripting implementation used or %NULL if none
- **/
-SwfdecPlayerScripting *
-swfdec_player_get_scripting (SwfdecPlayer *player)
-{
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
-
- return player->priv->scripting;
-}
-
-/**
- * swfdec_player_set_scripting:
- * @player: a #SwfdecPlayer
- * @scripting: the scripting implementation to use or %NULL to disable scripting
- *
- * Sets the implementation to use for external scripting in the given @player.
- * Note that this is different from the internal script engine. See the
- * #SwfdecPlayerScripting paragraph for details about external scripting.
- **/
-void
-swfdec_player_set_scripting (SwfdecPlayer *player, SwfdecPlayerScripting *scripting)
-{
- SwfdecPlayerPrivate *priv;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (scripting == NULL || SWFDEC_IS_PLAYER_SCRIPTING (scripting));
-
- priv = player->priv;
- if (priv->scripting == scripting)
- return;
-
- if (priv->scripting)
- g_object_unref (priv->scripting);
- priv->scripting = g_object_ref (scripting);
- g_object_notify (G_OBJECT (player), "scripting");
-}
-
-/**
- * swfdec_player_get_base_url:
- * @player: a #SwfdecPlayer
- *
- * Gets the base URL that this player uses when resolving a relative URL. It is
- * automatically set to the parent directory of the currently played back
- * resource, but can be changed using swfdec_player_set_base_url(). When no
- * resource has been set on the @player yet, %NULL is returned.
- *
- * Returns: the base #SwfdecURL for resolving relative links or %NULL
- **/
-const SwfdecURL *
-swfdec_player_get_base_url (SwfdecPlayer *player)
-{
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
-
- return player->priv->base_url;
-}
-
-/**
- * swfdec_player_set_base_url:
- * @player: a #SwfdecPlayer
- * @url: a #SwfdecURL or %NULL to reset to defaults
- *
- * Sets the URL that will be used for resolving realtive links inside the
- * @player.
- **/
-void
-swfdec_player_set_base_url (SwfdecPlayer *player, const SwfdecURL *url)
-{
- SwfdecPlayerPrivate *priv;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
-
- priv = player->priv;
- if (priv->base_url)
- swfdec_url_free (priv->base_url);
- if (url == NULL) {
- if (priv->url) {
- priv->base_url = swfdec_url_new_parent (priv->url);
- } else {
- priv->base_url = NULL;
- }
- } else {
- priv->base_url = swfdec_url_copy (url);
- }
- g_object_notify (G_OBJECT (player), "base-url");
-}
-
-/**
- * swfdec_player_get_url:
- * @player: a #SwfdecPlayer
- *
- * Gets the URL of the resource that is currently played back. If no URL has
- * been set on the @player yet, %NULL is returned.
- *
- * Returns: the #SwfdecURL currently played back or %NULL
- **/
-const SwfdecURL *
-swfdec_player_get_url (SwfdecPlayer *player)
-{
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
-
- if (player->priv->resource == NULL)
- return NULL;
-
- return swfdec_loader_get_url (player->priv->resource->loader);
-}
-
-/**
- * swfdec_player_set_url:
- * @player: a #SwfdecPlayer
- * @url: the url for the initial reference in this player
- *
- * Sets the @url for the main data. This function may only be called once.
- **/
-void
-swfdec_player_set_url (SwfdecPlayer *player, const SwfdecURL *url)
-{
- SwfdecPlayerPrivate *priv;
- SwfdecLoader *loader;
- SwfdecMovie *movie;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (player->priv->url == NULL);
- g_return_if_fail (url != NULL);
-
- g_object_freeze_notify (G_OBJECT (player));
- priv = player->priv;
- priv->url = swfdec_url_copy (url);
- loader = swfdec_player_load (player, swfdec_url_get_url (url),
- SWFDEC_LOADER_REQUEST_DEFAULT, NULL);
- priv->resource = swfdec_resource_new (player, loader, priv->variables);
- if (priv->base_url == NULL) {
- priv->base_url = swfdec_url_new_parent (swfdec_loader_get_url (loader));
- g_object_notify (G_OBJECT (player), "base-url");
- }
- movie = swfdec_movie_new (player, -16384, NULL, priv->resource, NULL, SWFDEC_AS_STR__level0);
- movie->name = SWFDEC_AS_STR_EMPTY;
- g_object_unref (loader);
- g_object_notify (G_OBJECT (player), "url");
- g_object_thaw_notify (G_OBJECT (player));
-}
-
-/**
- * swfdec_player_get_variables:
- * @player: a #SwfdecPlayer
- *
- * Gets the initial variables for this player. See swfdec_player_set_variables()
- * for details about variables.
- *
- * Returns: a string represetation of the current variables or %NULL if none are
- * set on the @player.
- **/
-const char *
-swfdec_player_get_variables (SwfdecPlayer *player)
-{
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
-
- return player->priv->variables;
-}
-
-/**
- * swfdec_player_set_variables:
- * @player: a #SwfdecPlayer
- * @variables: a string that is checked to be in 'application/x-www-form-urlencoded'
- * syntax describing the arguments to set on the new player or NULL for
- * none.
- *
- * Sets the loader for the main data. This function may only be called if
- * swfdec_player_set_url() has not been called yet.
- * If the @variables are set and validate, they will be set as properties on the
- * root movie.
- **/
-void
-swfdec_player_set_variables (SwfdecPlayer *player, const char *variables)
-{
- SwfdecPlayerPrivate *priv;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (player->priv->url == NULL);
-
- g_free (priv->variables);
- priv->variables = g_strdup (variables);
- g_object_notify (G_OBJECT (player), "variables");
-}
-
diff --git a/libswfdec/swfdec_player.h b/libswfdec/swfdec_player.h
deleted file mode 100644
index b3ec5f5..0000000
--- a/libswfdec/swfdec_player.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_PLAYER_H_
-#define _SWFDEC_PLAYER_H_
-
-#include <glib-object.h>
-#include <cairo.h>
-#include <libswfdec/swfdec_as_context.h>
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_url.h>
-
-G_BEGIN_DECLS
-
-typedef enum {
- SWFDEC_MOUSE_CURSOR_NORMAL,
- SWFDEC_MOUSE_CURSOR_NONE,
- SWFDEC_MOUSE_CURSOR_TEXT,
- SWFDEC_MOUSE_CURSOR_CLICK
-} SwfdecMouseCursor;
-
-typedef enum {
- SWFDEC_ALIGNMENT_TOP_LEFT,
- SWFDEC_ALIGNMENT_TOP,
- SWFDEC_ALIGNMENT_TOP_RIGHT,
- SWFDEC_ALIGNMENT_LEFT,
- SWFDEC_ALIGNMENT_CENTER,
- SWFDEC_ALIGNMENT_RIGHT,
- SWFDEC_ALIGNMENT_BOTTOM_LEFT,
- SWFDEC_ALIGNMENT_BOTTOM,
- SWFDEC_ALIGNMENT_BOTTOM_RIGHT
-} SwfdecAlignment;
-
-typedef enum {
- SWFDEC_SCALE_SHOW_ALL,
- SWFDEC_SCALE_NO_BORDER,
- SWFDEC_SCALE_EXACT_FIT,
- SWFDEC_SCALE_NONE
-} SwfdecScaleMode;
-
-/* forward declarations */
-typedef struct _SwfdecPlayerScripting SwfdecPlayerScripting;
-
-typedef struct _SwfdecPlayer SwfdecPlayer;
-typedef struct _SwfdecPlayerPrivate SwfdecPlayerPrivate;
-typedef struct _SwfdecPlayerClass SwfdecPlayerClass;
-
-#define SWFDEC_TYPE_PLAYER (swfdec_player_get_type())
-#define SWFDEC_IS_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_PLAYER))
-#define SWFDEC_IS_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_PLAYER))
-#define SWFDEC_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_PLAYER, SwfdecPlayer))
-#define SWFDEC_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_PLAYER, SwfdecPlayerClass))
-#define SWFDEC_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_PLAYER, SwfdecPlayerClass))
-
-struct _SwfdecPlayer
-{
- SwfdecAsContext context;
- SwfdecPlayerPrivate * priv;
-};
-
-struct _SwfdecPlayerClass
-{
- SwfdecAsContextClass context_class;
-
- void (* advance) (SwfdecPlayer * player,
- gulong msecs,
- guint audio_samples);
- gboolean (* handle_key) (SwfdecPlayer * player,
- guint key,
- guint character,
- gboolean down);
- gboolean (* handle_mouse) (SwfdecPlayer * player,
- double x,
- double y,
- int button);
-};
-
-void swfdec_init (void);
-
-GType swfdec_player_get_type (void);
-
-SwfdecPlayer * swfdec_player_new (SwfdecAsDebugger * debugger);
-
-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_default_size (SwfdecPlayer * player,
- guint * width,
- guint * height);
-void swfdec_player_get_size (SwfdecPlayer * player,
- int * width,
- int * height);
-void swfdec_player_set_size (SwfdecPlayer * player,
- int width,
- int height);
-guint swfdec_player_get_background_color
- (SwfdecPlayer * player);
-void swfdec_player_set_background_color
- (SwfdecPlayer * player,
- guint color);
-SwfdecScaleMode swfdec_player_get_scale_mode (SwfdecPlayer * player);
-void swfdec_player_set_scale_mode (SwfdecPlayer * player,
- SwfdecScaleMode mode);
-SwfdecAlignment swfdec_player_get_alignment (SwfdecPlayer * player);
-void swfdec_player_set_alignment (SwfdecPlayer * player,
- SwfdecAlignment align);
-gulong swfdec_player_get_maximum_runtime
- (SwfdecPlayer * player);
-void swfdec_player_set_maximum_runtime
- (SwfdecPlayer * player,
- gulong msecs);
-const SwfdecURL *
- swfdec_player_get_url (SwfdecPlayer * player);
-void swfdec_player_set_url (SwfdecPlayer * player,
- const SwfdecURL * url);
-const SwfdecURL *
- swfdec_player_get_base_url (SwfdecPlayer * player);
-void swfdec_player_set_base_url (SwfdecPlayer * player,
- const SwfdecURL * url);
-const char* swfdec_player_get_variables (SwfdecPlayer * player);
-void swfdec_player_set_variables (SwfdecPlayer * player,
- const char * variables);
-SwfdecPlayerScripting *
- swfdec_player_get_scripting (SwfdecPlayer * player);
-void swfdec_player_set_scripting (SwfdecPlayer * player,
- SwfdecPlayerScripting *scripting);
-
-void swfdec_player_render (SwfdecPlayer * player,
- cairo_t * cr,
- double x,
- double y,
- double width,
- double height);
-void swfdec_player_advance (SwfdecPlayer * player,
- gulong msecs);
-gboolean swfdec_player_mouse_move (SwfdecPlayer * player,
- double x,
- double y);
-gboolean swfdec_player_mouse_press (SwfdecPlayer * player,
- double x,
- double y,
- guint button);
-gboolean swfdec_player_mouse_release (SwfdecPlayer * player,
- double x,
- double y,
- guint button);
-gboolean swfdec_player_key_press (SwfdecPlayer * player,
- guint keycode,
- guint character);
-gboolean swfdec_player_key_release (SwfdecPlayer * player,
- guint keycode,
- guint character);
-/* audio - see swfdec_audio.c */
-void swfdec_player_render_audio (SwfdecPlayer * player,
- gint16 * dest,
- guint start_offset,
- guint n_samples);
-const GList * swfdec_player_get_audio (SwfdecPlayer * player);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_player_as.c b/libswfdec/swfdec_player_as.c
deleted file mode 100644
index d4d8dd5..0000000
--- a/libswfdec/swfdec_player_as.c
+++ /dev/null
@@ -1,367 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-/* NB: include this first, it redefines SWFDEC_AS_NATIVE */
-#include "swfdec_asnative.h"
-
-#include "swfdec_player_internal.h"
-#include "swfdec_as_function.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_native_function.h"
-#include "swfdec_as_object.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-#include "swfdec_internal.h"
-#include "swfdec_interval.h"
-#include "swfdec_as_frame_internal.h"
-
-/* FIXME: to avoid duplicate definitions */
-#undef SWFDEC_AS_NATIVE
-#define SWFDEC_AS_NATIVE(x, y, func)
-
-/*** INTERVALS ***/
-
-static void
-swfdec_player_do_set_interval (gboolean repeat, SwfdecAsContext *cx, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
- SwfdecAsObject *object;
- guint id, msecs;
-#define MIN_INTERVAL_TIME 10
-
- if (argc < 2) {
- SWFDEC_WARNING ("setInterval needs at least 2 arguments");
- return;
- }
-
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0])) {
- SWFDEC_WARNING ("first argument to setInterval is not an object");
- return;
- }
- object = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
- if (SWFDEC_IS_AS_FUNCTION (object)) {
- msecs = swfdec_as_value_to_integer (cx, &argv[1]);
- if (msecs < MIN_INTERVAL_TIME) {
- SWFDEC_INFO ("interval duration is %u, making it %u msecs", msecs, MIN_INTERVAL_TIME);
- msecs = MIN_INTERVAL_TIME;
- }
- id = swfdec_interval_new_function (player, msecs, repeat,
- SWFDEC_AS_FUNCTION (object), argc - 2, &argv[2]);
- } else {
- const char *name;
- if (argc < 3) {
- SWFDEC_WARNING ("setInterval needs 3 arguments when not called with function");
- return;
- }
- name = swfdec_as_value_to_string (cx, &argv[1]);
- msecs = swfdec_as_value_to_integer (cx, &argv[2]);
- if (msecs < MIN_INTERVAL_TIME) {
- SWFDEC_INFO ("interval duration is %u, making it %u msecs", msecs, MIN_INTERVAL_TIME);
- msecs = MIN_INTERVAL_TIME;
- }
- id = swfdec_interval_new_object (player, msecs, repeat, object, name, argc - 3, &argv[3]);
- }
- SWFDEC_AS_VALUE_SET_INT (rval, id);
-}
-
-SWFDEC_AS_NATIVE (2, 0, swfdec_player_ASnew)
-void
-swfdec_player_ASnew (SwfdecAsContext *cx, SwfdecAsObject *obj,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- g_return_if_fail (cx->frame->next != NULL);
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (rval, cx->frame->next->construct);
-}
-
-SWFDEC_AS_NATIVE (250, 0, swfdec_player_setInterval)
-void
-swfdec_player_setInterval (SwfdecAsContext *cx, SwfdecAsObject *obj,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- swfdec_player_do_set_interval (TRUE, cx, argc, argv, rval);
-}
-
-SWFDEC_AS_NATIVE (250, 2, swfdec_player_setTimeout)
-void
-swfdec_player_setTimeout (SwfdecAsContext *cx, SwfdecAsObject *obj,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- swfdec_player_do_set_interval (FALSE, cx, argc, argv, rval);
-}
-
-SWFDEC_AS_NATIVE (250, 1, swfdec_player_clearInterval)
-void
-swfdec_player_clearInterval (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
- guint id;
-
- SWFDEC_AS_CHECK (0, NULL, "i", &id);
-
- swfdec_interval_remove (player, id);
-}
-
-/*** VARIOUS ***/
-
-SWFDEC_AS_NATIVE (100, 4, swfdec_player_trace)
-void
-swfdec_player_trace (SwfdecAsContext *cx, SwfdecAsObject *obj,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_FIXME ("Is _global.trace supposed to do something?");
-}
-
-SWFDEC_AS_NATIVE (9, 0, swfdec_player_updateAfterEvent)
-void
-swfdec_player_updateAfterEvent (SwfdecAsContext *cx, SwfdecAsObject *obj,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("updateAfterEvent");
-}
-
-SWFDEC_AS_NATIVE (1021, 1, swfdec_player_showRedrawRegions)
-void
-swfdec_player_showRedrawRegions (SwfdecAsContext *cx, SwfdecAsObject *obj,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("showRedrawRegions");
-}
-
-static void
-swfdec_player_enableDebugConsole (SwfdecAsContext *cx, SwfdecAsObject *obj,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("enableDebugConsole");
-}
-
-static void
-swfdec_player_do_nothing (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
-}
-
-static SwfdecAsFunction *
-swfdec_get_asnative (SwfdecAsContext *cx, guint x, guint y)
-{
- gboolean x_exists;
- guint i;
-
- x_exists = FALSE;
- for (i = 0; native_funcs[i].func != NULL; i++) {
- if (native_funcs[i].x == x)
- x_exists = TRUE;
- if (native_funcs[i].x == x && native_funcs[i].y == y) {
- SwfdecAsFunction *fun = swfdec_as_native_function_new (cx, native_funcs[i].name,
- native_funcs[i].func, 0, NULL);
- if (native_funcs[i].get_type) {
- swfdec_as_native_function_set_construct_type (SWFDEC_AS_NATIVE_FUNCTION (fun),
- native_funcs[i].get_type ());
- }
- return fun;
- }
- }
- SWFDEC_WARNING ("no ASnative (%u, %u)", x, y);
- if (x_exists) {
- SwfdecAsFunction *func;
- char *name = g_strdup_printf ("ASnative (%u, %u)", x, y);
- func = swfdec_as_native_function_new (cx, name, swfdec_player_do_nothing,
- 0, NULL);
- g_free (name);
- return func;
- } else {
- return NULL;
- }
-}
-
-// same as ASnative, but also sets prototype
-static void
-swfdec_player_ASconstructor (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecAsValue val;
- SwfdecAsObject *proto;
- SwfdecAsFunction *func;
- guint x, y;
-
- SWFDEC_AS_CHECK (0, NULL, "ii", &x, &y);
-
- func = swfdec_get_asnative (cx, x, y);
- if (func) {
- proto = swfdec_as_object_new (cx);
-
- SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
- swfdec_as_object_set_variable_and_flags (SWFDEC_AS_OBJECT (func),
- SWFDEC_AS_STR_prototype, &val,
- SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
-
- SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (func));
- swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
-
- SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (func));
- }
-}
-
-static void
-swfdec_player_ASnative (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecAsFunction *func;
- guint x, y;
-
- SWFDEC_AS_CHECK (0, NULL, "ii", &x, &y);
-
- func = swfdec_get_asnative (cx, x, y);
- if (func) {
- SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (func));
- }
-}
-
-SWFDEC_AS_NATIVE (4, 0, ASSetNative)
-void
-ASSetNative (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecAsFunction *function;
- SwfdecAsObject *target;
- SwfdecAsValue val;
- SwfdecAsVariableFlag flags;
- const char *s;
- char **names;
- guint i, x, y;
-
- SWFDEC_AS_CHECK (0, NULL, "ois", &target, &x, &s);
-
- if (argc > 3)
- y = swfdec_as_value_to_integer (cx, &argv[3]);
- else
- y = 0;
- names = g_strsplit (s, ",", -1);
- for (i = 0; names[i]; i++) {
- s = names[i];
- flags = 0;
- if (s[0] == '6') {
- flags |= SWFDEC_AS_VARIABLE_VERSION_6_UP;
- s++;
- } else if (s[0] == '7') {
- flags |= SWFDEC_AS_VARIABLE_VERSION_7_UP;
- s++;
- } else if (s[0] == '8') {
- flags |= SWFDEC_AS_VARIABLE_VERSION_8_UP;
- s++;
- } else if (s[0] == '9') {
- flags |= SWFDEC_AS_VARIABLE_VERSION_9_UP;
- s++;
- }
- function = swfdec_get_asnative (cx, x, y);
- if (function == NULL)
- break;
- SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (function));
- swfdec_as_object_set_variable_and_flags (target,
- swfdec_as_context_get_string (cx, s), &val, flags);
- y++;
- }
- g_strfreev (names);
-}
-
-SWFDEC_AS_NATIVE (4, 1, ASSetNativeAccessor)
-void
-ASSetNativeAccessor (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecAsFunction *get, *set;
- SwfdecAsObject *target;
- SwfdecAsVariableFlag flags;
- const char *s;
- char **names;
- guint i, x, y;
-
- SWFDEC_AS_CHECK (0, NULL, "ois|i", &target, &x, &s, &y);
-
- names = g_strsplit (s, ",", -1);
- for (i = 0; names[i]; i++) {
- s = names[i];
- flags = 0;
- if (s[0] == '6') {
- flags |= SWFDEC_AS_VARIABLE_VERSION_6_UP;
- s++;
- } else if (s[0] == '7') {
- flags |= SWFDEC_AS_VARIABLE_VERSION_7_UP;
- s++;
- } else if (s[0] == '8') {
- flags |= SWFDEC_AS_VARIABLE_VERSION_8_UP;
- s++;
- } else if (s[0] == '9') {
- flags |= SWFDEC_AS_VARIABLE_VERSION_9_UP;
- s++;
- }
- get = swfdec_get_asnative (cx, x, y++);
- set = swfdec_get_asnative (cx, x, y++);
- if (get == NULL) {
- SWFDEC_ERROR ("no getter for %s", s);
- break;
- }
- swfdec_as_object_add_variable (target, swfdec_as_context_get_string (cx, s),
- get, set, flags);
- }
- g_strfreev (names);
-}
-
-SWFDEC_AS_NATIVE (101, 8, swfdec_player_object_registerClass)
-void
-swfdec_player_object_registerClass (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- const char *name;
-
- SWFDEC_AS_CHECK (0, NULL, "s", &name);
-
- if (argc < 2 || !SWFDEC_AS_VALUE_IS_OBJECT (&argv[1])) {
- SWFDEC_AS_VALUE_SET_BOOLEAN (rval, FALSE);
- return;
- }
-
- swfdec_player_set_export_class (SWFDEC_PLAYER (cx), name,
- SWFDEC_AS_VALUE_GET_OBJECT (&argv[1]));
- SWFDEC_AS_VALUE_SET_BOOLEAN (rval, TRUE);
-}
-
-/* This is ran at the beginning of swfdec_as_context_startup.
- * Yes, this is a hack */
-void
-swfdec_player_preinit_global (SwfdecAsContext *context)
-{
- /* init these two before swfdec_as_context_startup, so they won't get
- * __proto__ and constructor properties */
- swfdec_as_object_add_function (context->global, SWFDEC_AS_STR_ASnative,
- 0, swfdec_player_ASnative, 2);
- swfdec_as_object_add_function (context->global, SWFDEC_AS_STR_ASconstructor,
- 0, swfdec_player_ASconstructor, 2);
- // FIXME: is this only the debug player?
- swfdec_as_object_add_function (context->global,
- SWFDEC_AS_STR_enableDebugConsole, 0, swfdec_player_enableDebugConsole,
- 2);
-}
diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h
deleted file mode 100644
index a38b957..0000000
--- a/libswfdec/swfdec_player_internal.h
+++ /dev/null
@@ -1,263 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_PLAYER_INTERNAL_H_
-#define _SWFDEC_PLAYER_INTERNAL_H_
-
-#include <libswfdec/swfdec_player.h>
-#include <libswfdec/swfdec_audio.h>
-#include <libswfdec/swfdec_event.h>
-#include <libswfdec/swfdec_function_list.h>
-#include <libswfdec/swfdec_loader.h>
-#include <libswfdec/swfdec_player_scripting.h>
-#include <libswfdec/swfdec_rect.h>
-#include <libswfdec/swfdec_ringbuffer.h>
-#include <libswfdec/swfdec_socket.h>
-#include <libswfdec/swfdec_system.h>
-
-G_BEGIN_DECLS
-
-typedef enum {
- SWFDEC_ALIGN_FLAG_TOP = (1 << 0),
- SWFDEC_ALIGN_FLAG_BOTTOM = (1 << 1),
- SWFDEC_ALIGN_FLAG_LEFT = (1 << 2),
- SWFDEC_ALIGN_FLAG_RIGHT = (1 << 3)
-} SwfdecAlignFlag;
-
-typedef void (* SwfdecActionFunc) (gpointer object, gpointer data);
-typedef gboolean (* SwfdecAudioRemoveFunc) (SwfdecAudio *audio, gpointer data);
-typedef void (* SwfdecPolicyFunc) (SwfdecPlayer *player, gboolean allow, gpointer data);
-
-typedef struct _SwfdecTimeout SwfdecTimeout;
-struct _SwfdecTimeout {
- SwfdecTick timestamp; /* timestamp at which this thing is supposed to trigger */
- void (* callback) (SwfdecTimeout *advance);
- void (* free) (SwfdecTimeout *advance);
-};
-
-#define SWFDEC_PLAYER_N_ACTION_QUEUES 4
-
-struct _SwfdecPlayerPrivate
-{
- SwfdecPlayer * player; /* backlink */
-
- /* global properties */
- SwfdecSystem * system; /* our system properties */
- gboolean initialized; /* if width and height are set already */
- guint rate; /* divide by 256 to get iterations per second */
- guint width; /* width of movie */
- guint height; /* height of movie */
- GList * roots; /* all the root movies */
- SwfdecCache * cache; /* player cache */
- gboolean bgcolor_set; /* TRUE if the background color has been set */
- SwfdecColor bgcolor; /* background color */
- SwfdecResource * resource; /* initial resource loaded */
- char * variables; /* variables to set on the player */
- SwfdecURL * url; /* url or NULL if not set yet */
- SwfdecURL * base_url; /* base url or NULL if not set yet */
- SwfdecPlayerScripting *scripting; /* scripting object */
- GHashTable * scripting_callbacks; /* GC string => SwfdecAsFunction mapping of script callbacks */
- GType loader_type; /* type to use for creating sockets */
- GType socket_type; /* type to use for creating sockets */
- /* stage properties */
- guint internal_width; /* width used by the scripting engine */
- guint internal_height; /* height used by the scripting engine */
- guint broadcasted_width; /* width given in the last onResize event */
- guint broadcasted_height; /* height given in the last onResize event */
- gint stage_width; /* width set by the user */
- gint stage_height; /* height set by the user */
- SwfdecRectangle stage; /* size of the stage set by user */
- guint align_flags; /* SwfdecAlignFlag */
- SwfdecScaleMode scale_mode; /* scale mode */
- double scale_x; /* cached x scale value */
- double scale_y; /* cached y scale value */
- int offset_x; /* x offset from top left edge after scaling */
- int offset_y; /* y offset from top left edge after scaling */
-
- SwfdecFunctionList resource_requests; /* all external requested URIs - see swfdec_resource_request.[ch] */
- guint unnamed_count; /* variable used for naming unnamed movies */
- /* ActionScript */
- SwfdecFunctionList rooted; /* all the objects we keep track of */
- guint interval_id; /* id returned from setInterval call */
- GList * intervals; /* all currently running intervals */
- GHashTable * registered_classes; /* name => SwfdecAsObject constructor */
-
- /* rendering */
- SwfdecRectangle invalid_extents; /* extents of area that needs a redraw in global coordinates */
- GArray * invalidations; /* fine-grained areas in need of redraw */
-
- /* mouse */
- gboolean mouse_visible; /* show the mouse (actionscriptable) */
- SwfdecMouseCursor mouse_cursor; /* cursor that should be shown */
- double mouse_x; /* in stage coordinates */
- double mouse_y; /* in stage coordinates */
- guint mouse_button; /* 0 for not pressed, 1 for pressed */
- SwfdecMovie * mouse_below; /* movie that currently is below the mouse */
- SwfdecMovie * mouse_grab; /* movie that currently has the mouse */
- SwfdecMovie * mouse_drag; /* current movie activated by startDrag */
- gboolean mouse_drag_center; /* TRUE to use center of movie at mouse, FALSE for movie's (0,0) */
- SwfdecRect mouse_drag_rect; /* clipping rectangle for movements */
- double mouse_drag_x; /* offset of mouse in x direction */
- double mouse_drag_y; /* offset of mouse in y direction */
-
- /* key */
- guint last_keycode; /* last keycode that was pressed/released */
- guint last_character; /* UCS4 of last character pressed/released */
- guint8 key_pressed[256/8]; /* boolean array for isDown */
-
- /* audio */
- GList * audio; /* list of playing SwfdecAudio */
-
- /* events and advancing */
- SwfdecTick time; /* current time */
- GList * timeouts; /* list of events, sorted by timestamp */
- guint tick; /* next tick */
- SwfdecTimeout iterate_timeout; /* callback for iterating */
- GTimer * runtime; /* for checking how long we've been running */
- gulong max_runtime; /* maximum number of seconds the player may run */
- SwfdecRingBuffer * external_actions; /* external actions we've queued up, like resize or loader stuff */
- SwfdecTimeout external_timeout; /* callback for iterating */
- /* iterating */
- GList * movies; /* list of all movies that want to be iterated */
- SwfdecRingBuffer * actions[SWFDEC_PLAYER_N_ACTION_QUEUES]; /* all actions we've queued up so far */
-
- /* security */
- GSList * sandboxes; /* all existing sandboxes */
- GList * loading_policy_files; /* list of loading SwfdecPlayerLoader - newest first */
- GSList * policy_files; /* list of SwfdecPolicyLoader that finished loading */
-};
-
-void swfdec_player_initialize (SwfdecPlayer * player,
- guint rate,
- guint width,
- guint height);
-void swfdec_player_add_movie (SwfdecPlayer * player,
- guint depth,
- const char * url);
-void swfdec_player_remove_movie (SwfdecPlayer * player,
- SwfdecMovie * movie);
-
-gboolean swfdec_player_lock (SwfdecPlayer * player);
-void swfdec_player_lock_soft (SwfdecPlayer * player);
-void swfdec_player_unlock (SwfdecPlayer * player);
-void swfdec_player_unlock_soft (SwfdecPlayer * player);
-void swfdec_player_perform_actions (SwfdecPlayer * player);
-
-#define swfdec_player_root(player, data, mark_func) \
- swfdec_function_list_add (&(player)->priv->rooted, (mark_func), (data), NULL)
-#define swfdec_player_root_full(player, data, mark_func, destroy_notify) \
- swfdec_function_list_add (&(player)->priv->rooted, (mark_func), (data), (destroy_notify))
-#define swfdec_player_unroot(player, data) \
- swfdec_function_list_remove (&(player)->priv->rooted, (data))
-#define swfdec_player_request_resource(player, request_func, data, destroy_notify) \
- swfdec_function_list_add (&(player)->priv->resource_requests, (request_func), (data), (destroy_notify))
-SwfdecURL * swfdec_player_create_url (SwfdecPlayer * player,
- const char * string);
-SwfdecLoader * swfdec_player_load (SwfdecPlayer * player,
- const char * url,
- SwfdecLoaderRequest request,
- SwfdecBuffer * buffer);
-SwfdecAsObject *swfdec_player_get_export_class (SwfdecPlayer * player,
- const char * name);
-void swfdec_player_set_export_class (SwfdecPlayer * player,
- const char * name,
- SwfdecAsObject * object);
-
-SwfdecSocket * swfdec_player_create_socket (SwfdecPlayer * player,
- const char * hostname,
- guint port);
-
-#define swfdec_player_is_mouse_pressed(player) ((player)->priv->mouse_button & 1)
-void swfdec_player_invalidate (SwfdecPlayer * player,
- const SwfdecRect * rect);
-void swfdec_player_add_timeout (SwfdecPlayer * player,
- SwfdecTimeout * timeout);
-void swfdec_player_remove_timeout (SwfdecPlayer * player,
- SwfdecTimeout * timeout);
-void swfdec_player_add_external_action
- (SwfdecPlayer * player,
- gpointer object,
- SwfdecActionFunc action_func,
- gpointer action_data);
-void swfdec_player_remove_all_external_actions
- (SwfdecPlayer * player,
- gpointer object);
-void swfdec_player_add_action (SwfdecPlayer * player,
- SwfdecMovie * movie,
- SwfdecEventType type,
- guint importance);
-void swfdec_player_add_action_script (SwfdecPlayer * player,
- SwfdecMovie * movie,
- SwfdecScript * script,
- guint importance);
-void swfdec_player_remove_all_actions (SwfdecPlayer * player,
- SwfdecMovie * movie);
-
-void swfdec_player_set_drag_movie (SwfdecPlayer * player,
- SwfdecMovie * drag,
- gboolean center,
- SwfdecRect * rect);
-void swfdec_player_set_align_flags (SwfdecPlayer * player,
- guint flags);
-void swfdec_player_stop_sounds (SwfdecPlayer * player,
- SwfdecAudioRemoveFunc func,
- gpointer data);
-void swfdec_player_stop_all_sounds (SwfdecPlayer * player);
-gboolean swfdec_player_get_level (SwfdecPlayer * player,
- const char * name);
-SwfdecSpriteMovie *
- swfdec_player_get_movie_at_level(SwfdecPlayer * player,
- int level);
-SwfdecSpriteMovie *
- swfdec_player_create_movie_at_level
- (SwfdecPlayer * player,
- SwfdecResource * resource,
- int level);
-void swfdec_player_launch (SwfdecPlayer * player,
- SwfdecLoaderRequest request,
- const char * url,
- const char * target,
- SwfdecBuffer * data);
-void swfdec_player_stage_to_global (SwfdecPlayer * player,
- double * x,
- double * y);
-void swfdec_player_global_to_stage (SwfdecPlayer * player,
- double * x,
- double * y);
-void swfdec_player_update_scale (SwfdecPlayer * player);
-
-/* in swfdec_policy_file.c */
-gboolean swfdec_player_allow_now (SwfdecPlayer * player,
- const SwfdecURL * url);
-void swfdec_player_allow_or_load (SwfdecPlayer * player,
- const SwfdecURL * url,
- const SwfdecURL * load_url,
- SwfdecPolicyFunc func,
- gpointer data);
-/* in swfdec_as_interpret.c */
-SwfdecMovie * swfdec_player_get_movie_from_value
- (SwfdecPlayer * player,
- SwfdecAsValue * val);
-SwfdecMovie * swfdec_player_get_movie_from_string
- (SwfdecPlayer * player,
- const char * s);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_player_scripting.c b/libswfdec/swfdec_player_scripting.c
deleted file mode 100644
index 0063a62..0000000
--- a/libswfdec/swfdec_player_scripting.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_player_scripting.h"
-#include "swfdec_debug.h"
-
-
-G_DEFINE_ABSTRACT_TYPE (SwfdecPlayerScripting, swfdec_player_scripting, G_TYPE_OBJECT)
-
-static void
-swfdec_player_scripting_class_init (SwfdecPlayerScriptingClass *klass)
-{
-}
-
-static void
-swfdec_player_scripting_init (SwfdecPlayerScripting *player_scripting)
-{
-}
-
diff --git a/libswfdec/swfdec_player_scripting.h b/libswfdec/swfdec_player_scripting.h
deleted file mode 100644
index 8ad3c8f..0000000
--- a/libswfdec/swfdec_player_scripting.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_PLAYER_SCRIPTING_H_
-#define _SWFDEC_PLAYER_SCRIPTING_H_
-
-#include <glib-object.h>
-#include <libswfdec/swfdec_player.h>
-
-G_BEGIN_DECLS
-
-/* forward-declared in swfdec-player.h */
-/* typedef struct _SwfdecPlayerScripting SwfdecPlayerScripting; */
-typedef struct _SwfdecPlayerScriptingClass SwfdecPlayerScriptingClass;
-
-#define SWFDEC_TYPE_PLAYER_SCRIPTING (swfdec_player_scripting_get_type())
-#define SWFDEC_IS_PLAYER_SCRIPTING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_PLAYER_SCRIPTING))
-#define SWFDEC_IS_PLAYER_SCRIPTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_PLAYER_SCRIPTING))
-#define SWFDEC_PLAYER_SCRIPTING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_PLAYER_SCRIPTING, SwfdecPlayerScripting))
-#define SWFDEC_PLAYER_SCRIPTING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_PLAYER_SCRIPTING, SwfdecPlayerScriptingClass))
-#define SWFDEC_PLAYER_SCRIPTING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_PLAYER_SCRIPTING, SwfdecPlayerScriptingClass))
-
-struct _SwfdecPlayerScripting
-{
- GObject object;
-};
-
-struct _SwfdecPlayerScriptingClass
-{
- GObjectClass object_class;
-
- char * (* js_get_id) (SwfdecPlayerScripting *scripting,
- SwfdecPlayer * player);
- char * (* js_call) (SwfdecPlayerScripting *scripting,
- SwfdecPlayer * player,
- const char * code);
- char * (* xml_call) (SwfdecPlayerScripting *scripting,
- SwfdecPlayer * player,
- const char * xml);
-};
-
-GType swfdec_player_scripting_get_type (void);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_policy_file.c b/libswfdec/swfdec_policy_file.c
deleted file mode 100644
index 80fd599..0000000
--- a/libswfdec/swfdec_policy_file.c
+++ /dev/null
@@ -1,350 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "swfdec_policy_file.h"
-#include "swfdec_resource.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-#include "swfdec_loader_internal.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_xml.h"
-#include "swfdec_xml_node.h"
-
-typedef struct _SwfdecPolicyFileRequest SwfdecPolicyFileRequest;
-struct _SwfdecPolicyFileRequest {
- SwfdecURL * url; /* URL we are supposed to check */
- SwfdecPolicyFunc func; /* function to call when we know if access is (not) allowed */
- gpointer data; /* data to pass to func */
-};
-
-static void
-swfdec_policy_file_request_free (SwfdecPolicyFileRequest *request)
-{
- swfdec_url_free (request->url);
- g_slice_free (SwfdecPolicyFileRequest, request);
-}
-
-/*** PARSING THE FILE ***/
-
-static void
-swfdec_policy_file_parse (SwfdecPolicyFile *file, const char *text)
-{
- SwfdecXml *xml;
- gint32 i, j;
-
- g_return_if_fail (SWFDEC_IS_POLICY_FILE (file));
- g_return_if_fail (text != NULL);
-
- xml = swfdec_xml_new_no_properties (SWFDEC_AS_CONTEXT (file->player), text, TRUE);
-
- if (xml == NULL) {
- SWFDEC_ERROR ("failed to create an XML object for crossdomain policy");
- return;
- }
-
- if (SWFDEC_XML_NODE (xml)->type != SWFDEC_XML_NODE_ELEMENT) {
- SWFDEC_LOG ("empty crossdomain policy file");
- return;
- }
-
- for (i = 0; i < swfdec_xml_node_num_children (SWFDEC_XML_NODE (xml)); i++) {
- SwfdecXmlNode *node_cdp =
- swfdec_xml_node_get_child (SWFDEC_XML_NODE (xml), i);
-
- if (node_cdp->type != SWFDEC_XML_NODE_ELEMENT)
- continue;
-
- if (g_ascii_strcasecmp (node_cdp->name, "cross-domain-policy") != 0)
- continue;
-
- for (j = 0; j < swfdec_xml_node_num_children (node_cdp); j++) {
- SwfdecXmlNode *node_aaf = swfdec_xml_node_get_child (node_cdp, j);
- const char *value;
- GPatternSpec *pattern;
- char *value_lower;
-
- if (node_aaf->type != SWFDEC_XML_NODE_ELEMENT)
- continue;
-
- if (g_ascii_strcasecmp (node_aaf->name, "allow-access-from") != 0)
- continue;
-
- // FIXME: secure attribute?
-
- value = swfdec_xml_node_get_attribute (node_aaf, SWFDEC_AS_STR_domain);
- if (value == NULL)
- continue;
-
- if (strchr (value, '?') != NULL) {
- SWFDEC_WARNING ("'?' in allowed domain attribute for %s", value);
- continue;
- }
-
- value_lower = g_ascii_strdown (value, -1);
- pattern = g_pattern_spec_new (value_lower);
- g_free (value_lower);
-
- file->allowed_hosts = g_slist_prepend (file->allowed_hosts, pattern);
- }
- }
-}
-
-/*** SWFDEC_STREAM_TARGET ***/
-
-static SwfdecPlayer *
-swfdec_policy_file_target_get_player (SwfdecStreamTarget *target)
-{
- return SWFDEC_POLICY_FILE (target)->player;
-}
-
-static void
-swfdec_policy_file_finished_loading (SwfdecPolicyFile *file, const char *text)
-{
- SwfdecPlayerPrivate *priv;
- SwfdecPolicyFile *next;
- GList *link;
-
- swfdec_stream_set_target (file->stream, NULL);
- file->stream = NULL;
-
- if (text)
- swfdec_policy_file_parse (file, text);
-
- priv = file->player->priv;
- link = g_list_find (priv->loading_policy_files, file);
- next = link->next ? link->next->data : NULL;
- priv->loading_policy_files = g_list_delete_link (priv->loading_policy_files, link);
- priv->policy_files = g_slist_prepend (priv->policy_files, file);
- if (next) {
- next->requests = g_slist_concat (next->requests, file->requests);
- } else {
- GSList *walk;
-
- for (walk = file->requests; walk; walk = walk->next) {
- SwfdecPolicyFileRequest *request = walk->data;
- gboolean allow = swfdec_player_allow_now (file->player, request->url);
- request->func (file->player, allow, request->data);
- swfdec_policy_file_request_free (request);
- }
- g_slist_free (file->requests);
- }
- file->requests = NULL;
-}
-
-static void
-swfdec_policy_file_target_error (SwfdecStreamTarget *target,
- SwfdecStream *stream)
-{
- SwfdecPolicyFile *file = SWFDEC_POLICY_FILE (target);
-
- swfdec_policy_file_finished_loading (file, NULL);
-}
-
-static void
-swfdec_policy_file_target_close (SwfdecStreamTarget *target,
- SwfdecStream *stream)
-{
- SwfdecPolicyFile *file = SWFDEC_POLICY_FILE (target);
- char *text;
-
- swfdec_stream_set_target (stream, NULL);
- file->stream = NULL;
- if (SWFDEC_IS_LOADER (stream)) {
- text = swfdec_loader_get_text (SWFDEC_LOADER (stream), 8);
- } else {
- SWFDEC_FIXME ("rewrite swfdec_loader_get_text() to swfdec_buffer_queue_get_text()");
- text = NULL;
- }
-
- if (text == NULL) {
- SWFDEC_ERROR ("couldn't get text from crossdomain policy file %s",
- swfdec_url_get_url (file->load_url));
- }
- swfdec_policy_file_finished_loading (file, text);
- g_free (text);
-}
-
-static void
-swfdec_policy_file_stream_target_init (SwfdecStreamTargetInterface *iface)
-{
- iface->get_player = swfdec_policy_file_target_get_player;
- iface->close = swfdec_policy_file_target_close;
- iface->error = swfdec_policy_file_target_error;
-}
-
-/*** SWFDEC_POLICY_FILE ***/
-
-G_DEFINE_TYPE_WITH_CODE (SwfdecPolicyFile, swfdec_policy_file, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (SWFDEC_TYPE_STREAM_TARGET, swfdec_policy_file_stream_target_init))
-
-static void
-swfdec_policy_file_dispose (GObject *object)
-{
- SwfdecPolicyFile *file = SWFDEC_POLICY_FILE (object);
-
- if (file->stream) {
- swfdec_stream_set_target (file->stream, NULL);
- g_object_unref (file->stream);
- file->stream = NULL;
- g_slist_foreach (file->requests, (GFunc) swfdec_policy_file_request_free, NULL);
- g_slist_free (file->requests);
- file->requests = NULL;
- } else {
- g_assert (file->requests == NULL);
- }
- swfdec_url_free (file->load_url);
- swfdec_url_free (file->url);
-
- G_OBJECT_CLASS (swfdec_policy_file_parent_class)->dispose (object);
-}
-
-static void
-swfdec_policy_file_class_init (SwfdecPolicyFileClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->dispose = swfdec_policy_file_dispose;
-}
-
-static void
-swfdec_policy_file_init (SwfdecPolicyFile *policy_file)
-{
-}
-
-SwfdecPolicyFile *
-swfdec_policy_file_new (SwfdecPlayer *player, const SwfdecURL *url)
-{
- SwfdecPolicyFile *file;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (url != NULL, NULL);
-
- file = g_object_new (SWFDEC_TYPE_POLICY_FILE, NULL);
- file->player = player;
- file->load_url = swfdec_url_copy (url);
- file->url = swfdec_url_new_parent (url);
- if (swfdec_url_has_protocol (url, "xmlsocket")) {
- SWFDEC_FIXME ("implement xmlsocket: protocol");
- } else {
- file->stream = SWFDEC_STREAM (swfdec_player_load (player,
- swfdec_url_get_url (url), SWFDEC_LOADER_REQUEST_DEFAULT, NULL));
- swfdec_stream_set_target (file->stream, SWFDEC_STREAM_TARGET (file));
- }
- player->priv->loading_policy_files =
- g_list_prepend (player->priv->loading_policy_files, file);
-
- return file;
-}
-
-gboolean
-swfdec_policy_file_is_loading (SwfdecPolicyFile *file)
-{
- g_return_val_if_fail (SWFDEC_IS_POLICY_FILE (file), FALSE);
-
- return file->stream != NULL;
-}
-
-gboolean
-swfdec_policy_file_allow (SwfdecPolicyFile *file, const SwfdecURL *url)
-{
- GSList *walk;
- gsize len;
- char *emantsoh;
- const char *hostname;
-
- g_return_val_if_fail (SWFDEC_IS_POLICY_FILE (file), FALSE);
- g_return_val_if_fail (url != NULL, FALSE);
-
- hostname = swfdec_url_get_host (url);
- /* This is a hack that simplifies the following code. As the pattern can not
- * contain any ?, the only pattern that matches the string "?" is the pattern
- * "*"
- */
- if (hostname == NULL)
- hostname = "?";
- len = strlen (hostname);
- emantsoh = g_utf8_strreverse (hostname, len);
- for (walk = file->allowed_hosts; walk; walk = walk->next) {
- GPatternSpec *pattern = walk->data;
- if (g_pattern_match (pattern, len, hostname, emantsoh)) {
- g_free (emantsoh);
- return TRUE;
- }
- }
- g_free (emantsoh);
- return FALSE;
-}
-
-/*** PLAYER API ***/
-
-gboolean
-swfdec_player_allow_now (SwfdecPlayer *player, const SwfdecURL *url)
-{
- GSList *walk;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE);
- g_return_val_if_fail (url != NULL, FALSE);
-
- for (walk = player->priv->policy_files; walk; walk = walk->next) {
- if (swfdec_policy_file_allow (walk->data, url))
- return TRUE;
- }
- return FALSE;
-}
-
-void
-swfdec_player_allow_or_load (SwfdecPlayer *player, const SwfdecURL *url,
- const SwfdecURL *load_url, SwfdecPolicyFunc func, gpointer data)
-{
- SwfdecPlayerPrivate *priv;
- SwfdecPolicyFileRequest *request;
- SwfdecPolicyFile *file;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (url != NULL);
- g_return_if_fail (func);
-
- if (swfdec_player_allow_now (player, url)) {
- func (player, TRUE, data);
- return;
- }
- if (load_url)
- swfdec_policy_file_new (player, load_url);
-
- priv = player->priv;
- if (priv->loading_policy_files == NULL) {
- func (player, FALSE, data);
- return;
- }
- request = g_slice_new (SwfdecPolicyFileRequest);
- request->url = swfdec_url_copy (url);
- request->func = func;
- request->data = data;
-
- file = priv->loading_policy_files->data;
- file->requests = g_slist_append (file->requests, request);
-}
-
diff --git a/libswfdec/swfdec_policy_file.h b/libswfdec/swfdec_policy_file.h
deleted file mode 100644
index b849562..0000000
--- a/libswfdec/swfdec_policy_file.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_FLASH_SECURITY_POLICY_H_
-#define _SWFDEC_FLASH_SECURITY_POLICY_H_
-
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_player.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecPolicyFile SwfdecPolicyFile;
-typedef struct _SwfdecPolicyFileClass SwfdecPolicyFileClass;
-
-#define SWFDEC_TYPE_POLICY_FILE (swfdec_policy_file_get_type())
-#define SWFDEC_IS_POLICY_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_POLICY_FILE))
-#define SWFDEC_IS_POLICY_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_POLICY_FILE))
-#define SWFDEC_POLICY_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_POLICY_FILE, SwfdecPolicyFile))
-#define SWFDEC_POLICY_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_POLICY_FILE, SwfdecPolicyFileClass))
-#define SWFDEC_POLICY_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_POLICY_FILE, SwfdecPolicyFileClass))
-
-struct _SwfdecPolicyFile {
- GObject object;
-
- SwfdecPlayer * player; /* player we're loaded from */
- SwfdecURL * load_url; /* url we're loaded from */
- SwfdecURL * url; /* parent url we check with */
- SwfdecStream * stream; /* stream we are loading or NULL if done loading */
- GSList * allowed_hosts; /* list of GPatternSpec of the allowed hosts */
-
- GSList * requests; /* requests waiting for this file to finish loading */
-};
-
-struct _SwfdecPolicyFileClass {
- GObjectClass object_class;
-};
-
-GType swfdec_policy_file_get_type (void);
-
-SwfdecPolicyFile *swfdec_policy_file_new (SwfdecPlayer * player,
- const SwfdecURL * url);
-gboolean swfdec_policy_file_is_loading (SwfdecPolicyFile * file);
-gboolean swfdec_policy_file_allow (SwfdecPolicyFile * file,
- const SwfdecURL * url);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_print_job.c b/libswfdec/swfdec_print_job.c
deleted file mode 100644
index 1428a6a..0000000
--- a/libswfdec/swfdec_print_job.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_as_context.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (111, 100, swfdec_print_job_start)
-void
-swfdec_print_job_start (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("PrintJob.start");
-}
-
-SWFDEC_AS_NATIVE (111, 101, swfdec_print_job_addPage)
-void
-swfdec_print_job_addPage (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("PrintJob.addPage");
-}
-
-SWFDEC_AS_NATIVE (111, 102, swfdec_print_job_send)
-void
-swfdec_print_job_send (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("PrintJob.send");
-}
-
-static void
-swfdec_print_job_get_orientation (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("PrintJob.orientation (get)");
-}
-
-static void
-swfdec_print_job_get_pageHeight (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("PrintJob.pageHeight (get)");
-}
-
-static void
-swfdec_print_job_get_pageWidth (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("PrintJob.pageWidth (get)");
-}
-
-static void
-swfdec_print_job_get_paperHeight (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("PrintJob.paperHeight (get)");
-}
-
-static void
-swfdec_print_job_get_paperWidth (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("PrintJob.paperWidth (get)");
-}
-
-static void
-swfdec_print_job_init_properties (SwfdecAsContext *cx)
-{
- SwfdecAsValue val;
- SwfdecAsObject *xml, *proto;
-
- // FIXME: We should only initialize if the prototype Object has not been
- // initialized by any object's constructor with native properties
- // (TextField, TextFormat, XML, XMLNode at least)
-
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (cx));
-
- swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_PrintJob, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return;
- xml = SWFDEC_AS_VALUE_GET_OBJECT (&val);
-
- swfdec_as_object_get_variable (xml, SWFDEC_AS_STR_prototype, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return;
- proto = SWFDEC_AS_VALUE_GET_OBJECT (&val);
-
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_orientation,
- swfdec_print_job_get_orientation, NULL);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_pageHeight,
- swfdec_print_job_get_pageHeight, NULL);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_pageWidth,
- swfdec_print_job_get_pageWidth, NULL);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_paperHeight,
- swfdec_print_job_get_paperHeight, NULL);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_paperWidth,
- swfdec_print_job_get_paperWidth, NULL);
-}
-
-SWFDEC_AS_NATIVE (111, 0, swfdec_print_job_construct)
-void
-swfdec_print_job_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("PrintJob");
-
- swfdec_print_job_init_properties (cx);
-}
diff --git a/libswfdec/swfdec_rect.c b/libswfdec/swfdec_rect.c
deleted file mode 100644
index c6365c1..0000000
--- a/libswfdec/swfdec_rect.c
+++ /dev/null
@@ -1,223 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-#include "swfdec_rect.h"
-
-void
-swfdec_rect_init_empty (SwfdecRect *rect)
-{
- g_return_if_fail (rect != NULL);
-
- rect->x0 = 0;
- rect->y0 = 0;
- rect->x1 = 0;
- rect->y1 = 0;
-}
-
-/**
- * swfdec_rect_round:
- * @dest: pointer to rect that will take the result
- * @src: #SwfdecRect that should be rounded
- *
- * Puts the smallest rectangle in @dest that includes @src but only
- * contains integer numbers
- **/
-void
-swfdec_rect_round (SwfdecRect *dest, SwfdecRect *src)
-{
- g_return_if_fail (dest != NULL);
- g_return_if_fail (src != NULL);
-
- if (swfdec_rect_is_empty (src)) {
- swfdec_rect_init_empty (dest);
- return;
- }
- dest->x0 = floor (src->x0);
- dest->y0 = floor (src->y0);
- dest->x1 = ceil (src->x1);
- dest->y1 = ceil (src->y1);
-}
-
-gboolean
-swfdec_rect_intersect (SwfdecRect * dest, const SwfdecRect * a, const SwfdecRect * b)
-{
- SwfdecRect tmp;
-
- g_return_val_if_fail (a != NULL, FALSE);
- g_return_val_if_fail (b != NULL, FALSE);
- if (dest == NULL)
- dest = &tmp;
-
- dest->x0 = MAX (a->x0, b->x0);
- dest->y0 = MAX (a->y0, b->y0);
- dest->x1 = MIN (a->x1, b->x1);
- dest->y1 = MIN (a->y1, b->y1);
-
- return !swfdec_rect_is_empty (dest);
-}
-
-/**
- * swfdec_rect_union:
- * @dest: destination rectangle
- * @a: first source rectangle, may be emtpy
- * @b: second source rectangle, may be empty
- *
- * Stores the union of @a and @b into @dest. The union is the smallest
- * rectangle that includes both source rectangles. @a, @b and @dest may point
- * to the same rectangle.
- **/
-void
-swfdec_rect_union (SwfdecRect * dest, const SwfdecRect * a, const SwfdecRect * b)
-{
- g_return_if_fail (dest != NULL);
- g_return_if_fail (a != NULL);
- g_return_if_fail (b != NULL);
-
- if (swfdec_rect_is_empty (a)) {
- *dest = *b;
- } else if (swfdec_rect_is_empty (b)) {
- *dest = *a;
- } else {
- dest->x0 = MIN (a->x0, b->x0);
- dest->y0 = MIN (a->y0, b->y0);
- dest->x1 = MAX (a->x1, b->x1);
- dest->y1 = MAX (a->y1, b->y1);
- }
-}
-
-void
-swfdec_rect_subtract (SwfdecRect *dest, const SwfdecRect *a, const SwfdecRect *b)
-{
- g_return_if_fail (dest != NULL);
- g_return_if_fail (a != NULL);
- g_return_if_fail (b != NULL);
-
- /* FIXME: improve this */
- if (swfdec_rect_is_empty (a)) {
- swfdec_rect_init_empty (dest);
- } else if (swfdec_rect_is_empty (b)) {
- *dest = *a;
- } else if (b->x0 <= a->x0 && b->x1 >= a->x1 &&
- b->y0 <= a->y0 && b->y1 >= a->y1) {
- swfdec_rect_init_empty (dest);
- } else {
- *dest = *a;
- }
-}
-
-void
-swfdec_rect_scale (SwfdecRect *dest, const SwfdecRect *src, double factor)
-{
- g_return_if_fail (dest != NULL);
- g_return_if_fail (src != NULL);
-
- dest->x0 = src->x0 * factor;
- dest->x1 = src->x1 * factor;
- dest->y0 = src->y0 * factor;
- dest->y1 = src->y1 * factor;
-}
-
-gboolean
-swfdec_rect_is_empty (const SwfdecRect * a)
-{
- return (a->x1 <= a->x0) || (a->y1 <= a->y0);
-}
-
-gboolean
-swfdec_rect_contains (const SwfdecRect *rect, double x, double y)
-{
- return x >= rect->x0 &&
- x < rect->x1 &&
- y >= rect->y0 &&
- y < rect->y1;
-}
-
-/**
- * swfdec_rect_transform:
- * @dest: destination rectangle
- * @src: source rectangle
- * @matrix: matrix to apply to source
- *
- * Computes a rectangle that completely encloses the area that results from
- * applying @matrix to @src.
- **/
-void
-swfdec_rect_transform (SwfdecRect *dest, const SwfdecRect *src, const cairo_matrix_t *matrix)
-{
- SwfdecRect tmp, tmp2;
-
- g_return_if_fail (dest != NULL);
- g_return_if_fail (src != NULL);
- g_return_if_fail (matrix != NULL);
-
- tmp = *src;
- tmp2 = *src;
- cairo_matrix_transform_point (matrix, &tmp.x0, &tmp.y0);
- cairo_matrix_transform_point (matrix, &tmp.x1, &tmp.y1);
- cairo_matrix_transform_point (matrix, &tmp2.x0, &tmp2.y1);
- cairo_matrix_transform_point (matrix, &tmp2.x1, &tmp2.y0);
-
- dest->x0 = MIN (MIN (tmp.x0, tmp.x1), MIN (tmp2.x0, tmp2.x1));
- dest->y0 = MIN (MIN (tmp.y0, tmp.y1), MIN (tmp2.y0, tmp2.y1));
- dest->x1 = MAX (MAX (tmp.x0, tmp.x1), MAX (tmp2.x0, tmp2.x1));
- dest->y1 = MAX (MAX (tmp.y0, tmp.y1), MAX (tmp2.y0, tmp2.y1));
-}
-
-/**
- * swfdec_rect_inside:
- * @outer: the supposed outer rectangle
- * @inner: the supposed inner rectangle
- *
- * Checks if @outer completely includes the rectangle specified by @inner.
- * If both rectangles are empty, TRUE is returned.
- *
- * Returns: TRUE if @outer includes @inner, FALSE otherwise
- **/
-gboolean
-swfdec_rect_inside (const SwfdecRect *outer, const SwfdecRect *inner)
-{
- /* empty includes empty */
- if (swfdec_rect_is_empty (inner))
- return TRUE;
- /* if outer is empty, below will return FALSE */
- return outer->x0 <= inner->x0 &&
- outer->y0 <= inner->y0 &&
- outer->x1 >= inner->x1 &&
- outer->y1 >= inner->y1;
-}
-
-void
-swfdec_rectangle_init_rect (SwfdecRectangle *rectangle, const SwfdecRect *rect)
-{
- g_return_if_fail (rectangle != NULL);
- g_return_if_fail (rect != NULL);
-
- rectangle->x = floor (rect->x0);
- rectangle->y = floor (rect->y0);
- rectangle->width = ceil (rect->x1) - rectangle->x;
- rectangle->height = ceil (rect->y1) - rectangle->y;
-}
-
diff --git a/libswfdec/swfdec_rect.h b/libswfdec/swfdec_rect.h
deleted file mode 100644
index d43cee4..0000000
--- a/libswfdec/swfdec_rect.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef __SWFDEC_RECT_H__
-#define __SWFDEC_RECT_H__
-
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_rectangle.h>
-
-struct _SwfdecRect
-{
- double x0;
- double y0;
- double x1;
- double y1;
-};
-
-void swfdec_rect_init_empty (SwfdecRect *rect);
-
-gboolean swfdec_rect_intersect (SwfdecRect * dest, const SwfdecRect * a, const SwfdecRect * b);
-void swfdec_rect_round (SwfdecRect *dest, SwfdecRect *src);
-void swfdec_rect_union (SwfdecRect * dest, const SwfdecRect * a, const SwfdecRect * b);
-void swfdec_rect_subtract (SwfdecRect *dest, const SwfdecRect *a, const SwfdecRect *b);
-void swfdec_rect_scale (SwfdecRect *dest, const SwfdecRect *src, double factor);
-gboolean swfdec_rect_is_empty (const SwfdecRect * a);
-/* FIXME: rename to _contains_point and _contains instead of _inside? */
-gboolean swfdec_rect_contains (const SwfdecRect *rect, double x, double y);
-gboolean swfdec_rect_inside (const SwfdecRect *outer, const SwfdecRect *inner);
-void swfdec_rect_transform (SwfdecRect *dest, const SwfdecRect *src, const cairo_matrix_t *matrix);
-
-void swfdec_rectangle_init_rect (SwfdecRectangle *rectangle, const SwfdecRect *rect);
-
-#endif
diff --git a/libswfdec/swfdec_rectangle.c b/libswfdec/swfdec_rectangle.c
deleted file mode 100644
index 622f15a..0000000
--- a/libswfdec/swfdec_rectangle.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_rectangle.h"
-
-/**
- * SECTION:SwfdecRectangle
- * @title: SwfdecRectangle
- * @short_description: handling regions on the screen
- *
- * This section describes how regions are handled in Swfdec. Regions are
- * important when tracking which parts of the screen have been invalidated and
- * need to be repainted. See SwfdecPlayer::invalidate for an example.
- */
-
-/**
- * SwfdecRectangle:
- * @x: x coordinate of top-left point
- * @y: y coordinate of top-left point
- * @width: width of rectangle or 0 for empty
- * @height: height of rectangle or 0 for empty
- *
- * This structure represents a rectangular region. It is identical to the
- * #GdkRectangle structure, so you can cast freely between them. The only
- * difference is that Gdk does not allow empty rectangles, while Swfdec does.
- * You can use swfdec_rectangle_is_empty() to check for this.
- */
-
-static gpointer
-swfdec_rectangle_copy (gpointer src)
-{
- return g_memdup (src, sizeof (SwfdecRectangle));
-}
-
-GType
-swfdec_rectangle_get_type (void)
-{
- static GType type = 0;
-
- if (!type)
- type = g_boxed_type_register_static ("SwfdecRectangle",
- swfdec_rectangle_copy, g_free);
-
- return type;
-}
-
-/**
- * swfdec_rectangle_init_empty:
- * @rectangle: rectangle to initialize
- *
- * Initializes the rectangle as empty.
- **/
-void
-swfdec_rectangle_init_empty (SwfdecRectangle *rectangle)
-{
- rectangle->x = rectangle->y = rectangle->width = rectangle->height = 0;
-}
-
-/**
- * swfdec_rectangle_is_empty:
- * @rectangle: rectangle to check
- *
- * Checks if the given @rectangle is empty.
- *
- * Returns: %TRUE if the rectangle is emtpy
- **/
-gboolean
-swfdec_rectangle_is_empty (const SwfdecRectangle *rectangle)
-{
- g_return_val_if_fail (rectangle != NULL, FALSE);
-
- return rectangle->width <= 0 || rectangle->height <= 0;
-}
-
-/**
- * swfdec_rectangle_intersect:
- * @dest: the rectangle to take the result or %NULL
- * @a: first rectangle to intersect
- * @b: second rectangle to intersect
- *
- * Intersects the rectangles @a and @b and puts the result into @dest. It is
- * allowed if @dest is the same as @a or @b.
- *
- * Returns: %TRUE if the intersection is not empty.
- **/
-gboolean
-swfdec_rectangle_intersect (SwfdecRectangle *dest, const SwfdecRectangle *a,
- const SwfdecRectangle *b)
-{
- SwfdecRectangle tmp;
-
- g_return_val_if_fail (a != NULL, FALSE);
- g_return_val_if_fail (b != NULL, FALSE);
-
- tmp.x = MAX (a->x, b->x);
- tmp.y = MAX (a->y, b->y);
- tmp.width = MIN (a->x + a->width, b->x + b->width) - tmp.x;
- tmp.height = MIN (a->y + a->height, b->y + b->height) - tmp.y;
-
- if (tmp.width <= 0 && tmp.height <= 0) {
- if (dest)
- dest->x = dest->y = dest->width = dest->height = 0;
- return FALSE;
- }
-
- if (dest != NULL)
- *dest = tmp;
- return TRUE;
-}
-
-/**
- * swfdec_rectangle_union:
- * @dest: destination to take the union
- * @a: first rectangle to union
- * @b: second rectangle to union
- *
- * Computes the smallest rectangle that contains both @a and @b and puts it in
- * @dest.
- **/
-void
-swfdec_rectangle_union (SwfdecRectangle *dest, const SwfdecRectangle *a,
- const SwfdecRectangle *b)
-{
- int x, y;
-
- g_return_if_fail (dest != NULL);
- g_return_if_fail (a != NULL);
- g_return_if_fail (b != NULL);
-
- if (swfdec_rectangle_is_empty (a)) {
- *dest = *b;
- return;
- } else if (swfdec_rectangle_is_empty (b)) {
- *dest = *a;
- return;
- }
- x = MIN (a->x, b->x);
- y = MIN (a->y, b->y);
- dest->width = MAX (a->x + a->width, b->x + b->width) - x;
- dest->height = MAX (a->y + a->height, b->y + b->height) - y;
- dest->x = x;
- dest->y = y;
-}
-
-/**
- * swfdec_rectangle_contains:
- * @container: the supposedly bigger rectangle
- * @content: the supposedly smaller rectangle
- *
- * Checks if @container contains the whole rectangle @content.
- *
- * Returns: %TRUE if @container contains @content.
- **/
-gboolean
-swfdec_rectangle_contains (const SwfdecRectangle *container, const SwfdecRectangle *content)
-{
- g_return_val_if_fail (container != NULL, FALSE);
- g_return_val_if_fail (content != NULL, FALSE);
-
- return container->x <= content->x &&
- container->y <= content->y &&
- container->x + container->width >= content->x + content->width &&
- container->y + container->height >= content->y + content->height;
-}
-
-/**
- * swfdec_rectangle_contains_point:
- * @rectangle: a rectangle
- * @x: x coordinate of point to check
- * @y: y coordinate of point to check
- *
- * Checks if the given point is inside the given rectangle.
- *
- * Returns: %TRUE if the point is inside the rectangle
- **/
-gboolean
-swfdec_rectangle_contains_point (const SwfdecRectangle *rectangle, int x, int y)
-{
- g_return_val_if_fail (rectangle != NULL, FALSE);
-
- return rectangle->x <= x && rectangle->y <= y &&
- rectangle->x + rectangle->width > x && rectangle->y + rectangle->height > y;
-}
diff --git a/libswfdec/swfdec_rectangle.h b/libswfdec/swfdec_rectangle.h
deleted file mode 100644
index 4d34ae6..0000000
--- a/libswfdec/swfdec_rectangle.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef __SWFDEC_RECTANGLE_H__
-#define __SWFDEC_RECTANGLE_H__
-
-#include <glib-object.h>
-
-#define SWFDEC_TYPE_RECTANGLE swfdec_rectangle_get_type ()
-
-typedef struct _SwfdecRectangle SwfdecRectangle;
-
-struct _SwfdecRectangle {
- int x; /* x coordinate of top-left point */
- int y; /* y coordinate of top left point */
- int width; /* width of rectangle or 0 for empty */
- int height; /* height of rectangle or 0 for empty */
-};
-
-GType swfdec_rectangle_get_type (void);
-
-void swfdec_rectangle_init_empty (SwfdecRectangle * rectangle);
-
-gboolean swfdec_rectangle_is_empty (const SwfdecRectangle * rectangle);
-
-gboolean swfdec_rectangle_intersect (SwfdecRectangle * dest,
- const SwfdecRectangle * a,
- const SwfdecRectangle * b);
-void swfdec_rectangle_union (SwfdecRectangle * dest,
- const SwfdecRectangle * a,
- const SwfdecRectangle * b);
-gboolean swfdec_rectangle_contains (const SwfdecRectangle * container,
- const SwfdecRectangle * content);
-gboolean swfdec_rectangle_contains_point (const SwfdecRectangle * rectangle,
- int x,
- int y);
-
-
-#endif
diff --git a/libswfdec/swfdec_resource.c b/libswfdec/swfdec_resource.c
deleted file mode 100644
index 2ea802f..0000000
--- a/libswfdec/swfdec_resource.c
+++ /dev/null
@@ -1,691 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include "swfdec_resource.h"
-#include "swfdec_as_object.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_interpret.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_character.h"
-#include "swfdec_debug.h"
-#include "swfdec_decoder.h"
-#include "swfdec_image_decoder.h"
-#include "swfdec_loader_internal.h"
-#include "swfdec_movie_clip_loader.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_sandbox.h"
-#include "swfdec_script.h"
-#include "swfdec_sprite.h"
-#include "swfdec_stream_target.h"
-#include "swfdec_swf_decoder.h"
-#include "swfdec_utils.h"
-
-
-static void swfdec_resource_stream_target_init (SwfdecStreamTargetInterface *iface);
-G_DEFINE_TYPE_WITH_CODE (SwfdecResource, swfdec_resource, SWFDEC_TYPE_AS_OBJECT,
- G_IMPLEMENT_INTERFACE (SWFDEC_TYPE_STREAM_TARGET, swfdec_resource_stream_target_init))
-
-/*** SWFDEC_STREAM_TARGET interface ***/
-
-static gboolean
-swfdec_resource_is_root (SwfdecResource *resource)
-{
- g_return_val_if_fail (SWFDEC_IS_RESOURCE (resource), FALSE);
-
- return
- resource->movie == SWFDEC_PLAYER (SWFDEC_AS_OBJECT (resource)->context)->priv->roots->data;
-}
-
-static SwfdecPlayer *
-swfdec_resource_stream_target_get_player (SwfdecStreamTarget *target)
-{
- return SWFDEC_PLAYER (SWFDEC_AS_OBJECT (target)->context);
-}
-
-static void
-swfdec_resource_stream_target_image (SwfdecResource *instance)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (instance)->context);
- SwfdecSpriteMovie *movie = instance->movie;
-
- if (movie->sprite != NULL)
- return;
-
- if (SWFDEC_IS_SWF_DECODER (instance->decoder)) {
- SwfdecSwfDecoder *dec = SWFDEC_SWF_DECODER (instance->decoder);
-
- instance->sandbox = swfdec_sandbox_get_for_url (player,
- swfdec_loader_get_url (instance->loader), instance->version,
- SWFDEC_SWF_DECODER (instance->decoder)->use_network);
- if (instance->sandbox) {
- movie->sprite = dec->main_sprite;
- g_assert (movie->sprite->parse_frame > 0);
- movie->n_frames = movie->sprite->n_frames;
- swfdec_movie_invalidate_last (SWFDEC_MOVIE (movie));
- swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (movie), instance->sandbox->MovieClip);
- if (swfdec_resource_is_root (instance)) {
- swfdec_movie_initialize (SWFDEC_MOVIE (movie));
- swfdec_player_perform_actions (player);
- }
- } else {
- SWFDEC_FIXME ("cannot continue loading %s, invalid rights",
- swfdec_url_get_url (swfdec_loader_get_url (instance->loader)));
- swfdec_stream_set_target (SWFDEC_STREAM (instance->loader), NULL);
- /* FIXME: anyting on the movie we need to clear? */
- }
- } else {
- g_assert_not_reached ();
- }
-}
-
-/* NB: name must be GC'ed */
-static void
-swfdec_resource_emit_signal (SwfdecResource *resource, const char *name, gboolean progress,
- SwfdecAsValue *args, guint n_args)
-{
- SwfdecAsContext *cx;
- SwfdecAsObject *movie;
- guint skip = progress ? 4 : 2;
- SwfdecAsValue vals[n_args + skip];
-
- if (resource->clip_loader == NULL)
- return;
- cx = SWFDEC_AS_OBJECT (resource->clip_loader)->context;
- g_assert (resource->target);
- movie = swfdec_action_lookup_object (cx, SWFDEC_PLAYER (cx)->priv->roots->data,
- resource->target, resource->target + strlen (resource->target));
- if (!SWFDEC_IS_SPRITE_MOVIE (movie)) {
- SWFDEC_DEBUG ("no movie, not emitting signal");
- return;
- }
- if (name == SWFDEC_AS_STR_onLoadInit &&
- movie != SWFDEC_AS_OBJECT (resource->movie)) {
- SWFDEC_INFO ("not emitting onLoadInit - the movie is different");
- return;
- }
-
- 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[skip], args, sizeof (SwfdecAsValue) * n_args);
- /* FIXME: what's the correct sandbox here? */
- swfdec_sandbox_use (resource->clip_loader_sandbox);
- swfdec_as_object_call (SWFDEC_AS_OBJECT (resource->clip_loader), SWFDEC_AS_STR_broadcastMessage,
- n_args + skip, vals, NULL);
- swfdec_sandbox_unuse (resource->clip_loader_sandbox);
-}
-
-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 SwfdecSpriteMovie *
-swfdec_resource_replace_movie (SwfdecSpriteMovie *movie, SwfdecResource *resource)
-{
- /* can't use swfdec_movie_duplicate() here, we copy to same depth */
- SwfdecMovie *mov = SWFDEC_MOVIE (movie);
- SwfdecMovie *copy;
-
- copy = swfdec_movie_new (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context),
- mov->depth, mov->parent, resource, NULL, mov->name);
- if (copy == NULL)
- return FALSE;
- copy->matrix = mov->matrix;
- copy->original_name = mov->original_name;
- copy->modified = mov->modified;
- copy->xscale = mov->xscale;
- copy->yscale = mov->yscale;
- copy->rotation = mov->rotation;
- /* FIXME: are events copied? If so, wouldn't that be a security issue? */
- swfdec_movie_set_static_properties (copy, &mov->original_transform,
- &mov->original_ctrans, mov->original_ratio, mov->clip_depth,
- mov->blend_mode, NULL);
- swfdec_movie_remove (mov);
- swfdec_movie_queue_update (copy, SWFDEC_MOVIE_INVALID_MATRIX);
- return SWFDEC_SPRITE_MOVIE (copy);
-}
-
-static gboolean
-swfdec_resource_create_movie (SwfdecResource *resource)
-{
- SwfdecPlayer *player;
- SwfdecSpriteMovie *movie;
- int level = -1;
-
- if (resource->movie)
- return TRUE;
- player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (resource)->context);
- movie = (SwfdecSpriteMovie *) swfdec_action_lookup_object (SWFDEC_AS_CONTEXT (player),
- player->priv->roots->data, resource->target, resource->target + strlen (resource->target));
- if (!SWFDEC_IS_SPRITE_MOVIE (movie)) {
- level = swfdec_player_get_level (player, resource->target);
- if (level < 0) {
- SWFDEC_WARNING ("%s does not reference a movie, not loading %s", resource->target,
- swfdec_url_get_url (swfdec_loader_get_url (resource->loader)));
- swfdec_stream_close (SWFDEC_STREAM (resource->loader));
- swfdec_player_unroot (player, resource);
- return FALSE;
- }
- movie = swfdec_player_get_movie_at_level (player, level);
- }
- if (movie == NULL) {
- movie = swfdec_player_create_movie_at_level (player, resource, level);
- } else {
- /* FIXME: is this correct? */
- movie = swfdec_resource_replace_movie (movie, resource);
- }
- swfdec_player_unroot (player, resource);
- return TRUE;
-}
-
-static void
-swfdec_resource_stream_target_open (SwfdecStreamTarget *target, SwfdecStream *stream)
-{
- SwfdecLoader *loader = SWFDEC_LOADER (stream);
- SwfdecResource *instance = SWFDEC_RESOURCE (target);
- const char *query;
-
- if (!swfdec_resource_create_movie (instance))
- return;
- query = swfdec_url_get_query (swfdec_loader_get_url (loader));
- if (query) {
- SWFDEC_INFO ("set url query movie variables: %s", query);
- swfdec_as_object_decode (SWFDEC_AS_OBJECT (instance->movie), query);
- }
- if (instance->variables) {
- SWFDEC_INFO ("set manual movie variables: %s", instance->variables);
- swfdec_as_object_decode (SWFDEC_AS_OBJECT (instance->movie), instance->variables);
- }
- swfdec_resource_emit_signal (instance, SWFDEC_AS_STR_onLoadStart, FALSE, NULL, 0);
- instance->state = SWFDEC_RESOURCE_OPENED;
-}
-
-static void
-swfdec_resource_stream_target_parse (SwfdecStreamTarget *target, SwfdecStream *stream)
-{
- SwfdecLoader *loader = SWFDEC_LOADER (stream);
- SwfdecResource *resource = SWFDEC_RESOURCE (target);
- SwfdecBufferQueue *queue;
- SwfdecBuffer *buffer;
- SwfdecDecoder *dec = resource->decoder;
- SwfdecStatus status;
- guint parsed;
-
- queue = swfdec_stream_get_queue (stream);
- if (dec == NULL && swfdec_buffer_queue_get_offset (queue) == 0) {
- if (swfdec_buffer_queue_get_depth (queue) < SWFDEC_DECODER_DETECT_LENGTH)
- return;
- buffer = swfdec_buffer_queue_peek (queue, 4);
- dec =
- swfdec_decoder_new (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (resource)->context), buffer);
- swfdec_buffer_unref (buffer);
- if (dec == NULL) {
- SWFDEC_ERROR ("no decoder found for format");
- } else {
- glong total;
- resource->decoder = dec;
- total = swfdec_loader_get_size (loader);
- if (total >= 0)
- dec->bytes_total = total;
- }
- }
- while (swfdec_buffer_queue_get_depth (queue)) {
- parsed = 0;
- status = 0;
- do {
- buffer = swfdec_buffer_queue_peek_buffer (queue);
- if (buffer == NULL)
- break;
- if (parsed + buffer->length <= 65536) {
- swfdec_buffer_unref (buffer);
- buffer = swfdec_buffer_queue_pull_buffer (queue);
- } else {
- swfdec_buffer_unref (buffer);
- buffer = swfdec_buffer_queue_pull (queue, 65536 - parsed);
- }
- parsed += buffer->length;
- if (dec) {
- status |= swfdec_decoder_parse (dec, buffer);
- } else {
- swfdec_buffer_unref (buffer);
- }
- } while (parsed < 65536 && (status & (SWFDEC_STATUS_ERROR | SWFDEC_STATUS_EOF)) == 0);
- if (status & SWFDEC_STATUS_ERROR) {
- SWFDEC_ERROR ("parsing error");
- swfdec_stream_set_target (SWFDEC_STREAM (loader), NULL);
- return;
- }
- if ((status & SWFDEC_STATUS_INIT)) {
- if (SWFDEC_IS_SWF_DECODER (dec))
- resource->version = SWFDEC_SWF_DECODER (dec)->version;
- if (swfdec_resource_is_root (resource)) {
- swfdec_player_initialize (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (resource)->context),
- dec->rate, dec->width, dec->height);
- }
- }
- if (status & SWFDEC_STATUS_IMAGE)
- swfdec_resource_stream_target_image (resource);
- swfdec_resource_emit_signal (resource, SWFDEC_AS_STR_onLoadProgress, TRUE, NULL, 0);
- if (status & SWFDEC_STATUS_EOF)
- return;
- }
-}
-
-static void
-swfdec_resource_stream_target_close (SwfdecStreamTarget *target, SwfdecStream *stream)
-{
- SwfdecResource *resource = SWFDEC_RESOURCE (target);
- SwfdecAsValue val;
-
- swfdec_resource_emit_signal (resource, SWFDEC_AS_STR_onLoadProgress, TRUE, NULL, 0);
- if (resource->decoder) {
- SwfdecDecoder *dec = resource->decoder;
- swfdec_decoder_eof (dec);
- if (dec->data_type != SWFDEC_LOADER_DATA_UNKNOWN)
- swfdec_loader_set_data_type (SWFDEC_LOADER (stream), dec->data_type);
- }
- 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_stream_target_error (SwfdecStreamTarget *target, SwfdecStream *stream)
-{
- 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:
- default:
- g_assert_not_reached ();
- message = SWFDEC_AS_STR_EMPTY;
- break;
- }
- swfdec_resource_emit_error (resource, message);
-}
-
-static void
-swfdec_resource_stream_target_init (SwfdecStreamTargetInterface *iface)
-{
- iface->get_player = swfdec_resource_stream_target_get_player;
- iface->open = swfdec_resource_stream_target_open;
- iface->parse = swfdec_resource_stream_target_parse;
- iface->error = swfdec_resource_stream_target_error;
- iface->close = swfdec_resource_stream_target_close;
-}
-
-static void
-swfdec_resource_mark (SwfdecAsObject *object)
-{
- SwfdecResource *resource = SWFDEC_RESOURCE (object);
-
- if (resource->clip_loader) {
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (resource->clip_loader));
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (resource->clip_loader_sandbox));
- }
- if (resource->sandbox)
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (resource->sandbox));
-
- SWFDEC_AS_OBJECT_CLASS (swfdec_resource_parent_class)->mark (object);
-}
-
-static void
-swfdec_resource_dispose (GObject *object)
-{
- SwfdecResource *resource = SWFDEC_RESOURCE (object);
-
- if (resource->loader) {
- swfdec_stream_set_target (SWFDEC_STREAM (resource->loader), NULL);
- g_object_unref (resource->loader);
- resource->loader = NULL;
- }
- if (resource->decoder) {
- g_object_unref (resource->decoder);
- resource->decoder = NULL;
- }
- g_free (resource->target);
- g_free (resource->variables);
- g_hash_table_destroy (resource->exports);
- g_hash_table_destroy (resource->export_names);
-
- G_OBJECT_CLASS (swfdec_resource_parent_class)->dispose (object);
-}
-
-static void
-swfdec_resource_class_init (SwfdecResourceClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
-
- object_class->dispose = swfdec_resource_dispose;
-
- asobject_class->mark = swfdec_resource_mark;
-}
-
-static void
-swfdec_resource_init (SwfdecResource *instance)
-{
- instance->exports = g_hash_table_new_full (swfdec_str_case_hash,
- swfdec_str_case_equal, g_free, g_object_unref);
- instance->export_names = g_hash_table_new_full (g_direct_hash, g_direct_equal,
- g_object_unref, g_free);
-}
-
-static void
-swfdec_resource_set_loader (SwfdecResource *resource, SwfdecLoader *loader)
-{
- g_return_if_fail (SWFDEC_IS_RESOURCE (resource));
- g_return_if_fail (SWFDEC_IS_LOADER (loader));
- g_return_if_fail (resource->loader == NULL);
-
- resource->loader = g_object_ref (loader);
- swfdec_stream_set_target (SWFDEC_STREAM (resource->loader), SWFDEC_STREAM_TARGET (resource));
- resource->state = SWFDEC_RESOURCE_REQUESTED;
-}
-
-SwfdecResource *
-swfdec_resource_new (SwfdecPlayer *player, SwfdecLoader *loader, const char *variables)
-{
- SwfdecResource *resource;
- guint size;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (SWFDEC_IS_LOADER (loader), NULL);
-
- size = sizeof (SwfdecResource);
- if (!swfdec_as_context_use_mem (SWFDEC_AS_CONTEXT (player), size))
- size = 0;
- resource = g_object_new (SWFDEC_TYPE_RESOURCE, NULL);
- swfdec_as_object_add (SWFDEC_AS_OBJECT (resource), SWFDEC_AS_CONTEXT (player), size);
- resource->version = 8;
- resource->variables = g_strdup (variables);
- swfdec_resource_set_loader (resource, loader);
-
- return resource;
-}
-
-gpointer
-swfdec_resource_get_export (SwfdecResource *instance, const char *name)
-{
- g_return_val_if_fail (SWFDEC_IS_RESOURCE (instance), NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- return g_hash_table_lookup (instance->exports, name);
-}
-
-const char *
-swfdec_resource_get_export_name (SwfdecResource *instance, SwfdecCharacter *character)
-{
- g_return_val_if_fail (SWFDEC_IS_RESOURCE (instance), NULL);
- g_return_val_if_fail (SWFDEC_IS_CHARACTER (character), NULL);
-
- return g_hash_table_lookup (instance->export_names, character);
-}
-
-void
-swfdec_resource_add_export (SwfdecResource *instance, SwfdecCharacter *character, const char *name)
-{
- g_return_if_fail (SWFDEC_IS_RESOURCE (instance));
- g_return_if_fail (SWFDEC_IS_CHARACTER (character));
- g_return_if_fail (name != NULL);
-
- g_hash_table_insert (instance->exports, g_strdup (name), g_object_ref (character));
- g_hash_table_insert (instance->export_names, g_object_ref (character), g_strdup (name));
-}
-
-/*** RESOURC LOAD ***/
-
-typedef struct _SwfdecResourceLoad SwfdecResourceLoad;
-struct _SwfdecResourceLoad {
- SwfdecSandbox * sandbox;
- char * target;
- char * url;
- SwfdecLoaderRequest request;
- SwfdecBuffer * buffer;
- SwfdecMovieClipLoader * loader;
- gboolean target_is_movie;
-};
-
-static void
-swfdec_resource_load_free (gpointer loadp)
-{
- SwfdecResourceLoad *load = loadp;
-
- swfdec_player_unroot (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (load->sandbox)->context), load);
- g_free (load->url);
- g_free (load->target);
- if (load->buffer)
- swfdec_buffer_unref (load->buffer);
- g_slice_free (SwfdecResourceLoad, load);
-}
-
-static void
-swfdec_resource_load_mark (gpointer loadp, gpointer playerp)
-{
- SwfdecResourceLoad *load = loadp;
-
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (load->sandbox));
- if (load->loader)
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (load->loader));
-}
-
-static void
-swfdec_resource_do_load (SwfdecPlayer *player, gboolean allowed, gpointer loadp)
-{
- SwfdecResourceLoad *load = loadp;
- SwfdecResource *resource;
- SwfdecLoader *loader;
-
- if (!swfdec_as_context_use_mem (SWFDEC_AS_CONTEXT (player), sizeof (SwfdecResource)))
- return;
- resource = g_object_new (SWFDEC_TYPE_RESOURCE, NULL);
- swfdec_as_object_add (SWFDEC_AS_OBJECT (resource), SWFDEC_AS_CONTEXT (player), sizeof (SwfdecResource));
- resource->version = 8;
- resource->target = g_strdup (load->target);
- if (load->loader) {
- resource->clip_loader = load->loader;
- resource->clip_loader_sandbox = load->sandbox;
- }
- resource->sandbox = load->sandbox;
-
- if (!allowed) {
- SWFDEC_WARNING ("SECURITY: no access to %s from %s",
- load->url, swfdec_url_get_url (load->sandbox->url));
- /* FIXME: is replacing correct? */
- swfdec_resource_emit_error (resource, SWFDEC_AS_STR_IllegalRequest);
- return;
- }
-
- swfdec_player_root (player, resource, (GFunc) swfdec_as_object_mark);
- loader = swfdec_player_load (player, load-> url, load->request, load->buffer);
- swfdec_resource_set_loader (resource, loader);
- g_object_unref (loader);
-}
-
-static void
-swfdec_resource_load_request (gpointer loadp, gpointer playerp)
-{
- SwfdecResourceLoad *load = loadp;
- SwfdecPlayer *player = playerp;
- SwfdecURL *url;
-
- /* empty URL means unload (yay!) */
- if (load->url[0] == '\0') {
- SwfdecSpriteMovie *movie;
-
- movie = (SwfdecSpriteMovie *) swfdec_action_lookup_object (
- SWFDEC_AS_CONTEXT (player), player->priv->roots->data,
- load->target, load->target + strlen (load->target));
- if (!SWFDEC_IS_SPRITE_MOVIE (movie)) {
- SWFDEC_DEBUG ("no movie, not unloading");
- return;
- }
- swfdec_resource_replace_movie (movie, SWFDEC_MOVIE (movie)->resource);
- return;
- }
-
- /* fscommand? */
- if (g_ascii_strncasecmp (load->url, "FSCommand:", 10) == 0) {
- char *command = load->url + 10;
- g_signal_emit_by_name (player, "fscommand", command, load->target);
- return;
- }
-
- /* LAUNCH command (aka getURL) */
- if (!load->target_is_movie && swfdec_player_get_level (player, load->target) < 0) {
- swfdec_player_launch (player, load->request, load->url,load->target, load->buffer);
- return;
- }
-
- if (swfdec_url_path_is_relative (load->url)) {
- swfdec_resource_do_load (player, TRUE, load);
- return;
- }
- url = swfdec_player_create_url (player, load->url);
- if (url == NULL) {
- swfdec_resource_do_load (player, FALSE, load);
- return;
- }
- switch (load->sandbox->type) {
- case SWFDEC_SANDBOX_REMOTE:
- swfdec_resource_do_load (player, !swfdec_url_is_local (url), load);
- break;
- case SWFDEC_SANDBOX_LOCAL_NETWORK:
- case SWFDEC_SANDBOX_LOCAL_TRUSTED:
- if (!swfdec_url_is_local (url)) {
- SWFDEC_FIXME ("Adobe claims you need to be allowed by policy files now, "
- "we don't check that though");
- }
- swfdec_resource_do_load (player, TRUE, load);
- break;
- case SWFDEC_SANDBOX_LOCAL_FILE:
- swfdec_resource_do_load (player, swfdec_url_is_local (url), load);
- break;
- case SWFDEC_SANDBOX_NONE:
- default:
- g_assert_not_reached ();
- break;
- }
- swfdec_url_free (url);
-}
-
-/* NB: must be called from a script */
-/* FIXME: 7 arguments?! */
-void
-swfdec_resource_load (SwfdecPlayer *player, const char *target, const char *url,
- SwfdecLoaderRequest request, SwfdecBuffer *buffer, SwfdecMovieClipLoader *loader,
- gboolean target_is_movie)
-{
- SwfdecSpriteMovie *movie;
- SwfdecResourceLoad *load;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (target != NULL);
- g_return_if_fail (url != NULL);
- g_return_if_fail (loader == NULL || SWFDEC_IS_MOVIE_CLIP_LOADER (loader));
-
- g_assert (SWFDEC_AS_CONTEXT (player)->frame != NULL);
- load = g_slice_new (SwfdecResourceLoad);
-
- if (target_is_movie) {
- movie = (SwfdecSpriteMovie *) swfdec_player_get_movie_from_string (player, target);
- if (SWFDEC_IS_SPRITE_MOVIE (movie)) {
- load->target = swfdec_movie_get_path (SWFDEC_MOVIE (movie), TRUE);
- } else if (swfdec_player_get_level (player, target) >= 0) {
- load->target = g_strdup (target);
- } else {
- SWFDEC_WARNING ("%s does not reference a movie, not loading %s", target, url);
- return;
- }
- } else {
- load->target = g_strdup (target);
- }
- load->sandbox = SWFDEC_SANDBOX (SWFDEC_AS_CONTEXT (player)->global);
- load->url = g_strdup (url);
- load->request = request;
- load->buffer = buffer;
- load->loader = loader;
- load->target_is_movie = target_is_movie;
-
- swfdec_player_root (player, load, swfdec_resource_load_mark);
- swfdec_player_request_resource (player, swfdec_resource_load_request, load, swfdec_resource_load_free);
-}
-
-gboolean
-swfdec_resource_emit_on_load_init (SwfdecResource *resource)
-{
- g_return_val_if_fail (SWFDEC_IS_RESOURCE (resource), FALSE);
-
- if (resource->state != SWFDEC_RESOURCE_COMPLETE)
- return FALSE;
-
- if (resource->movie && SWFDEC_IS_IMAGE_DECODER (resource->decoder)) {
- SwfdecImage *image = SWFDEC_IMAGE_DECODER (resource->decoder)->image;
- if (image) {
- swfdec_movie_invalidate_next (SWFDEC_MOVIE (resource->movie));
- swfdec_movie_queue_update (SWFDEC_MOVIE (resource->movie), SWFDEC_MOVIE_INVALID_EXTENTS);
- SWFDEC_MOVIE (resource->movie)->image = g_object_ref (image);
- }
- }
- swfdec_resource_emit_signal (resource, SWFDEC_AS_STR_onLoadInit, FALSE, NULL, 0);
- resource->state = SWFDEC_RESOURCE_DONE;
- /* free now unneeded resources */
- resource->clip_loader = NULL;
- resource->clip_loader_sandbox = NULL;
- return TRUE;
-}
diff --git a/libswfdec/swfdec_resource.h b/libswfdec/swfdec_resource.h
deleted file mode 100644
index fba2f95..0000000
--- a/libswfdec/swfdec_resource.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_RESOURCE_H_
-#define _SWFDEC_RESOURCE_H_
-
-#include <libswfdec/swfdec_player.h>
-#include <libswfdec/swfdec_sandbox.h>
-#include <libswfdec/swfdec_sprite_movie.h>
-
-G_BEGIN_DECLS
-
-//typedef struct _SwfdecResource SwfdecResource;
-typedef struct _SwfdecResourceClass SwfdecResourceClass;
-
-#define SWFDEC_TYPE_RESOURCE (swfdec_resource_get_type())
-#define SWFDEC_IS_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_RESOURCE))
-#define SWFDEC_IS_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_RESOURCE))
-#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
-{
- SwfdecAsObject object;
-
- guint version; /* version of this resource */
- SwfdecSandbox * sandbox; /* sandbox this resource belongs to (only NULL for a short time on very first loader) */
- SwfdecSpriteMovie * movie; /* the movie responsible for creating this instance */
-
- SwfdecLoader * loader; /* the loader providing data for the decoder */
- SwfdecDecoder * decoder; /* decoder in use or NULL if broken file */
- char * variables; /* extra variables to be set */
-
- GHashTable * exports; /* string->SwfdecCharacter mapping of exported characters */
- 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 */
- SwfdecSandbox * clip_loader_sandbox; /* sandbox used for events on the clip loader */
-};
-
-struct _SwfdecResourceClass
-{
- SwfdecAsObjectClass object_class;
-};
-
-GType swfdec_resource_get_type (void);
-
-SwfdecResource *swfdec_resource_new (SwfdecPlayer * player,
- SwfdecLoader * loader,
- const char * variables);
-
-gboolean swfdec_resource_emit_on_load_init (SwfdecResource * resource);
-void swfdec_resource_add_export (SwfdecResource * instance,
- SwfdecCharacter * character,
- const char * name);
-gpointer swfdec_resource_get_export (SwfdecResource * root,
- const char * name);
-const char * swfdec_resource_get_export_name (SwfdecResource * root,
- SwfdecCharacter * character);
-
-void swfdec_resource_load (SwfdecPlayer * player,
- const char * target,
- const char * url,
- SwfdecLoaderRequest request,
- SwfdecBuffer * buffer,
- SwfdecMovieClipLoader *loader,
- gboolean target_is_movie);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_ringbuffer.c b/libswfdec/swfdec_ringbuffer.c
deleted file mode 100644
index 6d3dd04..0000000
--- a/libswfdec/swfdec_ringbuffer.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include "swfdec_ringbuffer.h"
-
-SwfdecRingBuffer *
-swfdec_ring_buffer_new (guint element_size, guint size)
-{
- SwfdecRingBuffer *buffer;
-
- g_return_val_if_fail (element_size > 0, NULL);
- g_return_val_if_fail (size > 1, NULL);
-
- buffer = g_new0 (SwfdecRingBuffer, 1);
- buffer->element_size = element_size;
- buffer->size = size;
- buffer->data = g_malloc (element_size * size);
-
- return buffer;
-}
-
-void
-swfdec_ring_buffer_free (SwfdecRingBuffer *buffer)
-{
- g_return_if_fail (buffer != NULL);
-
- g_free (buffer->data);
- g_free (buffer);
-}
-
-guint
-swfdec_ring_buffer_get_size (SwfdecRingBuffer *buffer)
-{
- g_return_val_if_fail (buffer != NULL, 0);
-
- return buffer->size;
-}
-
-#define GET_ELEMENT(buffer,idx) (buffer->data + buffer->element_size * (idx))
-void
-swfdec_ring_buffer_set_size (SwfdecRingBuffer *buffer, guint new_size)
-{
- g_return_if_fail (buffer != NULL);
- g_return_if_fail (buffer->size < new_size);
-
- buffer->data = g_realloc (buffer->data, buffer->element_size * new_size);
- if (buffer->tail <= buffer->head && buffer->n_elements) {
- memmove (GET_ELEMENT (buffer, buffer->head + new_size - buffer->size),
- GET_ELEMENT (buffer, buffer->head),
- buffer->element_size * (buffer->size - buffer->head));
- buffer->head += new_size - buffer->size;
- }
- buffer->size = new_size;
-}
-
-guint
-swfdec_ring_buffer_get_n_elements (SwfdecRingBuffer *buffer)
-{
- g_return_val_if_fail (buffer != NULL, 0);
-
- return buffer->n_elements;
-}
-
-gpointer
-swfdec_ring_buffer_push (SwfdecRingBuffer *buffer)
-{
- gpointer ret;
-
- g_return_val_if_fail (buffer != NULL, NULL);
-
- if (buffer->n_elements == buffer->size)
- return NULL;
-
- ret = GET_ELEMENT (buffer, buffer->tail);
- buffer->tail = (buffer->tail + 1) % buffer->size;
- buffer->n_elements++;
- return ret;
-}
-
-gpointer
-swfdec_ring_buffer_pop (SwfdecRingBuffer *buffer)
-{
- gpointer ret;
-
- g_return_val_if_fail (buffer != NULL, NULL);
-
- if (buffer->n_elements == 0)
- return NULL;
-
- ret = GET_ELEMENT (buffer, buffer->head);
- buffer->head = (buffer->head + 1) % buffer->size;
- buffer->n_elements--;
- return ret;
-}
-
-gpointer
-swfdec_ring_buffer_peek_nth (SwfdecRingBuffer *buffer, guint id)
-{
- g_return_val_if_fail (buffer != NULL, NULL);
- g_return_val_if_fail (id < buffer->n_elements, NULL);
-
- id = (buffer->head + id) % buffer->size;
- return GET_ELEMENT (buffer, id);
-}
diff --git a/libswfdec/swfdec_ringbuffer.h b/libswfdec/swfdec_ringbuffer.h
deleted file mode 100644
index 3f02851..0000000
--- a/libswfdec/swfdec_ringbuffer.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef __SWFDEC_RING_BUFFER_H__
-#define __SWFDEC_RING_BUFFER_H__
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-
-typedef struct _SwfdecRingBuffer SwfdecRingBuffer;
-
-struct _SwfdecRingBuffer
-{
- unsigned char * data; /* our data */
- gsize element_size; /* size of one element */
- guint size; /* number of elements in the buffer */
-
- guint head; /* index of first element */
- guint tail; /* index after last element */
- guint n_elements; /* number of elements in ringbuffer */
-};
-
-SwfdecRingBuffer * swfdec_ring_buffer_new (guint element_size,
- guint size);
-#define swfdec_ring_buffer_new_for_type(element_type,size) \
- swfdec_ring_buffer_new (sizeof (element_type), (size))
-void swfdec_ring_buffer_free (SwfdecRingBuffer * buffer);
-
-guint swfdec_ring_buffer_get_size (SwfdecRingBuffer * buffer);
-void swfdec_ring_buffer_set_size (SwfdecRingBuffer * buffer,
- guint new_size);
-guint swfdec_ring_buffer_get_n_elements (SwfdecRingBuffer * buffer);
-
-gpointer swfdec_ring_buffer_push (SwfdecRingBuffer * buffer);
-gpointer swfdec_ring_buffer_pop (SwfdecRingBuffer * buffer);
-gpointer swfdec_ring_buffer_peek_nth (SwfdecRingBuffer * buffer,
- guint id);
-
-G_END_DECLS
-
-#endif
diff --git a/libswfdec/swfdec_sandbox.c b/libswfdec/swfdec_sandbox.c
deleted file mode 100644
index 9832f63..0000000
--- a/libswfdec/swfdec_sandbox.c
+++ /dev/null
@@ -1,303 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_sandbox.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-#include "swfdec_initialize.h"
-#include "swfdec_internal.h"
-#include "swfdec_player_internal.h"
-
-/*** GTK-DOC ***/
-
-/**
- * SECTION:SwfdecSandbox
- * @title: SwfdecSandbox
- * @short_description: global object used for security
- *
- * The SwfdecSandbox object is a garbage-collected script object that does two
- * things. The simple thing is its use as the global object while code is
- * executed in a #SwfdecPlayer. So you can always assume that the global object
- * is a #SwfdecSandbox. The second task it fulfills is acting as the security
- * mechanism used by native functions to determine if a given action should be
- * allowed or not. This is easy, because script functions can always refer to
- * it as the global object.
- */
-
-G_DEFINE_TYPE (SwfdecSandbox, swfdec_sandbox, SWFDEC_TYPE_AS_OBJECT)
-
-static void
-swfdec_sandbox_mark (SwfdecAsObject *object)
-{
- SwfdecSandbox *sandbox = SWFDEC_SANDBOX (object);
-
- swfdec_as_object_mark (sandbox->Function);
- swfdec_as_object_mark (sandbox->Function_prototype);
- swfdec_as_object_mark (sandbox->Object);
- swfdec_as_object_mark (sandbox->Object_prototype);
- swfdec_as_object_mark (sandbox->MovieClip);
- swfdec_as_object_mark (sandbox->Video);
-
- SWFDEC_AS_OBJECT_CLASS (swfdec_sandbox_parent_class)->mark (object);
-}
-
-static void
-swfdec_sandbox_dispose (GObject *object)
-{
- SwfdecSandbox *sandbox = SWFDEC_SANDBOX (object);
-
- swfdec_url_free (sandbox->url);
-
- G_OBJECT_CLASS (swfdec_sandbox_parent_class)->dispose (object);
-}
-
-static void
-swfdec_sandbox_class_init (SwfdecSandboxClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
-
- object_class->dispose = swfdec_sandbox_dispose;
-
- asobject_class->mark = swfdec_sandbox_mark;
-}
-
-static void
-swfdec_sandbox_init (SwfdecSandbox *sandbox)
-{
- sandbox->type = SWFDEC_SANDBOX_NONE;
-}
-
-static void
-swfdec_sandbox_initialize (SwfdecSandbox *sandbox, guint version)
-{
- SwfdecAsContext *context = SWFDEC_AS_OBJECT (sandbox)->context;
- SwfdecPlayer *player = SWFDEC_PLAYER (context);
-
- swfdec_sandbox_use (sandbox);
- if (context->state == SWFDEC_AS_CONTEXT_RUNNING)
- context->state = SWFDEC_AS_CONTEXT_NEW;
- swfdec_as_context_startup (context);
- /* reset state for initialization */
- /* FIXME: have a better way to do this */
- context->state = SWFDEC_AS_CONTEXT_NEW;
- swfdec_sprite_movie_init_context (player);
- swfdec_video_movie_init_context (player);
- swfdec_net_stream_init_context (player);
-
- swfdec_as_context_run_init_script (context, swfdec_initialize,
- sizeof (swfdec_initialize), version);
-
- sandbox->Function = context->Function;
- sandbox->Function_prototype = context->Function_prototype;
- sandbox->Object = context->Object;
- sandbox->Object_prototype = context->Object_prototype;
-
- if (context->state == SWFDEC_AS_CONTEXT_NEW)
- context->state = SWFDEC_AS_CONTEXT_RUNNING;
- swfdec_sandbox_unuse (sandbox);
-}
-/**
- * swfdec_sandbox_set_allow_network:
- * @sandbox: a #SwfdecSandbox
- * finished, by giving the sandbox network or local file access. This function
- * should be called on all return values of swfdec_sandbox_get_for_url().
- *
- * Returns: %TRUE if the sandbox initialization could be finished as requested,
- * %FALSE if not and it shouldn't be used.
- **/
-static gboolean
-swfdec_sandbox_set_allow_network (SwfdecSandbox *sandbox, gboolean network)
-{
- g_return_val_if_fail (SWFDEC_IS_SANDBOX (sandbox), FALSE);
-
- switch (sandbox->type) {
- case SWFDEC_SANDBOX_REMOTE:
- return TRUE;
- case SWFDEC_SANDBOX_LOCAL_FILE:
- return !network;
- case SWFDEC_SANDBOX_LOCAL_NETWORK:
- return network;
- case SWFDEC_SANDBOX_LOCAL_TRUSTED:
- return TRUE;
- case SWFDEC_SANDBOX_NONE:
- break;
- default:
- g_assert_not_reached ();
- break;
- }
-
- if (swfdec_url_is_local (sandbox->url)) {
- sandbox->type = network ? SWFDEC_SANDBOX_LOCAL_NETWORK : SWFDEC_SANDBOX_LOCAL_FILE;
- } else {
- sandbox->type = SWFDEC_SANDBOX_REMOTE;
- }
-
- return TRUE;
-}
-
-/**
- * swfdec_sandbox_get_for_url:
- * @player: a #SwfdecPlayer
- * @url: the URL this player refers to
- * @flash_version: The Flash version for looking up the sandbox
- * @allow_network: %TRUE to allow network access, %FALSE to only allow local
- * file access. See the documentation of the use_network flag
- * of the SWF FileAttributes tag for what that means.
- *
- *
- * Checks if a sandbox is already in use for a given URL and if so, returns it.
- * Otherwise a new sandbox is created, initialized and returned.
- * Note that the given url must be a HTTP, HTTPS or a FILE url.
- *
- * Returns: the sandbox corresponding to the given URL or %NULL if no such
- * sandbox is allowed.
- **/
-SwfdecSandbox *
-swfdec_sandbox_get_for_url (SwfdecPlayer *player, const SwfdecURL *url,
- guint flash_version, gboolean allow_network)
-{
- SwfdecPlayerPrivate *priv;
- SwfdecSandbox *sandbox;
- SwfdecURL *real;
- guint as_version;
- GSList *walk;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
- g_return_val_if_fail (url != NULL, NULL);
-
- priv = player->priv;
- real = swfdec_url_new_components (swfdec_url_get_protocol (url),
- swfdec_url_get_host (url), swfdec_url_get_port (url), NULL, NULL);
- as_version = flash_version < 7 ? 1 : 2;
-
- for (walk = priv->sandboxes; walk; walk = walk->next) {
- sandbox = walk->data;
- if (sandbox->as_version == as_version &&
- swfdec_url_equal (sandbox->url, real))
- break;
- }
-
- if (walk) {
- swfdec_url_free (real);
-
- if (!swfdec_sandbox_set_allow_network (sandbox, allow_network))
- return NULL;
- } else {
- SwfdecAsContext *context = SWFDEC_AS_CONTEXT (player);
- guint size = sizeof (SwfdecSandbox);
- if (!swfdec_as_context_use_mem (context, size))
- size = 0;
-
- sandbox = g_object_new (SWFDEC_TYPE_SANDBOX, NULL);
- swfdec_as_object_add (SWFDEC_AS_OBJECT (sandbox), context, size);
- sandbox->url = real;
- sandbox->as_version = as_version;
- priv->sandboxes = g_slist_append (priv->sandboxes, sandbox);
-
- if (!swfdec_sandbox_set_allow_network (sandbox, allow_network))
- return NULL;
-
- swfdec_sandbox_initialize (sandbox, flash_version);
- }
-
-
- return sandbox;
-}
-
-/**
- * swfdec_sandbox_use:
- * @sandbox: the sandbox to use when executing scripts
- *
- * Sets @sandbox to be used for scripts that are going to be executed next. No
- * sandbox may be set yet. You must unset the sandbox with
- * swfdec_sandbox_unuse() after calling your script.
- **/
-void
-swfdec_sandbox_use (SwfdecSandbox *sandbox)
-{
- SwfdecAsContext *context;
- SwfdecPlayerPrivate *priv;
-
- g_return_if_fail (SWFDEC_IS_SANDBOX (sandbox));
- g_return_if_fail (sandbox->type != SWFDEC_SANDBOX_NONE);
- g_return_if_fail (SWFDEC_AS_OBJECT (sandbox)->context->global == NULL);
-
- context = SWFDEC_AS_OBJECT (sandbox)->context;
- priv = SWFDEC_PLAYER (context)->priv;
- context->global = SWFDEC_AS_OBJECT (sandbox);
-
- context->Function = sandbox->Function;
- context->Function_prototype = sandbox->Function_prototype;
- context->Object = sandbox->Object;
- context->Object_prototype = sandbox->Object_prototype;
-}
-
-/**
- * swfdec_sandbox_try_use:
- * @sandbox: the sandbox to use
- *
- * Makes sure a sandbox is in use. If no sandbox is in use currently, use the
- * given @sandbox. This function is intended for cases where code can be called
- * from both inside scripts with a sandbox already set or outside with no
- * sandbox in use.
- *
- * Returns: %TRUE if the new sandbox will be used. You need to call
- * swfdec_sandbox_unuse() afterwards. %FALSE if a sandbox is already in
- * use.
- **/
-gboolean
-swfdec_sandbox_try_use (SwfdecSandbox *sandbox)
-{
- g_return_val_if_fail (SWFDEC_IS_SANDBOX (sandbox), FALSE);
- g_return_val_if_fail (sandbox->type != SWFDEC_SANDBOX_NONE, FALSE);
-
- if (SWFDEC_AS_OBJECT (sandbox)->context->global)
- return FALSE;
-
- swfdec_sandbox_use (sandbox);
- return TRUE;
-}
-
-/**
- * swfdec_sandbox_unuse:
- * @sandbox: a #SwfdecSandbox
- *
- * Unsets the sandbox as the current sandbox for executing scripts.
- **/
-void
-swfdec_sandbox_unuse (SwfdecSandbox *sandbox)
-{
- SwfdecAsContext *context;
-
- g_return_if_fail (SWFDEC_IS_SANDBOX (sandbox));
- g_return_if_fail (SWFDEC_AS_OBJECT (sandbox)->context->global == SWFDEC_AS_OBJECT (sandbox));
-
- context = SWFDEC_AS_OBJECT (sandbox)->context;
- context->global = NULL;
- context->Function = NULL;
- context->Function_prototype = NULL;
- context->Object = NULL;
- context->Object_prototype = NULL;
-}
-
diff --git a/libswfdec/swfdec_sandbox.h b/libswfdec/swfdec_sandbox.h
deleted file mode 100644
index 6fda9b7..0000000
--- a/libswfdec/swfdec_sandbox.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_SANDBOX_H_
-#define _SWFDEC_SANDBOX_H_
-
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_url.h>
-#include <libswfdec/swfdec_player.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecSandbox SwfdecSandbox;
-typedef struct _SwfdecSandboxClass SwfdecSandboxClass;
-
-typedef enum {
- SWFDEC_SANDBOX_NONE,
- SWFDEC_SANDBOX_REMOTE,
- SWFDEC_SANDBOX_LOCAL_FILE,
- SWFDEC_SANDBOX_LOCAL_NETWORK,
- SWFDEC_SANDBOX_LOCAL_TRUSTED
-} SwfdecSandboxType;
-
-#define SWFDEC_TYPE_SANDBOX (swfdec_sandbox_get_type())
-#define SWFDEC_IS_SANDBOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SANDBOX))
-#define SWFDEC_IS_SANDBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SANDBOX))
-#define SWFDEC_SANDBOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SANDBOX, SwfdecSandbox))
-#define SWFDEC_SANDBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SANDBOX, SwfdecSandboxClass))
-#define SWFDEC_SANDBOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_SANDBOX, SwfdecSandboxClass))
-
-struct _SwfdecSandbox
-{
- SwfdecAsObject object;
-
- SwfdecSandboxType type; /* type of this sandbox */
- SwfdecURL * url; /* URL this sandbox acts for */
- guint as_version; /* Actionscript version */
-
- /* global cached objects from context */
- SwfdecAsObject * Function; /* Function */
- SwfdecAsObject * Function_prototype; /* Function.prototype */
- SwfdecAsObject * Object; /* Object */
- SwfdecAsObject * Object_prototype; /* Object.prototype */
-
- /* global player objects */
- SwfdecAsObject * MovieClip; /* MovieClip object */
- SwfdecAsObject * Video; /* Video object */
-};
-
-struct _SwfdecSandboxClass
-{
- SwfdecAsObjectClass object_class;
-};
-
-GType swfdec_sandbox_get_type (void);
-
-SwfdecSandbox * swfdec_sandbox_get_for_url (SwfdecPlayer * player,
- const SwfdecURL * url,
- guint flash_version,
- gboolean allow_network);
-
-void swfdec_sandbox_use (SwfdecSandbox * sandbox);
-gboolean swfdec_sandbox_try_use (SwfdecSandbox * sandbox);
-void swfdec_sandbox_unuse (SwfdecSandbox * sandbox);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_script.c b/libswfdec/swfdec_script.c
deleted file mode 100644
index ec73386..0000000
--- a/libswfdec/swfdec_script.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_script.h"
-#include "swfdec_script_internal.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_interpret.h"
-#include "swfdec_debug.h"
-
-/**
- * SwfdecScript:
- *
- * This is the object used for code to be executed by Swfdec. Scripts are
- * independant from the #SwfdecAsContext they are executed in, so you can
- * execute the same script in multiple contexts.
- */
-
-/* Define this to get SWFDEC_WARN'd about missing properties of objects.
- * This can be useful to find out about unimplemented native properties,
- * but usually just causes a lot of spam. */
-//#define SWFDEC_WARN_MISSING_PROPERTIES
-
-/*** CONSTANT POOLS ***/
-
-struct _SwfdecConstantPool {
- SwfdecAsContext * context; /* context we are attached to or NULL */
- guint n_strings; /* number of strings */
- char * strings[1]; /* n_strings strings */
-};
-
-SwfdecConstantPool *
-swfdec_constant_pool_new_from_action (const guint8 *data, guint len, guint version)
-{
- guint i, n;
- SwfdecBits bits;
- SwfdecConstantPool *pool;
-
- swfdec_bits_init_data (&bits, data, len);
-
- n = swfdec_bits_get_u16 (&bits);
- if (n == 0)
- return NULL;
-
- pool = g_malloc0 (sizeof (SwfdecConstantPool) + (n - 1) * sizeof (char *));
- pool->n_strings = n;
- for (i = 0; i < n; i++) {
- pool->strings[i] = swfdec_bits_get_string (&bits, version);
- if (pool->strings[i] == NULL) {
- SWFDEC_ERROR ("not enough strings available");
- swfdec_constant_pool_free (pool);
- return NULL;
- }
- }
- if (swfdec_bits_left (&bits)) {
- SWFDEC_WARNING ("constant pool didn't consume whole buffer (%u bytes leftover)", swfdec_bits_left (&bits) / 8);
- }
- return pool;
-}
-
-void
-swfdec_constant_pool_attach_to_context (SwfdecConstantPool *pool, SwfdecAsContext *context)
-{
- guint i;
-
- g_return_if_fail (pool != NULL);
- g_return_if_fail (pool->context == NULL);
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
-
- pool->context = context;
- for (i = 0; i < pool->n_strings; i++) {
- pool->strings[i] = (char *) swfdec_as_context_give_string (context, pool->strings[i]);
- }
-}
-
-guint
-swfdec_constant_pool_size (SwfdecConstantPool *pool)
-{
- return pool->n_strings;
-}
-
-const char *
-swfdec_constant_pool_get (SwfdecConstantPool *pool, guint i)
-{
- g_assert (i < pool->n_strings);
- return pool->strings[i];
-}
-
-void
-swfdec_constant_pool_free (SwfdecConstantPool *pool)
-{
- if (pool->context == NULL) {
- guint i;
- for (i = 0; i < pool->n_strings; i++) {
- g_free (pool->strings[i]);
- }
- }
- g_free (pool);
-}
-
-/*** SUPPORT FUNCTIONS ***/
-
-char *
-swfdec_script_print_action (guint action, const guint8 *data, guint len)
-{
- const SwfdecActionSpec *spec = swfdec_as_actions + action;
-
- if (action & 0x80) {
- if (spec->print == NULL) {
- SWFDEC_ERROR ("action %u 0x%02X %s has no print statement",
- action, action, spec->name ? spec->name : "Unknown");
- return g_strdup_printf ("erroneous action %s",
- spec->name ? spec->name : "Unknown");
- }
- return spec->print (action, data, len);
- } else {
- if (spec->name == NULL) {
- SWFDEC_ERROR ("action %u is unknown", action);
- return g_strdup_printf ("unknown Action 0x%02X", action);
- }
- return g_strdup (spec->name);
- }
-}
-
-static gboolean
-swfdec_script_foreach_internal (SwfdecBits *bits, SwfdecScriptForeachFunc func, gpointer user_data)
-{
- guint action, len;
- const guint8 *data;
- gconstpointer bytecode;
-
- bytecode = bits->ptr;
- while (swfdec_bits_left (bits) && (action = swfdec_bits_get_u8 (bits))) {
- if (action & 0x80) {
- len = swfdec_bits_get_u16 (bits);
- data = bits->ptr;
- } else {
- len = 0;
- data = NULL;
- }
- if (swfdec_bits_skip_bytes (bits, len) != len) {
- SWFDEC_ERROR ("script too short");
- return FALSE;
- }
- if (!func (bytecode, action, data, len, user_data))
- return FALSE;
- bytecode = bits->ptr;
- }
- return TRUE;
-}
-
-static gboolean
-validate_action (gconstpointer bytecode, guint action, const guint8 *data, guint len, gpointer scriptp)
-{
- // TODO: get rid of this function
- return TRUE;
-}
-
-/*** PUBLIC API ***/
-
-gboolean
-swfdec_script_foreach (SwfdecScript *script, SwfdecScriptForeachFunc func, gpointer user_data)
-{
- SwfdecBits bits;
-
- g_return_val_if_fail (script != NULL, FALSE);
- g_return_val_if_fail (func != NULL, FALSE);
-
- swfdec_bits_init (&bits, script->buffer);
- bits.ptr = script->main;
- return swfdec_script_foreach_internal (&bits, func, user_data);
-}
-
-/**
- * swfdec_script_new:
- * @buffer: the #SwfdecBuffer containing the script. This function will take
- * ownership of the passed in buffer.
- * @name: name of the script for debugging purposes
- * @version: Actionscript version to use in this script
- *
- * Creates a new script for the actionscript provided in @buffer.
- *
- * Returns: a new #SwfdecScript for executing the script i @buffer.
- **/
-SwfdecScript *
-swfdec_script_new (SwfdecBuffer *buffer, const char *name, guint version)
-{
- SwfdecBits bits;
- SwfdecScript *script;
-
- g_return_val_if_fail (buffer != NULL, NULL);
-
- swfdec_bits_init (&bits, buffer);
- script = swfdec_script_new_from_bits (&bits, name, version);
- swfdec_buffer_unref (buffer);
- return script;
-}
-
-SwfdecScript *
-swfdec_script_new_from_bits (SwfdecBits *bits, const char *name, guint version)
-{
- SwfdecScript *script;
- SwfdecBuffer *buffer;
- SwfdecBits org;
- guint len;
-
- g_return_val_if_fail (bits != NULL, NULL);
-
- org = *bits;
- len = swfdec_bits_left (bits) / 8;
- script = g_new0 (SwfdecScript, 1);
- script->refcount = 1;
- script->name = g_strdup (name ? name : "Unnamed script");
- script->version = version;
- /* by default, a function has 4 registers */
- script->n_registers = 5;
- /* These flags are the default arguments used by scripts read from a file.
- * DefineFunction and friends override this */
- script->flags = SWFDEC_SCRIPT_SUPPRESS_ARGS;
-
- if (!swfdec_script_foreach_internal (bits, validate_action, script)) {
- swfdec_script_unref (script);
- return NULL;
- }
- len -= swfdec_bits_left (bits) / 8;
- if (len == 0) {
- buffer = swfdec_buffer_new ();
- } else {
- buffer = swfdec_bits_get_buffer (&org, len);
- }
-
- script->main = buffer->data;
- script->exit = buffer->data + buffer->length;
- script->buffer = swfdec_buffer_ref (swfdec_buffer_get_super (buffer));
- swfdec_buffer_unref (buffer);
- return script;
-}
-
-SwfdecScript *
-swfdec_script_ref (SwfdecScript *script)
-{
- g_return_val_if_fail (script != NULL, NULL);
- g_return_val_if_fail (script->refcount > 0, NULL);
-
- script->refcount++;
- return script;
-}
-
-void
-swfdec_script_unref (SwfdecScript *script)
-{
- guint i;
-
- g_return_if_fail (script != NULL);
- g_return_if_fail (script->refcount > 0);
-
- script->refcount--;
- if (script->refcount > 0)
- return;
-
- if (script->buffer)
- swfdec_buffer_unref (script->buffer);
- if (script->constant_pool)
- swfdec_buffer_unref (script->constant_pool);
- g_free (script->name);
- for (i = 0; i < script->n_arguments; i++) {
- g_free (script->arguments[i].name);
- }
- g_free (script->arguments);
- g_free (script);
-}
-
-/*** UTILITY FUNCTIONS ***/
-
-const char *
-swfdec_action_get_name (guint action)
-{
- g_return_val_if_fail (action < 256, NULL);
-
- return swfdec_as_actions[action].name;
-}
-
-guint
-swfdec_action_get_from_name (const char *name)
-{
- guint i;
-
- g_return_val_if_fail (name != NULL, 0);
-
- for (i = 0; i < 256; i++) {
- if (swfdec_as_actions[i].name && g_str_equal (name, swfdec_as_actions[i].name))
- return i;
- }
- return 0;
-}
-
-
diff --git a/libswfdec/swfdec_script.h b/libswfdec/swfdec_script.h
deleted file mode 100644
index fe90428..0000000
--- a/libswfdec/swfdec_script.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_SCRIPT_H_
-#define _SWFDEC_SCRIPT_H_
-
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_buffer.h>
-
-G_BEGIN_DECLS
-
-
-SwfdecScript * swfdec_script_new (SwfdecBuffer * buffer,
- const char * name,
- guint version);
-SwfdecScript * swfdec_script_ref (SwfdecScript * script);
-void swfdec_script_unref (SwfdecScript * script);
-
-
-G_END_DECLS
-
-#endif
diff --git a/libswfdec/swfdec_script_internal.h b/libswfdec/swfdec_script_internal.h
deleted file mode 100644
index 23acb0d..0000000
--- a/libswfdec/swfdec_script_internal.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_SCRIPT_INTERNAL_H_
-#define _SWFDEC_SCRIPT_INTERNAL_H_
-
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_bits.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecScriptArgument SwfdecScriptArgument;
-typedef struct _SwfdecConstantPool SwfdecConstantPool;
-
-typedef enum {
- SWFDEC_SCRIPT_PRELOAD_THIS = (1 << 0),
- SWFDEC_SCRIPT_SUPPRESS_THIS = (1 << 1),
- SWFDEC_SCRIPT_PRELOAD_ARGS = (1 << 2),
- SWFDEC_SCRIPT_SUPPRESS_ARGS = (1 << 3),
- SWFDEC_SCRIPT_PRELOAD_SUPER = (1 << 4),
- SWFDEC_SCRIPT_SUPPRESS_SUPER = (1 << 5),
- SWFDEC_SCRIPT_PRELOAD_ROOT = (1 << 6),
- SWFDEC_SCRIPT_PRELOAD_PARENT = (1 << 7),
- SWFDEC_SCRIPT_PRELOAD_GLOBAL = (1 << 8)
-} SwfdecScriptFlag;
-
-typedef gboolean (* SwfdecScriptForeachFunc) (gconstpointer bytecode, guint action,
- const guint8 *data, guint len, gpointer user_data);
-
-/* FIXME: May want to typedef to SwfdecBuffer directly */
-struct _SwfdecScript {
- SwfdecBuffer * buffer; /* buffer holding the script */
- const guint8 * main; /* entry point for script */
- const guint8 * exit; /* exit point for script */
- guint refcount; /* reference count */
- char * name; /* name identifying this script */
- guint version; /* version of the script */
- guint n_registers; /* number of registers */
- SwfdecBuffer * constant_pool; /* constant pool action */
- guint flags; /* SwfdecScriptFlags */
- guint n_arguments; /* number of arguments */
- SwfdecScriptArgument *arguments; /* arguments or NULL if none */
-};
-
-struct _SwfdecScriptArgument {
- char * name; /* name of the argument (not GC'ed) */
- guint preload; /* preload slot to preload to or 0 */
-};
-
-const char * swfdec_action_get_name (guint action);
-guint swfdec_action_get_from_name (const char * name);
-
-SwfdecConstantPool *
- swfdec_constant_pool_new_from_action (const guint8 * data,
- guint len,
- guint version);
-void swfdec_constant_pool_free (SwfdecConstantPool * pool);
-guint swfdec_constant_pool_size (SwfdecConstantPool * pool);
-const char * swfdec_constant_pool_get (SwfdecConstantPool * pool,
- guint i);
-void swfdec_constant_pool_attach_to_context (SwfdecConstantPool * pool,
- SwfdecAsContext * context);
-
-SwfdecScript * swfdec_script_new_from_bits (SwfdecBits * bits,
- const char * name,
- guint version);
-
-gboolean swfdec_script_foreach (SwfdecScript * script,
- SwfdecScriptForeachFunc func,
- gpointer user_data);
-char * swfdec_script_print_action (guint action,
- const guint8 * data,
- guint len);
-
-G_END_DECLS
-
-#endif
diff --git a/libswfdec/swfdec_selection.c b/libswfdec/swfdec_selection.c
deleted file mode 100644
index e23e494..0000000
--- a/libswfdec/swfdec_selection.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_as_context.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (600, 0, swfdec_selection_getBeginIndex)
-void
-swfdec_selection_getBeginIndex (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Selection.getBeginIndex (static)");
-}
-
-SWFDEC_AS_NATIVE (600, 1, swfdec_selection_getEndIndex)
-void
-swfdec_selection_getEndIndex (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Selection.getEndIndex (static)");
-}
-
-SWFDEC_AS_NATIVE (600, 2, swfdec_selection_getCaretIndex)
-void
-swfdec_selection_getCaretIndex (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Selection.getCaretIndex (static)");
-}
-
-SWFDEC_AS_NATIVE (600, 3, swfdec_selection_getFocus)
-void
-swfdec_selection_getFocus (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Selection.getFocus (static)");
-}
-
-SWFDEC_AS_NATIVE (600, 4, swfdec_selection_setFocus)
-void
-swfdec_selection_setFocus (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Selection.setFocus (static)");
-}
-
-SWFDEC_AS_NATIVE (600, 5, swfdec_selection_setSelection)
-void
-swfdec_selection_setSelection (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Selection.setSelection (static)");
-}
diff --git a/libswfdec/swfdec_shape.c b/libswfdec/swfdec_shape.c
deleted file mode 100644
index ca86d8f..0000000
--- a/libswfdec/swfdec_shape.c
+++ /dev/null
@@ -1,387 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-#include <string.h>
-
-#include "swfdec_shape.h"
-#include "swfdec.h"
-#include "swfdec_debug.h"
-#include "swfdec_path.h"
-#include "swfdec_shape_parser.h"
-#include "swfdec_stroke.h"
-
-G_DEFINE_TYPE (SwfdecShape, swfdec_shape, SWFDEC_TYPE_GRAPHIC)
-
-static void
-swfdec_shape_dispose (GObject *object)
-{
- SwfdecShape * shape = SWFDEC_SHAPE (object);
-
- g_slist_foreach (shape->draws, (GFunc) g_object_unref, NULL);
- g_slist_free (shape->draws);
- shape->draws = NULL;
-
- G_OBJECT_CLASS (swfdec_shape_parent_class)->dispose (G_OBJECT (shape));
-}
-
-static void
-swfdec_shape_render (SwfdecGraphic *graphic, cairo_t *cr,
- const SwfdecColorTransform *trans, const SwfdecRect *inval)
-{
- SwfdecShape *shape = SWFDEC_SHAPE (graphic);
- GSList *walk;
-
- for (walk = shape->draws; walk; walk = walk->next) {
- SwfdecDraw *draw = walk->data;
-
- if (!swfdec_rect_intersect (NULL, &draw->extents, inval))
- continue;
-
- swfdec_draw_paint (draw, cr, trans);
- }
-}
-
-static gboolean
-swfdec_shape_mouse_in (SwfdecGraphic *graphic, double x, double y)
-{
- SwfdecShape *shape = SWFDEC_SHAPE (graphic);
- GSList *walk;
-
- for (walk = shape->draws; walk; walk = walk->next) {
- SwfdecDraw *draw = walk->data;
-
- if (swfdec_draw_contains (draw, x, y))
- return TRUE;
- }
- return FALSE;
-}
-
-static void
-swfdec_shape_class_init (SwfdecShapeClass * g_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (g_class);
- SwfdecGraphicClass *graphic_class = SWFDEC_GRAPHIC_CLASS (g_class);
-
- object_class->dispose = swfdec_shape_dispose;
-
- graphic_class->render = swfdec_shape_render;
- graphic_class->mouse_in = swfdec_shape_mouse_in;
-}
-
-static void
-swfdec_shape_init (SwfdecShape * shape)
-{
-}
-
-int
-tag_define_shape (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecBits *bits = &s->b;
- SwfdecShape *shape;
- SwfdecShapeParser *parser;
- int id;
-
- id = swfdec_bits_get_u16 (bits);
-
- shape = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_SHAPE);
- if (!shape)
- return SWFDEC_STATUS_OK;
-
- SWFDEC_INFO ("id=%d", id);
-
- swfdec_bits_get_rect (bits, &SWFDEC_GRAPHIC (shape)->extents);
-
- parser = swfdec_shape_parser_new ((SwfdecParseDrawFunc) swfdec_pattern_parse,
- (SwfdecParseDrawFunc) swfdec_stroke_parse, s);
- swfdec_shape_parser_parse (parser, bits);
- shape->draws = swfdec_shape_parser_free (parser);
-
- return SWFDEC_STATUS_OK;
-}
-
-int
-tag_define_shape_3 (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecBits *bits = &s->b;
- SwfdecShape *shape;
- SwfdecShapeParser *parser;
- int id;
-
- id = swfdec_bits_get_u16 (bits);
- shape = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_SHAPE);
- if (!shape)
- return SWFDEC_STATUS_OK;
-
- swfdec_bits_get_rect (bits, &SWFDEC_GRAPHIC (shape)->extents);
-
- parser = swfdec_shape_parser_new ((SwfdecParseDrawFunc) swfdec_pattern_parse_rgba,
- (SwfdecParseDrawFunc) swfdec_stroke_parse_rgba, s);
- swfdec_shape_parser_parse (parser, bits);
- shape->draws = swfdec_shape_parser_free (parser);
-
- return SWFDEC_STATUS_OK;
-}
-
-int
-tag_define_shape_4 (SwfdecSwfDecoder *s, guint tag)
-{
- SwfdecBits *bits = &s->b;
- SwfdecShape *shape;
- SwfdecShapeParser *parser;
- int id;
- SwfdecRect tmp;
- gboolean has_scale_strokes, has_noscale_strokes;
-
- id = swfdec_bits_get_u16 (bits);
- shape = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_SHAPE);
- if (!shape)
- return SWFDEC_STATUS_OK;
-
- swfdec_bits_get_rect (bits, &SWFDEC_GRAPHIC (shape)->extents);
- SWFDEC_LOG (" extents: %g %g x %g %g",
- SWFDEC_GRAPHIC (shape)->extents.x0, SWFDEC_GRAPHIC (shape)->extents.y0,
- SWFDEC_GRAPHIC (shape)->extents.x1, SWFDEC_GRAPHIC (shape)->extents.y1);
- swfdec_bits_get_rect (bits, &tmp);
- SWFDEC_LOG (" extents: %g %g x %g %g",
- tmp.x0, tmp.y0, tmp.x1, tmp.y1);
- swfdec_bits_getbits (bits, 6);
- has_scale_strokes = swfdec_bits_getbit (bits);
- has_noscale_strokes = swfdec_bits_getbit (bits);
- SWFDEC_LOG (" has scaling strokes: %d", has_scale_strokes);
- SWFDEC_LOG (" has non-scaling strokes: %d", has_noscale_strokes);
-
- parser = swfdec_shape_parser_new ((SwfdecParseDrawFunc) swfdec_pattern_parse_rgba,
- (SwfdecParseDrawFunc) swfdec_stroke_parse_extended, s);
- swfdec_shape_parser_parse (parser, bits);
- shape->draws = swfdec_shape_parser_free (parser);
-
- return SWFDEC_STATUS_OK;
-}
-
-#if 0
-/*** MORPH SHAPE ***/
-
-#include "swfdec_morphshape.h"
-
-static SubPath *
-swfdec_morph_shape_do_change (SwfdecBits *end_bits, SubPath *other, SwfdecMorphShape *morph,
- GArray *path_array, SubPath *path, int *x, int *y)
-{
- if (path) {
- path->x_end = *x;
- path->y_end = *y;
- }
- g_array_set_size (path_array, path_array->len + 1);
- path = &g_array_index (path_array, SubPath, path_array->len - 1);
- *path = *other;
- swfdec_path_init (&path->path);
- if (swfdec_shape_peek_type (end_bits) == SWFDEC_SHAPE_TYPE_CHANGE) {
- int state_line_styles, state_fill_styles1, state_fill_styles0, state_moveto;
-
- if (swfdec_bits_getbit (end_bits) != 0) {
- g_assert_not_reached ();
- }
- if (swfdec_bits_getbit (end_bits)) {
- SWFDEC_ERROR ("new styles aren't allowed in end edges, ignoring");
- }
- state_line_styles = swfdec_bits_getbit (end_bits);
- state_fill_styles1 = swfdec_bits_getbit (end_bits);
- state_fill_styles0 = swfdec_bits_getbit (end_bits);
- state_moveto = swfdec_bits_getbit (end_bits);
- if (state_moveto) {
- int n_bits = swfdec_bits_getbits (end_bits, 5);
- *x = swfdec_bits_getsbits (end_bits, n_bits);
- *y = swfdec_bits_getsbits (end_bits, n_bits);
-
- SWFDEC_LOG (" moveto %d,%d", *x, *y);
- }
- if (state_fill_styles0) {
- guint check = swfdec_bits_getbits (end_bits, morph->n_fill_bits) +
- SWFDEC_SHAPE (morph)->fills_offset;
- if (check != path->fill0style)
- SWFDEC_ERROR ("end fill0style %u differs from start fill0style %u", check, path->fill0style);
- }
- if (state_fill_styles1) {
- guint check = swfdec_bits_getbits (end_bits, morph->n_fill_bits) +
- SWFDEC_SHAPE (morph)->fills_offset;
- if (check != path->fill1style)
- SWFDEC_ERROR ("end fill1style %u differs from start fill1style %u", check, path->fill1style);
- }
- if (state_line_styles) {
- guint check = swfdec_bits_getbits (end_bits, morph->n_line_bits) +
- SWFDEC_SHAPE (morph)->lines_offset;
- if (check != path->linestyle)
- SWFDEC_ERROR ("end linestyle %u differs from start linestyle %u", check, path->linestyle);
- }
- }
- path->x_start = *x;
- path->y_start = *y;
- return path;
-}
-
-static void
-swfdec_morph_shape_get_recs (SwfdecSwfDecoder * s, SwfdecMorphShape *morph, SwfdecBits *end_bits)
-{
- int start_x = 0, start_y = 0, end_x = 0, end_y = 0;
- SubPath *start_path = NULL, *end_path = NULL;
- GArray *start_path_array, *end_path_array, *tmp;
- SwfdecShapeType start_type, end_type;
- SwfdecBits *start_bits = &s->b;
- SwfdecShape *shape = SWFDEC_SHAPE (morph);
-
- /* First, accumulate all sub-paths into an array */
- start_path_array = g_array_new (FALSE, TRUE, sizeof (SubPath));
- end_path_array = g_array_new (FALSE, TRUE, sizeof (SubPath));
-
- while ((start_type = swfdec_shape_peek_type (start_bits))) {
- end_type = swfdec_shape_peek_type (end_bits);
- if (end_type == SWFDEC_SHAPE_TYPE_CHANGE && start_type != SWFDEC_SHAPE_TYPE_CHANGE) {
- SubPath *path;
- if (start_path) {
- start_path->x_end = start_x;
- start_path->y_end = start_y;
- }
- g_array_set_size (start_path_array, start_path_array->len + 1);
- path = &g_array_index (start_path_array, SubPath, start_path_array->len - 1);
- if (start_path)
- *path = *start_path;
- start_path = path;
- swfdec_path_init (&start_path->path);
- start_path->x_start = start_x;
- start_path->y_start = start_y;
- end_path = swfdec_morph_shape_do_change (end_bits, start_path, morph, end_path_array, end_path, &end_x, &end_y);
- continue;
- }
- switch (start_type) {
- case SWFDEC_SHAPE_TYPE_CHANGE:
- start_path = swfdec_shape_parse_change (s, shape, start_path_array, start_path, &start_x, &start_y,
- swfdec_pattern_parse_morph, swfdec_stroke_parse_morph);
- end_path = swfdec_morph_shape_do_change (end_bits, start_path, morph, end_path_array, end_path, &end_x, &end_y);
- break;
- case SWFDEC_SHAPE_TYPE_LINE:
- if (end_type == SWFDEC_SHAPE_TYPE_LINE) {
- swfdec_shape_parse_line (start_bits, start_path, &start_x, &start_y, FALSE);
- swfdec_shape_parse_line (end_bits, end_path, &end_x, &end_y, FALSE);
- } else if (end_type == SWFDEC_SHAPE_TYPE_CURVE) {
- swfdec_shape_parse_line (start_bits, start_path, &start_x, &start_y, TRUE);
- swfdec_shape_parse_curve (end_bits, end_path, &end_x, &end_y);
- } else {
- SWFDEC_ERROR ("edge type didn't match, wanted line or curve, but got %s",
- end_type ? "change" : "end");
- goto error;
- }
- break;
- case SWFDEC_SHAPE_TYPE_CURVE:
- swfdec_shape_parse_curve (start_bits, start_path, &start_x, &start_y);
- if (end_type == SWFDEC_SHAPE_TYPE_LINE) {
- swfdec_shape_parse_line (end_bits, end_path, &end_x, &end_y, TRUE);
- } else if (end_type == SWFDEC_SHAPE_TYPE_CURVE) {
- swfdec_shape_parse_curve (end_bits, end_path, &end_x, &end_y);
- } else {
- SWFDEC_ERROR ("edge type didn't match, wanted line or curve, but got %s",
- end_type ? "change" : "end");
- goto error;
- }
- break;
- case SWFDEC_SHAPE_TYPE_END:
- default:
- g_assert_not_reached ();
- break;
- }
- }
- if (start_path) {
- start_path->x_end = start_x;
- start_path->y_end = start_y;
- }
- if (end_path) {
- end_path->x_end = end_x;
- end_path->y_end = end_y;
- }
- swfdec_bits_getbits (start_bits, 6);
- swfdec_bits_syncbits (start_bits);
- if (swfdec_bits_getbits (end_bits, 6) != 0) {
- SWFDEC_ERROR ("end shapes are not finished when start shapes are");
- }
- swfdec_bits_syncbits (end_bits);
-
-error:
- /* FIXME: there's probably a problem if start and end paths get accumulated in
- * different ways, this could lead to the morphs not looking like they should.
- * Need a good testcase for this first though.
- * FIXME: Also, due to error handling, there needs to be syncing of code paths
- */
- tmp = shape->vecs;
- shape->vecs = morph->end_vecs;
- swfdec_shape_initialize_from_sub_paths (shape, end_path_array);
- morph->end_vecs = shape->vecs;
- shape->vecs = tmp;
- swfdec_shape_initialize_from_sub_paths (shape, start_path_array);
- g_assert (morph->end_vecs->len == shape->vecs->len);
-}
-#endif
-
-#if 0
- SwfdecBits end_bits;
- SwfdecBits *bits = &s->b;
- SwfdecMorphShape *morph;
- guint offset;
- int id;
- id = swfdec_bits_get_u16 (bits);
-
- morph = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_MORPH_SHAPE);
- if (!morph)
- return SWFDEC_STATUS_OK;
-
- SWFDEC_INFO ("id=%d", id);
-
- swfdec_bits_get_rect (bits, &SWFDEC_GRAPHIC (morph)->extents);
- swfdec_bits_get_rect (bits, &morph->end_extents);
- offset = swfdec_bits_get_u32 (bits);
- end_bits = *bits;
- if (swfdec_bits_skip_bytes (&end_bits, offset) != offset) {
- SWFDEC_ERROR ("wrong offset in DefineMorphShape");
- return SWFDEC_STATUS_OK;
- }
- bits->end = end_bits.ptr;
-
- swfdec_shape_add_styles (s, SWFDEC_SHAPE (morph),
- swfdec_pattern_parse_morph, swfdec_stroke_parse_morph);
-
- morph->n_fill_bits = swfdec_bits_getbits (&end_bits, 4);
- morph->n_line_bits = swfdec_bits_getbits (&end_bits, 4);
- SWFDEC_LOG ("%u fill bits, %u line bits in end shape", morph->n_fill_bits, morph->n_line_bits);
-
- swfdec_morph_shape_get_recs (s, morph, &end_bits);
- if (swfdec_bits_left (&s->b)) {
- SWFDEC_WARNING ("early finish when parsing start shapes: %u bytes",
- swfdec_bits_left (&s->b));
- }
-
- s->b = end_bits;
-
- return SWFDEC_STATUS_OK;
-}
-#endif
diff --git a/libswfdec/swfdec_shape.h b/libswfdec/swfdec_shape.h
deleted file mode 100644
index 312dc9f..0000000
--- a/libswfdec/swfdec_shape.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_SHAPE_H_
-#define _SWFDEC_SHAPE_H_
-
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_color.h>
-#include <libswfdec/swfdec_bits.h>
-#include <libswfdec/swfdec_graphic.h>
-#include <libswfdec/swfdec_pattern.h>
-#include <libswfdec/swfdec_stroke.h>
-#include <libswfdec/swfdec_swf_decoder.h>
-
-G_BEGIN_DECLS
-
-//typedef struct _SwfdecShape SwfdecShape;
-typedef struct _SwfdecShapeClass SwfdecShapeClass;
-
-#define SWFDEC_TYPE_SHAPE (swfdec_shape_get_type())
-#define SWFDEC_IS_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SHAPE))
-#define SWFDEC_IS_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SHAPE))
-#define SWFDEC_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SHAPE, SwfdecShape))
-#define SWFDEC_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SHAPE, SwfdecShapeClass))
-
-struct _SwfdecShape {
- SwfdecGraphic graphic;
-
- GSList * draws; /* drawing operations - first drawn first */
-};
-
-struct _SwfdecShapeClass
-{
- SwfdecGraphicClass graphic_class;
-};
-
-GType swfdec_shape_get_type (void);
-
-int tag_define_shape (SwfdecSwfDecoder * s, guint tag);
-int tag_define_shape_3 (SwfdecSwfDecoder * s, guint tag);
-int tag_define_shape_4 (SwfdecSwfDecoder * s, guint tag);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_shape_parser.c b/libswfdec/swfdec_shape_parser.c
deleted file mode 100644
index d521a9c..0000000
--- a/libswfdec/swfdec_shape_parser.c
+++ /dev/null
@@ -1,675 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_shape_parser.h"
-#include "swfdec_debug.h"
-#include "swfdec_path.h"
-#include "swfdec_stroke.h"
-
-/*** PATH CONSTRUCTION ***/
-
-typedef enum {
- SWFDEC_SHAPE_TYPE_END = 0,
- SWFDEC_SHAPE_TYPE_CHANGE,
- SWFDEC_SHAPE_TYPE_LINE,
- SWFDEC_SHAPE_TYPE_CURVE
-} SwfdecShapeType;
-
-static SwfdecShapeType
-swfdec_shape_peek_type (SwfdecBits *bits)
-{
- guint ret = swfdec_bits_peekbits (bits, 6);
-
- if (ret == 0)
- return SWFDEC_SHAPE_TYPE_END;
- if ((ret & 0x20) == 0)
- return SWFDEC_SHAPE_TYPE_CHANGE;
- if ((ret & 0x10) == 0)
- return SWFDEC_SHAPE_TYPE_CURVE;
- return SWFDEC_SHAPE_TYPE_LINE;
-}
-
-typedef struct {
- int x_start, y_start;
- int x_end, y_end;
- cairo_path_t path;
-} SwfdecSubPath;
-
-static gboolean
-swfdec_sub_path_match (SwfdecSubPath *from, SwfdecSubPath *to)
-{
- return from->x_end == to->x_start && from->y_end == to->y_start;
-}
-
-typedef struct {
- SwfdecDraw * draw; /* drawing operation that should take the subpaths or NULL on parsing error */
- GSList * subpaths; /* indexes into SubPath array */
-} SwfdecStyle;
-
-struct _SwfdecShapeParser {
- /* state */
- GSList * draws; /* completely accumulated drawing commands */
- SwfdecParseDrawFunc parse_fill; /* function to call to parse a fill style */
- SwfdecParseDrawFunc parse_line; /* function to call to parse a line style */
- gpointer data; /* data to pass to parse functions */
- /* used while parsing */
- GArray * fillstyles; /* SwfdecStyle objects */
- GArray * linestyles; /* SwfdecStyle objects */
- GArray * subpaths; /* SwfdecSubPath partial paths */
- guint fill0style;
- guint fill1style;
- guint linestyle;
- guint n_fill_bits;
- guint n_line_bits;
- /* for morph styles */
- GArray * subpaths2; /* SwfdecSubPath partial paths */
- guint fill0style2;
- guint fill1style2;
- guint linestyle2;
- guint n_fill_bits2;
- guint n_line_bits2;
-};
-
-static void
-swfdec_shape_parser_new_styles (SwfdecShapeParser *parser, SwfdecBits *bits)
-{
- guint i, n_fill_styles, n_line_styles;
-
- swfdec_bits_syncbits (bits);
- if (parser->parse_fill) {
- n_fill_styles = swfdec_bits_get_u8 (bits);
- if (n_fill_styles == 0xff) {
- n_fill_styles = swfdec_bits_get_u16 (bits);
- }
- SWFDEC_LOG (" n_fill_styles %d", n_fill_styles);
- g_array_set_size (parser->fillstyles, n_fill_styles);
- for (i = 0; i < n_fill_styles && swfdec_bits_left (bits); i++) {
- g_array_index (parser->fillstyles, SwfdecStyle, i).draw =
- parser->parse_fill (bits, parser->data);
- }
-
- n_line_styles = swfdec_bits_get_u8 (bits);
- if (n_line_styles == 0xff) {
- n_line_styles = swfdec_bits_get_u16 (bits);
- }
- SWFDEC_LOG (" n_line_styles %d", n_line_styles);
- g_array_set_size (parser->linestyles, n_line_styles);
- for (i = 0; i < n_line_styles && swfdec_bits_left (bits); i++) {
- g_array_index (parser->linestyles, SwfdecStyle, i).draw =
- parser->parse_line (bits, parser->data);
- }
- } else {
- /* This is the magic part for DefineFont */
- g_array_set_size (parser->fillstyles, 1);
- g_array_index (parser->fillstyles, SwfdecStyle, 0).draw =
- SWFDEC_DRAW (swfdec_pattern_new_color (0xFFFFFFFF));
- }
- parser->n_fill_bits = swfdec_bits_getbits (bits, 4);
- parser->n_line_bits = swfdec_bits_getbits (bits, 4);
-}
-
-
-SwfdecShapeParser *
-swfdec_shape_parser_new (SwfdecParseDrawFunc parse_fill,
- SwfdecParseDrawFunc parse_line, gpointer data)
-{
- SwfdecShapeParser *list;
-
- list = g_slice_new0 (SwfdecShapeParser);
- list->parse_fill = parse_fill;
- list->parse_line = parse_line;
- list->data = data;
- list->fillstyles = g_array_new (FALSE, TRUE, sizeof (SwfdecStyle));
- list->linestyles = g_array_new (FALSE, TRUE, sizeof (SwfdecStyle));
- list->subpaths = g_array_new (FALSE, TRUE, sizeof (SwfdecSubPath));
- list->subpaths2 = g_array_new (FALSE, TRUE, sizeof (SwfdecSubPath));
-
- return list;
-}
-
-static inline void
-swfdec_shape_parser_clear_one (GArray *array)
-{
- guint i;
-
- for (i = 0; i < array->len; i++) {
- SwfdecStyle *style = &g_array_index (array, SwfdecStyle, i);
- if (style->draw)
- g_object_unref (style->draw);
- g_slist_free (style->subpaths);
- }
- g_array_set_size (array, 0);
-}
-
-static void
-swfdec_shape_parser_clear (SwfdecShapeParser *list)
-{
- guint i;
-
- swfdec_shape_parser_clear_one (list->fillstyles);
- swfdec_shape_parser_clear_one (list->linestyles);
-
- for (i = 0; i < list->subpaths->len; i++) {
- SwfdecSubPath *path = &g_array_index (list->subpaths, SwfdecSubPath, i);
- swfdec_path_reset (&path->path);
- }
- g_array_set_size (list->subpaths, 0);
- for (i = 0; i < list->subpaths2->len; i++) {
- SwfdecSubPath *path = &g_array_index (list->subpaths2, SwfdecSubPath, i);
- swfdec_path_reset (&path->path);
- }
- g_array_set_size (list->subpaths2, 0);
-}
-
-GSList *
-swfdec_shape_parser_reset (SwfdecShapeParser *parser)
-{
- GSList *draws = parser->draws;
-
- parser->draws = NULL;
- return draws;
-}
-
-GSList *
-swfdec_shape_parser_free (SwfdecShapeParser *parser)
-{
- GSList *draws = parser->draws;
-
- swfdec_shape_parser_clear (parser);
- g_array_free (parser->fillstyles, TRUE);
- g_array_free (parser->linestyles, TRUE);
- g_array_free (parser->subpaths, TRUE);
- g_array_free (parser->subpaths2, TRUE);
- g_slice_free (SwfdecShapeParser, parser);
-
- draws = g_slist_reverse (draws);
- return draws;
-}
-
-/* NB: assumes all fill paths are closed */
-static void
-swfdec_style_finish (SwfdecStyle *style, SwfdecSubPath *paths, SwfdecSubPath *paths2, gboolean line)
-{
- GSList *walk;
-
- /* checked before calling this function */
- g_assert (style->draw);
-
- /* accumulate paths one by one */
- while (style->subpaths) {
- SwfdecSubPath *start, *last;
- SwfdecSubPath *start2 = NULL, *last2 = NULL;
-
- last = start = &paths[GPOINTER_TO_UINT (style->subpaths->data)];
- swfdec_path_move_to (&style->draw->path, start->x_start, start->y_start);
- swfdec_path_append (&style->draw->path, &start->path);
- if (paths2) {
- last2 = start2 = &paths2[GPOINTER_TO_UINT (style->subpaths->data)];
- swfdec_path_move_to (&style->draw->end_path, start2->x_start, start2->y_start);
- swfdec_path_append (&style->draw->end_path, &start2->path);
- }
- style->subpaths = g_slist_delete_link (style->subpaths, style->subpaths);
- while (!swfdec_sub_path_match (last, start) ||
- (paths2 != NULL && !swfdec_sub_path_match (last2, start2))) {
- for (walk = style->subpaths; walk; walk = walk->next) {
- SwfdecSubPath *cur = &paths[GPOINTER_TO_UINT (walk->data)];
- if (swfdec_sub_path_match (last, cur)) {
- if (paths2) {
- SwfdecSubPath *cur2 = &paths2[GPOINTER_TO_UINT (walk->data)];
- if (!swfdec_sub_path_match (last2, cur2))
- continue;
- swfdec_path_append (&style->draw->end_path, &cur2->path);
- last2 = cur2;
- }
- swfdec_path_append (&style->draw->path, &cur->path);
- last = cur;
- break;
- }
- }
- if (walk) {
- style->subpaths = g_slist_delete_link (style->subpaths, walk);
- } else {
- if (!line) {
- SWFDEC_ERROR ("fill path not closed");
- }
- break;
- }
- }
- }
- swfdec_draw_recompute (style->draw);
-}
-
-/* merge subpaths into draws, then reset */
-static void
-swfdec_shape_parser_finish (SwfdecShapeParser *parser)
-{
- guint i;
- for (i = 0; i < parser->fillstyles->len; i++) {
- SwfdecStyle *style = &g_array_index (parser->fillstyles, SwfdecStyle, i);
- if (style->draw == NULL)
- continue;
- if (style->subpaths) {
- swfdec_style_finish (style, (SwfdecSubPath *) (void *) parser->subpaths->data,
- parser->subpaths2->len ? (SwfdecSubPath *) (void *) parser->subpaths2->data : NULL, FALSE);
- parser->draws = g_slist_prepend (parser->draws, g_object_ref (style->draw));
- } else {
- SWFDEC_INFO ("fillstyle %u has no path", i);
- }
- }
- for (i = 0; i < parser->linestyles->len; i++) {
- SwfdecStyle *style = &g_array_index (parser->linestyles, SwfdecStyle, i);
- if (style->draw == NULL)
- continue;
- if (style->subpaths) {
- swfdec_style_finish (style, (SwfdecSubPath *) (void *) parser->subpaths->data,
- parser->subpaths2->len ? (SwfdecSubPath *) (void *) parser->subpaths2->data : NULL, TRUE);
- parser->draws = g_slist_prepend (parser->draws, g_object_ref (style->draw));
- } else {
- SWFDEC_WARNING ("linestyle %u has no path", i);
- }
- }
- swfdec_shape_parser_clear (parser);
-}
-
-static void
-swfdec_shape_parser_end_path (SwfdecShapeParser *parser, SwfdecSubPath *path1, SwfdecSubPath *path2,
- int x1, int y1, int x2, int y2)
-{
- if (path1 == NULL)
- return;
- if (path1->path.num_data == 0) {
- SWFDEC_INFO ("ignoring empty path");
- return;
- }
-
- path1->x_end = x1;
- path1->y_end = y1;
-
- if (path2) {
- path2->x_end = x2;
- path2->y_end = y2;
- /* check our assumptions about morph styles */
- if ((parser->fill0style != parser->fill0style2 &&
- parser->fill0style != parser->fill1style2) ||
- (parser->fill1style != parser->fill0style2 &&
- parser->fill1style != parser->fill1style2)) {
- SWFDEC_ERROR ("fillstyle assumptions don't hold for %u %u vs %u %u",
- parser->fill0style, parser->fill1style, parser->fill0style2,
- parser->fill1style2);
- return;
- }
- if (parser->linestyle != parser->linestyle2) {
- SWFDEC_ERROR ("linestyle change from %u to %u", parser->linestyle,
- parser->linestyle2);
- return;
- }
- }
-
- /* add the path to their styles */
- if (parser->fill0style) {
- if (parser->fill0style > parser->fillstyles->len) {
- SWFDEC_ERROR ("fillstyle too big (%u > %u)", parser->fill0style,
- parser->fillstyles->len);
- } else {
- SwfdecStyle *style = &g_array_index (parser->fillstyles,
- SwfdecStyle, parser->fill0style - 1);
- style->subpaths = g_slist_prepend (style->subpaths,
- GUINT_TO_POINTER (parser->subpaths->len - 1));
- }
- }
- if (parser->fill1style) {
- if (parser->fill1style > parser->fillstyles->len) {
- SWFDEC_ERROR ("fillstyle too big (%u > %u)", parser->fill1style,
- parser->fillstyles->len);
- } else {
- SwfdecStyle *style = &g_array_index (parser->fillstyles,
- SwfdecStyle, parser->fill1style - 1);
-
- if (swfdec_sub_path_match (path1, path1) &&
- (path2 == NULL || swfdec_sub_path_match (path2, path2))) {
- style->subpaths = g_slist_prepend (style->subpaths,
- GUINT_TO_POINTER (parser->subpaths->len - 1));
- } else {
- SwfdecSubPath reverse;
- SWFDEC_LOG ("reversing path from %d %d to %d %d", path1->x_start, path1->y_start,
- path1->x_end, path1->y_end);
- reverse.x_start = path1->x_end;
- reverse.y_start = path1->y_end;
- reverse.x_end = path1->x_start;
- reverse.y_end = path1->y_start;
- swfdec_path_init (&reverse.path);
- swfdec_path_append_reverse (&reverse.path, &path1->path, reverse.x_end, reverse.y_end);
- style->subpaths = g_slist_prepend (style->subpaths,
- GUINT_TO_POINTER (parser->subpaths->len));
- g_array_append_val (parser->subpaths, reverse);
- if (path2) {
- reverse.x_start = path2->x_end;
- reverse.y_start = path2->y_end;
- reverse.x_end = path2->x_start;
- reverse.y_end = path2->y_start;
- swfdec_path_init (&reverse.path);
- swfdec_path_append_reverse (&reverse.path, &path2->path, reverse.x_end, reverse.y_end);
- g_array_append_val (parser->subpaths2, reverse);
- }
- }
- }
- }
- if (parser->linestyle) {
- if (parser->linestyle > parser->linestyles->len) {
- SWFDEC_ERROR ("linestyle too big (%u > %u)", parser->linestyle,
- parser->linestyles->len);
- } else {
- SwfdecStyle *style = &g_array_index (parser->linestyles,
- SwfdecStyle, parser->linestyle - 1);
- style->subpaths = g_slist_prepend (style->subpaths,
- GUINT_TO_POINTER (parser->subpaths->len - 1));
- }
- }
-}
-
-static SwfdecSubPath *
-swfdec_sub_path_create (GArray *array, int x, int y)
-{
- SwfdecSubPath *path;
-
- g_array_set_size (array, array->len + 1);
- path = &g_array_index (array, SwfdecSubPath, array->len - 1);
- swfdec_path_init (&path->path);
- path->x_start = x;
- path->y_start = y;
-
- return path;
-}
-
-static SwfdecSubPath *
-swfdec_shape_parser_parse_change (SwfdecShapeParser *parser, SwfdecBits *bits, int *x, int *y)
-{
- int state_new_styles, state_line_styles, state_fill_styles1, state_fill_styles0, state_moveto;
- SwfdecSubPath *path;
-
- if (swfdec_bits_getbit (bits) != 0) {
- g_assert_not_reached ();
- }
-
- state_new_styles = swfdec_bits_getbit (bits);
- state_line_styles = swfdec_bits_getbit (bits);
- state_fill_styles1 = swfdec_bits_getbit (bits);
- state_fill_styles0 = swfdec_bits_getbit (bits);
- state_moveto = swfdec_bits_getbit (bits);
-
- if (state_moveto) {
- int n_bits = swfdec_bits_getbits (bits, 5);
- *x = swfdec_bits_getsbits (bits, n_bits);
- *y = swfdec_bits_getsbits (bits, n_bits);
-
- SWFDEC_LOG (" moveto %d,%d", *x, *y);
- }
- if (state_fill_styles0) {
- parser->fill0style = swfdec_bits_getbits (bits, parser->n_fill_bits);
- SWFDEC_LOG (" * fill0style = %d", parser->fill0style);
- } else {
- SWFDEC_LOG (" * not changing fill0style");
- }
- if (state_fill_styles1) {
- parser->fill1style = swfdec_bits_getbits (bits, parser->n_fill_bits);
- SWFDEC_LOG (" * fill1style = %d", parser->fill1style);
- } else {
- SWFDEC_LOG (" * not changing fill1style");
- }
- if (state_line_styles) {
- parser->linestyle = swfdec_bits_getbits (bits, parser->n_line_bits);
- SWFDEC_LOG (" * linestyle = %d", parser->linestyle);
- } else {
- SWFDEC_LOG (" * not changing linestyle");
- }
- if (state_new_styles) {
- SWFDEC_LOG (" * new styles");
- swfdec_shape_parser_finish (parser);
- swfdec_shape_parser_new_styles (parser, bits);
- }
- path = swfdec_sub_path_create (parser->subpaths, *x, *y);
- return path;
-}
-
-static void
-swfdec_shape_parser_parse_curve (SwfdecBits *bits, SwfdecSubPath *path,
- int *x, int *y)
-{
- int n_bits;
- int cur_x, cur_y;
- int control_x, control_y;
-
- if (swfdec_bits_getbits (bits, 2) != 2) {
- g_assert_not_reached ();
- }
-
- n_bits = swfdec_bits_getbits (bits, 4) + 2;
-
- cur_x = *x;
- cur_y = *y;
-
- control_x = cur_x + swfdec_bits_getsbits (bits, n_bits);
- control_y = cur_y + swfdec_bits_getsbits (bits, n_bits);
- SWFDEC_LOG (" control %d,%d", control_x, control_y);
-
- *x = control_x + swfdec_bits_getsbits (bits, n_bits);
- *y = control_y + swfdec_bits_getsbits (bits, n_bits);
- SWFDEC_LOG (" anchor %d,%d", *x, *y);
- if (path) {
- swfdec_path_curve_to (&path->path,
- cur_x, cur_y,
- control_x, control_y,
- *x, *y);
- } else {
- SWFDEC_ERROR ("no path to curve in");
- }
-}
-
-static void
-swfdec_shape_parser_parse_line (SwfdecBits *bits, SwfdecSubPath *path,
- int *x, int *y, gboolean add_as_curve)
-{
- int n_bits;
- int general_line_flag;
- int cur_x, cur_y;
-
- if (swfdec_bits_getbits (bits, 2) != 3) {
- g_assert_not_reached ();
- }
-
- cur_x = *x;
- cur_y = *y;
- n_bits = swfdec_bits_getbits (bits, 4) + 2;
- general_line_flag = swfdec_bits_getbit (bits);
- if (general_line_flag == 1) {
- *x += swfdec_bits_getsbits (bits, n_bits);
- *y += swfdec_bits_getsbits (bits, n_bits);
- } else {
- int vert_line_flag = swfdec_bits_getbit (bits);
- if (vert_line_flag == 0) {
- *x += swfdec_bits_getsbits (bits, n_bits);
- } else {
- *y += swfdec_bits_getsbits (bits, n_bits);
- }
- }
- SWFDEC_LOG (" line to %d,%d", *x, *y);
- if (path) {
- if (add_as_curve)
- swfdec_path_curve_to (&path->path, cur_x, cur_y,
- (cur_x + *x) / 2, (cur_y + *y) / 2, *x, *y);
- else
- swfdec_path_line_to (&path->path, *x, *y);
- } else {
- SWFDEC_ERROR ("no path to line in");
- }
-}
-
-void
-swfdec_shape_parser_parse (SwfdecShapeParser *parser, SwfdecBits *bits)
-{
- int x = 0, y = 0;
- SwfdecSubPath *path = NULL;
- SwfdecShapeType type;
-
- swfdec_shape_parser_new_styles (parser, bits);
-
- while ((type = swfdec_shape_peek_type (bits))) {
- switch (type) {
- case SWFDEC_SHAPE_TYPE_CHANGE:
- swfdec_shape_parser_end_path (parser, path, NULL, x, y, 0, 0);
- path = swfdec_shape_parser_parse_change (parser, bits, &x, &y);
- break;
- case SWFDEC_SHAPE_TYPE_LINE:
- swfdec_shape_parser_parse_line (bits, path, &x, &y, FALSE);
- break;
- case SWFDEC_SHAPE_TYPE_CURVE:
- swfdec_shape_parser_parse_curve (bits, path, &x, &y);
- break;
- case SWFDEC_SHAPE_TYPE_END:
- default:
- g_assert_not_reached ();
- break;
- }
- }
- swfdec_shape_parser_end_path (parser, path, NULL, x, y, 0, 0);
- swfdec_bits_getbits (bits, 6);
- swfdec_bits_syncbits (bits);
-
- swfdec_shape_parser_finish (parser);
-}
-
-static SwfdecSubPath *
-swfdec_shape_parser_parse_morph_change (SwfdecShapeParser *parser,
- SwfdecBits *bits, int *x, int *y)
-{
- SwfdecSubPath *path;
- int state_line_styles, state_fill_styles1, state_fill_styles0, state_moveto;
-
- if (swfdec_bits_getbit (bits) != 0) {
- g_assert_not_reached ();
- }
- if (swfdec_bits_getbit (bits)) {
- SWFDEC_ERROR ("new styles aren't allowed in end edges, ignoring");
- }
- state_line_styles = swfdec_bits_getbit (bits);
- state_fill_styles1 = swfdec_bits_getbit (bits);
- state_fill_styles0 = swfdec_bits_getbit (bits);
- state_moveto = swfdec_bits_getbit (bits);
- if (state_moveto) {
- int n_bits = swfdec_bits_getbits (bits, 5);
- *x = swfdec_bits_getsbits (bits, n_bits);
- *y = swfdec_bits_getsbits (bits, n_bits);
-
- SWFDEC_LOG (" moveto %d,%d", *x, *y);
- }
- path = swfdec_sub_path_create (parser->subpaths2, *x, *y);
- if (state_fill_styles0) {
- parser->fill0style2 = swfdec_bits_getbits (bits, parser->n_fill_bits2);
- }
- if (state_fill_styles1) {
- parser->fill1style2 = swfdec_bits_getbits (bits, parser->n_fill_bits2);
- }
- if (state_line_styles) {
- parser->linestyle2 = swfdec_bits_getbits (bits, parser->n_line_bits2);
- }
-
- return path;
-}
-
-void
-swfdec_shape_parser_parse_morph (SwfdecShapeParser *parser, SwfdecBits *bits1, SwfdecBits *bits2)
-{
- int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
- SwfdecSubPath *path1 = NULL, *path2 = NULL;
- SwfdecShapeType type1, type2;
-
- swfdec_shape_parser_new_styles (parser, bits1);
- parser->n_fill_bits2 = swfdec_bits_getbits (bits2, 4);
- parser->n_line_bits2 = swfdec_bits_getbits (bits2, 4);
- parser->fill0style2 = parser->fill0style;
- parser->fill1style2 = parser->fill1style;
- parser->linestyle2 = parser->linestyle;
- SWFDEC_LOG ("%u fill bits, %u line bits in end shape", parser->n_fill_bits2, parser->n_line_bits2);
-
- while ((type1 = swfdec_shape_peek_type (bits1))) {
- type2 = swfdec_shape_peek_type (bits2);
- if (type2 == SWFDEC_SHAPE_TYPE_CHANGE || type1 == SWFDEC_SHAPE_TYPE_CHANGE) {
- swfdec_shape_parser_end_path (parser, path1, path2, x1, y1, x2, y2);
- if (type1 == SWFDEC_SHAPE_TYPE_CHANGE) {
- path1 = swfdec_shape_parser_parse_change (parser, bits1, &x1, &y1);
- parser->fill0style2 = parser->fill0style;
- parser->fill1style2 = parser->fill1style;
- parser->linestyle2 = parser->linestyle;
- } else {
- path1 = swfdec_sub_path_create (parser->subpaths, x1, y1);
- }
- if (type2 == SWFDEC_SHAPE_TYPE_CHANGE) {
- path2 = swfdec_shape_parser_parse_morph_change (parser, bits2, &x2, &y2);
- } else {
- path2 = swfdec_sub_path_create (parser->subpaths2, x2, y2);
- }
- continue;
- }
- switch (type2) {
- case SWFDEC_SHAPE_TYPE_LINE:
- swfdec_shape_parser_parse_line (bits2, path2, &x2, &y2, type1 != SWFDEC_SHAPE_TYPE_LINE);
- break;
- case SWFDEC_SHAPE_TYPE_CURVE:
- swfdec_shape_parser_parse_curve (bits2, path2, &x2, &y2);
- break;
- case SWFDEC_SHAPE_TYPE_END:
- SWFDEC_ERROR ("morph shape ends too early, aborting");
- goto out;
- case SWFDEC_SHAPE_TYPE_CHANGE:
- default:
- g_assert_not_reached ();
- break;
- }
- switch (type1) {
- case SWFDEC_SHAPE_TYPE_LINE:
- swfdec_shape_parser_parse_line (bits1, path1, &x1, &y1, type2 != SWFDEC_SHAPE_TYPE_LINE);
- break;
- case SWFDEC_SHAPE_TYPE_CURVE:
- swfdec_shape_parser_parse_curve (bits1, path1, &x1, &y1);
- break;
- case SWFDEC_SHAPE_TYPE_CHANGE:
- case SWFDEC_SHAPE_TYPE_END:
- default:
- g_assert_not_reached ();
- break;
- }
- }
-out:
- swfdec_shape_parser_end_path (parser, path1, path2, x1, y1, x2, y2);
- swfdec_bits_getbits (bits1, 6);
- swfdec_bits_syncbits (bits1);
- if (swfdec_bits_getbits (bits2, 6) != 0) {
- SWFDEC_ERROR ("end shapes are not finished when start shapes are");
- }
- swfdec_bits_syncbits (bits2);
-
- swfdec_shape_parser_finish (parser);
-}
-
diff --git a/libswfdec/swfdec_shape_parser.h b/libswfdec/swfdec_shape_parser.h
deleted file mode 100644
index 9dccbf0..0000000
--- a/libswfdec/swfdec_shape_parser.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_SHAPE_PARSER_H_
-#define _SWFDEC_SHAPE_PARSER_H_
-
-#include <libswfdec/swfdec_bits.h>
-#include <libswfdec/swfdec_draw.h>
-
-G_BEGIN_DECLS
-
-
-typedef struct _SwfdecShapeParser SwfdecShapeParser;
-typedef SwfdecDraw * (* SwfdecParseDrawFunc) (SwfdecBits *bits, gpointer *data);
-
-SwfdecShapeParser * swfdec_shape_parser_new (SwfdecParseDrawFunc parse_fill,
- SwfdecParseDrawFunc parse_line,
- gpointer data);
-GSList * swfdec_shape_parser_reset (SwfdecShapeParser * parser);
-GSList * swfdec_shape_parser_free (SwfdecShapeParser * parser);
-
-void swfdec_shape_parser_parse (SwfdecShapeParser * parser,
- SwfdecBits * bits);
-void swfdec_shape_parser_parse_morph (SwfdecShapeParser * parser,
- SwfdecBits * bits1,
- SwfdecBits * bits2);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_shared_object.c b/libswfdec/swfdec_shared_object.c
deleted file mode 100644
index 2377bd6..0000000
--- a/libswfdec/swfdec_shared_object.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-// normal
-SWFDEC_AS_NATIVE (2106, 0, swfdec_shared_object_connect)
-void
-swfdec_shared_object_connect (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("SharedObject.connect");
-}
-
-SWFDEC_AS_NATIVE (2106, 1, swfdec_shared_object_send)
-void
-swfdec_shared_object_send (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("SharedObject.send");
-}
-
-SWFDEC_AS_NATIVE (2106, 2, swfdec_shared_object_flush)
-void
-swfdec_shared_object_flush (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("SharedObject.flush");
-}
-
-SWFDEC_AS_NATIVE (2106, 3, swfdec_shared_object_close)
-void
-swfdec_shared_object_close (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("SharedObject.close");
-}
-
-SWFDEC_AS_NATIVE (2106, 4, swfdec_shared_object_getSize)
-void
-swfdec_shared_object_getSize (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("SharedObject.getSize");
-}
-
-SWFDEC_AS_NATIVE (2106, 5, swfdec_shared_object_setFps)
-void
-swfdec_shared_object_setFps (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("SharedObject.setFps");
-}
-
-SWFDEC_AS_NATIVE (2106, 6, swfdec_shared_object_clear)
-void
-swfdec_shared_object_clear (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("SharedObject.clear");
-}
diff --git a/libswfdec/swfdec_socket.c b/libswfdec/swfdec_socket.c
deleted file mode 100644
index 723050c..0000000
--- a/libswfdec/swfdec_socket.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/* Swfdec
- * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_socket.h"
-#include "swfdec_loader_internal.h"
-
-/*** GTK-DOC ***/
-
-/**
- * SECTION:SwfdecSocket
- * @title: SwfdecSocket
- * @short_description: object used for network connections
- *
- * SwfdecSockets are used to implement TCP streams. These are for example used
- * to implement RTMP support or the XMLSocket script class. Backends are
- * supposed to provide an implementation for this, as by default this class is
- * unimplemented. However, libswfdec-gtk or other convenience libraries provide
- * a socket implementation by default.
- *
- * The socket implementation used by a #SwfdecPlayer can be set with the
- * SwfdecPlayer:socket-type property.
- */
-
-/**
- * SwfdecSocket:
- *
- * This is the base object used for providing input. It is abstract, create a
- * subclass to provide your own socket implementation. All members are
- * considered private.
- */
-
-/**
- * SwfdecSocketClass:
- * @create: Create a new socket for the given hostname and port. This function
- * must return a new socket, returning %NULL is not allowed. If you
- * encounter an error, create a new socket and call
- * swfdec_stream_error() on it.
- * @send: Called to send data down the given socket. This function will only be
- * called when the socket is open. You get passed a reference to the
- * buffer, so it is your responsibility to call swfdec_buffer_unref() on
- * it when you are done with it.
- *
- * This is the socket class. When you create a subclass, you need to implement
- * the functions listed above.
- */
-
-/*** SWFDEC_SOCKET ***/
-
-G_DEFINE_ABSTRACT_TYPE (SwfdecSocket, swfdec_socket, SWFDEC_TYPE_STREAM)
-
-static void
-swfdec_socket_class_init (SwfdecSocketClass *klass)
-{
-}
-
-static void
-swfdec_socket_init (SwfdecSocket *socket)
-{
-}
-
-/**
- * swfdec_socket_send:
- * @sock: a #SwfdecSocket
- * @buffer: data to send to the stream
- *
- * Pushes the given @buffer down the stream.
- **/
-void
-swfdec_socket_send (SwfdecSocket *sock, SwfdecBuffer *buffer)
-{
- SwfdecSocketClass *klass;
-
- g_return_if_fail (SWFDEC_IS_SOCKET (sock));
- g_return_if_fail (buffer != NULL);
-
- klass = SWFDEC_SOCKET_GET_CLASS (sock);
- klass->send (sock, buffer);
-}
-
diff --git a/libswfdec/swfdec_socket.h b/libswfdec/swfdec_socket.h
deleted file mode 100644
index 7e062ca..0000000
--- a/libswfdec/swfdec_socket.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Swfdec
- * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_SOCKET_H_
-#define _SWFDEC_SOCKET_H_
-
-#include <glib-object.h>
-#include <libswfdec/swfdec_stream.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecSocket SwfdecSocket;
-typedef struct _SwfdecSocketClass SwfdecSocketClass;
-
-#define SWFDEC_TYPE_SOCKET (swfdec_socket_get_type())
-#define SWFDEC_IS_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SOCKET))
-#define SWFDEC_IS_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SOCKET))
-#define SWFDEC_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SOCKET, SwfdecSocket))
-#define SWFDEC_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SOCKET, SwfdecSocketClass))
-#define SWFDEC_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_SOCKET, SwfdecSocketClass))
-
-struct _SwfdecSocket
-{
- SwfdecStream stream;
-};
-
-struct _SwfdecSocketClass
-{
- SwfdecStreamClass stream_class;
-
- SwfdecSocket * (* create) (const char * hostname,
- guint port);
-
- void (* send) (SwfdecSocket * socket,
- SwfdecBuffer * buffer);
-};
-
-GType swfdec_socket_get_type (void);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_sound.c b/libswfdec/swfdec_sound.c
deleted file mode 100644
index cb1e97c..0000000
--- a/libswfdec/swfdec_sound.c
+++ /dev/null
@@ -1,558 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <string.h>
-
-#include "swfdec_audio_internal.h"
-#include "swfdec_sound.h"
-#include "swfdec_bits.h"
-#include "swfdec_buffer.h"
-#include "swfdec_button.h"
-#include "swfdec_debug.h"
-#include "swfdec_sprite.h"
-#include "swfdec_swf_decoder.h"
-
-G_DEFINE_TYPE (SwfdecSound, swfdec_sound, SWFDEC_TYPE_CACHED)
-
-static void
-swfdec_sound_unload (SwfdecCached *cached)
-{
- SwfdecSound * sound = SWFDEC_SOUND (cached);
-
- if (sound->decoded) {
- swfdec_buffer_unref (sound->decoded);
- sound->decoded = NULL;
- }
-}
-
-static void
-swfdec_sound_dispose (GObject *object)
-{
- SwfdecSound * sound = SWFDEC_SOUND (object);
-
- if (sound->encoded)
- swfdec_buffer_unref (sound->encoded);
-
- G_OBJECT_CLASS (swfdec_sound_parent_class)->dispose (object);
-}
-
-static void
-swfdec_sound_class_init (SwfdecSoundClass * g_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (g_class);
- SwfdecCachedClass *cached_class = SWFDEC_CACHED_CLASS (g_class);
-
- object_class->dispose = swfdec_sound_dispose;
-
- cached_class->unload = swfdec_sound_unload;
-}
-
-static void
-swfdec_sound_init (SwfdecSound * sound)
-{
-
-}
-
-int
-tag_func_sound_stream_block (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecSound *sound;
- SwfdecBuffer *chunk;
- int n_samples;
- int skip;
-
- sound = SWFDEC_SOUND (s->parse_sprite->frames[s->parse_sprite->parse_frame].sound_head);
-
- if (!sound) {
- SWFDEC_WARNING ("no streaming sound block");
- return SWFDEC_STATUS_OK;
- }
-
- n_samples = swfdec_bits_get_u16 (&s->b);
- if (sound->codec == SWFDEC_AUDIO_CODEC_MP3) {
- skip = swfdec_bits_get_s16 (&s->b);
- } else {
- skip = 0;
- }
- if (swfdec_bits_left (&s->b) == 0) {
- SWFDEC_DEBUG ("empty sound block n_samples=%d skip=%d", n_samples,
- skip);
- chunk = NULL;
- return SWFDEC_STATUS_OK;
- } else {
- chunk = swfdec_bits_get_buffer (&s->b, -1);
- if (chunk == NULL) {
- SWFDEC_ERROR ("empty sound chunk");
- return SWFDEC_STATUS_OK;
- }
- SWFDEC_LOG ("got a buffer with %u samples, %d skip and %"G_GSIZE_FORMAT" bytes mp3 data", n_samples, skip,
- chunk->length);
- /* use this to write out the stream data to stdout - nice way to get an mp3 file :) */
- //write (1, (void *) chunk->data, chunk->length);
- }
-
- swfdec_sprite_add_sound_chunk (s->parse_sprite, s->parse_sprite->parse_frame, chunk, skip, n_samples);
-
- return SWFDEC_STATUS_OK;
-}
-
-int
-tag_func_define_sound (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecBits *b = &s->b;
- int id;
- int n_samples;
- SwfdecSound *sound;
-
- id = swfdec_bits_get_u16 (b);
- sound = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_SOUND);
- if (!sound)
- return SWFDEC_STATUS_OK;
-
- sound->codec = swfdec_bits_getbits (b, 4);
- SWFDEC_LOG (" codec: %u", sound->codec);
- sound->format = swfdec_audio_format_parse (b);
- SWFDEC_LOG (" format: %s", swfdec_audio_format_to_string (sound->format));
- n_samples = swfdec_bits_get_u32 (b);
- sound->n_samples = n_samples;
-
- switch (sound->codec) {
- case 0:
- if (swfdec_audio_format_is_16bit (sound->format))
- SWFDEC_WARNING ("undefined endianness for s16 sound");
- /* just assume LE and hope it works (FIXME: want a switch for this?) */
- sound->codec = SWFDEC_AUDIO_CODEC_UNCOMPRESSED;
- /* fall through */
- case 3:
- sound->encoded = swfdec_bits_get_buffer (&s->b, -1);
- break;
- case 2:
- sound->skip = swfdec_bits_get_u16 (b);
- sound->encoded = swfdec_bits_get_buffer (&s->b, -1);
- break;
- case 1:
- case 5:
- case 6:
- sound->encoded = swfdec_bits_get_buffer (&s->b, -1);
- break;
- default:
- SWFDEC_WARNING ("unknown codec %d", sound->codec);
- }
- sound->n_samples *= swfdec_audio_format_get_granularity (sound->format);
-
- return SWFDEC_STATUS_OK;
-}
-
-SwfdecBuffer *
-swfdec_sound_get_decoded (SwfdecSound *sound, SwfdecAudioFormat *format)
-{
- gpointer decoder;
- SwfdecBuffer *tmp;
- SwfdecBufferQueue *queue;
- guint sample_bytes;
- guint n_samples;
- guint depth;
-
- g_return_val_if_fail (SWFDEC_IS_SOUND (sound), NULL);
- g_return_val_if_fail (format != NULL, NULL);
-
- if (sound->decoded) {
- swfdec_cached_use (SWFDEC_CACHED (sound));
- *format = sound->decoded_format;
- return sound->decoded;
- }
- if (sound->encoded == NULL)
- return NULL;
-
- decoder = swfdec_audio_decoder_new (sound->codec, sound->format);
- if (decoder == NULL)
- return NULL;
-
- swfdec_audio_decoder_push (decoder, sound->encoded);
- swfdec_audio_decoder_push (decoder, NULL);
- queue = swfdec_buffer_queue_new ();
- while ((tmp = swfdec_audio_decoder_pull (decoder))) {
- swfdec_buffer_queue_push (queue, tmp);
- }
- sound->decoded_format = swfdec_audio_decoder_get_format (decoder);
- swfdec_audio_decoder_free (decoder);
- depth = swfdec_buffer_queue_get_depth (queue);
- if (depth == 0) {
- SWFDEC_ERROR ("decoding didn't produce any data, bailing");
- return NULL;
- }
- swfdec_cached_load (SWFDEC_CACHED (sound), depth);
- tmp = swfdec_buffer_queue_pull (queue, depth);
- swfdec_buffer_queue_unref (queue);
-
- sample_bytes = swfdec_audio_format_get_bytes_per_sample (sound->decoded_format);
- n_samples = sound->n_samples / swfdec_audio_format_get_granularity (sound->decoded_format);
-
- SWFDEC_LOG ("after decoding, got %"G_GSIZE_FORMAT" samples, should get %u and skip %u",
- tmp->length / sample_bytes, n_samples, sound->skip);
- if (sound->skip) {
- SwfdecBuffer *tmp2 = swfdec_buffer_new_subbuffer (tmp, sound->skip * sample_bytes,
- tmp->length - sound->skip * sample_bytes);
- swfdec_buffer_unref (tmp);
- tmp = tmp2;
- }
- if (tmp->length > n_samples * sample_bytes) {
- SwfdecBuffer *tmp2 = swfdec_buffer_new_subbuffer (tmp, 0, n_samples * sample_bytes);
- SWFDEC_DEBUG ("%u samples in %u bytes should be available, but %"G_GSIZE_FORMAT" bytes are, cutting them off",
- n_samples, n_samples * sample_bytes, tmp->length);
- swfdec_buffer_unref (tmp);
- tmp = tmp2;
- } else if (tmp->length < n_samples * sample_bytes) {
- /* we handle this case in swfdec_sound_render */
- /* FIXME: this message is important when writing new codecs, so I made it a warning.
- * It's probably not worth more than INFO for the usual case though */
- SWFDEC_WARNING ("%u samples in %u bytes should be available, but only %"G_GSIZE_FORMAT" bytes are",
- n_samples, n_samples * sample_bytes, tmp->length);
- }
- /* only assign here, the decoding code checks this variable */
- sound->decoded = tmp;
-
- *format = sound->decoded_format;
- return sound->decoded;
-}
-
-int
-tag_func_sound_stream_head (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecBits *b = &s->b;
- SwfdecAudioFormat playback;
- guint playback_codec;
- int n_samples;
- int latency;
- SwfdecSound *sound;
-
- playback_codec = swfdec_bits_getbits (b, 4);
- /* we don't care about playback suggestions */
- playback = swfdec_audio_format_parse (b);
- SWFDEC_LOG (" suggested playback format: %s", swfdec_audio_format_to_string (playback));
-
- sound = g_object_new (SWFDEC_TYPE_SOUND, NULL);
- sound->codec = swfdec_bits_getbits (b, 4);
- sound->format = swfdec_audio_format_parse (b);
- n_samples = swfdec_bits_get_u16 (b);
- if (playback_codec != 0 && playback_codec != sound->codec) {
- SWFDEC_FIXME ("playback codec %u doesn't match sound codec %u",
- playback_codec, sound->codec);
- }
-
- if (s->parse_sprite->frames[s->parse_sprite->parse_frame].sound_head)
- g_object_unref (s->parse_sprite->frames[s->parse_sprite->parse_frame].sound_head);
- s->parse_sprite->frames[s->parse_sprite->parse_frame].sound_head = sound;
-
- switch (sound->codec) {
- case SWFDEC_AUDIO_CODEC_UNDEFINED:
- if (swfdec_audio_format_is_16bit (sound->format)) {
- SWFDEC_WARNING ("undefined endianness for s16 sound");
- /* just assume LE and hope it works (FIXME: want a switch for this?) */
- sound->codec = SWFDEC_AUDIO_CODEC_UNCOMPRESSED;
- }
- break;
- case SWFDEC_AUDIO_CODEC_MP3:
- /* latency seek */
- latency = swfdec_bits_get_s16 (b);
- break;
- case SWFDEC_AUDIO_CODEC_ADPCM:
- case SWFDEC_AUDIO_CODEC_UNCOMPRESSED:
- case SWFDEC_AUDIO_CODEC_NELLYMOSER_8KHZ:
- case SWFDEC_AUDIO_CODEC_NELLYMOSER:
- break;
- default:
- SWFDEC_WARNING ("unknown codec %d", sound->codec);
- sound->codec = SWFDEC_AUDIO_CODEC_UNDEFINED;
- }
-
- return SWFDEC_STATUS_OK;
-}
-
-void
-swfdec_sound_chunk_free (SwfdecSoundChunk *chunk)
-{
- g_return_if_fail (chunk != NULL);
-
- g_free (chunk->envelope);
- g_free (chunk);
-}
-
-SwfdecSoundChunk *
-swfdec_sound_parse_chunk (SwfdecSwfDecoder *s, SwfdecBits *b, int id)
-{
- int has_envelope;
- int has_loops;
- int has_out_point;
- int has_in_point;
- guint i, j;
- SwfdecSound *sound;
- SwfdecSoundChunk *chunk;
-
- sound = swfdec_swf_decoder_get_character (s, id);
- if (!SWFDEC_IS_SOUND (sound)) {
- SWFDEC_ERROR ("given id %d does not reference a sound object", id);
- return NULL;
- }
-
- chunk = g_new0 (SwfdecSoundChunk, 1);
- chunk->sound = sound;
- SWFDEC_DEBUG ("parsing sound chunk for sound %d", SWFDEC_CHARACTER (sound)->id);
-
- swfdec_bits_getbits (b, 2);
- chunk->stop = swfdec_bits_getbits (b, 1);
- chunk->no_restart = swfdec_bits_getbits (b, 1);
- has_envelope = swfdec_bits_getbits (b, 1);
- has_loops = swfdec_bits_getbits (b, 1);
- has_out_point = swfdec_bits_getbits (b, 1);
- has_in_point = swfdec_bits_getbits (b, 1);
- if (has_in_point) {
- chunk->start_sample = swfdec_bits_get_u32 (b);
- SWFDEC_LOG (" start_sample = %u", chunk->start_sample);
- } else {
- chunk->start_sample = 0;
- }
- if (has_out_point) {
- chunk->stop_sample = swfdec_bits_get_u32 (b);
- if (chunk->stop_sample == 0) {
- SWFDEC_FIXME ("stop sample == 0???");
- }
- SWFDEC_LOG (" stop_sample = %u", chunk->stop_sample);
- if (chunk->stop_sample <= chunk->start_sample) {
- SWFDEC_ERROR ("stopping before starting? (start sample %u, stop sample %u)",
- chunk->start_sample, chunk->stop_sample);
- chunk->stop_sample = 0;
- }
- } else {
- chunk->stop_sample = 0;
- }
- if (has_loops) {
- chunk->loop_count = swfdec_bits_get_u16 (b);
- if (chunk->loop_count == 0) {
- SWFDEC_ERROR ("loop_count 0 not allowed, setting to 1");
- chunk->loop_count = 1;
- }
- SWFDEC_LOG (" loop_count = %u", chunk->loop_count);
- } else {
- chunk->loop_count = 1;
- }
- if (has_envelope) {
- chunk->n_envelopes = swfdec_bits_get_u8 (b);
- chunk->envelope = g_new0 (SwfdecSoundEnvelope, chunk->n_envelopes);
- SWFDEC_LOG (" n_envelopes = %u", chunk->n_envelopes);
- }
-
- for (i = 0; i < chunk->n_envelopes && swfdec_bits_left (b); i++) {
- chunk->envelope[i].offset = swfdec_bits_get_u32 (b);
- if (i > 0 && chunk->envelope[i-1].offset > chunk->envelope[i].offset) {
- SWFDEC_ERROR ("unordered sound envelopes");
- chunk->envelope[i].offset = chunk->envelope[i-1].offset;
- }
-
- for (j = 0; j < 2; j++) {
- chunk->envelope[i].volume[j] = swfdec_bits_get_u16 (b);
- if (chunk->envelope[i].volume[j] > 32768) {
- SWFDEC_FIXME ("too big envelope volumes (%u > 32768) not handled correctly",
- chunk->envelope[i].volume[j]);
- chunk->envelope[i].volume[j] = 32768;
- }
- }
-
- SWFDEC_LOG (" envelope = %u { %u, %u }", chunk->envelope[i].offset,
- (guint) chunk->envelope[i].volume[0], (guint) chunk->envelope[i].volume[1]);
- }
-
- if (i < chunk->n_envelopes)
- SWFDEC_ERROR ("out of bits when reading sound envelopes");
-
- return chunk;
-}
-
-int
-tag_func_define_button_sound (SwfdecSwfDecoder * s, guint tag)
-{
- guint i;
- guint id;
- SwfdecButton *button;
-
- id = swfdec_bits_get_u16 (&s->b);
- button = (SwfdecButton *) swfdec_swf_decoder_get_character (s, id);
- if (!SWFDEC_IS_BUTTON (button)) {
- SWFDEC_ERROR ("id %u is not a button", id);
- return SWFDEC_STATUS_OK;
- }
- SWFDEC_LOG ("loading sound events for button %u", id);
- for (i = 0; i < 4; i++) {
- id = swfdec_bits_get_u16 (&s->b);
- if (id) {
- SWFDEC_LOG ("loading sound %u for button event %u", id, i);
- if (button->sounds[i]) {
- SWFDEC_ERROR ("need to delete previous sound for button %u's event %u",
- SWFDEC_CHARACTER (button)->id, i);
- swfdec_sound_chunk_free (button->sounds[i]);
- }
- button->sounds[i] = swfdec_sound_parse_chunk (s, &s->b, id);
- }
- }
-
- return SWFDEC_STATUS_OK;
-}
-
-/**
- * swfdec_sound_buffer_get_n_samples:
- * @buffer: data to examine
- * @format: format the data in @buffer is in
- *
- * Determines the number of samples inside @buffer that would be available if
- * it were to be rendered using the default Flash format, 44100Hz.
- *
- * Returns: Number of samples contained in @buffer when rendered
- **/
-guint
-swfdec_sound_buffer_get_n_samples (const SwfdecBuffer *buffer, SwfdecAudioFormat format)
-{
- g_return_val_if_fail (buffer != NULL, 0);
- g_return_val_if_fail (buffer->length % (2 * swfdec_audio_format_get_channels (format)) == 0, 0);
-
- return buffer->length / (2 * swfdec_audio_format_get_channels (format)) *
- swfdec_audio_format_get_granularity (format);
-}
-
-static void
-swfdec_sound_buffer_render_stereo (gint16 *dest, const gint16 *source, guint offset,
- guint n_samples, guint rate)
-{
- guint i, j;
-
- source += 2 * (offset / rate);
- offset %= rate;
-
- if (offset) {
- offset = MIN (rate - offset, n_samples);
- for (i = 0; i < offset; i++) {
- *dest++ = source[0];
- *dest++ = source[1];
- }
- source += 2;
- n_samples -= offset;
- }
- for (i = rate; i <= n_samples; i += rate) {
- for (j = 0; j < rate; j++) {
- *dest++ = source[0];
- *dest++ = source[1];
- }
- source += 2;
- }
- n_samples -= i - rate;
- g_assert (n_samples < rate);
- for (i = 0; i < n_samples; i++) {
- *dest++ = source[0];
- *dest++ = source[1];
- }
-}
-
-static void
-swfdec_sound_buffer_render_mono (gint16 *dest, const gint16 *source, guint offset,
- guint n_samples, guint rate)
-{
- guint i, j;
-
- source += (offset / rate);
- offset %= rate;
-
- if (offset) {
- offset = MIN (rate - offset, n_samples);
- for (i = 0; i < offset; i++) {
- *dest++ = *source;
- *dest++ = *source;
- }
- source++;
- n_samples -= offset;
- }
- for (i = rate; i <= n_samples; i += rate) {
- for (j = 0; j < rate; j++) {
- *dest++ = *source;
- *dest++ = *source;
- }
- source++;
- }
- n_samples -= i - rate;
- g_assert (n_samples < rate);
- for (i = 0; i < n_samples; i++) {
- *dest++ = *source;
- *dest++ = *source;
- }
-}
-
-/**
- * swfdec_sound_render_buffer:
- * @dest: target buffer to render to
- * @source: source data to render
- * @format: format of data in @source and @previous
- * @previous: previous buffer or NULL for none. This is necessary for
- * upsampling at buffer boundaries
- * @offset: offset in 44100Hz samples into @source
- * @n_samples: number of samples to render into @dest. If more data would be
- * rendered than is available in @source, 0 samples are used instead.
- *
- * Adds data from @source into @dest
- **/
-void
-swfdec_sound_buffer_render (gint16 *dest, const SwfdecBuffer *source,
- SwfdecAudioFormat format, const SwfdecBuffer *previous,
- guint offset, guint n_samples)
-{
- guint channels = swfdec_audio_format_get_channels (format);
- guint rate = swfdec_audio_format_get_granularity (format);
- guint width = swfdec_audio_format_is_16bit (format) ? 2 : 1;
- guint total_samples;
- gint16 *fixme = NULL;
-
- g_return_if_fail (dest != NULL);
- g_return_if_fail (source != NULL);
- g_return_if_fail (swfdec_sound_buffer_get_n_samples (source, format) > 0);
- g_return_if_fail (previous == NULL || swfdec_sound_buffer_get_n_samples (previous, format) > 0);
-
- total_samples = (source->length / channels / width) * rate;
- SWFDEC_LOG ("rendering [%u %u) - total: %u samples", offset, n_samples, total_samples);
- /* FIXME: warn about this? */
- n_samples = MIN (n_samples, total_samples - offset);
-
- if (width == 1) {
- guint i;
- /* FIXME: make this faster */
- fixme = g_try_malloc (source->length * 2);
- if (fixme == NULL)
- return;
- for (i = 0; i < source->length; i++) {
- fixme[i] = (((gint16) source->data[i]) << 8) - 32768;
- }
- }
- if (channels == 2) {
- swfdec_sound_buffer_render_stereo (dest, (const void *) source->data, offset, n_samples, rate);
- } else {
- swfdec_sound_buffer_render_mono (dest, (const void *) source->data, offset, n_samples, rate);
- }
- g_free (fixme);
-}
-
diff --git a/libswfdec/swfdec_sound.h b/libswfdec/swfdec_sound.h
deleted file mode 100644
index 75e917e..0000000
--- a/libswfdec/swfdec_sound.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_SOUND_H_
-#define _SWFDEC_SOUND_H_
-
-#include <libswfdec/swfdec_cached.h>
-#include <libswfdec/swfdec_codec_audio.h>
-#include <libswfdec/swfdec_swf_decoder.h>
-#include <libswfdec/swfdec_types.h>
-
-G_BEGIN_DECLS
-
-//typedef struct _SwfdecSoundChunk SwfdecSoundChunk;
-//typedef struct _SwfdecSound SwfdecSound;
-typedef struct _SwfdecSoundClass SwfdecSoundClass;
-typedef struct _SwfdecSoundEnvelope SwfdecSoundEnvelope;
-
-#define SWFDEC_TYPE_SOUND (swfdec_sound_get_type())
-#define SWFDEC_IS_SOUND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SOUND))
-#define SWFDEC_IS_SOUND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SOUND))
-#define SWFDEC_SOUND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SOUND, SwfdecSound))
-#define SWFDEC_SOUND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SOUND, SwfdecSoundClass))
-
-struct _SwfdecSoundEnvelope {
- guint offset; /* offset in frames */
- guint16 volume[2]; /* volume to use */
-};
-
-struct _SwfdecSoundChunk
-{
- SwfdecSound * sound; /* sound to play */
-
- int stop; /* stop the sample being played */
- int no_restart; /* don't restart if already playing */
-
- guint start_sample; /* sample at which to start playing */
- guint stop_sample; /* first sample to not play anymore or 0 for playing all */
- guint loop_count; /* amount of times this sample should be played back */
- guint n_envelopes; /* amount of points in the envelope */
- SwfdecSoundEnvelope * envelope; /* volume envelope or NULL if none */
-};
-
-struct _SwfdecSound
-{
- SwfdecCached cached;
-
- guint codec; /* codec in use */
- SwfdecAudioFormat format; /* channel/rate/width information for codec */
- guint n_samples; /* total number of samples when decoded to 44100kHz */
- guint skip; /* samples to skip at start */
- SwfdecBuffer * encoded; /* encoded data */
-
- SwfdecAudioFormat decoded_format; /* format of decoded data */
- SwfdecBuffer * decoded; /* decoded data */
-};
-
-struct _SwfdecSoundClass
-{
- SwfdecCachedClass cached_class;
-};
-
-GType swfdec_sound_get_type (void);
-
-int tag_func_define_sound (SwfdecSwfDecoder * s, guint tag);
-int tag_func_sound_stream_block (SwfdecSwfDecoder * s, guint tag);
-int tag_func_sound_stream_head (SwfdecSwfDecoder * s, guint tag);
-int tag_func_start_sound (SwfdecSwfDecoder * s, guint tag);
-int tag_func_define_button_sound (SwfdecSwfDecoder * s, guint tag);
-
-SwfdecBuffer * swfdec_sound_get_decoded (SwfdecSound * sound,
- SwfdecAudioFormat * format);
-void swfdec_sound_buffer_render (gint16 * dest,
- const SwfdecBuffer * source,
- SwfdecAudioFormat format,
- const SwfdecBuffer * previous,
- guint offset,
- guint n_samples);
-guint swfdec_sound_buffer_get_n_samples (const SwfdecBuffer * buffer,
- SwfdecAudioFormat format);
-
-SwfdecSoundChunk * swfdec_sound_parse_chunk (SwfdecSwfDecoder * s,
- SwfdecBits * bits,
- int id);
-void swfdec_sound_chunk_free (SwfdecSoundChunk * chunk);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_sound_object.c b/libswfdec/swfdec_sound_object.c
deleted file mode 100644
index 7a17761..0000000
--- a/libswfdec/swfdec_sound_object.c
+++ /dev/null
@@ -1,340 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-#include "swfdec_sound_object.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_native_function.h"
-#include "swfdec_as_object.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_audio_event.h"
-#include "swfdec_debug.h"
-#include "swfdec_internal.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_resource.h"
-
-/*** SwfdecSoundObject ***/
-
-G_DEFINE_TYPE (SwfdecSoundObject, swfdec_sound_object, SWFDEC_TYPE_AS_OBJECT)
-
-static void
-swfdec_sound_object_mark (SwfdecAsObject *object)
-{
- SwfdecSoundObject *sound = SWFDEC_SOUND_OBJECT (object);
-
- if (sound->target != NULL)
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (sound->target));
-
- SWFDEC_AS_OBJECT_CLASS (swfdec_sound_object_parent_class)->mark (object);
-}
-
-static void
-swfdec_sound_object_dispose (GObject *object)
-{
- SwfdecSoundObject *sound = SWFDEC_SOUND_OBJECT (object);
-
- if (sound->attached) {
- g_object_unref (sound->attached);
- sound->attached = NULL;
- }
-
- G_OBJECT_CLASS (swfdec_sound_object_parent_class)->dispose (object);
-}
-
-static void
-swfdec_sound_object_class_init (SwfdecSoundObjectClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
-
- object_class->dispose = swfdec_sound_object_dispose;
-
- asobject_class->mark = swfdec_sound_object_mark;
-}
-
-static void
-swfdec_sound_object_init (SwfdecSoundObject *sound)
-{
-}
-
-static SwfdecSound *
-swfdec_sound_object_get_sound (SwfdecSoundObject *sound, const char *name)
-{
- if (sound->target == NULL)
- return NULL;
-
- return swfdec_resource_get_export (sound->target->resource, name);
-}
-
-/*** AS CODE ***/
-
-SWFDEC_AS_NATIVE (500, 0, swfdec_sound_object_getPan)
-void
-swfdec_sound_object_getPan (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Sound.getPan");
-}
-
-SWFDEC_AS_NATIVE (500, 1, swfdec_sound_object_getTransform)
-void
-swfdec_sound_object_getTransform (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Sound.getTransform");
-}
-
-SWFDEC_AS_NATIVE (500, 2, swfdec_sound_object_getVolume)
-void
-swfdec_sound_object_getVolume (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Sound.getVolume");
-}
-
-SWFDEC_AS_NATIVE (500, 3, swfdec_sound_object_setPan)
-void
-swfdec_sound_object_setPan (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Sound.setPan");
-}
-
-SWFDEC_AS_NATIVE (500, 4, swfdec_sound_object_setTransform)
-void
-swfdec_sound_object_setTransform (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Sound.setTransform");
-}
-
-SWFDEC_AS_NATIVE (500, 5, swfdec_sound_object_setVolume)
-void
-swfdec_sound_object_setVolume (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Sound.setVolume");
-}
-
-SWFDEC_AS_NATIVE (500, 9, swfdec_sound_object_getDuration)
-void
-swfdec_sound_object_getDuration (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Sound.getDuration");
-}
-
-SWFDEC_AS_NATIVE (500, 10, swfdec_sound_object_setDuration)
-void
-swfdec_sound_object_setDuration (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Sound.setDuration");
-}
-
-SWFDEC_AS_NATIVE (500, 11, swfdec_sound_object_getPosition)
-void
-swfdec_sound_object_getPosition (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Sound.getPosition");
-}
-
-SWFDEC_AS_NATIVE (500, 12, swfdec_sound_object_setPosition)
-void
-swfdec_sound_object_setPosition (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Sound.setPosition");
-}
-
-SWFDEC_AS_NATIVE (500, 13, swfdec_sound_object_loadSound)
-void
-swfdec_sound_object_loadSound (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Sound.loadSound");
-}
-
-SWFDEC_AS_NATIVE (500, 14, swfdec_sound_object_getBytesLoaded)
-void
-swfdec_sound_object_getBytesLoaded (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Sound.getBytesLoaded");
-}
-
-SWFDEC_AS_NATIVE (500, 15, swfdec_sound_object_getBytesTotal)
-void
-swfdec_sound_object_getBytesTotal (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Sound.getBytesTotal");
-}
-
-SWFDEC_AS_NATIVE (500, 18, swfdec_sound_object_get_checkPolicyFile)
-void
-swfdec_sound_object_get_checkPolicyFile (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Sound.checkPolicyFile (get)");
-}
-
-SWFDEC_AS_NATIVE (500, 19, swfdec_sound_object_set_checkPolicyFile)
-void
-swfdec_sound_object_set_checkPolicyFile (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Sound.checkPolicyFile (set)");
-}
-
-SWFDEC_AS_NATIVE (500, 16, swfdec_sound_object_areSoundsInaccessible)
-void
-swfdec_sound_object_areSoundsInaccessible (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Sound.areSoundsInaccessible");
-}
-
-SWFDEC_AS_NATIVE (500, 7, swfdec_sound_object_attachSound)
-void
-swfdec_sound_object_attachSound (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecSoundObject *sound;
- const char *name;
- SwfdecSound *new;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_SOUND_OBJECT, &sound, "s", &name);
-
- new = swfdec_sound_object_get_sound (sound, name);
- if (new) {
- if (sound->attached)
- g_object_unref (sound->attached);
- sound->attached = g_object_ref (new);
- }
-}
-
-SWFDEC_AS_NATIVE (500, 8, swfdec_sound_object_start)
-void
-swfdec_sound_object_start (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecSoundObject *sound;
- double offset;
- int loops;
- SwfdecAudio *audio;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_SOUND_OBJECT, &sound, "|ni", &offset, &loops);
-
- if (sound->attached == NULL) {
- SWFDEC_INFO ("no sound attached when calling Sound.start()");
- return;
- }
- if (argc < 2 || loops < 0)
- loops = 1;
- if (offset < 0 || !isfinite (offset))
- offset = 0;
-
- audio = swfdec_audio_event_new (SWFDEC_PLAYER (cx), sound->attached, offset / 44100, loops);
- g_object_unref (audio);
-}
-
-typedef struct {
- SwfdecMovie *movie;
- SwfdecSound *sound;
-} RemoveData;
-
-static gboolean
-swfdec_sound_object_should_stop (SwfdecAudio *audio, gpointer datap)
-{
- RemoveData *data = datap;
- SwfdecAudioEvent *event;
-
- if (!SWFDEC_IS_AUDIO_EVENT (audio))
- return FALSE;
- event = SWFDEC_AUDIO_EVENT (audio);
- if (data->sound != NULL && event->sound != data->sound)
- return FALSE;
- /* FIXME: also check the movie is identical */
- return TRUE;
-}
-
-SWFDEC_AS_NATIVE (500, 6, swfdec_sound_object_stop)
-void
-swfdec_sound_object_stop (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecSoundObject *sound;
- const char *name;
- RemoveData data;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_SOUND_OBJECT, &sound, "|s", &name);
-
- if (sound->global) {
- data.movie = NULL;
- } else {
- data.movie = sound->target;
- }
- if (argc > 0) {
- data.sound = swfdec_sound_object_get_sound (sound, name);
- if (data.sound == NULL)
- return;
- } else if (sound->attached) {
- data.sound = sound->attached;
- } else {
- data.sound = NULL;
- }
- swfdec_player_stop_sounds (SWFDEC_PLAYER (cx), swfdec_sound_object_should_stop, &data);
-}
-
-SWFDEC_AS_CONSTRUCTOR (500, 16, swfdec_sound_object_construct, swfdec_sound_object_get_type)
-void
-swfdec_sound_object_construct (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecSoundObject *sound;
- SwfdecPlayer *player;
-
- if (!swfdec_as_context_is_constructing (cx))
- return;
-
- sound = SWFDEC_SOUND_OBJECT (object);
- player = SWFDEC_PLAYER (cx);
-
- if (argc == 0 || SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0])) {
- sound->global = TRUE;
- /* FIXME: what is the target for global sounds? Problem:
- * We use the target in attachSound to look up the sound object to attach.
- * But I'm not sure what is used for global sounds.
- * So we just use a random one that looks good for now. */
- sound->target = player->priv->roots->data;
- } else {
- sound->target = swfdec_player_get_movie_from_value (player, &argv[0]);
- }
-}
-
diff --git a/libswfdec/swfdec_sound_object.h b/libswfdec/swfdec_sound_object.h
deleted file mode 100644
index cdceaeb..0000000
--- a/libswfdec/swfdec_sound_object.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_SOUND_OBJECT_H_
-#define _SWFDEC_SOUND_OBJECT_H_
-
-#include <libswfdec/swfdec_movie.h>
-
-G_BEGIN_DECLS
-
-
-typedef struct _SwfdecSoundObject SwfdecSoundObject;
-typedef struct _SwfdecSoundObjectClass SwfdecSoundObjectClass;
-
-#define SWFDEC_TYPE_SOUND_OBJECT (swfdec_sound_object_get_type())
-#define SWFDEC_IS_SOUND_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SOUND_OBJECT))
-#define SWFDEC_IS_SOUND_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SOUND_OBJECT))
-#define SWFDEC_SOUND_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SOUND_OBJECT, SwfdecSoundObject))
-#define SWFDEC_SOUND_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SOUND_OBJECT, SwfdecSoundObjectClass))
-#define SWFDEC_SOUND_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_SOUND_OBJECT, SwfdecSoundObjectClass))
-
-struct _SwfdecSoundObject {
- SwfdecAsObject object;
-
- SwfdecMovie * target; /* target movie or NULL on constructing error */
- gboolean global; /* TRUE if handling global sound */
- SwfdecSound * attached; /* sound that was attached */
-};
-
-struct _SwfdecSoundObjectClass {
- SwfdecAsObjectClass object_class;
-};
-
-GType swfdec_sound_object_get_type (void);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_sprite.c b/libswfdec/swfdec_sprite.c
deleted file mode 100644
index f7bc576..0000000
--- a/libswfdec/swfdec_sprite.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <string.h>
-
-#include "swfdec_sprite.h"
-#include "swfdec_debug.h"
-#include "swfdec_movie.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_script.h"
-#include "swfdec_sound.h"
-#include "swfdec_sprite_movie.h"
-#include "swfdec_swf_decoder.h"
-#include "swfdec_tag.h"
-
-G_DEFINE_TYPE (SwfdecSprite, swfdec_sprite, SWFDEC_TYPE_GRAPHIC)
-
-static void
-swfdec_sprite_dispose (GObject *object)
-{
- SwfdecSprite * sprite = SWFDEC_SPRITE (object);
- guint i;
-
- if (sprite->frames) {
- for (i = 0; i < sprite->n_frames; i++) {
- g_free (sprite->frames[i].label);
- if (sprite->frames[i].sound_head)
- g_object_unref (sprite->frames[i].sound_head);
- if (sprite->frames[i].sound_block) {
- swfdec_buffer_unref (sprite->frames[i].sound_block);
- }
- g_slist_foreach (sprite->frames[i].sound, (GFunc) swfdec_sound_chunk_free, NULL);
- g_slist_free (sprite->frames[i].sound);
- }
- g_free(sprite->frames);
- }
- for (i = 0; i < sprite->actions->len; i++) {
- SwfdecSpriteAction *cur = &g_array_index (sprite->actions, SwfdecSpriteAction, i);
- if (cur->buffer)
- swfdec_buffer_unref (cur->buffer);
- }
- g_array_free (sprite->actions, TRUE);
- sprite->actions = NULL;
- if (sprite->init_action) {
- swfdec_script_unref (sprite->init_action);
- sprite->init_action = NULL;
- }
-
- G_OBJECT_CLASS (swfdec_sprite_parent_class)->dispose (object);
-}
-
-void
-swfdec_sprite_add_sound_chunk (SwfdecSprite * sprite, guint frame,
- SwfdecBuffer * chunk, int skip, guint n_samples)
-{
- g_assert (sprite->frames != NULL);
- g_assert (chunk != NULL || n_samples == 0);
-
- if (sprite->frames[frame].sound_head == NULL) {
- SWFDEC_ERROR ("attempting to add a sound block without previous sound head");
- swfdec_buffer_unref (chunk);
- return;
- }
- if (sprite->frames[frame].sound_block) {
- SWFDEC_ERROR ("attempting to add 2 sound blocks to one frame");
- swfdec_buffer_unref (chunk);
- return;
- }
- SWFDEC_LOG ("adding %u samples in %"G_GSIZE_FORMAT" bytes to frame %u", n_samples,
- chunk ? chunk->length : 0, frame);
- sprite->frames[frame].sound_skip = skip;
- sprite->frames[frame].sound_block = chunk;
- sprite->frames[frame].sound_samples = n_samples *
- swfdec_audio_format_get_granularity (sprite->frames[frame].sound_head->format);
-}
-
-void
-swfdec_sprite_add_action (SwfdecSprite *sprite, guint tag, SwfdecBuffer *buffer)
-{
- SwfdecSpriteAction action;
-
- action.tag = tag;
- action.buffer = buffer;
- g_array_append_val (sprite->actions, action);
-}
-
-gboolean
-swfdec_sprite_get_action (SwfdecSprite *sprite, guint n, guint *tag, SwfdecBuffer **buffer)
-{
- SwfdecSpriteAction *action;
-
- g_return_val_if_fail (SWFDEC_IS_SPRITE (sprite), FALSE);
- g_return_val_if_fail (tag != NULL, FALSE);
- g_return_val_if_fail (buffer != NULL, FALSE);
-
- if (n >= sprite->actions->len)
- return FALSE;
- action = &g_array_index (sprite->actions, SwfdecSpriteAction, n);
- *tag = action->tag;
- *buffer = action->buffer;
- return TRUE;
-}
-
-int
-tag_func_set_background_color (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecPlayer *player = SWFDEC_DECODER (s)->player;
- SwfdecPlayerPrivate *priv = player->priv;
- SwfdecColor color = swfdec_bits_get_color (&s->b);
-
- if (priv->bgcolor_set) {
- /* only an INFO because it can be set by user, should be error if we check duplication of tag */
- SWFDEC_INFO ("background color has been set to %X already, setting to %X ignored",
- priv->bgcolor, color);
- } else {
- SWFDEC_LOG ("setting background color to %X", color);
- /* can't use swfdec_player_set_background_color() here, because the player is locked and doesn't emit signals */
- priv->bgcolor = color;
- priv->bgcolor_set = TRUE;
- priv->invalid_extents = priv->stage;
- g_array_set_size (priv->invalidations, 1);
- g_array_index (priv->invalidations, SwfdecRectangle, 0) = priv->stage;
- g_object_notify (G_OBJECT (player), "background-color");
- }
-
- return SWFDEC_STATUS_OK;
-}
-
-static SwfdecMovie *
-swfdec_sprite_create_movie (SwfdecGraphic *graphic, gsize *size)
-{
- SwfdecSpriteMovie *ret = g_object_new (SWFDEC_TYPE_SPRITE_MOVIE, NULL);
-
- ret->sprite = SWFDEC_SPRITE (graphic);
- ret->n_frames = ret->sprite->n_frames;
- *size = sizeof (SwfdecSpriteMovie);
-
- return SWFDEC_MOVIE (ret);
-}
-
-static void
-swfdec_sprite_class_init (SwfdecSpriteClass * g_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (g_class);
- SwfdecGraphicClass *graphic_class = SWFDEC_GRAPHIC_CLASS (g_class);
-
- object_class->dispose = swfdec_sprite_dispose;
-
- graphic_class->create_movie = swfdec_sprite_create_movie;
-}
-
-static void
-swfdec_sprite_init (SwfdecSprite * sprite)
-{
- sprite->actions = g_array_new (FALSE, FALSE, sizeof (SwfdecSpriteAction));
-}
-
-void
-swfdec_sprite_set_n_frames (SwfdecSprite *sprite, guint n_frames,
- guint rate)
-{
- guint i;
-
- g_return_if_fail (SWFDEC_IS_SPRITE (sprite));
- if (n_frames > 0) {
- sprite->frames = g_new0 (SwfdecSpriteFrame, n_frames);
- sprite->n_frames = n_frames;
-
- if (rate > 0) {
- for (i = 0; i < n_frames; i++) {
- sprite->frames[i].sound_samples = 44100 * 256 / rate;
- }
- }
- }
-
- SWFDEC_LOG ("n_frames = %d", sprite->n_frames);
-}
-
-int
-swfdec_sprite_get_frame (SwfdecSprite *sprite, const char *label)
-{
- guint i;
-
- g_return_val_if_fail (SWFDEC_IS_SPRITE (sprite), -1);
- g_return_val_if_fail (label != NULL, -1);
-
- for (i = 0; i < SWFDEC_SPRITE (sprite)->n_frames; i++) {
- SwfdecSpriteFrame *frame = &sprite->frames[i];
- if (frame->label == NULL)
- continue;
- if (g_str_equal (frame->label, label))
- return i;
- }
- return -1;
-}
-
diff --git a/libswfdec/swfdec_sprite.h b/libswfdec/swfdec_sprite.h
deleted file mode 100644
index 6c9d4b9..0000000
--- a/libswfdec/swfdec_sprite.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_SPRITE_H_
-#define _SWFDEC_SPRITE_H_
-
-#include <libswfdec/swfdec_color.h>
-#include <libswfdec/swfdec_event.h>
-#include <libswfdec/swfdec_graphic.h>
-#include <libswfdec/swfdec_types.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecSpriteClass SwfdecSpriteClass;
-typedef struct _SwfdecSpriteAction SwfdecSpriteAction;
-typedef struct _SwfdecExport SwfdecExport;
-
-/* FIXME: It might make sense to event a SwfdecActionBuffer - a subclass of
- * SwfdecBuffer that carries around a the tag.
- * It might also make more sense to not parse the file into buffers at all
- * and operate on the memory directly.
- */
-struct _SwfdecSpriteAction {
- guint tag; /* the data tag (see swfdec_tag.h) */
- SwfdecBuffer * buffer; /* the buffer for this data (can be NULL) */
-};
-
-#define SWFDEC_TYPE_SPRITE (swfdec_sprite_get_type())
-#define SWFDEC_IS_SPRITE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SPRITE))
-#define SWFDEC_IS_SPRITE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SPRITE))
-#define SWFDEC_SPRITE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SPRITE, SwfdecSprite))
-#define SWFDEC_SPRITE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SPRITE, SwfdecSpriteClass))
-
-struct _SwfdecSpriteFrame
-{
- char *label; /* name of the frame for "GotoLabel" */
-
- /* sound */
- SwfdecSound *sound_head; /* sound head for this frame */
- int sound_skip; /* samples to skip - maybe even backwards */
- SwfdecBuffer *sound_block; /* sound chunk to play here or NULL for none */
- guint sound_samples; /* number of samples in this frame */
- GSList *sound; /* list of SwfdecSoundChunk events to start playing here */
-};
-
-struct _SwfdecSprite
-{
- SwfdecGraphic graphic;
-
- SwfdecSpriteFrame * frames; /* the n_frames different frames */
- guint n_frames; /* number of frames in this sprite */
- SwfdecScript * init_action; /* action to run when initializing this sprite */
- GArray * actions; /* SwfdecSpriteAction in execution order */
-
- /* parse state */
- guint parse_frame; /* frame we're currently parsing. == n_frames if done parsing */
-};
-
-struct _SwfdecSpriteClass
-{
- SwfdecGraphicClass graphic_class;
-};
-
-GType swfdec_sprite_get_type (void);
-
-int tag_func_define_sprite (SwfdecSwfDecoder * s, guint tag);
-void swfdec_sprite_add_sound_chunk (SwfdecSprite * sprite, guint frame,
- SwfdecBuffer * chunk, int skip, guint n_samples);
-void swfdec_sprite_set_n_frames (SwfdecSprite *sprite, guint n_frames, guint rate);
-void swfdec_sprite_add_action (SwfdecSprite * sprite, guint tag, SwfdecBuffer *buffer);
-gboolean swfdec_sprite_get_action (SwfdecSprite * sprite,
- guint n,
- guint * tag,
- SwfdecBuffer ** buffer);
-int swfdec_sprite_get_frame (SwfdecSprite * sprite,
- const char * label);
-
-int tag_func_set_background_color (SwfdecSwfDecoder * s, guint tag);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c
deleted file mode 100644
index e014ece..0000000
--- a/libswfdec/swfdec_sprite_movie.c
+++ /dev/null
@@ -1,883 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <strings.h>
-
-#include "swfdec_sprite_movie.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_audio_event.h"
-#include "swfdec_audio_stream.h"
-#include "swfdec_debug.h"
-#include "swfdec_filter.h"
-#include "swfdec_graphic_movie.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_ringbuffer.h"
-#include "swfdec_script_internal.h"
-#include "swfdec_sprite.h"
-#include "swfdec_resource.h"
-#include "swfdec_tag.h"
-
-/*** SWFDEC_SPRITE_MOVIE ***/
-
-static gboolean
-swfdec_sprite_movie_remove_child (SwfdecMovie *movie, int depth)
-{
- SwfdecMovie *child = swfdec_movie_find (movie, depth);
-
- if (child == NULL)
- return FALSE;
-
- swfdec_movie_remove (child);
- return TRUE;
-}
-
-static int
-swfdec_get_clipeventflags (SwfdecMovie *movie, SwfdecBits * bits)
-{
- if (SWFDEC_SWF_DECODER (movie->resource->decoder)->version <= 5) {
- return swfdec_bits_get_u16 (bits);
- } else {
- return swfdec_bits_get_u32 (bits);
- }
-}
-
-static gboolean
-swfdec_sprite_movie_perform_old_place (SwfdecSpriteMovie *movie,
- SwfdecBits *bits, guint tag)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
- SwfdecMovie *mov = SWFDEC_MOVIE (movie);
- SwfdecMovie *cur;
- SwfdecSwfDecoder *dec;
- int depth;
- cairo_matrix_t transform;
- gboolean has_ctrans;
- SwfdecColorTransform ctrans;
- guint id;
- SwfdecGraphic *graphic;
-
- dec = SWFDEC_SWF_DECODER (mov->resource->decoder);
-
- SWFDEC_LOG ("performing PlaceObject on movie %s", mov->name);
-
- id = swfdec_bits_get_u16 (bits);
- SWFDEC_LOG (" id = %d", id);
-
- depth = swfdec_bits_get_u16 (bits);
- if (depth >= 16384) {
- SWFDEC_FIXME ("depth of placement too high: %u >= 16384", depth);
- }
- SWFDEC_LOG (" depth = %d (=> %d)", depth, depth - 16384);
- depth -= 16384;
-
- swfdec_bits_get_matrix (bits, &transform, NULL);
- SWFDEC_LOG (" matrix = { %g %g, %g %g } + { %g %g }",
- transform.xx, transform.yx,
- transform.xy, transform.yy,
- transform.x0, transform.y0);
-
- if (swfdec_bits_left (bits)) {
- has_ctrans = TRUE;
- swfdec_bits_get_color_transform (bits, &ctrans);
- SWFDEC_LOG (" color transform = %d %d %d %d %d %d %d %d",
- ctrans.ra, ctrans.rb,
- ctrans.ga, ctrans.gb,
- ctrans.ba, ctrans.bb,
- ctrans.aa, ctrans.ab);
- } else {
- has_ctrans = FALSE;
- }
-
- /* 3) perform the actions depending on the set properties */
- cur = swfdec_movie_find (mov, depth);
- graphic = swfdec_swf_decoder_get_character (dec, id);
-
- if (!SWFDEC_IS_GRAPHIC (graphic)) {
- SWFDEC_FIXME ("character %u is not a graphic (does it even exist?), aborting", id);
- return FALSE;
- }
-
- cur = swfdec_movie_new (player, depth, mov, mov->resource, graphic, NULL);
- swfdec_movie_set_static_properties (cur, &transform,
- has_ctrans ? &ctrans : NULL, -1, 0, 0, NULL);
- swfdec_movie_queue_script (cur, SWFDEC_EVENT_INITIALIZE);
- swfdec_movie_queue_script (cur, SWFDEC_EVENT_CONSTRUCT);
- swfdec_movie_queue_script (cur, SWFDEC_EVENT_LOAD);
- swfdec_movie_initialize (cur);
-
- return TRUE;
-}
-
-
-static gboolean
-swfdec_sprite_movie_perform_place (SwfdecSpriteMovie *movie, SwfdecBits *bits, guint tag)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
- SwfdecMovie *mov = SWFDEC_MOVIE (movie);
- SwfdecMovie *cur;
- SwfdecSwfDecoder *dec;
- gboolean has_clip_actions;
- gboolean has_clip_depth;
- gboolean has_name;
- gboolean has_ratio;
- gboolean has_ctrans;
- gboolean has_transform;
- gboolean has_character;
- gboolean move;
- int depth;
- gboolean cache;
- gboolean has_blend_mode = 0;
- gboolean has_filter = 0;
- int clip_depth;
- cairo_matrix_t transform;
- SwfdecColorTransform ctrans;
- guint ratio, id, version;
- SwfdecEventList *events;
- const char *name;
- guint blend_mode;
- SwfdecGraphic *graphic;
-
- dec = SWFDEC_SWF_DECODER (mov->resource->decoder);
- version = dec->version;
-
- /* 1) check which stuff is set */
- has_clip_actions = swfdec_bits_getbit (bits);
- has_clip_depth = swfdec_bits_getbit (bits);
- has_name = swfdec_bits_getbit (bits);
- has_ratio = swfdec_bits_getbit (bits);
- has_ctrans = swfdec_bits_getbit (bits);
- has_transform = swfdec_bits_getbit (bits);
- has_character = swfdec_bits_getbit (bits);
- move = swfdec_bits_getbit (bits);
-
- SWFDEC_LOG ("performing PlaceObject%d on movie %s", tag == SWFDEC_TAG_PLACEOBJECT2 ? 2 : 3, mov->name);
- SWFDEC_LOG (" has_clip_actions = %d", has_clip_actions);
- SWFDEC_LOG (" has_clip_depth = %d", has_clip_depth);
- SWFDEC_LOG (" has_name = %d", has_name);
- SWFDEC_LOG (" has_ratio = %d", has_ratio);
- SWFDEC_LOG (" has_ctrans = %d", has_ctrans);
- SWFDEC_LOG (" has_transform = %d", has_transform);
- SWFDEC_LOG (" has_character = %d", has_character);
- SWFDEC_LOG (" move = %d", move);
-
- if (tag == SWFDEC_TAG_PLACEOBJECT3) {
- swfdec_bits_getbits (bits, 5);
- cache = swfdec_bits_getbit (bits);
- has_blend_mode = swfdec_bits_getbit (bits);
- has_filter = swfdec_bits_getbit (bits);
- SWFDEC_LOG (" cache = %d", cache);
- SWFDEC_LOG (" has filter = %d", has_filter);
- SWFDEC_LOG (" has blend mode = %d", has_blend_mode);
- }
-
- /* 2) read all properties */
- depth = swfdec_bits_get_u16 (bits);
- if (depth >= 16384) {
- SWFDEC_FIXME ("depth of placement too high: %u >= 16384", depth);
- }
- SWFDEC_LOG (" depth = %d (=> %d)", depth, depth - 16384);
- depth -= 16384;
- if (has_character) {
- id = swfdec_bits_get_u16 (bits);
- SWFDEC_LOG (" id = %d", id);
- } else {
- id = 0;
- }
-
- if (has_transform) {
- swfdec_bits_get_matrix (bits, &transform, NULL);
- SWFDEC_LOG (" matrix = { %g %g, %g %g } + { %g %g }",
- transform.xx, transform.yx,
- transform.xy, transform.yy,
- transform.x0, transform.y0);
- }
- if (has_ctrans) {
- swfdec_bits_get_color_transform (bits, &ctrans);
- SWFDEC_LOG (" color transform = %d %d %d %d %d %d %d %d",
- ctrans.ra, ctrans.rb,
- ctrans.ga, ctrans.gb,
- ctrans.ba, ctrans.bb,
- ctrans.aa, ctrans.ab);
- }
-
- if (has_ratio) {
- ratio = swfdec_bits_get_u16 (bits);
- SWFDEC_LOG (" ratio = %d", ratio);
- } else {
- ratio = -1;
- }
-
- if (has_name) {
- char *s = swfdec_bits_get_string (bits, version);
- name = swfdec_as_context_give_string (SWFDEC_AS_CONTEXT (player), s);
- SWFDEC_LOG (" name = %s", name);
- } else {
- name = NULL;
- }
-
- if (has_clip_depth) {
- clip_depth = swfdec_bits_get_u16 (bits) - 16384;
- SWFDEC_LOG (" clip_depth = %d (=> %d)", clip_depth + 16384, clip_depth);
- } else {
- clip_depth = 0;
- }
-
- if (has_filter) {
- GSList *filters = swfdec_filter_parse (player, bits);
- g_slist_free (filters);
- }
-
- if (has_blend_mode) {
- blend_mode = swfdec_bits_get_u8 (bits);
- SWFDEC_LOG (" blend mode = %u", blend_mode);
- } else {
- blend_mode = 0;
- }
-
- if (has_clip_actions) {
- int reserved, clip_event_flags, event_flags, key_code;
- char *script_name;
-
- events = swfdec_event_list_new (player);
- reserved = swfdec_bits_get_u16 (bits);
- clip_event_flags = swfdec_get_clipeventflags (mov, bits);
-
- if (name)
- script_name = g_strdup (name);
- else if (id)
- script_name = g_strdup_printf ("Sprite%u", id);
- else
- script_name = g_strdup ("unknown");
- while ((event_flags = swfdec_get_clipeventflags (mov, bits)) != 0) {
- guint length = swfdec_bits_get_u32 (bits);
- SwfdecBits action_bits;
-
- swfdec_bits_init_bits (&action_bits, bits, length);
- if (event_flags & (1<<SWFDEC_EVENT_KEY_PRESS))
- key_code = swfdec_bits_get_u8 (&action_bits);
- else
- key_code = 0;
-
- SWFDEC_INFO ("clip event with flags 0x%X, key code %d", event_flags, key_code);
-#define SWFDEC_UNIMPLEMENTED_EVENTS \
- ((1<< SWFDEC_EVENT_DATA) | (1<<SWFDEC_EVENT_KEY_PRESS))
- if (event_flags & SWFDEC_UNIMPLEMENTED_EVENTS) {
- SWFDEC_ERROR ("using non-implemented clip events %u", event_flags & SWFDEC_UNIMPLEMENTED_EVENTS);
- }
- swfdec_event_list_parse (events, &action_bits, version,
- event_flags, key_code, script_name);
- if (swfdec_bits_left (&action_bits)) {
- SWFDEC_ERROR ("not all action data was parsed: %u bytes left",
- swfdec_bits_left (&action_bits));
- }
- }
- g_free (script_name);
- } else {
- events = NULL;
- }
-
- /* 3) perform the actions depending on the set properties */
- cur = swfdec_movie_find (mov, depth);
- graphic = swfdec_swf_decoder_get_character (dec, id);
- if (move) {
- if (cur == NULL) {
- SWFDEC_INFO ("no movie at depth %d, ignoring move command", depth);
- goto out;
- }
- if (graphic) {
- SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (cur);
- if (klass->replace)
- klass->replace (cur, graphic);
- }
- swfdec_movie_set_static_properties (cur, has_transform ? &transform : NULL,
- has_ctrans ? &ctrans : NULL, ratio, clip_depth, blend_mode, events);
- } else {
- if (cur != NULL && version > 5) {
- SWFDEC_INFO ("depth %d is already occupied by movie %s, not placing", depth, cur->name);
- goto out;
- }
- if (!SWFDEC_IS_GRAPHIC (graphic)) {
- SWFDEC_FIXME ("character %u is not a graphic (does it even exist?), aborting", id);
- if (events)
- swfdec_event_list_free (events);
- return FALSE;
- }
- cur = swfdec_movie_new (player, depth, mov, mov->resource, graphic, name);
- swfdec_movie_set_static_properties (cur, has_transform ? &transform : NULL,
- has_ctrans ? &ctrans : NULL, ratio, clip_depth, blend_mode, events);
- swfdec_movie_queue_script (cur, SWFDEC_EVENT_INITIALIZE);
- swfdec_movie_queue_script (cur, SWFDEC_EVENT_CONSTRUCT);
- swfdec_movie_queue_script (cur, SWFDEC_EVENT_LOAD);
- swfdec_movie_initialize (cur);
- }
-
-out:
- if (events)
- swfdec_event_list_free (events);
- return TRUE;
-}
-
-static void
-swfdec_sprite_movie_start_sound (SwfdecMovie *movie, SwfdecBits *bits)
-{
- SwfdecSoundChunk *chunk;
- int id;
-
- id = swfdec_bits_get_u16 (bits);
- chunk = swfdec_sound_parse_chunk (SWFDEC_SWF_DECODER (movie->resource->decoder), bits, id);
- if (chunk) {
- SwfdecAudio *audio = swfdec_audio_event_new_from_chunk (SWFDEC_PLAYER (
- SWFDEC_AS_OBJECT (movie)->context), chunk);
- if (audio)
- g_object_unref (audio);
- }
-}
-
-static gboolean
-swfdec_sprite_movie_perform_one_action (SwfdecSpriteMovie *movie, guint tag, SwfdecBuffer *buffer,
- gboolean skip_scripts, gboolean first_time)
-{
- SwfdecMovie *mov = SWFDEC_MOVIE (movie);
- SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (mov)->context);
- SwfdecBits bits;
-
- g_assert (mov->resource);
- swfdec_bits_init (&bits, buffer);
-
- SWFDEC_LOG ("%p: executing %uth tag %s in frame %u", movie, movie->next_action - 1,
- swfdec_swf_decoder_get_tag_name (tag), movie->frame);
- switch (tag) {
- case SWFDEC_TAG_DOACTION:
- SWFDEC_LOG ("SCRIPT action");
- if (!skip_scripts) {
- SwfdecScript *script = swfdec_swf_decoder_get_script (
- SWFDEC_SWF_DECODER (mov->resource->decoder), buffer->data);
- g_assert (script);
- swfdec_player_add_action_script (player, mov, script, 2);
- }
- return TRUE;
- case SWFDEC_TAG_PLACEOBJECT:
- return swfdec_sprite_movie_perform_old_place (movie, &bits, tag);
- case SWFDEC_TAG_PLACEOBJECT2:
- case SWFDEC_TAG_PLACEOBJECT3:
- return swfdec_sprite_movie_perform_place (movie, &bits, tag);
- case SWFDEC_TAG_REMOVEOBJECT:
- /* yes, this code is meant to be like this - the following u16 is the
- * character id, that we don't care about, the rest is like RemoveObject2
- */
- swfdec_bits_get_u16 (&bits);
- /* fall through */
- case SWFDEC_TAG_REMOVEOBJECT2:
- {
- int depth = swfdec_bits_get_u16 (&bits);
- SWFDEC_LOG ("REMOVE action: depth %d => %d", depth, depth - 16384);
- depth -= 16384;
- if (!swfdec_sprite_movie_remove_child (mov, depth))
- SWFDEC_INFO ("could not remove, no child at depth %d", depth);
- }
- return TRUE;
- case SWFDEC_TAG_STARTSOUND:
- swfdec_sprite_movie_start_sound (mov, &bits);
- return TRUE;
- case SWFDEC_TAG_SHOWFRAME:
- if (movie->frame < movie->n_frames) {
- movie->frame++;
- } else {
- SWFDEC_ERROR ("too many ShowFrame tags");
- }
- return FALSE;
- case SWFDEC_TAG_EXPORTASSETS:
- {
- SwfdecResource *resource = swfdec_movie_get_own_resource (mov);
- guint i, count;
-
- g_assert (resource); /* must hold, ExportAssets can only be in root movies */
- if (!first_time)
- return TRUE;
- count = swfdec_bits_get_u16 (&bits);
- SWFDEC_LOG ("exporting %u assets", count);
- for (i = 0; i < count && swfdec_bits_left (&bits); i++) {
- SwfdecSwfDecoder *s = SWFDEC_SWF_DECODER (resource->decoder);
- guint id;
- SwfdecCharacter *object;
- char *name;
-
- id = swfdec_bits_get_u16 (&bits);
- object = swfdec_swf_decoder_get_character (s, id);
- name = swfdec_bits_get_string (&bits, s->version);
- if (object == NULL) {
- SWFDEC_ERROR ("cannot export id %u as %s, id wasn't found", id, name);
- } else if (name == NULL) {
- SWFDEC_ERROR ("cannot export id %u, no name was given", id);
- } else {
- SWFDEC_LOG ("exporting %s %u as %s", G_OBJECT_TYPE_NAME (object), id, name);
- swfdec_resource_add_export (resource, object, name);
- }
- g_free (name);
- }
- }
- return TRUE;
- case SWFDEC_TAG_DOINITACTION:
- if (!first_time)
- return TRUE;
- if (!swfdec_movie_get_own_resource (mov)) {
- SWFDEC_FIXME ("behavior of init actions in DefineSprite untested");
- }
- {
- guint id;
- SwfdecSprite *sprite;
- char *name;
-
- id = swfdec_bits_get_u16 (&bits);
- SWFDEC_LOG ("InitAction");
- SWFDEC_LOG (" id = %u", id);
- sprite = swfdec_swf_decoder_get_character (SWFDEC_SWF_DECODER (mov->resource->decoder), id);
- if (!SWFDEC_IS_SPRITE (sprite)) {
- SWFDEC_ERROR ("character %u is not a sprite", id);
- return TRUE;
- }
- if (sprite->init_action != NULL) {
- SWFDEC_ERROR ("sprite %u already has an init action", id);
- return TRUE;
- }
- name = g_strdup_printf ("InitAction %u", id);
- sprite->init_action = swfdec_script_new_from_bits (&bits, name,
- swfdec_movie_get_version (mov));
- g_free (name);
- if (sprite->init_action) {
- swfdec_player_add_action_script (player, mov, sprite->init_action, 0);
- }
- }
- return TRUE;
- default:
- g_assert_not_reached ();
- return FALSE;
- }
-}
-
-static gboolean
-swfdec_movie_is_compatible (SwfdecMovie *movie, SwfdecMovie *with)
-{
- g_assert (movie->depth == with->depth);
-
- if (movie->original_ratio != with->original_ratio)
- return FALSE;
-
- if (G_OBJECT_TYPE (movie) != G_OBJECT_TYPE (with))
- return FALSE;
-
- return TRUE;
-}
-
-static GList *
-my_g_list_split (GList *list, GList *split)
-{
- GList *prev;
-
- if (split == NULL)
- return list;
-
- prev = split->prev;
- if (prev == NULL)
- return NULL;
- prev->next = NULL;
- split->prev = NULL;
- return list;
-}
-
-void
-swfdec_sprite_movie_goto (SwfdecSpriteMovie *movie, guint goto_frame)
-{
- SwfdecMovie *mov;
- SwfdecPlayer *player;
- GList *old;
- guint n;
-
- g_return_if_fail (SWFDEC_IS_SPRITE_MOVIE (movie));
-
- mov = SWFDEC_MOVIE (movie);
- /* lots of things where we've got nothing to do */
- if (goto_frame == 0 || goto_frame > movie->n_frames ||
- movie->sprite == NULL || mov->state >= SWFDEC_MOVIE_STATE_REMOVED || goto_frame == movie->frame)
- return;
-
- if (goto_frame > movie->sprite->parse_frame) {
- SWFDEC_WARNING ("jumping to not-yet-loaded frame %u (loaded: %u/%u)",
- goto_frame, movie->sprite->parse_frame, movie->sprite->n_frames);
- return;
- }
-
- player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
- SWFDEC_LOG ("doing goto %u for %p %d", goto_frame, movie,
- SWFDEC_CHARACTER (movie->sprite)->id);
-
- SWFDEC_DEBUG ("performing goto %u -> %u for character %u",
- movie->frame, goto_frame, SWFDEC_CHARACTER (movie->sprite)->id);
- if (goto_frame < movie->frame) {
- GList *walk;
- movie->frame = 0;
- for (walk = mov->list; walk &&
- swfdec_depth_classify (SWFDEC_MOVIE (walk->data)->depth) != SWFDEC_DEPTH_CLASS_TIMELINE;
- walk = walk->next) {
- /* do nothing */
- }
- old = walk;
- mov->list = my_g_list_split (mov->list, old);
- for (walk = old; walk &&
- swfdec_depth_classify (SWFDEC_MOVIE (walk->data)->depth) == SWFDEC_DEPTH_CLASS_TIMELINE;
- walk = walk->next) {
- /* do nothing */
- }
- old = my_g_list_split (old, walk);
- mov->list = g_list_concat (mov->list, walk);
- n = goto_frame;
- movie->next_action = 0;
- } else {
- /* NB: this path is also taken on init */
- old = NULL;
- n = goto_frame - movie->frame;
- }
- while (n) {
- guint tag;
- gboolean first_time;
- SwfdecBuffer *buffer;
- if (!swfdec_sprite_get_action (movie->sprite, movie->next_action, &tag, &buffer))
- break;
- movie->next_action++;
- if (movie->next_action > movie->max_action) {
- first_time = TRUE;
- movie->max_action = movie->next_action;
- } else {
- first_time = FALSE;
- }
- if (!swfdec_sprite_movie_perform_one_action (movie, tag, buffer, n > 1, first_time))
- n--;
- }
- /* now try to copy eventual movies */
- if (old) {
- SwfdecMovie *prev, *cur;
- GList *old_walk, *walk;
- walk = mov->list;
- old_walk = old;
- if (!walk)
- goto out;
- cur = walk->data;
- for (; old_walk; old_walk = old_walk->next) {
- prev = old_walk->data;
- while (cur->depth < prev->depth) {
- walk = walk->next;
- if (!walk)
- goto out;
- cur = walk->data;
- }
- if (cur->depth == prev->depth &&
- swfdec_movie_is_compatible (prev, cur)) {
- SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (prev);
- walk->data = prev;
- /* FIXME: This merging stuff probably needs to be improved a _lot_ */
- if (klass->replace)
- klass->replace (prev, cur->graphic);
- swfdec_movie_set_static_properties (prev, &cur->original_transform,
- &cur->original_ctrans, cur->original_ratio, cur->clip_depth,
- cur->blend_mode, cur->events);
- swfdec_movie_destroy (cur);
- cur = prev;
- continue;
- }
- swfdec_movie_remove (prev);
- }
-out:
- for (; old_walk; old_walk = old_walk->next) {
- swfdec_movie_remove (old_walk->data);
- }
- g_list_free (old);
- }
-}
-
-/*** MOVIE ***/
-
-G_DEFINE_TYPE (SwfdecSpriteMovie, swfdec_sprite_movie, SWFDEC_TYPE_MOVIE)
-
-static void
-swfdec_sprite_movie_dispose (GObject *object)
-{
- SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (object);
-
- g_assert (movie->sound_stream == NULL);
-
- G_OBJECT_CLASS (swfdec_sprite_movie_parent_class)->dispose (object);
-}
-
-static void
-swfdec_sprite_movie_init_movie (SwfdecMovie *mov)
-{
- SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov);
-
- g_assert (movie->frame == (guint) -1);
- movie->frame = 0;
- swfdec_sprite_movie_goto (movie, 1);
-}
-
-static void
-swfdec_sprite_movie_add (SwfdecAsObject *object)
-{
- SwfdecMovie *movie = SWFDEC_MOVIE (object);
-
- if (movie->resource->sandbox)
- swfdec_as_object_set_constructor (object, movie->resource->sandbox->MovieClip);
-
- SWFDEC_AS_OBJECT_CLASS (swfdec_sprite_movie_parent_class)->add (object);
-}
-
-static void
-swfdec_sprite_movie_iterate (SwfdecMovie *mov)
-{
- SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov);
- SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (mov)->context);
- guint goto_frame;
-
- if (mov->state >= SWFDEC_MOVIE_STATE_REMOVED)
- return;
-
- if (movie->sprite && movie->frame == (guint) -1)
- movie->frame = 0;
-
- swfdec_player_add_action (player, mov, SWFDEC_EVENT_ENTER, 2);
- if (movie->playing && movie->sprite != NULL) {
- if (movie->frame == movie->n_frames)
- goto_frame = 1;
- else if (movie->sprite && movie->frame == movie->sprite->parse_frame)
- goto_frame = movie->frame;
- else
- goto_frame = movie->frame + 1;
- swfdec_sprite_movie_goto (movie, goto_frame);
- }
-}
-
-/* FIXME: This function is a mess */
-static gboolean
-swfdec_sprite_movie_iterate_end (SwfdecMovie *mov)
-{
- SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov);
- SwfdecSpriteFrame *last;
- SwfdecSpriteFrame *current;
- SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (mov)->context);
-
- if (!SWFDEC_MOVIE_CLASS (swfdec_sprite_movie_parent_class)->iterate_end (mov)) {
- g_assert (movie->sound_stream == NULL);
- return FALSE;
- }
-
- if (movie->sprite == NULL)
- return TRUE;
- g_assert (movie->frame <= movie->n_frames);
- if (movie->frame == 0)
- return TRUE;
- current = &movie->sprite->frames[movie->frame - 1];
-
- /* then do the streaming thing */
- if (current->sound_head == NULL ||
- !movie->playing) {
- if (movie->sound_stream) {
- swfdec_audio_remove (movie->sound_stream);
- g_object_unref (movie->sound_stream);
- movie->sound_stream = NULL;
- }
- goto exit;
- }
- if (movie->sound_stream == NULL && current->sound_block == NULL)
- goto exit;
- SWFDEC_LOG ("iterating audio (from %u to %u)", movie->sound_frame, movie->frame);
- if (movie->sound_frame + 1 != movie->frame)
- goto new_decoder;
- if (movie->sound_frame == (guint) -1)
- goto new_decoder;
- if (current->sound_head && movie->sound_stream == NULL)
- goto new_decoder;
- last = &movie->sprite->frames[movie->sound_frame];
- if (last->sound_head != current->sound_head)
- goto new_decoder;
-exit:
- movie->sound_frame = movie->frame;
- return TRUE;
-
-new_decoder:
- if (movie->sound_stream) {
- swfdec_audio_remove (movie->sound_stream);
- g_object_unref (movie->sound_stream);
- movie->sound_stream = NULL;
- }
-
- if (current->sound_block) {
- movie->sound_stream = swfdec_audio_stream_new (player,
- movie->sprite, movie->frame - 1);
- movie->sound_frame = movie->frame;
- }
- return TRUE;
-}
-
-static void
-swfdec_sprite_movie_finish_movie (SwfdecMovie *mov)
-{
- SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov);
- SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (mov)->context);
-
- swfdec_player_remove_all_actions (player, mov);
- if (movie->sound_stream) {
- swfdec_audio_remove (movie->sound_stream);
- g_object_unref (movie->sound_stream);
- movie->sound_stream = NULL;
- }
-}
-
-static void
-swfdec_sprite_movie_mark (SwfdecAsObject *object)
-{
- GList *walk;
-
- for (walk = SWFDEC_MOVIE (object)->list; walk; walk = walk->next) {
- SwfdecAsObject *child = walk->data;
- g_assert (child->properties != NULL);
- swfdec_as_object_mark (child);
- }
-
- SWFDEC_AS_OBJECT_CLASS (swfdec_sprite_movie_parent_class)->mark (object);
-}
-
-static void
-swfdec_sprite_movie_class_init (SwfdecSpriteMovieClass * g_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (g_class);
- SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (g_class);
- SwfdecMovieClass *movie_class = SWFDEC_MOVIE_CLASS (g_class);
-
- object_class->dispose = swfdec_sprite_movie_dispose;
-
- asobject_class->add = swfdec_sprite_movie_add;
- asobject_class->mark = swfdec_sprite_movie_mark;
-
- movie_class->init_movie = swfdec_sprite_movie_init_movie;
- movie_class->finish_movie = swfdec_sprite_movie_finish_movie;
- movie_class->iterate_start = swfdec_sprite_movie_iterate;
- movie_class->iterate_end = swfdec_sprite_movie_iterate_end;
-}
-
-static void
-swfdec_sprite_movie_init (SwfdecSpriteMovie * movie)
-{
- movie->playing = TRUE;
- movie->frame = (guint) -1;
-}
-
-/* cute little hack */
-extern void
-swfdec_sprite_movie_clear (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval);
-/**
- * swfdec_sprite_movie_unload:
- * @movie: a #SwfdecMovie
- *
- * Clears all contents from the given movie. This means deleting all
- * variables and removing all children movie clips.
- **/
-void
-swfdec_sprite_movie_unload (SwfdecSpriteMovie *movie)
-{
- SwfdecMovie *mov;
- SwfdecAsValue hack;
-
- g_return_if_fail (SWFDEC_IS_SPRITE_MOVIE (movie));
-
- mov = SWFDEC_MOVIE (movie);
- swfdec_sprite_movie_clear (SWFDEC_AS_OBJECT (movie)->context,
- SWFDEC_AS_OBJECT (movie), 0, NULL, &hack);
- /* FIXME: destroy or unload? */
- while (mov->list)
- swfdec_movie_remove (mov->list->data);
- swfdec_as_object_delete_all_variables (SWFDEC_AS_OBJECT (movie));
- movie->frame = (guint) -1;
- movie->n_frames = 0;
- movie->next_action = 0;
- movie->max_action = 0;
- movie->sprite = NULL;
- swfdec_movie_queue_update (SWFDEC_MOVIE (movie), SWFDEC_MOVIE_INVALID_EXTENTS);
-}
-
-/**
- * swfdec_sprite_movie_get_frames_loaded:
- * @movie: a #SwfdecSpriteMovie
- *
- * Computes the number of loaded frames as used by the _framesloaded property
- * or the WaitForFrame actions. If the @movie is fully loaded, this is the
- * amount of total frames of the sprite it displays, or 0 if it has no sprite.
- * If the movie is not fully loaded, it is the amount of frames that are
- * completely loaded minus one. Welcome to the world of Flash.
- *
- * Returns: The number of loaded frames as reported by ActionScript.
- **/
-int
-swfdec_sprite_movie_get_frames_loaded (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) {
- /* FIXME: can we set n_frames to 1 for movies without sprites instead? */
- if (movie->sprite)
- return movie->n_frames;
- else
- 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;
-}
-
-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) {
- /* FIXME: can we set n_frames to 1 for movies without sprites instead? */
- if (movie->sprite)
- return movie->n_frames;
- else
- 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
deleted file mode 100644
index 093154d..0000000
--- a/libswfdec/swfdec_sprite_movie.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_SPRITE_MOVIE_H_
-#define _SWFDEC_SPRITE_MOVIE_H_
-
-#include <libswfdec/swfdec_movie.h>
-#include <libswfdec/swfdec_audio.h>
-#include <libswfdec/swfdec_types.h>
-
-G_BEGIN_DECLS
-
-
-//typedef struct _SwfdecSpriteMovie SwfdecSpriteMovie;
-typedef struct _SwfdecSpriteMovieClass SwfdecSpriteMovieClass;
-
-#define SWFDEC_TYPE_SPRITE_MOVIE (swfdec_sprite_movie_get_type())
-#define SWFDEC_IS_SPRITE_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SPRITE_MOVIE))
-#define SWFDEC_IS_SPRITE_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SPRITE_MOVIE))
-#define SWFDEC_SPRITE_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SPRITE_MOVIE, SwfdecSpriteMovie))
-#define SWFDEC_SPRITE_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SPRITE_MOVIE, SwfdecSpriteMovieClass))
-
-struct _SwfdecSpriteMovie
-{
- SwfdecMovie movie;
-
- SwfdecSprite * sprite; /* displayed sprite */
-
- /* frame information */
- guint next_action; /* next action in sprite to perform */
- guint max_action; /* next action in sprite tthat has never ben executed (used to detect first-time execution) */
- guint frame; /* current frame or -1 if none */
- guint n_frames; /* amount of frames */
- gboolean playing; /* TRUE if the movie automatically advances */
-
- /* color information */
- SwfdecColor bg_color; /* background color (only used on main sprite) */
-
- /* audio stream handling */
- guint sound_frame; /* current sound frame */
- SwfdecAudio * sound_stream; /* stream that currently plays */
-};
-
-struct _SwfdecSpriteMovieClass
-{
- SwfdecMovieClass movie_class;
-};
-
-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);
-void swfdec_sprite_movie_unload (SwfdecSpriteMovie * movie);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_sprite_movie_as.c b/libswfdec/swfdec_sprite_movie_as.c
deleted file mode 100644
index 03f2a21..0000000
--- a/libswfdec/swfdec_sprite_movie_as.c
+++ /dev/null
@@ -1,891 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_movie.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_bits.h"
-#include "swfdec_debug.h"
-#include "swfdec_decoder.h"
-#include "swfdec_internal.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_sprite.h"
-#include "swfdec_sprite_movie.h"
-#include "swfdec_swf_decoder.h"
-#include "swfdec_resource.h"
-#include "swfdec_utils.h"
-#include "swfdec_as_internal.h"
-
-SWFDEC_AS_NATIVE (900, 200, swfdec_sprite_movie_get_tabIndex)
-void
-swfdec_sprite_movie_get_tabIndex (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.tabIndex (get)");
-}
-
-SWFDEC_AS_NATIVE (900, 201, swfdec_sprite_movie_set_tabIndex)
-void
-swfdec_sprite_movie_set_tabIndex (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.tabIndex (set)");
-}
-
-SWFDEC_AS_NATIVE (900, 300, swfdec_sprite_movie_get__lockroot)
-void
-swfdec_sprite_movie_get__lockroot (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip._lockroot (get)");
-}
-
-SWFDEC_AS_NATIVE (900, 301, swfdec_sprite_movie_set__lockroot)
-void
-swfdec_sprite_movie_set__lockroot (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip._lockroot (set)");
-}
-
-SWFDEC_AS_NATIVE (900, 401, swfdec_sprite_movie_get_cacheAsBitmap)
-void
-swfdec_sprite_movie_get_cacheAsBitmap (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.cacheAsBitmap (get)");
-}
-
-SWFDEC_AS_NATIVE (900, 402, swfdec_sprite_movie_set_cacheAsBitmap)
-void
-swfdec_sprite_movie_set_cacheAsBitmap (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.cacheAsBitmap (set)");
-}
-
-SWFDEC_AS_NATIVE (900, 403, swfdec_sprite_movie_get_opaqueBackground)
-void
-swfdec_sprite_movie_get_opaqueBackground (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.opaqueBackground (get)");
-}
-
-SWFDEC_AS_NATIVE (900, 404, swfdec_sprite_movie_set_opaqueBackground)
-void
-swfdec_sprite_movie_set_opaqueBackground (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.opaqueBackground (set)");
-}
-
-SWFDEC_AS_NATIVE (900, 405, swfdec_sprite_movie_get_scrollRect)
-void
-swfdec_sprite_movie_get_scrollRect (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.scrollRect (get)");
-}
-
-SWFDEC_AS_NATIVE (900, 406, swfdec_sprite_movie_set_scrollRect)
-void
-swfdec_sprite_movie_set_scrollRect (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.scrollRect (set)");
-}
-
-SWFDEC_AS_NATIVE (900, 417, swfdec_sprite_movie_get_filters)
-void
-swfdec_sprite_movie_get_filters (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.filters (get)");
-}
-
-SWFDEC_AS_NATIVE (900, 418, swfdec_sprite_movie_set_filters)
-void
-swfdec_sprite_movie_set_filters (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.filters (set)");
-}
-
-SWFDEC_AS_NATIVE (900, 419, swfdec_sprite_movie_get_transform)
-void
-swfdec_sprite_movie_get_transform (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.transform (get)");
-}
-
-SWFDEC_AS_NATIVE (900, 420, swfdec_sprite_movie_set_transform)
-void
-swfdec_sprite_movie_set_transform (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.transform (set)");
-}
-
-static const char *blend_mode_names[] = {
- SWFDEC_AS_STR_normal,
- SWFDEC_AS_STR_layer,
- SWFDEC_AS_STR_multiply,
- SWFDEC_AS_STR_screen,
- SWFDEC_AS_STR_lighten,
- SWFDEC_AS_STR_darken,
- SWFDEC_AS_STR_difference,
- SWFDEC_AS_STR_add,
- SWFDEC_AS_STR_subtract,
- SWFDEC_AS_STR_invert,
- SWFDEC_AS_STR_alpha,
- SWFDEC_AS_STR_erase,
- SWFDEC_AS_STR_overlay,
- SWFDEC_AS_STR_hardlight
-};
-static const gsize num_blend_mode_names =
- sizeof (blend_mode_names) / sizeof (blend_mode_names[0]);
-
-SWFDEC_AS_NATIVE (900, 500, swfdec_sprite_movie_get_blendMode)
-void
-swfdec_sprite_movie_get_blendMode (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "");
-
- if (movie->blend_mode > 0 && movie->blend_mode <= num_blend_mode_names)
- SWFDEC_AS_VALUE_SET_STRING (rval, blend_mode_names[movie->blend_mode - 1]);
-}
-
-SWFDEC_AS_NATIVE (900, 501, swfdec_sprite_movie_set_blendMode)
-void
-swfdec_sprite_movie_set_blendMode (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
- SwfdecAsValue val;
- const char *str;
- int blend_mode;
- gsize i;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "v", &val);
-
- if (SWFDEC_AS_VALUE_IS_NUMBER (&val)) {
- blend_mode = SWFDEC_AS_VALUE_GET_NUMBER (&val);
- } else if (SWFDEC_AS_VALUE_IS_STRING (&val)) {
- blend_mode = 0;
- str = SWFDEC_AS_VALUE_GET_STRING (&val);
- for (i = 0; i < num_blend_mode_names; i++) {
- if (str == blend_mode_names[i]) { // case-sensitive
- blend_mode = i + 1;
- break;
- }
- }
- } else if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
- blend_mode = 0;
- } else {
- blend_mode = 1;
- }
-
- if ((guint)blend_mode != movie->blend_mode) {
- movie->blend_mode = blend_mode;
- swfdec_movie_invalidate_last (movie);
- }
-}
-
-SWFDEC_AS_NATIVE (900, 2, swfdec_sprite_movie_localToGlobal)
-void
-swfdec_sprite_movie_localToGlobal (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
- SwfdecAsObject *o;
- SwfdecAsValue *xv, *yv;
- double x, y;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "O", &o);
-
- xv = swfdec_as_object_peek_variable (o, SWFDEC_AS_STR_x);
- if (xv == NULL || !SWFDEC_AS_VALUE_IS_NUMBER (xv))
- return;
- yv = swfdec_as_object_peek_variable (o, SWFDEC_AS_STR_y);
- if (yv == NULL || !SWFDEC_AS_VALUE_IS_NUMBER (yv))
- return;
-
- x = SWFDEC_AS_VALUE_GET_NUMBER (xv);
- y = SWFDEC_AS_VALUE_GET_NUMBER (yv);
- x = swfdec_as_double_to_integer (x * SWFDEC_TWIPS_SCALE_FACTOR);
- y = swfdec_as_double_to_integer (y * SWFDEC_TWIPS_SCALE_FACTOR);
- swfdec_movie_local_to_global (movie, &x, &y);
- SWFDEC_AS_VALUE_SET_NUMBER (xv, SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) x));
- SWFDEC_AS_VALUE_SET_NUMBER (yv, SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) y));
-}
-
-SWFDEC_AS_NATIVE (900, 3, swfdec_sprite_movie_globalToLocal)
-void
-swfdec_sprite_movie_globalToLocal (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
- SwfdecAsObject *o;
- SwfdecAsValue *xv, *yv;
- double x, y;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "O", &o);
-
- xv = swfdec_as_object_peek_variable (o, SWFDEC_AS_STR_x);
- if (xv == NULL || !SWFDEC_AS_VALUE_IS_NUMBER (xv))
- return;
- yv = swfdec_as_object_peek_variable (o, SWFDEC_AS_STR_y);
- if (yv == NULL || !SWFDEC_AS_VALUE_IS_NUMBER (yv))
- return;
-
- x = SWFDEC_AS_VALUE_GET_NUMBER (xv);
- y = SWFDEC_AS_VALUE_GET_NUMBER (yv);
- x = swfdec_as_double_to_integer (x * SWFDEC_TWIPS_SCALE_FACTOR);
- y = swfdec_as_double_to_integer (y * SWFDEC_TWIPS_SCALE_FACTOR);
- swfdec_movie_global_to_local (movie, &x, &y);
- SWFDEC_AS_VALUE_SET_NUMBER (xv, SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) x));
- SWFDEC_AS_VALUE_SET_NUMBER (yv, SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) y));
-}
-
-SWFDEC_AS_NATIVE (900, 8, swfdec_sprite_movie_attachAudio)
-void
-swfdec_sprite_movie_attachAudio (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.attachAudio");
-}
-
-SWFDEC_AS_NATIVE (900, 9, swfdec_sprite_movie_attachVideo)
-void
-swfdec_sprite_movie_attachVideo (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.attachVideo");
-}
-
-SWFDEC_AS_NATIVE (900, 23, swfdec_sprite_movie_getInstanceAtDepth)
-void
-swfdec_sprite_movie_getInstanceAtDepth (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
- int depth;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "i", &depth);
-
- // special case
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
- return;
-
- movie = swfdec_movie_find (movie, depth);
- if (movie != NULL)
- SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (movie));
-}
-
-SWFDEC_AS_NATIVE (900, 24, swfdec_sprite_movie_getSWFVersion)
-void
-swfdec_sprite_movie_getSWFVersion (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- if (object != NULL && SWFDEC_IS_MOVIE (object)) {
- SWFDEC_AS_VALUE_SET_INT (rval,
- swfdec_movie_get_version (SWFDEC_MOVIE (object)));
- } else {
- SWFDEC_AS_VALUE_SET_INT (rval, -1);
- }
-}
-
-SWFDEC_AS_NATIVE (900, 25, swfdec_sprite_movie_attachBitmap)
-void
-swfdec_sprite_movie_attachBitmap (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.attachBitmap");
-}
-
-SWFDEC_AS_NATIVE (900, 26, swfdec_sprite_movie_getRect)
-void
-swfdec_sprite_movie_getRect (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("MovieClip.getRect");
-}
-
-SWFDEC_AS_NATIVE (900, 12, swfdec_sprite_movie_play)
-void
-swfdec_sprite_movie_play (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecSpriteMovie *movie;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_SPRITE_MOVIE, (gpointer)&movie, "");
-
- movie->playing = TRUE;
-}
-
-SWFDEC_AS_NATIVE (900, 13, swfdec_sprite_movie_stop)
-void
-swfdec_sprite_movie_stop (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecSpriteMovie *movie;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_SPRITE_MOVIE, (gpointer)&movie, "");
-
- movie->playing = FALSE;
-}
-
-SWFDEC_AS_NATIVE (900, 7, swfdec_sprite_movie_getBytesLoaded)
-void
-swfdec_sprite_movie_getBytesLoaded (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
- SwfdecResource *resource;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
-
- resource = swfdec_movie_get_own_resource (movie);
- if (resource && resource->decoder) {
- SWFDEC_AS_VALUE_SET_INT (rval, resource->decoder->bytes_loaded);
- } else {
- SWFDEC_AS_VALUE_SET_INT (rval, 0);
- }
-}
-
-SWFDEC_AS_NATIVE (900, 6, swfdec_sprite_movie_getBytesTotal)
-void
-swfdec_sprite_movie_getBytesTotal (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
- SwfdecResource *resource;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
-
- resource = swfdec_movie_get_own_resource (movie);
- if (resource) {
- if (resource->decoder) {
- SWFDEC_AS_VALUE_SET_INT (rval, resource->decoder->bytes_total);
- } else {
- SWFDEC_AS_VALUE_SET_INT (rval, -1);
- }
- } else {
- SWFDEC_AS_VALUE_SET_INT (rval, 0);
- }
-}
-
-SWFDEC_AS_NATIVE (900, 22, swfdec_sprite_movie_getNextHighestDepth)
-void
-swfdec_sprite_movie_getNextHighestDepth (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
- int depth;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
-
- if (movie->list) {
- depth = SWFDEC_MOVIE (g_list_last (movie->list)->data)->depth + 1;
- if (depth < 0)
- depth = 0;
- } else {
- depth = 0;
- }
- SWFDEC_AS_VALUE_SET_INT (rval, depth);
-}
-
-static void
-swfdec_sprite_movie_do_goto (SwfdecSpriteMovie *movie, SwfdecAsValue *target)
-{
- int frame;
-
- g_return_if_fail (SWFDEC_IS_SPRITE_MOVIE (movie));
- g_return_if_fail (SWFDEC_IS_AS_VALUE (target));
-
- if (SWFDEC_AS_VALUE_IS_STRING (target)) {
- const char *label = SWFDEC_AS_VALUE_GET_STRING (target);
- frame = swfdec_sprite_get_frame (movie->sprite, label);
- /* FIXME: nonexisting frames? */
- if (frame == -1)
- return;
- frame++;
- } else {
- frame = swfdec_as_value_to_integer (SWFDEC_AS_OBJECT (movie)->context, target);
- }
- /* FIXME: how to handle overflow? */
- frame = CLAMP (frame, 1, (int) movie->n_frames);
-
- swfdec_sprite_movie_goto (movie, frame);
-}
-
-SWFDEC_AS_NATIVE (900, 16, swfdec_sprite_movie_gotoAndPlay)
-void
-swfdec_sprite_movie_gotoAndPlay (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecSpriteMovie *movie;
- SwfdecAsValue val;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_SPRITE_MOVIE, (gpointer)&movie, "v", &val);
-
- swfdec_sprite_movie_do_goto (movie, &val);
- movie->playing = TRUE;
-}
-
-SWFDEC_AS_NATIVE (900, 17, swfdec_sprite_movie_gotoAndStop)
-void
-swfdec_sprite_movie_gotoAndStop (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecSpriteMovie *movie;
- SwfdecAsValue val;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_SPRITE_MOVIE, (gpointer)&movie, "v", &val);
-
- swfdec_sprite_movie_do_goto (movie, &val);
- movie->playing = FALSE;
-}
-
-SWFDEC_AS_NATIVE (900, 14, swfdec_sprite_movie_nextFrame)
-void
-swfdec_sprite_movie_nextFrame (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecSpriteMovie *movie;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_SPRITE_MOVIE, (gpointer)&movie, "");
-
- swfdec_sprite_movie_goto (movie, movie->frame + 1);
- movie->playing = FALSE;
-}
-
-SWFDEC_AS_NATIVE (900, 15, swfdec_sprite_movie_prevFrame)
-void
-swfdec_sprite_movie_prevFrame (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecSpriteMovie *movie;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_SPRITE_MOVIE, (gpointer)&movie, "");
-
- swfdec_sprite_movie_goto (movie, movie->frame - 1);
- movie->playing = FALSE;
-}
-
-SWFDEC_AS_NATIVE (900, 4, swfdec_sprite_movie_hitTest)
-void
-swfdec_sprite_movie_hitTest (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
-
- if (argc == 1) {
- SwfdecMovie *other;
- SwfdecRect movie_rect, other_rect;
-
- other = swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx), &argv[0]);
- if (other == NULL) {
- SWFDEC_AS_VALUE_SET_BOOLEAN (rval, FALSE);
- return;
- }
- swfdec_movie_update (movie);
- swfdec_movie_update (other);
- movie_rect = movie->extents;
- if (movie->parent)
- swfdec_movie_rect_local_to_global (movie->parent, &movie_rect);
- other_rect = other->extents;
- if (other->parent)
- swfdec_movie_rect_local_to_global (other->parent, &other_rect);
- SWFDEC_AS_VALUE_SET_BOOLEAN (rval, swfdec_rect_intersect (NULL, &movie_rect, &other_rect));
- } else if (argc >= 2) {
- double x, y;
- gboolean shape, ret;
-
- x = swfdec_as_value_to_number (cx, &argv[0]) * SWFDEC_TWIPS_SCALE_FACTOR;
- y = swfdec_as_value_to_number (cx, &argv[1]) * SWFDEC_TWIPS_SCALE_FACTOR;
- shape = (argc >= 3 && swfdec_as_value_to_boolean (cx, &argv[2]));
-
- swfdec_movie_global_to_local (movie, &x, &y);
-
- if (shape) {
- ret = swfdec_movie_contains (movie, x, y);
- } else {
- ret = swfdec_rect_contains (&movie->original_extents, x, y);
- }
- SWFDEC_AS_VALUE_SET_BOOLEAN (rval, ret);
- }
-}
-
-SWFDEC_AS_NATIVE (900, 20, swfdec_sprite_movie_startDrag)
-void
-swfdec_sprite_movie_startDrag (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
- gboolean center = FALSE;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
-
- if (argc > 0) {
- center = swfdec_as_value_to_boolean (cx, &argv[0]);
- }
- if (argc >= 5) {
- SwfdecRect rect;
- rect.x0 = swfdec_as_value_to_number (cx, &argv[1]);
- rect.y0 = swfdec_as_value_to_number (cx, &argv[2]);
- rect.x1 = swfdec_as_value_to_number (cx, &argv[3]);
- rect.y1 = swfdec_as_value_to_number (cx, &argv[4]);
- swfdec_rect_scale (&rect, &rect, SWFDEC_TWIPS_SCALE_FACTOR);
- swfdec_player_set_drag_movie (player, movie, center, &rect);
- } else {
- swfdec_player_set_drag_movie (player, movie, center, NULL);
- }
-}
-
-SWFDEC_AS_NATIVE (900, 21, swfdec_sprite_movie_stopDrag)
-void
-swfdec_sprite_movie_stopDrag (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- // FIXME: Should this work when called on non-movie objects or not?
-
- swfdec_player_set_drag_movie (SWFDEC_PLAYER (cx), NULL, FALSE, NULL);
-}
-
-SWFDEC_AS_NATIVE (900, 1, swfdec_sprite_movie_swapDepths)
-void
-swfdec_sprite_movie_swapDepths (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
- SwfdecMovie *other;
- int depth;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
-
- if (argc < 1)
- return;
-
- if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[0])) {
- other = (SwfdecMovie *) SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
- if (!SWFDEC_IS_MOVIE (other) ||
- other->parent != movie->parent)
- return;
- depth = other->depth;
- } else {
- depth = swfdec_as_value_to_integer (cx, &argv[0]);
- if (movie->parent) {
- other = swfdec_movie_find (movie->parent, depth);
- } else {
- // special case: if root movie: we won't swap just, but just set depth
- other = NULL;
- }
- }
- if (other)
- swfdec_movie_set_depth (other, movie->depth);
- swfdec_movie_set_depth (movie, depth);
-}
-
-SWFDEC_AS_NATIVE (901, 0, swfdec_sprite_movie_createEmptyMovieClip)
-void
-swfdec_sprite_movie_createEmptyMovieClip (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie, *parent;
- int depth;
- const char *name;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &parent, "si", &name, &depth);
-
- movie = swfdec_movie_find (parent, depth);
- if (movie)
- swfdec_movie_remove (movie);
- movie = swfdec_movie_new (SWFDEC_PLAYER (cx), depth, parent, parent->resource, NULL, name);
- swfdec_movie_initialize (movie);
- SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (movie));
-}
-
-static void
-swfdec_sprite_movie_copy_props (SwfdecMovie *target, SwfdecMovie *src)
-{
- swfdec_movie_queue_update (target, SWFDEC_MOVIE_INVALID_MATRIX);
- target->matrix = src->matrix;
- target->color_transform = src->color_transform;
-}
-
-static gboolean
-swfdec_sprite_movie_foreach_copy_properties (SwfdecAsObject *object,
- const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
-{
- SwfdecAsObject *target = data;
-
- g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (target), FALSE);
-
- swfdec_as_object_set_variable (target, variable, value);
-
- return TRUE;
-}
-
-static void
-swfdec_sprite_movie_init_from_object (SwfdecMovie *movie,
- SwfdecAsObject *initObject)
-{
- g_return_if_fail (SWFDEC_IS_MOVIE (movie));
- g_return_if_fail (initObject == NULL || SWFDEC_IS_AS_OBJECT (initObject));
-
- if (initObject != NULL) {
- swfdec_as_object_foreach (initObject,
- swfdec_sprite_movie_foreach_copy_properties, SWFDEC_AS_OBJECT (movie));
- }
-
- if (SWFDEC_IS_SPRITE_MOVIE (movie)) {
- SwfdecSandbox *sandbox = movie->resource->sandbox;
- swfdec_movie_queue_script (movie, SWFDEC_EVENT_INITIALIZE);
- swfdec_movie_queue_script (movie, SWFDEC_EVENT_LOAD);
- swfdec_sandbox_unuse (sandbox);
- swfdec_movie_initialize (movie);
- swfdec_movie_execute (movie, SWFDEC_EVENT_CONSTRUCT);
- swfdec_sandbox_use (sandbox);
- } else {
- swfdec_movie_initialize (movie);
- }
-}
-
-SWFDEC_AS_NATIVE (900, 0, swfdec_sprite_movie_attachMovie)
-void
-swfdec_sprite_movie_attachMovie (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
- SwfdecMovie *ret;
- SwfdecAsObject *initObject;
- const char *name, *export;
- int depth;
- SwfdecGraphic *sprite;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "ssi", &export, &name, &depth);
-
- if (argc > 3 && SWFDEC_AS_VALUE_IS_OBJECT (&argv[3])) {
- initObject = SWFDEC_AS_VALUE_GET_OBJECT ((&argv[3]));
- } else {
- initObject = NULL;
- }
- sprite = swfdec_resource_get_export (movie->resource, export);
- if (!SWFDEC_IS_SPRITE (sprite)) {
- if (sprite == NULL) {
- SWFDEC_WARNING ("no symbol with name %s exported", export);
- } else {
- SWFDEC_WARNING ("can only use attachMovie with sprites");
- }
- return;
- }
- if (swfdec_depth_classify (depth) == SWFDEC_DEPTH_CLASS_EMPTY)
- return;
- ret = swfdec_movie_find (movie, depth);
- if (ret)
- swfdec_movie_remove (ret);
- ret = swfdec_movie_new (SWFDEC_PLAYER (object->context), depth, movie, movie->resource, sprite, name);
- SWFDEC_LOG ("attached %s (%u) as %s to depth %u", export, SWFDEC_CHARACTER (sprite)->id,
- ret->name, ret->depth);
- /* run init and construct */
- swfdec_sprite_movie_init_from_object (ret, initObject);
- SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (ret));
-}
-
-SWFDEC_AS_NATIVE (900, 18, swfdec_sprite_movie_duplicateMovieClip)
-void
-swfdec_sprite_movie_duplicateMovieClip (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
- SwfdecMovie *new;
- const char *name;
- int depth;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "si", &name, &depth);
-
- if (swfdec_depth_classify (depth) == SWFDEC_DEPTH_CLASS_EMPTY)
- return;
- new = swfdec_movie_duplicate (movie, name, depth);
- if (new == NULL)
- return;
- swfdec_sprite_movie_copy_props (new, movie);
- SWFDEC_LOG ("duplicated %s as %s to depth %u", movie->name, new->name, new->depth);
- SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (new));
-}
-
-SWFDEC_AS_NATIVE (900, 19, swfdec_sprite_movie_removeMovieClip)
-void
-swfdec_sprite_movie_removeMovieClip (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
-
- if (swfdec_depth_classify (movie->depth) == SWFDEC_DEPTH_CLASS_DYNAMIC)
- swfdec_movie_remove (movie);
-}
-
-SWFDEC_AS_NATIVE (900, 10, swfdec_sprite_movie_getDepth)
-void
-swfdec_sprite_movie_getDepth (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
-
- SWFDEC_AS_VALUE_SET_INT (rval, movie->depth);
-}
-
-SWFDEC_AS_NATIVE (900, 5, swfdec_sprite_movie_getBounds)
-void
-swfdec_sprite_movie_getBounds (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- int x0, x1, y0, y1;
- SwfdecAsValue val;
- SwfdecAsObject *obj;
- SwfdecMovie *movie;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
-
- obj= swfdec_as_object_new_empty (cx);
- if (obj== NULL)
- return;
-
- swfdec_movie_update (movie);
- if (swfdec_rect_is_empty (&movie->extents)) {
- x0 = x1 = y0 = y1 = 0x7FFFFFF;
- } else {
- SwfdecRect rect = movie->extents;
- SwfdecMovie *other;
-
- if (argc > 0) {
- other =
- swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx), &argv[0]);
- if (!other)
- return;
- } else {
- other = movie;
- }
-
- if (movie->parent)
- swfdec_movie_rect_local_to_global (movie->parent, &rect);
- swfdec_movie_rect_global_to_local ((other != NULL ? other : movie), &rect);
-
- x0 = rect.x0;
- y0 = rect.y0;
- x1 = rect.x1;
- y1 = rect.y1;
- }
- SWFDEC_AS_VALUE_SET_NUMBER (&val, SWFDEC_TWIPS_TO_DOUBLE (x0));
- swfdec_as_object_set_variable (obj, SWFDEC_AS_STR_xMin, &val);
- SWFDEC_AS_VALUE_SET_NUMBER (&val, SWFDEC_TWIPS_TO_DOUBLE (y0));
- swfdec_as_object_set_variable (obj, SWFDEC_AS_STR_yMin, &val);
- SWFDEC_AS_VALUE_SET_NUMBER (&val, SWFDEC_TWIPS_TO_DOUBLE (x1));
- swfdec_as_object_set_variable (obj, SWFDEC_AS_STR_xMax, &val);
- SWFDEC_AS_VALUE_SET_NUMBER (&val, SWFDEC_TWIPS_TO_DOUBLE (y1));
- swfdec_as_object_set_variable (obj, SWFDEC_AS_STR_yMax, &val);
-
- SWFDEC_AS_VALUE_SET_OBJECT (rval, obj);
-}
-
-SWFDEC_AS_NATIVE (900, 11, swfdec_sprite_movie_setMask)
-void
-swfdec_sprite_movie_setMask (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecMovie *movie, *mask;
-
- /* yes, this works with regular movies */
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "O", &mask);
-
- if (mask != NULL && !SWFDEC_IS_MOVIE (mask)) {
- SWFDEC_FIXME ("mask is not a movie, what now?");
- mask = NULL;
- }
- if (movie->masked_by)
- movie->masked_by->mask_of = NULL;
- if (movie->mask_of)
- movie->mask_of->masked_by = NULL;
- movie->masked_by = mask;
- movie->mask_of = NULL;
- if (movie->clip_depth) {
- g_assert (movie->parent);
- swfdec_movie_invalidate_last (movie->parent);
- movie->clip_depth = 0;
- } else {
- swfdec_movie_invalidate_last (movie);
- }
- if (mask) {
- if (mask->masked_by)
- mask->masked_by->mask_of = NULL;
- if (mask->mask_of)
- mask->mask_of->masked_by = NULL;
- mask->masked_by = NULL;
- mask->mask_of = movie;
- swfdec_movie_invalidate_last (mask);
- if (mask->clip_depth) {
- g_assert (mask->parent);
- swfdec_movie_invalidate_last (mask->parent);
- mask->clip_depth = 0;
- } else {
- swfdec_movie_invalidate_last (mask);
- }
- }
-}
-
-void
-swfdec_sprite_movie_init_context (SwfdecPlayer *player)
-{
- SwfdecAsContext *context = SWFDEC_AS_CONTEXT (player);
- SwfdecAsValue val;
- SwfdecAsObject *proto, *movie;
-
- movie = SWFDEC_AS_OBJECT (swfdec_as_object_add_function (context->global,
- SWFDEC_AS_STR_MovieClip, 0, NULL, 0));
- if (movie == NULL)
- return;
- SWFDEC_SANDBOX (context->global)->MovieClip = movie;
- proto = swfdec_as_object_new (context);
- if (!proto)
- return;
- SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
- swfdec_as_object_set_variable_and_flags (movie,
- SWFDEC_AS_STR_prototype, &val, SWFDEC_AS_VARIABLE_HIDDEN |
- SWFDEC_AS_VARIABLE_PERMANENT);
-};
diff --git a/libswfdec/swfdec_stage_as.c b/libswfdec/swfdec_stage_as.c
deleted file mode 100644
index 87ced97..0000000
--- a/libswfdec/swfdec_stage_as.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include "swfdec_as_internal.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-#include "swfdec_player_internal.h"
-
-/*** AS CODE ***/
-
-SWFDEC_AS_NATIVE (666, 1, get_scaleMode)
-void
-get_scaleMode (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
-
- switch (player->priv->scale_mode) {
- case SWFDEC_SCALE_SHOW_ALL:
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_showAll);
- break;
- case SWFDEC_SCALE_NO_BORDER:
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_noBorder);
- break;
- case SWFDEC_SCALE_EXACT_FIT:
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_exactFit);
- break;
- case SWFDEC_SCALE_NONE:
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_noScale);
- break;
- default:
- g_assert_not_reached ();
- break;
- }
-}
-
-SWFDEC_AS_NATIVE (666, 2, set_scaleMode)
-void
-set_scaleMode (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
- const char *s;
- SwfdecScaleMode mode;
-
- if (argc == 0)
- return;
- s = swfdec_as_value_to_string (cx, &argv[0]);
- if (g_ascii_strcasecmp (s, SWFDEC_AS_STR_noBorder) == 0) {
- mode = SWFDEC_SCALE_NO_BORDER;
- } else if (g_ascii_strcasecmp (s, SWFDEC_AS_STR_exactFit) == 0) {
- mode = SWFDEC_SCALE_EXACT_FIT;
- } else if (g_ascii_strcasecmp (s, SWFDEC_AS_STR_noScale) == 0) {
- mode = SWFDEC_SCALE_NONE;
- } else {
- mode = SWFDEC_SCALE_SHOW_ALL;
- }
- swfdec_player_set_scale_mode (player, mode);
-}
-
-SWFDEC_AS_NATIVE (666, 3, get_align)
-void
-get_align (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
- SwfdecPlayerPrivate *priv = player->priv;
- char s[5];
- guint i = 0;
-
- if (priv->align_flags & SWFDEC_ALIGN_FLAG_LEFT)
- s[i++] = 'L';
- if (priv->align_flags & SWFDEC_ALIGN_FLAG_TOP)
- s[i++] = 'T';
- if (priv->align_flags & SWFDEC_ALIGN_FLAG_RIGHT)
- s[i++] = 'R';
- if (priv->align_flags & SWFDEC_ALIGN_FLAG_BOTTOM)
- s[i++] = 'B';
- s[i] = 0;
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (cx, s));
-}
-
-SWFDEC_AS_NATIVE (666, 4, set_align)
-void
-set_align (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
- guint flags = 0;
- const char *s;
-
- if (argc == 0)
- return;
-
- s = swfdec_as_value_to_string (cx, &argv[0]);
- if (strchr (s, 'l') || strchr (s, 'L'))
- flags |= SWFDEC_ALIGN_FLAG_LEFT;
- if (strchr (s, 't') || strchr (s, 'T'))
- flags |= SWFDEC_ALIGN_FLAG_TOP;
- if (strchr (s, 'r') || strchr (s, 'R'))
- flags |= SWFDEC_ALIGN_FLAG_RIGHT;
- if (strchr (s, 'b') || strchr (s, 'B'))
- flags |= SWFDEC_ALIGN_FLAG_BOTTOM;
-
- if (flags != player->priv->align_flags) {
- player->priv->align_flags = flags;
- g_object_notify (G_OBJECT (player), "alignment");
- swfdec_player_update_scale (player);
- }
-}
-
-SWFDEC_AS_NATIVE (666, 5, get_width)
-void
-get_width (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
-
- SWFDEC_AS_VALUE_SET_INT (ret, player->priv->internal_width);
-}
-
-SWFDEC_AS_NATIVE (666, 7, get_height)
-void
-get_height (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
-
- SWFDEC_AS_VALUE_SET_INT (ret, player->priv->internal_height);
-}
-
-/* FIXME: do this smarter */
-SWFDEC_AS_NATIVE (666, 6, set_width)
-void
-set_width (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
-}
-
-SWFDEC_AS_NATIVE (666, 8, set_height)
-void
-set_height (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
-}
-
-SWFDEC_AS_NATIVE (666, 9, swfdec_stage_get_showMenu)
-void
-swfdec_stage_get_showMenu (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Stage.showMenu (get)");
-}
-
-SWFDEC_AS_NATIVE (666, 10, swfdec_stage_set_showMenu)
-void
-swfdec_stage_set_showMenu (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Stage.showMenu (set)");
-}
-
-SWFDEC_AS_NATIVE (666, 11, swfdec_stage_get_displayState)
-void
-swfdec_stage_get_displayState (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Stage.displayState (get)");
-}
-
-SWFDEC_AS_NATIVE (666, 12, swfdec_stage_set_displayState)
-void
-swfdec_stage_set_displayState (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Stage.displayState (set)");
-}
-
-SWFDEC_AS_NATIVE (666, 100, swfdec_stage_get_fullScreenSourceRect)
-void
-swfdec_stage_get_fullScreenSourceRect (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Stage.fullScreenSourceRect (get)");
-}
-
-SWFDEC_AS_NATIVE (666, 101, swfdec_stage_set_fullScreenSourceRect)
-void
-swfdec_stage_set_fullScreenSourceRect (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Stage.fullScreenSourceRect (set)");
-}
-
-SWFDEC_AS_NATIVE (666, 102, swfdec_stage_get_fullScreenHeight)
-void
-swfdec_stage_get_fullScreenHeight (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Stage.fullScreenHeight (get)");
-}
-
-SWFDEC_AS_NATIVE (666, 103, swfdec_stage_set_fullScreenHeight)
-void
-swfdec_stage_set_fullScreenHeight (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Stage.fullScreenHeight (set)");
-}
-
-SWFDEC_AS_NATIVE (666, 104, swfdec_stage_get_fullScreenWidth)
-void
-swfdec_stage_get_fullScreenWidth (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Stage.fullScreenWidth (get)");
-}
-
-SWFDEC_AS_NATIVE (666, 105, swfdec_stage_set_fullScreenWidth)
-void
-swfdec_stage_set_fullScreenWidth (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Stage.fullScreenWidth (set)");
-}
diff --git a/libswfdec/swfdec_stream.c b/libswfdec/swfdec_stream.c
deleted file mode 100644
index 11be333..0000000
--- a/libswfdec/swfdec_stream.c
+++ /dev/null
@@ -1,427 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2008 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include "swfdec_loader_internal.h"
-#include "swfdec_buffer.h"
-#include "swfdec_debug.h"
-#include "swfdec_stream_target.h"
-#include "swfdec_player_internal.h"
-
-/*** gtk-doc ***/
-
-/**
- * SECTION:SwfdecStream
- * @title: SwfdecStream
- * @short_description: object used for input
- *
- * SwfdecStream is the base class used for communication inside Swfdec. If you
- * are a UNIX developer, think of this class as the equivalent to a file
- * descriptor. #SwfdecLoader and #SwfdecSocket are the subclasses supposed to
- * be used for files or network sockets, respectively.
- *
- * This class provides the functions necessary to implement subclasses of
- * streams. None of the functions described in this section should be used by
- * anything but subclass implementations. Consider them "protected".
- */
-
-/**
- * SwfdecStream:
- *
- * This is the base object used for providing input. It is abstract, use a
- * subclass to provide your input. All members are considered private.
- */
-
-/**
- * SwfdecStreamClass:
- * @describe: Provide a string describing your string. Default implementations
- * of this function exist for both the #SwfdecLoader and
- * #SwfdecStream subclasses. They return the URL for the stream.
- * @close: Called when Swfdec requests that the stream be closed. After this
- * function was called, Swfdec will consider the stream finished and
- * will not ever read data from it again.
- *
- * This is the base class used for providing input. You are supposed to create
- * a subclass that fills in the function pointers mentioned above.
- */
-
-/*** SwfdecStream ***/
-
-typedef enum {
- SWFDEC_STREAM_STATE_CONNECTING = 0, /* stream is still in the process of establishing a connection */
- SWFDEC_STREAM_STATE_OPEN, /* stream is open and data flow is happening */
- SWFDEC_STREAM_STATE_CLOSED, /* loader has been closed */
- SWFDEC_STREAM_STATE_ERROR /* loader is in error state */
-} SwfdecStreamState;
-
-struct _SwfdecStreamPrivate
-{
- SwfdecPlayer * player; /* player to queue target notificaions in */
- SwfdecStreamTarget * target; /* SwfdecStreamTarget that gets notified about loading progress */
- SwfdecStreamState state; /* SwfdecStreamState the stream is currently in */
- SwfdecStreamState processed_state;/* SwfdecStreamState the target knows about */
- gboolean queued; /* TRUE if we have queued an action already */
- char * error; /* error message if in error state or NULL */
- SwfdecBufferQueue * queue; /* SwfdecBufferQueue managing the input buffers */
-};
-
-enum {
- PROP_0,
- PROP_ERROR,
- PROP_OPEN,
- PROP_EOF
-};
-
-G_DEFINE_ABSTRACT_TYPE (SwfdecStream, swfdec_stream, G_TYPE_OBJECT)
-
-static void
-swfdec_stream_get_property (GObject *object, guint param_id, GValue *value,
- GParamSpec * pspec)
-{
- SwfdecStreamPrivate *stream = SWFDEC_STREAM (object)->priv;
-
- switch (param_id) {
- case PROP_ERROR:
- g_value_set_string (value, stream->error);
- break;
- case PROP_OPEN:
- g_value_set_boolean (value, stream->state == SWFDEC_STREAM_STATE_OPEN);
- break;
- case PROP_EOF:
- g_value_set_boolean (value, stream->state == SWFDEC_STREAM_STATE_CLOSED);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-swfdec_stream_set_property (GObject *object, guint param_id, const GValue *value,
- GParamSpec *pspec)
-{
- //SwfdecStream *stream = SWFDEC_STREAM (object);
-
- switch (param_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-swfdec_stream_dispose (GObject *object)
-{
- SwfdecStreamPrivate *stream = SWFDEC_STREAM (object)->priv;
-
- /* targets are supposed to keep a reference around */
- g_assert (stream->target == NULL);
- if (stream->queue) {
- swfdec_buffer_queue_unref (stream->queue);
- stream->queue = NULL;
- }
- g_free (stream->error);
- stream->error = NULL;
-
- G_OBJECT_CLASS (swfdec_stream_parent_class)->dispose (object);
-}
-
-static void
-swfdec_stream_class_init (SwfdecStreamClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (SwfdecStreamPrivate));
-
- object_class->dispose = swfdec_stream_dispose;
- object_class->get_property = swfdec_stream_get_property;
- object_class->set_property = swfdec_stream_set_property;
-
- g_object_class_install_property (object_class, PROP_ERROR,
- g_param_spec_string ("error", "error", "NULL when no error or string describing error",
- NULL, G_PARAM_READABLE));
- g_object_class_install_property (object_class, PROP_OPEN,
- g_param_spec_boolean ("open", "open", "TRUE while data is flowing",
- FALSE, G_PARAM_READABLE));
- g_object_class_install_property (object_class, PROP_EOF,
- g_param_spec_boolean ("eof", "eof", "TRUE when all data has been transmitted",
- FALSE, G_PARAM_READABLE));
-}
-
-static void
-swfdec_stream_init (SwfdecStream *stream)
-{
- SwfdecStreamPrivate *priv;
-
- stream->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (stream, SWFDEC_TYPE_STREAM, SwfdecStreamPrivate);
-
- priv->queue = swfdec_buffer_queue_new ();
-}
-
-/*** INTERNAL API ***/
-
-SwfdecBufferQueue *
-swfdec_stream_get_queue (SwfdecStream *stream)
-{
- g_return_val_if_fail (SWFDEC_IS_STREAM (stream), NULL);
-
- return stream->priv->queue;
-}
-
-static void
-swfdec_stream_process (gpointer streamp, gpointer unused)
-{
- SwfdecStream *stream = streamp;
- SwfdecStreamPrivate *priv = stream->priv;
-
- g_assert (priv->target != NULL);
-
- priv->queued = FALSE;
- if (priv->state == priv->processed_state &&
- priv->state != SWFDEC_STREAM_STATE_OPEN)
- return;
- g_assert (priv->processed_state != SWFDEC_STREAM_STATE_CLOSED);
- g_object_ref (stream);
- if (priv->state == SWFDEC_STREAM_STATE_ERROR) {
- swfdec_stream_target_error (priv->target, stream);
- } else {
- while (priv->state != priv->processed_state) {
- if (priv->processed_state == SWFDEC_STREAM_STATE_CONNECTING) {
- priv->processed_state = SWFDEC_STREAM_STATE_OPEN;
- swfdec_stream_target_open (priv->target, stream);
- } else if (priv->processed_state == SWFDEC_STREAM_STATE_OPEN) {
- swfdec_stream_target_parse (priv->target, stream);
- priv->processed_state = SWFDEC_STREAM_STATE_CLOSED;
- swfdec_stream_target_close (priv->target, stream);
- }
- }
- if (priv->processed_state == SWFDEC_STREAM_STATE_OPEN) {
- swfdec_stream_target_parse (priv->target, stream);
- }
- }
- g_object_unref (stream);
-}
-
-static void
-swfdec_stream_queue_processing (SwfdecStream *stream)
-{
- SwfdecStreamPrivate *priv = stream->priv;
-
- if (priv->queued)
- return;
- priv->queued = TRUE;
- if (priv->target) {
- g_assert (priv->player);
- swfdec_player_add_external_action (priv->player, stream,
- swfdec_stream_process, NULL);
- }
-}
-
-void
-swfdec_stream_close (SwfdecStream *stream)
-{
- SwfdecStreamPrivate *priv;
- SwfdecStreamClass *klass;
-
- g_return_if_fail (SWFDEC_IS_STREAM (stream));
-
- priv = stream->priv;
- if (priv->state == SWFDEC_STREAM_STATE_ERROR &&
- priv->state == SWFDEC_STREAM_STATE_CLOSED)
- return;
-
- klass = SWFDEC_STREAM_GET_CLASS (stream);
-
- if (klass->close)
- klass->close (stream);
- priv->state = SWFDEC_STREAM_STATE_CLOSED;
- priv->processed_state = SWFDEC_STREAM_STATE_CLOSED;
-}
-
-void
-swfdec_stream_set_target (SwfdecStream *stream, SwfdecStreamTarget *target)
-{
- SwfdecStreamPrivate *priv;
-
- g_return_if_fail (SWFDEC_IS_STREAM (stream));
- if (target != NULL) {
- g_return_if_fail (stream->priv->processed_state == SWFDEC_STREAM_STATE_CONNECTING);
- g_return_if_fail (SWFDEC_IS_STREAM_TARGET (target));
- }
-
- priv = stream->priv;
- if (priv->target) {
- swfdec_player_remove_all_external_actions (priv->player, stream);
- }
- priv->queued = FALSE;
- priv->target = target;
- if (target) {
- priv->player = swfdec_stream_target_get_player (target);
- if (priv->state != SWFDEC_STREAM_STATE_CONNECTING)
- swfdec_stream_queue_processing (stream);
- } else {
- priv->player = NULL;
- }
-}
-
-/** PUBLIC API ***/
-
-/**
- * swfdec_stream_describe:
- * @stream: a #SwfdecStream
- *
- * Describes the stream in a simple string. This is mostly useful for debugging
- * purposes.
- *
- * Returns: a constant string describing the stream
- **/
-const char *
-swfdec_stream_describe (SwfdecStream *stream)
-{
- SwfdecStreamClass *klass;
-
- g_return_val_if_fail (SWFDEC_IS_STREAM (stream), NULL);
-
- klass = SWFDEC_STREAM_GET_CLASS (stream);
- g_return_val_if_fail (klass->describe, NULL);
-
- return klass->describe (stream);
-}
-
-/**
- * swfdec_stream_error:
- * @stream: a #SwfdecStream
- * @error: a printf-style string describing the error
- * @...: arguments for the @error string
- *
- * Moves the stream in the error state if it wasn't before. A stream that is in
- * the error state will not process any more data. Also, internal error
- * handling scripts may be executed.
- **/
-void
-swfdec_stream_error (SwfdecStream *stream, const char *error, ...)
-{
- va_list args;
-
- g_return_if_fail (SWFDEC_IS_STREAM (stream));
- g_return_if_fail (error != NULL);
-
- va_start (args, error);
- swfdec_stream_errorv (stream, error, args);
- va_end (args);
-}
-
-/**
- * swfdec_stream_errorv:
- * @stream: a #SwfdecStream
- * @error: a printf-style error string
- * @args: arguments for @error
- *
- * This function is the va_list alternative to swfdec_stream_error(). See that
- * function for details.
- **/
-void
-swfdec_stream_errorv (SwfdecStream *stream, const char *error, va_list args)
-{
- SwfdecStreamPrivate *priv;
- char *real_error;
-
- g_return_if_fail (SWFDEC_IS_STREAM (stream));
- g_return_if_fail (error != NULL);
-
- real_error = g_strdup_vprintf (error, args);
- priv = stream->priv;
- if (priv->error) {
- SWFDEC_ERROR ("another error in stream for %s: %s",
- swfdec_stream_describe (stream), real_error);
- g_free (real_error);
- return;
- }
-
- SWFDEC_ERROR ("error in stream for %s: %s",
- swfdec_stream_describe (stream), real_error);
- priv->state = SWFDEC_STREAM_STATE_ERROR;
- priv->error = real_error;
- swfdec_stream_queue_processing (stream);
-}
-
-/**
- * swfdec_stream_open:
- * @stream: a #SwfdecStream
- *
- * Call this function when your stream opened the resulting file. For HTTP this
- * is when having received the headers. You must call this function before
- * swfdec_stream_push() can be called.
- **/
-void
-swfdec_stream_open (SwfdecStream *stream)
-{
- g_return_if_fail (SWFDEC_IS_STREAM (stream));
- g_return_if_fail (stream->priv->state == SWFDEC_STREAM_STATE_CONNECTING);
-
- stream->priv->state = SWFDEC_STREAM_STATE_OPEN;
- g_object_notify (G_OBJECT (stream), "open");
- swfdec_stream_queue_processing (stream);
-}
-
-/**
- * swfdec_stream_push:
- * @stream: a #SwfdecStream
- * @buffer: new data to make available. The stream takes the reference
- * to the buffer.
- *
- * Makes the data in @buffer available to @stream and processes it. The @stream
- * must be open.
- **/
-void
-swfdec_stream_push (SwfdecStream *stream, SwfdecBuffer *buffer)
-{
- g_return_if_fail (SWFDEC_IS_STREAM (stream));
- g_return_if_fail (stream->priv->state == SWFDEC_STREAM_STATE_OPEN);
- g_return_if_fail (buffer != NULL);
-
- swfdec_buffer_queue_push (stream->priv->queue, buffer);
- /* FIXME */
- if (SWFDEC_IS_LOADER (stream))
- g_object_notify (G_OBJECT (stream), "loaded");
- swfdec_stream_queue_processing (stream);
-}
-
-/**
- * swfdec_stream_eof:
- * @stream: a #SwfdecStream
- *
- * Indicates to @stream that no more data will follow. The stream must be open.
- **/
-void
-swfdec_stream_eof (SwfdecStream *stream)
-{
- g_return_if_fail (SWFDEC_IS_STREAM (stream));
- g_return_if_fail (stream->priv->state == SWFDEC_STREAM_STATE_OPEN);
-
- stream->priv->state = SWFDEC_STREAM_STATE_CLOSED;
- g_object_notify (G_OBJECT (stream), "open");
- g_object_notify (G_OBJECT (stream), "eof");
- swfdec_stream_queue_processing (stream);
-}
-
diff --git a/libswfdec/swfdec_stream.h b/libswfdec/swfdec_stream.h
deleted file mode 100644
index f1cb86c..0000000
--- a/libswfdec/swfdec_stream.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2008 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_STREAM_H_
-#define _SWFDEC_STREAM_H_
-
-#include <glib-object.h>
-#include <libswfdec/swfdec_buffer.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecStream SwfdecStream;
-typedef struct _SwfdecStreamClass SwfdecStreamClass;
-typedef struct _SwfdecStreamPrivate SwfdecStreamPrivate;
-
-#define SWFDEC_TYPE_STREAM (swfdec_stream_get_type())
-#define SWFDEC_IS_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_STREAM))
-#define SWFDEC_IS_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_STREAM))
-#define SWFDEC_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_STREAM, SwfdecStream))
-#define SWFDEC_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_STREAM, SwfdecStreamClass))
-#define SWFDEC_STREAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_STREAM, SwfdecStreamClass))
-
-struct _SwfdecStream
-{
- GObject object;
-
- /*< private >*/
- SwfdecStreamPrivate * priv;
-};
-
-struct _SwfdecStreamClass
-{
- GObjectClass object_class;
-
- /* get a nice description string */
- const char * (* describe) (SwfdecStream * stream);
- /* close the stream. */
- void (* close) (SwfdecStream * stream);
-};
-
-GType swfdec_stream_get_type (void);
-
-void swfdec_stream_open (SwfdecStream * stream);
-void swfdec_stream_push (SwfdecStream * stream,
- SwfdecBuffer * buffer);
-void swfdec_stream_eof (SwfdecStream * stream);
-void swfdec_stream_error (SwfdecStream * stream,
- const char * error,
- ...) G_GNUC_PRINTF (2, 3);
-void swfdec_stream_errorv (SwfdecStream * stream,
- const char * error,
- va_list args);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_stream_target.c b/libswfdec/swfdec_stream_target.c
deleted file mode 100644
index a5d7184..0000000
--- a/libswfdec/swfdec_stream_target.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007-2008 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_stream_target.h"
-#include "swfdec_debug.h"
-#include "swfdec_loader_internal.h"
-#include "swfdec_player_internal.h"
-
-static void
-swfdec_stream_target_base_init (gpointer g_class)
-{
- static gboolean initialized = FALSE;
-
- if (G_UNLIKELY (!initialized)) {
- initialized = TRUE;
- }
-}
-
-GType
-swfdec_stream_target_get_type (void)
-{
- static GType stream_target_type = 0;
-
- if (!stream_target_type) {
- static const GTypeInfo stream_target_info = {
- sizeof (SwfdecStreamTargetInterface),
- swfdec_stream_target_base_init,
- NULL,
- NULL,
- NULL,
- NULL,
- 0,
- 0,
- NULL,
- };
-
- stream_target_type = g_type_register_static (G_TYPE_INTERFACE,
- "SwfdecStreamTarget", &stream_target_info, 0);
- g_type_interface_add_prerequisite (stream_target_type, G_TYPE_OBJECT);
- }
-
- return stream_target_type;
-}
-
-SwfdecPlayer *
-swfdec_stream_target_get_player (SwfdecStreamTarget *target)
-{
- SwfdecStreamTargetInterface *iface;
-
- g_return_val_if_fail (SWFDEC_IS_STREAM_TARGET (target), NULL);
-
- iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
- g_assert (iface->get_player != NULL);
- return iface->get_player (target);
-}
-
-void
-swfdec_stream_target_open (SwfdecStreamTarget *target, SwfdecStream *stream)
-{
- SwfdecStreamTargetInterface *iface;
-
- g_return_if_fail (SWFDEC_IS_STREAM_TARGET (target));
- g_return_if_fail (SWFDEC_IS_STREAM (stream));
-
- SWFDEC_LOG ("opening %s", swfdec_stream_describe (stream));
-
- iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
- if (iface->open)
- iface->open (target, stream);
-}
-
-void
-swfdec_stream_target_parse (SwfdecStreamTarget *target, SwfdecStream *stream)
-{
- SwfdecStreamTargetInterface *iface;
-
- g_return_if_fail (SWFDEC_IS_STREAM_TARGET (target));
- g_return_if_fail (SWFDEC_IS_STREAM (stream));
-
- SWFDEC_LOG ("parsing %s", swfdec_stream_describe (stream));
-
- iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
- if (iface->parse)
- iface->parse (target, stream);
-}
-
-void
-swfdec_stream_target_close (SwfdecStreamTarget *target, SwfdecStream *stream)
-{
- SwfdecStreamTargetInterface *iface;
-
- g_return_if_fail (SWFDEC_IS_STREAM_TARGET (target));
- g_return_if_fail (SWFDEC_IS_STREAM (stream));
-
- SWFDEC_LOG ("close on %s", swfdec_stream_describe (stream));
-
- iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
- if (iface->close)
- iface->close (target, stream);
-}
-
-void
-swfdec_stream_target_error (SwfdecStreamTarget *target, SwfdecStream *stream)
-{
- SwfdecStreamTargetInterface *iface;
-
- g_return_if_fail (SWFDEC_IS_STREAM_TARGET (target));
- g_return_if_fail (SWFDEC_IS_STREAM (stream));
-
- SWFDEC_LOG ("error on %s", swfdec_stream_describe (stream));
-
- iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
- if (iface->error)
- iface->error (target, stream);
-}
-
diff --git a/libswfdec/swfdec_stream_target.h b/libswfdec/swfdec_stream_target.h
deleted file mode 100644
index 42b8e16..0000000
--- a/libswfdec/swfdec_stream_target.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007-2008 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef __SWFDEC_STREAM_TARGET_H__
-#define __SWFDEC_STREAM_TARGET_H__
-
-#include <libswfdec/swfdec.h>
-
-G_BEGIN_DECLS
-
-
-#define SWFDEC_TYPE_STREAM_TARGET (swfdec_stream_target_get_type ())
-#define SWFDEC_STREAM_TARGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_STREAM_TARGET, SwfdecStreamTarget))
-#define SWFDEC_IS_STREAM_TARGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_STREAM_TARGET))
-#define SWFDEC_STREAM_TARGET_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), SWFDEC_TYPE_STREAM_TARGET, SwfdecStreamTargetInterface))
-
-typedef struct _SwfdecStreamTarget SwfdecStreamTarget; /* dummy object */
-typedef struct _SwfdecStreamTargetInterface SwfdecStreamTargetInterface;
-
-struct _SwfdecStreamTargetInterface {
- GTypeInterface parent;
-
- /* mandatory vfunc */
- SwfdecPlayer * (* get_player) (SwfdecStreamTarget * target);
- /* optional vfuncs */
- void (* open) (SwfdecStreamTarget * target,
- SwfdecStream * stream);
- void (* parse) (SwfdecStreamTarget * target,
- SwfdecStream * stream);
- void (* close) (SwfdecStreamTarget * target,
- SwfdecStream * stream);
- void (* error) (SwfdecStreamTarget * target,
- SwfdecStream * stream);
-};
-
-GType swfdec_stream_target_get_type (void) G_GNUC_CONST;
-
-SwfdecPlayer * swfdec_stream_target_get_player (SwfdecStreamTarget * target);
-void swfdec_stream_target_open (SwfdecStreamTarget * target,
- SwfdecStream * stream);
-void swfdec_stream_target_parse (SwfdecStreamTarget * target,
- SwfdecStream * stream);
-void swfdec_stream_target_close (SwfdecStreamTarget * target,
- SwfdecStream * stream);
-void swfdec_stream_target_error (SwfdecStreamTarget * target,
- SwfdecStream * stream);
-
-
-G_END_DECLS
-
-#endif /* __SWFDEC_STREAM_TARGET_H__ */
diff --git a/libswfdec/swfdec_stroke.c b/libswfdec/swfdec_stroke.c
deleted file mode 100644
index f043727..0000000
--- a/libswfdec/swfdec_stroke.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-
-#include "swfdec_stroke.h"
-#include "swfdec_bits.h"
-#include "swfdec_color.h"
-#include "swfdec_debug.h"
-#include "swfdec_decoder.h"
-#include "swfdec_path.h"
-
-#define MAX_ALIGN 10
-
-G_DEFINE_TYPE (SwfdecStroke, swfdec_stroke, SWFDEC_TYPE_DRAW);
-
-/* FIXME: This is wrong. Snapping only happens for vertical or horizontal lines.
- * And the snapping shouldn't happen to the cr's device units, but to the
- * Stage coordinate system.
- * This would of course require this function to know that matrix... */
-static void
-swfdec_stroke_append_path_snapped (cairo_t *cr, const cairo_path_t *path)
-{
- cairo_path_data_t *data;
- double x, y;
- int i;
-
- data = path->data;
- for (i = 0; i < path->num_data; i++) {
- switch (data[i].header.type) {
- case CAIRO_PATH_MOVE_TO:
- i++;
- x = data[i].point.x;
- y = data[i].point.y;
- cairo_user_to_device (cr, &x, &y);
- x = rint (x - 0.5) + 0.5;
- y = rint (y - 0.5) + 0.5;
- cairo_device_to_user (cr, &x, &y);
- /* FIXME: currently we need to clamp this due to extents */
- x = CLAMP (x, data[i].point.x - MAX_ALIGN, data[i].point.x + MAX_ALIGN);
- y = CLAMP (y, data[i].point.y - MAX_ALIGN, data[i].point.y + MAX_ALIGN);
- cairo_move_to (cr, x, y);
- break;
- case CAIRO_PATH_LINE_TO:
- i++;
- x = data[i].point.x;
- y = data[i].point.y;
- cairo_user_to_device (cr, &x, &y);
- x = rint (x - 0.5) + 0.5;
- y = rint (y - 0.5) + 0.5;
- cairo_device_to_user (cr, &x, &y);
- /* FIXME: currently we need to clamp this due to extents */
- x = CLAMP (x, data[i].point.x - MAX_ALIGN, data[i].point.x + MAX_ALIGN);
- y = CLAMP (y, data[i].point.y - MAX_ALIGN, data[i].point.y + MAX_ALIGN);
- cairo_line_to (cr, x, y);
- break;
- case CAIRO_PATH_CURVE_TO:
- x = data[i+3].point.x;
- y = data[i+3].point.y;
- cairo_user_to_device (cr, &x, &y);
- x = rint (x - 0.5) + 0.5;
- y = rint (y - 0.5) + 0.5;
- cairo_device_to_user (cr, &x, &y);
- /* FIXME: currently we need to clamp this due to extents */
- x = CLAMP (x, data[i+3].point.x - MAX_ALIGN, data[i+3].point.x + MAX_ALIGN);
- y = CLAMP (y, data[i+3].point.y - MAX_ALIGN, data[i+3].point.y + MAX_ALIGN);
- cairo_curve_to (cr, data[i+1].point.x, data[i+1].point.y,
- data[i+2].point.x, data[i+2].point.y, x, y);
- i += 3;
- break;
- case CAIRO_PATH_CLOSE_PATH:
- /* doesn't exist in our code */
- default:
- g_assert_not_reached ();
- }
- }
-}
-
-static void
-swfdec_stroke_paint (SwfdecDraw *draw, cairo_t *cr, const SwfdecColorTransform *trans)
-{
- SwfdecStroke *stroke = SWFDEC_STROKE (draw);
- SwfdecColor color;
-
- cairo_set_line_cap (cr, stroke->start_cap);
- cairo_set_line_join (cr, stroke->join);
- if (stroke->join == CAIRO_LINE_JOIN_MITER)
- cairo_set_miter_limit (cr, stroke->miter_limit);
-
- if (draw->snap)
- swfdec_stroke_append_path_snapped (cr, &draw->path);
- else
- cairo_append_path (cr, &draw->path);
-
- if (stroke->pattern) {
- cairo_pattern_t *pattern = swfdec_pattern_get_pattern (stroke->pattern, trans);
- cairo_set_source (cr, pattern);
- cairo_pattern_destroy (pattern);
- } else {
- color = swfdec_color_apply_transform (stroke->start_color, trans);
- swfdec_color_set_source (cr, color);
- }
- cairo_set_line_width (cr, MAX (stroke->start_width, SWFDEC_TWIPS_SCALE_FACTOR));
- cairo_stroke (cr);
-}
-
-static void
-swfdec_stroke_morph (SwfdecDraw *dest, SwfdecDraw *source, guint ratio)
-{
- SwfdecStroke *dstroke = SWFDEC_STROKE (dest);
- SwfdecStroke *sstroke = SWFDEC_STROKE (source);
-
- dstroke->start_color = swfdec_color_apply_morph (sstroke->start_color,
- sstroke->end_color, ratio);
- dstroke->start_width = (sstroke->start_width * ratio +
- sstroke->end_width * (65535 - ratio)) / 65535;
- if (sstroke->pattern) {
- dstroke->pattern = SWFDEC_PATTERN (swfdec_draw_morph (
- SWFDEC_DRAW (sstroke->pattern), ratio));
- }
- dstroke->start_cap = sstroke->start_cap;
- dstroke->end_cap = sstroke->end_cap;
- dstroke->join = sstroke->join;
- dstroke->miter_limit = sstroke->miter_limit;
- dstroke->no_vscale = sstroke->no_vscale;
- dstroke->no_hscale = sstroke->no_hscale;
- dstroke->no_close = sstroke->no_close;
-
- SWFDEC_DRAW_CLASS (swfdec_stroke_parent_class)->morph (dest, source, ratio);
-}
-
-static void
-swfdec_stroke_compute_extents (SwfdecDraw *draw)
-{
- guint width = SWFDEC_STROKE (draw)->start_width;
-
- if (SWFDEC_STROKE (draw)->join != CAIRO_LINE_JOIN_ROUND) {
- SWFDEC_FIXME ("work out extents computation for non-round line joins");
- }
- swfdec_path_get_extents (&draw->path, &draw->extents);
- draw->extents.x0 -= width;
- draw->extents.x1 += width;
- draw->extents.y0 -= width;
- draw->extents.y1 += width;
-}
-
-static gboolean
-swfdec_stroke_contains (SwfdecDraw *draw, cairo_t *cr, double x, double y)
-{
- SwfdecStroke *stroke = SWFDEC_STROKE (draw);
-
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
- cairo_set_line_cap (cr, stroke->start_cap);
- cairo_set_line_join (cr, stroke->join);
- if (stroke->join == CAIRO_LINE_JOIN_MITER)
- cairo_set_miter_limit (cr, stroke->miter_limit);
- cairo_set_line_width (cr, MAX (stroke->start_width, SWFDEC_TWIPS_SCALE_FACTOR));
- /* FIXME: do snapping here? */
- cairo_append_path (cr, &draw->path);
- return cairo_in_stroke (cr, x, y);
-}
-
-static void
-swfdec_stroke_class_init (SwfdecStrokeClass *klass)
-{
- SwfdecDrawClass *draw_class = SWFDEC_DRAW_CLASS (klass);
-
- draw_class->morph = swfdec_stroke_morph;
- draw_class->paint = swfdec_stroke_paint;
- draw_class->compute_extents = swfdec_stroke_compute_extents;
- draw_class->contains = swfdec_stroke_contains;
-}
-
-static void
-swfdec_stroke_init (SwfdecStroke *stroke)
-{
- SwfdecDraw *draw = SWFDEC_DRAW (stroke);
-
- draw->snap = TRUE;
-
- stroke->start_cap = CAIRO_LINE_CAP_ROUND;
- stroke->end_cap = CAIRO_LINE_CAP_ROUND;
- stroke->join = CAIRO_LINE_JOIN_ROUND;
-}
-
-/*** EXPORTED API ***/
-
-SwfdecDraw *
-swfdec_stroke_parse (SwfdecBits *bits, SwfdecSwfDecoder *dec)
-{
- SwfdecStroke *stroke = g_object_new (SWFDEC_TYPE_STROKE, NULL);
-
- stroke->start_width = swfdec_bits_get_u16 (bits);
- stroke->end_width = stroke->start_width;
- stroke->start_color = swfdec_bits_get_color (bits);
- stroke->end_color = stroke->start_color;
- SWFDEC_LOG ("new stroke: width %u color %08x", stroke->start_width, stroke->start_color);
-
- return SWFDEC_DRAW (stroke);
-}
-
-SwfdecDraw *
-swfdec_stroke_parse_rgba (SwfdecBits *bits, SwfdecSwfDecoder *dec)
-{
- SwfdecStroke *stroke = g_object_new (SWFDEC_TYPE_STROKE, NULL);
-
- stroke->start_width = swfdec_bits_get_u16 (bits);
- stroke->end_width = stroke->start_width;
- stroke->start_color = swfdec_bits_get_rgba (bits);
- stroke->end_color = stroke->start_color;
- SWFDEC_LOG ("new stroke: width %u color %08x", stroke->start_width, stroke->start_color);
-
- return SWFDEC_DRAW (stroke);
-}
-
-SwfdecDraw *
-swfdec_stroke_parse_morph (SwfdecBits *bits, SwfdecSwfDecoder *dec)
-{
- SwfdecStroke *stroke = g_object_new (SWFDEC_TYPE_STROKE, NULL);
-
- stroke->start_width = swfdec_bits_get_u16 (bits);
- stroke->end_width = swfdec_bits_get_u16 (bits);
- stroke->start_color = swfdec_bits_get_rgba (bits);
- stroke->end_color = swfdec_bits_get_rgba (bits);
- SWFDEC_LOG ("new stroke: width %u => %u color %08X => %08X",
- stroke->start_width, stroke->end_width,
- stroke->start_color, stroke->end_color);
-
- return SWFDEC_DRAW (stroke);
-}
-
-static cairo_line_cap_t
-swfdec_line_cap_get (guint cap)
-{
- switch (cap) {
- case 0:
- return CAIRO_LINE_CAP_ROUND;
- case 1:
- return CAIRO_LINE_CAP_BUTT;
- case 2:
- return CAIRO_LINE_CAP_SQUARE;
- default:
- SWFDEC_ERROR ("invalid line cap value %u", cap);
- return CAIRO_LINE_CAP_ROUND;
- }
-}
-static cairo_line_join_t
-swfdec_line_join_get (guint join)
-{
- switch (join) {
- case 0:
- return CAIRO_LINE_JOIN_ROUND;
- case 1:
- return CAIRO_LINE_JOIN_BEVEL;
- case 2:
- return CAIRO_LINE_JOIN_MITER;
- default:
- SWFDEC_ERROR ("invalid line join value %u", join);
- return CAIRO_LINE_JOIN_ROUND;
- }
-}
-
-static SwfdecDraw *
-swfdec_stroke_do_parse_extended (SwfdecBits *bits, SwfdecSwfDecoder *dec, gboolean morph)
-{
- guint tmp;
- gboolean has_pattern;
- SwfdecStroke *stroke = g_object_new (SWFDEC_TYPE_STROKE, NULL);
-
- stroke->start_width = swfdec_bits_get_u16 (bits);
- if (morph) {
- stroke->end_width = swfdec_bits_get_u16 (bits);
- SWFDEC_LOG (" width: %u => %u", stroke->start_width, stroke->end_width);
- } else {
- stroke->end_width = stroke->start_width;
- SWFDEC_LOG (" width: %u", stroke->start_width);
- }
- tmp = swfdec_bits_getbits (bits, 2);
- SWFDEC_LOG (" start cap: %u", tmp);
- stroke->start_cap = swfdec_line_cap_get (tmp);
- tmp = swfdec_bits_getbits (bits, 2);
- SWFDEC_LOG (" line join: %u", tmp);
- stroke->join = swfdec_line_join_get (tmp);
- has_pattern = swfdec_bits_getbit (bits);
- SWFDEC_LOG (" has pattern: %d", has_pattern);
- stroke->no_hscale = swfdec_bits_getbit (bits);
- SWFDEC_LOG (" no hscale: %d", stroke->no_hscale);
- stroke->no_vscale = swfdec_bits_getbit (bits);
- SWFDEC_LOG (" no vscale: %d", stroke->no_vscale);
- SWFDEC_DRAW (stroke)->snap = swfdec_bits_getbit (bits);
- SWFDEC_LOG (" align pixels: %d", SWFDEC_DRAW (stroke)->snap);
- tmp = swfdec_bits_getbits (bits, 5);
- stroke->no_close = swfdec_bits_getbit (bits);
- SWFDEC_LOG (" no close: %d", stroke->no_close);
- tmp = swfdec_bits_getbits (bits, 2);
- SWFDEC_LOG (" end cap: %u", tmp);
- stroke->end_cap = swfdec_line_cap_get (tmp);
- if (stroke->end_cap != stroke->start_cap) {
- SWFDEC_WARNING ("FIXME: different caps on start and end of line are unsupported");
- }
- if (stroke->join == CAIRO_LINE_JOIN_MITER) {
- stroke->miter_limit = swfdec_bits_get_u16 (bits);
- SWFDEC_LOG (" miter limit: %u", stroke->miter_limit);
- }
- if (has_pattern) {
- if (morph) {
- stroke->pattern = SWFDEC_PATTERN (swfdec_pattern_parse_morph (bits, dec));
- } else {
- stroke->pattern = SWFDEC_PATTERN (swfdec_pattern_parse_rgba (bits, dec));
- }
- } else {
- stroke->start_color = swfdec_bits_get_rgba (bits);
- if (morph) {
- stroke->end_color = swfdec_bits_get_rgba (bits);
- SWFDEC_LOG (" color: #%08X", stroke->start_color);
- } else {
- stroke->end_color = stroke->start_color;
- SWFDEC_LOG (" color: #%08X", stroke->start_color);
- }
- }
-
- return SWFDEC_DRAW (stroke);
-}
-
-SwfdecDraw *
-swfdec_stroke_parse_extended (SwfdecBits *bits, SwfdecSwfDecoder *dec)
-{
- g_return_val_if_fail (bits != NULL, NULL);
- g_return_val_if_fail (SWFDEC_IS_SWF_DECODER (dec), NULL);
-
- return swfdec_stroke_do_parse_extended (bits, dec, FALSE);
-}
-
-SwfdecDraw *
-swfdec_stroke_parse_morph_extended (SwfdecBits *bits, SwfdecSwfDecoder *dec)
-{
- g_return_val_if_fail (bits != NULL, NULL);
- g_return_val_if_fail (SWFDEC_IS_SWF_DECODER (dec), NULL);
-
- return swfdec_stroke_do_parse_extended (bits, dec, TRUE);
-}
diff --git a/libswfdec/swfdec_stroke.h b/libswfdec/swfdec_stroke.h
deleted file mode 100644
index 8d1e7cd..0000000
--- a/libswfdec/swfdec_stroke.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_STROKE_H_
-#define _SWFDEC_STROKE_H_
-
-#include <libswfdec/swfdec_pattern.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecStroke SwfdecStroke;
-typedef struct _SwfdecStrokeClass SwfdecStrokeClass;
-
-#define SWFDEC_TYPE_STROKE (swfdec_stroke_get_type())
-#define SWFDEC_IS_STROKE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_STROKE))
-#define SWFDEC_IS_STROKE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_STROKE))
-#define SWFDEC_STROKE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_STROKE, SwfdecStroke))
-#define SWFDEC_STROKE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_STROKE, SwfdecStrokeClass))
-#define SWFDEC_STROKE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_STROKE, SwfdecStrokeClass))
-
-struct _SwfdecStroke
-{
- SwfdecDraw draw;
-
- guint start_width; /* width of line */
- SwfdecColor start_color; /* color to paint with */
- guint end_width; /* width of line */
- SwfdecColor end_color; /* color to paint with */
- /* Flash 8 */
- SwfdecPattern * pattern; /* pattern to use instead of color if not NULL */
- cairo_line_cap_t start_cap;
- cairo_line_cap_t end_cap;
- cairo_line_join_t join;
- guint miter_limit; /* only set when join = MITER */
- gboolean no_vscale; /* don't scale line in vertical direction */
- gboolean no_hscale; /* don't scale line in horizontal direction */
- gboolean no_close; /* don't auto-close lines */
-};
-
-struct _SwfdecStrokeClass
-{
- SwfdecDrawClass draw_class;
-};
-
-GType swfdec_stroke_get_type (void);
-
-SwfdecDraw * swfdec_stroke_parse (SwfdecBits * bits,
- SwfdecSwfDecoder * dec);
-SwfdecDraw * swfdec_stroke_parse_rgba (SwfdecBits * bits,
- SwfdecSwfDecoder * dec);
-SwfdecDraw * swfdec_stroke_parse_extended (SwfdecBits * bits,
- SwfdecSwfDecoder * dec);
-SwfdecDraw * swfdec_stroke_parse_morph (SwfdecBits * bits,
- SwfdecSwfDecoder * dec);
-SwfdecDraw * swfdec_stroke_parse_morph_extended (SwfdecBits * bits,
- SwfdecSwfDecoder * dec);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_style_sheet.c b/libswfdec/swfdec_style_sheet.c
deleted file mode 100644
index 847b199..0000000
--- a/libswfdec/swfdec_style_sheet.c
+++ /dev/null
@@ -1,366 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "swfdec_style_sheet.h"
-#include "swfdec_as_native_function.h"
-#include "swfdec_as_array.h"
-#include "swfdec_as_object.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_text_format.h"
-#include "swfdec_text_field_movie.h"
-#include "swfdec_debug.h"
-#include "swfdec_internal.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_player_internal.h"
-
-enum {
- UPDATE,
- LAST_SIGNAL
-};
-
-G_DEFINE_TYPE (SwfdecStyleSheet, swfdec_style_sheet, SWFDEC_TYPE_AS_OBJECT)
-static guint signals[LAST_SIGNAL] = { 0, };
-
-static void
-swfdec_style_sheet_class_init (SwfdecStyleSheetClass *klass)
-{
- signals[UPDATE] = g_signal_new ("update", G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-swfdec_style_sheet_init (SwfdecStyleSheet *style_sheet)
-{
-}
-
-// Note: This overwrites any old object with the same name
-static SwfdecAsObject *
-swfdec_style_sheet_get_selector_object (SwfdecAsObject *object,
- const char *name)
-{
- SwfdecAsValue val;
- SwfdecAsObject *empty;
-
- g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- empty = swfdec_as_object_new_empty (object->context);
- SWFDEC_AS_VALUE_SET_OBJECT (&val, empty);
- swfdec_as_object_unset_variable_flags (object, name,
- SWFDEC_AS_VARIABLE_CONSTANT);
- swfdec_as_object_set_variable (object, name, &val);
-
- return empty;
-}
-
-static const char *
-swfdec_style_sheet_parse_selectors (SwfdecAsContext *cx, const char *p,
- SwfdecAsObject *object, GPtrArray *selectors)
-{
- const char *end;
- const char *name;
-
- g_return_val_if_fail (p != NULL && p != '\0' && !g_ascii_isspace (*p), NULL);
- g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL);
- g_return_val_if_fail (selectors != NULL, NULL);
-
- p += strspn (p, " \t\r\n,");
- if (*p == '{')
- return NULL;
-
- while (*p != '\0' && *p != '{') {
- end = p + strcspn (p, " \t\r\n,{");
- g_assert (end > p);
-
- name = swfdec_as_context_give_string (cx, g_strndup (p, end - p));
- g_ptr_array_add (selectors,
- swfdec_style_sheet_get_selector_object (object, name));
-
-
- p = end + strspn (end, " \t\r\n,");
- if (*p != '{') {
- // no , between selectors?
- if (strchr (end, ',') == NULL || strchr (end, ',') > p)
- return NULL;
- }
- }
-
- if (*p != '{')
- return NULL;
-
- p++;
- p = p + strspn (p, " \t\r\n");
-
- // special case: don't allow empty declarations if not totally empty
- if (*(p-1) != '{' && (*p == '\0' || *p == '}'))
- return NULL;
-
- return p;
-}
-
-static char *
-swfdec_style_sheet_convert_name (char *name)
-{
- char *p;
-
- p = name;
- while ((p = strchr (p, '-')) != NULL && *(p + 1) != '\0') {
- memmove (p, p + 1, strlen (p + 1) + 1); // include NULL-byte
- *p = g_ascii_toupper (*p);
- p++;
- };
-
- return name;
-}
-
-static const char *
-swfdec_style_sheet_parse_property (SwfdecAsContext *cx, const char *p,
- const char **name, const char **value)
-{
- const char *end;
-
- *name = NULL;
- *value = NULL;
-
- g_return_val_if_fail (p != NULL && p != '\0' && !g_ascii_isspace (*p), NULL);
- g_return_val_if_fail (name != NULL, NULL);
- g_return_val_if_fail (value != NULL, NULL);
-
- end = p + strcspn (p, ":;");
- if (*end == '\0' || *end == ';')
- return NULL;
-
- *name = swfdec_as_context_give_string (cx,
- swfdec_style_sheet_convert_name (g_strndup (p, end - p)));
-
- end++;
- p = end + strspn (end, " \t\r\n");
- if (*p == '\0')
- return NULL;
- end = p + strcspn (p, ";}");
- if (*end == '\0')
- return NULL;
-
- if (end == p) {
- *value = SWFDEC_AS_STR_EMPTY;
- } else {
- *value = swfdec_as_context_give_string (cx, g_strndup (p, end - p));
- }
-
- if (*end == '}') {
- p = end;
- } else {
- end++;
- p = end + strspn (end, " \t\r\n");
- }
-
- return p;
-}
-
-static SwfdecAsObject *
-swfdec_style_sheet_parse (SwfdecAsContext *cx, const char *css)
-{
- guint i;
- const char *p;
- SwfdecAsValue val;
- SwfdecAsObject *object;
- GPtrArray *selectors;
-
- g_return_val_if_fail (css != NULL, FALSE);
-
- object = swfdec_as_object_new_empty (cx);
- selectors = g_ptr_array_new ();
-
- p = css + strspn (css, " \t\r\n");
- while (p != NULL && *p != '\0')
- {
- if (selectors->len == 0) {
- p = swfdec_style_sheet_parse_selectors (cx, p, object, selectors);
- } else {
- if (*p == '}') {
- g_ptr_array_set_size (selectors, 0);
- p++;
- p += strspn (p, " \t\r\n");
- } else {
- const char *name, *value;
- p = swfdec_style_sheet_parse_property (cx, p, &name, &value);
- if (p != NULL) {
- for (i = 0; i < selectors->len; i++) {
- SWFDEC_AS_VALUE_SET_STRING (&val, value);
- swfdec_as_object_set_variable (
- (SwfdecAsObject *)(selectors->pdata[i]), name, &val);
- }
- }
- }
- }
- }
-
- g_ptr_array_free (selectors, TRUE);
- if (p == NULL)
- return NULL;
-
- return object;
-}
-
-SWFDEC_AS_NATIVE (113, 100, swfdec_style_sheet_update)
-void
-swfdec_style_sheet_update (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecStyleSheet *style;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_STYLESHEET, &style, "");
-
- g_signal_emit (style, signals[UPDATE], 0);
-}
-
-SWFDEC_AS_NATIVE (113, 101, swfdec_style_sheet_parseCSSInternal)
-void
-swfdec_style_sheet_parseCSSInternal (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *rval)
-{
- SwfdecAsObject *values;
-
- if (argc < 1)
- return;
-
- values =
- swfdec_style_sheet_parse (cx, swfdec_as_value_to_string (cx, &argv[0]));
-
- if (values == NULL) {
- SWFDEC_AS_VALUE_SET_NULL (rval);
- } else {
- SWFDEC_AS_VALUE_SET_OBJECT (rval, values);
- }
-}
-
-SWFDEC_AS_NATIVE (113, 102, swfdec_style_sheet_parseCSSFontFamily)
-void
-swfdec_style_sheet_parseCSSFontFamily (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *rval)
-{
- const char *name;
-
- SWFDEC_AS_CHECK (0, NULL, "s", &name);
-
- if (!g_ascii_strcasecmp (name, "mono")) {
- SWFDEC_AS_VALUE_SET_STRING (rval, SWFDEC_AS_STR__typewriter);
- } else if (!g_ascii_strcasecmp (name, "sans-serif")) {
- SWFDEC_AS_VALUE_SET_STRING (rval, SWFDEC_AS_STR__sans);
- } else if (!g_ascii_strcasecmp (name, "serif")) {
- SWFDEC_AS_VALUE_SET_STRING (rval, SWFDEC_AS_STR__serif);
- } else {
- SWFDEC_AS_VALUE_SET_STRING (rval, name);
- }
-}
-
-SWFDEC_AS_NATIVE (113, 103, swfdec_style_sheet_parseColor)
-void
-swfdec_style_sheet_parseColor (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- const char *value;
- char *tail;
- gint64 result;
-
- SWFDEC_AS_VALUE_SET_NULL (rval);
-
- SWFDEC_AS_CHECK (0, NULL, "s", &value);
-
- if (strlen(value) != 7)
- return;
-
- if (value[0] != '#')
- return;
-
- result = g_ascii_strtoll (value + 1, &tail, 16);
- if (*tail != '\0')
- return;
-
- SWFDEC_AS_VALUE_SET_INT (rval, result);
-}
-
-SWFDEC_AS_CONSTRUCTOR (113, 0, swfdec_style_sheet_construct, swfdec_style_sheet_get_type)
-void
-swfdec_style_sheet_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!swfdec_as_context_is_constructing (cx)) {
- SWFDEC_FIXME ("What do we do if not constructing?");
- return;
- }
-
- g_assert (SWFDEC_IS_STYLESHEET (object));
-}
-
-static SwfdecTextFormat *
-swfdec_style_sheet_get_format (SwfdecStyleSheet *style, const char *name)
-{
- SwfdecAsObject *styles;
- SwfdecAsValue val;
-
- g_return_val_if_fail (SWFDEC_IS_STYLESHEET (style), NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (style),
- SWFDEC_AS_STR__styles, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return NULL;
- styles = SWFDEC_AS_VALUE_GET_OBJECT (&val);
-
- swfdec_as_object_get_variable (styles, name, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return NULL;
- if (!SWFDEC_IS_TEXT_FORMAT (SWFDEC_AS_VALUE_GET_OBJECT (&val)))
- return NULL;
-
- return SWFDEC_TEXT_FORMAT (SWFDEC_AS_VALUE_GET_OBJECT (&val));
-}
-
-SwfdecTextFormat *
-swfdec_style_sheet_get_tag_format (SwfdecStyleSheet *style, const char *name)
-{
- return swfdec_style_sheet_get_format (style, name);
-}
-
-SwfdecTextFormat *
-swfdec_style_sheet_get_class_format (SwfdecStyleSheet *style, const char *name)
-{
- char *name_full;
-
- g_return_val_if_fail (SWFDEC_IS_STYLESHEET (style), NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- name_full = g_malloc (1 + strlen (name) + 1);
- name_full[0] = '.';
- memcpy (name_full + 1, name, strlen (name) + 1);
-
- return swfdec_style_sheet_get_format (style, swfdec_as_context_give_string (
- SWFDEC_AS_OBJECT (style)->context, name_full));
-}
diff --git a/libswfdec/swfdec_style_sheet.h b/libswfdec/swfdec_style_sheet.h
deleted file mode 100644
index 847d7f7..0000000
--- a/libswfdec/swfdec_style_sheet.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_STYLESHEET_H_
-#define _SWFDEC_STYLESHEET_H_
-
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_script.h>
-#include <libswfdec/swfdec_text_format.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecStyleSheet SwfdecStyleSheet;
-typedef struct _SwfdecStyleSheetClass SwfdecStyleSheetClass;
-
-#define SWFDEC_TYPE_STYLESHEET (swfdec_style_sheet_get_type())
-#define SWFDEC_IS_STYLESHEET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_STYLESHEET))
-#define SWFDEC_IS_STYLESHEET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_STYLESHEET))
-#define SWFDEC_STYLESHEET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_STYLESHEET, SwfdecStyleSheet))
-#define SWFDEC_STYLESHEET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_STYLESHEET, SwfdecStyleSheetClass))
-#define SWFDEC_STYLESHEET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_STYLESHEET, SwfdecStyleSheetClass))
-
-struct _SwfdecStyleSheet {
- SwfdecAsObject object;
-};
-
-struct _SwfdecStyleSheetClass {
- SwfdecAsObjectClass object_class;
-};
-
-GType swfdec_style_sheet_get_type (void);
-
-SwfdecTextFormat *swfdec_style_sheet_get_tag_format (SwfdecStyleSheet * style,
- const char * name);
-SwfdecTextFormat *swfdec_style_sheet_get_class_format (SwfdecStyleSheet * style,
- const char * name);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_swf_decoder.c b/libswfdec/swfdec_swf_decoder.c
deleted file mode 100644
index 5f3b2e0..0000000
--- a/libswfdec/swfdec_swf_decoder.c
+++ /dev/null
@@ -1,487 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <zlib.h>
-#include <math.h>
-#include <string.h>
-#include <stdlib.h>
-#include <liboil/liboil.h>
-
-#include "swfdec_swf_decoder.h"
-#include "swfdec.h"
-#include "swfdec_bits.h"
-#include "swfdec_cached.h"
-#include "swfdec_debug.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_script.h"
-#include "swfdec_script_internal.h"
-#include "swfdec_sprite.h"
-#include "swfdec_tag.h"
-
-enum {
- SWFDEC_STATE_INIT1 = 0,
- SWFDEC_STATE_INIT2,
- SWFDEC_STATE_PARSE_FIRST_TAG,
- SWFDEC_STATE_PARSE_TAG,
- SWFDEC_STATE_EOF,
-};
-
-G_DEFINE_TYPE (SwfdecSwfDecoder, swfdec_swf_decoder, SWFDEC_TYPE_DECODER)
-
-static void
-swfdec_swf_decoder_dispose (GObject *object)
-{
- SwfdecSwfDecoder *s = SWFDEC_SWF_DECODER (object);
-
- g_hash_table_destroy (s->characters);
- g_object_unref (s->main_sprite);
- g_hash_table_destroy (s->scripts);
-
- if (s->compressed)
- inflateEnd (&s->z);
- if (s->buffer) {
- swfdec_buffer_unref (s->buffer);
- s->buffer = NULL;
- }
-
- if (s->jpegtables) {
- swfdec_buffer_unref (s->jpegtables);
- }
-
- g_free (s->password);
-
- G_OBJECT_CLASS (swfdec_swf_decoder_parent_class)->dispose (object);
-}
-
-static void *
-zalloc (void *opaque, guint items, guint size)
-{
- return g_malloc (items * size);
-}
-
-static void
-zfree (void *opaque, void *addr)
-{
- g_free (addr);
-}
-
-static SwfdecBuffer *
-swfdec_buffer_merge (const SwfdecBuffer *front, const SwfdecBuffer *end)
-{
- SwfdecBuffer *new;
-
- g_return_val_if_fail (front != NULL, NULL);
- g_return_val_if_fail (end != NULL, NULL);
-
- new = swfdec_buffer_new_and_alloc (front->length + end->length);
- if (front->length)
- memcpy (new->data, front->data, front->length);
- if (end->length)
- memcpy (new->data + front->length, end->data, end->length);
- return new;
-}
-
-static gboolean
-swfdec_swf_decoder_deflate (SwfdecSwfDecoder * s, SwfdecBuffer *buffer)
-{
- int ret;
- SwfdecDecoder *dec = SWFDEC_DECODER (s);
-
- if (s->buffer == NULL) {
- /* never written to */
- g_assert (s->state == SWFDEC_STATE_INIT1);
- s->buffer = buffer;
- } else if (s->state == SWFDEC_STATE_INIT1) {
- /* not initialized yet */
- SwfdecBuffer *merge = swfdec_buffer_merge (s->buffer, buffer);
- swfdec_buffer_unref (s->buffer);
- swfdec_buffer_unref (buffer);
- s->buffer = merge;
- } else if (s->compressed) {
- s->z.next_in = buffer->data;
- s->z.avail_in = buffer->length;
- ret = inflate (&s->z, Z_SYNC_FLUSH);
- if (ret < Z_OK) {
- SWFDEC_ERROR ("error uncompressing data: %s", s->z.msg);
- return FALSE;
- }
-
- dec->bytes_loaded = s->z.total_out + 8;
- swfdec_buffer_unref (buffer);
- } else {
- guint max = buffer->length;
-
- if (dec->bytes_loaded + max > s->buffer->length) {
- SWFDEC_WARNING ("%"G_GSIZE_FORMAT" bytes more than declared filesize",
- dec->bytes_loaded + max - s->buffer->length);
- max = s->buffer->length - dec->bytes_loaded;
- }
- memcpy (s->buffer->data + dec->bytes_loaded, buffer->data, max);
- dec->bytes_loaded += max;
- swfdec_buffer_unref (buffer);
- }
-
- return TRUE;
-}
-
-static gboolean
-swf_inflate_init (SwfdecSwfDecoder * s)
-{
- z_stream *z;
- int ret;
- z = &s->z;
- z->zalloc = zalloc;
- z->zfree = zfree;
- ret = inflateInit (z);
- SWFDEC_DEBUG ("inflateInit returned %d", ret);
-
- z->next_out = s->buffer->data + 8;
- z->avail_out = s->buffer->length - 8;
- z->opaque = NULL;
- return TRUE;
-}
-
-static void
-swfdec_swf_decoder_init_bits (SwfdecSwfDecoder *dec, SwfdecBits *bits)
-{
- swfdec_bits_init (bits, dec->buffer);
- bits->end = bits->ptr + SWFDEC_DECODER (dec)->bytes_loaded;
- bits->ptr += dec->bytes_parsed;
- g_assert (bits->ptr <= bits->end);
-}
-
-static void
-swfdec_swf_decoder_flush_bits (SwfdecSwfDecoder *dec, SwfdecBits *bits)
-{
- g_assert (bits->idx == 0);
- g_assert (bits->buffer == dec->buffer);
-
- dec->bytes_parsed = bits->ptr - dec->buffer->data;
- g_assert (dec->bytes_parsed <= SWFDEC_DECODER (dec)->bytes_loaded);
-}
-
-static int
-swf_parse_header1 (SwfdecSwfDecoder * s)
-{
- SwfdecDecoder *dec = SWFDEC_DECODER (s);
- int sig1, sig2, sig3;
- SwfdecBuffer *buffer, *rest;
- SwfdecBits bits;
- guint8 *data;
-
- g_assert (s->buffer != NULL);
- if (s->buffer->length <= 8) {
- return SWFDEC_STATUS_NEEDBITS;
- }
-
- swfdec_bits_init (&bits, s->buffer);
-
- sig1 = swfdec_bits_get_u8 (&bits);
- sig2 = swfdec_bits_get_u8 (&bits);
- sig3 = swfdec_bits_get_u8 (&bits);
- if ((sig1 != 'F' && sig1 != 'C') || sig2 != 'W' || sig3 != 'S') {
- return SWFDEC_STATUS_ERROR;
- }
-
- s->version = swfdec_bits_get_u8 (&bits);
- dec->bytes_total = swfdec_bits_get_u32 (&bits);
- if (dec->bytes_total <= 8) {
- SWFDEC_ERROR ("Joke? Flash files need to be bigger than %u bytes", dec->bytes_total);
- dec->bytes_total = 0;
- return SWFDEC_STATUS_ERROR;
- }
- rest = swfdec_bits_get_buffer (&bits, -1);
-
- data = g_try_malloc (dec->bytes_total);
- if (data == NULL)
- return SWFDEC_STATUS_ERROR;
- buffer = swfdec_buffer_new_for_data (data, dec->bytes_total);
- memcpy (buffer->data, s->buffer->data, 8);
- swfdec_buffer_unref (s->buffer);
- s->buffer = buffer;
-
- s->compressed = (sig1 == 'C');
- if (s->compressed) {
- SWFDEC_DEBUG ("compressed");
- if (!swf_inflate_init (s))
- return SWFDEC_STATUS_ERROR;
- } else {
- SWFDEC_DEBUG ("not compressed");
- }
- SWFDEC_DECODER (s)->bytes_loaded = 8;
- s->bytes_parsed = 8;
- s->state = SWFDEC_STATE_INIT2;
- swfdec_swf_decoder_deflate (s, rest);
- dec->data_type = SWFDEC_LOADER_DATA_SWF;
-
- return SWFDEC_STATUS_OK;
-}
-
-static int
-swf_parse_header2 (SwfdecSwfDecoder * s)
-{
- guint n;
- SwfdecRect rect;
- SwfdecDecoder *dec = SWFDEC_DECODER (s);
-
- swfdec_swf_decoder_init_bits (s, &s->b);
- n = swfdec_bits_peekbits (&s->b, 5);
- /* rect rate + total_frames */
- n = ((5 + 4 * n + 7) / 8 + (2 + 2)) * 8;
- if (swfdec_bits_left (&s->b) < n)
- return SWFDEC_STATUS_NEEDBITS;
-
- swfdec_bits_get_rect (&s->b, &rect);
- if (rect.x0 != 0.0 || rect.y0 != 0.0)
- SWFDEC_ERROR ("SWF window doesn't start at 0 0 but at %g %g", rect.x0, rect.y0);
- SWFDEC_INFO ("SWF size: %g x %g pixels", rect.x1 / SWFDEC_TWIPS_SCALE_FACTOR,
- rect.y1 / SWFDEC_TWIPS_SCALE_FACTOR);
- dec->width = MAX (0, ceil (rect.x1 / SWFDEC_TWIPS_SCALE_FACTOR));
- dec->height = MAX (0, ceil (rect.y1 / SWFDEC_TWIPS_SCALE_FACTOR));
- swfdec_bits_syncbits (&s->b);
- dec->rate = swfdec_bits_get_u16 (&s->b);
- if (dec->rate == 0) {
- SWFDEC_INFO ("rate is 0, setting to 65536");
- dec->rate = 65536;
- }
- SWFDEC_LOG ("rate = %g", dec->rate / 256.0);
- dec->frames_total = swfdec_bits_get_u16 (&s->b);
- SWFDEC_LOG ("n_frames = %d", dec->frames_total);
- swfdec_sprite_set_n_frames (s->main_sprite, dec->frames_total, dec->rate);
-
- swfdec_swf_decoder_flush_bits (s, &s->b);
-
- s->state = SWFDEC_STATE_PARSE_FIRST_TAG;
- return SWFDEC_STATUS_INIT;
-}
-
-static SwfdecStatus
-swfdec_swf_decoder_parse_one (SwfdecSwfDecoder *s)
-{
- int ret = SWFDEC_STATUS_OK;
-
- s->b = s->parse;
-
- switch (s->state) {
- case SWFDEC_STATE_INIT1:
- ret = swf_parse_header1 (s);
- break;
- case SWFDEC_STATE_INIT2:
- ret = swf_parse_header2 (s);
- break;
- case SWFDEC_STATE_PARSE_FIRST_TAG:
- case SWFDEC_STATE_PARSE_TAG:
- {
- guint header_length;
- guint x;
- SwfdecTagFunc func;
- guint tag;
- guint tag_len;
- SwfdecBits bits;
-
- /* we're parsing tags */
- swfdec_swf_decoder_init_bits (s, &bits);
- if (swfdec_bits_left (&bits) < 2 * 8)
- return SWFDEC_STATUS_NEEDBITS;
-
- x = swfdec_bits_get_u16 (&bits);
- tag = (x >> 6) & 0x3ff;
- SWFDEC_DEBUG ("tag %d %s", tag, swfdec_swf_decoder_get_tag_name (tag));
- tag_len = x & 0x3f;
- if (tag_len == 0x3f) {
- if (swfdec_bits_left (&bits) < 4 * 8)
- return SWFDEC_STATUS_NEEDBITS;
-
- tag_len = swfdec_bits_get_u32 (&bits);
- header_length = 6;
- } else {
- header_length = 2;
- }
-
- SWFDEC_INFO ("parsing at %d, tag %d %s, length %d",
- s->bytes_parsed, tag,
- swfdec_swf_decoder_get_tag_name (tag), tag_len);
-
- if (swfdec_bits_left (&bits) / 8 < tag_len)
- return SWFDEC_STATUS_NEEDBITS;
-
- swfdec_bits_init_bits (&s->b, &bits, tag_len);
- swfdec_swf_decoder_flush_bits (s, &bits);
-
- func = swfdec_swf_decoder_get_tag_func (tag);
- if (tag == 0) {
- s->state = SWFDEC_STATE_EOF;
- } else if ((swfdec_swf_decoder_get_tag_flag (tag) & SWFDEC_TAG_FIRST_ONLY)
- && s->state == SWFDEC_STATE_PARSE_TAG) {
- SWFDEC_WARNING ("tag %d %s must be first tag in file, ignoring",
- tag, swfdec_swf_decoder_get_tag_name (tag));
- } else if (func == NULL) {
- SWFDEC_WARNING ("tag function not implemented for %d %s",
- tag, swfdec_swf_decoder_get_tag_name (tag));
- } else if (s->main_sprite->parse_frame < s->main_sprite->n_frames) {
- s->parse_sprite = s->main_sprite;
- ret = func (s, tag);
- s->parse_sprite = NULL;
-
- if (swfdec_bits_left (&s->b)) {
- SWFDEC_WARNING
- ("early finish (%d bytes) at %d, tag %d %s, length %d",
- swfdec_bits_left (&s->b) / 8,
- s->bytes_parsed, tag,
- swfdec_swf_decoder_get_tag_name (tag), tag_len);
- }
- } else {
- ret = SWFDEC_STATE_EOF;
- SWFDEC_ERROR ("data after last frame");
- }
- s->state = SWFDEC_STATE_PARSE_TAG;
-
- break;
- }
- case SWFDEC_STATE_EOF:
- if (s->bytes_parsed < SWFDEC_DECODER (s)->bytes_loaded) {
- SWFDEC_WARNING ("%u bytes after EOF", SWFDEC_DECODER (s)->bytes_loaded - s->bytes_parsed);
- }
- return SWFDEC_STATUS_EOF;
- default:
- g_assert_not_reached ();
- }
-
- /* copy state */
- SWFDEC_DECODER (s)->frames_loaded = s->main_sprite->parse_frame;
-
- return ret;
-}
-
-static SwfdecStatus
-swfdec_swf_decoder_parse (SwfdecDecoder *dec, SwfdecBuffer *buffer)
-{
- SwfdecSwfDecoder *s = SWFDEC_SWF_DECODER (dec);
- SwfdecStatus status = 0;
-
- swfdec_swf_decoder_deflate (s, buffer);
- do {
- status |= swfdec_swf_decoder_parse_one (s);
- } while ((status & (SWFDEC_STATUS_EOF | SWFDEC_STATUS_NEEDBITS | SWFDEC_STATUS_ERROR)) == 0);
- return status;
-}
-
-static SwfdecStatus
-swfdec_swf_decoder_eof (SwfdecDecoder *dec)
-{
- if (dec->bytes_loaded < dec->bytes_total) {
- SWFDEC_ERROR ("only %u of %u bytes provided, broken transmission?",
- dec->bytes_loaded, dec->bytes_total);
- }
-
- return 0;
-}
-
-static void
-swfdec_swf_decoder_class_init (SwfdecSwfDecoderClass *class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (class);
- SwfdecDecoderClass *decoder_class = SWFDEC_DECODER_CLASS (class);
-
- object_class->dispose = swfdec_swf_decoder_dispose;
-
- decoder_class->parse = swfdec_swf_decoder_parse;
- decoder_class->eof = swfdec_swf_decoder_eof;
-}
-
-static void
-swfdec_swf_decoder_init (SwfdecSwfDecoder *s)
-{
- s->main_sprite = g_object_new (SWFDEC_TYPE_SPRITE, NULL);
-
- s->characters = g_hash_table_new_full (g_direct_hash, g_direct_equal,
- NULL, g_object_unref);
- s->scripts = g_hash_table_new_full (g_direct_hash, g_direct_equal,
- NULL, (GDestroyNotify) swfdec_script_unref);
-}
-
-gpointer
-swfdec_swf_decoder_get_character (SwfdecSwfDecoder * s, guint id)
-{
- g_return_val_if_fail (SWFDEC_IS_SWF_DECODER (s), NULL);
-
- return g_hash_table_lookup (s->characters, GUINT_TO_POINTER (id));
-}
-
-/**
- * swfdec_swf_decoder_create_character:
- * @s: a #SwfdecDecoder
- * @id: id of the character
- * @type: the required type for the character
- *
- * Gets the character of the requested @type and with the given @id from @s.
- * If there is already a different character with the given id, return NULL.
- * If the character doesn't exist yet, create it.
- *
- * Returns: The requested character or NULL on failure;
- **/
-gpointer
-swfdec_swf_decoder_create_character (SwfdecSwfDecoder * s, guint id, GType type)
-{
- SwfdecCharacter *result;
-
- g_return_val_if_fail (SWFDEC_IS_DECODER (s), NULL);
- g_return_val_if_fail (g_type_is_a (type, SWFDEC_TYPE_CHARACTER), NULL);
-
- SWFDEC_INFO (" id = %d", id);
- result = swfdec_swf_decoder_get_character (s, id);
- if (result) {
- SWFDEC_WARNING ("character with id %d already exists", id);
- return NULL;
- }
- result = g_object_new (type, NULL);
- result->id = id;
- g_hash_table_insert (s->characters, GUINT_TO_POINTER (id), result);
- if (SWFDEC_IS_CACHED (result)) {
- swfdec_cached_set_cache (SWFDEC_CACHED (result), SWFDEC_DECODER (s)->player->priv->cache);
- }
-
- return result;
-}
-
-void
-swfdec_swf_decoder_add_script (SwfdecSwfDecoder *s, SwfdecScript *script)
-{
- g_return_if_fail (SWFDEC_IS_SWF_DECODER (s));
- g_return_if_fail (script != NULL);
- g_return_if_fail (script->buffer != NULL);
-
- g_hash_table_insert (s->scripts, (gpointer) script->main, script);
-}
-
-SwfdecScript *
-swfdec_swf_decoder_get_script (SwfdecSwfDecoder *s, guint8 *data)
-{
- g_return_val_if_fail (SWFDEC_IS_SWF_DECODER (s), NULL);
- g_return_val_if_fail (data != NULL, NULL);
-
- return g_hash_table_lookup (s->scripts, data);
-}
-
diff --git a/libswfdec/swfdec_swf_decoder.h b/libswfdec/swfdec_swf_decoder.h
deleted file mode 100644
index dcd2e16..0000000
--- a/libswfdec/swfdec_swf_decoder.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef __SWFDEC_SWF_DECODER_H__
-#define __SWFDEC_SWF_DECODER_H__
-
-#include <glib.h>
-#include <zlib.h>
-
-#include <libswfdec/swfdec_decoder.h>
-#include <libswfdec/swfdec_bits.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_rect.h>
-
-G_BEGIN_DECLS
-
-//typedef struct _SwfdecSwfDecoder SwfdecSwfDecoder;
-typedef struct _SwfdecSwfDecoderClass SwfdecSwfDecoderClass;
-typedef int (* SwfdecTagFunc) (SwfdecSwfDecoder *, guint);
-
-#define SWFDEC_TYPE_SWF_DECODER (swfdec_swf_decoder_get_type())
-#define SWFDEC_IS_SWF_DECODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SWF_DECODER))
-#define SWFDEC_IS_SWF_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SWF_DECODER))
-#define SWFDEC_SWF_DECODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SWF_DECODER, SwfdecSwfDecoder))
-#define SWFDEC_SWF_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SWF_DECODER, SwfdecSwfDecoderClass))
-#define SWFDEC_SWF_DECODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_SWF_DECODER, SwfdecSwfDecoderClass))
-
-struct _SwfdecSwfDecoder
-{
- SwfdecDecoder decoder;
-
- int version;
-
- gboolean compressed; /* TRUE if this is a compressed flash file */
- z_stream z; /* decompressor in use or uninitialized memory */
- SwfdecBuffer * buffer; /* buffer containing uncompressed data */
- guint bytes_parsed; /* number of bytes that have been processed by the parser */
-
- int state; /* where we are in the top-level state engine */
- SwfdecBits parse; /* where we are in global parsing */
- SwfdecBits b; /* temporary state while parsing */
-
- /* defined objects */
- GHashTable * characters; /* list of all objects with an id (called characters) */
- SwfdecSprite * main_sprite; /* the root sprite */
- SwfdecSprite * parse_sprite; /* the sprite that parsed at the moment */
- GHashTable * scripts; /* buffer -> script mapping for all scripts */
-
- gboolean use_network; /* allow network or local access */
- gboolean has_metadata; /* TRUE if this file contains metadata */
- gboolean protection; /* TRUE is this file is protected and may not be edited */
- char * password; /* MD5'd password to open for editing or NULL if may not be opened */
-
- SwfdecBuffer * jpegtables; /* jpeg tables for DefineJPEG compressed jpeg files */
-};
-
-struct _SwfdecSwfDecoderClass {
- SwfdecDecoderClass decoder_class;
-};
-
-GType swfdec_swf_decoder_get_type (void);
-
-gpointer swfdec_swf_decoder_get_character (SwfdecSwfDecoder * s,
- guint id);
-gpointer swfdec_swf_decoder_create_character (SwfdecSwfDecoder * s,
- guint id,
- GType type);
-
-void swfdec_swf_decoder_add_script (SwfdecSwfDecoder * s,
- SwfdecScript * script);
-SwfdecScript * swfdec_swf_decoder_get_script (SwfdecSwfDecoder * s,
- guint8 * data);
-
-SwfdecTagFunc swfdec_swf_decoder_get_tag_func (int tag);
-const char *swfdec_swf_decoder_get_tag_name (int tag);
-int swfdec_swf_decoder_get_tag_flag (int tag);
-
-G_END_DECLS
-
-#endif
diff --git a/libswfdec/swfdec_system.c b/libswfdec/swfdec_system.c
deleted file mode 100644
index 00cdaf7..0000000
--- a/libswfdec/swfdec_system.c
+++ /dev/null
@@ -1,315 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_system.h"
-#include "swfdec_debug.h"
-
-/*** gtk-doc ***/
-
-/**
- * SECTION:SwfdecSystem
- * @title: SwfdecSystem
- * @short_description: object holding system settings
- * @see_also: SwfdecPlayer
- *
- * This object is used to provide information about the system Swfdec currently
- * runs on.
- *
- * Almost all of this information can be categorized into three types:
- * Information about the current playback engine like manufacturer or version,
- * information about the current operating system and capabilities of the output
- * capabilities of the System like screen size.
- *
- * The information provided by this object is used by the Actionscript
- * System.capabilities.Query() function that is usually only run once during
- * initialization of the Flash player. If you want to set custom properties and
- * have them affect a running #SwfdecPlayer, you should change them before the
- * player gets initialized.
- *
- * Note that the System.capabilites object in Flash provides more functionality
- * than provided by this object. That information can be and is determined
- * automatically by Swfdec.
- */
-
-/**
- * SwfdecSystem:
- *
- * This is the object used for holding information about the current system. See
- * the introduction for details.
- */
-
-/*** SwfdecSystem ***/
-
-enum {
- PROP_0,
- PROP_DEBUGGER,
- PROP_MANUFACTURER,
- PROP_SERVER_MANUFACTURER,
- PROP_OS,
- PROP_OS_TYPE,
- PROP_PLAYER_TYPE,
- PROP_VERSION,
- PROP_LANGUAGE,
- PROP_SCREEN_WIDTH,
- PROP_SCREEN_HEIGHT,
- PROP_PAR,
- PROP_DPI,
- PROP_COLOR_MODE,
- PROP_UTC_OFFSET
-};
-
-G_DEFINE_TYPE (SwfdecSystem, swfdec_system, G_TYPE_OBJECT)
-
-static void
-swfdec_system_get_property (GObject *object, guint param_id, GValue *value,
- GParamSpec * pspec)
-{
- SwfdecSystem *system = SWFDEC_SYSTEM (object);
-
- switch (param_id) {
- case PROP_DEBUGGER:
- g_value_set_boolean (value, system->debugger);
- break;
- case PROP_MANUFACTURER:
- g_value_set_string (value, system->manufacturer);
- break;
- case PROP_SERVER_MANUFACTURER:
- g_value_set_string (value, system->server_manufacturer);
- break;
- case PROP_OS:
- g_value_set_string (value, system->os);
- break;
- case PROP_OS_TYPE:
- g_value_set_string (value, system->os_type);
- break;
- case PROP_PLAYER_TYPE:
- g_value_set_string (value, system->player_type);
- break;
- case PROP_VERSION:
- g_value_set_string (value, system->version);
- break;
- case PROP_LANGUAGE:
- g_value_set_string (value, system->language);
- break;
- case PROP_SCREEN_WIDTH:
- g_value_set_uint (value, system->screen_width);
- break;
- case PROP_SCREEN_HEIGHT:
- g_value_set_uint (value, system->screen_height);
- break;
- case PROP_PAR:
- g_value_set_double (value, system->par);
- break;
- case PROP_DPI:
- g_value_set_uint (value, system->dpi);
- break;
- case PROP_COLOR_MODE:
- g_value_set_string (value, system->color_mode);
- break;
- case PROP_UTC_OFFSET:
- g_value_set_int (value, system->utc_offset);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-swfdec_system_set_property (GObject *object, guint param_id, const GValue *value,
- GParamSpec *pspec)
-{
- SwfdecSystem *system = SWFDEC_SYSTEM (object);
- char *s;
-
- switch (param_id) {
- case PROP_DEBUGGER:
- system->debugger = g_value_get_boolean (value);
- break;
- case PROP_MANUFACTURER:
- s = g_value_dup_string (value);
- if (s) {
- g_free (system->manufacturer);
- system->manufacturer = s;
- }
- break;
- case PROP_SERVER_MANUFACTURER:
- s = g_value_dup_string (value);
- if (s) {
- g_free (system->server_manufacturer);
- system->server_manufacturer = s;
- }
- break;
- case PROP_OS:
- s = g_value_dup_string (value);
- if (s) {
- g_free (system->os);
- system->os = s;
- }
- break;
- case PROP_OS_TYPE:
- s = g_value_dup_string (value);
- if (s) {
- g_free (system->os_type);
- system->os_type = s;
- }
- break;
- case PROP_PLAYER_TYPE:
- s = g_value_dup_string (value);
- if (s) {
- g_free (system->player_type);
- system->player_type = s;
- }
- break;
- case PROP_VERSION:
- s = g_value_dup_string (value);
- if (s) {
- g_free (system->version);
- system->version = s;
- }
- break;
- case PROP_LANGUAGE:
- s = g_value_dup_string (value);
- if (s) {
- g_free (system->language);
- system->language = s;
- }
- break;
- case PROP_SCREEN_WIDTH:
- system->screen_width = g_value_get_uint (value);
- break;
- case PROP_SCREEN_HEIGHT:
- system->screen_height = g_value_get_uint (value);
- break;
- case PROP_PAR:
- system->par = g_value_get_double (value);
- break;
- case PROP_DPI:
- system->dpi = g_value_get_uint (value);
- break;
- case PROP_COLOR_MODE:
- s = g_value_dup_string (value);
- if (s) {
- g_free (system->color_mode);
- system->color_mode = s;
- }
- break;
- case PROP_UTC_OFFSET:
- system->utc_offset = g_value_get_int (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- }
-}
-
-static void
-swfdec_system_finalize (GObject *object)
-{
- SwfdecSystem *system = SWFDEC_SYSTEM (object);
-
- g_free (system->manufacturer);
- g_free (system->server_manufacturer);
- g_free (system->os);
- g_free (system->os_type);
- g_free (system->player_type);
- g_free (system->version);
- g_free (system->language);
- g_free (system->color_mode);
-
- G_OBJECT_CLASS (swfdec_system_parent_class)->finalize (object);
-}
-
-static void
-swfdec_system_class_init (SwfdecSystemClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = swfdec_system_finalize;
- object_class->get_property = swfdec_system_get_property;
- object_class->set_property = swfdec_system_set_property;
-
- g_object_class_install_property (object_class, PROP_DEBUGGER,
- g_param_spec_boolean ("debugger", "debugger", "TRUE if this player is supposed to be a debugger",
- FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class, PROP_MANUFACTURER,
- g_param_spec_string ("manufacturer", "manufacturer", "string describing the manufacturer of this system",
- "Macromedia Windows", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class, PROP_SERVER_MANUFACTURER,
- g_param_spec_string ("server-manufacturer", "server-manufacturer", "manufacturer of this system as used in serverString",
- "Adobe Windows", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class, PROP_OS,
- g_param_spec_string ("os", "os", "description of the operating system",
- "Windows XP", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class, PROP_OS_TYPE,
- g_param_spec_string ("os-type", "os type", "the operating system type: WIN, LIN or MAC",
- "WIN", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class, PROP_PLAYER_TYPE,
- g_param_spec_string ("player-type", "player type", "\"StandAlone\", \"External\", \"PlugIn\" or \"ActiveX\"",
- "StandAlone", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class, PROP_VERSION,
- g_param_spec_string ("version", "version", "version string",
- "WIN 9,0,100,0", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class, PROP_LANGUAGE,
- g_param_spec_string ("language", "language", "ISO 639-1 language code",
- "en", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class, PROP_SCREEN_WIDTH,
- g_param_spec_uint ("screen-width", "screen width", "width of the screen in pixels",
- 0, G_MAXUINT, 1024, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class, PROP_SCREEN_HEIGHT,
- g_param_spec_uint ("screen-height", "screen height", "height of the screen in pixels",
- 0, G_MAXUINT, 768, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class, PROP_PAR,
- g_param_spec_double ("pixel-aspect-ratio", "pixel aspect ratio", "the screen's pixel aspect ratio",
- G_MINDOUBLE, G_MAXDOUBLE, 1.0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class, PROP_DPI,
- g_param_spec_uint ("dpi", "dpi", "DPI setting of screen",
- 0, G_MAXUINT, 96, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class, PROP_COLOR_MODE,
- g_param_spec_string ("color-mode", "color mode", "\"color\", \"gray\" or \"bw\"",
- "color", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_object_class_install_property (object_class, PROP_UTC_OFFSET,
- g_param_spec_int ("utc-offset", "utc offset",
- "Difference between UTC and local timezone in minutes",
- -12 * 60, 12 * 60, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-}
-
-static void
-swfdec_system_init (SwfdecSystem *system)
-{
-}
-
-/**
- * swfdec_system_new:
- *
- * Creates a new #SwfdecSystem object using default settings. These settings are
- * mirroring the most common settings used by a Flash player. Currently this is
- * equivalent to a Flash player running on Windows XP.
- *
- * Returns: a new #SwfdecSystem object
- **/
-SwfdecSystem *
-swfdec_system_new (void)
-{
- return g_object_new (SWFDEC_TYPE_SYSTEM, NULL);
-}
diff --git a/libswfdec/swfdec_system.h b/libswfdec/swfdec_system.h
deleted file mode 100644
index 26c9647..0000000
--- a/libswfdec/swfdec_system.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_SYSTEM_H_
-#define _SWFDEC_SYSTEM_H_
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecSystem SwfdecSystem;
-typedef struct _SwfdecSystemClass SwfdecSystemClass;
-
-#define SWFDEC_TYPE_SYSTEM (swfdec_system_get_type())
-#define SWFDEC_IS_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SYSTEM))
-#define SWFDEC_IS_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SYSTEM))
-#define SWFDEC_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SYSTEM, SwfdecSystem))
-#define SWFDEC_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SYSTEM, SwfdecSystemClass))
-#define SWFDEC_SYSTEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_SYSTEM, SwfdecSystemClass))
-
-struct _SwfdecSystem
-{
- GObject object;
-
- /*< private >*/
- /* player engine */
- gboolean debugger; /* TRUE if this engine is debugging */
- char * manufacturer; /* note that this includes OS information */
- char * server_manufacturer; /* manufacturer as reported in serverString */
- char * os; /* supposed to identify the operating system */
- char * os_type; /* usually WIN, LIN or MAC */
- char * player_type; /* "StandAlone", "External", "PlugIn" or "ActiveX" */
- char * version; /* string of type "os_type MAJOR.MINOR.MACRO.MICRO" */
-
- /* system */
- char * language; /* ISO 639-1 language code */
-
- /* screen */
- guint screen_width; /* width of screen */
- guint screen_height; /* height of screen */
- double par; /* pixel aspect ratio */
- guint dpi; /* dpi setting */
- char * color_mode; /* "color", "gray" or "bw" */
-
- /* date */
- int utc_offset; /* difference between UTC and local timezeon in minutes */
-
-};
-
-struct _SwfdecSystemClass
-{
- GObjectClass object_class;
-};
-
-GType swfdec_system_get_type (void);
-
-SwfdecSystem * swfdec_system_new (void);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_system_as.c b/libswfdec/swfdec_system_as.c
deleted file mode 100644
index 0ba3f9e..0000000
--- a/libswfdec/swfdec_system_as.c
+++ /dev/null
@@ -1,347 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_string.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_codec_audio.h"
-#include "swfdec_debug.h"
-#include "swfdec_player_internal.h"
-
-SWFDEC_AS_NATIVE (1066, 0, swfdec_system_setClipboard)
-void
-swfdec_system_setClipboard (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("System.setClipboard (static)");
-}
-
-SWFDEC_AS_NATIVE (2107, 0, swfdec_system_showSettings)
-void
-swfdec_system_showSettings (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("System.showSettings (static)");
-}
-
-SWFDEC_AS_NATIVE (2107, 1, swfdec_system_get_exactSettings)
-void
-swfdec_system_get_exactSettings (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("System.exactSettings (static, get)");
-}
-
-SWFDEC_AS_NATIVE (2107, 2, swfdec_system_set_exactSettings)
-void
-swfdec_system_set_exactSettings (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("System.exactSettings (static, set)");
-}
-
-SWFDEC_AS_NATIVE (2107, 3, swfdec_system_get_useCodepage)
-void
-swfdec_system_get_useCodepage (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("System.useCodepage (static, get)");
-}
-
-SWFDEC_AS_NATIVE (2107, 4, swfdec_system_set_useCodepage)
-void
-swfdec_system_set_useCodepage (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("System.useCodepage (static, set)");
-}
-
-static void
-swfdec_system_has_audio (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- /* FIXME: allow setting this? */
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, TRUE);
-}
-
-static void
-swfdec_system_has_streaming_audio (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, TRUE);
-}
-
-static void
-swfdec_system_has_streaming_video (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- /* FIXME: check if video decoders got compiled in? */
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, TRUE);
-}
-
-static void
-swfdec_system_has_embedded_video (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- /* FIXME: what's this? */
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, TRUE);
-}
-
-static void
-swfdec_system_has_mp3 (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SwfdecAudioDecoder *dec = swfdec_audio_decoder_new (SWFDEC_AUDIO_CODEC_MP3,
- swfdec_audio_format_new (44100, 2, TRUE));
-
- if (dec) {
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, TRUE);
- swfdec_audio_decoder_free (dec);
- } else {
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
- }
-}
-
-static void
-swfdec_system_has_audio_encoder (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
-}
-
-static void
-swfdec_system_has_video_encoder (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
-}
-
-static void
-swfdec_system_has_accessibility (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
-}
-
-static void
-swfdec_system_has_printing (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
-}
-
-static void
-swfdec_system_has_screen_broadcast (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
-}
-
-static void
-swfdec_system_has_screen_playback (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
-}
-
-static void
-swfdec_system_is_debugger (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, player->priv->system->debugger);
-}
-
-static void
-swfdec_system_version (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (
- SWFDEC_AS_CONTEXT (player), player->priv->system->version));
-}
-
-static void
-swfdec_system_manufacturer (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (
- SWFDEC_AS_CONTEXT (player), player->priv->system->manufacturer));
-}
-
-static void
-swfdec_system_screen_width (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_INT (ret, player->priv->system->screen_width);
-}
-
-static void
-swfdec_system_screen_height (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_INT (ret, player->priv->system->screen_height);
-}
-
-static void
-swfdec_system_screen_dpi (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_INT (ret, player->priv->system->dpi);
-}
-
-static void
-swfdec_system_screen_color (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (
- SWFDEC_AS_CONTEXT (player), player->priv->system->color_mode));
-}
-
-static void
-swfdec_system_screen_par (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_NUMBER (ret, player->priv->system->par);
-}
-
-static void
-swfdec_system_os (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (
- SWFDEC_AS_CONTEXT (player), player->priv->system->os));
-}
-
-static void
-swfdec_system_language (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (
- SWFDEC_AS_CONTEXT (player), player->priv->system->language));
-}
-
-static void
-swfdec_system_has_ime (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
-}
-
-static void
-swfdec_system_player_type (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (
- SWFDEC_AS_CONTEXT (player), player->priv->system->player_type));
-}
-
-static void
-swfdec_system_av_disabled (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
-}
-
-static void
-swfdec_system_local_file_disabled (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
-}
-
-static void
-swfdec_system_windowless_disabled (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
-}
-
-static void
-swfdec_system_has_tls (SwfdecPlayer *player, SwfdecAsValue *ret)
-{
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
-}
-
-/* NB: ordered for the query string order */
-const struct {
- const char * name;
- const char * server_string;
- void (* get) (SwfdecPlayer *player, SwfdecAsValue *ret);
-} queries[] = {
- { SWFDEC_AS_STR_hasAudio, "A", swfdec_system_has_audio },
- { SWFDEC_AS_STR_hasStreamingAudio, "SA", swfdec_system_has_streaming_audio },
- { SWFDEC_AS_STR_hasStreamingVideo, "SV", swfdec_system_has_streaming_video },
- { SWFDEC_AS_STR_hasEmbeddedVideo, "EV", swfdec_system_has_embedded_video },
- { SWFDEC_AS_STR_hasMP3, "MP3", swfdec_system_has_mp3 },
- { SWFDEC_AS_STR_hasAudioEncoder, "AE", swfdec_system_has_audio_encoder },
- { SWFDEC_AS_STR_hasVideoEncoder, "VE", swfdec_system_has_video_encoder },
- { SWFDEC_AS_STR_hasAccessibility, "ACC", swfdec_system_has_accessibility },
- { SWFDEC_AS_STR_hasPrinting, "PR", swfdec_system_has_printing },
- { SWFDEC_AS_STR_hasScreenPlayback, "SP", swfdec_system_has_screen_playback },
- { SWFDEC_AS_STR_hasScreenBroadcast, "SB", swfdec_system_has_screen_broadcast },
- { SWFDEC_AS_STR_isDebugger, "DEB", swfdec_system_is_debugger },
- { SWFDEC_AS_STR_version, "V", swfdec_system_version },
- { SWFDEC_AS_STR_manufacturer, NULL, swfdec_system_manufacturer },
- { SWFDEC_AS_STR_screenResolutionX, "R", swfdec_system_screen_width },
- { SWFDEC_AS_STR_screenResolutionY, NULL, swfdec_system_screen_height },
- { SWFDEC_AS_STR_screenDPI, "DP", swfdec_system_screen_dpi },
- { SWFDEC_AS_STR_screenColor, "COL", swfdec_system_screen_color },
- { SWFDEC_AS_STR_pixelAspectRatio, NULL, swfdec_system_screen_par },
- { SWFDEC_AS_STR_os, "OS", swfdec_system_os },
- { SWFDEC_AS_STR_language, "L", swfdec_system_language },
- { SWFDEC_AS_STR_hasIME, "IME", swfdec_system_has_ime },
- { SWFDEC_AS_STR_playerType, "PT", swfdec_system_player_type },
- { SWFDEC_AS_STR_avHardwareDisable, "AVD", swfdec_system_av_disabled },
- { SWFDEC_AS_STR_localFileReadDisable, "LFD", swfdec_system_local_file_disabled },
- { SWFDEC_AS_STR_windowlessDisable, "WD", swfdec_system_windowless_disabled },
- { SWFDEC_AS_STR_hasTLS, "TLS", swfdec_system_has_tls },
-};
-
-SWFDEC_AS_NATIVE (11, 0, swfdec_system_query)
-void
-swfdec_system_query (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
-{
- SwfdecPlayer *player = SWFDEC_PLAYER (cx);
- SwfdecAsValue val;
- guint i;
- GString *server;
-
- if (object == NULL) {
- SWFDEC_WARNING ("no this object in Query()");
- return;
- }
-
- server = g_string_new ("");
- for (i = 0; i < G_N_ELEMENTS (queries); i++) {
- queries[i].get (player, &val);
- swfdec_as_object_set_variable (object, queries[i].name, &val);
- if (queries[i].name == SWFDEC_AS_STR_screenResolutionY) {
- g_string_append_printf (server, "x%d", (int) SWFDEC_AS_VALUE_GET_NUMBER (&val));
- } else if (queries[i].name == SWFDEC_AS_STR_pixelAspectRatio) {
- char buffer[10];
- g_ascii_formatd (buffer, sizeof (buffer), "%.1f",
- SWFDEC_AS_VALUE_GET_NUMBER (&val));
- g_string_append (server, "&AR=");
- g_string_append (server, buffer);
- } else if (queries[i].name == SWFDEC_AS_STR_manufacturer) {
- char *s = swfdec_as_string_escape (cx, player->priv->system->server_manufacturer);
- g_string_append_printf (server, "&M=%s", s);
- g_free (s);
- } else {
- g_assert (queries[i].server_string);
- if (i > 0)
- g_string_append_c (server, '&');
- g_string_append (server, queries[i].server_string);
- g_string_append_c (server, '=');
- if (SWFDEC_AS_VALUE_IS_BOOLEAN (&val)) {
- g_string_append_c (server, SWFDEC_AS_VALUE_GET_BOOLEAN (&val) ? 't' : 'f');
- } else if (SWFDEC_AS_VALUE_IS_NUMBER (&val)) {
- g_string_append_printf (server, "%d", (int) SWFDEC_AS_VALUE_GET_NUMBER (&val));
- } else if (SWFDEC_AS_VALUE_IS_STRING (&val)) {
- char *s = swfdec_as_string_escape (cx, SWFDEC_AS_VALUE_GET_STRING (&val));
- g_string_append (server, s);
- g_free (s);
- } else {
- g_assert_not_reached ();
- }
- }
- }
- SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_give_string (cx, g_string_free (server, FALSE)));
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_serverString, &val);
-}
-
diff --git a/libswfdec/swfdec_system_ime.c b/libswfdec/swfdec_system_ime.c
deleted file mode 100644
index 3506806..0000000
--- a/libswfdec/swfdec_system_ime.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (13, 0, swfdec_system_ime_getEnabled)
-void
-swfdec_system_ime_getEnabled (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("System.IME.getEnabled (static)");
-}
-
-SWFDEC_AS_NATIVE (13, 1, swfdec_system_ime_setEnabled)
-void
-swfdec_system_ime_setEnabled (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("System.IME.setEnabled (static)");
-}
-
-SWFDEC_AS_NATIVE (13, 2, swfdec_system_ime_getCovnersionMode)
-void
-swfdec_system_ime_getCovnersionMode (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("System.IME.getCovnersionMode (static)");
-}
-
-SWFDEC_AS_NATIVE (13, 3, swfdec_system_ime_setConversionMode)
-void
-swfdec_system_ime_setConversionMode (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("System.IME.setConversionMode (static)");
-}
-
-SWFDEC_AS_NATIVE (13, 4, swfdec_system_ime_setCompositionString)
-void
-swfdec_system_ime_setCompositionString (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("System.IME.setCompositionString (static)");
-}
-
-SWFDEC_AS_NATIVE (13, 5, swfdec_system_ime_doConversion)
-void
-swfdec_system_ime_doConversion (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("System.IME.doConversion (static)");
-}
diff --git a/libswfdec/swfdec_system_security.c b/libswfdec/swfdec_system_security.c
deleted file mode 100644
index 284eea1..0000000
--- a/libswfdec/swfdec_system_security.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_resource.h"
-#include "swfdec_player_internal.h"
-
-// properties
-SWFDEC_AS_NATIVE (12, 0, swfdec_system_security_allowDomain)
-void
-swfdec_system_security_allowDomain (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("System.security.allowDomain (static)");
-}
-
-SWFDEC_AS_NATIVE (12, 1, swfdec_system_security_allowInsecureDomain)
-void
-swfdec_system_security_allowInsecureDomain (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("System.security.allowInsecureDomain (static)");
-}
-
-SWFDEC_AS_NATIVE (12, 2, swfdec_system_security_loadPolicyFile)
-void
-swfdec_system_security_loadPolicyFile (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("System.security.loadPolicyFile (static)");
-}
-
-SWFDEC_AS_NATIVE (12, 3, swfdec_system_security_chooseLocalSwfPath)
-void
-swfdec_system_security_chooseLocalSwfPath (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("System.security.chooseLocalSwfPath (static)");
-}
-
-SWFDEC_AS_NATIVE (12, 4, swfdec_system_security_escapeDomain)
-void
-swfdec_system_security_escapeDomain (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("System.security.escapeDomain (static)");
-}
-
-SWFDEC_AS_NATIVE (12, 5, swfdec_system_security_get_sandboxType)
-void
-swfdec_system_security_get_sandboxType (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- switch (SWFDEC_SANDBOX (cx->global)->type) {
- case SWFDEC_SANDBOX_REMOTE:
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_remote);
- break;
-
- case SWFDEC_SANDBOX_LOCAL_FILE:
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_localWithFile);
- break;
-
- case SWFDEC_SANDBOX_LOCAL_NETWORK:
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_localWithNetwork);
- break;
-
- case SWFDEC_SANDBOX_LOCAL_TRUSTED:
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_localTrusted);
- break;
-
- case SWFDEC_SANDBOX_NONE:
- default:
- g_return_if_reached ();
- }
-}
-
-SWFDEC_AS_NATIVE (12, 6, swfdec_system_security_set_sandboxType)
-void
-swfdec_system_security_set_sandboxType (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- // read-only
-}
-
-// PolicyFileResolver
-
-SWFDEC_AS_NATIVE (15, 0, swfdec_system_security_policy_file_resolver_resolve)
-void
-swfdec_system_security_policy_file_resolver_resolve (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("System.security.PolicyFileResolver.resolve");
-}
diff --git a/libswfdec/swfdec_tag.c b/libswfdec/swfdec_tag.c
deleted file mode 100644
index 133f8b2..0000000
--- a/libswfdec/swfdec_tag.c
+++ /dev/null
@@ -1,628 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <zlib.h>
-#include <math.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "swfdec_tag.h"
-#include "swfdec_bits.h"
-#include "swfdec_button.h"
-#include "swfdec_debug.h"
-#include "swfdec_text_field.h"
-#include "swfdec_filter.h"
-#include "swfdec_font.h"
-#include "swfdec_image.h"
-#include "swfdec_morphshape.h"
-#include "swfdec_pattern.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_script_internal.h"
-#include "swfdec_shape.h"
-#include "swfdec_sound.h"
-#include "swfdec_sprite.h"
-#include "swfdec_text.h"
-#include "swfdec_video.h"
-
-static int
-tag_func_end (SwfdecSwfDecoder * s, guint tag)
-{
- return SWFDEC_STATUS_OK;
-}
-
-static int
-tag_func_protect (SwfdecSwfDecoder * s, guint tag)
-{
- if (s->protection) {
- SWFDEC_INFO ("This file is really protected.");
- g_free (s->password);
- s->password = NULL;
- }
- s->protection = TRUE;
- if (swfdec_bits_left (&s->b)) {
- /* FIXME: What's this for? */
- swfdec_bits_get_u16 (&s->b);
- s->password = swfdec_bits_get_string (&s->b, s->version);
- }
- return SWFDEC_STATUS_OK;
-}
-
-static int
-tag_func_frame_label (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecSpriteFrame *frame = &s->parse_sprite->frames[s->parse_sprite->parse_frame];
-
- if (frame->label) {
- SWFDEC_WARNING ("frame %d already has a label (%s)", s->parse_sprite->parse_frame, frame->label);
- g_free (frame->label);
- }
- frame->label = swfdec_bits_get_string (&s->b, s->version);
- SWFDEC_LOG ("frame %d named %s", s->parse_sprite->parse_frame, frame->label);
-
- return SWFDEC_STATUS_OK;
-}
-
-
-/* text */
-
-int
-tag_func_define_text (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecBits *bits = &s->b;
- int id;
- int n_glyph_bits;
- int n_advance_bits;
- SwfdecText *text = NULL;
- SwfdecTextGlyph glyph = { 0 };
-
- id = swfdec_bits_get_u16 (bits);
- text = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_TEXT);
- if (!text)
- return SWFDEC_STATUS_OK;
-
- glyph.color = 0xffffffff;
-
- swfdec_bits_get_rect (bits, &SWFDEC_GRAPHIC (text)->extents);
- swfdec_bits_get_matrix (bits, &text->transform, &text->transform_inverse);
- swfdec_bits_syncbits (bits);
- n_glyph_bits = swfdec_bits_get_u8 (bits);
- n_advance_bits = swfdec_bits_get_u8 (bits);
-
- //printf(" n_glyph_bits = %d\n", n_glyph_bits);
- //printf(" n_advance_bits = %d\n", n_advance_bits);
-
- while (swfdec_bits_peekbits (bits, 8) != 0) {
- int type;
-
- type = swfdec_bits_getbit (bits);
- if (type == 0) {
- /* glyph record */
- int n_glyphs;
- int i;
-
- n_glyphs = swfdec_bits_getbits (bits, 7);
- if (glyph.font == NULL)
- SWFDEC_ERROR ("no font for %d glyphs", n_glyphs);
- for (i = 0; i < n_glyphs; i++) {
- glyph.glyph = swfdec_bits_getbits (bits, n_glyph_bits);
-
- if (glyph.font != NULL)
- g_array_append_val (text->glyphs, glyph);
- glyph.x += swfdec_bits_getsbits (bits, n_advance_bits);
- }
- } else {
- /* state change */
- int reserved;
- int has_font;
- int has_color;
- int has_y_offset;
- int has_x_offset;
-
- reserved = swfdec_bits_getbits (bits, 3);
- has_font = swfdec_bits_getbit (bits);
- has_color = swfdec_bits_getbit (bits);
- has_y_offset = swfdec_bits_getbit (bits);
- has_x_offset = swfdec_bits_getbit (bits);
- if (has_font) {
- glyph.font = swfdec_swf_decoder_get_character (s, swfdec_bits_get_u16 (bits));
- //printf(" font = %d\n",font);
- }
- if (has_color) {
- if (tag == SWFDEC_TAG_DEFINETEXT) {
- glyph.color = swfdec_bits_get_color (bits);
- } else {
- glyph.color = swfdec_bits_get_rgba (bits);
- }
- //printf(" color = %08x\n",glyph.color);
- }
- if (has_x_offset) {
- glyph.x = swfdec_bits_get_s16 (bits);
- }
- if (has_y_offset) {
- glyph.y = swfdec_bits_get_s16 (bits);
- }
- if (has_font) {
- glyph.height = swfdec_bits_get_u16 (bits);
- }
- }
- swfdec_bits_syncbits (bits);
- }
- swfdec_bits_get_u8 (bits);
-
- return SWFDEC_STATUS_OK;
-}
-
-int
-tag_func_define_sprite (SwfdecSwfDecoder * s, guint define_sprite_tag)
-{
- SwfdecBits parse;
- int id;
- SwfdecSprite *sprite;
- int ret;
- guint tag = 1;
-
- parse = s->b;
-
- id = swfdec_bits_get_u16 (&parse);
- sprite = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_SPRITE);
- if (!sprite)
- return SWFDEC_STATUS_OK;
-
- SWFDEC_LOG (" ID: %d", id);
-
- swfdec_sprite_set_n_frames (sprite, swfdec_bits_get_u16 (&parse), SWFDEC_DECODER (s)->rate);
-
- s->parse_sprite = sprite;
- while (swfdec_bits_left (&parse)) {
- int x;
- guint tag_len;
- SwfdecTagFunc func;
-
- x = swfdec_bits_get_u16 (&parse);
- tag = (x >> 6) & 0x3ff;
- tag_len = x & 0x3f;
- if (tag_len == 0x3f) {
- tag_len = swfdec_bits_get_u32 (&parse);
- }
- SWFDEC_INFO ("sprite parsing at %td, tag %d %s, length %d",
- parse.buffer ? parse.ptr - parse.buffer->data : 0, tag,
- swfdec_swf_decoder_get_tag_name (tag), tag_len);
-
- if (tag_len == 0) {
- swfdec_bits_init_data (&s->b, NULL, 0);
- } else {
- swfdec_bits_init_bits (&s->b, &parse, tag_len);
- }
-
- func = swfdec_swf_decoder_get_tag_func (tag);
- if (tag == 0) {
- break;
- } else if (func == NULL) {
- SWFDEC_WARNING ("tag function not implemented for %d %s",
- tag, swfdec_swf_decoder_get_tag_name (tag));
- } else if ((swfdec_swf_decoder_get_tag_flag (tag) & 1) == 0) {
- SWFDEC_ERROR ("invalid tag %d %s during DefineSprite",
- tag, swfdec_swf_decoder_get_tag_name (tag));
- } else if (s->parse_sprite->parse_frame < s->parse_sprite->n_frames) {
- ret = func (s, tag);
-
- if (swfdec_bits_left (&s->b)) {
- SWFDEC_WARNING ("early parse finish (%d bytes)",
- swfdec_bits_left (&s->b) / 8);
- }
- } else {
- SWFDEC_ERROR ("data after last frame");
- }
- }
-
- /* sanity check the sprite */
- if (s->parse_sprite->n_frames != s->parse_sprite->parse_frame) {
- SWFDEC_INFO ("not enough frames in sprite %u (have %u, want %u), filling up with empty frames",
- id, s->parse_sprite->parse_frame, s->parse_sprite->n_frames);
- s->parse_sprite->parse_frame = s->parse_sprite->n_frames;
- }
-
- s->b = parse;
- /* this assumes that no recursive DefineSprite happens and we check it doesn't */
- s->parse_sprite = s->main_sprite;
- SWFDEC_LOG ("done parsing this sprite");
-
- return SWFDEC_STATUS_OK;
-}
-
-#if 0
-static int
-tag_func_define_button_2 (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecBits bits;
- int id, reserved;
- guint length;
- SwfdecButton *button;
- char *script_name;
-
- id = swfdec_bits_get_u16 (&s->b);
- button = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_BUTTON);
- if (!button)
- return SWFDEC_STATUS_OK;
-
- SWFDEC_LOG (" ID: %d", id);
-
- reserved = swfdec_bits_getbits (&s->b, 7);
- button->menubutton = swfdec_bits_getbit (&s->b) ? TRUE : FALSE;
- length = swfdec_bits_get_u16 (&s->b);
-
- SWFDEC_LOG (" reserved = %d", reserved);
- SWFDEC_LOG (" menu = %d", button->menubutton);
- SWFDEC_LOG (" length of region = %d", length);
-
- if (length)
- swfdec_bits_init_bits (&bits, &s->b, length > 2 ? length - 2 : 0);
- else
- swfdec_bits_init_bits (&bits, &s->b, swfdec_bits_left (&s->b) / 8);
- while (swfdec_bits_peek_u8 (&bits)) {
- guint character;
- guint depth;
- guint states;
- gboolean has_blend_mode, has_filters;
- SwfdecContent *content;
-
- if (s->version >= 8) {
- reserved = swfdec_bits_getbits (&bits, 2);
- has_blend_mode = swfdec_bits_getbit (&bits);
- has_filters = swfdec_bits_getbit (&bits);
- SWFDEC_LOG (" reserved = %d", reserved);
- SWFDEC_LOG (" has_blend_mode = %d", has_blend_mode);
- SWFDEC_LOG (" has_filters = %d", has_filters);
- } else {
- reserved = swfdec_bits_getbits (&bits, 4);
- has_blend_mode = 0;
- has_filters = 0;
- SWFDEC_LOG (" reserved = %d", reserved);
- }
- states = swfdec_bits_getbits (&bits, 4);
- character = swfdec_bits_get_u16 (&bits);
- depth = swfdec_bits_get_u16 (&bits);
-
- SWFDEC_LOG (" states: %s%s%s%scharacter=%u layer=%u",
- states & (1 << SWFDEC_BUTTON_HIT) ? "HIT " : "",
- states & (1 << SWFDEC_BUTTON_DOWN) ? "DOWN " : "",
- states & (1 << SWFDEC_BUTTON_OVER) ? "OVER " : "",
- states & (1 << SWFDEC_BUTTON_UP) ? "UP " : "",
- character, depth);
- content = swfdec_content_new (depth);
-
- swfdec_bits_get_matrix (&bits, &content->transform, NULL);
- content->has_transform = TRUE;
- SWFDEC_LOG ("matrix: %g %g %g %g %g %g",
- content->transform.xx, content->transform.yy,
- content->transform.xy, content->transform.yx,
- content->transform.x0, content->transform.y0);
- swfdec_bits_get_color_transform (&bits, &content->color_transform);
- content->has_color_transform = TRUE;
-
- content->graphic = swfdec_swf_decoder_get_character (s, character);
- if (has_blend_mode) {
- content->blend_mode = swfdec_bits_get_u8 (&bits);
- SWFDEC_LOG (" blend mode = %u", content->blend_mode);
- }
- if (has_filters) {
- GSList *list = swfdec_filter_parse (SWFDEC_DECODER (s)->player, &bits);
- g_slist_free (list);
- }
- if (!SWFDEC_IS_GRAPHIC (content->graphic)) {
- SWFDEC_ERROR ("id %u does not reference a graphic, ignoring", character);
- swfdec_content_free (content);
- } else {
- swfdec_button_append_content (button, states, content);
- }
- }
- swfdec_bits_get_u8 (&bits);
- if (swfdec_bits_left (&bits)) {
- SWFDEC_WARNING ("%u bytes left when parsing button records", swfdec_bits_left (&bits) / 8);
- }
-
- script_name = g_strdup_printf ("Button%u", SWFDEC_CHARACTER (button)->id);
- while (length != 0) {
- guint condition, key;
-
- length = swfdec_bits_get_u16 (&s->b);
- if (length)
- swfdec_bits_init_bits (&bits, &s->b, length > 2 ? length - 2 : 0);
- else
- swfdec_bits_init_bits (&bits, &s->b, swfdec_bits_left (&s->b) / 8);
- condition = swfdec_bits_get_u16 (&bits);
- key = condition >> 9;
- condition &= 0x1FF;
-
- SWFDEC_LOG (" length = %d", length);
-
- if (button->events == NULL)
- button->events = swfdec_event_list_new (SWFDEC_DECODER (s)->player);
- SWFDEC_LOG (" new event for condition %u (key %u)", condition, key);
- swfdec_event_list_parse (button->events, &bits, s->version, condition, key,
- script_name);
- if (swfdec_bits_left (&bits)) {
- SWFDEC_WARNING ("%u bytes left after parsing script", swfdec_bits_left (&bits) / 8);
- }
- }
- g_free (script_name);
-
- return SWFDEC_STATUS_OK;
-}
-
-static int
-tag_func_define_button (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecBits *bits = &s->b;
- int id;
- SwfdecButton *button;
- char *script_name;
-
- id = swfdec_bits_get_u16 (bits);
- button = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_BUTTON);
- if (!button)
- return SWFDEC_STATUS_OK;
-
- SWFDEC_LOG (" ID: %d", id);
-
- while (swfdec_bits_peek_u8 (bits)) {
- int reserved;
- guint character;
- guint depth;
- guint states;
- SwfdecContent *content;
-
- swfdec_bits_syncbits (bits);
- reserved = swfdec_bits_getbits (bits, 4);
- states = swfdec_bits_getbits (bits, 4);
- character = swfdec_bits_get_u16 (bits);
- depth = swfdec_bits_get_u16 (bits);
-
- SWFDEC_LOG (" reserved = %d", reserved);
- SWFDEC_LOG ("states: %s%s%s%scharacter=%u layer=%u",
- states & (1 << SWFDEC_BUTTON_HIT) ? "HIT " : "",
- states & (1 << SWFDEC_BUTTON_DOWN) ? "DOWN " : "",
- states & (1 << SWFDEC_BUTTON_OVER) ? "OVER " : "",
- states & (1 << SWFDEC_BUTTON_UP) ? "UP " : "",
- character, depth);
- content = swfdec_content_new (depth);
-
- swfdec_bits_get_matrix (bits, &content->transform, NULL);
- content->has_transform = TRUE;
- SWFDEC_LOG ("matrix: %g %g %g %g %g %g",
- content->transform.xx, content->transform.yy,
- content->transform.xy, content->transform.yx,
- content->transform.x0, content->transform.y0);
-
- content->graphic = swfdec_swf_decoder_get_character (s, character);
- if (!SWFDEC_IS_GRAPHIC (content->graphic)) {
- SWFDEC_ERROR ("id %u does not reference a graphic, ignoring", character);
- swfdec_content_free (content);
- } else {
- swfdec_button_append_content (button, states, content);
- }
- }
- swfdec_bits_get_u8 (bits);
-
- script_name = g_strdup_printf ("Button%u", SWFDEC_CHARACTER (button)->id);
- button->events = swfdec_event_list_new (SWFDEC_DECODER (s)->player);
- swfdec_event_list_parse (button->events, &s->b, s->version,
- SWFDEC_BUTTON_OVER_UP_TO_OVER_DOWN, 0, script_name);
- g_free (script_name);
-
- return SWFDEC_STATUS_OK;
-}
-#endif
-
-static int
-tag_func_file_attributes (SwfdecSwfDecoder *s, guint tag)
-{
- if (swfdec_bits_getbits (&s->b, 3))
- SWFDEC_INFO ("reserved bits (1) aren't 0");
- s->has_metadata = swfdec_bits_getbit (&s->b);
- SWFDEC_LOG (" has metadata: %d", s->has_metadata);
- if (swfdec_bits_getbits (&s->b, 3))
- SWFDEC_INFO ("reserved bits (2) aren't 0");
- s->use_network = swfdec_bits_getbit (&s->b);
- SWFDEC_LOG (" use network: %d", s->use_network);
- if (swfdec_bits_getbits (&s->b, 24))
- SWFDEC_INFO ("reserved bits (3) aren't 0");
- /* initialize default security if it wasn't initialized yet */
-
- return SWFDEC_STATUS_OK;
-}
-
-static int
-tag_func_enqueue (SwfdecSwfDecoder *s, guint tag)
-{
- SwfdecBuffer *buffer;
-
- buffer = swfdec_bits_get_buffer (&s->b, -1);
- SWFDEC_LOG ("queueing %s tag for sprite %u", swfdec_swf_decoder_get_tag_name (tag),
- SWFDEC_CHARACTER (s->parse_sprite)->id);
- swfdec_sprite_add_action (s->parse_sprite, tag, buffer);
-
- return SWFDEC_STATUS_OK;
-}
-
-static int
-tag_func_show_frame (SwfdecSwfDecoder * s, guint tag)
-{
- SWFDEC_DEBUG("show_frame %d of id %d", s->parse_sprite->parse_frame,
- SWFDEC_CHARACTER (s->parse_sprite)->id);
-
- s->parse_sprite->parse_frame++;
- if (s->parse_sprite->parse_frame < s->parse_sprite->n_frames) {
- SwfdecSpriteFrame *old = &s->parse_sprite->frames[s->parse_sprite->parse_frame - 1];
- SwfdecSpriteFrame *new = &s->parse_sprite->frames[s->parse_sprite->parse_frame];
- if (old->sound_head)
- new->sound_head = g_object_ref (old->sound_head);
- }
- tag_func_enqueue (s, tag);
-
- return SWFDEC_STATUS_IMAGE;
-}
-
-static int
-tag_func_do_action (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecScript *script;
- SwfdecBits bits;
- char *name;
-
- name = g_strdup_printf ("Sprite%u_Frame%u", SWFDEC_CHARACTER (s->parse_sprite)->id,
- s->parse_sprite->parse_frame);
- bits = s->b;
- script = swfdec_script_new_from_bits (&bits, name, s->version);
- g_free (name);
- if (script) {
- swfdec_swf_decoder_add_script (s, script);
- tag_func_enqueue (s, tag);
- }
-
- return SWFDEC_STATUS_OK;
-}
-
-struct tag_func_struct
-{
- const char *name;
- SwfdecTagFunc func;
- int flag;
-};
-static struct tag_func_struct tag_funcs[] = {
- [SWFDEC_TAG_END] = {"End", tag_func_end, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_SHOWFRAME] = {"ShowFrame", tag_func_show_frame, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_DEFINESHAPE] = {"DefineShape", tag_define_shape, 0},
- [SWFDEC_TAG_FREECHARACTER] = {"FreeCharacter", NULL, 0},
- [SWFDEC_TAG_PLACEOBJECT] = {"PlaceObject", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_REMOVEOBJECT] = {"RemoveObject", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_DEFINEBITSJPEG] = {"DefineBitsJPEG", tag_func_define_bits_jpeg, 0},
- [SWFDEC_TAG_DEFINEBUTTON] = {"DefineButton", tag_func_define_button, 0},
- [SWFDEC_TAG_JPEGTABLES] = {"JPEGTables", swfdec_image_jpegtables, 0},
- [SWFDEC_TAG_SETBACKGROUNDCOLOR] =
- {"SetBackgroundColor", tag_func_set_background_color, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_DEFINEFONT] = {"DefineFont", tag_func_define_font, 0},
- [SWFDEC_TAG_DEFINETEXT] = {"DefineText", tag_func_define_text, 0},
- [SWFDEC_TAG_DOACTION] = {"DoAction", tag_func_do_action, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_DEFINEFONTINFO] = {"DefineFontInfo", tag_func_define_font_info, 0},
- [SWFDEC_TAG_DEFINESOUND] = {"DefineSound", tag_func_define_sound, 0},
- [SWFDEC_TAG_STARTSOUND] = {"StartSound", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_DEFINEBUTTONSOUND] =
- {"DefineButtonSound", tag_func_define_button_sound, 0},
- [SWFDEC_TAG_SOUNDSTREAMHEAD] = {"SoundStreamHead", tag_func_sound_stream_head, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_SOUNDSTREAMBLOCK] = {"SoundStreamBlock", tag_func_sound_stream_block, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_DEFINEBITSLOSSLESS] =
- {"DefineBitsLossless", tag_func_define_bits_lossless, 0},
- [SWFDEC_TAG_DEFINEBITSJPEG2] = {"DefineBitsJPEG2", tag_func_define_bits_jpeg_2, 0},
- [SWFDEC_TAG_DEFINESHAPE2] = {"DefineShape2", tag_define_shape, 0},
- [SWFDEC_TAG_DEFINEBUTTONCXFORM] = {"DefineButtonCXForm", NULL, 0},
- [SWFDEC_TAG_PROTECT] = {"Protect", tag_func_protect, 0},
- [SWFDEC_TAG_PLACEOBJECT2] = {"PlaceObject2", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_REMOVEOBJECT2] = {"RemoveObject2", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_DEFINESHAPE3] = {"DefineShape3", tag_define_shape_3, 0},
- [SWFDEC_TAG_DEFINETEXT2] = {"DefineText2", tag_func_define_text, 0},
- [SWFDEC_TAG_DEFINEBUTTON2] = {"DefineButton2", tag_func_define_button_2, 0},
- [SWFDEC_TAG_DEFINEBITSJPEG3] = {"DefineBitsJPEG3", tag_func_define_bits_jpeg_3, 0},
- [SWFDEC_TAG_DEFINEBITSLOSSLESS2] =
- {"DefineBitsLossless2", tag_func_define_bits_lossless_2, 0},
- [SWFDEC_TAG_DEFINEEDITTEXT] = {"DefineEditText", tag_func_define_edit_text, 0},
- [SWFDEC_TAG_DEFINEMOVIE] = {"DefineMovie", NULL, 0},
- [SWFDEC_TAG_DEFINESPRITE] = {"DefineSprite", tag_func_define_sprite, 0},
- [SWFDEC_TAG_NAMECHARACTER] = {"NameCharacter", NULL, 0},
- [SWFDEC_TAG_SERIALNUMBER] = {"SerialNumber", NULL, 0},
- [SWFDEC_TAG_GENERATORTEXT] = {"GeneratorText", NULL, 0},
- [SWFDEC_TAG_FRAMELABEL] = {"FrameLabel", tag_func_frame_label, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_SOUNDSTREAMHEAD2] = {"SoundStreamHead2", tag_func_sound_stream_head, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_DEFINEMORPHSHAPE] =
- {"DefineMorphShape", tag_define_morph_shape, 0},
- [SWFDEC_TAG_DEFINEFONT2] = {"DefineFont2", tag_func_define_font_2, 0},
- [SWFDEC_TAG_TEMPLATECOMMAND] = {"TemplateCommand", NULL, 0},
- [SWFDEC_TAG_GENERATOR3] = {"Generator3", NULL, 0},
- [SWFDEC_TAG_EXTERNALFONT] = {"ExternalFont", NULL, 0},
- [SWFDEC_TAG_EXPORTASSETS] = {"ExportAssets", tag_func_enqueue, 0},
- [SWFDEC_TAG_IMPORTASSETS] = {"ImportAssets", NULL, 0},
- [SWFDEC_TAG_ENABLEDEBUGGER] = {"EnableDebugger", NULL, 0},
- [SWFDEC_TAG_DOINITACTION] = {"DoInitAction", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_DEFINEVIDEOSTREAM] = {"DefineVideoStream", tag_func_define_video, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_VIDEOFRAME] = {"VideoFrame", tag_func_video_frame, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_DEFINEFONTINFO2] = {"DefineFontInfo2", tag_func_define_font_info, 0},
- [SWFDEC_TAG_DEBUGID] = {"DebugID", NULL, 0},
- [SWFDEC_TAG_ENABLEDEBUGGER2] = {"EnableDebugger2", NULL, 0},
- [SWFDEC_TAG_SCRIPTLIMITS] = {"ScriptLimits", NULL, 0},
- [SWFDEC_TAG_SETTABINDEX] = {"SetTabIndex", NULL, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_FILEATTRIBUTES] = {"FileAttributes", tag_func_file_attributes, SWFDEC_TAG_FIRST_ONLY },
- [SWFDEC_TAG_PLACEOBJECT3] = {"PlaceObject3", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_IMPORTASSETS2] = {"ImportAssets2", NULL, 0},
- [SWFDEC_TAG_DEFINEFONTALIGNZONES] = {"DefineFontAlignZones", NULL, 0},
- [SWFDEC_TAG_CSMTEXTSETTINGS] = {"CSMTextSettings", NULL, 0},
- [SWFDEC_TAG_DEFINEFONT3] = {"DefineFont3", tag_func_define_font_3, 0},
- [SWFDEC_TAG_AVM2DECL] = {"AVM2Decl", NULL, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_METADATA] = {"Metadata", NULL, 0},
- [SWFDEC_TAG_DEFINESCALINGGRID] = {"DefineScalingGrid", NULL, 0},
- [SWFDEC_TAG_AVM2ACTION] = {"AVM2Action", NULL, SWFDEC_TAG_DEFINE_SPRITE },
- [SWFDEC_TAG_DEFINESHAPE4] = {"DefineShape4", tag_define_shape_4, 0},
- [SWFDEC_TAG_DEFINEMORPHSHAPE2] = {"DefineMorphShape2", NULL, 0},
- [SWFDEC_TAG_PRIVATE_IMAGE] = { "PrivateImage", NULL, 0},
- [SWFDEC_TAG_DEFINESCENEDATA] = { "DefineSceneData", NULL, 0},
- [SWFDEC_TAG_DEFINEBINARYDATA] = { "DefineBinaryData", NULL, 0},
- [SWFDEC_TAG_DEFINEFONTNAME] = { "DefineFontName", NULL, 0},
- [SWFDEC_TAG_STARTSOUND2] = {"StartSound2", NULL, SWFDEC_TAG_DEFINE_SPRITE }
-};
-
-static const int n_tag_funcs = sizeof (tag_funcs) / sizeof (tag_funcs[0]);
-
-const char *
-swfdec_swf_decoder_get_tag_name (int tag)
-{
- if (tag >= 0 && tag < n_tag_funcs) {
- if (tag_funcs[tag].name) {
- return tag_funcs[tag].name;
- }
- }
-
- return "unknown";
-}
-
-SwfdecTagFunc
-swfdec_swf_decoder_get_tag_func (int tag)
-{
- if (tag >= 0 && tag < n_tag_funcs) {
- if (tag_funcs[tag].func) {
- return tag_funcs[tag].func;
- }
- }
-
- return NULL;
-}
-
-int
-swfdec_swf_decoder_get_tag_flag (int tag)
-{
- if (tag >= 0 && tag < n_tag_funcs) {
- return tag_funcs[tag].flag;
- }
-
- return 0;
-}
diff --git a/libswfdec/swfdec_tag.h b/libswfdec/swfdec_tag.h
deleted file mode 100644
index cee23ce..0000000
--- a/libswfdec/swfdec_tag.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006-2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef __LIBSWFDEC_TAGS_H__
-#define __LIBSWFDEC_TAGS_H__
-
-typedef enum {
- SWFDEC_TAG_END = 0,
- SWFDEC_TAG_SHOWFRAME = 1,
- SWFDEC_TAG_DEFINESHAPE = 2,
- SWFDEC_TAG_FREECHARACTER = 3,
- SWFDEC_TAG_PLACEOBJECT = 4,
- SWFDEC_TAG_REMOVEOBJECT = 5,
- SWFDEC_TAG_DEFINEBITSJPEG = 6,
- SWFDEC_TAG_DEFINEBUTTON = 7,
- SWFDEC_TAG_JPEGTABLES = 8,
- SWFDEC_TAG_SETBACKGROUNDCOLOR = 9,
- SWFDEC_TAG_DEFINEFONT = 10,
- SWFDEC_TAG_DEFINETEXT = 11,
- SWFDEC_TAG_DOACTION = 12,
- SWFDEC_TAG_DEFINEFONTINFO = 13,
- SWFDEC_TAG_DEFINESOUND = 14, /* Event sound tags. */
- SWFDEC_TAG_STARTSOUND = 15,
- SWFDEC_TAG_DEFINEBUTTONSOUND = 17,
- SWFDEC_TAG_SOUNDSTREAMHEAD = 18,
- SWFDEC_TAG_SOUNDSTREAMBLOCK = 19,
- SWFDEC_TAG_DEFINEBITSLOSSLESS = 20, /* A bitmap using lossless zlib compression. */
- SWFDEC_TAG_DEFINEBITSJPEG2 = 21, /* A bitmap using an internal JPEG compression table. */
- SWFDEC_TAG_DEFINESHAPE2 = 22,
- SWFDEC_TAG_DEFINEBUTTONCXFORM = 23,
- SWFDEC_TAG_PROTECT = 24, /* This file should not be importable for editing. */
- SWFDEC_TAG_PLACEOBJECT2 = 26, /* The new style place w/ alpha color transform and name. */
- SWFDEC_TAG_REMOVEOBJECT2 = 28, /* A more compact remove object that omits the character tag (just depth). */
- SWFDEC_TAG_DEFINESHAPE3 = 32, /* A shape V3 includes alpha values. */
- SWFDEC_TAG_DEFINETEXT2 = 33, /* A text V2 includes alpha values. */
- SWFDEC_TAG_DEFINEBUTTON2 = 34, /* A button V2 includes color transform, alpha and multiple actions */
- SWFDEC_TAG_DEFINEBITSJPEG3 = 35, /* A JPEG bitmap with alpha info. */
- SWFDEC_TAG_DEFINEBITSLOSSLESS2 = 36, /* A lossless bitmap with alpha info. */
- SWFDEC_TAG_DEFINEEDITTEXT = 37,
- SWFDEC_TAG_DEFINEMOVIE = 38,
- SWFDEC_TAG_DEFINESPRITE = 39, /* Define a sequence of tags that describe the behavior of a sprite. */
- SWFDEC_TAG_NAMECHARACTER = 40, /* Name a character definition, character id and a string, (used for buttons, bitmaps, sprites and sounds). */
- SWFDEC_TAG_SERIALNUMBER = 41,
- SWFDEC_TAG_GENERATORTEXT = 42, /* contains an id */
- SWFDEC_TAG_FRAMELABEL = 43, /* A string label for the current frame. */
- SWFDEC_TAG_SOUNDSTREAMHEAD2 = 45, /* For lossless streaming sound, should not have needed this... */
- SWFDEC_TAG_DEFINEMORPHSHAPE = 46, /* A morph shape definition */
- SWFDEC_TAG_DEFINEFONT2 = 48,
- SWFDEC_TAG_TEMPLATECOMMAND = 49,
- SWFDEC_TAG_GENERATOR3 = 51,
- SWFDEC_TAG_EXTERNALFONT = 52,
- SWFDEC_TAG_EXPORTASSETS = 56,
- SWFDEC_TAG_IMPORTASSETS = 57,
- SWFDEC_TAG_ENABLEDEBUGGER = 58,
- SWFDEC_TAG_DOINITACTION = 59,
- SWFDEC_TAG_DEFINEVIDEOSTREAM = 60,
- SWFDEC_TAG_VIDEOFRAME = 61,
- SWFDEC_TAG_DEFINEFONTINFO2 = 62,
- SWFDEC_TAG_DEBUGID = 63,
- SWFDEC_TAG_ENABLEDEBUGGER2 = 64,
- SWFDEC_TAG_SCRIPTLIMITS = 65,
- SWFDEC_TAG_SETTABINDEX = 66,
-#if 0
- /* magic tags that seem to be similar to FILEATTRIBUTES */
- SWFDEC_TAG_ = 67,
- SWFDEC_TAG_ = 68,
-#endif
- SWFDEC_TAG_FILEATTRIBUTES = 69,
- SWFDEC_TAG_PLACEOBJECT3 = 70,
- SWFDEC_TAG_IMPORTASSETS2 = 71,
-#if 0
- /* seems similar to SWFDEC_TAG_AVM2DECL */
- SWFDEC_TAG_ = 72, /* allowed with DefineSprite */
-#endif
- SWFDEC_TAG_DEFINEFONTALIGNZONES = 73,
- SWFDEC_TAG_CSMTEXTSETTINGS = 74,
- SWFDEC_TAG_DEFINEFONT3 = 75,
- SWFDEC_TAG_AVM2DECL = 76,
- SWFDEC_TAG_METADATA = 77,
- SWFDEC_TAG_DEFINESCALINGGRID = 78,
-#if 0
- /* more magic tags that seem to be similar to FILEATTRIBUTES */
- SWFDEC_TAG_ = 80,
- SWFDEC_TAG_ = 81,
-#endif
- SWFDEC_TAG_AVM2ACTION = 82,
- SWFDEC_TAG_DEFINESHAPE4 = 83,
- SWFDEC_TAG_DEFINEMORPHSHAPE2 = 84,
- SWFDEC_TAG_PRIVATE_IMAGE = 85,
- SWFDEC_TAG_DEFINESCENEDATA = 86,
- SWFDEC_TAG_DEFINEBINARYDATA = 87,
- SWFDEC_TAG_DEFINEFONTNAME = 88,
- SWFDEC_TAG_STARTSOUND2 = 89
-} SwfdecTag;
-
-typedef enum {
- /* tag is allowe inside DefineSprite */
- SWFDEC_TAG_DEFINE_SPRITE = (1 << 0),
- /* tag must be first tag */
- SWFDEC_TAG_FIRST_ONLY = (1 << 1)
-} SwfdecTagFlag;
-
-#endif
diff --git a/libswfdec/swfdec_text.c b/libswfdec/swfdec_text.c
deleted file mode 100644
index 9205ea8..0000000
--- a/libswfdec/swfdec_text.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_text.h"
-#include "swfdec_debug.h"
-#include "swfdec_draw.h"
-#include "swfdec_font.h"
-#include "swfdec_swf_decoder.h"
-
-G_DEFINE_TYPE (SwfdecText, swfdec_text, SWFDEC_TYPE_GRAPHIC)
-
-static gboolean
-swfdec_text_mouse_in (SwfdecGraphic *graphic, double x, double y)
-{
- guint i;
- SwfdecText *text = SWFDEC_TEXT (graphic);
-
- cairo_matrix_transform_point (&text->transform_inverse, &x, &y);
- for (i = 0; i < text->glyphs->len; i++) {
- SwfdecTextGlyph *glyph;
- SwfdecDraw *draw;
- double tmpx, tmpy;
-
- glyph = &g_array_index (text->glyphs, SwfdecTextGlyph, i);
- draw = swfdec_font_get_glyph (glyph->font, glyph->glyph);
- if (draw == NULL)
- continue;
- tmpx = x - glyph->x;
- tmpy = y - glyph->y;
- tmpx = tmpx * glyph->font->scale_factor / glyph->height;
- tmpy = tmpy * glyph->font->scale_factor / glyph->height;
- if (swfdec_draw_contains (draw, tmpx, tmpy))
- return TRUE;
- }
- return FALSE;
-}
-
-static void
-swfdec_text_render (SwfdecGraphic *graphic, cairo_t *cr,
- const SwfdecColorTransform *trans, const SwfdecRect *inval)
-{
- guint i;
- SwfdecColor color;
- SwfdecText *text = SWFDEC_TEXT (graphic);
- SwfdecColorTransform force_color;
- SwfdecRect rect, inval_moved;
-
- cairo_transform (cr, &text->transform);
- /* scale by bounds */
- swfdec_rect_transform (&inval_moved, inval, &text->transform_inverse);
- for (i = 0; i < text->glyphs->len; i++) {
- SwfdecTextGlyph *glyph;
- SwfdecDraw *draw;
- cairo_matrix_t pos;
-
- glyph = &g_array_index (text->glyphs, SwfdecTextGlyph, i);
-
- draw = swfdec_font_get_glyph (glyph->font, glyph->glyph);
- if (draw == NULL) {
- SWFDEC_INFO ("failed getting glyph %d, maybe an empty glyph?", glyph->glyph);
- continue;
- }
-
- cairo_matrix_init_translate (&pos,
- glyph->x, glyph->y);
- cairo_matrix_scale (&pos,
- (double) glyph->height / glyph->font->scale_factor,
- (double) glyph->height / glyph->font->scale_factor);
- cairo_save (cr);
- cairo_transform (cr, &pos);
- if (!cairo_matrix_invert (&pos)) {
- swfdec_rect_transform (&rect, &inval_moved, &pos);
- color = swfdec_color_apply_transform (glyph->color, trans);
- swfdec_color_transform_init_color (&force_color, color);
- swfdec_draw_paint (draw, cr, &force_color);
- } else {
- SWFDEC_ERROR ("non-invertible matrix!");
- }
- cairo_restore (cr);
- }
-}
-
-static void
-swfdec_text_dispose (GObject *object)
-{
- SwfdecText * text = SWFDEC_TEXT (object);
-
- g_array_free (text->glyphs, TRUE);
-
- G_OBJECT_CLASS (swfdec_text_parent_class)->dispose (object);
-}
-
-static void
-swfdec_text_class_init (SwfdecTextClass * g_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (g_class);
- SwfdecGraphicClass *graphic_class = SWFDEC_GRAPHIC_CLASS (g_class);
-
- object_class->dispose = swfdec_text_dispose;
-
- graphic_class->render = swfdec_text_render;
- graphic_class->mouse_in = swfdec_text_mouse_in;
-}
-
-static void
-swfdec_text_init (SwfdecText * text)
-{
- text->glyphs = g_array_new (FALSE, TRUE, sizeof (SwfdecTextGlyph));
- cairo_matrix_init_identity (&text->transform);
-}
-
diff --git a/libswfdec/swfdec_text.h b/libswfdec/swfdec_text.h
deleted file mode 100644
index a590470..0000000
--- a/libswfdec/swfdec_text.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- * 2005-2006 Eric Anholt <eric at anholt.net>
- * 2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_TEXT_H_
-#define _SWFDEC_TEXT_H_
-
-#include <libswfdec/swfdec_graphic.h>
-#include <libswfdec/swfdec_color.h>
-
-G_BEGIN_DECLS
-//typedef struct _SwfdecText SwfdecText;
-typedef struct _SwfdecTextClass SwfdecTextClass;
-
-typedef struct _SwfdecTextGlyph SwfdecTextGlyph;
-
-#define SWFDEC_TYPE_TEXT (swfdec_text_get_type())
-#define SWFDEC_IS_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_TEXT))
-#define SWFDEC_IS_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_TEXT))
-#define SWFDEC_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_TEXT, SwfdecText))
-#define SWFDEC_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_TEXT, SwfdecTextClass))
-
-struct _SwfdecTextGlyph {
- int x;
- int y;
- int glyph;
- SwfdecFont * font;
- int height;
- SwfdecColor color;
-};
-
-struct _SwfdecText {
- SwfdecGraphic graphic;
-
- GArray * glyphs;
- cairo_matrix_t transform;
- cairo_matrix_t transform_inverse;
-};
-
-struct _SwfdecTextClass {
- SwfdecGraphicClass graphic_class;
-};
-
-GType swfdec_text_get_type (void);
-
-int tag_func_define_text (SwfdecSwfDecoder * s, guint tag);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_text_field.c b/libswfdec/swfdec_text_field.c
deleted file mode 100644
index 91af056..0000000
--- a/libswfdec/swfdec_text_field.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "swfdec_text_field.h"
-#include "swfdec_debug.h"
-#include "swfdec_text_field_movie.h"
-#include "swfdec_font.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_swf_decoder.h"
-
-G_DEFINE_TYPE (SwfdecTextField, swfdec_text_field, SWFDEC_TYPE_GRAPHIC)
-
-static gboolean
-swfdec_text_field_mouse_in (SwfdecGraphic *graphic, double x, double y)
-{
- return swfdec_rect_contains (&graphic->extents, x, y);
-}
-
-static SwfdecMovie *
-swfdec_text_field_create_movie (SwfdecGraphic *graphic, gsize *size)
-{
- SwfdecTextField *text = SWFDEC_TEXT_FIELD (graphic);
- SwfdecTextFieldMovie *ret =
- g_object_new (SWFDEC_TYPE_TEXT_FIELD_MOVIE, NULL);
-
- ret->text = text;
-
- *size = sizeof (SwfdecTextFieldMovie);
-
- return SWFDEC_MOVIE (ret);
-}
-
-static void
-swfdec_text_field_dispose (GObject *object)
-{
- SwfdecTextField *text = SWFDEC_TEXT_FIELD (object);
-
- if (text->input != NULL) {
- g_free (text->input);
- text->input = NULL;
- }
- if (text->variable != NULL) {
- g_free (text->variable);
- text->variable = NULL;
- }
- if (text->font != NULL) {
- g_free (text->font);
- text->font = NULL;
- }
-
- G_OBJECT_CLASS (swfdec_text_field_parent_class)->dispose (object);
-}
-
-static void
-swfdec_text_field_class_init (SwfdecTextFieldClass * g_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (g_class);
- SwfdecGraphicClass *graphic_class = SWFDEC_GRAPHIC_CLASS (g_class);
-
- object_class->dispose = swfdec_text_field_dispose;
- graphic_class->create_movie = swfdec_text_field_create_movie;
- graphic_class->mouse_in = swfdec_text_field_mouse_in;
-}
-
-static void
-swfdec_text_field_init (SwfdecTextField * text)
-{
-}
-
-int
-tag_func_define_edit_text (SwfdecSwfDecoder * s, guint tag)
-{
- SwfdecTextField *text;
- guint id;
- int reserved;
- gboolean has_font, has_color, has_max_length, has_layout, has_text;
- SwfdecBits *b = &s->b;
-
- id = swfdec_bits_get_u16 (b);
- SWFDEC_LOG (" id = %u", id);
- text = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_TEXT_FIELD);
- if (text == NULL)
- return SWFDEC_STATUS_OK;
-
- swfdec_bits_get_rect (b, &SWFDEC_GRAPHIC (text)->extents);
- SWFDEC_LOG (" extents: %g %g %g %g",
- SWFDEC_GRAPHIC (text)->extents.x0, SWFDEC_GRAPHIC (text)->extents.y0,
- SWFDEC_GRAPHIC (text)->extents.x1, SWFDEC_GRAPHIC (text)->extents.y1);
- swfdec_bits_syncbits (b);
-
- has_text = swfdec_bits_getbit (b);
- text->word_wrap = swfdec_bits_getbit (b);
- text->multiline = swfdec_bits_getbit (b);
- text->password = swfdec_bits_getbit (b);
- text->editable = !swfdec_bits_getbit (b);
- has_color = swfdec_bits_getbit (b);
- has_max_length = swfdec_bits_getbit (b);
- has_font = swfdec_bits_getbit (b);
- reserved = swfdec_bits_getbit (b);
- text->auto_size =
- (swfdec_bits_getbit (b) ? SWFDEC_AUTO_SIZE_LEFT : SWFDEC_AUTO_SIZE_NONE);
- has_layout = swfdec_bits_getbit (b);
- text->selectable = !swfdec_bits_getbit (b);
- text->background = text->border = swfdec_bits_getbit (b);
- reserved = swfdec_bits_getbit (b);
- text->html = swfdec_bits_getbit (b);
- text->embed_fonts = swfdec_bits_getbit (b);
- if (text->embed_fonts)
- SWFDEC_FIXME ("Using embed fonts in TextField is not supported");
-
- if (has_font) {
- SwfdecCharacter *font;
-
- id = swfdec_bits_get_u16 (b);
- font = swfdec_swf_decoder_get_character (s, id);
- if (SWFDEC_IS_FONT (font)) {
- SWFDEC_LOG (" font = %u", id);
- text->font = g_strdup (SWFDEC_FONT (font)->name);
- } else {
- SWFDEC_ERROR ("id %u does not specify a font", id);
- }
- text->size = swfdec_bits_get_u16 (b);
- SWFDEC_LOG (" size = %u", text->size);
- }
-
- if (has_color) {
- text->color = swfdec_bits_get_rgba (b);
- SWFDEC_LOG (" color = %u", text->color);
- } else {
- SWFDEC_WARNING ("FIXME: figure out default color");
- text->color = SWFDEC_COLOR_COMBINE (255, 255, 255, 0);
- }
-
- if (has_max_length) {
- text->max_chars = swfdec_bits_get_u16 (b);
- } else {
- text->max_chars = 0;
- }
-
- if (has_layout) {
- guint align = swfdec_bits_get_u8 (b);
- switch (align) {
- case 0:
- text->align = SWFDEC_TEXT_ALIGN_LEFT;
- break;
- case 1:
- text->align = SWFDEC_TEXT_ALIGN_RIGHT;
- break;
- case 2:
- text->align = SWFDEC_TEXT_ALIGN_CENTER;
- break;
- case 3:
- text->align = SWFDEC_TEXT_ALIGN_JUSTIFY;
- break;
- default:
- SWFDEC_ERROR ("undefined align value %u", align);
- break;
- }
- text->left_margin = swfdec_bits_get_u16 (b);
- text->right_margin = swfdec_bits_get_u16 (b);
- text->indent = swfdec_bits_get_u16 (b);
- text->leading = swfdec_bits_get_s16 (b);
- }
-
- text->variable = swfdec_bits_get_string (b, s->version);
- if (text->variable && *text->variable == 0) {
- g_free (text->variable);
- text->variable = NULL;
- }
-
- if (has_text)
- text->input = swfdec_bits_get_string (b, s->version);
-
- return SWFDEC_STATUS_OK;
-}
diff --git a/libswfdec/swfdec_text_field.h b/libswfdec/swfdec_text_field.h
deleted file mode 100644
index a321a1c..0000000
--- a/libswfdec/swfdec_text_field.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_TEXT_FIELD_H_
-#define _SWFDEC_TEXT_FIELD_H_
-
-#include <pango/pango.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_color.h>
-#include <libswfdec/swfdec_graphic.h>
-#include <libswfdec/swfdec_player.h>
-#include <libswfdec/swfdec_text_format.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecTextField SwfdecTextField;
-typedef struct _SwfdecTextFieldClass SwfdecTextFieldClass;
-
-#define SWFDEC_TYPE_TEXT_FIELD (swfdec_text_field_get_type())
-#define SWFDEC_IS_TEXT_FIELD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_TEXT_FIELD))
-#define SWFDEC_IS_TEXT_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_TEXT_FIELD))
-#define SWFDEC_TEXT_FIELD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_TEXT_FIELD, SwfdecTextField))
-#define SWFDEC_TEXT_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_TEXT_FIELD, SwfdecTextFieldClass))
-
-typedef enum {
- SWFDEC_AUTO_SIZE_NONE,
- SWFDEC_AUTO_SIZE_LEFT,
- SWFDEC_AUTO_SIZE_RIGHT,
- SWFDEC_AUTO_SIZE_CENTER
-} SwfdecAutoSize;
-
-struct _SwfdecTextField
-{
- SwfdecGraphic graphic;
-
- gboolean html;
-
- gboolean editable;
- gboolean password;
- int max_chars;
- gboolean selectable;
-
- gboolean embed_fonts;
-
- gboolean word_wrap;
- gboolean multiline;
- SwfdecAutoSize auto_size;
-
- gboolean border;
- gboolean background;
-
- /* only to be passed to the movie object */
- char * input;
- char * variable;
- char * font;
- guint size;
- SwfdecColor color;
- SwfdecTextAlign align;
- guint left_margin;
- guint right_margin;
- guint indent;
- int leading;
-};
-
-struct _SwfdecTextFieldClass
-{
- SwfdecGraphicClass graphic_class;
-};
-
-GType swfdec_text_field_get_type (void);
-
-int tag_func_define_edit_text (SwfdecSwfDecoder * s,
- guint tag);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_text_field_movie.c b/libswfdec/swfdec_text_field_movie.c
deleted file mode 100644
index 84a4001..0000000
--- a/libswfdec/swfdec_text_field_movie.c
+++ /dev/null
@@ -1,1627 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include <math.h>
-#include <pango/pangocairo.h>
-
-#include "swfdec_text_field_movie.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_as_interpret.h"
-#include "swfdec_debug.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_resource.h"
-#include "swfdec_sandbox.h"
-#include "swfdec_text_format.h"
-#include "swfdec_xml.h"
-
-G_DEFINE_TYPE (SwfdecTextFieldMovie, swfdec_text_field_movie, SWFDEC_TYPE_MOVIE)
-
-#define EXTRA_MARGIN 2
-#define BULLET_MARGIN 36
-
-static void
-swfdec_text_field_movie_update_extents (SwfdecMovie *movie,
- SwfdecRect *extents)
-{
- swfdec_rect_union (extents, extents,
- &SWFDEC_GRAPHIC (SWFDEC_TEXT_FIELD_MOVIE (movie)->text)->extents);
-}
-
-static void
-swfdec_text_field_movie_invalidate (SwfdecMovie *movie, const cairo_matrix_t *matrix, gboolean last)
-{
- SwfdecRect rect;
-
- swfdec_rect_transform (&rect,
- &SWFDEC_GRAPHIC (SWFDEC_TEXT_FIELD_MOVIE (movie)->text)->extents, matrix);
- swfdec_player_invalidate (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), &rect);
-}
-
-static void
-swfdec_text_field_movie_ensure_asterisks (SwfdecTextFieldMovie *text,
- guint length)
-{
- g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
-
- if (text->asterisks_length >= length)
- return;
-
- if (text->asterisks != NULL)
- g_free (text->asterisks);
-
- text->asterisks = g_malloc (length + 1);
- memset (text->asterisks, '*', length);
- text->asterisks[length] = 0;
- text->asterisks_length = length;
-}
-
-static void
-swfdec_text_paragraph_add_attribute (SwfdecParagraph *paragraph,
- PangoAttribute *attr)
-{
- paragraph->attrs = g_slist_prepend (paragraph->attrs, attr);
-}
-
-static void
-swfdec_text_paragraph_add_block (SwfdecParagraph *paragraph, int index_,
- SwfdecTextFormat *format)
-{
- gint32 length, i;
- SwfdecBlock *block;
- SwfdecAsValue val;
-
- block = g_new0 (SwfdecBlock, 1);
-
- block->index_ = index_;
-
- switch (format->align) {
- case SWFDEC_TEXT_ALIGN_LEFT:
- block->align = PANGO_ALIGN_LEFT;
- block->justify = FALSE;
- break;
- case SWFDEC_TEXT_ALIGN_RIGHT:
- block->align = PANGO_ALIGN_RIGHT;
- block->justify = FALSE;
- break;
- case SWFDEC_TEXT_ALIGN_CENTER:
- block->align = PANGO_ALIGN_CENTER;
- block->justify = FALSE;
- break;
- case SWFDEC_TEXT_ALIGN_JUSTIFY:
- block->align = PANGO_ALIGN_LEFT;
- block->justify = TRUE;
- break;
- default:
- g_assert_not_reached ();
- }
- block->leading = format->leading * 20 * PANGO_SCALE;
- block->block_indent = format->block_indent * 20;
- block->left_margin = format->left_margin * 20;
- block->right_margin = format->right_margin * 20;
-
- if (format->tab_stops != NULL) {
- length = swfdec_as_array_get_length (format->tab_stops);
- block->tab_stops = pango_tab_array_new (length, TRUE);
- for (i = 0; i < length; i++) {
- swfdec_as_array_get_value (format->tab_stops, i, &val);
- g_assert (SWFDEC_AS_VALUE_IS_NUMBER (&val));
- pango_tab_array_set_tab (block->tab_stops, i, PANGO_TAB_LEFT,
- SWFDEC_AS_VALUE_GET_NUMBER (&val) * 20);
- }
- } else {
- block->tab_stops = NULL;
- }
-
- paragraph->blocks = g_slist_prepend (paragraph->blocks, block);
-}
-
-static void
-swfdec_text_field_movie_generate_paragraph (SwfdecTextFieldMovie *text,
- SwfdecParagraph *paragraph, guint start_index, guint length)
-{
- SwfdecTextFormat *format, *format_prev;
- guint index_;
- GSList *iter;
- PangoAttribute *attr_bold, *attr_color, *attr_font, *attr_italic,
- *attr_letter_spacing, *attr_size, *attr_underline;
- // TODO: kerning, display
-
- g_assert (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
- g_assert (paragraph != NULL);
- g_assert (start_index + length <= text->input->len);
-
- paragraph->index_ = start_index;
- paragraph->length = length;
- if (text->input->str[start_index + length - 1] == '\n' ||
- text->input->str[start_index + length - 1] == '\r') {
- paragraph->newline = TRUE;
- } else {
- paragraph->newline = FALSE;
- }
-
- paragraph->blocks = NULL;
- paragraph->attrs = NULL;
-
- g_assert (text->formats != NULL);
- for (iter = text->formats; iter->next != NULL &&
- ((SwfdecFormatIndex *)(iter->next->data))->index_ <= start_index;
- iter = iter->next);
-
- index_ = start_index;
- format = ((SwfdecFormatIndex *)(iter->data))->format;
-
- // Paragraph formats
- paragraph->bullet = format->bullet;
- paragraph->indent = format->indent * 20 * PANGO_SCALE;
-
- // Add new block
- swfdec_text_paragraph_add_block (paragraph, 0, format);
-
- // Open attributes
- attr_bold = pango_attr_weight_new (
- (format->bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL));
- attr_bold->start_index = 0;
-
- attr_color = pango_attr_foreground_new (SWFDEC_COLOR_R (format->color) * 255,
- SWFDEC_COLOR_G (format->color) * 255,
- SWFDEC_COLOR_B (format->color) * 255);
- attr_color->start_index = 0;
-
- // FIXME: embed fonts
- attr_font = pango_attr_family_new (format->font);
- attr_font->start_index = 0;
-
- attr_italic = pango_attr_style_new (
- (format->italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL));
- attr_italic->start_index = 0;
-
- attr_letter_spacing = pango_attr_letter_spacing_new (
- format->letter_spacing * 20 * PANGO_SCALE);
- attr_letter_spacing->start_index = 0;
-
- attr_size =
- pango_attr_size_new_absolute (MAX (format->size, 1) * 20 * PANGO_SCALE);
- attr_size->start_index = 0;
-
- attr_underline = pango_attr_underline_new (
- (format->underline ? PANGO_UNDERLINE_SINGLE : PANGO_UNDERLINE_NONE));
- attr_underline->start_index = 0;
-
- for (iter = iter->next;
- iter != NULL &&
- ((SwfdecFormatIndex *)(iter->data))->index_ < start_index + length;
- iter = iter->next)
- {
- format_prev = format;
- index_ = ((SwfdecFormatIndex *)(iter->data))->index_;
- format = ((SwfdecFormatIndex *)(iter->data))->format;
-
- // Add new block if necessary
- if (format_prev->align != format->align ||
- format_prev->bullet != format->bullet ||
- format_prev->indent != format->indent ||
- format_prev->leading != format->leading ||
- format_prev->block_indent != format->block_indent ||
- format_prev->left_margin != format->left_margin)
- {
- swfdec_text_paragraph_add_block (paragraph, index_ - start_index,
- format);
- }
-
- // Change attributes if necessary
- if (format_prev->bold != format->bold) {
- attr_bold->end_index = index_ - start_index;
- swfdec_text_paragraph_add_attribute (paragraph, attr_bold);
-
- attr_bold = pango_attr_weight_new (
- (format->bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL));
- attr_bold->start_index = index_ - start_index;
- }
-
- if (format_prev->color != format->color) {
- attr_color->end_index = index_ - start_index;
- swfdec_text_paragraph_add_attribute (paragraph, attr_color);
-
- attr_color = pango_attr_foreground_new (
- SWFDEC_COLOR_R (format->color) * 255,
- SWFDEC_COLOR_G (format->color) * 255,
- SWFDEC_COLOR_B (format->color) * 255);
- attr_color->start_index = index_ - start_index;
- }
-
- if (format_prev->font != format->font) {
- attr_font->end_index = index_ - start_index;
- swfdec_text_paragraph_add_attribute (paragraph, attr_font);
-
- // FIXME: embed fonts
- attr_font = pango_attr_family_new (format->font);
- attr_font->start_index = index_ - start_index;
- }
-
- if (format_prev->italic != format->italic) {
- attr_italic->end_index = index_ - start_index;
- swfdec_text_paragraph_add_attribute (paragraph, attr_italic);
-
- attr_italic = pango_attr_style_new (
- (format->italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL));
- attr_italic->start_index = index_ - start_index;
- }
-
- if (format_prev->letter_spacing != format->letter_spacing) {
- attr_letter_spacing->end_index = index_ - start_index;
- swfdec_text_paragraph_add_attribute (paragraph, attr_letter_spacing);
-
- attr_letter_spacing = pango_attr_letter_spacing_new (
- format->letter_spacing * 20 * PANGO_SCALE);
- attr_letter_spacing->start_index = index_ - start_index;
- }
-
- if (format_prev->size != format->size) {
- attr_size->end_index = index_ - start_index;
- swfdec_text_paragraph_add_attribute (paragraph, attr_size);
-
- attr_size = pango_attr_size_new_absolute (
- MAX (1, format->size) * 20 * PANGO_SCALE);
- attr_size->start_index = index_ - start_index;
- }
-
- if (format_prev->underline != format->underline) {
- attr_underline->end_index = index_ - start_index;
- swfdec_text_paragraph_add_attribute (paragraph, attr_underline);
-
- attr_underline = pango_attr_underline_new (
- (format->underline ? PANGO_UNDERLINE_SINGLE : PANGO_UNDERLINE_NONE));
- attr_underline->start_index = index_ - start_index;
- }
- }
-
- // Close attributes
- attr_bold->end_index = length;
- swfdec_text_paragraph_add_attribute (paragraph, attr_bold);
- attr_bold = NULL;
-
- attr_color->end_index = length;
- swfdec_text_paragraph_add_attribute (paragraph, attr_color);
- attr_color = NULL;
-
- attr_font->end_index = length;
- swfdec_text_paragraph_add_attribute (paragraph, attr_font);
- attr_font = NULL;
-
- attr_italic->end_index = length;
- swfdec_text_paragraph_add_attribute (paragraph, attr_italic);
- attr_italic = NULL;
-
- attr_letter_spacing->end_index = length;
- swfdec_text_paragraph_add_attribute (paragraph, attr_letter_spacing);
- attr_letter_spacing = NULL;
-
- attr_size->end_index = length;
- swfdec_text_paragraph_add_attribute (paragraph, attr_size);
- attr_size = NULL;
-
- attr_underline->end_index = length;
- swfdec_text_paragraph_add_attribute (paragraph, attr_underline);
- attr_underline = NULL;
-
- // reverse blocks since we use prepend to add them
- paragraph->blocks = g_slist_reverse (paragraph->blocks);
-}
-
-static SwfdecParagraph *
-swfdec_text_field_movie_get_paragraphs (SwfdecTextFieldMovie *text, int *num)
-{
- GArray *paragraphs;
- SwfdecParagraph paragraph;
- const char *p, *end;
- guint max_length;
-
- g_assert (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
-
- paragraphs = g_array_new (TRUE, TRUE, sizeof (SwfdecParagraph));
-
- max_length = 0;
- p = text->input->str;
- while (*p != '\0')
- {
- end = strpbrk (p, "\r\n");
- if (end == NULL) {
- end = strchr (p, '\0');
- } else {
- end++;
- }
-
- if ((guint) (end - p) > max_length)
- max_length = end - p;
-
- swfdec_text_field_movie_generate_paragraph (text, ¶graph,
- p - text->input->str, end - p);
- paragraphs = g_array_append_val (paragraphs, paragraph);
-
- p = end;
- }
-
- if (num != NULL)
- *num = paragraphs->len;
-
- if (text->text->password)
- swfdec_text_field_movie_ensure_asterisks (text, max_length);
-
- return (SwfdecParagraph *) (void *) g_array_free (paragraphs, FALSE);
-}
-
-static void
-swfdec_text_field_movie_free_paragraphs (SwfdecParagraph *paragraphs)
-{
- GSList *iter;
- int i;
-
- g_return_if_fail (paragraphs != NULL);
-
- for (i = 0; paragraphs[i].blocks != NULL; i++)
- {
- for (iter = paragraphs[i].blocks; iter != NULL; iter = iter->next) {
- if (((SwfdecBlock *)(iter->data))->tab_stops)
- pango_tab_array_free (((SwfdecBlock *)(iter->data))->tab_stops);
- g_free (iter->data);
- }
- g_slist_free (paragraphs[i].blocks);
-
- for (iter = paragraphs[i].attrs; iter != NULL; iter = iter->next) {
- pango_attribute_destroy ((PangoAttribute *)(iter->data));
- }
- g_slist_free (paragraphs[i].attrs);
- }
- g_free (paragraphs);
-}
-
-/*
- * Rendering
- */
-static PangoAttrList *
-swfdec_text_field_movie_paragraph_get_attr_list (
- const SwfdecParagraph *paragraph, guint index_,
- const SwfdecColorTransform *trans)
-{
- PangoAttrList *attr_list;
- GSList *iter;
-
- attr_list = pango_attr_list_new ();
-
- for (iter = paragraph->attrs; iter != NULL; iter = iter->next)
- {
- PangoAttribute *attr;
-
- if (((PangoAttribute *)iter->data)->end_index <= index_)
- continue;
-
- attr = pango_attribute_copy ((PangoAttribute *)iter->data);
-
- if (attr->klass->type == PANGO_ATTR_FOREGROUND && trans != NULL &&
- !swfdec_color_transform_is_identity (trans))
- {
- SwfdecColor color;
- PangoColor color_p;
-
- color_p = ((PangoAttrColor *)attr)->color;
-
- color = SWFDEC_COLOR_COMBINE (color_p.red >> 8, color_p.green >> 8,
- color_p.blue >> 8, 255);
- color = swfdec_color_apply_transform (color, trans);
-
- color_p.red = SWFDEC_COLOR_R (color) << 8;
- color_p.green = SWFDEC_COLOR_G (color) << 8;
- color_p.blue = SWFDEC_COLOR_B (color) << 8;
- }
-
- attr->start_index =
- (attr->start_index > index_ ? attr->start_index - index_ : 0);
- attr->end_index = attr->end_index - index_;
- pango_attr_list_insert (attr_list, attr);
- }
-
- return attr_list;
-}
-
-static int
-swfdec_text_field_movie_layout_get_last_line_baseline (PangoLayout *playout)
-{
- int baseline;
- PangoLayoutIter *iter;
-
- g_return_val_if_fail (playout != NULL, 0);
-
- iter = pango_layout_get_iter (playout);
- while (!pango_layout_iter_at_last_line (iter))
- pango_layout_iter_next_line (iter);
-
- baseline = pango_layout_iter_get_baseline (iter) / PANGO_SCALE;
-
- pango_layout_iter_free (iter);
-
- return baseline;
-}
-
-static void
-swfdec_text_field_movie_attr_list_get_ascent_descent (PangoAttrList *attr_list,
- guint pos, int *ascent, int *descent)
-{
- PangoAttrIterator *attr_iter;
- PangoFontDescription *desc;
- PangoFontMap *fontmap;
- PangoFont *font;
- PangoFontMetrics *metrics;
- PangoContext *pcontext;
- int end;
-
- if (ascent != NULL)
- *ascent = 0;
- if (descent != NULL)
- *descent = 0;
-
- g_return_if_fail (attr_list != NULL);
-
- attr_iter = pango_attr_list_get_iterator (attr_list);
- pango_attr_iterator_range (attr_iter, NULL, &end);
- while ((guint)end < pos && pango_attr_iterator_next (attr_iter)) {
- pango_attr_iterator_range (attr_iter, NULL, &end);
- }
- desc = pango_font_description_new ();
- pango_attr_iterator_get_font (attr_iter, desc, NULL, NULL);
- fontmap = pango_cairo_font_map_get_default ();
- pcontext =
- pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fontmap));
- font = pango_font_map_load_font (fontmap, pcontext, desc);
- metrics = pango_font_get_metrics (font, NULL);
-
- if (ascent != NULL)
- *ascent = pango_font_metrics_get_ascent (metrics) / PANGO_SCALE;
- if (descent != NULL)
- *descent = pango_font_metrics_get_descent (metrics) / PANGO_SCALE;
-
- g_object_unref (pcontext);
- pango_font_metrics_unref (metrics);
- pango_font_description_free (desc);
- pango_attr_iterator_destroy (attr_iter);
-}
-
-static SwfdecLayout *
-swfdec_text_field_movie_get_layouts (SwfdecTextFieldMovie *text, int *num,
- cairo_t *cr, const SwfdecParagraph *paragraphs,
- const SwfdecColorTransform *trans)
-{
- GArray *layouts;
- guint i;
- SwfdecParagraph *paragraphs_free;
-
- g_assert (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
-
- if (cr == NULL)
- cr = text->cr;
-
- if (paragraphs == NULL) {
- paragraphs_free = swfdec_text_field_movie_get_paragraphs (text, NULL);
- paragraphs = paragraphs_free;
- } else {
- paragraphs_free = NULL;
- }
-
- layouts = g_array_new (TRUE, TRUE, sizeof (SwfdecLayout));
-
- for (i = 0; paragraphs[i].blocks != NULL; i++)
- {
- GSList *iter;
- guint skip;
-
- skip = 0;
- for (iter = paragraphs[i].blocks; iter != NULL; iter = iter->next)
- {
- SwfdecLayout layout;
- PangoLayout *playout;
- PangoAttrList *attr_list;
- SwfdecBlock *block;
- int width;
- guint length;
- gboolean end_of_paragraph;
-
- block = (SwfdecBlock *)iter->data;
- if (iter->next != NULL) {
- length =
- ((SwfdecBlock *)(iter->next->data))->index_ - block->index_;
- } else {
- length = paragraphs[i].length - block->index_;
- if (paragraphs[i].newline)
- length -= 1;
- }
-
- if (skip > length) {
- skip -= length;
- continue;
- }
-
- // create layout
- playout = layout.layout = pango_cairo_create_layout (cr);
-
- // set rendering position
- layout.offset_x = block->left_margin + block->block_indent;
- if (paragraphs[i].bullet)
- layout.offset_x += SWFDEC_DOUBLE_TO_TWIPS (BULLET_MARGIN);
-
- width = SWFDEC_MOVIE (text)->original_extents.x1 -
- SWFDEC_MOVIE (text)->original_extents.x0 - block->right_margin -
- layout.offset_x;
-
- if (block->index_ == 0 && paragraphs[i].indent < 0) {
- // limit negative indent to not go over leftMargin + blockIndent
- int indent = MAX (paragraphs[i].indent / PANGO_SCALE,
- -(block->left_margin + block->block_indent));
- layout.offset_x += indent;
- width += -indent;
- }
-
- if (text->text->word_wrap) {
- pango_layout_set_wrap (playout, PANGO_WRAP_WORD_CHAR);
- pango_layout_set_width (playout, width * PANGO_SCALE);
- pango_layout_set_alignment (playout, block->align);
- pango_layout_set_justify (playout, block->justify);
- } else {
- pango_layout_set_width (playout, -1);
- }
-
- // set paragraph styles
- if (block->index_ == 0) {
- pango_layout_set_indent (playout, paragraphs[i].indent);
- layout.bullet = paragraphs[i].bullet;
- } else {
- pango_layout_set_indent (playout, 0);
- layout.bullet = FALSE;
- }
-
- // set block styles
- pango_layout_set_spacing (playout, block->leading);
- if (block->tab_stops != NULL)
- pango_layout_set_tabs (playout, block->tab_stops);
-
- // set text attributes
- attr_list = swfdec_text_field_movie_paragraph_get_attr_list (
- ¶graphs[i], block->index_ + skip, trans);
- pango_layout_set_attributes (playout, attr_list);
-
- if (text->text->password) {
- pango_layout_set_text (playout, text->asterisks, paragraphs[i].length -
- block->index_ - skip - (paragraphs[i].newline ? 1 : 0));
- } else {
- pango_layout_set_text (playout,
- text->input->str + paragraphs[i].index_ + block->index_ + skip,
- paragraphs[i].length - block->index_ - skip -
- (paragraphs[i].newline ? 1 : 0));
- }
-
- end_of_paragraph = TRUE;
- if (iter->next != NULL && text->text->word_wrap)
- {
- PangoLayoutLine *line;
- int line_num;
- guint skip_new;
-
- pango_layout_index_to_line_x (playout, length - skip, FALSE, &line_num,
- NULL);
- if (line_num < pango_layout_get_line_count (playout) - 1) {
- end_of_paragraph = FALSE;
- line = pango_layout_get_line_readonly (playout, line_num);
- skip_new = line->start_index + line->length - (length - skip);
- pango_layout_set_text (playout,
- text->input->str + paragraphs[i].index_ + block->index_ + skip,
- length - skip + skip_new);
- skip = skip_new;
- }
- }
- else
- {
- if (!text->text->word_wrap && block->align != PANGO_ALIGN_LEFT) {
- int line_width;
- pango_layout_get_pixel_size (playout, &line_width, 0);
- if (line_width < width) {
- if (block->align == PANGO_ALIGN_RIGHT) {
- layout.offset_x += width - line_width;
- } else if (block->align == PANGO_ALIGN_CENTER) {
- layout.offset_x += (width - line_width) / 2;
- } else {
- g_assert_not_reached ();
- }
- }
- }
-
- skip = 0;
- }
-
- pango_layout_get_pixel_size (playout, &layout.width, &layout.height);
- layout.width += layout.offset_x + block->right_margin;
- layout.last_line_offset_y = 0;
-
- // figure out if we need to add extra height because of the size of the
- // line break character
- if (end_of_paragraph && paragraphs[i].newline)
- {
- int ascent, descent;
-
- swfdec_text_field_movie_attr_list_get_ascent_descent (attr_list,
- paragraphs[i].length - block->index_ - skip, &ascent, &descent);
-
- if (ascent + descent > layout.height) {
- int baseline =
- swfdec_text_field_movie_layout_get_last_line_baseline (playout);
- layout.last_line_offset_y = ascent - baseline;
- layout.height = ascent + descent;
- }
- }
-
- pango_attr_list_unref (attr_list);
-
- // add leading to last line too
- layout.height += block->leading / PANGO_SCALE;
-
- layouts = g_array_append_val (layouts, layout);
-
- if (!text->text->word_wrap)
- break;
- }
- }
-
- if (paragraphs_free != NULL) {
- swfdec_text_field_movie_free_paragraphs (paragraphs_free);
- paragraphs_free = NULL;
- paragraphs = NULL;
- }
-
- if (num != NULL)
- *num = layouts->len;
-
- return (SwfdecLayout *) (void *) g_array_free (layouts, FALSE);
-}
-
-static void
-swfdec_text_field_movie_free_layouts (SwfdecLayout *layouts)
-{
- int i;
-
- g_return_if_fail (layouts != NULL);
-
- for (i = 0; layouts[i].layout != NULL; i++) {
- g_object_unref (layouts[i].layout);
- }
-
- g_free (layouts);
-}
-
-static void
-swfdec_text_field_movie_render (SwfdecMovie *movie, cairo_t *cr,
- const SwfdecColorTransform *trans, const SwfdecRect *inval)
-{
- SwfdecTextFieldMovie *text_movie;
- SwfdecTextField *text;
- SwfdecLayout *layouts;
- SwfdecRect limit;
- SwfdecColor color;
- SwfdecParagraph *paragraphs;
- int i, y, x, linenum;
- gboolean first;
-
- g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (movie));
- g_return_if_fail (cr != NULL);
- g_return_if_fail (trans != NULL);
- g_return_if_fail (inval != NULL);
-
- /* textfields don't mask */
- if (swfdec_color_transform_is_mask (trans))
- return;
-
- text_movie = SWFDEC_TEXT_FIELD_MOVIE (movie);
- text = SWFDEC_TEXT_FIELD (movie->graphic);
-
- paragraphs = swfdec_text_field_movie_get_paragraphs (text_movie, NULL);
-
- swfdec_rect_intersect (&limit, &movie->original_extents, inval);
-
- cairo_rectangle (cr, limit.x0, limit.y0, limit.x1 - limit.x0,
- limit.y1 - limit.y0);
- cairo_clip (cr);
-
- if (text->background) {
- cairo_rectangle (cr, limit.x0, limit.y0, limit.x1 - limit.x0,
- limit.y1 - limit.y0);
- color = swfdec_color_apply_transform (text_movie->background_color, trans);
- // always use full alpha
- swfdec_color_set_source (cr, color | SWFDEC_COLOR_COMBINE (0, 0, 0, 255));
- cairo_fill (cr);
- }
-
- if (text->border) {
- // FIXME: border should be partly outside the extents and should not be
- // scaled, but always be 1 pixel width
- cairo_rectangle (cr, movie->original_extents.x0 +
- SWFDEC_DOUBLE_TO_TWIPS (1), movie->original_extents.y0,
- movie->original_extents.x1 - movie->original_extents.x0 -
- SWFDEC_DOUBLE_TO_TWIPS (1), movie->original_extents.y1 -
- movie->original_extents.y0 - SWFDEC_DOUBLE_TO_TWIPS (1));
- color = swfdec_color_apply_transform (text_movie->border_color, trans);
- // always use full alpha
- swfdec_color_set_source (cr, color | SWFDEC_COLOR_COMBINE (0, 0, 0, 255));
- cairo_set_line_width (cr, SWFDEC_DOUBLE_TO_TWIPS (1));
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
- cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
- cairo_stroke (cr);
- }
-
- layouts = swfdec_text_field_movie_get_layouts (text_movie, NULL, cr,
- paragraphs, trans);
-
- first = TRUE;
- linenum = 0;
- x = movie->original_extents.x0 + EXTRA_MARGIN +
- MIN (text_movie->hscroll, text_movie->hscroll_max);
- y = movie->original_extents.y0 + EXTRA_MARGIN;
-
- for (i = 0; layouts[i].layout != NULL && y < limit.y1; i++)
- {
- SwfdecLayout *layout = &layouts[i];
- PangoLayoutIter *iter_line;
- PangoLayoutLine *line;
- PangoRectangle rect;
- int skipped;
-
- iter_line = pango_layout_get_iter (layout->layout);
-
- if (layout->bullet && linenum + 1 >=
- MIN (text_movie->scroll, text_movie->scroll_max)) {
- PangoColor color_p;
- PangoAttribute *attr;
- PangoAttrIterator *attr_iter;
-
- pango_layout_iter_get_line_extents (iter_line, NULL, &rect);
- pango_extents_to_pixels (NULL, &rect);
-
- cairo_new_sub_path (cr);
-
- // get current color
- attr_iter = pango_attr_list_get_iterator (
- pango_layout_get_attributes (layout->layout));
- attr = pango_attr_iterator_get (attr_iter, PANGO_ATTR_FOREGROUND);
- color_p = ((PangoAttrColor *)attr)->color;
- color = SWFDEC_COLOR_COMBINE (color_p.red >> 8, color_p.green >> 8,
- color_p.blue >> 8, 255);
- color = swfdec_color_apply_transform (color, trans);
- pango_attr_iterator_destroy (attr_iter);
-
- swfdec_color_set_source (cr, color);
-
- cairo_arc (cr, x + layout->offset_x +
- pango_layout_get_indent (layout->layout) -
- SWFDEC_DOUBLE_TO_TWIPS (BULLET_MARGIN) / 2,
- y + rect.height / 2, rect.height / 8, 20, 2 * M_PI);
- cairo_fill (cr);
- }
-
- skipped = 0;
- do {
- if (++linenum < MIN (text_movie->scroll, text_movie->scroll_max))
- continue;
-
- pango_layout_iter_get_line_extents (iter_line, NULL, &rect);
- pango_extents_to_pixels (NULL, &rect);
-
- if (linenum == MIN (text_movie->scroll, text_movie->scroll_max))
- skipped = rect.y;
-
- if (!first && y + rect.y + rect.height > movie->original_extents.y1)
- break;
-
- first = FALSE;
-
- if (y + rect.y > limit.y1)
- break;
-
- if (y + rect.y + rect.height < limit.y0 ||
- x + layout->offset_x + rect.x > limit.x1 ||
- x + layout->offset_x + rect.x + rect.width < limit.x0)
- continue;
-
- cairo_move_to (cr, x, y);
-
- if (pango_layout_iter_at_last_line (iter_line))
- cairo_rel_move_to (cr, 0, layout->last_line_offset_y);
- cairo_rel_move_to (cr, layout->offset_x + rect.x,
- pango_layout_iter_get_baseline (iter_line) / PANGO_SCALE - skipped);
-
- line = pango_layout_iter_get_line_readonly (iter_line);
- pango_cairo_show_layout_line (cr, line);
- } while (pango_layout_iter_next_line (iter_line));
-
- if (linenum >= MIN (text_movie->scroll, text_movie->scroll_max)) {
- y += layout->height - skipped;
- skipped = 0;
- }
-
- pango_layout_iter_free (iter_line);
- }
-
- swfdec_text_field_movie_free_layouts (layouts);
-
- swfdec_text_field_movie_free_paragraphs (paragraphs);
-}
-
-void
-swfdec_text_field_movie_update_scroll (SwfdecTextFieldMovie *text,
- gboolean check_limits)
-{
- SwfdecLayout *layouts;
- int i, num, y, visible, all, height;
- double width, width_max;
-
- g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
-
- layouts = swfdec_text_field_movie_get_layouts (text, &num, NULL, NULL, NULL);
-
- width = SWFDEC_MOVIE (text)->original_extents.x1 -
- SWFDEC_MOVIE (text)->original_extents.x0;
- height = SWFDEC_MOVIE (text)->original_extents.y1 -
- SWFDEC_MOVIE (text)->original_extents.y0;
-
- width_max = width;
- y = 0;
- all = 0;
- visible = 0;
-
- for (i = num - 1; i >= 0; i--)
- {
- SwfdecLayout *layout = &layouts[i];
- PangoLayoutIter *iter_line;
- PangoRectangle rect;
-
- if (layouts[i].width > width_max)
- width_max = layouts[i].width;
-
- y += layout->height;
-
- iter_line = pango_layout_get_iter (layout->layout);
-
- do {
- pango_layout_iter_get_line_extents (iter_line, NULL, &rect);
- pango_extents_to_pixels (NULL, &rect);
-
- if (y - rect.y <= height)
- visible++;
-
- all++;
- } while (pango_layout_iter_next_line (iter_line));
-
- pango_layout_iter_free (iter_line);
- }
-
- swfdec_text_field_movie_free_layouts (layouts);
- layouts = NULL;
-
- if (text->scroll_max != all - visible + 1) {
- text->scroll_max = all - visible + 1;
- text->scroll_changed = TRUE;
- }
- if (text->hscroll_max != SWFDEC_TWIPS_TO_DOUBLE (width_max - width)) {
- text->hscroll_max = SWFDEC_TWIPS_TO_DOUBLE (width_max - width);
- text->scroll_changed = TRUE;
- }
-
- if (check_limits) {
- if (text->scroll != CLAMP(text->scroll, 1, text->scroll_max)) {
- text->scroll = CLAMP(text->scroll, 1, text->scroll_max);
- text->scroll_changed = TRUE;
- }
- if (text->scroll_bottom != text->scroll + (visible > 0 ? visible - 1 : 0))
- {
- text->scroll_bottom = text->scroll + (visible > 0 ? visible - 1 : 0);
- text->scroll_changed = TRUE;
- }
- if (text->hscroll != CLAMP(text->hscroll, 0, text->hscroll_max)) {
- text->hscroll = CLAMP(text->hscroll, 0, text->hscroll_max);
- text->scroll_changed = TRUE;
- }
- } else {
- if (text->scroll_bottom < text->scroll ||
- text->scroll_bottom > text->scroll_max + visible - 1) {
- text->scroll_bottom = text->scroll;
- text->scroll_changed = TRUE;
- }
- }
-}
-
-void
-swfdec_text_field_movie_get_text_size (SwfdecTextFieldMovie *text, int *width,
- int *height)
-{
- SwfdecLayout *layouts;
- int i;
-
- if (width != NULL)
- *width = 0;
- if (height != NULL)
- *height = 0;
-
- g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
- g_return_if_fail (width != NULL || height != NULL);
-
- layouts = swfdec_text_field_movie_get_layouts (text, NULL, NULL, NULL, NULL);
-
- for (i = 0; layouts[i].layout != NULL; i++) {
- if (!text->text->word_wrap) {
- if (width != NULL && layouts[i].width > *width)
- *width = layouts[i].width;
- }
-
- if (height != NULL)
- *height += layouts[i].height;
- }
-
- // align to get integer amount after TWIPS_TO_DOUBLE
- if (width != NULL && *width % SWFDEC_TWIPS_SCALE_FACTOR != 0)
- *width += SWFDEC_TWIPS_SCALE_FACTOR - *width % SWFDEC_TWIPS_SCALE_FACTOR;
- if (height != NULL && *height % SWFDEC_TWIPS_SCALE_FACTOR != 0)
- *height += SWFDEC_TWIPS_SCALE_FACTOR - *height % SWFDEC_TWIPS_SCALE_FACTOR;
-
- swfdec_text_field_movie_free_layouts (layouts);
-}
-
-gboolean
-swfdec_text_field_movie_auto_size (SwfdecTextFieldMovie *text)
-{
- SwfdecGraphic *graphic;
- int height, width, diff;
-
- g_return_val_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text), FALSE);
-
- graphic = SWFDEC_GRAPHIC (text->text);
-
- if (text->text->auto_size == SWFDEC_AUTO_SIZE_NONE)
- return FALSE;
-
- swfdec_text_field_movie_get_text_size (text, &width, &height);
- width += SWFDEC_DOUBLE_TO_TWIPS (2 * EXTRA_MARGIN);
- height += SWFDEC_DOUBLE_TO_TWIPS (2 * EXTRA_MARGIN);
-
- if ((text->text->word_wrap ||
- graphic->extents.x1 - graphic->extents.x0 == width) &&
- graphic->extents.y1 - graphic->extents.y0 == height)
- return FALSE;
-
- swfdec_movie_invalidate_next (SWFDEC_MOVIE (text));
-
- if (!text->text->word_wrap && graphic->extents.x1 -
- graphic->extents.x0 != width)
- {
- switch (text->text->auto_size) {
- case SWFDEC_AUTO_SIZE_LEFT:
- graphic->extents.x1 = graphic->extents.x0 + width;
- break;
- case SWFDEC_AUTO_SIZE_RIGHT:
- graphic->extents.x0 = graphic->extents.x1 - width;
- break;
- case SWFDEC_AUTO_SIZE_CENTER:
- diff = (graphic->extents.x1 - graphic->extents.x0) - width;
- graphic->extents.x0 += floor (diff / 2.0);
- graphic->extents.x1 = graphic->extents.x0 + width;
- break;
- case SWFDEC_AUTO_SIZE_NONE:
- default:
- g_return_val_if_reached (FALSE);
- }
- }
-
- if (graphic->extents.y1 - graphic->extents.y0 != height)
- {
- graphic->extents.y1 = graphic->extents.y0 + height;
- }
-
- swfdec_movie_queue_update (SWFDEC_MOVIE (text),
- SWFDEC_MOVIE_INVALID_EXTENTS);
-
- return TRUE;
-}
-
-static void
-swfdec_text_field_movie_dispose (GObject *object)
-{
- SwfdecTextFieldMovie *text;
- GSList *iter;
-
- text = SWFDEC_TEXT_FIELD_MOVIE (object);
-
- if (text->asterisks != NULL) {
- g_free (text->asterisks);
- text->asterisks = NULL;
- text->asterisks_length = 0;
- }
-
- if (SWFDEC_IS_STYLESHEET (text->style_sheet)) {
- g_signal_handlers_disconnect_matched (text->style_sheet,
- G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, text);
- g_object_remove_weak_pointer (G_OBJECT (text->style_sheet),
- (gpointer) &text->style_sheet);
- }
- text->style_sheet = NULL;
-
- for (iter = text->formats; iter != NULL; iter = iter->next) {
- g_free (text->formats->data);
- text->formats->data = NULL;
- }
- g_slist_free (text->formats);
- text->formats = NULL;
-
- g_string_free (text->input, TRUE);
- text->input = NULL;
-
- cairo_destroy (text->cr);
- text->cr = NULL;
- cairo_surface_destroy (text->surface);
- text->surface = NULL;
-
- G_OBJECT_CLASS (swfdec_text_field_movie_parent_class)->dispose (object);
-}
-
-static void
-swfdec_text_field_movie_mark (SwfdecAsObject *object)
-{
- SwfdecTextFieldMovie *text;
- GSList *iter;
-
- text = SWFDEC_TEXT_FIELD_MOVIE (object);
-
- if (text->variable != NULL)
- swfdec_as_string_mark (text->variable);
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (text->format_new));
- for (iter = text->formats; iter != NULL; iter = iter->next) {
- swfdec_as_object_mark (
- SWFDEC_AS_OBJECT (((SwfdecFormatIndex *)(iter->data))->format));
- }
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (text->format_new));
- if (text->style_sheet != NULL)
- swfdec_as_object_mark (text->style_sheet);
- if (text->style_sheet_input != NULL)
- swfdec_as_string_mark (text->style_sheet_input);
- if (text->restrict_ != NULL)
- swfdec_as_string_mark (text->restrict_);
-
- SWFDEC_AS_OBJECT_CLASS (swfdec_text_field_movie_parent_class)->mark (object);
-}
-
-static void
-swfdec_text_field_movie_init_movie (SwfdecMovie *movie)
-{
- SwfdecTextFieldMovie *text = SWFDEC_TEXT_FIELD_MOVIE (movie);
- SwfdecAsContext *cx;
- SwfdecAsValue val;
- gboolean needs_unuse;
-
- needs_unuse = swfdec_sandbox_try_use (movie->resource->sandbox);
-
- cx = SWFDEC_AS_OBJECT (movie)->context;
-
- swfdec_text_field_movie_init_properties (cx);
-
- swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_TextField, &val);
- if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
- swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (movie),
- SWFDEC_AS_VALUE_GET_OBJECT (&val));
- }
-
- // listen self
- SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (movie));
- swfdec_as_object_call (SWFDEC_AS_OBJECT (movie), SWFDEC_AS_STR_addListener,
- 1, &val, NULL);
-
- // format
- text->format_new =
- SWFDEC_TEXT_FORMAT (swfdec_text_format_new_no_properties (cx));
- if (!text->format_new)
- goto out;
-
- swfdec_text_format_set_defaults (text->format_new);
- text->format_new->color = text->text->color;
- text->format_new->align = text->text->align;
- if (text->text->font != NULL) {
- text->format_new->font =
- swfdec_as_context_get_string (cx, text->text->font);
- }
- text->format_new->size = text->text->size / 20;
- text->format_new->left_margin = text->text->left_margin / 20;
- text->format_new->right_margin = text->text->right_margin / 20;
- text->format_new->indent = text->text->indent / 20;
- text->format_new->leading = text->text->leading / 20;
-
- text->border_color = SWFDEC_COLOR_COMBINE (0, 0, 0, 0);
- text->background_color = SWFDEC_COLOR_COMBINE (255, 255, 255, 0);
-
- // text
- if (text->text->input != NULL) {
- swfdec_text_field_movie_set_text (text,
- swfdec_as_context_get_string (cx, text->text->input),
- text->text->html);
- } else {
- swfdec_text_field_movie_set_text (text, SWFDEC_AS_STR_EMPTY,
- text->text->html);
- }
-
- // variable
- if (text->text->variable != NULL) {
- swfdec_text_field_movie_set_listen_variable (text,
- swfdec_as_context_get_string (cx, text->text->variable));
- }
-
-out:
- if (needs_unuse)
- swfdec_sandbox_unuse (movie->resource->sandbox);
-}
-
-static void
-swfdec_text_field_movie_finish_movie (SwfdecMovie *movie)
-{
- SwfdecTextFieldMovie *text = SWFDEC_TEXT_FIELD_MOVIE (movie);
-
- swfdec_text_field_movie_set_listen_variable (text, NULL);
-}
-
-static void
-swfdec_text_field_movie_iterate (SwfdecMovie *movie)
-{
- SwfdecTextFieldMovie *text = SWFDEC_TEXT_FIELD_MOVIE (movie);
-
- if (text->scroll_changed) {
- SwfdecAsValue argv[2];
-
- SWFDEC_FIXME ("I'm pretty sure this is swfdec_player_add_action()'d");
- SWFDEC_AS_VALUE_SET_STRING (&argv[0], SWFDEC_AS_STR_onScroller);
- SWFDEC_AS_VALUE_SET_OBJECT (&argv[1], SWFDEC_AS_OBJECT (movie));
- swfdec_sandbox_use (movie->resource->sandbox);
- swfdec_as_object_call (SWFDEC_AS_OBJECT (movie),
- SWFDEC_AS_STR_broadcastMessage, 2, argv, NULL);
- swfdec_sandbox_unuse (movie->resource->sandbox);
-
- /* FIXME: unset this before or after emitting the event? */
- text->scroll_changed = FALSE;
- }
-}
-
-static void
-swfdec_text_field_movie_class_init (SwfdecTextFieldMovieClass * g_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (g_class);
- SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (g_class);
- SwfdecMovieClass *movie_class = SWFDEC_MOVIE_CLASS (g_class);
-
- object_class->dispose = swfdec_text_field_movie_dispose;
-
- asobject_class->mark = swfdec_text_field_movie_mark;
-
- movie_class->init_movie = swfdec_text_field_movie_init_movie;
- movie_class->finish_movie = swfdec_text_field_movie_finish_movie;
- movie_class->iterate_start = swfdec_text_field_movie_iterate;
- movie_class->update_extents = swfdec_text_field_movie_update_extents;
- movie_class->render = swfdec_text_field_movie_render;
- movie_class->invalidate = swfdec_text_field_movie_invalidate;
-}
-
-static void
-swfdec_text_field_movie_init (SwfdecTextFieldMovie *text)
-{
- text->surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
- text->cr = cairo_create (text->surface);
-
- text->input = g_string_new ("");
- text->scroll = 1;
- text->mouse_wheel_enabled = TRUE;
-}
-
-void
-swfdec_text_field_movie_set_text_format (SwfdecTextFieldMovie *text,
- SwfdecTextFormat *format, guint start_index, guint end_index)
-{
- SwfdecFormatIndex *findex, *findex_new, *findex_prev;
- guint findex_end_index;
- GSList *iter, *next;
-
- g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
- g_return_if_fail (SWFDEC_IS_TEXT_FORMAT (format));
- g_return_if_fail (start_index < end_index);
- g_return_if_fail (end_index <= text->input->len);
-
- g_assert (text->formats != NULL);
- g_assert (text->formats->data != NULL);
- g_assert (((SwfdecFormatIndex *)text->formats->data)->index_ == 0);
-
- findex = NULL;
- for (iter = text->formats; iter != NULL &&
- ((SwfdecFormatIndex *)iter->data)->index_ < end_index;
- iter = next)
- {
- findex_prev = findex;
- next = iter->next;
- findex = iter->data;
- if (iter->next != NULL) {
- findex_end_index =
- ((SwfdecFormatIndex *)iter->next->data)->index_;
- } else {
- findex_end_index = text->input->len;
- }
-
- if (findex_end_index <= start_index)
- continue;
-
- if (swfdec_text_format_equal_or_undefined (findex->format, format))
- continue;
-
- if (findex_end_index > end_index) {
- findex_new = g_new (SwfdecFormatIndex, 1);
- findex_new->index_ = end_index;
- findex_new->format = swfdec_text_format_copy (findex->format);
- if (findex_new->format == NULL) {
- g_free (findex_new);
- break;
- }
-
- iter = g_slist_insert (iter, findex_new, 1);
- }
-
- if (findex->index_ < start_index) {
- findex_new = g_new (SwfdecFormatIndex, 1);
- findex_new->index_ = start_index;
- findex_new->format = swfdec_text_format_copy (findex->format);
- if (findex_new->format == NULL) {
- g_free (findex_new);
- break;
- }
- swfdec_text_format_add (findex_new->format, format);
-
- iter = g_slist_insert (iter, findex_new, 1);
- findex = findex_new;
- } else {
- swfdec_text_format_add (findex->format, format);
-
- // if current format now equals previous one, remove current
- if (findex_prev != NULL &&
- swfdec_text_format_equal (findex->format, findex_prev->format)) {
- text->formats = g_slist_remove (text->formats, findex);
- findex = findex_prev;
- }
- }
-
- // if current format now equals the next one, remove current
- if (findex_end_index <= end_index && next != NULL &&
- swfdec_text_format_equal (findex->format,
- ((SwfdecFormatIndex *)next->data)->format))
- {
- ((SwfdecFormatIndex *)next->data)->index_ = findex->index_;
- text->formats = g_slist_remove (text->formats, findex);
- findex = findex_prev;
- }
- }
-}
-
-SwfdecTextFormat *
-swfdec_text_field_movie_get_text_format (SwfdecTextFieldMovie *text,
- guint start_index, guint end_index)
-{
- SwfdecTextFormat *format;
- GSList *iter;
-
- g_assert (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
- g_assert (start_index < end_index);
- g_assert (end_index <= text->input->len);
-
- g_assert (text->formats != NULL);
- g_assert (text->formats->data != NULL);
- g_assert (((SwfdecFormatIndex *)text->formats->data)->index_ == 0);
-
- format = NULL;
- for (iter = text->formats; iter != NULL &&
- ((SwfdecFormatIndex *)iter->data)->index_ < end_index;
- iter = iter->next)
- {
- if (iter->next != NULL &&
- ((SwfdecFormatIndex *)iter->next->data)->index_ <= start_index)
- continue;
-
- if (format == NULL) {
- swfdec_text_format_init_properties (SWFDEC_AS_OBJECT (text)->context);
- format =
- swfdec_text_format_copy (((SwfdecFormatIndex *)iter->data)->format);
- } else {
- swfdec_text_format_remove_different (format,
- ((SwfdecFormatIndex *)iter->data)->format);
- }
- }
-
- return format;
-}
-
-static void
-swfdec_text_field_movie_parse_listen_variable (SwfdecTextFieldMovie *text,
- const char *variable, SwfdecAsObject **object, const char **name)
-{
- SwfdecAsContext *cx;
- SwfdecAsObject *parent;
- const char *p1, *p2;
-
- g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
- g_return_if_fail (variable != NULL);
- g_return_if_fail (object != NULL);
- g_return_if_fail (name != NULL);
-
- *object = NULL;
- *name = NULL;
-
- if (SWFDEC_MOVIE (text)->parent == NULL)
- return;
-
- g_assert (SWFDEC_IS_AS_OBJECT (SWFDEC_MOVIE (text)->parent));
- cx = SWFDEC_AS_OBJECT (text)->context;
- parent = SWFDEC_AS_OBJECT (SWFDEC_MOVIE (text)->parent);
-
- p1 = strrchr (variable, '.');
- p2 = strrchr (variable, ':');
- if (p1 == NULL && p2 == NULL) {
- *object = parent;
- *name = variable;
- } else {
- if (p1 == NULL || (p2 != NULL && p2 > p1))
- p1 = p2;
- if (strlen (p1) == 1)
- return;
- *object = swfdec_action_lookup_object (cx, parent, variable, p1);
- if (*object == NULL)
- return;
- *name = swfdec_as_context_get_string (cx, p1 + 1);
- }
-}
-
-void
-swfdec_text_field_movie_set_listen_variable_text (SwfdecTextFieldMovie *text,
- const char *value)
-{
- SwfdecAsObject *object;
- const char *name;
-
- g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
- g_return_if_fail (text->variable != NULL);
- g_return_if_fail (value != NULL);
-
- swfdec_text_field_movie_parse_listen_variable (text, text->variable,
- &object, &name);
- if (object != NULL) {
- SwfdecAsValue val;
- SWFDEC_AS_VALUE_SET_STRING (&val, value);
- swfdec_as_object_set_variable (object, name, &val);
- }
-}
-
-static void
-swfdec_text_field_movie_variable_listener_callback (SwfdecAsObject *object,
- const char *name, const SwfdecAsValue *val)
-{
- SwfdecTextFieldMovie *text;
-
- g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (object));
-
- text = SWFDEC_TEXT_FIELD_MOVIE (object);
- swfdec_text_field_movie_set_text (text,
- swfdec_as_value_to_string (object->context, val), text->text->html);
-}
-
-void
-swfdec_text_field_movie_set_listen_variable (SwfdecTextFieldMovie *text,
- const char *value)
-{
- SwfdecAsObject *object;
- const char *name;
-
- // FIXME: case-insensitive when v < 7?
- if (text->variable == value)
- return;
-
- if (text->variable != NULL) {
- swfdec_text_field_movie_parse_listen_variable (text, text->variable,
- &object, &name);
- if (object != NULL && SWFDEC_IS_MOVIE (object)) {
- swfdec_movie_remove_variable_listener (SWFDEC_MOVIE (object),
- SWFDEC_AS_OBJECT (text), name,
- swfdec_text_field_movie_variable_listener_callback);
- }
- }
-
- text->variable = value;
-
- if (value != NULL) {
- SwfdecAsValue val;
-
- swfdec_text_field_movie_parse_listen_variable (text, value, &object,
- &name);
- if (object != NULL && swfdec_as_object_get_variable (object, name, &val)) {
- swfdec_text_field_movie_set_text (text,
- swfdec_as_value_to_string (SWFDEC_AS_OBJECT (text)->context, &val),
- text->text->html);
- }
- if (object != NULL && SWFDEC_IS_MOVIE (object)) {
- swfdec_movie_add_variable_listener (SWFDEC_MOVIE (object),
- SWFDEC_AS_OBJECT (text), name,
- swfdec_text_field_movie_variable_listener_callback);
- }
- }
-}
-
-const char *
-swfdec_text_field_movie_get_text (SwfdecTextFieldMovie *text)
-{
- char *str, *p;
-
- str = g_strdup (text->input->str);
-
- // if input was orginally html, remove all \r
- if (text->input_html) {
- p = str;
- while ((p = strchr (p, '\r')) != NULL) {
- memmove (p, p + 1, strlen (p));
- }
- }
-
- // change all \n to \r
- p = str;
- while ((p = strchr (p, '\n')) != NULL) {
- *p = '\r';
- }
-
- return swfdec_as_context_give_string (SWFDEC_AS_OBJECT (text)->context, str);
-}
-
-void
-swfdec_text_field_movie_replace_text (SwfdecTextFieldMovie *text,
- guint start_index, guint end_index, const char *str)
-{
- SwfdecFormatIndex *findex;
- GSList *iter, *prev;
- gboolean first;
-
- g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
- g_return_if_fail (end_index <= text->input->len);
- g_return_if_fail (start_index <= end_index);
- g_return_if_fail (str != NULL);
-
- /* if there was a style sheet set when setting the text, modifications are
- * not allowed */
- if (text->style_sheet_input)
- return;
-
- first = TRUE;
- prev = NULL;
- for (iter = text->formats; iter != NULL; iter = iter->next)
- {
- findex = iter->data;
-
- if (findex->index_ >= start_index) {
- if (end_index == text->input->len ||(iter->next != NULL &&
- ((SwfdecFormatIndex *)iter->next->data)->index_ <= end_index))
- {
- g_free (iter->data);
- text->formats = g_slist_remove (text->formats, iter->data);
- iter = (prev != NULL ? prev : text->formats);
- }
- else
- {
- findex->index_ += strlen (str) - (end_index - start_index);
- if (first) {
- findex->index_ -= strlen (str);
- first = FALSE;
- }
- }
- }
- prev = iter;
- }
-
- if (end_index == text->input->len) {
- if (SWFDEC_AS_OBJECT (text)->context->version < 8) {
- SWFDEC_FIXME ("replaceText to the end of the TextField might use wrong text format on version 7");
- }
- findex = g_new0 (SwfdecFormatIndex, 1);
- findex->index_ = start_index;
- findex->format = swfdec_text_format_copy (
- ((SwfdecFormatIndex *)text->formats->data)->format);
- text->formats = g_slist_append (text->formats, findex);
- }
-
- text->input = g_string_erase (text->input, start_index,
- end_index - start_index);
- text->input = g_string_insert (text->input, start_index, str);
-
- swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
- swfdec_text_field_movie_auto_size (text);
- swfdec_text_field_movie_update_scroll (text, TRUE);
-}
-
-void
-swfdec_text_field_movie_set_text (SwfdecTextFieldMovie *text, const char *str,
- gboolean html)
-{
- SwfdecFormatIndex *block;
- GSList *iter;
-
- g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
- g_return_if_fail (str != NULL);
-
- if (text->format_new == NULL) {
- text->input = g_string_truncate (text->input, 0);
- return;
- }
-
- // remove old formatting info
- iter = text->formats;
- while (iter) {
- g_free (iter->data);
- iter = g_slist_next (iter);
- }
- g_slist_free (text->formats);
- text->formats = NULL;
-
- // add the default style
- if (html && SWFDEC_AS_OBJECT (text)->context->version < 8)
- swfdec_text_format_set_defaults (text->format_new);
- block = g_new (SwfdecFormatIndex, 1);
- block->index_ = 0;
- g_assert (SWFDEC_IS_TEXT_FORMAT (text->format_new));
- block->format = swfdec_text_format_copy (text->format_new);
- if (block->format == NULL) {
- g_free (block);
- text->input = g_string_truncate (text->input, 0);
- return;
- }
- text->formats = g_slist_prepend (text->formats, block);
-
- text->input_html = html;
-
- if (SWFDEC_AS_OBJECT (text)->context->version >= 7 &&
- text->style_sheet != NULL)
- {
- text->style_sheet_input = str;
- swfdec_text_field_movie_html_parse (text, str);
- }
- else
- {
- text->style_sheet_input = NULL;
- if (html) {
- swfdec_text_field_movie_html_parse (text, str);
- } else {
- text->input = g_string_assign (text->input, str);
- }
- }
-
- swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
- swfdec_text_field_movie_auto_size (text);
- swfdec_text_field_movie_update_scroll (text, TRUE);
-}
diff --git a/libswfdec/swfdec_text_field_movie.h b/libswfdec/swfdec_text_field_movie.h
deleted file mode 100644
index 8d719d3..0000000
--- a/libswfdec/swfdec_text_field_movie.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_TEXT_FIELD_MOVIE_H_
-#define _SWFDEC_TEXT_FIELD_MOVIE_H_
-
-#include <libswfdec/swfdec_movie.h>
-#include <libswfdec/swfdec_text_field.h>
-#include <libswfdec/swfdec_style_sheet.h>
-#include <libswfdec/swfdec_text_format.h>
-
-G_BEGIN_DECLS
-
-
-typedef struct _SwfdecTextFieldMovie SwfdecTextFieldMovie;
-typedef struct _SwfdecTextFieldMovieClass SwfdecTextFieldMovieClass;
-
-#define SWFDEC_TYPE_TEXT_FIELD_MOVIE (swfdec_text_field_movie_get_type())
-#define SWFDEC_IS_TEXT_FIELD_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_TEXT_FIELD_MOVIE))
-#define SWFDEC_IS_TEXT_FIELD_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_TEXT_FIELD_MOVIE))
-#define SWFDEC_TEXT_FIELD_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_TEXT_FIELD_MOVIE, SwfdecTextFieldMovie))
-#define SWFDEC_TEXT_FIELD_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_TEXT_FIELD_MOVIE, SwfdecTextFieldMovieClass))
-
-typedef struct {
- PangoLayout * layout;
- int offset_x;
- int last_line_offset_y;
- int height;
- int width;
- gboolean bullet;
-} SwfdecLayout;
-
-typedef struct {
- guint index_;
-
- PangoAlignment align;
- gboolean justify;
- int leading;
- int block_indent;
- int left_margin;
- int right_margin;
- PangoTabArray * tab_stops;
-} SwfdecBlock;
-
-typedef struct {
- guint index_;
- guint length;
- gboolean newline; // ends in newline
-
- gboolean bullet;
- int indent;
-
- GSList * blocks; // SwfdecBlock
- GSList * attrs; // PangoAttribute
-} SwfdecParagraph;
-
-typedef struct {
- guint index_;
- SwfdecTextFormat * format;
-} SwfdecFormatIndex;
-
-struct _SwfdecTextFieldMovie {
- SwfdecMovie movie;
-
- SwfdecTextField * text; /* the text_field object we render */
-
- GString * input;
- char * asterisks; /* bunch of asterisks that we display when password mode is enabled */
- guint asterisks_length;
- gboolean input_html; /* whether orginal input was given as HTML */
-
- const char * variable;
-
- SwfdecTextFormat * format_new;
- GSList * formats;
-
- gboolean condense_white;
- gboolean embed_fonts;
-
- SwfdecAsObject * style_sheet;
- const char * style_sheet_input; /* saved input, so it can be used to apply stylesheet again */
-
- gboolean scroll_changed; /* if any of the scroll attributes have changed and we haven't fired the event yet */
- int scroll;
- int scroll_max;
- int scroll_bottom;
- int hscroll;
- int hscroll_max;
- gboolean mouse_wheel_enabled;
-
- const char * restrict_;
-
- SwfdecColor border_color;
- SwfdecColor background_color;
-
- // FIXME: Temporary using image surface, until there is a way to get cairo_t
- // outside the rendering functions
- cairo_surface_t * surface;
- cairo_t * cr;
-};
-
-struct _SwfdecTextFieldMovieClass {
- SwfdecMovieClass movie_class;
-};
-
-GType swfdec_text_field_movie_get_type (void);
-
-void swfdec_text_field_movie_set_text (SwfdecTextFieldMovie * movie,
- const char * str,
- gboolean html);
-void swfdec_text_field_movie_get_text_size (SwfdecTextFieldMovie * text,
- int * width,
- int * height);
-gboolean swfdec_text_field_movie_auto_size (SwfdecTextFieldMovie * text);
-void swfdec_text_field_movie_update_scroll (SwfdecTextFieldMovie * text,
- gboolean check_limits);
-void swfdec_text_field_movie_set_text_format (SwfdecTextFieldMovie * text,
- SwfdecTextFormat * format,
- guint start_index,
- guint end_index);
-SwfdecTextFormat *swfdec_text_field_movie_get_text_format (SwfdecTextFieldMovie * text,
- guint start_index,
- guint end_index);
-const char * swfdec_text_field_movie_get_text (SwfdecTextFieldMovie * text);
-void swfdec_text_field_movie_set_listen_variable (SwfdecTextFieldMovie * text,
- const char * value);
-void swfdec_text_field_movie_set_listen_variable_text (SwfdecTextFieldMovie *text,
- const char * value);
-void swfdec_text_field_movie_replace_text (SwfdecTextFieldMovie * text,
- guint start_index,
- guint end_index,
- const char * str);
-
-/* implemented in swfdec_text_field_movie_as.c */
-void swfdec_text_field_movie_init_properties (SwfdecAsContext * cx);
-
-/* implemented in swfdec_html_parser.c */
-void swfdec_text_field_movie_html_parse (SwfdecTextFieldMovie * text,
- const char * str);
-const char * swfdec_text_field_movie_get_html_text (SwfdecTextFieldMovie * text);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_text_field_movie_as.c b/libswfdec/swfdec_text_field_movie_as.c
deleted file mode 100644
index 7e34120..0000000
--- a/libswfdec/swfdec_text_field_movie_as.c
+++ /dev/null
@@ -1,1539 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-#include <pango/pangocairo.h>
-
-#include "swfdec_text_field.h"
-#include "swfdec_text_field_movie.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-#include "swfdec_as_native_function.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_context.h"
-#include "swfdec_as_object.h"
-#include "swfdec_as_frame_internal.h"
-#include "swfdec_internal.h"
-#include "swfdec_player_internal.h"
-
-static SwfdecColor
-swfdec_text_field_movie_int_to_color (SwfdecAsContext *cx, int value)
-{
- if (value < 0) {
- value = (0xffffff + 1) + value % (0xffffff + 1);
- } else {
- value = value % (0xffffff + 1);
- }
-
- return SWFDEC_COLOR_COMBINE (value >> 16 & 0xff, value >> 8 & 0xff,
- value & 0xff, 0);
-}
-
-// does nothing but calls valueOf
-static void
-swfdec_text_field_movie_set_readonly (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- if (argc > 0)
- swfdec_as_value_to_number (cx, &argv[0]);
-}
-
-/*
- * Native properties: Text
- */
-static void
-swfdec_text_field_movie_do_get_text (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_text_field_movie_get_text (text));
-}
-
-static void
-swfdec_text_field_movie_do_set_text (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- const char *value;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "s", &value);
-
- swfdec_text_field_movie_set_text (text, value, FALSE);
-
- if (text->variable != NULL) {
- if (text->text->html) {
- swfdec_text_field_movie_set_listen_variable_text (text,
- swfdec_text_field_movie_get_html_text (text));
- } else {
- swfdec_text_field_movie_set_listen_variable_text (text,
- swfdec_text_field_movie_get_text (text));
- }
- }
-}
-
-static void
-swfdec_text_field_movie_get_html (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->text->html);
-}
-
-static void
-swfdec_text_field_movie_set_html (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- gboolean value;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
-
- swfdec_as_value_to_number (cx, &argv[0]);
-
- text->text->html = value;
-
- // FIXME: resize? invalidate?
-}
-
-static void
-swfdec_text_field_movie_get_htmlText (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- if (text->style_sheet_input) {
- SWFDEC_AS_VALUE_SET_STRING (ret, text->style_sheet_input);
- } else if (text->text->html) {
- SWFDEC_AS_VALUE_SET_STRING (ret,
- swfdec_text_field_movie_get_html_text (text));
- } else {
- SWFDEC_AS_VALUE_SET_STRING (ret,
- swfdec_text_field_movie_get_text (text));
- }
-}
-
-static void
-swfdec_text_field_movie_set_htmlText (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- const char *value;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "s", &value);
-
- swfdec_text_field_movie_set_text (text, value, text->text->html);
-
- if (text->variable != NULL) {
- if (text->text->html) {
- swfdec_text_field_movie_set_listen_variable_text (text,
- swfdec_text_field_movie_get_html_text (text));
- } else {
- swfdec_text_field_movie_set_listen_variable_text (text,
- swfdec_text_field_movie_get_text (text));
- }
- }
-}
-
-static void
-swfdec_text_field_movie_get_length (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- SWFDEC_AS_VALUE_SET_INT (ret, g_utf8_strlen (text->input->str, -1));
-}
-
-/*
- * Native properties: Input
- */
-static void
-swfdec_text_field_movie_get_condenseWhite (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->condense_white);
-}
-
-static void
-swfdec_text_field_movie_set_condenseWhite (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- gboolean value;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
-
- swfdec_as_value_to_number (cx, &argv[0]);
-
- text->condense_white = value;
-}
-
-static void
-swfdec_text_field_movie_get_maxChars (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- if (text->text->max_chars != 0) {
- SWFDEC_AS_VALUE_SET_INT (ret, text->text->max_chars);
- } else {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- }
-}
-
-static void
-swfdec_text_field_movie_set_maxChars (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- if (argc < 1)
- return;
-
- swfdec_as_value_to_number (cx, &argv[0]);
- text->text->max_chars = swfdec_as_value_to_integer (cx, &argv[0]);
-}
-
-static void
-swfdec_text_field_movie_get_multiline (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->text->multiline);
-}
-
-static void
-swfdec_text_field_movie_set_multiline (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- gboolean value;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
-
- swfdec_as_value_to_number (cx, &argv[0]);
-
- text->text->multiline = value;
-}
-
-static void
-swfdec_text_field_movie_get_restrict (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- if (text->restrict_ != NULL) {
- SWFDEC_AS_VALUE_SET_STRING (ret, text->restrict_);
- } else {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- }
-}
-
-static void
-swfdec_text_field_movie_set_restrict (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- const char *value;
-
- if (argc > 0)
- swfdec_as_value_to_number (cx, &argv[0]);
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "s", &value);
-
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]) ||
- SWFDEC_AS_VALUE_IS_NULL (&argv[0])) {
- text->restrict_ = NULL;
- } else {
- text->restrict_ = value;
- }
-}
-
-static void
-swfdec_text_field_movie_get_selectable (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->text->selectable);
-}
-
-static void
-swfdec_text_field_movie_set_selectable (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- gboolean value;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
-
- swfdec_as_value_to_number (cx, &argv[0]);
-
- text->text->selectable = value;
-
- // FIXME: invalidate
-}
-
-static void
-swfdec_text_field_movie_do_get_type (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- if (text->text->editable) {
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_input);
- } else {
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_dynamic);
- }
-}
-
-static void
-swfdec_text_field_movie_do_set_type (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- const char *value;
-
- if (argc > 0)
- swfdec_as_value_to_number (cx, &argv[0]);
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "s", &value);
-
- if (!g_strcasecmp (value, SWFDEC_AS_STR_input)) {
- text->text->editable = TRUE;
- } else if (!g_strcasecmp (value, SWFDEC_AS_STR_dynamic)) {
- text->text->editable = FALSE;
- }
-
- // FIXME: invalidate
-}
-
-static void
-swfdec_text_field_movie_do_get_variable (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- if (text->variable) {
- SWFDEC_AS_VALUE_SET_STRING (ret, text->variable);
- } else {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- }
-}
-
-static void
-swfdec_text_field_movie_do_set_variable (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- const char *value;
-
- if (argc > 0)
- swfdec_as_value_to_number (cx, &argv[0]);
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "s", &value);
-
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]) ||
- SWFDEC_AS_VALUE_IS_NULL (&argv[0]) || value == SWFDEC_AS_STR_EMPTY) {
- value = NULL;
- }
-
- swfdec_text_field_movie_set_listen_variable (text, value);
-}
-
-/*
- * Native properties: Info
- */
-static void
-swfdec_text_field_movie_get_textHeight (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- int height;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- swfdec_text_field_movie_get_text_size (text, NULL, &height);
- SWFDEC_AS_VALUE_SET_NUMBER (ret, SWFDEC_TWIPS_TO_DOUBLE (height));
-}
-
-static void
-swfdec_text_field_movie_get_textWidth (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- int width;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- swfdec_text_field_movie_get_text_size (text, &width, NULL);
- SWFDEC_AS_VALUE_SET_NUMBER (ret, SWFDEC_TWIPS_TO_DOUBLE (width));
-}
-
-/*
- * Native properties: Background & border
- */
-static void
-swfdec_text_field_movie_get_background (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->text->background);
-}
-
-static void
-swfdec_text_field_movie_set_background (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- gboolean value;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
-
- swfdec_as_value_to_number (cx, &argv[0]);
-
- if (text->text->background != value) {
- text->text->background = value;
- swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
- }
-}
-
-static void
-swfdec_text_field_movie_get_backgroundColor (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret,
- SWFDEC_COLOR_R (text->background_color) << 16 |
- SWFDEC_COLOR_G (text->background_color) << 8 |
- SWFDEC_COLOR_B (text->background_color));
-}
-
-static void
-swfdec_text_field_movie_set_backgroundColor (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- int value;
- SwfdecColor color;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "i", &value);
-
- color = swfdec_text_field_movie_int_to_color (cx, value);
- if (text->background_color != color) {
- text->background_color = color;
- swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
- }
-}
-
-static void
-swfdec_text_field_movie_get_border (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->text->border);
-}
-
-static void
-swfdec_text_field_movie_set_border (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- gboolean value;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
-
- swfdec_as_value_to_number (cx, &argv[0]);
-
- if (text->text->border != value) {
- text->text->border = value;
- swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
- }
-}
-
-static void
-swfdec_text_field_movie_get_borderColor (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret,
- SWFDEC_COLOR_R (text->border_color) << 16 |
- SWFDEC_COLOR_G (text->border_color) << 8 |
- SWFDEC_COLOR_B (text->border_color));
-}
-
-static void
-swfdec_text_field_movie_set_borderColor (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- int value;
- SwfdecColor color;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "i", &value);
-
- color = swfdec_text_field_movie_int_to_color (cx, value);
- if (text->border_color != color) {
- text->border_color = color;
- swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
- }
-}
-
-/*
- * Native properties: Scrolling
- */
-static void
-swfdec_text_field_movie_get_bottomScroll (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret, text->scroll_bottom);
-}
-
-static void
-swfdec_text_field_movie_do_get_hscroll (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret, text->hscroll);
-}
-
-static void
-swfdec_text_field_movie_do_set_hscroll (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- int value;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "i", &value);
-
- value = CLAMP (value, 0, text->hscroll_max);
- if (value != text->hscroll) {
- text->hscroll = value;
- text->scroll_changed = TRUE;
- swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
- }
-}
-
-static void
-swfdec_text_field_movie_get_maxhscroll (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- if (!text->text->word_wrap) {
- SWFDEC_AS_VALUE_SET_NUMBER (ret, text->hscroll_max);
- } else {
- SWFDEC_AS_VALUE_SET_NUMBER (ret, 0);
- }
-}
-
-static void
-swfdec_text_field_movie_get_maxscroll (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret, text->scroll_max);
-}
-
-static void
-swfdec_text_field_movie_get_mouseWheelEnabled (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->mouse_wheel_enabled);
-}
-
-static void
-swfdec_text_field_movie_set_mouseWheelEnabled (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- gboolean value;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
-
- swfdec_as_value_to_number (cx, &argv[0]);
-
- text->mouse_wheel_enabled = value;
-}
-
-static void
-swfdec_text_field_movie_do_get_scroll (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret, text->scroll);
-}
-
-static void
-swfdec_text_field_movie_do_set_scroll (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- int value;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "i", &value);
-
- value = CLAMP (value, 1, text->scroll_max);
- if (value != text->scroll) {
- text->scroll_bottom += value - text->scroll;
- text->scroll = value;
- text->scroll_changed = TRUE;
- swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
- }
-}
-
-/*
- * Native properties: Display
- */
-static void
-swfdec_text_field_movie_get_autoSize (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- switch (text->text->auto_size) {
- case SWFDEC_AUTO_SIZE_NONE:
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_none);
- break;
- case SWFDEC_AUTO_SIZE_LEFT:
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_left);
- break;
- case SWFDEC_AUTO_SIZE_RIGHT:
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_right);
- break;
- case SWFDEC_AUTO_SIZE_CENTER:
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_center);
- break;
- default:
- g_assert_not_reached ();
- }
-}
-
-static void
-swfdec_text_field_movie_set_autoSize (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- SwfdecAutoSize old;
- const char *s;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- if (argc < 1)
- return;
-
- if (SWFDEC_AS_VALUE_IS_BOOLEAN (&argv[0])) {
- if (SWFDEC_AS_VALUE_GET_BOOLEAN (&argv[0])) {
- text->text->auto_size = SWFDEC_AUTO_SIZE_LEFT;
- } else {
- text->text->auto_size = SWFDEC_AUTO_SIZE_NONE;
- }
- return;
- }
-
- swfdec_as_value_to_number (cx, &argv[0]);
- s = swfdec_as_value_to_string (cx, &argv[0]);
-
- old = text->text->auto_size;
- if (!g_ascii_strcasecmp (s, "none")) {
- text->text->auto_size = SWFDEC_AUTO_SIZE_NONE;
- } else if (!g_ascii_strcasecmp (s, "left")) {
- text->text->auto_size = SWFDEC_AUTO_SIZE_LEFT;
- } else if (!g_ascii_strcasecmp (s, "right")) {
- text->text->auto_size = SWFDEC_AUTO_SIZE_RIGHT;
- } else if (!g_ascii_strcasecmp (s, "center")) {
- text->text->auto_size = SWFDEC_AUTO_SIZE_CENTER;
- }
-
- if (text->text->auto_size != old) {
- swfdec_text_field_movie_auto_size (text);
- // FIXME: fix scrolling
- }
-}
-
-static void
-swfdec_text_field_movie_get_password (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->text->password);
-}
-
-static void
-swfdec_text_field_movie_set_password (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- gboolean value;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
-
- swfdec_as_value_to_number (cx, &argv[0]);
-
- if (text->text->password != value) {
- text->text->password = value;
- if (!value && text->asterisks != NULL) {
- g_free (text->asterisks);
- text->asterisks = NULL;
- text->asterisks_length = 0;
- }
- swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
- }
-}
-
-static void
-swfdec_text_field_movie_get_wordWrap (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->text->word_wrap);
-}
-
-static void
-swfdec_text_field_movie_set_wordWrap (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- gboolean value;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
-
- swfdec_as_value_to_number (cx, &argv[0]);
-
- if (text->text->word_wrap != value) {
- text->text->word_wrap = value;
- swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
- swfdec_text_field_movie_auto_size (text);
- // special case: don't set scrolling
- }
-}
-
-/*
- * Native properties: Format
- */
-static void
-swfdec_text_field_movie_get_embedFonts (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->text->embed_fonts);
-}
-
-static void
-swfdec_text_field_movie_set_embedFonts (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- gboolean value;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
-
- swfdec_as_value_to_number (cx, &argv[0]);
-
- if (!text->text->embed_fonts && value)
- SWFDEC_FIXME ("Using embed fonts in TextField not supported");
-
- text->text->embed_fonts = value;
-
- // FIXME: resize
-}
-
-static void
-swfdec_text_field_movie_get_styleSheet (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- if (text->style_sheet != NULL) {
- SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (text->style_sheet));
- } else {
- SWFDEC_AS_VALUE_SET_UNDEFINED (ret);
- }
-}
-
-static void
-swfdec_text_field_movie_style_sheet_update (SwfdecTextFieldMovie *text)
-{
- if (text->style_sheet_input)
- swfdec_text_field_movie_set_text (text, text->style_sheet_input, TRUE);
-}
-
-static void
-swfdec_text_field_movie_set_styleSheet (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- SwfdecAsObject *value;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- if (argc < 1)
- return;
-
- swfdec_as_value_to_number (cx, &argv[0]);
-
- if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[0])) {
- value = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
- if (SWFDEC_IS_MOVIE (value))
- value = NULL;
- } else {
- value = NULL;
- }
-
- if (text->style_sheet == value)
- return;
-
- if (text->style_sheet != NULL && SWFDEC_IS_STYLESHEET (text->style_sheet)) {
- g_signal_handlers_disconnect_by_func (text->style_sheet,
- swfdec_text_field_movie_style_sheet_update, text);
- g_object_remove_weak_pointer (G_OBJECT (text->style_sheet),
- (gpointer) &text->style_sheet);
- }
-
- text->style_sheet = value;
-
- if (SWFDEC_IS_STYLESHEET (value)) {
- g_signal_connect_swapped (value, "update",
- G_CALLBACK (swfdec_text_field_movie_style_sheet_update), text);
- g_object_add_weak_pointer (G_OBJECT (text->style_sheet),
- (gpointer) &text->style_sheet);
-
- swfdec_text_field_movie_style_sheet_update (text);
- }
-}
-
-static void
-swfdec_text_field_movie_get_textColor (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret, text->format_new->color);
-}
-
-// This doesn't work the same way as TextFormat's color setting
-static void
-swfdec_text_field_movie_set_textColor (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- int value;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "i", &value);
-
- text->format_new->color = swfdec_text_field_movie_int_to_color (cx, value);
-}
-
-SWFDEC_AS_NATIVE (104, 300, swfdec_text_field_movie_get_gridFitType)
-void
-swfdec_text_field_movie_get_gridFitType (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextField.gridFitType (get)");
-}
-
-SWFDEC_AS_NATIVE (104, 301, swfdec_text_field_movie_set_gridFitType)
-void
-swfdec_text_field_movie_set_gridFitType (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextField.gridFitType (set)");
-}
-
-SWFDEC_AS_NATIVE (104, 302, swfdec_text_field_movie_get_antiAliasType)
-void
-swfdec_text_field_movie_get_antiAliasType (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextField.antiAliasType (get)");
-}
-
-SWFDEC_AS_NATIVE (104, 303, swfdec_text_field_movie_set_antiAliasType)
-void
-swfdec_text_field_movie_set_antiAliasType (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextField.antiAliasType (set)");
-}
-
-SWFDEC_AS_NATIVE (104, 304, swfdec_text_field_movie_get_thickness)
-void
-swfdec_text_field_movie_get_thickness (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextField.thickness (get)");
-}
-
-SWFDEC_AS_NATIVE (104, 305, swfdec_text_field_movie_set_thickness)
-void
-swfdec_text_field_movie_set_thickness (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextField.thickness (set)");
-}
-
-SWFDEC_AS_NATIVE (104, 306, swfdec_text_field_movie_get_sharpness)
-void
-swfdec_text_field_movie_get_sharpness (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextField.sharpness (get)");
-}
-
-SWFDEC_AS_NATIVE (104, 307, swfdec_text_field_movie_set_sharpness)
-void
-swfdec_text_field_movie_set_sharpness (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextField.sharpness (set)");
-}
-
-SWFDEC_AS_NATIVE (104, 308, swfdec_text_field_movie_get_filters)
-void
-swfdec_text_field_movie_get_filters (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextField.filters (get)");
-}
-
-SWFDEC_AS_NATIVE (104, 309, swfdec_text_field_movie_set_filters)
-void
-swfdec_text_field_movie_set_filters (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextField.filters (set)");
-}
-
-/*
- * Native functions
- */
-SWFDEC_AS_NATIVE (104, 104, swfdec_text_field_movie_getNewTextFormat)
-void
-swfdec_text_field_movie_getNewTextFormat (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- swfdec_text_format_init_properties (cx);
-
- SWFDEC_AS_VALUE_SET_OBJECT (ret,
- SWFDEC_AS_OBJECT (swfdec_text_format_copy (text->format_new)));
-}
-
-SWFDEC_AS_NATIVE (104, 105, swfdec_text_field_movie_setNewTextFormat)
-void
-swfdec_text_field_movie_setNewTextFormat (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- SwfdecAsObject *obj;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "o", &obj);
-
- if (!SWFDEC_IS_TEXT_FORMAT (obj))
- return;
-
- swfdec_text_format_add (text->format_new, SWFDEC_TEXT_FORMAT (obj));
-}
-
-SWFDEC_AS_NATIVE (104, 102, swfdec_text_field_movie_setTextFormat)
-void
-swfdec_text_field_movie_setTextFormat (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- SwfdecTextFormat *format;
- int val, start_index, end_index;
- guint i;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- if (argc < 1)
- return;
-
- i = 0;
- if (argc <= i + 1) {
- start_index = 0;
- end_index = g_utf8_strlen (text->input->str, -1);
- } else {
- start_index = val = swfdec_as_value_to_integer (cx, &argv[i++]);
- start_index = CLAMP (start_index, 0, g_utf8_strlen (text->input->str, -1));
- if (argc <= i + 1) {
- if (val < 0) { // fail
- start_index = end_index = 0;
- } else{
- end_index = start_index + 1;
- }
- } else {
- end_index = swfdec_as_value_to_integer (cx, &argv[i++]);
- }
- end_index =
- CLAMP (end_index, start_index, g_utf8_strlen (text->input->str, -1));
- }
- if (start_index == end_index)
- return;
-
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[i]))
- return;
- if (!SWFDEC_IS_TEXT_FORMAT (SWFDEC_AS_VALUE_GET_OBJECT (&argv[i])))
- return;
-
- format = SWFDEC_TEXT_FORMAT (SWFDEC_AS_VALUE_GET_OBJECT (&argv[i]));
-
- swfdec_text_field_movie_set_text_format (text, format,
- g_utf8_offset_to_pointer (text->input->str, start_index) -
- text->input->str,
- g_utf8_offset_to_pointer (text->input->str, end_index) -
- text->input->str);
-
- swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
- swfdec_text_field_movie_auto_size (text);
- // special case: update the max values, not the current values
- swfdec_text_field_movie_update_scroll (text, FALSE);
-}
-
-SWFDEC_AS_NATIVE (104, 101, swfdec_text_field_movie_getTextFormat)
-void
-swfdec_text_field_movie_getTextFormat (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- SwfdecTextFormat *format;
- int val, start_index, end_index;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- if (argc == 0) {
- start_index = 0;
- end_index = g_utf8_strlen (text->input->str, -1);
- } else {
- start_index = val = swfdec_as_value_to_integer (cx, &argv[0]);
- start_index = CLAMP (start_index, 0, g_utf8_strlen (text->input->str, -1));
- if (argc == 1) {
- if (val < 0) { // fail
- start_index = end_index = 0;
- } else{
- end_index = start_index + 1;
- }
- } else {
- end_index = swfdec_as_value_to_integer (cx, &argv[1]);
- }
- end_index =
- CLAMP (end_index, start_index, g_utf8_strlen (text->input->str, -1));
- }
-
- if (start_index == end_index) {
- format = SWFDEC_TEXT_FORMAT (swfdec_text_format_new (cx));
- } else {
- format = swfdec_text_field_movie_get_text_format (text,
- g_utf8_offset_to_pointer (text->input->str, start_index) -
- text->input->str,
- g_utf8_offset_to_pointer (text->input->str, end_index) -
- text->input->str);
- }
-
- SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (format));
-}
-
-SWFDEC_AS_NATIVE (104, 100, swfdec_text_field_movie_replaceSel)
-void
-swfdec_text_field_movie_replaceSel (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextField.replaceSel");
-}
-
-SWFDEC_AS_NATIVE (104, 107, swfdec_text_field_movie_replaceText)
-void
-swfdec_text_field_movie_replaceText (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFieldMovie *text;
- int start_index, end_index;
- const char *str;
-
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "iis", &start_index,
- &end_index, &str);
-
- if (start_index < 0)
- return;
- if (end_index < start_index)
- return;
-
- start_index = MIN (start_index, g_utf8_strlen (text->input->str, -1));
- end_index = MIN (end_index, g_utf8_strlen (text->input->str, -1));
-
- swfdec_text_field_movie_replace_text (text,
- g_utf8_offset_to_pointer (text->input->str, start_index) -
- text->input->str,
- g_utf8_offset_to_pointer (text->input->str, end_index) -
- text->input->str, str);
-}
-
-// static
-SWFDEC_AS_NATIVE (104, 201, swfdec_text_field_movie_getFontList)
-void
-swfdec_text_field_movie_getFontList (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecAsArray *array;
- SwfdecAsValue val;
- PangoFontFamily **families;
- int i, n_families;
-
- pango_font_map_list_families (pango_cairo_font_map_get_default (),
- &families, &n_families);
-
- array = SWFDEC_AS_ARRAY (swfdec_as_array_new (cx));
- for (i = 0; i < n_families; i++) {
- SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_get_string (cx,
- pango_font_family_get_name (families[i])));
- swfdec_as_array_push (array, &val);
- }
- SWFDEC_AS_VALUE_SET_STRING (&val, SWFDEC_AS_STR_Sans);
- swfdec_as_array_push (array, &val);
- SWFDEC_AS_VALUE_SET_STRING (&val, SWFDEC_AS_STR_Serif);
- swfdec_as_array_push (array, &val);
- SWFDEC_AS_VALUE_SET_STRING (&val, SWFDEC_AS_STR_Monospace);
- swfdec_as_array_push (array, &val);
-
- g_free (families);
-
- SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (array));
-}
-
-SWFDEC_AS_NATIVE (104, 106, swfdec_text_field_movie_getDepth)
-void
-swfdec_text_field_movie_getDepth (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecTextFieldMovie *text;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- SWFDEC_AS_VALUE_SET_INT (rval, SWFDEC_MOVIE (text)->depth);
-}
-
-SWFDEC_AS_NATIVE (104, 103, swfdec_text_field_movie_removeTextField)
-void
-swfdec_text_field_movie_removeTextField (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *rval)
-{
- SwfdecTextFieldMovie *text;
- SwfdecMovie *movie;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
-
- movie = SWFDEC_MOVIE (text);
- if (swfdec_depth_classify (movie->depth) == SWFDEC_DEPTH_CLASS_DYNAMIC)
- swfdec_movie_remove (movie);
-}
-
-/*
- * Creating TextFields
- */
-SWFDEC_AS_NATIVE (104, 200, swfdec_text_field_movie_createTextField)
-void
-swfdec_text_field_movie_createTextField (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *rval)
-{
- SwfdecMovie *movie, *parent;
- SwfdecTextField *edittext;
- int depth, x, y, width, height;
- const char *name;
- SwfdecAsFunction *fun;
- SwfdecAsValue val;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &parent, "siiiii", &name, &depth, &x, &y, &width, &height);
-
- edittext = g_object_new (SWFDEC_TYPE_TEXT_FIELD, NULL);
- edittext->html = FALSE;
- edittext->editable = FALSE;
- edittext->password = FALSE;
- edittext->selectable = TRUE;
- edittext->font = NULL; // FIXME
- edittext->word_wrap = FALSE;
- edittext->multiline = FALSE;
- edittext->auto_size = SWFDEC_AUTO_SIZE_NONE;
- edittext->border = FALSE;
- edittext->size = 240; // FIXME: Correct?
-
- edittext->input = NULL;
- edittext->variable = NULL;
- edittext->color = 0;
- edittext->align = SWFDEC_TEXT_ALIGN_LEFT;
- edittext->left_margin = 0;
- edittext->right_margin = 0;
- edittext->indent = 0;
- edittext->leading = 0;
-
- SWFDEC_GRAPHIC (edittext)->extents.x0 = SWFDEC_DOUBLE_TO_TWIPS (x);
- SWFDEC_GRAPHIC (edittext)->extents.x1 =
- SWFDEC_GRAPHIC (edittext)->extents.x0 + SWFDEC_DOUBLE_TO_TWIPS (width);
- SWFDEC_GRAPHIC (edittext)->extents.y0 = SWFDEC_DOUBLE_TO_TWIPS (y);
- SWFDEC_GRAPHIC (edittext)->extents.y1 =
- SWFDEC_GRAPHIC (edittext)->extents.y0 + SWFDEC_DOUBLE_TO_TWIPS (height);
-
- movie = swfdec_movie_find (parent, depth);
- if (movie)
- swfdec_movie_remove (movie);
-
- movie = swfdec_movie_new (SWFDEC_PLAYER (cx), depth, parent, parent->resource,
- SWFDEC_GRAPHIC (edittext), name);
- g_assert (SWFDEC_IS_TEXT_FIELD_MOVIE (movie));
- g_object_unref (edittext);
- swfdec_movie_initialize (movie);
- swfdec_movie_update (movie);
-
- swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_TextField, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return;
- fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&val);
- if (!SWFDEC_IS_AS_FUNCTION (fun))
- return;
-
- /* set initial variables */
- if (swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (fun),
- SWFDEC_AS_STR_prototype, &val)) {
- swfdec_as_object_set_variable_and_flags (SWFDEC_AS_OBJECT (movie),
- SWFDEC_AS_STR___proto__, &val,
- SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
- }
- SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (fun));
- if (cx->version < 7) {
- swfdec_as_object_set_variable_and_flags (SWFDEC_AS_OBJECT (movie),
- SWFDEC_AS_STR_constructor, &val, SWFDEC_AS_VARIABLE_HIDDEN);
- }
- swfdec_as_object_set_variable_and_flags (SWFDEC_AS_OBJECT (movie),
- SWFDEC_AS_STR___constructor__, &val,
- SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_VERSION_6_UP);
-
- swfdec_as_function_call (fun, SWFDEC_AS_OBJECT (movie), 0, NULL, rval);
- cx->frame->construct = TRUE;
- swfdec_as_context_run (cx);
-}
-
-void
-swfdec_text_field_movie_init_properties (SwfdecAsContext *cx)
-{
- SwfdecAsValue val;
- SwfdecAsObject *object, *proto;
-
- // FIXME: We should only initialize if the prototype Object has not been
- // initialized by any object's constructor with native properties
- // (TextField, TextFormat, XML, XMLNode at least)
-
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (cx));
-
- swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_TextField, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return;
- object = SWFDEC_AS_VALUE_GET_OBJECT (&val);
- swfdec_as_object_get_variable (object, SWFDEC_AS_STR_prototype, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return;
- proto = SWFDEC_AS_VALUE_GET_OBJECT (&val);
-
- // text
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_text,
- swfdec_text_field_movie_do_get_text,
- swfdec_text_field_movie_do_set_text);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_html,
- swfdec_text_field_movie_get_html, swfdec_text_field_movie_set_html);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_htmlText,
- swfdec_text_field_movie_get_htmlText,
- swfdec_text_field_movie_set_htmlText);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_length,
- swfdec_text_field_movie_get_length,
- swfdec_text_field_movie_set_readonly);
-
- // input
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_condenseWhite,
- swfdec_text_field_movie_get_condenseWhite,
- swfdec_text_field_movie_set_condenseWhite);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_maxChars,
- swfdec_text_field_movie_get_maxChars,
- swfdec_text_field_movie_set_maxChars);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_multiline,
- swfdec_text_field_movie_get_multiline,
- swfdec_text_field_movie_set_multiline);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_restrict,
- swfdec_text_field_movie_get_restrict,
- swfdec_text_field_movie_set_restrict);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_selectable,
- swfdec_text_field_movie_get_selectable,
- swfdec_text_field_movie_set_selectable);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_type,
- swfdec_text_field_movie_do_get_type,
- swfdec_text_field_movie_do_set_type);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_variable,
- swfdec_text_field_movie_do_get_variable,
- swfdec_text_field_movie_do_set_variable);
-
- // info
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_textHeight,
- swfdec_text_field_movie_get_textHeight,
- swfdec_text_field_movie_set_readonly);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_textWidth,
- swfdec_text_field_movie_get_textWidth,
- swfdec_text_field_movie_set_readonly);
-
- // border & background
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_background,
- swfdec_text_field_movie_get_background,
- swfdec_text_field_movie_set_background);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_backgroundColor,
- swfdec_text_field_movie_get_backgroundColor,
- swfdec_text_field_movie_set_backgroundColor);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_border,
- swfdec_text_field_movie_get_border, swfdec_text_field_movie_set_border);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_borderColor,
- swfdec_text_field_movie_get_borderColor,
- swfdec_text_field_movie_set_borderColor);
-
- // scrolling
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_bottomScroll,
- swfdec_text_field_movie_get_bottomScroll,
- swfdec_text_field_movie_set_readonly);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_hscroll,
- swfdec_text_field_movie_do_get_hscroll,
- swfdec_text_field_movie_do_set_hscroll);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_maxhscroll,
- swfdec_text_field_movie_get_maxhscroll,
- swfdec_text_field_movie_set_readonly);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_maxscroll,
- swfdec_text_field_movie_get_maxscroll,
- swfdec_text_field_movie_set_readonly);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_mouseWheelEnabled,
- swfdec_text_field_movie_get_mouseWheelEnabled,
- swfdec_text_field_movie_set_mouseWheelEnabled);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_scroll,
- swfdec_text_field_movie_do_get_scroll,
- swfdec_text_field_movie_do_set_scroll);
-
- // display
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_autoSize,
- swfdec_text_field_movie_get_autoSize,
- swfdec_text_field_movie_set_autoSize);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_password,
- swfdec_text_field_movie_get_password,
- swfdec_text_field_movie_set_password);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_wordWrap,
- swfdec_text_field_movie_get_wordWrap,
- swfdec_text_field_movie_set_wordWrap);
-
- // format
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_embedFonts,
- swfdec_text_field_movie_get_embedFonts,
- swfdec_text_field_movie_set_embedFonts);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_styleSheet,
- swfdec_text_field_movie_get_styleSheet,
- swfdec_text_field_movie_set_styleSheet);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_textColor,
- swfdec_text_field_movie_get_textColor,
- swfdec_text_field_movie_set_textColor);
-
- // TODO: menu, tabEnabled, tabIndex
-
- // Version 8 properties have ASnative numbers:
- // gridFitType, antiAliasType, thickness, sharpness and filters
-}
-
-SWFDEC_AS_NATIVE (104, 0, swfdec_text_field_movie_construct)
-void
-swfdec_text_field_movie_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!cx->frame->construct) {
- SwfdecAsValue val;
- if (!swfdec_as_context_use_mem (cx, sizeof (SwfdecAsObject)))
- return;
- object = g_object_new (SWFDEC_TYPE_AS_OBJECT, NULL);
- swfdec_as_object_add (object, cx, sizeof (SwfdecAsObject));
- swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_TextField, &val);
- if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
- swfdec_as_object_set_constructor (object,
- SWFDEC_AS_VALUE_GET_OBJECT (&val));
- } else {
- SWFDEC_INFO ("\"TextField\" is not an object");
- }
- }
-
- swfdec_text_field_movie_init_properties (cx);
-
- // FIXME: do object.addListener (object);
-
- SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
-}
diff --git a/libswfdec/swfdec_text_field_movie_html.c b/libswfdec/swfdec_text_field_movie_html.c
deleted file mode 100644
index b0aa94f..0000000
--- a/libswfdec/swfdec_text_field_movie_html.c
+++ /dev/null
@@ -1,777 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "swfdec_text_field_movie.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_style_sheet.h"
-#include "swfdec_xml.h"
-#include "swfdec_debug.h"
-
-/*
- * Parsing
- */
-typedef struct {
- const char * name;
- int name_length;
- guint index;
- guint end_index;
- SwfdecTextFormat *format;
-} ParserTag;
-
-typedef struct {
- SwfdecAsContext *cx;
- gboolean multiline;
- gboolean condense_white;
- SwfdecStyleSheet *style_sheet;
- GString * text;
- GSList * tags_open;
- GSList * tags_closed;
-} ParserData;
-
-static void
-swfdec_text_field_movie_html_parse_close_tag (ParserData *data, ParserTag *tag)
-{
- g_return_if_fail (data != NULL);
- g_return_if_fail (tag != NULL);
-
- if (data->multiline &&
- ((tag->name_length == 1 && !g_strncasecmp (tag->name, "p", 1)) ||
- (tag->name_length == 2 && !g_strncasecmp (tag->name, "li", 2))))
- {
- GSList *iter;
-
- for (iter = data->tags_closed; iter != NULL; iter = iter->next) {
- ParserTag *f = iter->data;
- if (f->end_index < tag->index)
- break;
- if (f->name_length == 4 && !g_strncasecmp (f->name, "font", 4)) {
- ParserTag *n = g_new0 (ParserTag, 1);
- n->name = f->name;
- n->name_length = f->name_length;
- n->index = data->text->len;
- n->end_index = n->index + 1;
- if (f->format != NULL) {
- n->format = swfdec_text_format_copy (f->format);
- } else {
- n->format = NULL;
- }
- data->tags_closed = g_slist_prepend (data->tags_closed, n);
- break;
- }
- }
- data->text = g_string_append_c (data->text, '\n');
- }
-
- tag->end_index = data->text->len;
-
- data->tags_open = g_slist_remove (data->tags_open, tag);
- data->tags_closed = g_slist_prepend (data->tags_closed, tag);
-}
-
-static const char *
-swfdec_text_field_movie_html_parse_comment (ParserData *data, const char *p)
-{
- const char *end;
-
- g_return_val_if_fail (data != NULL, NULL);
- g_return_val_if_fail (p != NULL, NULL);
- g_return_val_if_fail (strncmp (p, "<!--", strlen ("<!--")) == 0, NULL);
-
- end = strstr (p + strlen ("<!--"), "-->");
- if (end != NULL)
- end += strlen("-->");
-
- // return NULL if no end found
- return end;
-}
-
-static void
-swfdec_text_field_movie_html_tag_set_attribute (ParserData *data,
- ParserTag *tag, const char *name, int name_length, const char *value,
- int value_length)
-{
- SwfdecAsValue val;
- SwfdecAsObject *object;
-
- g_return_if_fail (data != NULL);
- g_return_if_fail (tag != NULL);
- g_return_if_fail (name != NULL);
- g_return_if_fail (name_length >= 0);
- g_return_if_fail (value != NULL);
- g_return_if_fail (value_length >= 0);
-
- if (!tag->format)
- return;
-
- object = SWFDEC_AS_OBJECT (tag->format);
- SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_give_string (
- object->context, g_strndup (value, value_length)));
-
- if (tag->name_length == 10 && !g_strncasecmp (tag->name, "textformat", 10))
- {
- if (name_length == 10 && !g_strncasecmp (name, "leftmargin", 10))
- {
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_leftMargin, &val);
- }
- else if (name_length == 11 && !g_strncasecmp (name, "rightmargin", 11))
- {
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_rightMargin, &val);
- }
- else if (name_length == 6 && !g_strncasecmp (name, "indent", 6))
- {
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_indent, &val);
- }
- else if (name_length == 11 && !g_strncasecmp (name, "blockindent", 11))
- {
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_blockIndent, &val);
- }
- else if (name_length == 8 && !g_strncasecmp (name, "tabstops", 8))
- {
- // FIXME
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_tabStops, &val);
- }
- }
- else if (tag->name_length == 1 && !g_strncasecmp (tag->name, "p", 1))
- {
- if (name_length == 5 && !g_strncasecmp (name, "align", 5))
- {
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_align, &val);
- }
- }
- else if (tag->name_length == 4 && !g_strncasecmp (tag->name, "font", 4))
- {
- if (name_length == 4 && !g_strncasecmp (name, "face", 4))
- {
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_font, &val);
- }
- else if (name_length == 4 && !g_strncasecmp (name, "size", 4))
- {
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_size, &val);
- }
- else if (name_length == 5 && !g_strncasecmp (name, "color", 5))
- {
- SwfdecAsValue val_number;
-
- if (value_length != 7 || *value != '#') {
- SWFDEC_AS_VALUE_SET_NUMBER (&val_number, 0);
- } else {
- int number;
- char *tail;
-
- number = g_ascii_strtoll (value + 1, &tail, 16);
- if (tail != value + 7)
- number = 0;
- SWFDEC_AS_VALUE_SET_NUMBER (&val_number, number);
- }
-
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_color, &val_number);
- }
- else if (name_length == 13 && !g_strncasecmp (name, "letterspacing", 13))
- {
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_letterSpacing,
- &val);
- }
- // special case: Don't parse kerning
- }
- else if (tag->name_length == 1 && !g_strncasecmp (tag->name, "a", 1))
- {
- if (name_length == 4 && !g_strncasecmp (name, "href", 4))
- {
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_url, &val);
- }
- else if (name_length == 6 && !g_strncasecmp (name, "target", 6))
- {
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_target, &val);
- }
- }
-
- if (data->style_sheet &&
- ((tag->name_length == 2 && !g_strncasecmp (tag->name, "li", 2)) ||
- (tag->name_length == 4 && !g_strncasecmp (tag->name, "span", 4)) ||
- (tag->name_length == 1 && !g_strncasecmp (tag->name, "p", 1))))
- {
- if (name_length == 5 && !g_strncasecmp (name, "class", 5)) {
- SwfdecTextFormat *format = swfdec_style_sheet_get_class_format (
- data->style_sheet, swfdec_as_context_give_string (data->cx,
- g_strndup (value, value_length)));
- if (format != NULL)
- swfdec_text_format_add (tag->format, format);
- }
- }
-}
-
-static const char *
-swfdec_text_field_movie_html_parse_attribute (ParserData *data, ParserTag *tag,
- const char *p)
-{
- const char *end, *name, *value;
- int name_length, value_length;
-
- g_return_val_if_fail (data != NULL, NULL);
- g_return_val_if_fail (tag != NULL, NULL);
- g_return_val_if_fail ((*p != '>' && *p != '\0'), NULL);
-
- end = p + strcspn (p, "=> \r\n\t");
- if (end - p <= 0)
- return NULL; // Correct?
-
- name = p;
- name_length = end - p;
-
- p = end + strspn (end, " \r\n\t");
- if (*p != '=')
- return NULL; // FIXME: Correct?
- p = p + 1;
- p = p + strspn (p, " \r\n\t");
-
- if (*p != '"' && *p != '\'')
- return NULL; // FIXME: Correct?
-
- end = p + 1;
- do {
- end = strchr (end, *p);
- } while (end != NULL && *(end - 1) == '\\');
-
- if (end == NULL)
- return NULL; // FIXME: Correct?
-
- value = p + 1;
- value_length = end - (p + 1);
-
- if (tag != NULL) {
- swfdec_text_field_movie_html_tag_set_attribute (data, tag, name,
- name_length, value, value_length);
- }
-
- g_return_val_if_fail (end + 1 > p, NULL);
-
- return end + 1;
-}
-
-static const char *
-swfdec_text_field_movie_html_parse_tag (ParserData *data, const char *p)
-{
- ParserTag *tag;
- const char *name, *end;
- int name_length;
- gboolean close;
-
- g_return_val_if_fail (data != NULL, NULL);
- g_return_val_if_fail (p != NULL, NULL);
- g_return_val_if_fail (*p == '<', NULL);
-
- p++;
-
- // closing tag or opening tag?
- if (*p == '/') {
- close = TRUE;
- p++;
- } else {
- close = FALSE;
- }
-
- // find the end of the name
- end = p + strcspn (p, "> \r\n\t");
-
- if (*end == '\0')
- return NULL;
-
- // don't count trailing / as part of the name if it's followed by >
- // we still act like it's a normal opening tag even if it has /
- if (*end == '>' && *(end - 1) == '/')
- end = end - 1;
-
- if (end == p) // empty name
- return NULL;
-
- name = p;
- name_length = end - p;
-
- if (close)
- {
- if (data->tags_open != NULL) {
- tag = data->tags_open->data;
- if (name_length == tag->name_length &&
- !g_strncasecmp (name, tag->name, name_length))
- swfdec_text_field_movie_html_parse_close_tag (data, tag);
- }
-
- end = strchr (end, '>');
- if (end != NULL)
- end += 1;
- }
- else
- {
- SwfdecAsObject *object;
- SwfdecAsValue val;
-
- if (data->multiline) {
- if (name_length == 2 && !g_strncasecmp (name, "br", 2))
- {
- data->text = g_string_append_c (data->text, '\n');
- }
- else if ((name_length == 1 && !g_strncasecmp (name, "p", 1)) ||
- (name_length == 2 && !g_strncasecmp (name, "li", 2)) ||
- (name_length == 2 && !g_strncasecmp (name, "br", 2)))
- {
- GSList *iter;
-
- for (iter = data->tags_open; iter != NULL; iter = iter->next) {
- ParserTag *f = iter->data;
- if ((f->name_length == 1 && !g_strncasecmp (f->name, "p", 1)) ||
- (f->name_length == 2 && !g_strncasecmp (f->name, "li", 2))) {
- data->text = g_string_append_c (data->text, '\n');
- break;
- }
- }
- }
- }
-
- tag = g_new0 (ParserTag, 1);
- tag->name = name;
- tag->name_length = name_length;
- tag->format = SWFDEC_TEXT_FORMAT (swfdec_text_format_new (data->cx));
- tag->index = data->text->len;
-
- data->tags_open = g_slist_prepend (data->tags_open, tag);
-
- // set format based on tag
- if (tag->format != NULL) {
- object = SWFDEC_AS_OBJECT (tag->format);
- SWFDEC_AS_VALUE_SET_BOOLEAN (&val, TRUE);
-
- if (tag->name_length == 2 && !g_strncasecmp (tag->name, "li", 2)) {
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_bullet, &val);
- } else if (tag->name_length == 1 && !g_strncasecmp (tag->name, "b", 1)) {
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_bold, &val);
- } else if (tag->name_length == 1 && !g_strncasecmp (tag->name, "i", 1)) {
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_italic, &val);
- } else if (tag->name_length == 1 && !g_strncasecmp (tag->name, "u", 1)) {
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_underline, &val);
- }
- else if (tag->name_length == 3 && !g_strncasecmp (tag->name, "img", 3))
- {
- SWFDEC_FIXME ("IMG tag support for TextField's HTML input missing");
- }
- }
-
- if (data->style_sheet &&
- ((tag->name_length == 2 && !g_strncasecmp (tag->name, "li", 2)) ||
- (tag->name_length == 1 && !g_strncasecmp (tag->name, "p", 1)))) {
- SwfdecTextFormat *format = swfdec_style_sheet_get_tag_format (
- data->style_sheet, swfdec_as_context_give_string (data->cx,
- g_strndup (tag->name, tag->name_length)));
- if (format != NULL)
- swfdec_text_format_add (tag->format, format);
- }
-
- // parse attributes
- end = end + strspn (end, " \r\n\t");
- while (*end != '\0' && *end != '>' && (*end != '/' || *(end + 1) != '>')) {
- end = swfdec_text_field_movie_html_parse_attribute (data, tag, end);
- if (end == NULL)
- break;
- end = end + strspn (end, " \r\n\t");
- }
- if (end != NULL) {
- if (*end == '/')
- end += 1;
- if (*end == '>')
- end += 1;
- }
- }
-
- return end;
-}
-
-static const char *
-swfdec_text_field_movie_html_parse_text (ParserData *data, const char *p)
-{
- const char *end;
- char *unescaped;
-
- g_return_val_if_fail (data != NULL, NULL);
- g_return_val_if_fail (p != NULL, NULL);
- g_return_val_if_fail (*p != '\0' && *p != '<', NULL);
-
- // get the text
- // if condense_white: all whitespace blocks are converted to a single space
- while (*p != '\0' && *p != '<') {
- if (data->condense_white) {
- end = p + strcspn (p, "< \n\r\t");
- } else {
- end = strchr (p, '<');
- if (end == NULL)
- end = strchr (p, '\0');
- }
-
- unescaped = swfdec_xml_unescape_len (data->cx, p, end - p, TRUE);
- data->text = g_string_append (data->text, unescaped);
- g_free (unescaped);
-
- if (data->condense_white && g_ascii_isspace (*end)) {
- data->text = g_string_append_c (data->text, ' ');
- p = end + strspn (end, " \n\r\t");
- } else {
- p = end;
- }
- }
-
- return p;
-}
-
-void
-swfdec_text_field_movie_html_parse (SwfdecTextFieldMovie *text, const char *str)
-{
- ParserData data;
- const char *p;
-
- g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
- g_return_if_fail (str != NULL);
-
- text->input = g_string_assign (text->input, "");
-
- data.cx = SWFDEC_AS_OBJECT (text)->context;
- data.multiline = (data.cx->version < 7 || text->text->multiline);
- data.condense_white = text->condense_white;
- if (text->style_sheet != NULL && SWFDEC_IS_STYLESHEET (text->style_sheet)) {
- data.style_sheet = SWFDEC_STYLESHEET (text->style_sheet);
- } else {
- data.style_sheet = NULL;
- }
- data.text = text->input;
- data.tags_open = NULL;
- data.tags_closed = NULL;
-
- p = str;
- while (p != NULL && *p != '\0') {
- if (*p == '<') {
- if (strncmp (p + 1, "!--", strlen ("!--")) == 0) {
- p = swfdec_text_field_movie_html_parse_comment (&data, p);
- } else {
- p = swfdec_text_field_movie_html_parse_tag (&data, p);
- }
- } else {
- p = swfdec_text_field_movie_html_parse_text (&data, p);
- }
- }
-
- // close remaining tags
- while (data.tags_open != NULL) {
- swfdec_text_field_movie_html_parse_close_tag (&data,
- (ParserTag *)data.tags_open->data);
- }
-
- // add parsed styles
- while (data.tags_closed != NULL) {
- ParserTag *tag = (ParserTag *)data.tags_closed->data;
-
- if (tag->index != tag->end_index && tag->format != NULL) {
- swfdec_text_field_movie_set_text_format (text, tag->format, tag->index,
- tag->end_index);
- }
-
- g_free (tag);
- data.tags_closed = g_slist_remove (data.tags_closed, tag);
- }
-}
-
-/*
- * Generating
- */
-static const char *
-swfdec_text_field_movie_html_text_align_to_string (SwfdecTextAlign align)
-{
- switch (align) {
- case SWFDEC_TEXT_ALIGN_LEFT:
- return "LEFT";
- case SWFDEC_TEXT_ALIGN_RIGHT:
- return "RIGHT";
- case SWFDEC_TEXT_ALIGN_CENTER:
- return "CENTER";
- case SWFDEC_TEXT_ALIGN_JUSTIFY:
- return "JUSTIFY";
- default:
- g_assert_not_reached ();
- return "";
- }
-}
-
-/*
- * Order of tags:
- * TEXTFORMAT / P or LI / FONT / A / B / I / U
- *
- * Order of attributes:
- * TEXTFORMAT:
- * LEFTMARGIN / RIGHTMARGIN / INDENT / LEADING / BLOCKINDENT / TABSTOPS
- * P: ALIGN
- * LI: none
- * FONT: FACE / SIZE / COLOR / LETTERSPACING / KERNING
- * A: HREF / TARGET
- * B: none
- * I: none
- * U: none
- */
-static GString *
-swfdec_text_field_movie_html_text_append_paragraph (SwfdecTextFieldMovie *text,
- GString *string, guint start_index, guint end_index)
-{
- SwfdecTextFormat *format, *format_prev, *format_font;
- GSList *iter, *fonts, *iter_font;
- guint index_, index_prev;
- gboolean textformat, bullet, font = FALSE;
- char *escaped;
-
- g_return_val_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text), string);
- g_return_val_if_fail (string != NULL, string);
- g_return_val_if_fail (start_index <= end_index, string);
-
- g_return_val_if_fail (text->formats != NULL, string);
- for (iter = text->formats; iter->next != NULL &&
- ((SwfdecFormatIndex *)(iter->next->data))->index_ <= start_index;
- iter = iter->next);
-
- index_ = start_index;
- format = ((SwfdecFormatIndex *)(iter->data))->format;
-
- if (format->left_margin != 0 || format->right_margin != 0 ||
- format->indent != 0 || format->leading != 0 ||
- format->block_indent != 0 ||
- swfdec_as_array_get_length (format->tab_stops) > 0)
- {
- string = g_string_append (string, "<TEXTFORMAT");
- if (format->left_margin) {
- g_string_append_printf (string, " LEFTMARGIN=\"%i\"",
- format->left_margin);
- }
- if (format->right_margin) {
- g_string_append_printf (string, " RIGHTMARGIN=\"%i\"",
- format->right_margin);
- }
- if (format->indent)
- g_string_append_printf (string, " INDENT=\"%i\"", format->indent);
- if (format->leading)
- g_string_append_printf (string, " LEADING=\"%i\"", format->leading);
- if (format->block_indent) {
- g_string_append_printf (string, " BLOCKINDENT=\"%i\"",
- format->block_indent);
- }
- if (swfdec_as_array_get_length (format->tab_stops) > 0) {
- SwfdecAsValue val;
- SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (format->tab_stops));
- g_string_append_printf (string, " TABSTOPS=\"%s\"",
- swfdec_as_value_to_string (SWFDEC_AS_OBJECT
- (format->tab_stops)->context, &val));
- }
- string = g_string_append (string, ">");
-
- textformat = TRUE;
- }
- else
- {
- textformat = FALSE;
- }
-
- if (format->bullet) {
- string = g_string_append (string, "<LI>");
- bullet = TRUE;
- } else {
- g_string_append_printf (string, "<P ALIGN=\"%s\">",
- swfdec_text_field_movie_html_text_align_to_string (format->align));
- bullet = FALSE;
- }
-
- // note we don't escape format->font, even thought it can have evil chars
- g_string_append_printf (string, "<FONT FACE=\"%s\" SIZE=\"%i\" COLOR=\"#%06X\" LETTERSPACING=\"%i\" KERNING=\"%i\">",
- format->font, format->size, format->color, (int)format->letter_spacing,
- (format->kerning ? 1 : 0));
- fonts = g_slist_prepend (NULL, format);
-
- if (format->url != SWFDEC_AS_STR_EMPTY)
- g_string_append_printf (string, "<A HREF=\"%s\" TARGET=\"%s\">",
- format->url, format->target);
- if (format->bold)
- string = g_string_append (string, "<B>");
- if (format->italic)
- string = g_string_append (string, "<I>");
- if (format->underline)
- string = g_string_append (string, "<U>");
-
- // special case: use <= instead of < to add some extra markup
- for (iter = iter->next;
- iter != NULL && ((SwfdecFormatIndex *)(iter->data))->index_ <= end_index;
- iter = iter->next)
- {
- index_prev = index_;
- format_prev = format;
- index_ = ((SwfdecFormatIndex *)(iter->data))->index_;
- format = ((SwfdecFormatIndex *)(iter->data))->format;
-
- escaped = swfdec_xml_escape_len (text->input->str + index_prev,
- index_ - index_prev);
- string = g_string_append (string, escaped);
- g_free (escaped);
- escaped = NULL;
-
- // Figure out what tags need to be rewritten
- if (format->font != format_prev->font ||
- format->size != format_prev->size ||
- format->color != format_prev->color ||
- (int)format->letter_spacing != (int)format_prev->letter_spacing ||
- format->kerning != format_prev->kerning) {
- font = TRUE;
- } else if (format->url == format_prev->url &&
- format->target == format_prev->target &&
- format->bold == format_prev->bold &&
- format->italic == format_prev->italic &&
- format->underline == format_prev->underline) {
- continue;
- }
-
- // Close tags
- for (iter_font = fonts; iter_font != NULL; iter_font = iter_font->next)
- {
- format_font = (SwfdecTextFormat *)iter_font->data;
- if (format->font == format_font->font &&
- format->size == format_font->size &&
- format->color == format_font->color &&
- (int)format->letter_spacing == (int)format_font->letter_spacing &&
- format->kerning == format_font->kerning) {
- break;
- }
- }
- if (format_prev->underline)
- string = g_string_append (string, "</U>");
- if (format_prev->italic)
- string = g_string_append (string, "</I>");
- if (format_prev->bold)
- string = g_string_append (string, "</B>");
- if (format_prev->url != SWFDEC_AS_STR_EMPTY)
- string = g_string_append (string, "</A>");
- if (iter_font != NULL) {
- while (fonts != iter_font) {
- string = g_string_append (string, "</FONT>");
- fonts = g_slist_remove (fonts, fonts->data);
- }
- }
-
- // Open tags
- format_font = (SwfdecTextFormat *)fonts->data;
- if (font && (format->font != format_font->font ||
- format->size != format_font->size ||
- format->color != format_font->color ||
- (int)format->letter_spacing != (int)format_font->letter_spacing ||
- format->kerning != format_font->kerning))
- {
- fonts = g_slist_prepend (fonts, format);
-
- string = g_string_append (string, "<FONT");
- // note we don't escape format->font, even thought it can have evil chars
- if (format->font != format_font->font)
- g_string_append_printf (string, " FACE=\"%s\"", format->font);
- if (format->size != format_font->size)
- g_string_append_printf (string, " SIZE=\"%i\"", format->size);
- if (format->color != format_font->color)
- g_string_append_printf (string, " COLOR=\"#%06X\"", format->color);
- if ((int)format->letter_spacing != (int)format_font->letter_spacing) {
- g_string_append_printf (string, " LETTERSPACING=\"%i\"",
- (int)format->letter_spacing);
- }
- if (format->kerning != format_font->kerning) {
- g_string_append_printf (string, " KERNING=\"%i\"",
- (format->kerning ? 1 : 0));
- }
- string = g_string_append (string, ">");
- }
- if (format->url != SWFDEC_AS_STR_EMPTY) {
- g_string_append_printf (string, "<A HREF=\"%s\" TARGET=\"%s\">",
- format->url, format->target);
- }
- if (format->bold)
- string = g_string_append (string, "<B>");
- if (format->italic)
- string = g_string_append (string, "<I>");
- if (format->underline)
- string = g_string_append (string, "<U>");
- }
-
- escaped = swfdec_xml_escape_len (text->input->str + index_,
- end_index - index_);
- string = g_string_append (string, escaped);
- g_free (escaped);
-
- if (format->underline)
- string = g_string_append (string, "</U>");
- if (format->italic)
- string = g_string_append (string, "</I>");
- if (format->bold)
- string = g_string_append (string, "</B>");
- if (format->url != SWFDEC_AS_STR_EMPTY)
- string = g_string_append (string, "</A>");
- for (iter = fonts; iter != NULL; iter = iter->next)
- string = g_string_append (string, "</FONT>");
- g_slist_free (fonts);
- if (bullet) {
- string = g_string_append (string, "</LI>");
- } else {
- string = g_string_append (string, "</P>");
- }
- if (textformat)
- string = g_string_append (string, "</TEXTFORMAT>");
-
- return string;
-}
-
-const char *
-swfdec_text_field_movie_get_html_text (SwfdecTextFieldMovie *text)
-{
- const char *p, *end;
- GString *string;
-
- g_return_val_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text),
- SWFDEC_AS_STR_EMPTY);
-
- if (text->input == NULL)
- return SWFDEC_AS_STR_EMPTY;
-
- string = g_string_new ("");
-
- p = text->input->str;
- while (*p != '\0') {
- end = strpbrk (p, "\r\n");
- if (end == NULL)
- end = strchr (p, '\0');
-
- string = swfdec_text_field_movie_html_text_append_paragraph (text, string,
- p - text->input->str, end - text->input->str);
-
- p = end;
- if (*p != '\0') p++;
- }
-
- return swfdec_as_context_give_string (SWFDEC_AS_OBJECT (text)->context,
- g_string_free (string, FALSE));
-}
diff --git a/libswfdec/swfdec_text_format.c b/libswfdec/swfdec_text_format.c
deleted file mode 100644
index 79e82ee..0000000
--- a/libswfdec/swfdec_text_format.c
+++ /dev/null
@@ -1,1274 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-#include <string.h>
-
-#include "swfdec_text_format.h"
-#include "swfdec_as_native_function.h"
-#include "swfdec_as_array.h"
-#include "swfdec_as_object.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-#include "swfdec_internal.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_player_internal.h"
-
-G_DEFINE_TYPE (SwfdecTextFormat, swfdec_text_format, SWFDEC_TYPE_AS_OBJECT)
-
-typedef enum {
- PROP_ALIGN = 0,
- PROP_BLOCK_INDENT,
- PROP_BOLD,
- PROP_BULLET,
- PROP_COLOR,
- PROP_DISPLAY,
- PROP_FONT,
- PROP_INDENT,
- PROP_ITALIC,
- PROP_KERNING,
- PROP_LEADING,
- PROP_LEFT_MARGIN,
- PROP_LETTER_SPACING,
- PROP_RIGHT_MARGIN,
- PROP_SIZE,
- PROP_TAB_STOPS,
- PROP_TARGET,
- PROP_UNDERLINE,
- PROP_URL,
- PROP_TOTAL
-} FormatProp;
-
-static int property_offsets[] = {
- G_STRUCT_OFFSET (SwfdecTextFormat, align),
- G_STRUCT_OFFSET (SwfdecTextFormat, block_indent),
- G_STRUCT_OFFSET (SwfdecTextFormat, bold),
- G_STRUCT_OFFSET (SwfdecTextFormat, bullet),
- G_STRUCT_OFFSET (SwfdecTextFormat, color),
- G_STRUCT_OFFSET (SwfdecTextFormat, display),
- G_STRUCT_OFFSET (SwfdecTextFormat, font),
- G_STRUCT_OFFSET (SwfdecTextFormat, indent),
- G_STRUCT_OFFSET (SwfdecTextFormat, italic),
- G_STRUCT_OFFSET (SwfdecTextFormat, kerning),
- G_STRUCT_OFFSET (SwfdecTextFormat, leading),
- G_STRUCT_OFFSET (SwfdecTextFormat, left_margin),
- G_STRUCT_OFFSET (SwfdecTextFormat, letter_spacing),
- G_STRUCT_OFFSET (SwfdecTextFormat, right_margin),
- G_STRUCT_OFFSET (SwfdecTextFormat, size),
- G_STRUCT_OFFSET (SwfdecTextFormat, tab_stops),
- G_STRUCT_OFFSET (SwfdecTextFormat, target),
- G_STRUCT_OFFSET (SwfdecTextFormat, underline),
- G_STRUCT_OFFSET (SwfdecTextFormat, url)
-};
-
-static void
-swfdec_text_format_do_mark (SwfdecAsObject *object)
-{
- SwfdecTextFormat *format = SWFDEC_TEXT_FORMAT (object);
-
- if (format->font != NULL)
- swfdec_as_string_mark (format->font);
- if (format->tab_stops != NULL)
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (format->tab_stops));
- if (format->target != NULL)
- swfdec_as_string_mark (format->target);
- if (format->url != NULL)
- swfdec_as_string_mark (format->url);
-
- SWFDEC_AS_OBJECT_CLASS (swfdec_text_format_parent_class)->mark (object);
-}
-
-static void
-swfdec_text_format_class_init (SwfdecTextFormatClass *klass)
-{
- SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
-
- asobject_class->mark = swfdec_text_format_do_mark;
-}
-
-static void
-swfdec_text_format_init (SwfdecTextFormat *text_format)
-{
-}
-
-static gboolean
-swfdec_text_format_is_set (const SwfdecTextFormat *format, FormatProp property)
-{
- return (format->values_set & (1 << property));
-}
-
-static void
-swfdec_text_format_mark_set (SwfdecTextFormat *format,
- FormatProp property)
-{
- format->values_set |= (1 << property);
-}
-
-static void
-swfdec_text_format_mark_unset (SwfdecTextFormat *format,
- FormatProp property)
-{
- format->values_set &= ~(1 << property);
-}
-
-static void
-swfdec_text_format_get_string (SwfdecAsObject *object,
- FormatProp property, SwfdecAsValue *ret)
-{
- SwfdecTextFormat *format;
-
- if (!SWFDEC_IS_TEXT_FORMAT (object))
- return;
- format = SWFDEC_TEXT_FORMAT (object);
-
- if (!swfdec_text_format_is_set (format, property)) {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- return;
- }
-
- SWFDEC_AS_VALUE_SET_STRING (ret,
- G_STRUCT_MEMBER (const char *, format, property_offsets[property]));
-}
-
-static void
-swfdec_text_format_set_string (SwfdecAsObject *object,
- FormatProp property, guint argc, SwfdecAsValue *argv)
-{
- SwfdecTextFormat *format;
- const char *s;
-
- if (!SWFDEC_IS_TEXT_FORMAT (object))
- return;
- format = SWFDEC_TEXT_FORMAT (object);
-
- if (argc < 1)
- return;
-
- swfdec_as_value_to_integer (object->context, &argv[0]);
- swfdec_as_value_to_number (object->context, &argv[0]);
- s = swfdec_as_value_to_string (object->context, &argv[0]);
-
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]) ||
- SWFDEC_AS_VALUE_IS_NULL (&argv[0])) {
- G_STRUCT_MEMBER (const char *, format, property_offsets[property]) = NULL;
- swfdec_text_format_mark_unset (format, property);
- } else {
- G_STRUCT_MEMBER (const char *, format, property_offsets[property]) = s;
- swfdec_text_format_mark_set (format, property);
- }
-}
-
-static void
-swfdec_text_format_get_boolean (SwfdecAsObject *object,
- FormatProp property, SwfdecAsValue *ret)
-{
- SwfdecTextFormat *format;
-
- if (!SWFDEC_IS_TEXT_FORMAT (object))
- return;
- format = SWFDEC_TEXT_FORMAT (object);
-
- if (!swfdec_text_format_is_set (format, property)) {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- return;
- }
-
- if (G_STRUCT_MEMBER (gboolean, format, property_offsets[property])) {
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, TRUE);
- } else {
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
- }
-}
-
-static void
-swfdec_text_format_set_boolean (SwfdecAsObject *object,
- FormatProp property, guint argc, SwfdecAsValue *argv)
-{
- SwfdecTextFormat *format;
-
- if (!SWFDEC_IS_TEXT_FORMAT (object))
- return;
- format = SWFDEC_TEXT_FORMAT (object);
-
- if (argc < 1)
- return;
-
- swfdec_as_value_to_integer (object->context, &argv[0]);
- swfdec_as_value_to_number (object->context, &argv[0]);
- swfdec_as_value_to_string (object->context, &argv[0]);
-
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]) ||
- SWFDEC_AS_VALUE_IS_NULL (&argv[0])) {
- swfdec_text_format_mark_unset (format, property);
- } else {
- G_STRUCT_MEMBER (gboolean, format, property_offsets[property]) =
- swfdec_as_value_to_boolean (object->context, &argv[0]);
- swfdec_text_format_mark_set (format, property);
- }
-}
-
-static void
-swfdec_text_format_get_integer (SwfdecAsObject *object,
- FormatProp property, SwfdecAsValue *ret)
-{
- SwfdecTextFormat *format;
-
- if (!SWFDEC_IS_TEXT_FORMAT (object))
- return;
- format = SWFDEC_TEXT_FORMAT (object);
-
- if (!swfdec_text_format_is_set (format, property)) {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- return;
- }
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret,
- (double)G_STRUCT_MEMBER (int, format, property_offsets[property]));
-}
-
-static int
-swfdec_text_format_value_to_integer (SwfdecAsContext *cx, SwfdecAsValue *val,
- gboolean allow_negative)
-{
- double d;
- int n;
-
- n = swfdec_as_value_to_integer (cx, val);
- d = swfdec_as_value_to_number (cx, val);
- swfdec_as_value_to_string (cx, val);
-
- if (cx->version >= 8) {
- if (isnan (d))
- return (allow_negative ? G_MININT32 : 0);
-
- if (!isfinite (d)) {
- if (d > 0) {
- return G_MININT32;
- } else {
- return (allow_negative ? G_MININT32 : 0);
- }
- }
- if (d > (double)G_MAXINT32)
- return G_MININT32;
-
- n = (int)d;
- if (!allow_negative && n < 0) {
- return 0;
- } else {
- return n;
- }
- } else {
- if (!allow_negative && n < 0) {
- return 0;
- } else {
- return n;
- }
- }
-}
-
-static void
-swfdec_text_format_set_integer (SwfdecAsObject *object,
- FormatProp property, guint argc, SwfdecAsValue *argv,
- gboolean allow_negative)
-{
- SwfdecTextFormat *format;
-
- if (!SWFDEC_IS_TEXT_FORMAT (object))
- return;
- format = SWFDEC_TEXT_FORMAT (object);
-
- if (argc < 1)
- return;
-
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]) ||
- SWFDEC_AS_VALUE_IS_NULL (&argv[0])) {
- swfdec_text_format_mark_unset (format, property);
- } else {
- G_STRUCT_MEMBER (int, format, property_offsets[property]) =
- swfdec_text_format_value_to_integer (object->context, &argv[0],
- allow_negative);
- swfdec_text_format_mark_set (format, property);
- }
-}
-
-static void
-swfdec_text_format_do_get_align (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecTextFormat *format;
-
- if (!SWFDEC_IS_TEXT_FORMAT (object))
- return;
- format = SWFDEC_TEXT_FORMAT (object);
-
- if (!swfdec_text_format_is_set (format, PROP_ALIGN)) {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- return;
- }
-
- switch (format->align) {
- case SWFDEC_TEXT_ALIGN_LEFT:
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_left);
- break;
- case SWFDEC_TEXT_ALIGN_RIGHT:
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_right);
- break;
- case SWFDEC_TEXT_ALIGN_CENTER:
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_center);
- break;
- case SWFDEC_TEXT_ALIGN_JUSTIFY:
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_justify);
- break;
- default:
- g_assert_not_reached ();
- }
-}
-
-static void
-swfdec_text_format_do_set_align (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecTextFormat *format;
- const char *s;
-
- if (!SWFDEC_IS_TEXT_FORMAT (object))
- return;
- format = SWFDEC_TEXT_FORMAT (object);
-
- if (argc < 1)
- return;
-
- swfdec_as_value_to_integer (cx, &argv[0]);
- swfdec_as_value_to_number (cx, &argv[0]);
- s = swfdec_as_value_to_string (cx, &argv[0]);
-
- if (!g_ascii_strcasecmp (s, "left")) {
- format->align = SWFDEC_TEXT_ALIGN_LEFT;
- swfdec_text_format_mark_set (format, PROP_ALIGN);
- } else if (!g_ascii_strcasecmp (s, "right")) {
- format->align = SWFDEC_TEXT_ALIGN_RIGHT;
- swfdec_text_format_mark_set (format, PROP_ALIGN);
- } else if (!g_ascii_strcasecmp (s, "center")) {
- format->align = SWFDEC_TEXT_ALIGN_CENTER;
- swfdec_text_format_mark_set (format, PROP_ALIGN);
- } else if (!g_ascii_strcasecmp (s, "justify")) {
- format->align = SWFDEC_TEXT_ALIGN_JUSTIFY;
- swfdec_text_format_mark_set (format, PROP_ALIGN);
- }
-}
-
-static void
-swfdec_text_format_do_get_block_indent (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- swfdec_text_format_get_integer (object, PROP_BLOCK_INDENT, ret);
-}
-
-static void
-swfdec_text_format_do_set_block_indent (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- swfdec_text_format_set_integer (object, PROP_BLOCK_INDENT, argc, argv,
- cx->version >= 8);
-}
-
-static void
-swfdec_text_format_do_get_bold (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_get_boolean (object, PROP_BOLD, ret);
-}
-
-static void
-swfdec_text_format_do_set_bold (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_set_boolean (object, PROP_BOLD, argc, argv);
-}
-
-static void
-swfdec_text_format_do_get_bullet (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_get_boolean (object, PROP_BULLET, ret);
-}
-
-static void
-swfdec_text_format_do_set_bullet (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_set_boolean (object, PROP_BULLET, argc, argv);
-}
-
-static void
-swfdec_text_format_do_get_color (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecTextFormat *format;
-
- if (!SWFDEC_IS_TEXT_FORMAT (object))
- return;
- format = SWFDEC_TEXT_FORMAT (object);
-
- if (!swfdec_text_format_is_set (format, PROP_COLOR)) {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- return;
- }
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret, format->color);
-}
-
-static void
-swfdec_text_format_do_set_color (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecTextFormat *format;
-
- if (!SWFDEC_IS_TEXT_FORMAT (object))
- return;
- format = SWFDEC_TEXT_FORMAT (object);
-
- if (argc < 1)
- return;
-
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]) ||
- SWFDEC_AS_VALUE_IS_NULL (&argv[0])) {
- swfdec_text_format_mark_unset (format, PROP_COLOR);
- } else {
- format->color = (unsigned) swfdec_as_value_to_integer (cx, &argv[0]);
- swfdec_as_value_to_integer (cx, &argv[0]);
- swfdec_as_value_to_string (cx, &argv[0]);
-
- swfdec_text_format_mark_set (format, PROP_COLOR);
- }
-}
-
-static void
-swfdec_text_format_do_get_display (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecTextFormat *format;
-
- if (!SWFDEC_IS_TEXT_FORMAT (object))
- return;
- format = SWFDEC_TEXT_FORMAT (object);
-
- if (!swfdec_text_format_is_set (format, PROP_DISPLAY))
- {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- return;
- }
-
- switch (format->display) {
- case SWFDEC_TEXT_DISPLAY_NONE:
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_none);
- break;
- case SWFDEC_TEXT_DISPLAY_INLINE:
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_inline);
- break;
- case SWFDEC_TEXT_DISPLAY_BLOCK:
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_block);
- break;
- default:
- g_assert_not_reached ();
- }
-}
-
-static void
-swfdec_text_format_do_set_display (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecTextFormat *format;
- const char *s;
-
- if (!SWFDEC_IS_TEXT_FORMAT (object))
- return;
- format = SWFDEC_TEXT_FORMAT (object);
-
- swfdec_as_value_to_integer (cx, &argv[0]);
- swfdec_as_value_to_number (cx, &argv[0]);
- swfdec_as_value_to_string (cx, &argv[0]);
- s = swfdec_as_value_to_string (cx, &argv[0]); // oh yes, let's call it twice
-
- if (!g_ascii_strcasecmp (s, "none")) {
- format->display = SWFDEC_TEXT_DISPLAY_NONE;
- } else if (!g_ascii_strcasecmp (s, "inline")) {
- format->display = SWFDEC_TEXT_DISPLAY_INLINE;
- } else {
- format->display = SWFDEC_TEXT_DISPLAY_BLOCK;
- }
-
- swfdec_text_format_mark_set (format, PROP_DISPLAY);
-}
-
-static void
-swfdec_text_format_do_get_font (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_get_string (object, PROP_FONT, ret);
-}
-
-static void
-swfdec_text_format_do_set_font (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_set_string (object, PROP_FONT, argc, argv);
-}
-
-static void
-swfdec_text_format_do_get_indent (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_get_integer (object, PROP_INDENT, ret);
-}
-
-static void
-swfdec_text_format_do_set_indent (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_set_integer (object, PROP_INDENT, argc, argv,
- cx->version >= 8);
-}
-
-static void
-swfdec_text_format_do_get_italic (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_get_boolean (object, PROP_ITALIC, ret);
-}
-
-static void
-swfdec_text_format_do_set_italic (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_set_boolean (object, PROP_ITALIC, argc, argv);
-}
-
-static void
-swfdec_text_format_do_get_kerning (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_get_boolean (object, PROP_KERNING, ret);
-}
-
-static void
-swfdec_text_format_do_set_kerning (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_set_boolean (object, PROP_KERNING, argc, argv);
-}
-
-static void
-swfdec_text_format_do_get_leading (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_get_integer (object, PROP_LEADING, ret);
-}
-
-static void
-swfdec_text_format_do_set_leading (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_set_integer (object, PROP_LEADING, argc, argv,
- cx->version >= 8);
-}
-
-static void
-swfdec_text_format_do_get_left_margin (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- swfdec_text_format_get_integer (object, PROP_LEFT_MARGIN, ret);
-}
-
-static void
-swfdec_text_format_do_set_left_margin (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- swfdec_text_format_set_integer (object, PROP_LEFT_MARGIN, argc, argv, FALSE);
-}
-
-static void
-swfdec_text_format_do_get_letter_spacing (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFormat *format;
-
- if (!SWFDEC_IS_TEXT_FORMAT (object))
- return;
- format = SWFDEC_TEXT_FORMAT (object);
-
- if (!swfdec_text_format_is_set (format, PROP_LETTER_SPACING)) {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- return;
- }
-
- SWFDEC_AS_VALUE_SET_NUMBER (ret, format->letter_spacing);
-}
-
-static void
-swfdec_text_format_do_set_letter_spacing (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFormat *format;
- double d;
-
- if (!SWFDEC_IS_TEXT_FORMAT (object))
- return;
- format = SWFDEC_TEXT_FORMAT (object);
-
- if (argc < 1)
- return;
-
- swfdec_as_value_to_integer (cx, &argv[0]);
- d = swfdec_as_value_to_number (cx, &argv[0]);
- swfdec_as_value_to_string (cx, &argv[0]);
-
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]) ||
- SWFDEC_AS_VALUE_IS_NULL (&argv[0]))
- {
- swfdec_text_format_mark_unset (format,
- PROP_LETTER_SPACING);
- }
- else
- {
- format->letter_spacing = d;
- swfdec_text_format_mark_set (format,
- PROP_LETTER_SPACING);
- }
-}
-
-static void
-swfdec_text_format_do_get_right_margin (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- swfdec_text_format_get_integer (object, PROP_RIGHT_MARGIN, ret);
-}
-
-static void
-swfdec_text_format_do_set_right_margin (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- swfdec_text_format_set_integer (object, PROP_RIGHT_MARGIN, argc, argv,
- FALSE);
-}
-
-static void
-swfdec_text_format_do_get_size (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_get_integer (object, PROP_SIZE, ret);
-}
-
-static void
-swfdec_text_format_do_set_size (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_set_integer (object, PROP_SIZE, argc, argv, TRUE);
-}
-
-static void
-swfdec_text_format_do_get_tab_stops (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFormat *format;
-
- if (!SWFDEC_IS_TEXT_FORMAT (object))
- return;
- format = SWFDEC_TEXT_FORMAT (object);
-
- if (!swfdec_text_format_is_set (format, PROP_TAB_STOPS)) {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- return;
- }
-
- g_return_if_fail (SWFDEC_IS_AS_OBJECT (format->tab_stops));
- SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (format->tab_stops));
-}
-
-static void
-swfdec_text_format_do_set_tab_stops (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SwfdecTextFormat *format;
-
- if (!SWFDEC_IS_TEXT_FORMAT (object))
- return;
- format = SWFDEC_TEXT_FORMAT (object);
-
- if (argc < 1)
- return;
-
- swfdec_as_value_to_integer (cx, &argv[0]);
- swfdec_as_value_to_number (cx, &argv[0]);
- swfdec_as_value_to_string (cx, &argv[0]);
-
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]) ||
- SWFDEC_AS_VALUE_IS_NULL (&argv[0]))
- {
- format->tab_stops = NULL;
- swfdec_text_format_mark_unset (format, PROP_TAB_STOPS);
- }
- else if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]) &&
- SWFDEC_IS_AS_ARRAY (SWFDEC_AS_VALUE_GET_OBJECT (&argv[0])))
- {
- SwfdecAsArray *array;
- SwfdecAsValue val;
- gint32 len, i;
- int n;
-
- array = SWFDEC_AS_ARRAY (SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]));
- len = swfdec_as_array_get_length (array);
-
- if (!swfdec_text_format_is_set (format, PROP_TAB_STOPS)) {
- // special case, if we have null and array is empty, keep it at null
- if (len == 0)
- return;
- format->tab_stops = SWFDEC_AS_ARRAY (swfdec_as_array_new (cx));
- if (!format->tab_stops)
- return;
- swfdec_text_format_mark_set (format, PROP_TAB_STOPS);
- }
-
- swfdec_as_array_set_length (format->tab_stops, 0);
- for (i = 0; i < len; i++) {
- swfdec_as_array_get_value (array, i, &val);
- n = swfdec_text_format_value_to_integer (cx, &val, TRUE);
- SWFDEC_AS_VALUE_SET_INT (&val, n);
- swfdec_as_array_set_value (format->tab_stops, i, &val);
- }
- }
- else if (SWFDEC_AS_VALUE_IS_STRING (&argv[0]))
- {
- gsize i, len;
- SwfdecAsValue val;
-
- len = strlen (SWFDEC_AS_VALUE_GET_STRING (&argv[0]));
-
- // special case: empty strings mean null
- if (len == 0) {
- format->tab_stops = NULL;
- swfdec_text_format_mark_unset (format,
- PROP_TAB_STOPS);
- } else {
- format->tab_stops = SWFDEC_AS_ARRAY (swfdec_as_array_new (cx));
- if (format->tab_stops != NULL) {
- swfdec_text_format_mark_set (format, PROP_TAB_STOPS);
- if (cx->version >= 8) {
- SWFDEC_AS_VALUE_SET_INT (&val, -2147483648);
- } else {
- SWFDEC_AS_VALUE_SET_INT (&val, 0);
- }
- for (i = 0; i < len; i++) {
- swfdec_as_array_push (format->tab_stops, &val);
- }
- } else {
- swfdec_text_format_mark_unset (format, PROP_TAB_STOPS);
- }
- }
- }
- else if (swfdec_text_format_is_set (format, PROP_TAB_STOPS))
- {
- swfdec_as_array_set_length (format->tab_stops, 0);
- swfdec_text_format_mark_set (format, PROP_TAB_STOPS);
- }
-}
-
-static void
-swfdec_text_format_do_get_target (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_get_string (object, PROP_TARGET, ret);
-}
-
-static void
-swfdec_text_format_do_set_target (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_set_string (object, PROP_TARGET, argc, argv);
-}
-
-static void
-swfdec_text_format_do_get_underline (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- swfdec_text_format_get_boolean (object, PROP_UNDERLINE, ret);
-}
-
-static void
-swfdec_text_format_do_set_underline (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- swfdec_text_format_set_boolean (object, PROP_UNDERLINE, argc, argv);
-}
-
-static void
-swfdec_text_format_do_get_url (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_get_string (object, PROP_URL, ret);
-}
-
-static void
-swfdec_text_format_do_set_url (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- swfdec_text_format_set_string (object, PROP_URL, argc, argv);
-}
-
-static void
-swfdec_text_format_getTextExtent (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextFormat.getTextExtent");
-}
-
-void
-swfdec_text_format_add (SwfdecTextFormat *format, const SwfdecTextFormat *from)
-{
- g_return_if_fail (SWFDEC_IS_TEXT_FORMAT (format));
- g_return_if_fail (SWFDEC_IS_TEXT_FORMAT (from));
-
- if (swfdec_text_format_is_set (from, PROP_ALIGN))
- format->align = from->align;
- if (swfdec_text_format_is_set (from, PROP_BLOCK_INDENT))
- format->block_indent = from->block_indent;
- if (swfdec_text_format_is_set (from, PROP_BOLD))
- format->bold = from->bold;
- if (swfdec_text_format_is_set (from, PROP_BULLET))
- format->bullet = from->bullet;
- if (swfdec_text_format_is_set (from, PROP_COLOR))
- format->color = from->color;
- if (swfdec_text_format_is_set (from, PROP_DISPLAY))
- format->display = from->display;
- if (swfdec_text_format_is_set (from, PROP_FONT))
- format->font = from->font;
- if (swfdec_text_format_is_set (from, PROP_INDENT))
- format->indent = from->indent;
- if (swfdec_text_format_is_set (from, PROP_ITALIC))
- format->italic = from->italic ;
- if (swfdec_text_format_is_set (from, PROP_KERNING))
- format->kerning = from->kerning;
- if (swfdec_text_format_is_set (from, PROP_LEADING))
- format->leading = from->leading;
- if (swfdec_text_format_is_set (from, PROP_LEFT_MARGIN))
- format->left_margin = from->left_margin;
- if (swfdec_text_format_is_set (from, PROP_LETTER_SPACING))
- format->letter_spacing = from->letter_spacing;
- if (swfdec_text_format_is_set (from, PROP_RIGHT_MARGIN))
- format->right_margin = from->right_margin;
- if (swfdec_text_format_is_set (from, PROP_SIZE))
- format->size = from->size;
- if (swfdec_text_format_is_set (from, PROP_TAB_STOPS))
- format->tab_stops = from->tab_stops;
- if (swfdec_text_format_is_set (from, PROP_TARGET))
- format->target = from->target;
- if (swfdec_text_format_is_set (from, PROP_UNDERLINE))
- format->underline = from->underline;
- if (swfdec_text_format_is_set (from, PROP_URL))
- format->url = from->url;
-
- format->values_set |= from->values_set;
-}
-
-void
-swfdec_text_format_remove_different (SwfdecTextFormat *format,
- const SwfdecTextFormat *from)
-{
- int set;
-
- g_return_if_fail (SWFDEC_IS_TEXT_FORMAT (format));
- g_return_if_fail (SWFDEC_IS_TEXT_FORMAT (from));
-
- set = format->values_set & from->values_set;
-
- if (set & (1 << PROP_ALIGN) && format->align != from->align)
- set &= ~(1 << PROP_ALIGN);
- if (set & (1 << PROP_BLOCK_INDENT) &&
- format->block_indent != from->block_indent) {
- set &= ~(1 << PROP_BLOCK_INDENT);
- }
- if (set & (1 << PROP_BOLD) && format->bold != from->bold)
- set &= ~(1 << PROP_BOLD);
- if (set & (1 << PROP_BULLET) && format->bullet != from->bullet)
- set &= ~(1 << PROP_BULLET);
- if (set & (1 << PROP_COLOR) && format->color != from->color)
- set &= ~(1 << PROP_COLOR);
- if (set & (1 << PROP_DISPLAY) && format->display != from->display)
- set &= ~(1 << PROP_DISPLAY);
- if (set & (1 << PROP_FONT) && format->font != from->font)
- set &= ~(1 << PROP_FONT);
- if (set & (1 << PROP_INDENT) && format->indent != from->indent)
- set &= ~(1 << PROP_INDENT);
- if (set & (1 << PROP_ITALIC) && format->italic != from->italic)
- set &= ~(1 << PROP_ITALIC);
- if (set & (1 << PROP_KERNING) && format->kerning != from->kerning)
- set &= ~(1 << PROP_KERNING);
- if (set & (1 << PROP_LEADING) && format->leading != from->leading)
- set &= ~(1 << PROP_LEADING);
- if (set & (1 << PROP_LEFT_MARGIN) &&
- format->left_margin != from->left_margin) {
- set &= ~(1 << PROP_LEFT_MARGIN);
- }
- if (set & (1 << PROP_LETTER_SPACING) &&
- format->letter_spacing != from->letter_spacing) {
- set &= ~(1 << PROP_LETTER_SPACING);
- }
- if (set & (1 << PROP_RIGHT_MARGIN) &&
- format->right_margin != from->right_margin) {
- set &= ~(1 << PROP_RIGHT_MARGIN);
- }
- if (set & (1 << PROP_SIZE) && format->size != from->size)
- set &= ~(1 << PROP_SIZE);
- if (set & (1 << PROP_TAB_STOPS) && format->tab_stops != from->tab_stops)
- set &= ~(1 << PROP_TAB_STOPS);
- if (set & (1 << PROP_TARGET) && format->target != from->target)
- set &= ~(1 << PROP_TARGET);
- if (set & (1 << PROP_UNDERLINE) && format->underline != from->underline)
- set &= ~(1 << PROP_UNDERLINE);
- if (set & (1 << PROP_URL) && format->url != from->url)
- set &= ~(1 << PROP_URL);
-
- format->values_set = set;
-}
-
-gboolean
-swfdec_text_format_equal_or_undefined (const SwfdecTextFormat *a,
- const SwfdecTextFormat *b)
-{
- int set;
-
- set = a->values_set & b->values_set;
-
- g_return_val_if_fail (SWFDEC_IS_TEXT_FORMAT (a), FALSE);
- g_return_val_if_fail (SWFDEC_IS_TEXT_FORMAT (b), FALSE);
-
- if (set & (1 << PROP_ALIGN) && a->align != b->align)
- return FALSE;
- if (set & (1 << PROP_BLOCK_INDENT) && a->block_indent != b->block_indent)
- return FALSE;
- if (set & (1 << PROP_BOLD) && a->bold != b->bold)
- return FALSE;
- if (set & (1 << PROP_BULLET) && a->bullet != b->bullet)
- return FALSE;
- if (set & (1 << PROP_COLOR) && a->color != b->color)
- return FALSE;
- if (set & (1 << PROP_DISPLAY) && a->display != b->display)
- return FALSE;
- if (set & (1 << PROP_FONT) && a->font != b->font)
- return FALSE;
- if (set & (1 << PROP_INDENT) && a->indent != b->indent)
- return FALSE;
- if (set & (1 << PROP_ITALIC) && a->italic != b->italic)
- return FALSE;
- if (set & (1 << PROP_KERNING) && a->kerning != b->kerning)
- return FALSE;
- if (set & (1 << PROP_LEADING) && a->leading != b->leading)
- return FALSE;
- if (set & (1 << PROP_LEFT_MARGIN) && a->left_margin != b->left_margin)
- return FALSE;
- if (set & (1 << PROP_LETTER_SPACING) &&
- a->letter_spacing != b->letter_spacing) {
- return FALSE;
- }
- if (set & (1 << PROP_RIGHT_MARGIN) && a->right_margin != b->right_margin)
- return FALSE;
- if (set & (1 << PROP_SIZE) && a->size != b->size)
- return FALSE;
- if (set & (1 << PROP_TAB_STOPS) && a->tab_stops != b->tab_stops)
- return FALSE;
- if (set & (1 << PROP_TARGET) && a->target != b->target)
- return FALSE;
- if (set & (1 << PROP_UNDERLINE) && a->underline != b->underline)
- return FALSE;
- if (set & (1 << PROP_URL) && a->url != b->url)
- return FALSE;
-
- return TRUE;
-}
-
-gboolean
-swfdec_text_format_equal (const SwfdecTextFormat *a, const SwfdecTextFormat *b)
-{
- g_return_val_if_fail (SWFDEC_IS_TEXT_FORMAT (a), FALSE);
- g_return_val_if_fail (SWFDEC_IS_TEXT_FORMAT (b), FALSE);
-
- if (a->values_set != b->values_set)
- return FALSE;
-
- return swfdec_text_format_equal_or_undefined (a, b);
-}
-
-void
-swfdec_text_format_set_defaults (SwfdecTextFormat *format)
-{
- format->align = SWFDEC_TEXT_ALIGN_LEFT;
- format->block_indent = 0;
- format->bold = FALSE;
- format->bullet = FALSE;
- format->color = 0;
- format->display = SWFDEC_TEXT_DISPLAY_BLOCK;
- format->font = SWFDEC_AS_STR_Times_New_Roman;
- format->indent = 0;
- format->italic = FALSE;
- format->kerning = FALSE;
- format->leading = 0;
- format->left_margin = 0;
- format->letter_spacing = 0;
- format->right_margin = 0;
- format->size = 12;
- format->tab_stops =
- SWFDEC_AS_ARRAY (swfdec_as_array_new (SWFDEC_AS_OBJECT (format)->context));
- format->target = SWFDEC_AS_STR_EMPTY;
- format->url = SWFDEC_AS_STR_EMPTY;
- format->underline = FALSE;
-
- format->values_set = (1 << PROP_TOTAL) - 1;
-
- if (SWFDEC_AS_OBJECT (format)->context->version < 8) {
- swfdec_text_format_mark_unset (format, PROP_KERNING);
- swfdec_text_format_mark_unset (format, PROP_LETTER_SPACING);
- }
-}
-
-static void
-swfdec_text_format_clear (SwfdecTextFormat *format)
-{
- format->font = NULL;
- format->target = NULL;
- format->tab_stops = NULL;
- format->url = NULL;
- format->values_set = 0;
-
- format->display = SWFDEC_TEXT_DISPLAY_BLOCK;
- swfdec_text_format_mark_set (format, PROP_DISPLAY);
-}
-
-void
-swfdec_text_format_init_properties (SwfdecAsContext *cx)
-{
- SwfdecAsValue val;
- SwfdecAsObject *proto;
-
- // FIXME: We should only initialize if the prototype Object has not been
- // initialized by any object's constructor with native properties
- // (TextField, TextFormat, XML, XMLNode at least)
-
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (cx));
-
- swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_TextFormat, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return;
- proto = SWFDEC_AS_VALUE_GET_OBJECT (&val);
- swfdec_as_object_get_variable (proto, SWFDEC_AS_STR_prototype, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return;
- proto = SWFDEC_AS_VALUE_GET_OBJECT (&val);
-
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_align,
- swfdec_text_format_do_get_align, swfdec_text_format_do_set_align);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_blockIndent,
- swfdec_text_format_do_get_block_indent,
- swfdec_text_format_do_set_block_indent);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_bold,
- swfdec_text_format_do_get_bold, swfdec_text_format_do_set_bold);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_bullet,
- swfdec_text_format_do_get_bullet, swfdec_text_format_do_set_bullet);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_color,
- swfdec_text_format_do_get_color, swfdec_text_format_do_set_color);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_display,
- swfdec_text_format_do_get_display, swfdec_text_format_do_set_display);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_font,
- swfdec_text_format_do_get_font, swfdec_text_format_do_set_font);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_indent,
- swfdec_text_format_do_get_indent, swfdec_text_format_do_set_indent);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_italic,
- swfdec_text_format_do_get_italic, swfdec_text_format_do_set_italic);
- if (cx->version >= 8) {
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_kerning,
- swfdec_text_format_do_get_kerning, swfdec_text_format_do_set_kerning);
- }
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_leading,
- swfdec_text_format_do_get_leading, swfdec_text_format_do_set_leading);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_leftMargin,
- swfdec_text_format_do_get_left_margin,
- swfdec_text_format_do_set_left_margin);
- if (cx->version >= 8) {
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_letterSpacing,
- swfdec_text_format_do_get_letter_spacing,
- swfdec_text_format_do_set_letter_spacing);
- }
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_rightMargin,
- swfdec_text_format_do_get_right_margin,
- swfdec_text_format_do_set_right_margin);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_size,
- swfdec_text_format_do_get_size, swfdec_text_format_do_set_size);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_tabStops,
- swfdec_text_format_do_get_tab_stops,
- swfdec_text_format_do_set_tab_stops);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_target,
- swfdec_text_format_do_get_target, swfdec_text_format_do_set_target);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_underline,
- swfdec_text_format_do_get_underline,
- swfdec_text_format_do_set_underline);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_url,
- swfdec_text_format_do_get_url, swfdec_text_format_do_set_url);
-}
-
-SWFDEC_AS_CONSTRUCTOR (110, 0, swfdec_text_format_construct, swfdec_text_format_get_type)
-void
-swfdec_text_format_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- static const char *arguments[] = {
- SWFDEC_AS_STR_font,
- SWFDEC_AS_STR_size,
- SWFDEC_AS_STR_color,
- SWFDEC_AS_STR_bold,
- SWFDEC_AS_STR_italic,
- SWFDEC_AS_STR_underline,
- SWFDEC_AS_STR_url,
- SWFDEC_AS_STR_target,
- SWFDEC_AS_STR_align,
- SWFDEC_AS_STR_leftMargin,
- SWFDEC_AS_STR_rightMargin,
- SWFDEC_AS_STR_indent,
- SWFDEC_AS_STR_leading,
- NULL
- };
- SwfdecAsFunction *function;
- SwfdecAsObject *tmp;
- SwfdecAsValue val;
- guint i;
-
- if (!swfdec_as_context_is_constructing (cx)) {
- SWFDEC_FIXME ("What do we do if not constructing?");
- return;
- }
-
- g_assert (SWFDEC_IS_TEXT_FORMAT (object));
-
- swfdec_text_format_init_properties (cx);
-
- swfdec_text_format_clear (SWFDEC_TEXT_FORMAT (object));
-
- // FIXME: Need better way to create function without prototype/constructor
- tmp = cx->Function;
- cx->Function = NULL;
- function = swfdec_as_native_function_new (cx, SWFDEC_AS_STR_getTextExtent,
- swfdec_text_format_getTextExtent, 0, NULL);
- cx->Function = tmp;
- if (function != NULL) {
- SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (function));
- swfdec_as_object_set_variable (object, SWFDEC_AS_STR_getTextExtent, &val);
- }
-
- for (i = 0; i < argc && arguments[i] != NULL; i++) {
- swfdec_as_object_set_variable (object, arguments[i], &argv[i]);
- }
-}
-
-SwfdecTextFormat *
-swfdec_text_format_copy (const SwfdecTextFormat *copy_from)
-{
- SwfdecAsObject *object_to;
- SwfdecTextFormat *copy_to;
-
- g_return_val_if_fail (SWFDEC_IS_TEXT_FORMAT (copy_from), NULL);
-
- object_to = swfdec_text_format_new_no_properties (
- SWFDEC_AS_OBJECT (copy_from)->context);
- if (object_to == NULL)
- return NULL;
- copy_to = SWFDEC_TEXT_FORMAT (object_to);
-
- copy_to->align = copy_from->align;
- copy_to->block_indent = copy_from->block_indent;
- copy_to->bold = copy_from->bold;
- copy_to->bullet = copy_from->bullet;
- copy_to->color = copy_from->color;
- copy_to->display = copy_from->display;
- copy_to->font = copy_from->font;
- copy_to->indent = copy_from->indent;
- copy_to->italic = copy_from->italic ;
- copy_to->kerning = copy_from->kerning;
- copy_to->leading = copy_from->leading;
- copy_to->left_margin = copy_from->left_margin;
- copy_to->letter_spacing = copy_from->letter_spacing;
- copy_to->right_margin = copy_from->right_margin;
- copy_to->size = copy_from->size;
- copy_to->tab_stops = copy_from->tab_stops;
- copy_to->target = copy_from->target;
- copy_to->underline = copy_from->underline;
- copy_to->url = copy_from->url;
- copy_to->values_set = copy_from->values_set;
-
- return copy_to;
-}
-
-SwfdecAsObject *
-swfdec_text_format_new_no_properties (SwfdecAsContext *context)
-{
- SwfdecAsObject *ret;
- SwfdecAsValue val;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
-
- if (!swfdec_as_context_use_mem (context, sizeof (SwfdecTextFormat)))
- return NULL;
-
- ret = g_object_new (SWFDEC_TYPE_TEXT_FORMAT, NULL);
- swfdec_as_object_add (ret, context, sizeof (SwfdecTextFormat));
-
- swfdec_text_format_clear (SWFDEC_TEXT_FORMAT (ret));
-
- swfdec_as_object_get_variable (context->global, SWFDEC_AS_STR_TextFormat,
- &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return ret;
- swfdec_as_object_set_constructor (ret, SWFDEC_AS_VALUE_GET_OBJECT (&val));
-
- return ret;
-}
-
-SwfdecAsObject *
-swfdec_text_format_new (SwfdecAsContext *context)
-{
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
-
- swfdec_text_format_init_properties (context);
-
- return swfdec_text_format_new_no_properties (context);
-}
diff --git a/libswfdec/swfdec_text_format.h b/libswfdec/swfdec_text_format.h
deleted file mode 100644
index 77dddb4..0000000
--- a/libswfdec/swfdec_text_format.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_TEXT_FORMAT_H_
-#define _SWFDEC_TEXT_FORMAT_H_
-
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_as_array.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_script.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecTextFormat SwfdecTextFormat;
-typedef struct _SwfdecTextFormatClass SwfdecTextFormatClass;
-
-#define SWFDEC_TYPE_TEXT_FORMAT (swfdec_text_format_get_type())
-#define SWFDEC_IS_TEXT_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_TEXT_FORMAT))
-#define SWFDEC_IS_TEXT_FORMAT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_TEXT_FORMAT))
-#define SWFDEC_TEXT_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_TEXT_FORMAT, SwfdecTextFormat))
-#define SWFDEC_TEXT_FORMAT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_TEXT_FORMAT, SwfdecTextFormatClass))
-#define SWFDEC_TEXT_FORMAT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_TEXT_FORMAT, SwfdecTextFormatClass))
-
-typedef enum {
- SWFDEC_TEXT_ALIGN_LEFT,
- SWFDEC_TEXT_ALIGN_RIGHT,
- SWFDEC_TEXT_ALIGN_CENTER,
- SWFDEC_TEXT_ALIGN_JUSTIFY
-} SwfdecTextAlign;
-
-typedef enum {
- SWFDEC_TEXT_DISPLAY_NONE,
- SWFDEC_TEXT_DISPLAY_INLINE,
- SWFDEC_TEXT_DISPLAY_BLOCK,
-} SwfdecTextDisplay;
-
-struct _SwfdecTextFormat {
- SwfdecAsObject object;
-
- SwfdecTextAlign align;
- int block_indent;
- gboolean bold;
- gboolean bullet;
- SwfdecColor color;
- SwfdecTextDisplay display;
- const char * font;
- int indent;
- gboolean italic;
- gboolean kerning;
- int leading;
- int left_margin;
- double letter_spacing; // number or null
- int right_margin;
- int size;
- SwfdecAsArray * tab_stops;
- const char * target;
- gboolean underline;
- const char * url;
-
- int values_set;
-};
-
-struct _SwfdecTextFormatClass {
- SwfdecAsObjectClass object_class;
-};
-
-GType swfdec_text_format_get_type (void);
-
-SwfdecAsObject * swfdec_text_format_new (SwfdecAsContext * context);
-SwfdecAsObject * swfdec_text_format_new_no_properties (SwfdecAsContext * context);
-void swfdec_text_format_set_defaults (SwfdecTextFormat * format);
-SwfdecTextFormat * swfdec_text_format_copy (const SwfdecTextFormat *copy_from);
-void swfdec_text_format_add (SwfdecTextFormat * format,
- const SwfdecTextFormat *from);
-gboolean swfdec_text_format_equal (const SwfdecTextFormat *a,
- const SwfdecTextFormat *b);
-gboolean swfdec_text_format_equal_or_undefined (const SwfdecTextFormat *a,
- const SwfdecTextFormat *b);
-void swfdec_text_format_remove_different (SwfdecTextFormat * format,
- const SwfdecTextFormat * from);
-void swfdec_text_format_init_properties (SwfdecAsContext * cx);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_text_renderer.c b/libswfdec/swfdec_text_renderer.c
deleted file mode 100644
index 4a709b5..0000000
--- a/libswfdec/swfdec_text_renderer.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (2150, 1, swfdec_text_renderer_setAdvancedAntialiasingTable)
-void
-swfdec_text_renderer_setAdvancedAntialiasingTable (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextRenderer.setAdvancedAntialiasingTable (static)");
-}
-
-SWFDEC_AS_NATIVE (2150, 2, swfdec_text_renderer_get_antiAliasType)
-void
-swfdec_text_renderer_get_antiAliasType (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextRenderer.antiAliasType (static, get, not-really-named)");
-}
-
-SWFDEC_AS_NATIVE (2150, 3, swfdec_text_renderer_set_antiAliasType)
-void
-swfdec_text_renderer_set_antiAliasType (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextRenderer.antiAliasType (static, set, not-really-named)");
-}
-
-SWFDEC_AS_NATIVE (2150, 4, swfdec_text_renderer_get_maxLevel)
-void
-swfdec_text_renderer_get_maxLevel (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextRenderer.maxLevel (static, get)");
-}
-
-SWFDEC_AS_NATIVE (2150, 5, swfdec_text_renderer_set_maxLevel)
-void
-swfdec_text_renderer_set_maxLevel (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextRenderer.maxLevel (static, set)");
-}
-
-SWFDEC_AS_NATIVE (2150, 10, swfdec_text_renderer_get_displayMode)
-void
-swfdec_text_renderer_get_displayMode (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextRenderer.displayMode (static, get)");
-}
-
-SWFDEC_AS_NATIVE (2150, 11, swfdec_text_renderer_set_displayMode)
-void
-swfdec_text_renderer_set_displayMode (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextRenderer.displayMode (static, set)");
-}
-
-SWFDEC_AS_NATIVE (2150, 0, swfdec_text_renderer_construct)
-void
-swfdec_text_renderer_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextRenderer");
-}
diff --git a/libswfdec/swfdec_text_snapshot.c b/libswfdec/swfdec_text_snapshot.c
deleted file mode 100644
index 4eae6a4..0000000
--- a/libswfdec/swfdec_text_snapshot.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-SWFDEC_AS_NATIVE (1067, 1, swfdec_text_snapshot_getCount)
-void
-swfdec_text_snapshot_getCount (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextSnapshot.getCount");
-}
-
-SWFDEC_AS_NATIVE (1067, 2, swfdec_text_snapshot_setSelected)
-void
-swfdec_text_snapshot_setSelected (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextSnapshot.setSelected");
-}
-
-SWFDEC_AS_NATIVE (1067, 3, swfdec_text_snapshot_getSelected)
-void
-swfdec_text_snapshot_getSelected (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextSnapshot.getSelected");
-}
-
-SWFDEC_AS_NATIVE (1067, 4, swfdec_text_snapshot_getText)
-void
-swfdec_text_snapshot_getText (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextSnapshot.getText");
-}
-
-SWFDEC_AS_NATIVE (1067, 5, swfdec_text_snapshot_getSelectedText)
-void
-swfdec_text_snapshot_getSelectedText (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextSnapshot.getSelectedText");
-}
-
-SWFDEC_AS_NATIVE (1067, 6, swfdec_text_snapshot_hitTestTextNearPos)
-void
-swfdec_text_snapshot_hitTestTextNearPos (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextSnapshot.hitTestTextNearPos");
-}
-
-SWFDEC_AS_NATIVE (1067, 7, swfdec_text_snapshot_findText)
-void
-swfdec_text_snapshot_findText (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextSnapshot.findText");
-}
-
-SWFDEC_AS_NATIVE (1067, 8, swfdec_text_snapshot_setSelectColor)
-void
-swfdec_text_snapshot_setSelectColor (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextSnapshot.setSelectColor");
-}
-
-SWFDEC_AS_NATIVE (1067, 9, swfdec_text_snapshot_getTextRunInfo)
-void
-swfdec_text_snapshot_getTextRunInfo (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextSnapshot.getTextRunInfo");
-}
-
-SWFDEC_AS_NATIVE (1067, 0, swfdec_text_snapshot_construct)
-void
-swfdec_text_snapshot_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("TextSnapshot");
-}
diff --git a/libswfdec/swfdec_transform.c b/libswfdec/swfdec_transform.c
deleted file mode 100644
index 87fa99e..0000000
--- a/libswfdec/swfdec_transform.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_as_internal.h"
-#include "swfdec_debug.h"
-
-// properties
-SWFDEC_AS_NATIVE (1106, 101, swfdec_transform_get_matrix)
-void
-swfdec_transform_get_matrix (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Transform.matrix (get)");
-}
-
-SWFDEC_AS_NATIVE (1106, 102, swfdec_transform_set_matrix)
-void
-swfdec_transform_set_matrix (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Transform.matrix (set)");
-}
-
-SWFDEC_AS_NATIVE (1106, 103, swfdec_transform_get_concatenatedMatrix)
-void
-swfdec_transform_get_concatenatedMatrix (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Transform.concatenatedMatrix (get)");
-}
-
-SWFDEC_AS_NATIVE (1106, 104, swfdec_transform_set_concatenatedMatrix)
-void
-swfdec_transform_set_concatenatedMatrix (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Transform.concatenatedMatrix (set)");
-}
-
-SWFDEC_AS_NATIVE (1106, 105, swfdec_transform_get_colorTransform)
-void
-swfdec_transform_get_colorTransform (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Transform.colorTransform (get)");
-}
-
-SWFDEC_AS_NATIVE (1106, 106, swfdec_transform_set_colorTransform)
-void
-swfdec_transform_set_colorTransform (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Transform.colorTransform (set)");
-}
-
-SWFDEC_AS_NATIVE (1106, 107, swfdec_transform_get_concatenatedColorTransform)
-void
-swfdec_transform_get_concatenatedColorTransform (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Transform.concatenatedColorTransform (get)");
-}
-
-SWFDEC_AS_NATIVE (1106, 108, swfdec_transform_set_concatenatedColorTransform)
-void
-swfdec_transform_set_concatenatedColorTransform (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
- SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Transform.concatenatedColorTransform (set)");
-}
-
-SWFDEC_AS_NATIVE (1106, 109, swfdec_transform_get_pixelBounds)
-void
-swfdec_transform_get_pixelBounds (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Transform.pixelBounds (get)");
-}
-
-SWFDEC_AS_NATIVE (1106, 110, swfdec_transform_set_pixelBounds)
-void
-swfdec_transform_set_pixelBounds (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Transform.pixelBounds (set)");
-}
-
-// constructor
-SWFDEC_AS_NATIVE (1106, 0, swfdec_transform_construct)
-void
-swfdec_transform_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("Transform");
-}
diff --git a/libswfdec/swfdec_types.h b/libswfdec/swfdec_types.h
deleted file mode 100644
index d484396..0000000
--- a/libswfdec/swfdec_types.h
+++ /dev/null
@@ -1,63 +0,0 @@
-
-#ifndef _SWFDEC_TYPES_H_
-#define _SWFDEC_TYPES_H_
-
-#include <glib-object.h>
-#include <cairo.h>
-
-/* Pixel value in the same colorspace as cairo - endian-dependant ARGB.
- * The alpha pixel must be present */
-typedef guint SwfdecColor;
-
-/* audio is 44100Hz, framerate is multiple of 256Hz, FLV timestamps are 1000Hz
- * This is a multiple of all these numbers, so we can be always accurate
- */
-#define SWFDEC_TICKS_PER_SECOND G_GUINT64_CONSTANT (44100 * 256 * 10)
-typedef guint64 SwfdecTick;
-#define SWFDEC_MSECS_TO_TICKS(msecs) ((SwfdecTick) (msecs) * (SWFDEC_TICKS_PER_SECOND / 1000))
-#define SWFDEC_TICKS_TO_MSECS(ticks) ((ticks) / (SWFDEC_TICKS_PER_SECOND / 1000))
-#define SWFDEC_SAMPLES_TO_TICKS(msecs) ((SwfdecTick) (msecs) * (SWFDEC_TICKS_PER_SECOND / 44100))
-#define SWFDEC_TICKS_TO_SAMPLES(ticks) ((ticks) / (SWFDEC_TICKS_PER_SECOND / 44100))
-
-#define SWFDEC_TWIPS_SCALE_FACTOR 20
-typedef int SwfdecTwips;
-#define SWFDEC_TWIPS_TO_DOUBLE(t) ((t) * (1.0 / SWFDEC_TWIPS_SCALE_FACTOR))
-#define SWFDEC_DOUBLE_TO_TWIPS(d) ((SwfdecTwips)((d) * SWFDEC_TWIPS_SCALE_FACTOR))
-
-#define SWFDEC_FIXED_SCALE_FACTOR 65536
-typedef int SwfdecFixed;
-#define SWFDEC_FIXED_TO_DOUBLE(f) ((f) * (1.0 / SWFDEC_FIXED_SCALE_FACTOR))
-#define SWFDEC_DOUBLE_TO_FIXED(d) ((SwfdecFixed)((d) * SWFDEC_FIXED_SCALE_FACTOR))
-#define SWFDEC_FIXED_TO_INT(f) ((f) / SWFDEC_FIXED_SCALE_FACTOR)
-#define SWFDEC_INT_TO_FIXED(i) ((i) * SWFDEC_FIXED_SCALE_FACTOR)
-
-typedef struct _SwfdecButton SwfdecButton;
-typedef struct _SwfdecCache SwfdecCache;
-typedef struct _SwfdecCacheHandle SwfdecCacheHandle;
-typedef struct _SwfdecCharacter SwfdecCharacter;
-typedef struct _SwfdecColorTransform SwfdecColorTransform;
-typedef struct _SwfdecDecoder SwfdecDecoder;
-typedef struct _SwfdecDraw SwfdecDraw;
-typedef struct _SwfdecEventList SwfdecEventList;
-typedef struct _SwfdecFilter SwfdecFilter;
-typedef struct _SwfdecFont SwfdecFont;
-typedef struct _SwfdecGraphic SwfdecGraphic;
-typedef struct _SwfdecImage SwfdecImage;
-typedef struct _SwfdecListener SwfdecListener;
-typedef struct _SwfdecMovie SwfdecMovie;
-typedef struct _SwfdecMovieClipLoader SwfdecMovieClipLoader;
-typedef struct _SwfdecShape SwfdecShape;
-typedef struct _SwfdecShapeVec SwfdecShapeVec;
-typedef struct _SwfdecRect SwfdecRect;
-typedef struct _SwfdecResource SwfdecResource;
-typedef struct _SwfdecRootSprite SwfdecRootSprite;
-typedef struct _SwfdecScriptable SwfdecScriptable;
-typedef struct _SwfdecSound SwfdecSound;
-typedef struct _SwfdecSoundChunk SwfdecSoundChunk;
-typedef struct _SwfdecSprite SwfdecSprite;
-typedef struct _SwfdecSpriteFrame SwfdecSpriteFrame;
-typedef struct _SwfdecSpriteMovie SwfdecSpriteMovie;
-typedef struct _SwfdecSwfDecoder SwfdecSwfDecoder;
-typedef struct _SwfdecText SwfdecText;
-
-#endif
diff --git a/libswfdec/swfdec_url.c b/libswfdec/swfdec_url.c
deleted file mode 100644
index c81b5a2..0000000
--- a/libswfdec/swfdec_url.c
+++ /dev/null
@@ -1,709 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "swfdec_url.h"
-#include "swfdec_debug.h"
-
-/**
- * SECTION:SwfdecURL
- * @title: SwfdecURL
- * @short_description: URL handling in Swfdec
- *
- * SwfdecURL is Swfdec's way of handling URLs. You probably don't need to mess
- * with this type unless you want to write a #SwfdecLoader. In that case you
- * will want to use swfdec_loader_get_url() to get its url and then use the
- * functions in this section to access it.
- *
- * @see_also: #SwfdecLoader
- */
-
-/**
- * SwfdecURL:
- *
- * this is the structure used for URLs. It is a boxed type to glib's type system
- * and it is not reference counted. It is also a static struct in that it cannot
- * be modified after creation.
- */
-
-struct _SwfdecURL {
- char * url; /* the complete url */
- char * protocol; /* lowercase, http, file, rtmp, ... */
- char * host; /* lowercase, can be NULL for files */
- guint port; /* can be 0 */
- char * path; /* can be NULL for root path */
- char * query; /* can be NULL */
-};
-
-GType
-swfdec_url_get_type (void)
-{
- static GType type = 0;
-
- if (!type)
- type = g_boxed_type_register_static ("SwfdecURL",
- (GBoxedCopyFunc) swfdec_url_copy, (GBoxedFreeFunc) swfdec_url_free);
-
- return type;
-}
-
-static void *
-swfdec_memrchr (const void *s, int c, size_t n)
-{
- void *cur, *next;
-
- cur = memchr (s, c, n);
- if (cur == NULL)
- return NULL;
- while ((next = memchr (cur, c, n)))
- cur = next;
- return cur;
-}
-
-/**
- * swfdec_url_new:
- * @string: a full-qualified URL encoded in UTF-8
- *
- * Parses the given string into a URL for use in swfdec.
- *
- * Returns: a new #SwfdecURL
- **/
-SwfdecURL *
-swfdec_url_new (const char *string)
-{
- SwfdecURL *url;
- char *s;
-
- g_return_val_if_fail (string != NULL, NULL);
-
- /* FIXME: error checking? */
- SWFDEC_DEBUG ("new url: %s", string);
- url = g_slice_new0 (SwfdecURL);
- url->url = g_strdup (string);
- s = strstr (string, "://");
- if (s == NULL) {
- SWFDEC_INFO ("URL %s has no protocol", string);
- return url;
- }
- url->protocol = g_utf8_strdown (string, s - string);
- string = s + 3;
- s = strchr (string, '/');
- if (s == NULL) {
- url->host = g_ascii_strdown (string, -1);
- return url;
- }
- if (s != string) {
- char *colon = swfdec_memrchr (string, ':', s - string);
- if (colon) {
- url->port = strtoul (colon + 1, &colon, 10);
- url->host = g_ascii_strdown (string, colon - string);
- } else {
- url->host = g_ascii_strdown (string, s - string);
- }
- }
- string = s + 1;
- s = strchr (string, '?');
- if (s == NULL) {
- url->path = *string ? g_strdup (string) : NULL;
- return url;
- }
- url->path = g_strndup (string, s - string);
- s++;
- if (*s)
- url->query = g_strdup (s);
- return url;
-}
-
-/**
- * swfdec_url_new_components:
- * @protocol: protocol to use
- * @hostname: hostname or IP address or %NULL
- * @port: port number or 0. Must be 0 if no hostname is given
- * @path: a path or %NULL
- * @query: the query string or %NULL
- *
- * Creates a new URL from the given components.
- *
- * Returns: a new url pointing to the url from the given components
- **/
-SwfdecURL *
-swfdec_url_new_components (const char *protocol, const char *hostname,
- guint port, const char *path, const char *query)
-{
- GString *str;
- SwfdecURL *url;
-
- g_return_val_if_fail (protocol != NULL, NULL);
- g_return_val_if_fail (hostname != NULL || port == 0, NULL);
- g_return_val_if_fail (port < 65536, NULL);
-
- url = g_slice_new0 (SwfdecURL);
- str = g_string_new ("");
-
- /* protocol */
- url->protocol = g_ascii_strdown (protocol, -1);
- g_string_append (str, url->protocol);
- g_string_append (str, "://");
-
- /* hostname + port */
- if (hostname) {
- url->host = g_ascii_strdown (hostname, -1);
- url->port = port;
- g_string_append (str, url->host);
- if (port) {
- g_string_append_printf (str, ":%u", port);
- }
- }
- g_string_append (str, "/");
-
- /* path */
- if (path) {
- url->path = g_strdup (path);
- g_string_append (str, path);
- }
-
- /* query string */
- if (query) {
- url->query = g_strdup (query);
- g_string_append (str, "?");
- g_string_append (str, query);
- }
-
- url->url = g_string_free (str, FALSE);
- return url;
-}
-
-static gboolean
-swfdec_url_path_to_parent_path (char *path)
-{
- char *last = strrchr (path, '/');
-
- if (last == NULL)
- return FALSE;
-
- if (last[1] == '\0') {
- last[0] = '\0';
- return swfdec_url_path_to_parent_path (path);
- }
-
- *last = '\0';
- return TRUE;
-}
-
-/**
- * swfdec_url_new_parent:
- * @url: a #SwfdecURL
- *
- * Creates a new url that is the parent of @url. If the given @url has no
- * parent, a copy of itself is returned.
- *
- * Returns: a new url pointing to the parent of @url or %NULL on failure.
- **/
-SwfdecURL *
-swfdec_url_new_parent (const SwfdecURL *url)
-{
- char *path;
- SwfdecURL *ret;
-
- path = g_strdup (url->path);
- swfdec_url_path_to_parent_path (path);
- ret = swfdec_url_new_components (url->protocol, url->host, url->port,
- path, NULL);
- g_free (path);
- return ret;
-}
-
-/**
- * swfdec_url_new_relative:
- * @url: a #SwfdecURL
- * @string: a relative or absolute URL path
- *
- * Parses @string into a new URL. If the given @string is a relative URL, it
- * uses @url to resolve it to an absolute url; @url must already contain a
- * directory path.
- *
- * Returns: a new #SwfdecURL or %NULL if an error was detected.
- **/
-SwfdecURL *
-swfdec_url_new_relative (const SwfdecURL *url, const char *string)
-{
- SwfdecURL *ret;
- char *path, *query;
-
- g_return_val_if_fail (url != NULL, NULL);
- g_return_val_if_fail (string != NULL, NULL);
-
- /* check for full-qualified URL */
- if (strstr (string, "://"))
- return swfdec_url_new (string);
-
- if (string[0] == '/') {
- /* absolute URL */
- string++;
- query = strchr (string, '?');
- if (query == NULL) {
- path = *string ? g_strdup (string) : NULL;
- } else {
- path = g_strndup (string, query - string);
- query = g_strdup (query + 1);
- }
- } else {
- /* relative URL */
- char *cur = g_strdup (url->path);
- while (g_str_has_prefix (string, "../")) {
- if (!swfdec_url_path_to_parent_path (cur)) {
- g_free (cur);
- return NULL;
- }
- string += 3;
- }
- if (strstr (string, "/../")) {
- g_free (cur);
- return NULL;
- }
- path = g_strconcat (cur, "/", string, NULL);
- g_free (cur);
- cur = path;
- query = strchr (cur, '?');
- if (query == NULL) {
- path = *string ? g_strdup (cur) : NULL;
- } else {
- path = g_strndup (cur, query - cur);
- query = g_strdup (query + 1);
- }
- g_free (cur);
- }
- ret = swfdec_url_new_components (url->protocol, url->host, url->port,
- path, query);
- g_free (path);
- g_free (query);
- return ret;
-}
-
-/**
- * swfdec_url_copy:
- * @url: a #SwfdecURL
- *
- * copies the given url.
- *
- * Returns: a new #SwfdecURL
- **/
-SwfdecURL *
-swfdec_url_copy (const SwfdecURL *url)
-{
- SwfdecURL *copy;
-
- g_return_val_if_fail (url != NULL, NULL);
-
- copy = g_slice_new0 (SwfdecURL);
- copy->url = g_strdup (url->url);
- copy->protocol = g_strdup (url->protocol);
- copy->host = g_strdup (url->host);
- copy->port = url->port;
- copy->path = g_strdup (url->path);
- copy->query = g_strdup (url->query);
-
- return copy;
-}
-
-/**
- * swfdec_url_free:
- * @url: a #SwfdecURL
- *
- * Frees the URL and its associated ressources.
- **/
-void
-swfdec_url_free (SwfdecURL *url)
-{
- g_return_if_fail (url != NULL);
-
- g_free (url->url);
- g_free (url->protocol);
- g_free (url->host);
- g_free (url->path);
- g_free (url->query);
- g_slice_free (SwfdecURL, url);
-}
-
-/**
- * swfdec_url_get_url:
- * @url: a #SwfdecURL
- *
- * Gets the whole URL.
- *
- * Returns: the complete URL as string
- **/
-const char *
-swfdec_url_get_url (const SwfdecURL *url)
-{
- g_return_val_if_fail (url != NULL, NULL);
-
- return url->url;
-}
-
-/**
- * swfdec_url_get_protocol:
- * @url: a #SwfdecURL
- *
- * Gets the protocol used by this URL, such as "http" or "file".
- *
- * Returns: the protocol used or "error" if the URL is broken
- **/
-const char *
-swfdec_url_get_protocol (const SwfdecURL *url)
-{
- g_return_val_if_fail (url != NULL, NULL);
-
- if (url->protocol)
- return url->protocol;
- else
- return "error";
-}
-
-/**
- * swfdec_url_has_protocol:
- * @url: a url
- * @protocol: protocol name to check for
- *
- * Checks if the given @url references the given @protocol
- *
- * Returns: %TRUE if both protocols match, %FALSE otherwise
- **/
-gboolean
-swfdec_url_has_protocol (const SwfdecURL *url, const char *protocol)
-{
- g_return_val_if_fail (url != NULL, FALSE);
- g_return_val_if_fail (protocol != NULL, FALSE);
-
- return g_str_equal (url->protocol, protocol);
-}
-
-/**
- * swfdec_url_get_host:
- * @url: a #SwfdecURL
- *
- * Gets the host for @url as a lower case string.
- *
- * Returns: the host or %NULL if none (typically for file URLs).
- **/
-const char *
-swfdec_url_get_host (const SwfdecURL *url)
-{
- g_return_val_if_fail (url != NULL, NULL);
-
- return url->host;
-}
-
-/**
- * swfdec_url_get_port:
- * @url: a #SwfdecURL
- *
- * Gets the port number specified by the given @url. If the @url does not
- * specify a port number, 0 will be returned.
- *
- * Returns: the specified port or 0 if none was given.
- **/
-guint
-swfdec_url_get_port (const SwfdecURL *url)
-{
- g_return_val_if_fail (url != NULL, 0);
-
- return url->port;
-}
-
-/**
- * swfdec_url_get_path:
- * @url: a #SwfdecURL
- *
- * Gets the path associated with @url. If it contains no path, %NULL is
- * returned.
- * <note>The returned path does not start with a slash. So in particular for
- * files, you want to prepend the slash yourself.</note>
- *
- * Returns: the path or %NULL if none
- **/
-const char *
-swfdec_url_get_path (const SwfdecURL *url)
-{
- g_return_val_if_fail (url != NULL, NULL);
-
- return url->path;
-}
-
-/**
- * swfdec_url_get_query:
- * @url: a #SwfdecURL
- *
- * Gets the query string associated with @url. If the URL does not have a query
- * string, %NULL is returned.
- *
- * Returns: Query string or %NULL
- **/
-const char *
-swfdec_url_get_query (const SwfdecURL *url)
-{
- g_return_val_if_fail (url != NULL, NULL);
-
- return url->query;
-}
-
-/**
- * swfdec_url_is_parent:
- * @parent: the supposed parent url
- * @child: the supposed child url
- *
- * Checks if the given @parent url is a parent url of the given @child url. The
- * algorithm used is the same as checking policy files if hey apply. If @parent
- * equals @child, %TRUE is returned. This function does not compare query
- * strings.
- *
- * Returns: %TRUE if @parent is a parent of @child, %FALSE otherwise.
- **/
-gboolean
-swfdec_url_is_parent (const SwfdecURL *parent, const SwfdecURL *child)
-{
- gsize len;
-
- g_return_val_if_fail (parent != NULL, FALSE);
- g_return_val_if_fail (child != NULL, FALSE);
-
- if (!g_str_equal (parent->protocol, child->protocol))
- return FALSE;
- if (parent->host == NULL) {
- if (child->host != NULL)
- return FALSE;
- } else {
- if (child->host == NULL || !g_str_equal (parent->host, child->host))
- return FALSE;
- }
- if (parent->port != child->port)
- return FALSE;
- if (parent->path == NULL)
- return TRUE;
- if (child->path == NULL)
- return TRUE;
- len = strlen (parent->path);
- if (strncmp (parent->path, child->path, len) != 0)
- return FALSE;
- return child->path[len] == '\0' || child->path[len] == '/';
-}
-
-/**
- * swfdec_url_is_local:
- * @url: the url to check
- *
- * Checks if the given @url references a local resource. Local resources are
- * treated differently by Flash, since they get a higher degree of trust.
- *
- * Returns: %TRUE if the given url is local.
- **/
-gboolean
-swfdec_url_is_local (const SwfdecURL *url)
-{
- g_return_val_if_fail (url != NULL, FALSE);
-
- /* FIXME: If we ever support gnome-vfs, this might become tricky */
- return swfdec_url_has_protocol (url, "file");
-}
-
-/**
- * swfdec_url_equal:
- * @a: a #SwfdecURL
- * @b: a #SwfdecURL
- *
- * Compares the 2 given URLs for equality. 2 URLs are considered equal, when
- * they point to the same resource. This function is intended to be
- * used together with swfdec_url_hash() in a #GHashtable.
- *
- * Returns: %TRUE if the 2 given urls point to the same resource, %FALSE
- * otherwise.
- **/
-gboolean
-swfdec_url_equal (gconstpointer a, gconstpointer b)
-{
- const SwfdecURL *urla = a;
- const SwfdecURL *urlb = b;
-
- if (!swfdec_url_has_protocol (urla, urlb->protocol))
- return FALSE;
-
- if (urla->host == NULL) {
- if (urlb->host != NULL)
- return FALSE;
- } else {
- if (urlb->host == NULL ||
- !g_str_equal (urla->host, urlb->host))
- return FALSE;
- }
-
- if (urla->port != urlb->port)
- return FALSE;
-
- if (urla->path == NULL) {
- if (urlb->path != NULL)
- return FALSE;
- } else {
- if (urlb->path == NULL ||
- !g_str_equal (urla->path, urlb->path))
- return FALSE;
- }
-
- /* FIXME: include query strings? */
- if (urla->query == NULL) {
- if (urlb->query != NULL)
- return FALSE;
- } else {
- if (urlb->query == NULL ||
- !g_str_equal (urla->query, urlb->query))
- return FALSE;
- }
-
- return TRUE;
-}
-
-/**
- * swfdec_url_hash:
- * @url: a #SwfdecURL
- *
- * Creates a hash value for the given @url. This function is intended to be
- * used together with swfdec_url_equal() in a #GHashtable.
- *
- * Returns: a hash value
- **/
-guint
-swfdec_url_hash (gconstpointer url)
-{
- const SwfdecURL *u = url;
- guint ret;
-
- /* random hash function, feel free to improve it */
- ret = g_str_hash (u->protocol);
- if (u->host)
- ret ^= g_str_hash (u->host);
- ret ^= u->port;
- if (u->path)
- ret ^= g_str_hash (u->path);
- /* queries aren't used often in hashed urls, so ignore them */
- return ret;
-}
-
-/**
- * swfdec_url_path_is_relative:
- * @path: a string used to specify a url
- *
- * Checks if the given URL is relative or absolute.
- *
- * Returns: %TRUE if the path is a relative path, %FALSE if it is absolute
- **/
-gboolean
-swfdec_url_path_is_relative (const char *path)
-{
- g_return_val_if_fail (path != NULL, FALSE);
-
- return strstr (path, "://") == NULL;
-}
-
-/**
- * swfdec_url_new_from_input:
- * @input: the input povided
- *
- * Tries to guess the right URL from the given @input. This function is meant
- * as a utility function helping to convert user input (like command line
- * arguments) to a URL without requiring the full URL.
- *
- * Returns: a new url best matching the given @input.
- **/
-SwfdecURL *
-swfdec_url_new_from_input (const char *input)
-{
- SwfdecURL *url;
- char *url_string;
-
- g_return_val_if_fail (input != NULL, NULL);
-
- /* if it's a full URL, return it */
- if (!swfdec_url_path_is_relative (input) &&
- (url = swfdec_url_new (input)))
- return url;
-
- if (g_path_is_absolute (input)) {
- url_string = g_strconcat ("file://", input, NULL);
- } else {
- char *absolute, *cur;
- cur = g_get_current_dir ();
- absolute = g_build_filename (cur, input, NULL);
- g_free (cur);
- url_string = g_strconcat ("file://", absolute, NULL);
- g_free (absolute);
- }
-
- url = swfdec_url_new (url_string);
- g_free (url_string);
- g_return_val_if_fail (url != NULL, NULL);
- return url;
-}
-
-/**
- * swfdec_url_format_for_display:
- * @url: the url to display
- *
- * Creates a string suitable to display the given @url. An example for using
- * this function is to identify a currently playing Flash URL. Use
- * swfdec_player_get_url() to query the player's URL and then use this function
- * to get a displayable string.
- *
- * Returns: A new string containig a short description for this URL. g_free()
- * after use.
- **/
-char *
-swfdec_url_format_for_display (const SwfdecURL *url)
-{
- GString *str;
-
- g_return_val_if_fail (url != NULL, NULL);
-
- if (swfdec_url_is_local (url)) {
- const char *slash;
-
- if (url->path == NULL)
- return g_strdup ("/");
- slash = strrchr (url->path, '/');
- if (slash && slash[1] != '\0') {
- return g_strdup (slash + 1);
- } else {
- return g_strdup (url->path);
- }
- }
- str = g_string_new (url->protocol);
- g_string_append (str, "://");
- if (url->host)
- g_string_append (str, url->host);
- g_string_append (str, "/");
- if (url->path)
- g_string_append (str, url->path);
-
- return g_string_free (str, FALSE);
-}
-
diff --git a/libswfdec/swfdec_url.h b/libswfdec/swfdec_url.h
deleted file mode 100644
index a7d8c13..0000000
--- a/libswfdec/swfdec_url.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#include <glib-object.h>
-
-#ifndef _SWFDEC_URL_H_
-#define _SWFDEC_URL_H_
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecURL SwfdecURL;
-
-#define SWFDEC_TYPE_URL swfdec_url_get_type()
-GType swfdec_url_get_type (void) G_GNUC_CONST;
-
-SwfdecURL * swfdec_url_new (const char * string);
-SwfdecURL * swfdec_url_new_components (const char * protocol,
- const char * hostname,
- guint port,
- const char * path,
- const char * query);
-SwfdecURL * swfdec_url_new_parent (const SwfdecURL * url);
-SwfdecURL * swfdec_url_new_relative (const SwfdecURL * url,
- const char * string);
-SwfdecURL * swfdec_url_new_from_input (const char * input);
-SwfdecURL * swfdec_url_copy (const SwfdecURL * url);
-void swfdec_url_free (SwfdecURL * url);
-
-const char * swfdec_url_get_url (const SwfdecURL * url);
-const char * swfdec_url_get_protocol (const SwfdecURL * url);
-const char * swfdec_url_get_host (const SwfdecURL * url);
-guint swfdec_url_get_port (const SwfdecURL * url);
-const char * swfdec_url_get_path (const SwfdecURL * url);
-const char * swfdec_url_get_query (const SwfdecURL * url);
-char * swfdec_url_format_for_display (const SwfdecURL * url);
-
-gboolean swfdec_url_has_protocol (const SwfdecURL * url,
- const char * protocol);
-
-gboolean swfdec_url_is_parent (const SwfdecURL * parent,
- const SwfdecURL * child);
-gboolean swfdec_url_is_local (const SwfdecURL * url);
-
-gboolean swfdec_url_equal (gconstpointer a,
- gconstpointer b);
-guint swfdec_url_hash (gconstpointer url);
-
-gboolean swfdec_url_path_is_relative (const char * path);
-
-
-G_END_DECLS
-
-#endif
diff --git a/libswfdec/swfdec_utils.c b/libswfdec/swfdec_utils.c
deleted file mode 100644
index a6dc0db..0000000
--- a/libswfdec/swfdec_utils.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "swfdec_utils.h"
-
-gboolean
-swfdec_str_case_equal (gconstpointer v1, gconstpointer v2)
-{
- const char *s1 = v1;
- const char *s2 = v2;
-
- return g_ascii_strcasecmp (s1, s2) == 0;
-}
-
-guint
-swfdec_str_case_hash (gconstpointer v)
-{
- const signed char *p;
- guint32 h = 0;
-
- for (p = v; *p != '\0'; p++)
- h = (h << 5) - h + (*p & 0xDF);
-
- return h;
-}
-
-int
-swfdec_strcmp (guint version, const char *s1, const char *s2)
-{
- g_return_val_if_fail (s1 != NULL, 0);
- g_return_val_if_fail (s2 != NULL, 0);
-
- if (version < 7) {
- return g_ascii_strcasecmp (s1, s2);
- } else {
- return strcmp (s1, s2);
- }
-}
-
-int
-swfdec_strncmp (guint version, const char *s1, const char *s2, guint n)
-{
- g_return_val_if_fail (s1 != NULL, 0);
- g_return_val_if_fail (s2 != NULL, 0);
-
- if (version < 7) {
- return g_ascii_strncasecmp (s1, s2, n);
- } else {
- return strncmp (s1, s2, n);
- }
-}
-
diff --git a/libswfdec/swfdec_utils.h b/libswfdec/swfdec_utils.h
deleted file mode 100644
index fc57a5d..0000000
--- a/libswfdec/swfdec_utils.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#include <glib.h>
-
-#ifndef _SWFDEC_UTILS_H_
-#define _SWFDEC_UTILS_H_
-
-
-gboolean swfdec_str_case_equal (gconstpointer v1,
- gconstpointer v2);
-guint swfdec_str_case_hash (gconstpointer v);
-
-int swfdec_strcmp (guint version,
- const char * s1,
- const char * s2);
-int swfdec_strncmp (guint version,
- const char * s1,
- const char * s2,
- guint n);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_video.c b/libswfdec/swfdec_video.c
deleted file mode 100644
index 7ff8d8f..0000000
--- a/libswfdec/swfdec_video.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-
-#include "swfdec_video.h"
-#include "swfdec_debug.h"
-#include "swfdec_font.h"
-#include "swfdec_swf_decoder.h"
-#include "swfdec_video_movie.h"
-
-typedef struct {
- guint frame;
- SwfdecBuffer * buffer;
-} SwfdecVideoTag;
-
-static int
-swfdec_video_compare_frame (gconstpointer a, gconstpointer b)
-{
- return (int) *((const guint *) a) - *((const guint *) b);
-}
-
-static SwfdecBuffer *
-swfdec_video_find_frame (SwfdecVideo *video, guint frame)
-{
- SwfdecVideoTag tmp = { frame, NULL };
- SwfdecVideoTag *tag;
-
- if (video->images->len == 0)
- return NULL;
-
- tag = bsearch (&tmp, video->images->data, video->images->len,
- sizeof (SwfdecVideoTag), swfdec_video_compare_frame);
-
- return tag ? tag->buffer : NULL;
-}
-
-/*** INPUT FOR MOVIE ***/
-
-typedef struct {
- SwfdecVideoMovieInput input;
- SwfdecVideoMovie * movie;
- SwfdecVideo * video;
- gpointer decoder;
- guint current_frame;
- cairo_surface_t * surface;
-} SwfdecVideoInput;
-
-static void
-swfdec_video_input_set_ratio (SwfdecVideoMovieInput *input_, SwfdecVideoMovie *movie)
-{
- SwfdecVideoInput *input = (SwfdecVideoInput *) input_;
- guint ratio = SWFDEC_MOVIE (movie)->original_ratio;
- SwfdecBuffer *buffer;
-
- if (input->decoder == NULL)
- return;
- ratio++;
- if (ratio > input->video->n_frames) {
- SWFDEC_ERROR ("ratio %u too big: only %u frames", ratio, input->video->n_frames);
- ratio = input->video->n_frames - 1;
- }
- if (ratio < input->current_frame) {
- /* FIXME: need to reset decoder here? */
- input->current_frame = 0;
- }
-
- while (input->current_frame < ratio) {
- buffer = swfdec_video_find_frame (input->video, input->current_frame);
- if (buffer == NULL) {
- SWFDEC_INFO ("no buffer for frame %u", input->current_frame);
- } else {
- if (input->surface)
- cairo_surface_destroy (input->surface);
- input->surface = swfdec_video_decoder_decode (input->decoder, buffer);
- if (input->surface == NULL)
- return;
- if (input->video->width < (guint) cairo_image_surface_get_width (input->surface) ||
- input->video->height < (guint) cairo_image_surface_get_height (input->surface)) {
- static cairo_user_data_key_t key;
- cairo_surface_t *old = input->surface;
- input->surface = cairo_image_surface_create_for_data (
- cairo_image_surface_get_data (old), cairo_image_surface_get_format (old),
- input->video->width, input->video->height,
- cairo_image_surface_get_stride (old));
- cairo_surface_set_user_data (input->surface, &key, old,
- (cairo_destroy_func_t) cairo_surface_destroy);
- }
- }
- input->current_frame++;
- }
-}
-
-static void
-swfdec_video_input_connect (SwfdecVideoMovieInput *input_, SwfdecVideoMovie *movie)
-{
- SwfdecVideoInput *input = (SwfdecVideoInput *) input_;
-
- g_assert (input->movie == NULL);
- input->movie = movie;
-}
-
-static void
-swfdec_video_input_disconnect (SwfdecVideoMovieInput *input_, SwfdecVideoMovie *movie)
-{
- SwfdecVideoInput *input = (SwfdecVideoInput *) input_;
-
- g_assert (input->movie == movie);
- if (input->decoder)
- swfdec_video_decoder_free (input->decoder);
- if (input->surface)
- cairo_surface_destroy (input->surface);
- g_object_unref (input->video);
- g_slice_free (SwfdecVideoInput, input);
-}
-
-static cairo_surface_t *
-swfdec_video_input_get_image (SwfdecVideoMovieInput *input_)
-{
- SwfdecVideoInput *input = (SwfdecVideoInput *) input_;
-
- return input->surface;
-}
-
-static SwfdecVideoMovieInput *
-swfdec_video_input_new (SwfdecVideo *video)
-{
- SwfdecVideoInput *input;
-
- if (video->n_frames == 0)
- return NULL;
- input = g_slice_new0 (SwfdecVideoInput);
- input->decoder = swfdec_video_decoder_new (video->format);
- if (input->decoder == NULL) {
- g_slice_free (SwfdecVideoInput, input);
- return NULL;
- }
- input->input.connect = swfdec_video_input_connect;
- input->input.disconnect = swfdec_video_input_disconnect;
- input->input.set_ratio = swfdec_video_input_set_ratio;
- input->input.get_image = swfdec_video_input_get_image;
- g_object_ref (video);
- input->video = video;
- input->current_frame = (guint) -1;
- return &input->input;
-}
-
-/*** SWFDEC_VIDEO ***/
-
-G_DEFINE_TYPE (SwfdecVideo, swfdec_video, SWFDEC_TYPE_GRAPHIC)
-
-static SwfdecMovie *
-swfdec_video_create_movie (SwfdecGraphic *graphic, gsize *size)
-{
- SwfdecVideo *video = SWFDEC_VIDEO (graphic);
- SwfdecVideoMovie *movie = g_object_new (SWFDEC_TYPE_VIDEO_MOVIE, NULL);
- SwfdecVideoMovieInput *input = swfdec_video_input_new (video);
-
- movie->video = SWFDEC_VIDEO (graphic);
- g_object_ref (graphic);
- if (input)
- swfdec_video_movie_set_input (movie, input);
- *size = sizeof (SwfdecVideoMovie);
- return SWFDEC_MOVIE (movie);
-}
-
-static void
-swfdec_video_dispose (GObject *object)
-{
- SwfdecVideo * video = SWFDEC_VIDEO (object);
- guint i;
-
- for (i = 0; i < video->images->len; i++) {
- swfdec_buffer_unref (g_array_index (video->images, SwfdecVideoTag, i).buffer);
- }
- g_array_free (video->images, TRUE);
- G_OBJECT_CLASS (swfdec_video_parent_class)->dispose (object);
-}
-
-static void
-swfdec_video_class_init (SwfdecVideoClass * g_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (g_class);
- SwfdecGraphicClass *graphic_class = SWFDEC_GRAPHIC_CLASS (g_class);
-
- object_class->dispose = swfdec_video_dispose;
-
- graphic_class->create_movie = swfdec_video_create_movie;
-}
-
-static void
-swfdec_video_init (SwfdecVideo * video)
-{
- video->images = g_array_new (FALSE, FALSE, sizeof (SwfdecVideoTag));
-}
-
-int
-tag_func_define_video (SwfdecSwfDecoder *s, guint tag)
-{
- SwfdecVideo *video;
- guint id;
- SwfdecBits *bits = &s->b;
- int smoothing, deblocking;
-
- id = swfdec_bits_get_u16 (bits);
- video = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_VIDEO);
- if (!video)
- return SWFDEC_STATUS_OK;
-
- video->n_frames = swfdec_bits_get_u16 (bits);
- video->width = swfdec_bits_get_u16 (bits);
- video->height = swfdec_bits_get_u16 (bits);
- swfdec_bits_getbits (bits, 4);
- deblocking = swfdec_bits_getbits (bits, 3);
- smoothing = swfdec_bits_getbit (bits);
- video->format = swfdec_bits_get_u8 (bits);
- SWFDEC_LOG (" frames: %u", video->n_frames);
- SWFDEC_LOG (" size: %ux%u", video->width, video->height);
- SWFDEC_LOG (" deblocking: %d", deblocking);
- SWFDEC_LOG (" smoothing: %d", smoothing);
- SWFDEC_LOG (" format: %d", (int) video->format);
- return SWFDEC_STATUS_OK;
-}
-
-int
-tag_func_video_frame (SwfdecSwfDecoder *s, guint unused_tag)
-{
- SwfdecVideo *video;
- guint id;
- SwfdecVideoTag tag;
-
- id = swfdec_bits_get_u16 (&s->b);
- video = (SwfdecVideo *) swfdec_swf_decoder_get_character (s, id);
- if (!SWFDEC_IS_VIDEO (video)) {
- SWFDEC_ERROR ("id %u does not reference a video object", id);
- return SWFDEC_STATUS_OK;
- }
- tag.frame = swfdec_bits_get_u16 (&s->b);
- if (tag.frame >= video->n_frames) {
- SWFDEC_ERROR ("frame %u out of range %u", tag.frame, video->n_frames);
- return SWFDEC_STATUS_OK;
- }
- /* it seems flash video saves keyframe + format in every frame -
- * at least libflv + ming does that and Flash Player plays it.
- */
- if (video->format == SWFDEC_VIDEO_CODEC_SCREEN) {
-#if 0
- keyframe = swfdec_bits_get_bits (&s->b, 4);
- format = swfdec_bits_get_bits (&s->b, 4);
-#endif
- swfdec_bits_get_u8 (&s->b);
- }
- tag.buffer = swfdec_bits_get_buffer (&s->b, -1);
- if (tag.buffer == NULL) {
- SWFDEC_WARNING ("no buffer, ignoring");
- return SWFDEC_STATUS_OK;
- }
- if (video->images->len == 0) {
- g_array_append_val (video->images, tag);
- } else if (g_array_index (video->images, SwfdecVideoTag, video->images->len - 1).frame < tag.frame) {
- g_array_append_val (video->images, tag);
- } else {
- guint i;
- SWFDEC_WARNING ("frame not in ascending order (last is %u, this is %u)",
- g_array_index (video->images, SwfdecVideoTag, video->images->len - 1).frame, tag.frame);
- for (i = 0; i < video->images->len; i++) {
- SwfdecVideoTag *cur = &g_array_index (video->images, SwfdecVideoTag, i);
- if (cur->frame < tag.frame)
- continue;
- if (cur->frame == tag.frame) {
- SWFDEC_ERROR ("duplicate frame id %u", cur->frame);
- continue;
- }
- g_array_insert_val (video->images, i, tag);
- break;
- }
- if (i >= video->images->len)
- g_array_append_val (video->images, tag);
- }
- return SWFDEC_STATUS_OK;
-}
-
diff --git a/libswfdec/swfdec_video.h b/libswfdec/swfdec_video.h
deleted file mode 100644
index 585c726..0000000
--- a/libswfdec/swfdec_video.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_VIDEO_H_
-#define _SWFDEC_VIDEO_H_
-
-#include <libswfdec/swfdec_graphic.h>
-#include <libswfdec/swfdec_codec_video.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecVideo SwfdecVideo;
-typedef struct _SwfdecVideoClass SwfdecVideoClass;
-
-#define SWFDEC_TYPE_VIDEO (swfdec_video_get_type())
-#define SWFDEC_IS_VIDEO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_VIDEO))
-#define SWFDEC_IS_VIDEO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_VIDEO))
-#define SWFDEC_VIDEO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_VIDEO, SwfdecVideo))
-#define SWFDEC_VIDEO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_VIDEO, SwfdecVideoClass))
-
-struct _SwfdecVideo {
- SwfdecGraphic graphic;
-
- guint width; /* width in pixels */
- guint height; /* height in pixels */
- guint n_frames; /* length of movie */
- GArray * images; /* actual images of the movie */
-
- guint format; /* format in use */
-};
-
-struct _SwfdecVideoClass {
- SwfdecGraphicClass graphic_class;
-};
-
-GType swfdec_video_get_type (void);
-
-int tag_func_define_video (SwfdecSwfDecoder * s,
- guint tag);
-int tag_func_video_frame (SwfdecSwfDecoder * s,
- guint tag);
-
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_video_movie.c b/libswfdec/swfdec_video_movie.c
deleted file mode 100644
index b77379a..0000000
--- a/libswfdec/swfdec_video_movie.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_video_movie.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_resource.h"
-
-G_DEFINE_TYPE (SwfdecVideoMovie, swfdec_video_movie, SWFDEC_TYPE_MOVIE)
-
-static void
-swfdec_video_movie_update_extents (SwfdecMovie *movie,
- SwfdecRect *extents)
-{
- SwfdecVideoMovie *video = SWFDEC_VIDEO_MOVIE (movie);
- SwfdecRect rect = { 0, 0,
- SWFDEC_TWIPS_SCALE_FACTOR * video->video->width,
- SWFDEC_TWIPS_SCALE_FACTOR * video->video->height };
-
- swfdec_rect_union (extents, extents, &rect);
-}
-
-static void
-swfdec_video_movie_update_image (SwfdecVideoMovie *movie)
-{
- if (!movie->needs_update)
- return;
-
- if (movie->input != NULL) {
- if (movie->input->set_ratio)
- movie->input->set_ratio (movie->input, movie);
-
- if (movie->image)
- cairo_surface_destroy (movie->image);
- movie->image = movie->input->get_image (movie->input);
- if (movie->image)
- cairo_surface_reference (movie->image);
- }
- movie->needs_update = FALSE;
-}
-
-static void
-swfdec_video_movie_render (SwfdecMovie *mov, cairo_t *cr,
- const SwfdecColorTransform *trans, const SwfdecRect *inval)
-{
- SwfdecVideoMovie *movie = SWFDEC_VIDEO_MOVIE (mov);
-
- swfdec_video_movie_update_image (movie);
- if (movie->image == NULL)
- return;
-
- cairo_scale (cr,
- (mov->original_extents.x1 - mov->original_extents.x0)
- / cairo_image_surface_get_width (movie->image),
- (mov->original_extents.y1 - mov->original_extents.y0)
- / cairo_image_surface_get_height (movie->image));
- cairo_set_source_surface (cr, movie->image, 0.0, 0.0);
- cairo_paint (cr);
-}
-
-static void
-swfdec_video_movie_unset_input (SwfdecVideoMovie *movie)
-{
- if (movie->input == NULL)
- return;
-
- if (movie->input->disconnect)
- movie->input->disconnect (movie->input, movie);
- movie->input = NULL;
- swfdec_video_movie_update_image (movie);
-}
-
-static void
-swfdec_video_movie_dispose (GObject *object)
-{
- SwfdecVideoMovie *movie = SWFDEC_VIDEO_MOVIE (object);
-
- swfdec_video_movie_unset_input (movie);
- g_object_unref (movie->video);
- if (movie->image) {
- cairo_surface_destroy (movie->image);
- movie->image = NULL;
- }
-
- G_OBJECT_CLASS (swfdec_video_movie_parent_class)->dispose (object);
-}
-
-static void
-swfdec_video_movie_set_ratio (SwfdecMovie *movie)
-{
- SwfdecVideoMovie *video = SWFDEC_VIDEO_MOVIE (movie);
-
- if (video->input->set_ratio) {
- video->needs_update = TRUE;
- swfdec_movie_invalidate_last (movie);
- }
-}
-
-static void
-swfdec_video_movie_invalidate (SwfdecMovie *movie, const cairo_matrix_t *matrix, gboolean last)
-{
- SwfdecVideoMovie *video = SWFDEC_VIDEO_MOVIE (movie);
- SwfdecRect rect = { 0, 0,
- SWFDEC_TWIPS_SCALE_FACTOR * video->video->width,
- SWFDEC_TWIPS_SCALE_FACTOR * video->video->height };
-
- swfdec_rect_transform (&rect, &rect, matrix);
- swfdec_player_invalidate (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), &rect);
-}
-
-static void
-swfdec_video_movie_init_movie (SwfdecMovie *movie)
-{
- swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (movie), movie->resource->sandbox->Video);
-}
-
-static void
-swfdec_video_movie_class_init (SwfdecVideoMovieClass * g_class)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (g_class);
- SwfdecMovieClass *movie_class = SWFDEC_MOVIE_CLASS (g_class);
-
- object_class->dispose = swfdec_video_movie_dispose;
-
- movie_class->update_extents = swfdec_video_movie_update_extents;
- movie_class->render = swfdec_video_movie_render;
- movie_class->invalidate = swfdec_video_movie_invalidate;
- movie_class->init_movie = swfdec_video_movie_init_movie;
- movie_class->set_ratio = swfdec_video_movie_set_ratio;
-}
-
-static void
-swfdec_video_movie_init (SwfdecVideoMovie * video_movie)
-{
-}
-
-void
-swfdec_video_movie_set_input (SwfdecVideoMovie *movie, SwfdecVideoMovieInput *input)
-{
- g_return_if_fail (SWFDEC_IS_VIDEO_MOVIE (movie));
-
- swfdec_video_movie_unset_input (movie);
- movie->input = input;
- if (input == NULL)
- return;
- if (movie->input->set_ratio) {
- swfdec_movie_invalidate_last (SWFDEC_MOVIE (movie));
- }
- movie->needs_update = TRUE;
- if (input->connect)
- input->connect (input, movie);
-}
-
-void
-swfdec_video_movie_clear (SwfdecVideoMovie *movie)
-{
- g_return_if_fail (SWFDEC_IS_VIDEO_MOVIE (movie));
-
- if (movie->image) {
- cairo_surface_destroy (movie->image);
- movie->image = NULL;
- }
- swfdec_movie_invalidate_last (SWFDEC_MOVIE (movie));
-}
-
-void
-swfdec_video_movie_new_image (SwfdecVideoMovie *movie)
-{
- g_return_if_fail (SWFDEC_IS_VIDEO_MOVIE (movie));
-
- if (movie->image) {
- cairo_surface_destroy (movie->image);
- movie->image = NULL;
- }
- movie->needs_update = TRUE;
- swfdec_movie_invalidate_last (SWFDEC_MOVIE (movie));
-}
-
diff --git a/libswfdec/swfdec_video_movie.h b/libswfdec/swfdec_video_movie.h
deleted file mode 100644
index 958bc49..0000000
--- a/libswfdec/swfdec_video_movie.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_VIDEO_MOVIE_H_
-#define _SWFDEC_VIDEO_MOVIE_H_
-
-#include <glib-object.h>
-#include <libswfdec/swfdec_movie.h>
-#include <libswfdec/swfdec_video.h>
-
-G_BEGIN_DECLS
-
-
-typedef struct _SwfdecVideoMovie SwfdecVideoMovie;
-typedef struct _SwfdecVideoMovieClass SwfdecVideoMovieClass;
-typedef struct _SwfdecVideoMovieInput SwfdecVideoMovieInput;
-
-#define SWFDEC_TYPE_VIDEO_MOVIE (swfdec_video_movie_get_type())
-#define SWFDEC_IS_VIDEO_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_VIDEO_MOVIE))
-#define SWFDEC_IS_VIDEO_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_VIDEO_MOVIE))
-#define SWFDEC_VIDEO_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_VIDEO_MOVIE, SwfdecVideoMovie))
-#define SWFDEC_VIDEO_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_VIDEO_MOVIE, SwfdecVideoMovieClass))
-
-/* FIXME: make an interface? */
-struct _SwfdecVideoMovieInput {
- /* connect to movie */
- void (* connect) (SwfdecVideoMovieInput *input,
- SwfdecVideoMovie * movie);
- /* called when input is unset */
- void (* disconnect) (SwfdecVideoMovieInput *input,
- SwfdecVideoMovie * movie);
- /* called when movie ratio changed */
- void (* set_ratio) (SwfdecVideoMovieInput *input,
- SwfdecVideoMovie * movie);
- /* called to request the current image */
- cairo_surface_t * (* get_image) (SwfdecVideoMovieInput *input);
-};
-
-struct _SwfdecVideoMovie {
- SwfdecMovie movie;
-
- SwfdecVideo * video; /* video we play back */
- SwfdecVideoMovieInput *input; /* where we take the input from */
- gboolean needs_update; /* TRUE if we should call set_ratio and get_image */
- cairo_surface_t * image; /* currently displayed image */
-};
-
-struct _SwfdecVideoMovieClass {
- SwfdecMovieClass movie_class;
-};
-
-GType swfdec_video_movie_get_type (void);
-
-void swfdec_video_movie_set_input (SwfdecVideoMovie * movie,
- SwfdecVideoMovieInput *input);
-void swfdec_video_movie_clear (SwfdecVideoMovie * movie);
-/* API for SwfdecVideoMovieInput */
-void swfdec_video_movie_new_image (SwfdecVideoMovie * movie);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_video_movie_as.c b/libswfdec/swfdec_video_movie_as.c
deleted file mode 100644
index ecc7a28..0000000
--- a/libswfdec/swfdec_video_movie_as.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_video.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-#include "swfdec_internal.h"
-#include "swfdec_net_stream.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_sandbox.h"
-
-SWFDEC_AS_NATIVE (667, 1, swfdec_video_attach_video)
-void
-swfdec_video_attach_video (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecVideoMovie *video;
- SwfdecAsObject *stream;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_VIDEO_MOVIE, &video, "O", &stream);
-
- if (stream == NULL || !SWFDEC_IS_NET_STREAM (stream)) {
- SWFDEC_WARNING ("calling attachVideo without a NetStream object");
- swfdec_video_movie_set_input (video, NULL);
- return;
- }
-
- swfdec_video_movie_set_input (video, &SWFDEC_NET_STREAM (stream)->input);
-}
-
-SWFDEC_AS_NATIVE (667, 2, swfdec_video_clear)
-void
-swfdec_video_clear (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecVideoMovie *video;
-
- SWFDEC_AS_CHECK (SWFDEC_TYPE_VIDEO_MOVIE, &video, "");
-
- swfdec_video_movie_clear (video);
-}
-
-void
-swfdec_video_movie_init_context (SwfdecPlayer *player)
-{
- SwfdecAsContext *context;
- SwfdecAsObject *video, *proto;
- SwfdecAsValue val;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
-
- context = SWFDEC_AS_CONTEXT (player);
- video = SWFDEC_AS_OBJECT (swfdec_as_object_add_function (context->global,
- SWFDEC_AS_STR_Video, 0, NULL, 0));
- if (video == NULL)
- return;
- SWFDEC_SANDBOX (context->global)->Video = video;
- proto = swfdec_as_object_new_empty (context);
- if (proto == NULL)
- return;
- /* set the right properties on the Video object */
- SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
- swfdec_as_object_set_variable_and_flags (video, SWFDEC_AS_STR_prototype, &val,
- SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
- /* set the right properties on the Video.prototype object */
- SWFDEC_AS_VALUE_SET_OBJECT (&val, video);
- swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor,
- &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
- SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object_prototype);
- swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR___proto__, &val,
- SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
-}
-
diff --git a/libswfdec/swfdec_xml.c b/libswfdec/swfdec_xml.c
deleted file mode 100644
index e5331c6..0000000
--- a/libswfdec/swfdec_xml.c
+++ /dev/null
@@ -1,940 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-#include <string.h>
-
-#include "swfdec_xml.h"
-#include "swfdec_xml_node.h"
-#include "swfdec_as_native_function.h"
-#include "swfdec_as_array.h"
-#include "swfdec_as_object.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-#include "swfdec_internal.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_player_internal.h"
-
-G_DEFINE_TYPE (SwfdecXml, swfdec_xml, SWFDEC_TYPE_XML_NODE)
-
-static void
-swfdec_xml_do_mark (SwfdecAsObject *object)
-{
- SwfdecXml *xml = SWFDEC_XML (object);
-
- if (xml->xml_decl != NULL)
- swfdec_as_string_mark (xml->xml_decl);
- if (xml->doc_type_decl != NULL)
- swfdec_as_string_mark (xml->doc_type_decl);
-
- SWFDEC_AS_OBJECT_CLASS (swfdec_xml_parent_class)->mark (object);
-}
-
-static void
-swfdec_xml_class_init (SwfdecXmlClass *klass)
-{
- SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
-
- asobject_class->mark = swfdec_xml_do_mark;
-}
-
-static void
-swfdec_xml_init (SwfdecXml *xml)
-{
-}
-
-typedef struct {
- const char character;
- const char *escaped;
-} EntityConversion;
-
-static EntityConversion xml_entities[] = {
- { '&', "&" },
- { '"', """ },
- { '\'', "'" },
- { '<', "<" },
- { '>', ">" },
- { '\xa0', " " },
- { '\0', NULL }
-};
-
-char *
-swfdec_xml_escape_len (const char *orginal, gssize length)
-{
- int i;
- const char *p, *start;
- GString *string;
-
- string = g_string_new ("");
-
- // Note: we don't escape non-breaking space to
- p = start = orginal;
- while (*(p += strcspn (p, "&<>\"'")) != '\0' && p - orginal < length) {
- string = g_string_append_len (string, start, p - start);
-
- // escape it
- for (i = 0; xml_entities[i].escaped != NULL; i++) {
- if (xml_entities[i].character == *p) {
- string = g_string_append (string, xml_entities[i].escaped);
- break;
- }
- }
- g_assert (xml_entities[i].escaped != NULL);
-
- p++;
- start = p;
- }
- string = g_string_append_len (string, start, length - (start - orginal));
-
- return g_string_free (string, FALSE);
-}
-
-char *
-swfdec_xml_escape (const char *orginal)
-{
- return swfdec_xml_escape_len (orginal, strlen (orginal));
-}
-
-char *
-swfdec_xml_unescape_len (SwfdecAsContext *cx, const char *orginal,
- gssize length, gboolean unescape_nbsp)
-{
- int i;
- const char *p, *start, *end;
- GString *string;
-
- string = g_string_new ("");
-
- p = start = orginal;
- end = orginal + length;
- while ((p = memchr (p, '&', end - p)) != NULL) {
- string = g_string_append_len (string, start, p - start);
-
- for (i = 0; xml_entities[i].escaped != NULL; i++) {
- if (!g_ascii_strncasecmp (p, xml_entities[i].escaped,
- strlen (xml_entities[i].escaped))) {
- // FIXME: Do this cleaner
- if (xml_entities[i].character == '\xa0') {
- if (unescape_nbsp)
- string = g_string_append_c (string, '\xc2');
- else
- continue;
- }
- string = g_string_append_c (string, xml_entities[i].character);
- p += strlen (xml_entities[i].escaped);
- break;
- }
- }
- if (xml_entities[i].escaped == NULL) {
- string = g_string_append_c (string, '&');
- p++;
- }
-
- start = p;
- }
- string = g_string_append_len (string, start, length - (start - orginal));
-
- return g_string_free (string, FALSE);
-}
-
-char *
-swfdec_xml_unescape (SwfdecAsContext *cx, const char *orginal)
-{
- return swfdec_xml_unescape_len (cx, orginal, strlen (orginal), TRUE);
-}
-
-// this is never declared, only available as ASnative (100, 5)
-SWFDEC_AS_NATIVE (100, 5, swfdec_xml_do_escape)
-void
-swfdec_xml_do_escape (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- char *escaped;
-
- if (argc < 1)
- return;
-
- escaped = swfdec_xml_escape (swfdec_as_value_to_string (cx, &argv[0]));
- SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, escaped));
-}
-
-static void
-swfdec_xml_get_ignoreWhite (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_XML (object))
- return;
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, SWFDEC_XML (object)->ignore_white);
-}
-
-static void
-swfdec_xml_set_ignoreWhite (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_XML (object))
- return;
-
- if (argc < 1)
- return;
-
- // special case
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
- return;
-
- // special case, call toString of objects
- if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]))
- swfdec_as_value_to_string (cx, &argv[0]);
-
- SWFDEC_XML (object)->ignore_white =
- swfdec_as_value_to_boolean (cx, &argv[0]);
-}
-
-static void
-swfdec_xml_get_xmlDecl (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_XML (object))
- return;
-
- if (SWFDEC_XML (object)->xml_decl != NULL) {
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_XML (object)->xml_decl);
- } else {
- SWFDEC_AS_VALUE_SET_UNDEFINED (ret);
- }
-}
-
-static void
-swfdec_xml_set_xmlDecl (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_XML (object))
- return;
-
- if (argc < 1)
- return;
-
- // special case
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
- return;
-
- SWFDEC_XML (object)->xml_decl = swfdec_as_value_to_string (cx, &argv[0]);
-}
-
-static void
-swfdec_xml_get_docTypeDecl (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_XML (object))
- return;
-
- if (SWFDEC_XML (object)->doc_type_decl != NULL) {
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_XML (object)->doc_type_decl);
- } else {
- SWFDEC_AS_VALUE_SET_UNDEFINED (ret);
- }
-}
-
-static void
-swfdec_xml_set_docTypeDecl (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_XML (object))
- return;
-
- if (argc < 1)
- return;
-
- // special case
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
- return;
-
- SWFDEC_XML (object)->doc_type_decl =
- swfdec_as_value_to_string (cx, &argv[0]);
-}
-
-static void
-swfdec_xml_get_contentType (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_XML (object))
- return;
-
- *ret = SWFDEC_XML (object)->content_type;
-}
-
-static void
-swfdec_xml_set_contentType (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_XML (object))
- return;
-
- if (argc < 1)
- return;
-
- // special case
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
- return;
-
- SWFDEC_XML (object)->content_type = argv[0];
-}
-
-static void
-swfdec_xml_get_loaded (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_XML (object))
- return;
-
- *ret = SWFDEC_XML (object)->loaded;
-}
-
-static void
-swfdec_xml_set_loaded (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_XML (object))
- return;
-
- if (argc < 1)
- return;
-
- // special case, call toString of objects
- if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]))
- swfdec_as_value_to_string (cx, &argv[0]);
-
- // special case
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
- return;
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (&SWFDEC_XML (object)->loaded,
- swfdec_as_value_to_boolean (cx, &argv[0]));
-}
-
-static void
-swfdec_xml_get_status (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_XML (object))
- return;
-
- SWFDEC_AS_VALUE_SET_INT (ret, SWFDEC_XML (object)->status);
-}
-
-static void
-swfdec_xml_set_status (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- double d;
-
- if (!SWFDEC_IS_XML (object))
- return;
-
- if (argc < 1)
- return;
-
- swfdec_as_value_to_string (cx, &argv[0]);
- d = swfdec_as_value_to_number (cx, &argv[0]);
- if (!isfinite (d))
- SWFDEC_XML (object)->status = 0;
- else
- SWFDEC_XML (object)->status = d;
-}
-
-static const char *
-swfdec_xml_parse_xmlDecl (SwfdecXml *xml, SwfdecXmlNode *node, const char *p)
-{
- const char *end;
- GString *string;
-
- g_assert (p != NULL);
- g_return_val_if_fail (g_ascii_strncasecmp (p, "<?xml", strlen ("<?xml")) == 0,
- strchr (p, '\0'));
- g_return_val_if_fail (SWFDEC_IS_XML (xml), strchr (p, '\0'));
-
- end = strstr (p, "?>");
- if (end == NULL) {
- xml->status = XML_PARSE_STATUS_XMLDECL_NOT_TERMINATED;
- return strchr (p, '\0');
- }
-
- end += strlen ("?>");
-
- string = g_string_new ((xml->xml_decl != NULL ? xml->xml_decl : ""));
- string = g_string_append_len (string, p, end - p);
- xml->xml_decl = swfdec_as_context_give_string (
- SWFDEC_AS_OBJECT (xml)->context, g_string_free (string, FALSE));
-
- // in version 5 parsing xmlDecl or docType always adds undefined element to
- // the childNodes array
- if (SWFDEC_AS_OBJECT (xml)->context->version < 6)
- SWFDEC_FIXME ("Need to add undefined element to childNodes array");
-
- g_return_val_if_fail (end > p, strchr (p, '\0'));
-
- return end;
-}
-
-static const char *
-swfdec_xml_parse_docTypeDecl (SwfdecXml *xml, SwfdecXmlNode *node,
- const char *p)
-{
- const char *end;
- int open;
-
- g_assert (p != NULL);
- g_return_val_if_fail (
- g_ascii_strncasecmp (p, "<!DOCTYPE", strlen ("<!DOCTYPE")) == 0,
- strchr (p, '\0'));
- g_return_val_if_fail (SWFDEC_IS_XML (xml), strchr (p, '\0'));
-
- end = p + 1;
- open = 1;
- do {
- end += strcspn (end, "<>");
- if (*end == '<') {
- open++;
- end++;
- } else if (*end == '>') {
- open--;
- end++;
- }
- } while (*end != '\0' && open > 0);
-
- if (*end == '\0') {
- xml->status = XML_PARSE_STATUS_DOCTYPEDECL_NOT_TERMINATED;
- } else {
- xml->doc_type_decl = swfdec_as_context_give_string (
- SWFDEC_AS_OBJECT (xml)->context, g_strndup (p, end - p));
-
- // in version 5 parsing xmlDecl or docType always adds undefined element to
- // the childNodes array
- if (SWFDEC_AS_OBJECT (xml)->context->version < 6)
- SWFDEC_FIXME ("Need to add undefined element to childNodes array");
- }
-
- g_return_val_if_fail (end > p, strchr (p, '\0'));
-
- return end;
-}
-
-static const char *
-swfdec_xml_parse_comment (SwfdecXml *xml, const char *p)
-{
- const char *end;
-
- g_assert (p != NULL);
- g_return_val_if_fail (strncmp (p, "<!--", strlen ("<!--")) == 0,
- strchr (p, '\0'));
- g_return_val_if_fail (SWFDEC_IS_XML (xml), strchr (p, '\0'));
-
- end = strstr (p, "-->");
-
- if (end == NULL) {
- xml->status = XML_PARSE_STATUS_COMMENT_NOT_TERMINATED;
- return strchr (p, '\0');
- }
-
- end += strlen("-->");
-
- g_return_val_if_fail (end > p, strchr (p, '\0'));
-
- return end;
-}
-
-static void
-swfdec_xml_add_id_map (SwfdecXml *xml, SwfdecXmlNode *node, const char *id)
-{
- SwfdecAsObject *object;
- SwfdecAsValue val;
-
- g_return_if_fail (SWFDEC_IS_XML (xml));
- g_return_if_fail (SWFDEC_IS_XML_NODE (xml));
- g_return_if_fail (id != NULL && id != SWFDEC_AS_STR_EMPTY);
-
- if (SWFDEC_AS_OBJECT (xml)->context->version >= 8) {
- if (swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (xml),
- SWFDEC_AS_STR_idMap, &val)) {
- if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
- object = SWFDEC_AS_VALUE_GET_OBJECT (&val);
- } else {
- return;
- }
- } else {
- object = swfdec_as_object_new_empty (SWFDEC_AS_OBJECT (xml)->context);
- SWFDEC_AS_VALUE_SET_OBJECT (&val, object);
- swfdec_as_object_set_variable (SWFDEC_AS_OBJECT (xml),
- SWFDEC_AS_STR_idMap, &val);
- }
- } else {
- object = SWFDEC_AS_OBJECT (xml);
- }
-
- SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (node));
- swfdec_as_object_set_variable (object, id, &val);
-}
-
-static const char *
-swfdec_xml_parse_attribute (SwfdecXml *xml, SwfdecXmlNode *node, const char *p)
-{
- SwfdecAsValue val;
- const char *end, *name;
- char *text;
-
- g_return_val_if_fail (SWFDEC_IS_XML (xml), strchr (p, '\0'));
- g_return_val_if_fail (SWFDEC_IS_XML_NODE (node), strchr (p, '\0'));
- g_return_val_if_fail ((*p != '>' && *p != '\0'), p);
-
- end = p + strcspn (p, "=> \r\n\t");
- if (end - p <= 0) {
- xml->status = XML_PARSE_STATUS_ELEMENT_MALFORMED;
- return strchr (p, '\0');
- }
-
- text = g_strndup (p, end - p);
- name = swfdec_as_context_give_string (SWFDEC_AS_OBJECT (node)->context,
- swfdec_xml_unescape (SWFDEC_AS_OBJECT (xml)->context, text));
- g_free (text);
-
- p = end + strspn (end, " \r\n\t");
- if (*p != '=') {
- xml->status = XML_PARSE_STATUS_ELEMENT_MALFORMED;
- return strchr (p, '\0');
- }
- p = p + 1 + strspn (p + 1, " \r\n\t");
-
- if (*p != '"' && *p != '\'') {
- xml->status = XML_PARSE_STATUS_ELEMENT_MALFORMED;
- return strchr (p, '\0');
- }
-
- end = p + 1;
- do {
- end = strchr (end, *p);
- } while (end != NULL && *(end - 1) == '\\');
-
- if (end == NULL) {
- xml->status = XML_PARSE_STATUS_ATTRIBUTE_NOT_TERMINATED;
- return strchr (p, '\0');
- }
-
- if (!swfdec_as_object_get_variable (node->attributes, name, NULL)) {
- char *unescaped;
- const char *value;
-
- unescaped = swfdec_xml_unescape_len (SWFDEC_AS_OBJECT (xml)->context,
- p + 1, end - (p + 1), TRUE);
- value = swfdec_as_context_give_string (SWFDEC_AS_OBJECT (node)->context,
- unescaped);
- SWFDEC_AS_VALUE_SET_STRING (&val, value);
-
- swfdec_as_object_set_variable (node->attributes, name, &val);
- }
-
- g_return_val_if_fail (end + 1 > p, strchr (p, '\0'));
-
- return end + 1;
-}
-
-static const char *
-swfdec_xml_parse_tag (SwfdecXml *xml, SwfdecXmlNode **node, const char *p)
-{
- SwfdecAsObject *object;
- SwfdecXmlNode *child = NULL; // surpress warning
- char *name;
- const char *end;
- gboolean close;
-
- g_assert (p != NULL);
- g_return_val_if_fail (*p == '<', strchr (p, '\0'));
- g_return_val_if_fail (SWFDEC_IS_XML (xml), strchr (p, '\0'));
-
- object = SWFDEC_AS_OBJECT (xml);
-
- // closing tag or opening tag?
- if (*(p + 1) == '/') {
- close = TRUE;
- p++;
- } else {
- close = FALSE;
- }
-
- // find the end of the name
- end = p + strcspn (p, "> \r\n\t");
-
- // don't count trailing / as part of the name if it's followed by >
- // note we do this for close tags also, so <test/ ></test/> doesn't work
- if (*end == '>' && *(end - 1) == '/')
- end = end - 1;
-
- if (end - (p + 1) <= 0 || *end == '\0') {
- xml->status = XML_PARSE_STATUS_ELEMENT_MALFORMED;
- return strchr (p, '\0');
- }
-
- name = g_strndup (p + 1 , end - (p + 1));
-
- // create the new element
- if (!close) {
- child = swfdec_xml_node_new_no_properties (
- SWFDEC_AS_OBJECT (*node)->context, SWFDEC_XML_NODE_ELEMENT,
- swfdec_as_context_give_string (SWFDEC_AS_OBJECT (*node)->context,
- name));
- if (child == NULL)
- return strchr (p, '\0');
- }
-
- if (close) {
- end = strchr (end, '>');
- if (end == NULL)
- end = strchr (p, '\0');
- } else {
- end = end + strspn (end, " \r\n\t");
- while (*end != '\0' && *end != '>' && (*end != '/' || *(end + 1) != '>')) {
- end = swfdec_xml_parse_attribute (xml, child, end);
- end = end + strspn (end, " \r\n\t");
- }
- if (*end == '/')
- end += 1;
- }
-
- if (*end == '\0') {
- if (xml->status == XML_PARSE_STATUS_OK)
- xml->status = XML_PARSE_STATUS_ELEMENT_MALFORMED;
- if (close)
- g_free (name);
- return end;
- }
-
- if (close) {
- if ((*node)->parent != NULL && !g_ascii_strcasecmp ((*node)->name, name))
- {
- *node = (*node)->parent;
- }
- else // error
- {
- SwfdecXmlNode *iter = *node;
- while (iter != NULL && (iter->name == NULL || g_ascii_strcasecmp (iter->name, name))) {
- iter = iter->parent;
- }
- if (iter != NULL) {
- xml->status = XML_PARSE_STATUS_TAG_NOT_CLOSED;
- } else {
- xml->status = XML_PARSE_STATUS_TAG_MISMATCH;
- }
- }
- g_free (name);
- } else {
- const char *id;
-
- swfdec_xml_node_appendChild (*node, child);
-
- id = swfdec_xml_node_get_attribute (child, SWFDEC_AS_STR_id);
- if (id != NULL)
- swfdec_xml_add_id_map (xml, child, id);
-
- if (*(end - 1) != '/')
- *node = child;
- }
-
- end += 1;
-
- g_return_val_if_fail (end > p, strchr (p, '\0'));
-
- return end;
-}
-
-static const char *
-swfdec_xml_parse_text (SwfdecXml *xml, SwfdecXmlNode *node,
- const char *p, gboolean ignore_white)
-{
- SwfdecXmlNode *child;
- const char *end;
- char *text, *unescaped;
-
- g_assert (p != NULL);
- g_return_val_if_fail (*p != '\0', p);
- g_return_val_if_fail (SWFDEC_IS_XML (xml), strchr (p, '\0'));
-
- end = strchr (p, '<');
- if (end == NULL)
- end = strchr (p, '\0');
-
- if (!ignore_white || strspn (p, " \t\r\n") < (gsize)(end - p))
- {
- text = g_strndup (p, end - p);
- unescaped = swfdec_xml_unescape (SWFDEC_AS_OBJECT (xml)->context, text);
- g_free (text);
- child = swfdec_xml_node_new_no_properties (
- SWFDEC_AS_OBJECT (node)->context, SWFDEC_XML_NODE_TEXT,
- swfdec_as_context_give_string (SWFDEC_AS_OBJECT (xml)->context,
- unescaped));
- if (child == NULL)
- return strchr (p, '\0');
- swfdec_xml_node_appendChild (node, child);
- }
-
- g_return_val_if_fail (end > p, strchr (p, '\0'));
-
- return end;
-}
-
-static void
-swfdec_xml_parseXML (SwfdecXml *xml, const char *value)
-{
- SwfdecAsObject *object;
- SwfdecXmlNode *node;
- const char *p;
- gboolean ignore_white;
-
- g_return_if_fail (SWFDEC_IS_XML (xml));
- g_return_if_fail (value != NULL);
-
- object = SWFDEC_AS_OBJECT (xml);
-
- swfdec_xml_node_removeChildren (SWFDEC_XML_NODE (xml));
- xml->xml_decl = NULL;
- xml->doc_type_decl = NULL;
- xml->status = XML_PARSE_STATUS_OK;
-
- p = value;
- node = SWFDEC_XML_NODE (xml);
-
- // special case: we only use the ignoreWhite set at the start
- ignore_white = xml->ignore_white;
-
- while (xml->status == XML_PARSE_STATUS_OK && *p != '\0') {
- if (*p == '<') {
- if (g_ascii_strncasecmp (p + 1, "?xml", strlen ("?xml")) == 0) {
- p = swfdec_xml_parse_xmlDecl (xml, node, p);
- } else if (g_ascii_strncasecmp (p + 1, "!DOCTYPE", strlen ("!DOCTYPE")) == 0) {
- p = swfdec_xml_parse_docTypeDecl (xml, node, p);
- } else if (strncmp (p + 1, "!--", strlen ("!--")) == 0) {
- p = swfdec_xml_parse_comment (xml, p);
- } else {
- p = swfdec_xml_parse_tag (xml, &node, p);
- }
- } else {
- p = swfdec_xml_parse_text (xml, node, p, ignore_white);
- }
- g_assert (p != NULL);
- }
-
- if (xml->status == XML_PARSE_STATUS_OK && node != SWFDEC_XML_NODE (xml))
- xml->status = XML_PARSE_STATUS_TAG_NOT_CLOSED;
-}
-
-// this is an old XML parsing function that is only available trough the
-// ASnative code
-SWFDEC_AS_NATIVE (300, 0, swfdec_xml_do_oldParseXML)
-void
-swfdec_xml_do_oldParseXML (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SWFDEC_STUB ("XML.oldParseXML (not-really-named)");
-}
-
-SWFDEC_AS_NATIVE (253, 12, swfdec_xml_do_parseXML)
-void
-swfdec_xml_do_parseXML (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
- SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- if (!SWFDEC_IS_XML (object))
- return;
-
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- if (argc < 1)
- return;
-
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
- return;
-
- swfdec_xml_parseXML (SWFDEC_XML (object),
- swfdec_as_value_to_string (cx, &argv[0]));
-}
-
-SWFDEC_AS_NATIVE (253, 10, swfdec_xml_createElement)
-void
-swfdec_xml_createElement (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecXmlNode *node;
-
- if (!SWFDEC_IS_XML (object))
- return;
-
- if (argc < 1)
- return;
-
- // special case
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
- return;
-
- node = swfdec_xml_node_new (cx, SWFDEC_XML_NODE_ELEMENT,
- swfdec_as_value_to_string (cx, &argv[0]));
- if (node == NULL)
- return;
-
- SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (node));
-}
-
-SWFDEC_AS_NATIVE (253, 11, swfdec_xml_createTextNode)
-void
-swfdec_xml_createTextNode (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
- SwfdecXmlNode *node;
-
- if (!SWFDEC_IS_XML (object))
- return;
-
- if (argc < 1)
- return;
-
- // special case
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
- return;
-
- node = swfdec_xml_node_new (cx, SWFDEC_XML_NODE_TEXT,
- swfdec_as_value_to_string (cx, &argv[0]));
- if (node == NULL)
- return;
-
- SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (node));
-}
-
-static void
-swfdec_xml_init_properties (SwfdecAsContext *cx)
-{
- SwfdecAsValue val;
- SwfdecAsObject *xml, *proto;
-
- // FIXME: We should only initialize if the prototype Object has not been
- // initialized by any object's constructor with native properties
- // (TextField, TextFormat, XML, XMLNode at least)
-
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (cx));
-
- swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_XML, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return;
- xml = SWFDEC_AS_VALUE_GET_OBJECT (&val);
-
- swfdec_as_object_get_variable (xml, SWFDEC_AS_STR_prototype, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return;
- proto = SWFDEC_AS_VALUE_GET_OBJECT (&val);
-
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_ignoreWhite,
- swfdec_xml_get_ignoreWhite, swfdec_xml_set_ignoreWhite);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_status,
- swfdec_xml_get_status, swfdec_xml_set_status);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_xmlDecl,
- swfdec_xml_get_xmlDecl, swfdec_xml_set_xmlDecl);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_docTypeDecl,
- swfdec_xml_get_docTypeDecl, swfdec_xml_set_docTypeDecl);
-
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_contentType,
- swfdec_xml_get_contentType, swfdec_xml_set_contentType);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_loaded,
- swfdec_xml_get_loaded, swfdec_xml_set_loaded);
-}
-
-SWFDEC_AS_CONSTRUCTOR (253, 9, swfdec_xml_construct, swfdec_xml_get_type)
-void
-swfdec_xml_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!swfdec_as_context_is_constructing (cx))
- return;
-
- g_assert (SWFDEC_IS_XML (object));
-
- swfdec_xml_init_properties (cx);
-
- swfdec_xml_node_init_values (SWFDEC_XML_NODE (object),
- SWFDEC_XML_NODE_ELEMENT, SWFDEC_AS_STR_EMPTY);
-
- SWFDEC_AS_VALUE_SET_STRING (&SWFDEC_XML (object)->content_type,
- SWFDEC_AS_STR_application_x_www_form_urlencoded);
-
- SWFDEC_XML_NODE (object)->name = NULL;
-
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- if (argc >= 1 && !SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0])) {
- swfdec_xml_parseXML (SWFDEC_XML (object),
- swfdec_as_value_to_string (cx, &argv[0]));
- }
-}
-
-SwfdecXml *
-swfdec_xml_new_no_properties (SwfdecAsContext *context, const char *str,
- gboolean ignore_white)
-{
- SwfdecAsValue val;
- SwfdecXml *xml;
- guint size;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
-
- size = sizeof (SwfdecXml);
- if (!swfdec_as_context_use_mem (context, size))
- return NULL;
- xml = g_object_new (SWFDEC_TYPE_XML, NULL);
- swfdec_as_object_add (SWFDEC_AS_OBJECT (xml), context, size);
- swfdec_as_object_get_variable (context->global, SWFDEC_AS_STR_XML, &val);
- if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
- swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (xml),
- SWFDEC_AS_VALUE_GET_OBJECT (&val));
- }
-
- xml->ignore_white = ignore_white;
-
- swfdec_xml_node_init_values (SWFDEC_XML_NODE (xml),
- SWFDEC_XML_NODE_ELEMENT, SWFDEC_AS_STR_EMPTY);
-
- SWFDEC_AS_VALUE_SET_STRING (&xml->content_type,
- SWFDEC_AS_STR_application_x_www_form_urlencoded);
-
- if (str != NULL)
- swfdec_xml_parseXML (xml, str);
-
- return xml;
-}
-
-SwfdecXml *
-swfdec_xml_new (SwfdecAsContext *context, const char *str,
- gboolean ignore_white)
-{
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
-
- swfdec_xml_init_properties (context);
-
- return swfdec_xml_new_no_properties (context, str, ignore_white);
-}
diff --git a/libswfdec/swfdec_xml.h b/libswfdec/swfdec_xml.h
deleted file mode 100644
index 3be92d5..0000000
--- a/libswfdec/swfdec_xml.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_XML_H_
-#define _SWFDEC_XML_H_
-
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_script.h>
-#include <libswfdec/swfdec_xml_node.h>
-
-G_BEGIN_DECLS
-
-typedef struct _SwfdecXml SwfdecXml;
-typedef struct _SwfdecXmlClass SwfdecXmlClass;
-
-#define SWFDEC_TYPE_XML (swfdec_xml_get_type())
-#define SWFDEC_IS_XML(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_XML))
-#define SWFDEC_IS_XML_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_XML))
-#define SWFDEC_XML(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_XML, SwfdecXml))
-#define SWFDEC_XML_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_XML, SwfdecXmlClass))
-#define SWFDEC_XML_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_XML, SwfdecXmlClass))
-
-typedef enum {
- XML_PARSE_STATUS_OK = 0,
- XML_PARSE_STATUS_CDATA_NOT_TERMINATED = -2,
- XML_PARSE_STATUS_XMLDECL_NOT_TERMINATED = -3,
- XML_PARSE_STATUS_DOCTYPEDECL_NOT_TERMINATED = -4,
- XML_PARSE_STATUS_COMMENT_NOT_TERMINATED = -5,
- XML_PARSE_STATUS_ELEMENT_MALFORMED = -6,
- XML_PARSE_STATUS_OUT_OF_MEMORY = -7,
- XML_PARSE_STATUS_ATTRIBUTE_NOT_TERMINATED = -8,
- XML_PARSE_STATUS_TAG_NOT_CLOSED = -9, // FIXME are the two correct?
- XML_PARSE_STATUS_TAG_MISMATCH = -10
-} SwfdecXmlParseStatus;
-
-struct _SwfdecXml {
- SwfdecXmlNode xml_node;
-
- gboolean ignore_white;
- int status;
- const char *xml_decl;
- const char *doc_type_decl;
-
- SwfdecAsValue content_type;
- SwfdecAsValue loaded;
-};
-
-struct _SwfdecXmlClass {
- SwfdecXmlNodeClass xml_node_class;
-};
-
-GType swfdec_xml_get_type (void);
-
-char * swfdec_xml_escape (const char * orginal);
-char * swfdec_xml_escape_len (const char * orginal,
- gssize length);
-char * swfdec_xml_unescape (SwfdecAsContext * cx,
- const char * orginal);
-char * swfdec_xml_unescape_len (SwfdecAsContext * cx,
- const char * orginal,
- gssize length,
- gboolean unescape_nbsp);
-
-SwfdecXml * swfdec_xml_new (SwfdecAsContext * context,
- const char * str,
- gboolean ignore_white);
-SwfdecXml * swfdec_xml_new_no_properties (SwfdecAsContext * context,
- const char * str,
- gboolean ignore_white);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_xml_node.c b/libswfdec/swfdec_xml_node.c
deleted file mode 100644
index b0d35aa..0000000
--- a/libswfdec/swfdec_xml_node.c
+++ /dev/null
@@ -1,1113 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "swfdec_xml_node.h"
-#include "swfdec_xml.h"
-#include "swfdec_as_array.h"
-#include "swfdec_as_native_function.h"
-#include "swfdec_as_object.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_debug.h"
-#include "swfdec_internal.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_load_object.h"
-#include "swfdec_player_internal.h"
-
-G_DEFINE_TYPE (SwfdecXmlNode, swfdec_xml_node, SWFDEC_TYPE_AS_OBJECT)
-
-static void
-swfdec_xml_node_do_mark (SwfdecAsObject *object)
-{
- SwfdecXmlNode *node = SWFDEC_XML_NODE (object);
-
- if (node->name != NULL)
- swfdec_as_string_mark (node->name);
- if (node->value != NULL)
- swfdec_as_string_mark (node->value);
- if (node->parent != NULL)
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (node->parent));
- if (node->children != NULL)
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (node->children));
- if (node->attributes != NULL)
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (node->attributes));
- if (node->child_nodes != NULL)
- swfdec_as_object_mark (SWFDEC_AS_OBJECT (node->child_nodes));
-
- SWFDEC_AS_OBJECT_CLASS (swfdec_xml_node_parent_class)->mark (object);
-}
-
-static void
-swfdec_xml_node_class_init (SwfdecXmlNodeClass *klass)
-{
- SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
-
- asobject_class->mark = swfdec_xml_node_do_mark;
-}
-
-static void
-swfdec_xml_node_init (SwfdecXmlNode *xml_node)
-{
-}
-
-/*** AS CODE ***/
-
-gint32
-swfdec_xml_node_num_children (SwfdecXmlNode *node)
-{
- g_return_val_if_fail (SWFDEC_IS_VALID_XML_NODE (node), 0);
-
- return swfdec_as_array_get_length (node->children);
-}
-
-SwfdecXmlNode *
-swfdec_xml_node_get_child (SwfdecXmlNode *node, gint32 index_)
-{
- SwfdecAsValue val;
-
- g_return_val_if_fail (SWFDEC_IS_VALID_XML_NODE (node), NULL);
- g_return_val_if_fail (index_ >= 0, NULL);
-
- if (index_ >= swfdec_xml_node_num_children (node))
- return NULL;
-
- swfdec_as_array_get_value (node->children, index_, &val);
-
- g_return_val_if_fail (SWFDEC_AS_VALUE_IS_OBJECT (&val), NULL);
- g_return_val_if_fail (SWFDEC_IS_VALID_XML_NODE (
- SWFDEC_AS_VALUE_GET_OBJECT (&val)), NULL);
-
- return SWFDEC_XML_NODE (SWFDEC_AS_VALUE_GET_OBJECT (&val));
-}
-
-static gint32
-swfdec_xml_node_index_of_child (SwfdecXmlNode *node, SwfdecXmlNode *child)
-{
- gint32 num, i;
-
- g_return_val_if_fail (SWFDEC_IS_VALID_XML_NODE (node), -1);
- g_return_val_if_fail (SWFDEC_IS_VALID_XML_NODE (child), -1);
-
- num = swfdec_xml_node_num_children (node);
- for (i = 0; i < num; i++) {
- if (swfdec_xml_node_get_child (node, i) == child)
- return i;
- }
-
- return -1;
-}
-
-static void
-swfdec_xml_node_update_child_nodes (SwfdecXmlNode *node)
-{
- SwfdecAsValue val;
- SwfdecAsValue *vals;
- gint32 num, i;
-
- g_return_if_fail (SWFDEC_IS_VALID_XML_NODE (node));
-
- // remove old
- SWFDEC_AS_VALUE_SET_INT (&val, 0);
- swfdec_as_object_set_variable (SWFDEC_AS_OBJECT (node->child_nodes),
- SWFDEC_AS_STR_length, &val);
-
- // add everything
- num = swfdec_xml_node_num_children (node);
- vals = g_malloc (sizeof (SwfdecAsValue) * num);
- for (i = 0; i < num; i++) {
- SWFDEC_AS_VALUE_SET_OBJECT (&vals[i],
- SWFDEC_AS_OBJECT (swfdec_xml_node_get_child (node, i)));
- }
- swfdec_as_array_append_with_flags (node->child_nodes, num, vals,
- SWFDEC_AS_VARIABLE_CONSTANT);
- g_free (vals);
-}
-
-const char *
-swfdec_xml_node_get_attribute (SwfdecXmlNode *node, const char *name)
-{
- SwfdecAsValue val;
-
- g_return_val_if_fail (SWFDEC_IS_VALID_XML_NODE (node), NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- if (swfdec_as_object_get_variable (node->attributes, name, &val)) {
- return swfdec_as_value_to_string (SWFDEC_AS_OBJECT (node)->context, &val);
- } else {
- return NULL;
- }
-}
-
-static const char *
-swfdec_xml_node_getNamespaceForPrefix (SwfdecXmlNode *node, const char *prefix)
-{
- const char *var;
- SwfdecAsValue val;
-
- g_return_val_if_fail (SWFDEC_IS_VALID_XML_NODE (node), NULL);
-
- if (prefix == NULL || strlen (prefix) == 0) {
- var = swfdec_as_context_get_string (SWFDEC_AS_OBJECT (node)->context,
- "xmlns");
- } else {
- var = swfdec_as_context_give_string (SWFDEC_AS_OBJECT (node)->context,
- g_strconcat ("xmlns:", prefix, NULL));
- }
-
- do {
- swfdec_as_object_get_variable (node->attributes, var, &val);
- if (!SWFDEC_AS_VALUE_IS_UNDEFINED (&val)) {
- return swfdec_as_value_to_string (SWFDEC_AS_OBJECT (node)->context, &val);
- }
- node = node->parent;
- } while (node != NULL);
-
- return NULL;
-}
-
-typedef struct {
- const char *namespace;
- const char *variable;
-} ForeachFindNamespaceData;
-
-static gboolean
-swfdec_xml_node_foreach_find_namespace (SwfdecAsObject *object,
- const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
-{
- const char *uri;
- ForeachFindNamespaceData *fdata = data;
-
- // check whether it's namespace variable (xmlns or xmlns:*)
- if (strlen (variable) < strlen("xmlns"))
- return TRUE;
-
- if (g_ascii_strncasecmp (variable, "xmlns", strlen("xmlns")))
- return TRUE;
-
- if (variable[strlen("xmlns")] != '\0' && variable[strlen("xmlns")] != ':')
- return TRUE;
-
- // ok, now check if the uri is the one we are searching for
- uri = swfdec_as_value_to_string (object->context, value);
- if (!g_ascii_strcasecmp (uri, fdata->namespace)) {
- fdata->variable = variable;
- return FALSE;
- } else {
- return TRUE;
- }
-}
-
-static const char *
-swfdec_xml_node_getPrefixForNamespace (SwfdecXmlNode *node,
- const char *namespace)
-{
- ForeachFindNamespaceData fdata;
-
- g_return_val_if_fail (SWFDEC_IS_VALID_XML_NODE (node), NULL);
- g_return_val_if_fail (namespace != NULL, NULL);
-
- fdata.namespace = namespace;
- fdata.variable = NULL;
-
- do {
- swfdec_as_object_foreach (node->attributes,
- swfdec_xml_node_foreach_find_namespace, &fdata);
- node = node->parent;
- } while (node != NULL && fdata.variable == NULL);
-
- if (fdata.variable != NULL) {
- const char *p;
-
- p = strchr (fdata.variable, ':');
- if (p == NULL || *(p + 1) == '\0')
- return SWFDEC_AS_STR_EMPTY;
-
- return swfdec_as_context_get_string (SWFDEC_AS_OBJECT (node)->context,
- p + 1);
- } else {
- return NULL;
- }
-}
-
-static void
-swfdec_xml_node_get_nodeType (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- SWFDEC_AS_VALUE_SET_INT (ret, SWFDEC_XML_NODE (object)->type);
-}
-
-static void
-swfdec_xml_node_get_nodeValue (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- if (SWFDEC_XML_NODE (object)->value != NULL) {
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_XML_NODE (object)->value);
- } else {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- }
-}
-
-static void
-swfdec_xml_node_set_nodeValue (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *value;
-
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- if (argc < 1)
- return;
-
- value = swfdec_as_value_to_string (cx, &argv[0]);
-
- SWFDEC_XML_NODE (object)->value = value;
- SWFDEC_AS_VALUE_SET_STRING (ret, value);
-}
-
-static void
-swfdec_xml_node_get_nodeName (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- if (SWFDEC_XML_NODE (object)->name != NULL) {
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_XML_NODE (object)->name);
- } else {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- }
-}
-
-static void
-swfdec_xml_node_set_nodeName (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *name;
-
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- if (argc < 1)
- return;
-
- // special case
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
- return;
-
- name = swfdec_as_value_to_string (cx, &argv[0]);
-
- SWFDEC_XML_NODE (object)->name = name;
- SWFDEC_AS_VALUE_SET_STRING (ret, name);
-}
-
-static const char *
-swfdec_xml_node_get_prefix (SwfdecXmlNode *node)
-{
- const char *p;
-
- g_return_val_if_fail (SWFDEC_IS_VALID_XML_NODE (node), NULL);
-
- if (node->name == NULL)
- return NULL;
-
- p = strchr (node->name, ':');
- if (p == NULL || *(p + 1) == '\0')
- return NULL;
-
- return swfdec_as_context_give_string (SWFDEC_AS_OBJECT (node)->context,
- g_strndup (node->name, p - node->name));
-}
-
-static void
-swfdec_xml_node_do_get_prefix (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *prefix;
-
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- if (SWFDEC_XML_NODE (object)->name == NULL) {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- return;
- }
-
- prefix = swfdec_xml_node_get_prefix (SWFDEC_XML_NODE (object));
- if (prefix != NULL) {
- SWFDEC_AS_VALUE_SET_STRING (ret, prefix);
- } else {
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_EMPTY);
- }
-}
-
-static void
-swfdec_xml_node_get_localName (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *p, *name;
-
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- if (SWFDEC_XML_NODE (object)->name == NULL) {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- return;
- }
-
- name = SWFDEC_XML_NODE (object)->name;
- p = strchr (name, ':');
- if (p == NULL || *(p + 1) == '\0') {
- SWFDEC_AS_VALUE_SET_STRING (ret, name);
- return;
- }
- p++;
-
- SWFDEC_AS_VALUE_SET_STRING (ret,
- swfdec_as_context_give_string (cx, g_strdup (p)));
-}
-
-static void
-swfdec_xml_node_get_namespaceURI (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *uri;
-
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- if (SWFDEC_XML_NODE (object)->name == NULL) {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- return;
- }
-
- uri = swfdec_xml_node_getNamespaceForPrefix (SWFDEC_XML_NODE (object),
- swfdec_xml_node_get_prefix (SWFDEC_XML_NODE (object)));
- if (uri != NULL) {
- SWFDEC_AS_VALUE_SET_STRING (ret, uri);
- } else {
- SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_EMPTY);
- }
-}
-
-static void
-swfdec_xml_node_get_attributes (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_XML_NODE (object)->attributes);
-}
-
-static void
-swfdec_xml_node_get_parentNode (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- if (SWFDEC_XML_NODE (object)->parent != NULL) {
- SWFDEC_AS_VALUE_SET_OBJECT (ret,
- SWFDEC_AS_OBJECT (SWFDEC_XML_NODE (object)->parent));
- } else {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- }
-}
-
-static SwfdecXmlNode *
-swfdec_xml_node_previousSibling (SwfdecXmlNode *node)
-{
- gint32 i;
-
- if (node->parent == NULL)
- return NULL;
-
- i = swfdec_xml_node_index_of_child (node->parent, node);
- g_assert (i >= 0);
-
- if (i <= 0)
- return NULL;
-
- return swfdec_xml_node_get_child (node->parent, i - 1);
-}
-
-static void
-swfdec_xml_node_get_previousSibling (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecXmlNode *sibling;
-
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- sibling = swfdec_xml_node_previousSibling (SWFDEC_XML_NODE (object));
- if (sibling != NULL) {
- SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (sibling));
- } else {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- }
-}
-
-static SwfdecXmlNode *
-swfdec_xml_node_nextSibling (SwfdecXmlNode *node)
-{
- gint32 i;
-
- if (node->parent == NULL)
- return NULL;
-
- i = swfdec_xml_node_index_of_child (node->parent, node);
- g_assert (i >= 0);
-
- return swfdec_xml_node_get_child (node->parent, i + 1);
-}
-
-static void
-swfdec_xml_node_get_nextSibling (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecXmlNode *sibling;
-
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- sibling = swfdec_xml_node_nextSibling (SWFDEC_XML_NODE (object));
- if (sibling != NULL) {
- SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (sibling));
- } else {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- }
-}
-
-static void
-swfdec_xml_node_get_firstChild (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecXmlNode *child;
-
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- child = swfdec_xml_node_get_child (SWFDEC_XML_NODE (object), 0);
- if (child != NULL) {
- SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (child));
- } else {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- }
-}
-
-static void
-swfdec_xml_node_get_lastChild (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- gint32 num;
- SwfdecXmlNode *child;
-
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- num = swfdec_xml_node_num_children (SWFDEC_XML_NODE (object));
- if (num == 0) {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- return;
- }
-
- child = swfdec_xml_node_get_child (SWFDEC_XML_NODE (object), num - 1);
- g_assert (child != NULL);
-
- SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (child));
-}
-
-static void
-swfdec_xml_node_get_childNodes (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- SWFDEC_AS_VALUE_SET_OBJECT (ret,
- SWFDEC_AS_OBJECT (SWFDEC_XML_NODE (object)->child_nodes));
-}
-
-SWFDEC_AS_NATIVE (253, 7, swfdec_xml_node_do_getNamespaceForPrefix)
-void
-swfdec_xml_node_do_getNamespaceForPrefix (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *namespace;
-
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- if (argc < 1) {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- return;
- }
-
- namespace = swfdec_xml_node_getNamespaceForPrefix (SWFDEC_XML_NODE (object),
- swfdec_as_value_to_string (cx, &argv[0]));
-
- if (namespace != NULL) {
- SWFDEC_AS_VALUE_SET_STRING (ret, namespace);
- } else {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- }
-}
-
-SWFDEC_AS_NATIVE (253, 8, swfdec_xml_node_do_getPrefixForNamespace)
-void
-swfdec_xml_node_do_getPrefixForNamespace (SwfdecAsContext *cx,
- SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *prefix;
-
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- if (argc < 1) {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- return;
- }
-
- prefix = swfdec_xml_node_getPrefixForNamespace (SWFDEC_XML_NODE (object),
- swfdec_as_value_to_string (cx, &argv[0]));
-
- if (prefix != NULL) {
- SWFDEC_AS_VALUE_SET_STRING (ret, prefix);
- } else {
- SWFDEC_AS_VALUE_SET_NULL (ret);
- }
-}
-
-static gboolean
-swfdec_xml_node_foreach_copy_attributes (SwfdecAsObject *object,
- const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
-{
- SwfdecAsObject *target = data;
- swfdec_as_object_set_variable (target, variable, value);
- return TRUE;
-}
-
-static void
-swfdec_xml_node_copy_attributes (SwfdecXmlNode *node, SwfdecXmlNode *target)
-{
- swfdec_as_object_foreach (node->attributes,
- swfdec_xml_node_foreach_copy_attributes, target->attributes);
-}
-
-static SwfdecXmlNode *
-swfdec_xml_node_clone (SwfdecAsContext *cx, SwfdecXmlNode *node, gboolean deep)
-{
- SwfdecXmlNode *new;
-
- g_assert (SWFDEC_IS_AS_CONTEXT (cx));
- g_assert (SWFDEC_IS_VALID_XML_NODE (node));
-
- new = swfdec_xml_node_new (cx, SWFDEC_XML_NODE_ELEMENT, SWFDEC_AS_STR_EMPTY);
- if (new == NULL)
- return NULL;
-
- new->valid = TRUE;
- new->type = node->type;
- new->name = node->name;
- new->value = node->value;
-
- swfdec_xml_node_copy_attributes (node, new);
-
- if (deep) {
- SwfdecAsValue val;
- SwfdecXmlNode *child, *child_new;
- gint32 num, i;
-
- num = swfdec_xml_node_num_children (node);
-
- for (i = 0; i < num; i++) {
- child = swfdec_xml_node_get_child (node, i);
- child_new = swfdec_xml_node_clone (cx, child, TRUE);
- if (child_new == NULL)
- return NULL;
- child_new->parent = new;
- SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (child_new));
- swfdec_as_array_push (new->children, &val);
- }
-
- swfdec_xml_node_update_child_nodes (new);
- }
-
- return new;
-}
-
-SWFDEC_AS_NATIVE (253, 1, swfdec_xml_node_cloneNode)
-void
-swfdec_xml_node_cloneNode (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- gboolean deep;
- SwfdecXmlNode *new;
-
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- if (argc >= 1) {
- deep = swfdec_as_value_to_boolean (cx, &argv[0]);
- } else {
- deep = FALSE;
- }
-
- new = swfdec_xml_node_clone (cx, SWFDEC_XML_NODE (object), deep);
- if (new == NULL)
- return;
-
- SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (new));
-}
-
-void
-swfdec_xml_node_removeNode (SwfdecXmlNode *node)
-{
- gint32 i;
-
- g_return_if_fail (SWFDEC_IS_VALID_XML_NODE (node));
-
- if (node->parent == NULL)
- return;
-
- i = swfdec_xml_node_index_of_child (node->parent, node);
- g_assert (i >= 0);
-
- swfdec_as_array_remove (node->parent->children, i);
- swfdec_xml_node_update_child_nodes (node->parent);
- node->parent = NULL;
-}
-
-SWFDEC_AS_NATIVE (253, 2, swfdec_xml_node_do_removeNode)
-void
-swfdec_xml_node_do_removeNode (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- swfdec_xml_node_removeNode (SWFDEC_XML_NODE (object));
-}
-
-void
-swfdec_xml_node_removeChildren (SwfdecXmlNode *node)
-{
- gint32 num, i;
-
- g_return_if_fail (SWFDEC_IS_VALID_XML_NODE (node));
-
- num = swfdec_xml_node_num_children (node);
-
- for (i = 0; i < num; i++) {
- swfdec_xml_node_removeNode (swfdec_xml_node_get_child (node, 0));
- }
-}
-
-static void
-swfdec_xml_node_insertAt (SwfdecXmlNode *node, SwfdecXmlNode *child, gint32 ind)
-{
- SwfdecAsValue val;
-
- g_assert (SWFDEC_IS_VALID_XML_NODE (node));
- g_assert (SWFDEC_IS_VALID_XML_NODE (child));
- g_assert (ind >= 0);
-
- if (SWFDEC_AS_OBJECT (node)->context->version >= 8) {
- SwfdecXmlNode *parent = node;
- while (parent != NULL) {
- if (parent == child)
- return;
- parent = parent->parent;
- }
- }
-
- // remove the previous parent of the child
- swfdec_xml_node_removeNode (child);
-
- // insert child to node's child_nodes array
- SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (child));
- swfdec_as_array_insert (node->children, ind, &val);
- swfdec_xml_node_update_child_nodes (node);
-
- // set node as parent of child
- child->parent = node;
-}
-
-SWFDEC_AS_NATIVE (253, 3, swfdec_xml_node_insertBefore)
-void
-swfdec_xml_node_insertBefore (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- gint32 i;
- SwfdecAsObject *child, *point;
-
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- if (argc < 2)
- return;
-
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]))
- return;
-
- child = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
- if (!SWFDEC_IS_VALID_XML_NODE (child))
- return;
-
- // special case
- if (swfdec_xml_node_index_of_child (SWFDEC_XML_NODE (object),
- SWFDEC_XML_NODE (child)) != -1)
- return;
-
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[1]))
- return;
-
- point = SWFDEC_AS_VALUE_GET_OBJECT (&argv[1]);
- if (!SWFDEC_IS_VALID_XML_NODE (point))
- return;
-
- i = swfdec_xml_node_index_of_child (SWFDEC_XML_NODE (object),
- SWFDEC_XML_NODE (point));
-
- if (i != -1) {
- swfdec_xml_node_insertAt (SWFDEC_XML_NODE (object),
- SWFDEC_XML_NODE (child), i);
- }
-}
-
-void
-swfdec_xml_node_appendChild (SwfdecXmlNode *node, SwfdecXmlNode *child)
-{
- g_return_if_fail (SWFDEC_IS_VALID_XML_NODE (node));
- g_return_if_fail (SWFDEC_IS_VALID_XML_NODE (child));
- g_return_if_fail (node->children != NULL);
-
- swfdec_xml_node_insertAt (node, child,
- swfdec_as_array_get_length (node->children));
-}
-
-SWFDEC_AS_NATIVE (253, 4, swfdec_xml_node_do_appendChild)
-void
-swfdec_xml_node_do_appendChild (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SwfdecAsObject *child;
-
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- if (argc < 1)
- return;
-
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]))
- return;
-
- child = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
- if (!SWFDEC_IS_VALID_XML_NODE (child))
- return;
-
- // special case
- if (swfdec_xml_node_index_of_child (SWFDEC_XML_NODE (object),
- SWFDEC_XML_NODE (child)) != -1)
- return;
-
- swfdec_xml_node_appendChild (SWFDEC_XML_NODE (object),
- SWFDEC_XML_NODE (child));
-}
-
-SWFDEC_AS_NATIVE (253, 5, swfdec_xml_node_hasChildNodes)
-void
-swfdec_xml_node_hasChildNodes (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- if (swfdec_xml_node_num_children (SWFDEC_XML_NODE (object)) > 0) {
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, TRUE);
- } else {
- SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
- }
-}
-
-static gboolean
-swfdec_xml_node_foreach_string_append_attribute (SwfdecAsObject *object,
- const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
-{
- GString *string = *(GString **)data;
- char *escaped;
-
- string = g_string_append (string, " ");
- string = g_string_append (string, variable);
- string = g_string_append (string, "=\"");
- escaped =
- swfdec_xml_escape (swfdec_as_value_to_string (object->context, value));
- string = g_string_append (string, escaped);
- g_free (escaped);
- string = g_string_append (string, "\"");
-
- return TRUE;
-}
-
-static const char *
-swfdec_xml_node_toString (SwfdecXmlNode *node)
-{
- GString *string;
- SwfdecAsObject *object;
-
- g_assert (SWFDEC_IS_VALID_XML_NODE (node));
-
- object = SWFDEC_AS_OBJECT (node);
-
- string = g_string_new ("");
- if (SWFDEC_IS_XML (node)) {
- if (SWFDEC_XML (node)->xml_decl != NULL)
- string = g_string_append (string, SWFDEC_XML (node)->xml_decl);
- if (SWFDEC_XML (node)->doc_type_decl != NULL)
- string = g_string_append (string, SWFDEC_XML (node)->doc_type_decl);
- }
-
- switch (node->type) {
- case SWFDEC_XML_NODE_ELEMENT:
- {
- SwfdecXmlNode *child;
- gint32 i, num;
- gboolean visible;
-
- if (node->name == NULL) {
- visible = FALSE;
- } else {
- visible = TRUE;
- }
-
- if (visible) {
- string = g_string_append (string, "<");
- string = g_string_append (string, node->name);
-
- swfdec_as_object_foreach (node->attributes,
- swfdec_xml_node_foreach_string_append_attribute, &string);
- }
-
- num = swfdec_xml_node_num_children (node);
-
- if (num > 0) {
- if (visible)
- string = g_string_append (string, ">");
-
- for (i = 0; i < num; i++) {
- child = swfdec_xml_node_get_child (node, i);
- g_assert (child != NULL);
- string = g_string_append (string, swfdec_xml_node_toString (child));
- }
-
- if (visible) {
- string = g_string_append (string, "</");
- string = g_string_append (string, node->name);
- string = g_string_append (string, ">");
- }
- } else {
- if (visible)
- string = g_string_append (string, " />");
- }
-
- break;
- }
- case SWFDEC_XML_NODE_TEXT:
- default:
- {
- char *escaped = swfdec_xml_escape (node->value);
- string = g_string_append (string, escaped);
- g_free (escaped);
- break;
- }
- }
-
- return swfdec_as_context_give_string (object->context,
- g_string_free (string, FALSE));
-}
-
-SWFDEC_AS_NATIVE (253, 6, swfdec_xml_node_do_toString)
-void
-swfdec_xml_node_do_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!SWFDEC_IS_VALID_XML_NODE (object))
- return;
-
- SWFDEC_AS_VALUE_SET_STRING (ret,
- swfdec_xml_node_toString (SWFDEC_XML_NODE (object)));
-}
-
-void
-swfdec_xml_node_init_values (SwfdecXmlNode *node, int type, const char* value)
-{
- SwfdecAsObject *object;
-
- g_return_if_fail (SWFDEC_IS_XML_NODE (node));
- g_return_if_fail (value != NULL);
-
- object = SWFDEC_AS_OBJECT (node);
-
- node->valid = TRUE;
- node->parent = NULL;
- node->children = SWFDEC_AS_ARRAY (swfdec_as_array_new (object->context));
- node->attributes = swfdec_as_object_new_empty (object->context);
- node->type = type;
- if (node->type == SWFDEC_XML_NODE_ELEMENT) {
- node->name = value;
- } else {
- node->value = value;
- }
-
- node->child_nodes = SWFDEC_AS_ARRAY (swfdec_as_array_new (object->context));
-
- if (node->children == NULL || node->attributes == NULL ||
- node->child_nodes == NULL) {
- node->valid = FALSE;
- }
-}
-
-static void
-swfdec_xml_node_init_properties (SwfdecAsContext *cx)
-{
- SwfdecAsValue val;
- SwfdecAsObject *node, *proto;
-
- // FIXME: We should only initialize if the prototype Object has not been
- // initialized by any object's constructor with native properties
- // (TextField, TextFormat, XML, XMLNode at least)
-
- g_return_if_fail (SWFDEC_IS_AS_CONTEXT (cx));
-
- swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_XMLNode, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return;
- node = SWFDEC_AS_VALUE_GET_OBJECT (&val);
-
- swfdec_as_object_get_variable (node, SWFDEC_AS_STR_prototype, &val);
- if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
- return;
- proto = SWFDEC_AS_VALUE_GET_OBJECT (&val);
-
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_nodeType,
- swfdec_xml_node_get_nodeType, NULL);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_nodeValue,
- swfdec_xml_node_get_nodeValue, swfdec_xml_node_set_nodeValue);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_nodeName,
- swfdec_xml_node_get_nodeName, swfdec_xml_node_set_nodeName);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_prefix,
- swfdec_xml_node_do_get_prefix, NULL);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_localName,
- swfdec_xml_node_get_localName, NULL);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_namespaceURI,
- swfdec_xml_node_get_namespaceURI, NULL);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_attributes,
- swfdec_xml_node_get_attributes, NULL);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_parentNode,
- swfdec_xml_node_get_parentNode, NULL);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_previousSibling,
- swfdec_xml_node_get_previousSibling, NULL);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_nextSibling,
- swfdec_xml_node_get_nextSibling, NULL);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_firstChild,
- swfdec_xml_node_get_firstChild, NULL);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_lastChild,
- swfdec_xml_node_get_lastChild, NULL);
- swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_childNodes,
- swfdec_xml_node_get_childNodes, NULL);
-}
-
-SwfdecXmlNode *
-swfdec_xml_node_new_no_properties (SwfdecAsContext *context,
- SwfdecXmlNodeType type, const char* value)
-{
- SwfdecAsValue val;
- SwfdecXmlNode *node;
- guint size;
-
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
- g_return_val_if_fail (value != NULL, NULL);
-
- size = sizeof (SwfdecXmlNode);
- if (!swfdec_as_context_use_mem (context, size))
- return NULL;
- node = g_object_new (SWFDEC_TYPE_XML_NODE, NULL);
- swfdec_as_object_add (SWFDEC_AS_OBJECT (node), context, size);
- swfdec_as_object_get_variable (context->global, SWFDEC_AS_STR_XMLNode, &val);
- if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
- swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (node),
- SWFDEC_AS_VALUE_GET_OBJECT (&val));
- }
-
- swfdec_xml_node_init_values (node, type, value);
-
- return node;
-}
-
-SwfdecXmlNode *
-swfdec_xml_node_new (SwfdecAsContext *context, SwfdecXmlNodeType type,
- const char* value)
-{
- g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
-
- swfdec_xml_node_init_properties (context);
-
- return swfdec_xml_node_new_no_properties (context, type, value);
-}
-
-SWFDEC_AS_CONSTRUCTOR (253, 0, swfdec_xml_node_construct, swfdec_xml_node_get_type)
-void
-swfdec_xml_node_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- if (!swfdec_as_context_is_constructing (cx))
- return;
-
- g_assert (SWFDEC_IS_XML_NODE (object));
-
- if (argc < 2)
- return;
-
- // special case
- if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]) ||
- SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[1]))
- return;
-
- swfdec_xml_node_init_properties (cx);
-
- swfdec_xml_node_init_values (SWFDEC_XML_NODE (object),
- swfdec_as_value_to_integer (cx, &argv[0]),
- swfdec_as_value_to_string (cx, &argv[1]));
-
- SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
-}
diff --git a/libswfdec/swfdec_xml_node.h b/libswfdec/swfdec_xml_node.h
deleted file mode 100644
index 7135613..0000000
--- a/libswfdec/swfdec_xml_node.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- * 2007 Pekka Lampila <pekka.lampila at iki.fi>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_XML_NODE_H_
-#define _SWFDEC_XML_NODE_H_
-
-#include <libswfdec/swfdec_as_object.h>
-#include <libswfdec/swfdec_types.h>
-#include <libswfdec/swfdec_script.h>
-#include <libswfdec/swfdec_player.h>
-
-G_BEGIN_DECLS
-
-typedef enum {
- SWFDEC_XML_NODE_ELEMENT = 1,
- SWFDEC_XML_NODE_ATTRIBUTE = 2,
- SWFDEC_XML_NODE_TEXT = 3,
- SWFDEC_XML_NODE_CDATA_SECTION = 4,
- SWFDEC_XML_NODE_ENTITY_REFERENCE = 5,
- SWFDEC_XML_NODE_ENTITY = 6,
- SWFDEC_XML_NODE_PROCESSING_INSTRUCTION = 7,
- SWFDEC_XML_NODE_COMMENT = 8,
- SWFDEC_XML_NODE_DOCUMENT = 9,
- SWFDEC_XML_NODE_DOCUMENT_TYPE = 10,
- SWFDEC_XML_NODE_DOCUMENT_FRAGMENT = 11,
- SWFDEC_XML_NODE_NOTATION = 12,
-} SwfdecXmlNodeType;
-
-typedef struct _SwfdecXmlNode SwfdecXmlNode;
-typedef struct _SwfdecXmlNodeClass SwfdecXmlNodeClass;
-
-#define SWFDEC_TYPE_XML_NODE (swfdec_xml_node_get_type())
-#define SWFDEC_IS_XML_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_XML_NODE))
-#define SWFDEC_IS_XML_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_XML_NODE))
-#define SWFDEC_XML_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_XML_NODE, SwfdecXmlNode))
-#define SWFDEC_XML_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_XML_NODE, SwfdecXmlNodeClass))
-#define SWFDEC_XML_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_XML_NODE, SwfdecXmlNodeClass))
-
-#define SWFDEC_IS_VALID_XML_NODE(obj) (SWFDEC_IS_XML_NODE (obj) && SWFDEC_XML_NODE (obj)->valid)
-
-struct _SwfdecXmlNode {
- SwfdecAsObject object;
-
- gboolean valid;
-
- guint type; // SwfdecXmlNodeType
- const char *name; // for type == element
- const char *value; // for type != element
-
- SwfdecXmlNode *parent;
- SwfdecAsArray *children;
- SwfdecAsObject *attributes;
-
- // visible trough childNodes property, if modified by the user directly, the
- // changes are not visible in children and will get overwritten by next
- // internal change
- SwfdecAsArray *child_nodes;
-};
-
-struct _SwfdecXmlNodeClass {
- SwfdecAsObjectClass object_class;
-};
-
-GType swfdec_xml_node_get_type (void);
-
-SwfdecXmlNode * swfdec_xml_node_new (SwfdecAsContext * context,
- SwfdecXmlNodeType type,
- const char * value);
-SwfdecXmlNode * swfdec_xml_node_new_no_properties (SwfdecAsContext * context,
- SwfdecXmlNodeType type,
- const char * value);
-void swfdec_xml_node_removeNode (SwfdecXmlNode * node);
-void swfdec_xml_node_appendChild (SwfdecXmlNode * node,
- SwfdecXmlNode * child);
-void swfdec_xml_node_removeChildren (SwfdecXmlNode * node);
-void swfdec_xml_node_init_values (SwfdecXmlNode * node,
- int type,
- const char * value);
-gint32 swfdec_xml_node_num_children (SwfdecXmlNode * node);
-SwfdecXmlNode * swfdec_xml_node_get_child (SwfdecXmlNode * node,
- gint32 index_);
-const char * swfdec_xml_node_get_attribute (SwfdecXmlNode * node,
- const char * name);
-
-G_END_DECLS
-#endif
diff --git a/libswfdec/swfdec_xml_socket.c b/libswfdec/swfdec_xml_socket.c
deleted file mode 100644
index 886a042..0000000
--- a/libswfdec/swfdec_xml_socket.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/* Swfdec
- * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#include "swfdec_xml_socket.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_as_strings.h"
-#include "swfdec_buffer.h"
-#include "swfdec_debug.h"
-#include "swfdec_loader_internal.h"
-#include "swfdec_movie.h"
-#include "swfdec_player_internal.h"
-
-static GQuark xml_socket_quark = 0;
-
-static void
-swfdec_xml_socket_ensure_closed (SwfdecXmlSocket *xml)
-{
- gpointer cur;
-
- if (xml->socket == NULL)
- return;
-
- swfdec_stream_set_target (SWFDEC_STREAM (xml->socket), NULL);
- g_object_unref (xml->socket);
- xml->socket = NULL;
-
- swfdec_player_unroot (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (xml)->context), xml);
- cur = g_object_get_qdata (G_OBJECT (xml->target), xml_socket_quark);
- if (cur != xml)
- g_object_set_qdata (G_OBJECT (xml->target), xml_socket_quark, cur);
- xml->target = NULL;
-}
-
-/*** SWFDEC_STREAM_TARGET ***/
-
-static SwfdecPlayer *
-swfdec_xml_socket_stream_target_get_player (SwfdecStreamTarget *target)
-{
- return SWFDEC_PLAYER (SWFDEC_AS_OBJECT (target)->context);
-}
-
-static void
-swfdec_xml_socket_stream_target_error (SwfdecStreamTarget *target,
- SwfdecStream *stream)
-{
- SwfdecXmlSocket *xml = SWFDEC_XML_SOCKET (target);
-
- if (xml->open) {
- SWFDEC_FIXME ("is onClose emitted on error?");
- swfdec_as_object_call (xml->target, SWFDEC_AS_STR_onClose, 0, NULL, NULL);
- } else {
- SwfdecAsValue value;
-
- SWFDEC_AS_VALUE_SET_BOOLEAN (&value, FALSE);
- swfdec_as_object_call (xml->target, SWFDEC_AS_STR_onConnect, 1, &value, NULL);
- }
-
- swfdec_xml_socket_ensure_closed (xml);
-}
-
-static void
-swfdec_xml_socket_stream_target_parse (SwfdecStreamTarget *target,
- SwfdecStream *stream)
-{
- SwfdecXmlSocket *xml = SWFDEC_XML_SOCKET (target);
- SwfdecBufferQueue *queue;
- SwfdecBuffer *buffer;
- gsize len;
-
- /* parse until next 0 byte or take everything */
- queue = swfdec_stream_get_queue (stream);
- while ((buffer = swfdec_buffer_queue_peek_buffer (queue))) {
- guchar *nul = memchr (buffer->data, 0, buffer->length);
-
- len = nul ? (gsize) (nul - buffer->data + 1) : buffer->length;
- g_assert (len > 0);
- swfdec_buffer_unref (buffer);
- buffer = swfdec_buffer_queue_pull (queue, len);
- swfdec_buffer_queue_push (xml->queue, buffer);
- if (nul) {
- len = swfdec_buffer_queue_get_depth (xml->queue);
- g_assert (len > 0);
- buffer = swfdec_buffer_queue_pull (xml->queue, len);
- if (!g_utf8_validate ((char *) buffer->data, len, NULL)) {
- SWFDEC_FIXME ("invalid utf8 sent through socket, what now?");
- } else {
- SwfdecAsValue val;
-
- SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_get_string (
- SWFDEC_AS_OBJECT (xml)->context, (char *) buffer->data));
- swfdec_as_object_call (xml->target, SWFDEC_AS_STR_onData, 1, &val, NULL);
- }
- }
- }
-}
-
-static void
-swfdec_xml_socket_stream_target_close (SwfdecStreamTarget *target,
- SwfdecStream *stream)
-{
- SwfdecXmlSocket *xml = SWFDEC_XML_SOCKET (target);
-
- if (swfdec_buffer_queue_get_depth (xml->queue)) {
- SWFDEC_FIXME ("data left in socket, what now?");
- }
-
- swfdec_as_object_call (xml->target, SWFDEC_AS_STR_onClose, 0, NULL, NULL);
-
- swfdec_xml_socket_ensure_closed (xml);
-}
-
-static void
-swfdec_xml_socket_stream_target_init (SwfdecStreamTargetInterface *iface)
-{
- iface->get_player = swfdec_xml_socket_stream_target_get_player;
- iface->parse = swfdec_xml_socket_stream_target_parse;
- iface->close = swfdec_xml_socket_stream_target_close;
- iface->error = swfdec_xml_socket_stream_target_error;
-}
-
-/*** SWFDEC_XML_SOCKET ***/
-
-G_DEFINE_TYPE_WITH_CODE (SwfdecXmlSocket, swfdec_xml_socket, SWFDEC_TYPE_AS_OBJECT,
- G_IMPLEMENT_INTERFACE (SWFDEC_TYPE_STREAM_TARGET, swfdec_xml_socket_stream_target_init))
-
-static void
-swfdec_xml_socket_mark (SwfdecAsObject *object)
-{
- swfdec_as_object_mark (SWFDEC_XML_SOCKET (object)->target);
-
- SWFDEC_AS_OBJECT_CLASS (swfdec_xml_socket_parent_class)->mark (object);
-}
-
-static void
-swfdec_xml_socket_dispose (GObject *object)
-{
- SwfdecXmlSocket *xml = SWFDEC_XML_SOCKET (object);
-
- swfdec_xml_socket_ensure_closed (xml);
- if (xml->queue) {
- swfdec_buffer_queue_unref (xml->queue);
- xml->queue = NULL;
- }
-
- G_OBJECT_CLASS (swfdec_xml_socket_parent_class)->dispose (object);
-}
-
-static void
-swfdec_xml_socket_class_init (SwfdecXmlSocketClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- SwfdecAsObjectClass *as_object_class = SWFDEC_AS_OBJECT_CLASS (klass);
-
- object_class->dispose = swfdec_xml_socket_dispose;
-
- as_object_class->mark = swfdec_xml_socket_mark;
-}
-
-static void
-swfdec_xml_socket_init (SwfdecXmlSocket *xml)
-{
- xml->queue = swfdec_buffer_queue_new ();
-}
-
-static SwfdecXmlSocket *
-swfdec_xml_socket_create (SwfdecAsObject *target, const char *hostname, guint port)
-{
- SwfdecAsContext *cx = target->context;
- SwfdecXmlSocket *xml;
- SwfdecSocket *sock;
-
- if (!swfdec_as_context_use_mem (cx, sizeof (SwfdecXmlSocket)))
- return NULL;
-
- SWFDEC_FIXME ("implement security checks please");
- sock = swfdec_player_create_socket (SWFDEC_PLAYER (cx), hostname, port);
- if (sock == NULL)
- return NULL;
-
- xml = g_object_new (SWFDEC_TYPE_XML_SOCKET, NULL);
- swfdec_as_object_add (SWFDEC_AS_OBJECT (xml), cx, sizeof (SwfdecXmlSocket));
- swfdec_player_root (SWFDEC_PLAYER (cx), xml, (GFunc) swfdec_as_object_mark);
-
- xml->target = target;
- xml->socket = sock;
-
- return xml;
-}
-
-/*** AS CODE ***/
-
-SWFDEC_AS_NATIVE (400, 0, swfdec_xml_socket_connect)
-void
-swfdec_xml_socket_connect (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- const char *host;
- int port;
-
- SWFDEC_AS_CHECK (0, NULL, "si", &host, &port);
-
- if (SWFDEC_IS_MOVIE (object) || object == NULL)
- return;
-
- swfdec_xml_socket_create (object, host, port);
- SWFDEC_STUB ("XMLSocket.connect");
-}
-
-SWFDEC_AS_NATIVE (400, 1, swfdec_xml_socket_send)
-void
-swfdec_xml_socket_send (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("XMLSocket.send");
-}
-
-SWFDEC_AS_NATIVE (400, 2, swfdec_xml_socket_close)
-void
-swfdec_xml_socket_close (SwfdecAsContext *cx, SwfdecAsObject *object,
- guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
-{
- SWFDEC_STUB ("XMLSocket.close");
-}
diff --git a/libswfdec/swfdec_xml_socket.h b/libswfdec/swfdec_xml_socket.h
deleted file mode 100644
index 95f19c2..0000000
--- a/libswfdec/swfdec_xml_socket.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Swfdec
- * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef _SWFDEC_XML_SOCKET_H_
-#define _SWFDEC_XML_SOCKET_H_
-
-#include <libswfdec/swfdec.h>
-#include <libswfdec/swfdec_as_object.h>
-
-G_BEGIN_DECLS
-
-
-typedef struct _SwfdecXmlSocket SwfdecXmlSocket;
-typedef struct _SwfdecXmlSocketClass SwfdecXmlSocketClass;
-
-#define SWFDEC_TYPE_XML_SOCKET (swfdec_xml_socket_get_type())
-#define SWFDEC_IS_XML_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_XML_SOCKET))
-#define SWFDEC_IS_XML_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_XML_SOCKET))
-#define SWFDEC_XML_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_XML_SOCKET, SwfdecXmlSocket))
-#define SWFDEC_XML_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_XML_SOCKET, SwfdecXmlSocketClass))
-#define SWFDEC_XML_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_XML_SOCKET, SwfdecXmlSocketClass))
-
-struct _SwfdecXmlSocket {
- SwfdecAsObject object;
-
- SwfdecSocket * socket; /* the socket in use */
- gboolean open; /* the socket has been opened already */
- SwfdecBufferQueue * queue; /* everything that belongs to the same string */
- SwfdecAsObject * target; /* target object we call out to */
-};
-
-struct _SwfdecXmlSocketClass {
- SwfdecAsObjectClass object_class;
-};
-
-GType swfdec_xml_socket_get_type (void);
-
-
-G_END_DECLS
-#endif
diff --git a/swfdec-gtk/.gitignore b/swfdec-gtk/.gitignore
new file mode 100644
index 0000000..cad6c66
--- /dev/null
+++ b/swfdec-gtk/.gitignore
@@ -0,0 +1,14 @@
+*~
+CVS
+.cvsignore
+.deps
+.libs
+
+Makefile
+Makefile.in
+*.o
+*.la
+*.lo
+*.loT
+
+swfdec_playback.c
diff --git a/swfdec-gtk/Makefile.am b/swfdec-gtk/Makefile.am
new file mode 100644
index 0000000..4f724cf
--- /dev/null
+++ b/swfdec-gtk/Makefile.am
@@ -0,0 +1,45 @@
+# this workaround is needed or autotools don't generate the .deps/*.Plo files correctly
+swfdec_playback.c: swfdec_playback_$(AUDIO_TYPE).c Makefile
+ cmp -s $(srcdir)/swfdec_playback_$(AUDIO_TYPE).c swfdec_playback.c \
+ || cp $(srcdir)/swfdec_playback_$(AUDIO_TYPE).c swfdec_playback.c
+
+BUILT_SOURCES = swfdec_playback.c
+CLEANFILES = swfdec_playback.c
+
+lib_LTLIBRARIES = libswfdec-gtk- at SWFDEC_MAJORMINOR@.la
+
+libswfdec_gtk_ at SWFDEC_MAJORMINOR@_la_SOURCES = \
+ swfdec_playback.c \
+ swfdec_source.c \
+ swfdec_gtk_keys.c \
+ swfdec_gtk_loader.c \
+ swfdec_gtk_player.c \
+ swfdec_gtk_socket.c \
+ swfdec_gtk_widget.c
+
+noinst_HEADERS = \
+ swfdec_playback.h \
+ swfdec_source.h
+
+libswfdec_gtk_ at SWFDEC_MAJORMINOR@_la_CFLAGS = \
+ -I$(top_srcdir) $(GLOBAL_CFLAGS) $(SWFDEC_CFLAGS) $(GTK_CFLAGS) \
+ $(AUDIO_CFLAGS) \
+ -DG_LOG_DOMAIN=\"Swfdec-Gtk\"
+libswfdec_gtk_ at SWFDEC_MAJORMINOR@_la_LDFLAGS = \
+ -version-info $(SWFDEC_LIBVERSION) \
+ -export-symbols-regex '^(swfdec_.*)' \
+ $(GTK_LIBS) $(SWFDEC_LIBS) $(AUDIO_LIBS)
+libswfdec_ at SWFDEC_MAJORMINOR@includedir = $(includedir)/swfdec- at SWFDEC_MAJORMINOR@/libswfdec-gtk
+libswfdec_ at SWFDEC_MAJORMINOR@include_HEADERS = \
+ swfdec-gtk.h \
+ swfdec_gtk_keys.h \
+ swfdec_gtk_loader.h \
+ swfdec_gtk_player.h \
+ swfdec_gtk_socket.h \
+ swfdec_gtk_widget.h
+
+EXTRA_DIST = \
+ swfdec_playback_alsa.c \
+ swfdec_playback_oss.c \
+ swfdec_playback_pa.c \
+ swfdec_playback_none.c
diff --git a/swfdec-gtk/swfdec-gtk.h b/swfdec-gtk/swfdec-gtk.h
new file mode 100644
index 0000000..b64cf83
--- /dev/null
+++ b/swfdec-gtk/swfdec-gtk.h
@@ -0,0 +1,29 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SWFDEC_GTK_H__
+#define __SWFDEC_GTK_H__
+
+#include <libswfdec-gtk/swfdec_gtk_keys.h>
+#include <libswfdec-gtk/swfdec_gtk_loader.h>
+#include <libswfdec-gtk/swfdec_gtk_player.h>
+#include <libswfdec-gtk/swfdec_gtk_socket.h>
+#include <libswfdec-gtk/swfdec_gtk_widget.h>
+
+#endif
diff --git a/swfdec-gtk/swfdec_gtk_keys.c b/swfdec-gtk/swfdec_gtk_keys.c
new file mode 100644
index 0000000..69e0a6e
--- /dev/null
+++ b/swfdec-gtk/swfdec_gtk_keys.c
@@ -0,0 +1,77 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include "swfdec_gtk_keys.h"
+
+static const guint8 flash_keycodes[] = {
+ /* 0 */ 0, 0, 0, 0, 0,
+ /* 5 */ 0, 0, 0, 0, SWFDEC_KEY_ESCAPE,
+ /* 10 */ SWFDEC_KEY_1, SWFDEC_KEY_2, SWFDEC_KEY_3, SWFDEC_KEY_4, SWFDEC_KEY_5,
+ /* 15 */ SWFDEC_KEY_6, SWFDEC_KEY_7, SWFDEC_KEY_8, SWFDEC_KEY_9, SWFDEC_KEY_0,
+ /* 20 */ SWFDEC_KEY_MINUS, SWFDEC_KEY_EQUAL, SWFDEC_KEY_BACKSPACE, SWFDEC_KEY_TAB, SWFDEC_KEY_Q,
+ /* 25 */ SWFDEC_KEY_W, SWFDEC_KEY_E, SWFDEC_KEY_R, SWFDEC_KEY_T, SWFDEC_KEY_Y,
+ /* 30 */ SWFDEC_KEY_U, SWFDEC_KEY_I, SWFDEC_KEY_O, SWFDEC_KEY_P, SWFDEC_KEY_LEFT_BRACKET,
+ /* 35 */ SWFDEC_KEY_RIGHT_BRACKET, SWFDEC_KEY_ENTER, SWFDEC_KEY_CONTROL, SWFDEC_KEY_A, SWFDEC_KEY_S,
+ /* 40 */ SWFDEC_KEY_D, SWFDEC_KEY_F, SWFDEC_KEY_G, SWFDEC_KEY_H, SWFDEC_KEY_J,
+ /* 45 */ SWFDEC_KEY_K, SWFDEC_KEY_L, SWFDEC_KEY_SEMICOLON, SWFDEC_KEY_APOSTROPHE, SWFDEC_KEY_GRAVE,
+ /* 50 */ SWFDEC_KEY_SHIFT, SWFDEC_KEY_BACKSLASH, SWFDEC_KEY_Z, SWFDEC_KEY_X, SWFDEC_KEY_C,
+ /* 55 */ SWFDEC_KEY_V, SWFDEC_KEY_B, SWFDEC_KEY_N, SWFDEC_KEY_M, 0,
+ /* 60 */ 0, SWFDEC_KEY_SLASH, SWFDEC_KEY_SHIFT, SWFDEC_KEY_NUMPAD_MULTIPLY, SWFDEC_KEY_ALT,
+ /* 65 */ SWFDEC_KEY_SPACE, 0, SWFDEC_KEY_F1, SWFDEC_KEY_F2, SWFDEC_KEY_F3,
+ /* 70 */ SWFDEC_KEY_F4, SWFDEC_KEY_F5, SWFDEC_KEY_F6, SWFDEC_KEY_F7, SWFDEC_KEY_F8,
+ /* 75 */ SWFDEC_KEY_F9, SWFDEC_KEY_F10, SWFDEC_KEY_NUM_LOCK, 0, SWFDEC_KEY_NUMPAD_7,
+ /* 80 */ SWFDEC_KEY_NUMPAD_8, SWFDEC_KEY_NUMPAD_9, SWFDEC_KEY_NUMPAD_SUBTRACT, SWFDEC_KEY_NUMPAD_4, SWFDEC_KEY_NUMPAD_5,
+ /* 85 */ SWFDEC_KEY_NUMPAD_6, SWFDEC_KEY_NUMPAD_ADD, SWFDEC_KEY_NUMPAD_1, SWFDEC_KEY_NUMPAD_2, SWFDEC_KEY_NUMPAD_3,
+ /* 90 */ SWFDEC_KEY_NUMPAD_0, SWFDEC_KEY_NUMPAD_DECIMAL, 0, 0, 0,
+ /* 95 */ SWFDEC_KEY_F11, SWFDEC_KEY_F12, SWFDEC_KEY_HOME, SWFDEC_KEY_UP, SWFDEC_KEY_PAGE_UP,
+ /* 100 */ SWFDEC_KEY_LEFT, 0, SWFDEC_KEY_RIGHT, SWFDEC_KEY_END, SWFDEC_KEY_DOWN,
+ /* 105 */ SWFDEC_KEY_PAGE_DOWN, SWFDEC_KEY_INSERT, SWFDEC_KEY_DELETE, SWFDEC_KEY_ENTER, SWFDEC_KEY_CONTROL,
+ /* 110 */ 0, 0, SWFDEC_KEY_NUMPAD_DIVIDE, SWFDEC_KEY_ALT, 0,
+ /* 115 */ 0, 0, 0, 0, 0
+};
+/*
+SWFDEC_KEY_COMMA 59
+SWFDEC_KEY_DOT 60
+SWFDEC_KEY_SCROLL_LOCK 78
+SWFDEC_KEY_BREAK 110
+SWFDEC_KEY_META 115
+SWFDEC_KEY_META_R 116
+SWFDEC_KEY_MENU 117
+*/
+
+/**
+ * swfdec_gtk_keycode_from_hardware_keycode:
+ * @hardware_keycode: a hardware keycode sent from the X server
+ *
+ * Tries to transform an X hardware keycode to the corresponding #SwfdecKey.
+ * This is a utility function for cases where key events need to be transformed
+ * manually.
+ *
+ * Returns: the corresponding key code as used in Flash.
+ **/
+guint
+swfdec_gtk_keycode_from_hardware_keycode (guint hardware_keycode)
+{
+ if (hardware_keycode >= G_N_ELEMENTS (flash_keycodes))
+ return 0;
+ return flash_keycodes[hardware_keycode];
+}
diff --git a/swfdec-gtk/swfdec_gtk_keys.h b/swfdec-gtk/swfdec_gtk_keys.h
new file mode 100644
index 0000000..d9b985b
--- /dev/null
+++ b/swfdec-gtk/swfdec_gtk_keys.h
@@ -0,0 +1,30 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_GTK_KEYS_H_
+#define _SWFDEC_GTK_KEYS_H_
+
+#include <libswfdec/swfdec.h>
+
+G_BEGIN_DECLS
+
+guint swfdec_gtk_keycode_from_hardware_keycode (guint hardware_keycode);
+
+G_END_DECLS
+#endif
diff --git a/swfdec-gtk/swfdec_gtk_loader.c b/swfdec-gtk/swfdec_gtk_loader.c
new file mode 100644
index 0000000..375ca60
--- /dev/null
+++ b/swfdec-gtk/swfdec_gtk_loader.c
@@ -0,0 +1,217 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <libsoup/soup.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include "swfdec_gtk_loader.h"
+
+/*** GTK-DOC ***/
+
+/**
+ * SECTION:SwfdecGtkLoader
+ * @title: SwfdecGtkLoader
+ * @short_description: advanced loader able to load network ressources
+ * @see_also: #SwfdecLoader
+ *
+ * #SwfdecGtkLoader is a #SwfdecLoader that is intended as an easy way to be
+ * access ressources that are not stored in files, such as HTTP. It can
+ * however be compiled with varying support for different protocols, so don't
+ * rely on support for a particular protocol being available. If you need this,
+ * code your own SwfdecLoader subclass.
+ */
+
+/**
+ * SwfdecGtkLoader:
+ *
+ * This is the object used to represent a loader. Since it may use varying
+ * backends, it is completely private.
+ */
+
+struct _SwfdecGtkLoader
+{
+ SwfdecLoader loader;
+
+ SoupMessage * message; /* the message we're sending */
+ gboolean opened; /* set after first bytes of data have arrived */
+};
+
+struct _SwfdecGtkLoaderClass {
+ SwfdecLoaderClass loader_class;
+
+ SoupSession * session; /* the session used by the loader */
+};
+
+/*** SwfdecGtkLoader ***/
+
+G_DEFINE_TYPE (SwfdecGtkLoader, swfdec_gtk_loader, SWFDEC_TYPE_FILE_LOADER)
+
+static void
+swfdec_gtk_loader_set_size (SwfdecGtkLoader *gtk)
+{
+ const char *s = soup_message_get_header (gtk->message->response_headers, "Content-Length");
+ unsigned long l;
+ char *end;
+
+ if (s == NULL)
+ return;
+
+ errno = 0;
+ l = strtoul (s, &end, 10);
+ if (errno == 0 && *end == 0 && l <= G_MAXLONG)
+ swfdec_loader_set_size (SWFDEC_LOADER (gtk), l);
+}
+
+static void
+swfdec_gtk_loader_ensure_open (SwfdecGtkLoader *gtk)
+{
+ char *real_uri;
+
+ if (gtk->opened)
+ return;
+
+ real_uri = soup_uri_to_string (soup_message_get_uri (gtk->message), FALSE);
+ swfdec_gtk_loader_set_size (gtk);
+ swfdec_loader_set_url (SWFDEC_LOADER (gtk), real_uri);
+ swfdec_stream_open (SWFDEC_STREAM (gtk));
+ gtk->opened = TRUE;
+ g_free (real_uri);
+}
+
+static void
+swfdec_gtk_loader_push (SoupMessage *msg, gpointer loader)
+{
+ SwfdecGtkLoader *gtk = SWFDEC_GTK_LOADER (loader);
+ SwfdecBuffer *buffer;
+
+ swfdec_gtk_loader_ensure_open (gtk);
+ buffer = swfdec_buffer_new_and_alloc (msg->response.length);
+ memcpy (buffer->data, msg->response.body, msg->response.length);
+ swfdec_stream_push (loader, buffer);
+}
+
+static void
+swfdec_gtk_loader_finished (SoupMessage *msg, gpointer loader)
+{
+ if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
+ swfdec_gtk_loader_ensure_open (loader);
+ swfdec_stream_eof (loader);
+ } else {
+ swfdec_stream_error (loader, "%u %s", msg->status_code, msg->reason_phrase);
+ }
+}
+
+static void
+swfdec_gtk_loader_dispose (GObject *object)
+{
+ SwfdecGtkLoader *gtk = SWFDEC_GTK_LOADER (object);
+
+ if (gtk->message) {
+ g_signal_handlers_disconnect_by_func (gtk->message, swfdec_gtk_loader_push, gtk);
+ g_signal_handlers_disconnect_by_func (gtk->message, swfdec_gtk_loader_finished, gtk);
+ g_object_unref (gtk->message);
+ gtk->message = NULL;
+ }
+
+ G_OBJECT_CLASS (swfdec_gtk_loader_parent_class)->dispose (object);
+}
+
+static void
+swfdec_gtk_loader_load (SwfdecLoader *loader, SwfdecPlayer *player,
+ const char *url_string, SwfdecLoaderRequest request, SwfdecBuffer *buffer)
+{
+ SwfdecURL *url;
+
+ if (swfdec_url_path_is_relative (url_string)) {
+ url = swfdec_url_new_relative (swfdec_player_get_base_url (player), url_string);
+ } else {
+ url = swfdec_url_new (url_string);
+ }
+
+ if (url == NULL) {
+ swfdec_stream_error (SWFDEC_STREAM (loader), "invalid URL %s", url_string);
+ return;
+ };
+ if (!swfdec_url_has_protocol (url, "http") &&
+ !swfdec_url_has_protocol (url, "https")) {
+ SWFDEC_LOADER_CLASS (swfdec_gtk_loader_parent_class)->load (loader, player,
+ url_string, request, buffer);
+ } else {
+ SwfdecGtkLoader *gtk = SWFDEC_GTK_LOADER (loader);
+ SwfdecGtkLoaderClass *klass = SWFDEC_GTK_LOADER_GET_CLASS (gtk);
+
+ gtk->message = soup_message_new (request == SWFDEC_LOADER_REQUEST_POST ? "POST" : "GET",
+ swfdec_url_get_url (url));
+ soup_message_set_flags (gtk->message, SOUP_MESSAGE_OVERWRITE_CHUNKS);
+ g_signal_connect (gtk->message, "got-chunk", G_CALLBACK (swfdec_gtk_loader_push), gtk);
+ g_signal_connect (gtk->message, "finished", G_CALLBACK (swfdec_gtk_loader_finished), gtk);
+ if (buffer)
+ soup_message_set_request (gtk->message, "appliation/x-www-urlencoded",
+ SOUP_BUFFER_USER_OWNED, (char *) buffer->data, buffer->length);
+ g_object_ref (gtk->message);
+ soup_session_queue_message (klass->session, gtk->message, NULL, NULL);
+ }
+ swfdec_url_free (url);
+}
+
+static void
+swfdec_gtk_loader_close (SwfdecStream *stream)
+{
+ SwfdecGtkLoader *gtk = SWFDEC_GTK_LOADER (stream);
+
+ if (gtk->message) {
+ gboolean eof;
+
+ g_object_get (stream, "eof", &eof, NULL);
+ if (!eof) {
+ SwfdecGtkLoaderClass *klass = SWFDEC_GTK_LOADER_GET_CLASS (gtk);
+
+ soup_session_cancel_message (klass->session, gtk->message);
+ g_object_unref (gtk->message);
+ gtk->message = NULL;
+ }
+ }
+}
+
+static void
+swfdec_gtk_loader_class_init (SwfdecGtkLoaderClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ SwfdecStreamClass *stream_class = SWFDEC_STREAM_CLASS (klass);
+ SwfdecLoaderClass *loader_class = SWFDEC_LOADER_CLASS (klass);
+
+ object_class->dispose = swfdec_gtk_loader_dispose;
+
+ stream_class->close = swfdec_gtk_loader_close;
+
+ loader_class->load = swfdec_gtk_loader_load;
+
+ klass->session = soup_session_async_new ();
+}
+
+static void
+swfdec_gtk_loader_init (SwfdecGtkLoader *gtk_loader)
+{
+}
+
diff --git a/swfdec-gtk/swfdec_gtk_loader.h b/swfdec-gtk/swfdec_gtk_loader.h
new file mode 100644
index 0000000..ccae174
--- /dev/null
+++ b/swfdec-gtk/swfdec_gtk_loader.h
@@ -0,0 +1,42 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_GTK_LOADER_H_
+#define _SWFDEC_GTK_LOADER_H_
+
+#include <libswfdec/swfdec.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _SwfdecGtkLoader SwfdecGtkLoader;
+typedef struct _SwfdecGtkLoaderClass SwfdecGtkLoaderClass;
+
+#define SWFDEC_TYPE_GTK_LOADER (swfdec_gtk_loader_get_type())
+#define SWFDEC_IS_GTK_LOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_GTK_LOADER))
+#define SWFDEC_IS_GTK_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_GTK_LOADER))
+#define SWFDEC_GTK_LOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_GTK_LOADER, SwfdecGtkLoader))
+#define SWFDEC_GTK_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_GTK_LOADER, SwfdecGtkLoaderClass))
+#define SWFDEC_GTK_LOADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_GTK_LOADER, SwfdecGtkLoaderClass))
+
+GType swfdec_gtk_loader_get_type (void);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec-gtk/swfdec_gtk_player.c b/swfdec-gtk/swfdec_gtk_player.c
new file mode 100644
index 0000000..6d0a0a3
--- /dev/null
+++ b/swfdec-gtk/swfdec_gtk_player.c
@@ -0,0 +1,315 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "libswfdec-gtk/swfdec_gtk_loader.h"
+#include "libswfdec-gtk/swfdec_gtk_player.h"
+#include "libswfdec-gtk/swfdec_gtk_socket.h"
+#include "libswfdec-gtk/swfdec_playback.h"
+#include "libswfdec-gtk/swfdec_source.h"
+
+struct _SwfdecGtkPlayer
+{
+ SwfdecPlayer player;
+
+ GSource * source; /* source if playing, NULL otherwise */
+ SwfdecPlayback * playback; /* audio playback object */
+ gboolean audio_enabled; /* TRUE if audio should be played */
+ double speed; /* desired playback speed */
+};
+
+struct _SwfdecGtkPlayerClass
+{
+ SwfdecPlayerClass player_class;
+};
+
+enum {
+ PROP_0,
+ PROP_PLAYING,
+ PROP_AUDIO,
+ PROP_SPEED
+};
+
+/*** gtk-doc ***/
+
+/**
+ * SECTION:SwfdecGtkPlayer
+ * @title: SwfdecGtkPlayer
+ * @short_description: an improved #SwfdecPlayer
+ *
+ * The #SwfdecGtkPlayer adds common functionality to the rather barebones
+ * #SwfdecPlayer class, such as automatic playback and audio handling. Note
+ * that by default, the player will be paused, so you need to call
+ * swfdec_gtk_player_set_playing () on the new player.
+ *
+ * @see_also: SwfdecPlayer
+ */
+
+/**
+ * SwfdecGtkPlayer:
+ *
+ * The structure for the Swfdec Gtk player contains no public fields.
+ */
+
+/*** SWFDEC_GTK_PLAYER ***/
+
+G_DEFINE_TYPE (SwfdecGtkPlayer, swfdec_gtk_player, SWFDEC_TYPE_PLAYER)
+
+static void
+swfdec_gtk_player_get_property (GObject *object, guint param_id, GValue *value,
+ GParamSpec * pspec)
+{
+ SwfdecGtkPlayer *player = SWFDEC_GTK_PLAYER (object);
+
+ switch (param_id) {
+ case PROP_PLAYING:
+ g_value_set_boolean (value, player->source != NULL);
+ break;
+ case PROP_AUDIO:
+ g_value_set_boolean (value, player->audio_enabled);
+ break;
+ case PROP_SPEED:
+ g_value_set_double (value, player->speed);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+swfdec_gtk_player_set_property (GObject *object, guint param_id, const GValue *value,
+ GParamSpec *pspec)
+{
+ SwfdecGtkPlayer *player = SWFDEC_GTK_PLAYER (object);
+
+ switch (param_id) {
+ case PROP_PLAYING:
+ swfdec_gtk_player_set_playing (player, g_value_get_boolean (value));
+ break;
+ case PROP_AUDIO:
+ swfdec_gtk_player_set_audio_enabled (player, g_value_get_boolean (value));
+ break;
+ case PROP_SPEED:
+ swfdec_gtk_player_set_speed (player, g_value_get_double (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+swfdec_gtk_player_dispose (GObject *object)
+{
+ SwfdecGtkPlayer *player = SWFDEC_GTK_PLAYER (object);
+
+ swfdec_gtk_player_set_playing (player, FALSE);
+ g_assert (player->playback == NULL);
+
+ G_OBJECT_CLASS (swfdec_gtk_player_parent_class)->dispose (object);
+}
+
+static void
+swfdec_gtk_player_class_init (SwfdecGtkPlayerClass * g_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+
+ object_class->dispose = swfdec_gtk_player_dispose;
+ object_class->get_property = swfdec_gtk_player_get_property;
+ object_class->set_property = swfdec_gtk_player_set_property;
+
+ g_object_class_install_property (object_class, PROP_PLAYING,
+ g_param_spec_boolean ("playing", "playing", "TRUE if the player is playing (d'oh)",
+ FALSE, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_AUDIO,
+ g_param_spec_boolean ("audio-enabled", "audio enabled", "TRUE if automatic audio handling is enabled",
+ TRUE, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_SPEED,
+ g_param_spec_double ("speed", "speed", "desired playback speed",
+ G_MINDOUBLE, G_MAXDOUBLE, 1.0, G_PARAM_READWRITE));
+}
+
+static void
+swfdec_gtk_player_init (SwfdecGtkPlayer * player)
+{
+ player->speed = 1.0;
+ player->audio_enabled = TRUE;
+}
+
+/*** PUBLIC API ***/
+
+/**
+ * swfdec_gtk_player_new:
+ * @debugger: %NULL or a #SwfdecAsDebugger to debug this player
+ *
+ * Creates a new Swfdec Gtk player.
+ * This function calls swfdec_init () for you if it wasn't called before.
+ *
+ * Returns: The new player
+ **/
+SwfdecPlayer *
+swfdec_gtk_player_new (SwfdecAsDebugger *debugger)
+{
+ SwfdecPlayer *player;
+
+ swfdec_init ();
+ player = g_object_new (SWFDEC_TYPE_GTK_PLAYER,
+ "loader-type", SWFDEC_TYPE_GTK_LOADER, "socket-type", SWFDEC_TYPE_GTK_SOCKET,
+ "debugger", debugger, NULL);
+
+ return player;
+}
+
+static void
+swfdec_gtk_player_update_audio (SwfdecGtkPlayer *player)
+{
+ gboolean should_play = player->audio_enabled;
+
+ should_play &= (player->source != NULL);
+ should_play &= (player->speed == 1.0);
+
+ if (should_play && player->playback == NULL) {
+ player->playback = swfdec_playback_open (SWFDEC_PLAYER (player),
+ g_main_context_default ());
+ } else if (!should_play && player->playback != NULL) {
+ swfdec_playback_close (player->playback);
+ player->playback = NULL;
+ }
+}
+
+/**
+ * swfdec_gtk_player_set_playing:
+ * @player: a #SwfdecGtkPlayer
+ * @playing: if the player should play or not
+ *
+ * Sets if @player should be playing or not. If the player is playing, a timer
+ * will be attached to the default main loop that periodically calls
+ * swfdec_player_advance().
+ **/
+void
+swfdec_gtk_player_set_playing (SwfdecGtkPlayer *player, gboolean playing)
+{
+ g_return_if_fail (SWFDEC_IS_GTK_PLAYER (player));
+
+ if (playing && player->source == NULL) {
+ player->source = swfdec_iterate_source_new (SWFDEC_PLAYER (player), player->speed);
+ g_source_attach (player->source, NULL);
+ } else if (!playing && player->source != NULL) {
+ g_source_destroy (player->source);
+ g_source_unref (player->source);
+ player->source = NULL;
+ }
+ swfdec_gtk_player_update_audio (player);
+ g_object_notify (G_OBJECT (player), "playing");
+}
+
+/**
+ * swfdec_gtk_player_get_playing:
+ * @player: a #SwfdecGtkPlayer
+ *
+ * Queries if the player is playing.
+ *
+ * Returns: %TRUE if the player is playing
+ **/
+gboolean
+swfdec_gtk_player_get_playing (SwfdecGtkPlayer *player)
+{
+ g_return_val_if_fail (SWFDEC_IS_GTK_PLAYER (player), FALSE);
+
+ return player->source != NULL;
+}
+
+/**
+ * swfdec_gtk_player_set_audio_enabled:
+ * @player: a #SwfdecGtkPlayer
+ * @enabled: %TRUE to enable audio
+ *
+ * Enables or disables automatic audio playback.
+ **/
+void
+swfdec_gtk_player_set_audio_enabled (SwfdecGtkPlayer *player, gboolean enabled)
+{
+ g_return_if_fail (SWFDEC_IS_GTK_PLAYER (player));
+
+ if (player->audio_enabled == enabled)
+ return;
+ player->audio_enabled = enabled;
+ swfdec_gtk_player_update_audio (player);
+ g_object_notify (G_OBJECT (player), "audio-enabled");
+}
+
+/**
+ * swfdec_gtk_player_get_audio_enabled:
+ * @player: a #SwfdecGtkPlayer
+ *
+ * Queries if audio playback for @player is enabled or not.
+ *
+ * Returns: %TRUE if audio playback is enabled
+ **/
+gboolean
+swfdec_gtk_player_get_audio_enabled (SwfdecGtkPlayer *player)
+{
+ g_return_val_if_fail (SWFDEC_IS_GTK_PLAYER (player), FALSE);
+
+ return player->audio_enabled;
+}
+
+/**
+ * swfdec_gtk_player_set_speed:
+ * @player: a #SwfdecGtkPlayer
+ * @speed: the new playback speed
+ *
+ * Sets the new playback speed. 1.0 means the default speed, bigger values
+ * make playback happen faster. Audio will only play back if the speed is
+ * 1.0. Note that if the player is not playing when calling this function,
+ * it will not automatically start.
+ **/
+void
+swfdec_gtk_player_set_speed (SwfdecGtkPlayer *player, double speed)
+{
+ g_return_if_fail (SWFDEC_IS_GTK_PLAYER (player));
+ g_return_if_fail (speed > 0.0);
+
+ player->speed = speed;
+ swfdec_gtk_player_update_audio (player);
+ if (player->source)
+ swfdec_iterate_source_set_speed (player->source, player->speed);
+ g_object_notify (G_OBJECT (player), "speed");
+}
+
+/**
+ * swfdec_gtk_player_get_speed:
+ * @player: a #SwfdecGtkPlayer
+ *
+ * Queries the current playback speed. If the player is currently paused, it
+ * will report the speed that it would use if playing.
+ *
+ * Returns: the current playback speed.
+ **/
+double
+swfdec_gtk_player_get_speed (SwfdecGtkPlayer *player)
+{
+ g_return_val_if_fail (SWFDEC_IS_GTK_PLAYER (player), FALSE);
+
+ return player->speed;
+}
diff --git a/swfdec-gtk/swfdec_gtk_player.h b/swfdec-gtk/swfdec_gtk_player.h
new file mode 100644
index 0000000..3ff77bf
--- /dev/null
+++ b/swfdec-gtk/swfdec_gtk_player.h
@@ -0,0 +1,56 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_GTK_PLAYER_H_
+#define _SWFDEC_GTK_PLAYER_H_
+
+#include <libswfdec/swfdec.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecGtkPlayer SwfdecGtkPlayer;
+typedef struct _SwfdecGtkPlayerClass SwfdecGtkPlayerClass;
+
+#define SWFDEC_TYPE_GTK_PLAYER (swfdec_gtk_player_get_type())
+#define SWFDEC_IS_GTK_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_GTK_PLAYER))
+#define SWFDEC_IS_GTK_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_GTK_PLAYER))
+#define SWFDEC_GTK_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_GTK_PLAYER, SwfdecGtkPlayer))
+#define SWFDEC_GTK_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_GTK_PLAYER, SwfdecGtkPlayerClass))
+#define SWFDEC_GTK_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_GTK_PLAYER, SwfdecGtkPlayerClass))
+
+GType swfdec_gtk_player_get_type (void);
+
+SwfdecPlayer * swfdec_gtk_player_new (SwfdecAsDebugger * debugger);
+
+void swfdec_gtk_player_set_playing (SwfdecGtkPlayer * player,
+ gboolean playing);
+gboolean swfdec_gtk_player_get_playing (SwfdecGtkPlayer * player);
+void swfdec_gtk_player_set_audio_enabled
+ (SwfdecGtkPlayer * player,
+ gboolean enabled);
+gboolean swfdec_gtk_player_get_audio_enabled
+ (SwfdecGtkPlayer * player);
+void swfdec_gtk_player_set_speed (SwfdecGtkPlayer * player,
+ double speed);
+double swfdec_gtk_player_get_speed (SwfdecGtkPlayer * player);
+
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec-gtk/swfdec_gtk_socket.c b/swfdec-gtk/swfdec_gtk_socket.c
new file mode 100644
index 0000000..08cbb76
--- /dev/null
+++ b/swfdec-gtk/swfdec_gtk_socket.c
@@ -0,0 +1,220 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_gtk_socket.h"
+#include <libsoup/soup.h>
+#include <libsoup/soup-address.h>
+
+/*** GTK-DOC ***/
+
+/**
+ * SECTION:SwfdecGtkSocket
+ * @title: SwfdecGtkSocket
+ * @short_description: a socket implementation integrating into the Gtk main loop
+ * @see_also: #SwfdecSocket, #SwfdecGtkPlayer
+ *
+ * #SwfdecGtkSocket is a #SwfdecSocket that is a socket implementation that
+ * uses libsoup and integrates with the Gtk main loop. It is used by default
+ * by the #SwfecGtkPlayer.
+ */
+
+/**
+ * SwfdecGtkSocket:
+ *
+ * This is the object used to represent a socket. It is completely private.
+ */
+
+struct _SwfdecGtkSocket
+{
+ SwfdecSocket socket;
+
+ SoupSocket * sock; /* libsoup socket we're using */
+ gboolean sock_writable; /* FALSE if writing would block */
+ SwfdecBufferQueue * queue; /* buffers we still need to push */
+};
+
+struct _SwfdecGtkSocketClass {
+ SwfdecSocketClass socket_class;
+};
+
+/*** SwfdecGtkSocket ***/
+
+G_DEFINE_TYPE (SwfdecGtkSocket, swfdec_gtk_socket, SWFDEC_TYPE_SOCKET)
+
+static void
+swfdec_gtk_socket_close (SwfdecStream *stream)
+{
+ SwfdecGtkSocket *gtk = SWFDEC_GTK_SOCKET (stream);
+
+ soup_socket_disconnect (gtk->sock);
+}
+
+static void
+swfdec_gtk_socket_do_connect (SoupSocket *sock, int status, SwfdecGtkSocket *gtk)
+{
+ if (SOUP_STATUS_IS_SUCCESSFUL (status))
+ swfdec_stream_open (SWFDEC_STREAM (gtk));
+ else
+ swfdec_stream_error (SWFDEC_STREAM (gtk), "error connecting");
+
+}
+
+static void
+swfdec_gtk_socket_do_disconnect (SoupSocket *sock, SwfdecGtkSocket *gtk)
+{
+ swfdec_stream_eof (SWFDEC_STREAM (gtk));
+}
+
+static void
+swfdec_gtk_socket_do_read (SoupSocket *sock, SwfdecGtkSocket *gtk)
+{
+#define SWFDEC_GTK_SOCKET_BLOCK_SIZE 1024
+ SwfdecBuffer *buffer;
+ SoupSocketIOStatus status;
+ gsize len;
+
+ do {
+ buffer = swfdec_buffer_new_and_alloc (SWFDEC_GTK_SOCKET_BLOCK_SIZE);
+ status = soup_socket_read (sock, buffer, SWFDEC_GTK_SOCKET_BLOCK_SIZE, &len);
+ buffer->length = len;
+ switch (status) {
+ case SOUP_SOCKET_OK:
+ swfdec_stream_push (SWFDEC_STREAM (gtk), buffer);
+ break;
+ case SOUP_SOCKET_WOULD_BLOCK:
+ case SOUP_SOCKET_EOF:
+ swfdec_buffer_unref (buffer);
+ break;
+ case SOUP_SOCKET_ERROR:
+ swfdec_buffer_unref (buffer);
+ swfdec_stream_error (SWFDEC_STREAM (gtk), "error reading data");
+ break;
+ default:
+ g_warning ("unhandled status code %u from soup_socket_read()", (guint) status);
+ break;
+ }
+ } while (status == SOUP_SOCKET_OK);
+}
+
+static void
+swfdec_gtk_socket_do_write (SoupSocket *sock, SwfdecGtkSocket *gtk)
+{
+ SwfdecBuffer *buffer;
+ SoupSocketIOStatus status;
+ gsize len;
+
+ gtk->sock_writable = TRUE;
+ while ((buffer = swfdec_buffer_queue_peek_buffer (gtk->queue))) {
+ status = soup_socket_write (sock, buffer->data, buffer->length, &len);
+ swfdec_buffer_unref (buffer);
+ switch (status) {
+ case SOUP_SOCKET_OK:
+ buffer = swfdec_buffer_queue_pull (gtk->queue, len);
+ swfdec_buffer_unref (buffer);
+ break;
+ case SOUP_SOCKET_WOULD_BLOCK:
+ case SOUP_SOCKET_EOF:
+ gtk->sock_writable = FALSE;
+ break;
+ case SOUP_SOCKET_ERROR:
+ swfdec_stream_error (SWFDEC_STREAM (gtk), "error writing data");
+ break;
+ default:
+ g_warning ("unhandled status code %u from soup_socket_read()", (guint) status);
+ break;
+ }
+ };
+}
+
+static SwfdecSocket *
+swfdec_gtk_socket_create (const char *hostname, guint port)
+{
+ SwfdecGtkSocket *sock = g_object_new (SWFDEC_TYPE_GTK_SOCKET, NULL);
+ SoupAddress *addr;
+
+ addr = soup_address_new (hostname, port);
+ sock->sock = soup_socket_new (SOUP_SOCKET_FLAG_NONBLOCKING, TRUE,
+ /* FIXME: we should set nodelay, no? */
+ SOUP_SOCKET_FLAG_NODELAY, TRUE, NULL);
+ g_signal_connect (sock->sock, "connect-result",
+ G_CALLBACK (swfdec_gtk_socket_do_connect), socket);
+ g_signal_connect (sock->sock, "disconnect",
+ G_CALLBACK (swfdec_gtk_socket_do_disconnect), socket);
+ g_signal_connect (sock->sock, "readable",
+ G_CALLBACK (swfdec_gtk_socket_do_read), socket);
+ g_signal_connect (sock->sock, "writable",
+ G_CALLBACK (swfdec_gtk_socket_do_write), socket);
+
+ return SWFDEC_SOCKET (sock);
+}
+
+static void
+swfdec_gtk_socket_send (SwfdecSocket *sock, SwfdecBuffer *buffer)
+{
+ SwfdecGtkSocket *gtk = SWFDEC_GTK_SOCKET (sock);
+
+ swfdec_buffer_queue_push (gtk->queue, buffer);
+ if (gtk->sock_writable)
+ swfdec_gtk_socket_do_write (gtk->sock, gtk);
+}
+
+static void
+swfdec_gtk_socket_dispose (GObject *object)
+{
+ SwfdecGtkSocket *gtk = SWFDEC_GTK_SOCKET (object);
+
+ if (gtk->sock) {
+ g_signal_handlers_disconnect_matched (gtk->sock, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, gtk);
+ g_object_unref (gtk->sock);
+ gtk->sock = NULL;
+ }
+ if (gtk->queue) {
+ swfdec_buffer_queue_unref (gtk->queue);
+ gtk->queue = NULL;
+ }
+ G_OBJECT_CLASS (swfdec_gtk_socket_parent_class)->dispose (object);
+}
+
+static void
+swfdec_gtk_socket_class_init (SwfdecGtkSocketClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ SwfdecStreamClass *stream_class = SWFDEC_STREAM_CLASS (klass);
+ SwfdecSocketClass *socket_class = SWFDEC_SOCKET_CLASS (klass);
+
+ object_class->dispose = swfdec_gtk_socket_dispose;
+
+ stream_class->close = swfdec_gtk_socket_close;
+
+ socket_class->create = swfdec_gtk_socket_create;
+ socket_class->send = swfdec_gtk_socket_send;
+}
+
+static void
+swfdec_gtk_socket_init (SwfdecGtkSocket *gtk)
+{
+ gtk->sock_writable = TRUE;
+ gtk->queue = swfdec_buffer_queue_new ();
+}
+
diff --git a/swfdec-gtk/swfdec_gtk_socket.h b/swfdec-gtk/swfdec_gtk_socket.h
new file mode 100644
index 0000000..62bb546
--- /dev/null
+++ b/swfdec-gtk/swfdec_gtk_socket.h
@@ -0,0 +1,42 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_GTK_SOCKET_H_
+#define _SWFDEC_GTK_SOCKET_H_
+
+#include <libswfdec/swfdec.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _SwfdecGtkSocket SwfdecGtkSocket;
+typedef struct _SwfdecGtkSocketClass SwfdecGtkSocketClass;
+
+#define SWFDEC_TYPE_GTK_SOCKET (swfdec_gtk_socket_get_type())
+#define SWFDEC_IS_GTK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_GTK_SOCKET))
+#define SWFDEC_IS_GTK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_GTK_SOCKET))
+#define SWFDEC_GTK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_GTK_SOCKET, SwfdecGtkSocket))
+#define SWFDEC_GTK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_GTK_SOCKET, SwfdecGtkSocketClass))
+#define SWFDEC_GTK_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_GTK_SOCKET, SwfdecGtkSocketClass))
+
+GType swfdec_gtk_socket_get_type (void);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec-gtk/swfdec_gtk_widget.c b/swfdec-gtk/swfdec_gtk_widget.c
new file mode 100644
index 0000000..4836aa0
--- /dev/null
+++ b/swfdec-gtk/swfdec_gtk_widget.c
@@ -0,0 +1,683 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+#include <gdk/gdkkeysyms.h>
+#include "swfdec_gtk_widget.h"
+#include "swfdec_gtk_keys.h"
+
+struct _SwfdecGtkWidgetPrivate
+{
+ SwfdecPlayer * player; /* the video we play */
+
+ gboolean renderer_set; /* TRUE if a special renderer has been set */
+ cairo_surface_type_t renderer; /* the renderer that was set */
+ gboolean interactive; /* TRUE if this widget propagates keyboard and mouse events */
+};
+
+enum {
+ PROP_0,
+ PROP_PLAYER,
+ PROP_INTERACTIVE,
+ PROP_RENDERER_SET,
+ PROP_RENDERER
+};
+
+/*** gtk-doc ***/
+
+/**
+ * SECTION:SwfdecGtkWidget
+ * @title: SwfdecGtkWidget
+ * @short_description: a #GtkWidget for embedding SWF files
+ *
+ * This is a widget for playing Flash movies rendered with Swfdec in a Gtk
+ * application. It supports a lot of advanced features, if you want to use
+ * them. If you don't want to use them and just want to embed a movie in
+ * your application, swfdec_gtk_widget_new() will probably be the only
+ * function you need.
+ *
+ * @see_also: SwfdecGtkPlayer
+ */
+
+/**
+ * SwfdecGtkWidget:
+ *
+ * The structure for the Swfdec Gtk widget contains no public fields.
+ */
+
+/*** SWFDEC_GTK_WIDGET ***/
+
+G_DEFINE_TYPE (SwfdecGtkWidget, swfdec_gtk_widget, GTK_TYPE_WIDGET)
+
+static gboolean
+swfdec_gtk_widget_motion_notify (GtkWidget *gtkwidget, GdkEventMotion *event)
+{
+ SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (gtkwidget);
+ SwfdecGtkWidgetPrivate *priv = widget->priv;
+ int x, y;
+
+ gdk_window_get_pointer (gtkwidget->window, &x, &y, NULL);
+
+ if (priv->interactive && priv->player)
+ swfdec_player_mouse_move (priv->player, x, y);
+
+ return FALSE;
+}
+
+static gboolean
+swfdec_gtk_widget_leave_notify (GtkWidget *gtkwidget, GdkEventCrossing *event)
+{
+ SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (gtkwidget);
+ SwfdecGtkWidgetPrivate *priv = widget->priv;
+
+ if (priv->interactive && priv->player) {
+ swfdec_player_mouse_move (priv->player, event->x, event->y);
+ }
+ return FALSE;
+}
+
+static gboolean
+swfdec_gtk_widget_button_press (GtkWidget *gtkwidget, GdkEventButton *event)
+{
+ SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (gtkwidget);
+ SwfdecGtkWidgetPrivate *priv = widget->priv;
+
+ if (event->type == GDK_BUTTON_PRESS && event->button <= 32 && priv->interactive && priv->player) {
+ swfdec_player_mouse_press (priv->player, event->x, event->y, event->button);
+ }
+ return FALSE;
+}
+
+static gboolean
+swfdec_gtk_widget_button_release (GtkWidget *gtkwidget, GdkEventButton *event)
+{
+ SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (gtkwidget);
+ SwfdecGtkWidgetPrivate *priv = widget->priv;
+
+ if (event->button <= 32 && priv->interactive && priv->player) {
+ swfdec_player_mouse_release (priv->player, event->x, event->y, event->button);
+ }
+ return FALSE;
+}
+
+static guint
+swfdec_gtk_event_to_keycode (GdkEventKey *event)
+{
+ guint ret;
+
+ /* we try to match as well as possible to Flash _Windows_ key codes.
+ * Since a lot of Flash files won't special case weird Linux key codes and we
+ * want the best compatibility possible, we have to do that.
+ */
+ /* FIXME: I have no clue about non-western keyboards, so if you happen to use
+ * such a keyboard, please help out here if it doesn't match.
+ */
+
+ /* try to match latin keys directly */
+ if (event->keyval >= GDK_A && event->keyval <= GDK_Z)
+ return event->keyval - GDK_A + SWFDEC_KEY_A;
+ if (event->keyval >= GDK_a && event->keyval <= GDK_z)
+ return event->keyval - GDK_a + SWFDEC_KEY_A;
+
+ /* last resort: try to translate the hardware keycode directly */
+ ret = swfdec_gtk_keycode_from_hardware_keycode (event->hardware_keycode);
+ if (ret == 0)
+ g_printerr ("could not translate key to Flash keycode. HW keycode %u, keyval %u\n",
+ event->hardware_keycode, event->keyval);
+ return ret;
+}
+
+static gboolean
+swfdec_gtk_widget_key_press (GtkWidget *gtkwidget, GdkEventKey *event)
+{
+ SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (gtkwidget);
+ SwfdecGtkWidgetPrivate *priv = widget->priv;
+
+ if (priv->interactive && priv->player) {
+ guint keycode = swfdec_gtk_event_to_keycode (event);
+ if (keycode != 0) {
+ swfdec_player_key_press (priv->player, keycode,
+ gdk_keyval_to_unicode (event->keyval));
+ }
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
+swfdec_gtk_widget_key_release (GtkWidget *gtkwidget, GdkEventKey *event)
+{
+ SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (gtkwidget);
+ SwfdecGtkWidgetPrivate *priv = widget->priv;
+
+ if (priv->interactive && priv->player) {
+ guint keycode = swfdec_gtk_event_to_keycode (event);
+ if (keycode != 0) {
+ swfdec_player_key_release (priv->player, keycode,
+ gdk_keyval_to_unicode (event->keyval));
+ }
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static cairo_surface_t *
+swfdec_gtk_widget_create_renderer (cairo_surface_type_t type, int width, int height)
+{
+ if (type == CAIRO_SURFACE_TYPE_IMAGE) {
+ return cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
+ } else {
+ return NULL;
+ }
+}
+
+static gboolean
+swfdec_gtk_widget_expose (GtkWidget *gtkwidget, GdkEventExpose *event)
+{
+ SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (gtkwidget);
+ SwfdecGtkWidgetPrivate *priv = widget->priv;
+ cairo_t *cr;
+ cairo_surface_t *surface = NULL;
+
+ if (event->window != gtkwidget->window)
+ return FALSE;
+ if (priv->player == NULL)
+ return FALSE;
+
+ if (!priv->renderer_set ||
+ (surface = swfdec_gtk_widget_create_renderer (priv->renderer,
+ event->area.width, event->area.height)) == NULL) {
+ cr = gdk_cairo_create (gtkwidget->window);
+ } else {
+ cr = cairo_create (surface);
+ cairo_translate (cr, -event->area.x, -event->area.y);
+ }
+ swfdec_player_render (priv->player, cr,
+ event->area.x, event->area.y, event->area.width, event->area.height);
+ cairo_show_page (cr);
+ cairo_destroy (cr);
+
+ if (surface) {
+ cairo_t *crw = gdk_cairo_create (gtkwidget->window);
+ cairo_set_source_surface (crw, surface, event->area.x, event->area.y);
+ cairo_paint (crw);
+ cairo_destroy (crw);
+ cairo_surface_destroy (surface);
+ }
+
+ return FALSE;
+}
+
+static void
+swfdec_gtk_widget_get_property (GObject *object, guint param_id, GValue *value,
+ GParamSpec * pspec)
+{
+ SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (object);
+ SwfdecGtkWidgetPrivate *priv = widget->priv;
+
+ switch (param_id) {
+ case PROP_PLAYER:
+ g_value_set_object (value, priv->player);
+ break;
+ case PROP_INTERACTIVE:
+ g_value_set_boolean (value, priv->interactive);
+ break;
+ case PROP_RENDERER_SET:
+ g_value_set_boolean (value, priv->renderer_set);
+ break;
+ case PROP_RENDERER:
+ g_value_set_uint (value, priv->renderer);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+swfdec_gtk_widget_set_property (GObject *object, guint param_id, const GValue *value,
+ GParamSpec *pspec)
+{
+ SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (object);
+ SwfdecGtkWidgetPrivate *priv = widget->priv;
+
+ switch (param_id) {
+ case PROP_PLAYER:
+ swfdec_gtk_widget_set_player (widget, g_value_get_object (value));
+ break;
+ case PROP_INTERACTIVE:
+ swfdec_gtk_widget_set_interactive (widget, g_value_get_boolean (value));
+ break;
+ case PROP_RENDERER_SET:
+ priv->renderer_set = g_value_get_boolean (value);
+ gtk_widget_queue_draw (GTK_WIDGET (widget));
+ break;
+ case PROP_RENDERER:
+ priv->renderer = g_value_get_uint (value);
+ if (priv->renderer_set)
+ gtk_widget_queue_draw (GTK_WIDGET (widget));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+swfdec_gtk_widget_dispose (GObject *object)
+{
+ SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (object);
+
+ swfdec_gtk_widget_set_player (widget, NULL);
+
+ G_OBJECT_CLASS (swfdec_gtk_widget_parent_class)->dispose (object);
+}
+
+static void
+swfdec_gtk_widget_size_allocate (GtkWidget *gtkwidget, GtkAllocation *allocation)
+{
+ SwfdecGtkWidget *widget = SWFDEC_GTK_WIDGET (gtkwidget);
+ SwfdecGtkWidgetPrivate *priv = widget->priv;
+
+ gtkwidget->allocation = *allocation;
+
+ if (priv->player && swfdec_player_is_initialized (priv->player))
+ swfdec_player_set_size (priv->player, allocation->width, allocation->height);
+ if (GTK_WIDGET_REALIZED (gtkwidget)) {
+ gdk_window_move_resize (gtkwidget->window,
+ allocation->x, allocation->y, allocation->width, allocation->height);
+ }
+}
+
+static void
+swfdec_gtk_widget_size_request (GtkWidget *gtkwidget, GtkRequisition *req)
+{
+ SwfdecGtkWidget * widget = SWFDEC_GTK_WIDGET (gtkwidget);
+ SwfdecGtkWidgetPrivate *priv = widget->priv;
+
+ if (priv->player == NULL) {
+ req->width = req->height = 0;
+ } else {
+ 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);
+ }
+}
+
+static void
+swfdec_gtk_widget_update_cursor (SwfdecGtkWidget *widget)
+{
+ GdkWindow *window = GTK_WIDGET (widget)->window;
+ GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (widget));
+ SwfdecGtkWidgetPrivate *priv = widget->priv;
+ SwfdecMouseCursor swfcursor;
+ GdkCursor *cursor;
+
+ if (window == NULL)
+ return;
+ if (priv->interactive)
+ g_object_get (priv->player, "mouse-cursor", &swfcursor, NULL);
+ else
+ swfcursor = SWFDEC_MOUSE_CURSOR_NORMAL;
+
+ switch (swfcursor) {
+ case SWFDEC_MOUSE_CURSOR_NONE:
+ {
+ GdkBitmap *bitmap;
+ GdkColor color = { 0, 0, 0, 0 };
+ char data = 0;
+
+ bitmap = gdk_bitmap_create_from_data (window, &data, 1, 1);
+ if (bitmap == NULL)
+ return;
+ cursor = gdk_cursor_new_from_pixmap (bitmap, bitmap, &color, &color, 0, 0);
+ gdk_window_set_cursor (window, cursor);
+ gdk_cursor_unref (cursor);
+ g_object_unref (bitmap);
+ break;
+ }
+ case SWFDEC_MOUSE_CURSOR_TEXT:
+ cursor = gdk_cursor_new_for_display (display, GDK_XTERM);
+ gdk_window_set_cursor (window, cursor);
+ gdk_cursor_unref (cursor);
+ break;
+ case SWFDEC_MOUSE_CURSOR_CLICK:
+ cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
+ gdk_window_set_cursor (window, cursor);
+ gdk_cursor_unref (cursor);
+ break;
+ case SWFDEC_MOUSE_CURSOR_NORMAL:
+ cursor = gdk_cursor_new_for_display (display, GDK_LEFT_PTR);
+ gdk_window_set_cursor (window, cursor);
+ gdk_cursor_unref (cursor);
+ break;
+ default:
+ g_warning ("invalid cursor %d", (int) swfcursor);
+ gdk_window_set_cursor (window, NULL);
+ break;
+ }
+}
+
+static void
+swfdec_gtk_widget_realize (GtkWidget *widget)
+{
+ GdkWindowAttr attributes;
+ gint attributes_mask;
+
+ GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+
+ attributes.window_type = GDK_WINDOW_CHILD;
+ attributes.x = widget->allocation.x;
+ attributes.y = widget->allocation.y;
+ attributes.width = widget->allocation.width;
+ attributes.height = widget->allocation.height;
+ attributes.wclass = GDK_INPUT_OUTPUT;
+ attributes.event_mask = gtk_widget_get_events (widget);
+ attributes.event_mask |= GDK_EXPOSURE_MASK |
+ GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_LEAVE_NOTIFY_MASK |
+ GDK_POINTER_MOTION_MASK |
+ GDK_POINTER_MOTION_HINT_MASK |
+ GDK_KEY_PRESS_MASK |
+ GDK_KEY_RELEASE_MASK;
+
+ attributes_mask = GDK_WA_X | GDK_WA_Y;
+
+ widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gdk_window_set_user_data (widget->window, widget);
+
+ widget->style = gtk_style_attach (widget->style, widget->window);
+
+ if (SWFDEC_GTK_WIDGET (widget)->priv->player) {
+ swfdec_gtk_widget_update_cursor (SWFDEC_GTK_WIDGET (widget));
+ }
+}
+
+static void
+swfdec_gtk_widget_class_init (SwfdecGtkWidgetClass * g_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (g_class);
+
+ object_class->dispose = swfdec_gtk_widget_dispose;
+ object_class->get_property = swfdec_gtk_widget_get_property;
+ object_class->set_property = swfdec_gtk_widget_set_property;
+
+ g_object_class_install_property (object_class, PROP_PLAYER,
+ g_param_spec_object ("player", "player", "player that is displayed",
+ SWFDEC_TYPE_PLAYER, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_INTERACTIVE,
+ g_param_spec_boolean ("interactive", "interactive", "if mouse events are processed",
+ TRUE, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_RENDERER_SET,
+ g_param_spec_boolean ("renderer-set", "renderer set", "if an intermediate renderer should be used",
+ TRUE, G_PARAM_READWRITE));
+ /* FIXME: get an enum for cairo_surface_type_t */
+ g_object_class_install_property (object_class, PROP_RENDERER,
+ g_param_spec_uint ("renderer", "renderer", "cairo_surface_type_t of intermediate renderer to use",
+ 0, G_MAXUINT, CAIRO_SURFACE_TYPE_IMAGE, G_PARAM_READWRITE));
+
+ widget_class->realize = swfdec_gtk_widget_realize;
+ widget_class->size_request = swfdec_gtk_widget_size_request;
+ widget_class->size_allocate = swfdec_gtk_widget_size_allocate;
+ widget_class->expose_event = swfdec_gtk_widget_expose;
+ widget_class->button_press_event = swfdec_gtk_widget_button_press;
+ widget_class->button_release_event = swfdec_gtk_widget_button_release;
+ widget_class->motion_notify_event = swfdec_gtk_widget_motion_notify;
+ widget_class->leave_notify_event = swfdec_gtk_widget_leave_notify;
+ widget_class->key_press_event = swfdec_gtk_widget_key_press;
+ widget_class->key_release_event = swfdec_gtk_widget_key_release;
+
+ g_type_class_add_private (object_class, sizeof (SwfdecGtkWidgetPrivate));
+}
+
+static void
+swfdec_gtk_widget_init (SwfdecGtkWidget * widget)
+{
+ SwfdecGtkWidgetPrivate *priv;
+
+ priv = widget->priv = G_TYPE_INSTANCE_GET_PRIVATE (widget, SWFDEC_TYPE_GTK_WIDGET, SwfdecGtkWidgetPrivate);
+
+ priv->interactive = TRUE;
+ priv->renderer = CAIRO_SURFACE_TYPE_IMAGE;
+
+ GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
+}
+
+static void
+swfdec_gtk_widget_invalidate_cb (SwfdecPlayer *player, const SwfdecRectangle *extents,
+ const SwfdecRectangle *rect, guint n_rects, SwfdecGtkWidget *widget)
+{
+ GdkRegion *region;
+ guint i;
+
+ if (!GTK_WIDGET_REALIZED (widget))
+ return;
+
+ region = gdk_region_new ();
+ for (i = 0; i < n_rects; i++) {
+ gdk_region_union_with_rect (region, (GdkRectangle *) &rect[i]);
+ }
+ gdk_window_invalidate_region (GTK_WIDGET (widget)->window, region, FALSE);
+ gdk_region_destroy (region);
+}
+
+static void
+swfdec_gtk_widget_notify_cb (SwfdecPlayer *player, GParamSpec *pspec, SwfdecGtkWidget *widget)
+{
+ if (g_str_equal (pspec->name, "mouse-cursor")) {
+ swfdec_gtk_widget_update_cursor (widget);
+ } else if (g_str_equal (pspec->name, "initialized")) {
+ gtk_widget_queue_resize (GTK_WIDGET (widget));
+ }
+}
+
+/*** PUBLIC API ***/
+
+/**
+ * swfdec_gtk_widget_set_player:
+ * @widget: a #SwfdecGtkWidget
+ * @player: the #SwfdecPlayer to display or %NULL for none
+ *
+ * Sets the new player to display in @widget.
+ **/
+void
+swfdec_gtk_widget_set_player (SwfdecGtkWidget *widget, SwfdecPlayer *player)
+{
+ SwfdecGtkWidgetPrivate *priv = widget->priv;
+
+ g_return_if_fail (SWFDEC_IS_GTK_WIDGET (widget));
+ g_return_if_fail (player == NULL || SWFDEC_IS_PLAYER (player));
+
+ if (priv->player) {
+ g_signal_handlers_disconnect_by_func (priv->player, swfdec_gtk_widget_invalidate_cb, widget);
+ g_signal_handlers_disconnect_by_func (priv->player, swfdec_gtk_widget_notify_cb, widget);
+ g_object_unref (priv->player);
+ }
+ priv->player = player;
+ if (player) {
+ g_signal_connect (player, "invalidate", G_CALLBACK (swfdec_gtk_widget_invalidate_cb), widget);
+ g_signal_connect (player, "notify", G_CALLBACK (swfdec_gtk_widget_notify_cb), widget);
+ g_object_ref (player);
+ swfdec_gtk_widget_update_cursor (widget);
+ } else {
+ if (GTK_WIDGET (widget)->window)
+ gdk_window_set_cursor (GTK_WIDGET (widget)->window, NULL);
+ }
+ gtk_widget_queue_resize (GTK_WIDGET (widget));
+ g_object_notify (G_OBJECT (widget), "player");
+}
+
+/**
+ * swfdec_gtk_widget_get_player:
+ * @widget: a #SwfdecGtkWidget
+ *
+ * Gets the player that is currently played back in this @widget.
+ *
+ * Returns: the #SwfdecPlayer or %NULL if none
+ **/
+SwfdecPlayer *
+swfdec_gtk_widget_get_player (SwfdecGtkWidget *widget)
+{
+ g_return_val_if_fail (SWFDEC_IS_GTK_WIDGET (widget), NULL);
+
+ return widget->priv->player;
+}
+
+/**
+ * swfdec_gtk_widget_new:
+ * @player: a #SwfdecPlayer or %NULL
+ *
+ * Creates a new #SwfdecGtkWidget to display @player.
+ *
+ * Returns: the new widget that displays @player
+ **/
+GtkWidget *
+swfdec_gtk_widget_new (SwfdecPlayer *player)
+{
+ SwfdecGtkWidget *widget;
+
+ g_return_val_if_fail (player == NULL || SWFDEC_IS_PLAYER (player), NULL);
+
+ widget = g_object_new (SWFDEC_TYPE_GTK_WIDGET, "player", player, NULL);
+
+ return GTK_WIDGET (widget);
+}
+
+/**
+ * swfdec_gtk_widget_set_interactive:
+ * @widget: a #SwfdecGtkWidget
+ * @interactive: %TRUE to make the widget interactive
+ *
+ * Sets the widget to be interactive or not. An interactive widget processes
+ * mouse and keyboard events, while a non-interactive widget does not care about
+ * user input. Widgets are interactive by default.
+ **/
+void
+swfdec_gtk_widget_set_interactive (SwfdecGtkWidget *widget, gboolean interactive)
+{
+ g_return_if_fail (SWFDEC_IS_GTK_WIDGET (widget));
+
+ widget->priv->interactive = interactive;
+ swfdec_gtk_widget_update_cursor (widget);
+ g_object_notify (G_OBJECT (widget), "interactive");
+}
+
+/**
+ * swfdec_gtk_widget_get_interactive:
+ * @widget: a #SwfdecGtkWidget
+ *
+ * Queries if the @widget is currently interactive. See
+ * swfdec_gtk_widget_set_interactive() for details.
+ *
+ * Returns: %TRUE if the widget is interactive, %FALSE otherwise.
+ **/
+gboolean
+swfdec_gtk_widget_get_interactive (SwfdecGtkWidget *widget)
+{
+ g_return_val_if_fail (SWFDEC_IS_GTK_WIDGET (widget), FALSE);
+
+ return widget->priv->interactive;
+}
+
+/**
+ * swfdec_gtk_widget_set_renderer:
+ * @widget: a #SwfdecGtkWidget
+ * @renderer: a #cairo_surface_type_t for the intermediate renderer
+ *
+ * Tells @widget to use an intermediate surface for rendering. This is
+ * useful for debugging or performance measurements inside swfdec and is
+ * probably not interesting for anyone else.
+ **/
+void
+swfdec_gtk_widget_set_renderer (SwfdecGtkWidget *widget, cairo_surface_type_t renderer)
+{
+ g_return_if_fail (SWFDEC_IS_GTK_WIDGET (widget));
+
+ widget->priv->renderer = renderer;
+ if (widget->priv->renderer_set == FALSE) {
+ widget->priv->renderer_set = TRUE;
+ g_object_notify (G_OBJECT (widget), "renderer-set");
+ }
+ g_object_notify (G_OBJECT (widget), "renderer");
+}
+
+/**
+ * swfdec_gtk_widget_unset_renderer:
+ * @widget: a #SwfdecGtkWidget
+ *
+ * Unsets the use of an intermediate rendering surface. See
+ * swfdec_gtk_widget_set_renderer() for details.
+ **/
+void
+swfdec_gtk_widget_unset_renderer (SwfdecGtkWidget *widget)
+{
+ g_return_if_fail (SWFDEC_IS_GTK_WIDGET (widget));
+
+ if (widget->priv->renderer_set == FALSE)
+ return;
+ widget->priv->renderer_set = FALSE;
+ g_object_notify (G_OBJECT (widget), "renderer-set");
+}
+
+/**
+ * swfdec_gtk_widget_get_renderer:
+ * @widget: a #SwfdecGtkWidget
+ *
+ * Gets the intermediate renderer that is or would be in use by @widget. Use
+ * swfdec_gtk_widget_uses_renderer() to check if an intermediate renderer is in
+ * use. See swfdec_gtk_widget_set_renderer() for details.
+ *
+ * Returns: the type of the intermediate renderer
+ **/
+cairo_surface_type_t
+swfdec_gtk_widget_get_renderer (SwfdecGtkWidget *widget)
+{
+ g_return_val_if_fail (SWFDEC_IS_GTK_WIDGET (widget), CAIRO_SURFACE_TYPE_IMAGE);
+
+ return widget->priv->renderer;
+}
+
+/**
+ * swfdec_gtk_widget_uses_renderer:
+ * @widget: a #SwfdecGtkWidget
+ *
+ * Queries if an intermediate renderer set via swfdec_gtk_widget_set_renderer()
+ * is currently in use.
+ *
+ * Returns: %TRUE if an intermediate renderer is used.
+ **/
+gboolean
+swfdec_gtk_widget_uses_renderer (SwfdecGtkWidget *widget)
+{
+ g_return_val_if_fail (SWFDEC_IS_GTK_WIDGET (widget), FALSE);
+
+ return widget->priv->renderer_set;
+}
+
diff --git a/swfdec-gtk/swfdec_gtk_widget.h b/swfdec-gtk/swfdec_gtk_widget.h
new file mode 100644
index 0000000..86b03fd
--- /dev/null
+++ b/swfdec-gtk/swfdec_gtk_widget.h
@@ -0,0 +1,69 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_GTK_WIDGET_H_
+#define _SWFDEC_GTK_WIDGET_H_
+
+#include <gtk/gtk.h>
+#include <libswfdec/swfdec.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecGtkWidget SwfdecGtkWidget;
+typedef struct _SwfdecGtkWidgetClass SwfdecGtkWidgetClass;
+typedef struct _SwfdecGtkWidgetPrivate SwfdecGtkWidgetPrivate;
+
+#define SWFDEC_TYPE_GTK_WIDGET (swfdec_gtk_widget_get_type())
+#define SWFDEC_IS_GTK_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_GTK_WIDGET))
+#define SWFDEC_IS_GTK_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_GTK_WIDGET))
+#define SWFDEC_GTK_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_GTK_WIDGET, SwfdecGtkWidget))
+#define SWFDEC_GTK_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_GTK_WIDGET, SwfdecGtkWidgetClass))
+
+struct _SwfdecGtkWidget
+{
+ GtkWidget widget;
+
+ /*< private >*/
+ SwfdecGtkWidgetPrivate * priv;
+};
+
+struct _SwfdecGtkWidgetClass
+{
+ GtkWidgetClass widget_class;
+};
+
+GType swfdec_gtk_widget_get_type (void);
+
+GtkWidget * swfdec_gtk_widget_new (SwfdecPlayer * player);
+
+void swfdec_gtk_widget_set_player (SwfdecGtkWidget * widget,
+ SwfdecPlayer * player);
+SwfdecPlayer * swfdec_gtk_widget_get_player (SwfdecGtkWidget * widget);
+void swfdec_gtk_widget_set_renderer (SwfdecGtkWidget * widget,
+ cairo_surface_type_t renderer);
+void swfdec_gtk_widget_unset_renderer (SwfdecGtkWidget * widget);
+cairo_surface_type_t
+ swfdec_gtk_widget_get_renderer (SwfdecGtkWidget * widget);
+gboolean swfdec_gtk_widget_uses_renderer (SwfdecGtkWidget * widget);
+void swfdec_gtk_widget_set_interactive (SwfdecGtkWidget * widget,
+ gboolean interactive);
+gboolean swfdec_gtk_widget_get_interactive (SwfdecGtkWidget * widget);
+
+G_END_DECLS
+#endif
diff --git a/swfdec-gtk/swfdec_playback.h b/swfdec-gtk/swfdec_playback.h
new file mode 100644
index 0000000..8be67dd
--- /dev/null
+++ b/swfdec-gtk/swfdec_playback.h
@@ -0,0 +1,35 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_PLAYBACK_H_
+#define _SWFDEC_PLAYBACK_H_
+
+#include <libswfdec/swfdec.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecPlayback SwfdecPlayback;
+
+SwfdecPlayback *swfdec_playback_open (SwfdecPlayer * player,
+ GMainContext * context);
+
+void swfdec_playback_close (SwfdecPlayback * sound);
+
+G_END_DECLS
+#endif
diff --git a/swfdec-gtk/swfdec_playback_alsa.c b/swfdec-gtk/swfdec_playback_alsa.c
new file mode 100644
index 0000000..bddd189
--- /dev/null
+++ b/swfdec-gtk/swfdec_playback_alsa.c
@@ -0,0 +1,360 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <alsa/asoundlib.h>
+#include "swfdec_playback.h"
+
+/* Why ALSA sucks for beginners:
+ * - snd_pcm_delay is not sample-exact, but period-exact most of the time.
+ * Yay for getting told the time every 512 samples when a human notices
+ * a delay of 100 samples (oooops)
+ * - lots of functions are simply not implemented. So the super-smart idea
+ * of using snd_pcm_rewind to avoid XRUNS and still get low latency has
+ * some issues when dmix just returns -EIO all of the time. That wouldn't
+ * be so bad if there was actually a way to query if it's supported.
+ * - But to make up for all this, you have 10 hardware parameters, 10
+ * software parameters and 10 configuration parameters. All of this is
+ * naturally supported on 10 driver APIs depending on kernel. So if your
+ * sound card seems to do weird stuff, that is not my fault.
+ * Welcome to Linux sound in the 21st century.
+ */
+
+/*** DEFINITIONS ***/
+
+struct _SwfdecPlayback {
+ SwfdecPlayer * player;
+ GList * streams; /* all Stream objects */
+ GMainContext * context; /* context we work in */
+};
+
+typedef struct {
+ SwfdecPlayback * sound; /* reference to sound object */
+ SwfdecAudio * audio; /* the audio we play back */
+ snd_pcm_t * pcm; /* the pcm we play back to */
+ GSource ** sources; /* sources for writing data */
+ guint n_sources; /* number of sources */
+ guint offset; /* offset into sound */
+} Stream;
+
+#define ALSA_TRY(func,msg) G_STMT_START{ \
+ int err = func; \
+ if (err < 0) \
+ g_printerr (msg ": %s\n", snd_strerror (err)); \
+}G_STMT_END
+
+#define ALSA_ERROR(func,msg,retval) G_STMT_START { \
+ int err = func; \
+ if (err < 0) { \
+ g_printerr (msg ": %s\n", snd_strerror (err)); \
+ return retval; \
+ } \
+}G_STMT_END
+
+/*** STREAMS ***/
+
+static snd_pcm_uframes_t
+write_player (Stream *stream, const snd_pcm_channel_area_t *dst,
+ snd_pcm_uframes_t offset, snd_pcm_uframes_t avail)
+{
+ /* FIXME: do a long path if this doesn't hold */
+ g_assert (dst[1].first - dst[0].first == 16);
+ g_assert (dst[0].addr == dst[1].addr);
+ g_assert (dst[0].step == dst[1].step);
+ g_assert (dst[0].step == 32);
+
+ memset ((guint8 *) dst[0].addr + offset * dst[0].step / 8, 0, avail * 4);
+ swfdec_audio_render (stream->audio, (gint16 *) ((guint8 *) dst[0].addr + offset * dst[0].step / 8),
+ stream->offset, avail);
+ //g_print ("rendering %u %u\n", stream->offset, (guint) avail);
+ return avail;
+}
+
+static gboolean
+try_write (Stream *stream)
+{
+ snd_pcm_sframes_t avail_result;
+ snd_pcm_uframes_t offset, avail;
+ const snd_pcm_channel_area_t *dst;
+
+ while (TRUE) {
+ avail_result = snd_pcm_avail_update (stream->pcm);
+ ALSA_ERROR (avail_result, "snd_pcm_avail_update failed", FALSE);
+ if (avail_result == 0)
+ return TRUE;
+ avail = avail_result;
+ ALSA_ERROR (snd_pcm_mmap_begin (stream->pcm, &dst, &offset, &avail),
+ "snd_pcm_mmap_begin failed", FALSE);
+ //g_print (" avail = %u\n", (guint) avail);
+
+ avail = write_player (stream, dst, offset, avail);
+ if (snd_pcm_mmap_commit (stream->pcm, offset, avail) < 0) {
+ g_printerr ("snd_pcm_mmap_commit failed\n");
+ return FALSE;
+ }
+ stream->offset += avail;
+ //g_print ("offset: %u (+%u)\n", stream->offset, (guint) avail);
+ }
+ return TRUE;
+}
+
+static void
+swfdec_playback_stream_remove_handlers (Stream *stream)
+{
+ guint i;
+
+ for (i = 0; i < stream->n_sources; i++) {
+ if (stream->sources[i]) {
+ g_source_destroy (stream->sources[i]);
+ g_source_unref (stream->sources[i]);
+ stream->sources[i] = NULL;
+ }
+ }
+}
+
+static void swfdec_playback_stream_start (Stream *stream);
+static gboolean
+handle_stream (GIOChannel *source, GIOCondition cond, gpointer data)
+{
+ Stream *stream = data;
+ snd_pcm_state_t state;
+
+ state = snd_pcm_state (stream->pcm);
+ if (state != SND_PCM_STATE_RUNNING) {
+ swfdec_playback_stream_start (stream);
+ } else {
+ try_write (stream);
+ }
+ return TRUE;
+}
+
+static void
+swfdec_playback_stream_install_handlers (Stream *stream)
+{
+ GIOChannel *channel;
+
+ if (stream->n_sources > 0) {
+ struct pollfd polls[stream->n_sources];
+ guint i, count;
+ if (stream->n_sources > 1)
+ g_printerr ("attention: more than one fd!\n");
+ count = snd_pcm_poll_descriptors (stream->pcm, polls, stream->n_sources);
+ for (i = 0; i < count; i++) {
+ if (stream->sources[i] != NULL)
+ continue;
+ channel = g_io_channel_unix_new (polls[i].fd);
+ stream->sources[i] = g_io_create_watch (channel, polls[i].events);
+ g_source_set_priority (stream->sources[i], G_PRIORITY_HIGH);
+ g_source_set_callback (stream->sources[i], (GSourceFunc) handle_stream, stream, NULL);
+ g_io_channel_unref (channel);
+ g_source_attach (stream->sources[i], stream->sound->context);
+ }
+ }
+}
+
+static void
+swfdec_playback_stream_start (Stream *stream)
+{
+ snd_pcm_state_t state = snd_pcm_state (stream->pcm);
+ switch (state) {
+ case SND_PCM_STATE_XRUN:
+ ALSA_ERROR (snd_pcm_prepare (stream->pcm), "no prepare",);
+ //g_print ("XRUN!\n");
+ /* fall through */
+ case SND_PCM_STATE_SUSPENDED:
+ case SND_PCM_STATE_PREPARED:
+ stream->offset = 0;
+ //g_print ("offset: %u (delay: %ld)\n", sound->offset, delay);
+ if (try_write (stream)) {
+ ALSA_ERROR (snd_pcm_start (stream->pcm), "error starting",);
+ swfdec_playback_stream_install_handlers (stream);
+ }
+ break;
+ case SND_PCM_STATE_OPEN:
+ case SND_PCM_STATE_SETUP:
+ case SND_PCM_STATE_RUNNING:
+ case SND_PCM_STATE_DRAINING:
+ case SND_PCM_STATE_PAUSED:
+ case SND_PCM_STATE_DISCONNECTED:
+ default:
+ g_assert_not_reached ();
+ }
+}
+
+static void
+swfdec_playback_stream_open (SwfdecPlayback *sound, SwfdecAudio *audio)
+{
+ Stream *stream;
+ snd_pcm_t *ret;
+ snd_pcm_hw_params_t *hw_params;
+ guint rate;
+ snd_pcm_uframes_t uframes;
+
+ /* "default" uses dmix, and dmix ticks way slow, so this thingy here stutters */
+ ALSA_ERROR (snd_pcm_open (&ret, "default", SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK),
+ "Failed to open sound device", );
+
+ snd_pcm_hw_params_alloca (&hw_params);
+ if (snd_pcm_hw_params_any (ret, hw_params) < 0) {
+ g_printerr ("No sound format available\n");
+ return;
+ }
+ if (snd_pcm_hw_params_set_access (ret, hw_params, SND_PCM_ACCESS_MMAP_INTERLEAVED) < 0) {
+ g_printerr ("Failed setting access\n");
+ goto fail;
+ }
+ if (snd_pcm_hw_params_set_format (ret, hw_params, SND_PCM_FORMAT_S16) < 0) {
+ g_printerr ("Failed setting format\n");
+ goto fail;
+ }
+ if (snd_pcm_hw_params_set_channels (ret, hw_params, 2) < 0) {
+ g_printerr ("Failed setting channels\n");
+ goto fail;
+ }
+ rate = 44100;
+ if (snd_pcm_hw_params_set_rate_near (ret, hw_params, &rate, 0) < 0) {
+ g_printerr ("Failed setting rate\n");
+ goto fail;
+ }
+ uframes = 16384;
+ if (snd_pcm_hw_params_set_buffer_size_near (ret, hw_params, &uframes) < 0) {
+ g_printerr ("Failed setting buffer size\n");
+ goto fail;
+ }
+ if (snd_pcm_hw_params (ret, hw_params) < 0) {
+ g_printerr ("Could not set hardware parameters\n");
+ goto fail;
+ }
+#if 0
+ {
+ snd_output_t *log;
+ snd_output_stdio_attach (&log, stderr, 0);
+ snd_pcm_hw_params_dump (hw_params, log);
+ }
+#endif
+ stream = g_new0 (Stream, 1);
+ stream->sound = sound;
+ stream->audio = g_object_ref (audio);
+ stream->pcm = ret;
+ stream->n_sources = snd_pcm_poll_descriptors_count (ret);
+ if (stream->n_sources > 0)
+ stream->sources = g_new0 (GSource *, stream->n_sources);
+ sound->streams = g_list_prepend (sound->streams, stream);
+ swfdec_playback_stream_start (stream);
+ return;
+
+fail:
+ snd_pcm_close (ret);
+}
+
+static void
+swfdec_playback_stream_close (Stream *stream)
+{
+ ALSA_TRY (snd_pcm_close (stream->pcm), "failed closing");
+ swfdec_playback_stream_remove_handlers (stream);
+ g_free (stream->sources);
+ stream->sound->streams = g_list_remove (stream->sound->streams, stream);
+ g_object_unref (stream->audio);
+ g_free (stream);
+}
+
+/*** SOUND ***/
+
+static void
+advance_before (SwfdecPlayer *player, guint msecs, guint audio_samples, gpointer data)
+{
+ SwfdecPlayback *sound = data;
+ GList *walk;
+
+ for (walk = sound->streams; walk; walk = walk->next) {
+ Stream *stream = walk->data;
+ if (audio_samples >= stream->offset) {
+ stream->offset = 0;
+ } else {
+ stream->offset -= audio_samples;
+ }
+ }
+}
+
+static void
+audio_added (SwfdecPlayer *player, SwfdecAudio *audio, SwfdecPlayback *sound)
+{
+ swfdec_playback_stream_open (sound, audio);
+}
+
+static void
+audio_removed (SwfdecPlayer *player, SwfdecAudio *audio, SwfdecPlayback *sound)
+{
+ GList *walk;
+
+ for (walk = sound->streams; walk; walk = walk->next) {
+ Stream *stream = walk->data;
+ if (stream->audio == audio) {
+ swfdec_playback_stream_close (stream);
+ return;
+ }
+ }
+}
+
+SwfdecPlayback *
+swfdec_playback_open (SwfdecPlayer *player, GMainContext *context)
+{
+ SwfdecPlayback *sound;
+ const GList *walk;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (context != NULL, NULL);
+
+ sound = g_new0 (SwfdecPlayback, 1);
+ sound->player = player;
+ g_signal_connect (player, "advance", G_CALLBACK (advance_before), sound);
+ g_signal_connect (player, "audio-added", G_CALLBACK (audio_added), sound);
+ g_signal_connect (player, "audio-removed", G_CALLBACK (audio_removed), sound);
+ for (walk = swfdec_player_get_audio (player); walk; walk = walk->next) {
+ swfdec_playback_stream_open (sound, walk->data);
+ }
+ g_main_context_ref (context);
+ sound->context = context;
+ return sound;
+}
+
+void
+swfdec_playback_close (SwfdecPlayback *sound)
+{
+#define REMOVE_HANDLER_FULL(obj,func,data,count) G_STMT_START {\
+ if (g_signal_handlers_disconnect_by_func ((obj), \
+ G_CALLBACK (func), (data)) != (count)) { \
+ g_assert_not_reached (); \
+ } \
+} G_STMT_END
+#define REMOVE_HANDLER(obj,func,data) REMOVE_HANDLER_FULL (obj, func, data, 1)
+
+ while (sound->streams)
+ swfdec_playback_stream_close (sound->streams->data);
+ REMOVE_HANDLER (sound->player, advance_before, sound);
+ REMOVE_HANDLER (sound->player, audio_added, sound);
+ REMOVE_HANDLER (sound->player, audio_removed, sound);
+ g_main_context_unref (sound->context);
+ g_free (sound);
+}
+
+
diff --git a/swfdec-gtk/swfdec_playback_none.c b/swfdec-gtk/swfdec_playback_none.c
new file mode 100644
index 0000000..79651d6
--- /dev/null
+++ b/swfdec-gtk/swfdec_playback_none.c
@@ -0,0 +1,38 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_playback.h"
+
+/* STUBS ONLY - audio is disabled */
+
+SwfdecPlayback *
+swfdec_playback_open (SwfdecPlayer *player, GMainContext *context)
+{
+ return GINT_TO_POINTER (-1);
+}
+
+void
+swfdec_playback_close (SwfdecPlayback *sound)
+{
+ g_assert (sound == GINT_TO_POINTER (-1));
+}
diff --git a/swfdec-gtk/swfdec_playback_oss.c b/swfdec-gtk/swfdec_playback_oss.c
new file mode 100644
index 0000000..c2eb493
--- /dev/null
+++ b/swfdec-gtk/swfdec_playback_oss.c
@@ -0,0 +1,265 @@
+/* Swfdec
+ * Copyright © 2006 Benjamin Otte <otte at gnome.org>
+ * Copyright © 2007 Eric Anholt <eric at anholt.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/soundcard.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "swfdec_playback.h"
+
+/** @file Implements swfdec audio playback by opening /dev/dsp per stream
+ * and playing out through that.
+ *
+ * Allowing multiple access to /dev/dsp is not required by the OSS API spec,
+ * but FreeBSD's sound system lets you, which is what this file was written
+ * for.
+ */
+
+/*** DEFINITIONS ***/
+
+struct _SwfdecPlayback {
+ SwfdecPlayer * player;
+ GList * streams; /* all Stream objects */
+ GMainContext * context; /* context we work in */
+};
+
+typedef struct {
+ SwfdecPlayback * sound; /* reference to sound object */
+ SwfdecAudio * audio; /* the audio we play back */
+ int dsp_fd;
+ int fragsize; /* Audio fragment size */
+ GSource * source; /* source for writing data */
+ guint offset; /* offset into sound */
+} Stream;
+
+/* Size of one of our audio samples, in bytes */
+#define SAMPLESIZE 2
+#define CHANNELS 2
+
+/*** STREAMS ***/
+
+static gboolean
+handle_stream (GIOChannel *source, GIOCondition cond, gpointer data)
+{
+ Stream *stream = data;
+ char *frag = malloc(stream->fragsize);
+
+ if (frag == NULL) {
+ g_printerr ("Failed to allocate fragment of size %d\n",
+ stream->fragsize);
+ return FALSE;
+ }
+
+ while (TRUE) {
+ int ret;
+ audio_buf_info spaceinfo;
+
+ ret = ioctl(stream->dsp_fd, SNDCTL_DSP_GETOSPACE, &spaceinfo);
+ if (ret == -1) {
+ g_printerr ("Failed to get output buffer availability\n");
+ free(frag);
+ return FALSE;
+ }
+ g_assert(spaceinfo.fragsize == stream->fragsize);
+
+ if (spaceinfo.fragments == 0)
+ break;
+
+ memset (frag, 0, stream->fragsize);
+ swfdec_audio_render (stream->audio, (gint16 *)frag, stream->offset,
+ stream->fragsize / SAMPLESIZE / CHANNELS);
+
+ ret = write (stream->dsp_fd, frag, stream->fragsize);
+ if (ret != stream->fragsize) {
+ g_printerr ("Failed to write fragment\n");
+ free(frag);
+ return FALSE;
+ }
+
+ stream->offset += stream->fragsize / SAMPLESIZE / CHANNELS;
+ }
+
+ free(frag);
+
+ return TRUE;
+}
+
+static void
+swfdec_playback_stream_open (SwfdecPlayback *sound, SwfdecAudio *audio)
+{
+ GIOChannel *channel;
+ Stream *stream;
+ guint rate;
+ int dsp_fd, ret, format, channels, fragsize;
+
+ dsp_fd = open("/dev/dsp", O_WRONLY);
+ if (dsp_fd == -1) {
+ g_printerr ("Failed to open /dev/dsp\n");
+ return;
+ }
+
+ format = AFMT_S16_LE;
+ ret = ioctl(dsp_fd, SNDCTL_DSP_SETFMT, &format);
+ if (ret == -1) {
+ g_printerr ("Failed to set sound format\n");
+ close(dsp_fd);
+ return;
+ }
+
+ channels = 2;
+ ret = ioctl(dsp_fd, SNDCTL_DSP_CHANNELS, &channels);
+ if (ret == -1) {
+ g_printerr ("Failed to set stereo\n");
+ close(dsp_fd);
+ return;
+ }
+
+ rate = 44100;
+ ret = ioctl(dsp_fd, SNDCTL_DSP_SPEED, &rate);
+ if (ret == -1) {
+ g_printerr ("Failed to set rate\n");
+ close(dsp_fd);
+ return;
+ }
+
+ ret = ioctl(dsp_fd, SNDCTL_DSP_GETBLKSIZE, &fragsize);
+ if (ret == -1) {
+ g_printerr ("Failed to get fragment size\n");
+ close(dsp_fd);
+ return;
+ }
+
+ stream = g_new0 (Stream, 1);
+ stream->sound = sound;
+ stream->audio = g_object_ref (audio);
+ stream->dsp_fd = dsp_fd;
+ stream->fragsize = fragsize;
+ sound->streams = g_list_prepend (sound->streams, stream);
+
+ channel = g_io_channel_unix_new (stream->dsp_fd);
+ stream->source = g_io_create_watch (channel, G_IO_OUT);
+ g_source_set_priority (stream->source, G_PRIORITY_HIGH);
+ g_source_set_callback (stream->source, (GSourceFunc) handle_stream, stream,
+ NULL);
+ g_io_channel_unref (channel);
+ g_source_attach (stream->source, stream->sound->context);
+
+ return;
+}
+
+static void
+swfdec_playback_stream_close (Stream *stream)
+{
+ close (stream->dsp_fd);
+ g_source_destroy (stream->source);
+ g_source_unref (stream->source);
+ stream->sound->streams = g_list_remove (stream->sound->streams, stream);
+ g_object_unref (stream->audio);
+ g_free (stream);
+}
+
+/*** SOUND ***/
+
+static void
+advance_before (SwfdecPlayer *player, guint msecs, guint audio_samples, gpointer data)
+{
+ SwfdecPlayback *sound = data;
+ GList *walk;
+
+ for (walk = sound->streams; walk; walk = walk->next) {
+ Stream *stream = walk->data;
+ if (audio_samples >= stream->offset) {
+ stream->offset = 0;
+ } else {
+ stream->offset -= audio_samples;
+ }
+ }
+}
+
+static void
+audio_added (SwfdecPlayer *player, SwfdecAudio *audio, SwfdecPlayback *sound)
+{
+ swfdec_playback_stream_open (sound, audio);
+}
+
+static void
+audio_removed (SwfdecPlayer *player, SwfdecAudio *audio, SwfdecPlayback *sound)
+{
+ GList *walk;
+
+ for (walk = sound->streams; walk; walk = walk->next) {
+ Stream *stream = walk->data;
+ if (stream->audio == audio) {
+ swfdec_playback_stream_close (stream);
+ return;
+ }
+ }
+ g_assert_not_reached ();
+}
+
+SwfdecPlayback *
+swfdec_playback_open (SwfdecPlayer *player, GMainContext *context)
+{
+ SwfdecPlayback *sound;
+ const GList *walk;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (context != NULL, NULL);
+
+ sound = g_new0 (SwfdecPlayback, 1);
+ sound->player = player;
+ g_signal_connect (player, "advance", G_CALLBACK (advance_before), sound);
+ g_signal_connect (player, "audio-added", G_CALLBACK (audio_added), sound);
+ g_signal_connect (player, "audio-removed", G_CALLBACK (audio_removed), sound);
+ for (walk = swfdec_player_get_audio (player); walk; walk = walk->next) {
+ swfdec_playback_stream_open (sound, walk->data);
+ }
+ g_main_context_ref (context);
+ sound->context = context;
+ return sound;
+}
+
+void
+swfdec_playback_close (SwfdecPlayback *sound)
+{
+#define REMOVE_HANDLER_FULL(obj,func,data,count) G_STMT_START {\
+ if (g_signal_handlers_disconnect_by_func ((obj), \
+ G_CALLBACK (func), (data)) != (count)) { \
+ g_assert_not_reached (); \
+ } \
+} G_STMT_END
+#define REMOVE_HANDLER(obj,func,data) REMOVE_HANDLER_FULL (obj, func, data, 1)
+
+ while (sound->streams)
+ swfdec_playback_stream_close (sound->streams->data);
+ REMOVE_HANDLER (sound->player, advance_before, sound);
+ REMOVE_HANDLER (sound->player, audio_added, sound);
+ REMOVE_HANDLER (sound->player, audio_removed, sound);
+ g_main_context_unref (sound->context);
+ g_free (sound);
+}
+
+
diff --git a/swfdec-gtk/swfdec_playback_pa.c b/swfdec-gtk/swfdec_playback_pa.c
new file mode 100644
index 0000000..755b033
--- /dev/null
+++ b/swfdec-gtk/swfdec_playback_pa.c
@@ -0,0 +1,350 @@
+/* Swfdec
+ * Copyright © 2006 Benjamin Otte <otte at gnome.org>
+ * Copyright © 2007 Eric Anholt <eric at anholt.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "swfdec_playback.h"
+#include "pulse/pulseaudio.h"
+#include "pulse/glib-mainloop.h"
+
+/** @file Implements swfdec audio playback by dumping swfdec streams out
+ * using pulseaudio streams.
+ */
+
+/*** DEFINITIONS ***/
+
+struct _SwfdecPlayback {
+ SwfdecPlayer * player;
+ GList * streams; /* all Stream objects */
+ GMainContext * context; /* glib context we work in */
+ pa_glib_mainloop * pa_mainloop; /* PA to glib mainloop connection */
+ pa_context * pa; /* PA context for sound rendering */
+};
+
+typedef struct {
+ SwfdecPlayback * sound; /* reference to sound object */
+ SwfdecAudio * audio; /* the audio we play back */
+ guint offset; /* offset into sound */
+ pa_stream * pa; /* PA stream */
+ pa_cvolume volume; /* Volume control. Not yet used. */
+ gboolean no_more;
+} Stream;
+
+/* Size of one of our audio samples, in bytes */
+#define SAMPLESIZE 2
+#define CHANNELS 2
+
+/*** STREAMS ***/
+
+static void
+stream_write_callback (pa_stream *pa,
+ size_t bytes,
+ void *data)
+{
+ Stream *stream = data;
+ char *frag;
+ unsigned int samples = bytes / SAMPLESIZE / CHANNELS;
+ int err;
+
+ if (stream->no_more)
+ return;
+
+ /* Adjust to our rounded-down number */
+ bytes = samples * SAMPLESIZE * CHANNELS;
+
+ frag = malloc (bytes);
+ if (frag == NULL) {
+ g_printerr ("Failed to allocate fragment of size %d\n", (int)bytes);
+ return;
+ }
+
+ /* Set up our fragment and render swfdec's audio into it. The swfdec audio
+ * decoder renders deltas from the existing data in the fragment.
+ */
+ memset (frag, 0, bytes);
+ swfdec_audio_render (stream->audio, (gint16 *)frag, stream->offset,
+ samples);
+
+ /* Send the new fragment out the PA stream */
+ err = pa_stream_write (pa, frag, bytes, NULL, 0, PA_SEEK_RELATIVE);
+ if (err != 0) {
+ g_printerr ("Failed to write fragment to PA stream: %s\n",
+ pa_strerror(pa_context_errno(stream->sound->pa)));
+ }
+
+ /* Advance playback pointer */
+ stream->offset += samples;
+
+ free(frag);
+}
+
+static void
+stream_drain_complete (pa_stream *pa, int success, void *data)
+{
+ Stream *stream = data;
+
+ pa_stream_disconnect (stream->pa);
+ pa_stream_unref (stream->pa);
+ g_object_unref (stream->audio);
+ g_free (stream);
+}
+
+static void
+swfdec_playback_stream_close (Stream *stream)
+{
+ /* Pull it off of the active stream list. */
+ stream->sound->streams = g_list_remove (stream->sound->streams, stream);
+
+ /* If we have created a PA stream, defer freeing until we drain it. */
+ if (stream->pa != NULL) {
+ stream->no_more = 1;
+ pa_operation_unref (pa_stream_drain (stream->pa,
+ stream_drain_complete,
+ stream));
+ } else {
+ g_object_unref (stream->audio);
+ g_free (stream);
+ }
+}
+
+static void
+stream_state_callback (pa_stream *pa, void *data)
+{
+ switch (pa_stream_get_state(pa)) {
+ case PA_STREAM_CREATING:
+ case PA_STREAM_TERMINATED:
+ case PA_STREAM_READY:
+ case PA_STREAM_UNCONNECTED:
+ break;
+
+ case PA_STREAM_FAILED:
+ g_printerr("PA stream failed: %s\n",
+ pa_strerror(pa_context_errno(pa_stream_get_context(pa))));
+ default:
+ break;
+ }
+}
+
+static void
+swfdec_playback_stream_open (SwfdecPlayback *sound, SwfdecAudio *audio)
+{
+ Stream *stream;
+ pa_sample_spec spec = {
+ .format = PA_SAMPLE_S16LE,
+ .rate = 44100,
+ .channels = CHANNELS,
+ };
+ int err;
+
+ stream = g_new0 (Stream, 1);
+ stream->sound = sound;
+ stream->audio = g_object_ref (audio);
+ sound->streams = g_list_prepend (sound->streams, stream);
+
+ /* If we failed to initialize the context, don't try to create the stream.
+ * We still have to get put in the list, because swfdec_playback.c expects
+ * to find it in the list for removal later.
+ */
+ if (sound->pa == NULL)
+ return;
+
+ /* Create our stream */
+ stream->pa = pa_stream_new(sound->pa,
+ "swfdec stream",
+ &spec,
+ NULL /* Default channel map */
+ );
+ if (stream->pa == NULL) {
+ g_printerr("Failed to create PA stream\n");
+ swfdec_playback_stream_close(stream);
+ return;
+ }
+
+ /* Start at default volume */
+ pa_cvolume_set(&stream->volume, CHANNELS, PA_VOLUME_NORM);
+
+ /* Hook up our stream write callback for when new data is needed */
+ pa_stream_set_state_callback(stream->pa, stream_state_callback, stream);
+ pa_stream_set_write_callback(stream->pa, stream_write_callback, stream);
+
+ /* Connect it up as a playback stream. */
+ err = pa_stream_connect_playback(stream->pa,
+ NULL, /* Default device */
+ NULL /* Default buffering */,
+ 0, /* No flags */
+ &stream->volume,
+ NULL /* Don't sync to any stream */
+ );
+ if (err != 0) {
+ g_printerr ("Failed to connect PA stream: %s\n",
+ pa_strerror(pa_context_errno(sound->pa)));
+ swfdec_playback_stream_close(stream);
+ return;
+ }
+}
+
+/*** SOUND ***/
+
+static void
+advance_before (SwfdecPlayer *player, guint msecs, guint audio_samples, gpointer data)
+{
+ SwfdecPlayback *sound = data;
+ GList *walk;
+
+ for (walk = sound->streams; walk; walk = walk->next) {
+ Stream *stream = walk->data;
+ if (audio_samples >= stream->offset) {
+ stream->offset = 0;
+ } else {
+ stream->offset -= audio_samples;
+ }
+ }
+}
+
+static void
+audio_added (SwfdecPlayer *player, SwfdecAudio *audio, SwfdecPlayback *sound)
+{
+ swfdec_playback_stream_open (sound, audio);
+}
+
+static void
+audio_removed (SwfdecPlayer *player, SwfdecAudio *audio, SwfdecPlayback *sound)
+{
+ GList *walk;
+
+ for (walk = sound->streams; walk; walk = walk->next) {
+ Stream *stream = walk->data;
+ if (stream->audio == audio) {
+ swfdec_playback_stream_close (stream);
+ return;
+ }
+ }
+ g_assert_not_reached ();
+}
+static void
+context_state_callback (pa_context *pa, void *data)
+{
+ SwfdecPlayback *sound = data;
+
+ switch (pa_context_get_state(pa)) {
+ case PA_CONTEXT_FAILED:
+ g_printerr ("PA context failed\n");
+ pa_context_unref (pa);
+ sound->pa = NULL;
+ break;
+
+ default:
+ case PA_CONTEXT_TERMINATED:
+ case PA_CONTEXT_UNCONNECTED:
+ case PA_CONTEXT_CONNECTING:
+ case PA_CONTEXT_AUTHORIZING:
+ case PA_CONTEXT_SETTING_NAME:
+ case PA_CONTEXT_READY:
+ break;
+
+ }
+}
+
+SwfdecPlayback *
+swfdec_playback_open (SwfdecPlayer *player, GMainContext *context)
+{
+ SwfdecPlayback *sound;
+ const GList *walk;
+ pa_mainloop_api *pa_api;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (context != NULL, NULL);
+
+ sound = g_new0 (SwfdecPlayback, 1);
+ sound->player = player;
+ g_signal_connect (player, "advance", G_CALLBACK (advance_before), sound);
+ g_signal_connect (player, "audio-added", G_CALLBACK (audio_added), sound);
+ g_signal_connect (player, "audio-removed", G_CALLBACK (audio_removed), sound);
+
+ /* Create our mainloop attachment to glib. XXX: I hope this means we don't
+ * have to run the main loop using pa functions.
+ */
+ sound->pa_mainloop = pa_glib_mainloop_new (context);
+ pa_api = pa_glib_mainloop_get_api (sound->pa_mainloop);
+
+ sound->pa = pa_context_new (pa_api, "swfdec");
+
+ pa_context_set_state_callback (sound->pa, context_state_callback, sound);
+ pa_context_connect (sound->pa,
+ NULL, /* default server */
+ 0, /* default flags */
+ NULL /* spawning api */
+ );
+
+ for (walk = swfdec_player_get_audio (player); walk; walk = walk->next) {
+ swfdec_playback_stream_open (sound, walk->data);
+ }
+ g_main_context_ref (context);
+ sound->context = context;
+ return sound;
+}
+
+static void
+context_drain_complete (pa_context *pa, void *data)
+{
+ pa_context_disconnect (pa);
+ pa_context_unref (pa);
+}
+
+void
+swfdec_playback_close (SwfdecPlayback *sound)
+{
+ pa_operation *op;
+
+#define REMOVE_HANDLER_FULL(obj,func,data,count) G_STMT_START {\
+ if (g_signal_handlers_disconnect_by_func ((obj), \
+ G_CALLBACK (func), (data)) != (count)) { \
+ g_assert_not_reached (); \
+ } \
+} G_STMT_END
+#define REMOVE_HANDLER(obj,func,data) REMOVE_HANDLER_FULL (obj, func, data, 1)
+
+ while (sound->streams)
+ swfdec_playback_stream_close (sound->streams->data);
+ REMOVE_HANDLER (sound->player, advance_before, sound);
+ REMOVE_HANDLER (sound->player, audio_added, sound);
+ REMOVE_HANDLER (sound->player, audio_removed, sound);
+
+ if (sound->pa != NULL) {
+ op = pa_context_drain (sound->pa, context_drain_complete, NULL);
+ if (op == NULL) {
+ pa_context_disconnect (sound->pa);
+ pa_context_unref (sound->pa);
+ } else {
+ pa_operation_unref (op);
+ }
+ pa_glib_mainloop_free (sound->pa_mainloop);
+ }
+
+ g_main_context_unref (sound->context);
+ g_free (sound);
+}
+
+
diff --git a/swfdec-gtk/swfdec_source.c b/swfdec-gtk/swfdec_source.c
new file mode 100644
index 0000000..471b99b
--- /dev/null
+++ b/swfdec-gtk/swfdec_source.c
@@ -0,0 +1,183 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include "swfdec_source.h"
+
+static glong
+my_time_val_difference (const GTimeVal *compare, const GTimeVal *now)
+{
+ return (compare->tv_sec - now->tv_sec) * 1000 +
+ (compare->tv_usec - now->tv_usec) / 1000;
+}
+
+/*** SwfdecIterateSource ***/
+
+typedef struct _SwfdecIterateSource SwfdecIterateSource;
+struct _SwfdecIterateSource {
+ GSource source;
+ SwfdecPlayer * player; /* player we manage or NULL if player was deleted */
+ double speed; /* inverse playback speed (so 0.5 means double speed) */
+ gulong notify; /* set for iterate notifications (only valid when player != NULL) */
+ GTimeVal last; /* last time */
+};
+
+static glong
+swfdec_iterate_get_msecs_to_next_event (GSource *source_)
+{
+ SwfdecIterateSource *source = (SwfdecIterateSource *) source_;
+ GTimeVal now;
+ glong diff;
+
+ g_assert (source->player);
+ diff = swfdec_player_get_next_event (source->player);
+ if (diff == -1)
+ return G_MAXLONG;
+ diff *= source->speed;
+ g_source_get_current_time (source_, &now);
+ /* should really add to source->last instead of subtracting from now */
+ g_time_val_add (&now, -diff * 1000);
+ diff = my_time_val_difference (&source->last, &now);
+
+ return diff;
+}
+
+static gboolean
+swfdec_iterate_prepare (GSource *source, gint *timeout)
+{
+ glong diff;
+
+ diff = swfdec_iterate_get_msecs_to_next_event (source);
+ if (((SwfdecIterateSource *) source)->player == NULL) {
+ *timeout = 0;
+ return TRUE;
+ }
+
+ if (diff == G_MAXLONG) {
+ *timeout = -1;
+ return FALSE;
+ } else if (diff <= 0) {
+ *timeout = 0;
+ return TRUE;
+ } else {
+ *timeout = diff;
+ return FALSE;
+ }
+}
+
+static gboolean
+swfdec_iterate_check (GSource *source)
+{
+ glong diff;
+
+ if (((SwfdecIterateSource *) source)->player == NULL)
+ return 0;
+ diff = swfdec_iterate_get_msecs_to_next_event (source);
+ return diff < 0;
+}
+
+static gboolean
+swfdec_iterate_dispatch (GSource *source_, GSourceFunc callback, gpointer user_data)
+{
+ SwfdecIterateSource *source = (SwfdecIterateSource *) source_;
+ glong diff;
+
+ if (source->player == NULL)
+ return FALSE;
+ diff = swfdec_iterate_get_msecs_to_next_event (source_);
+ if (diff > 0)
+ return TRUE;
+ diff = swfdec_player_get_next_event (source->player) - diff;
+ swfdec_player_advance (source->player, diff);
+ return TRUE;
+}
+
+static void
+swfdec_iterate_finalize (GSource *source_)
+{
+ SwfdecIterateSource *source = (SwfdecIterateSource *) source_;
+
+ if (source->notify && source->player) {
+ g_signal_handler_disconnect (source->player, source->notify);
+ }
+ if (source->player) {
+ g_object_remove_weak_pointer (G_OBJECT (source->player), (gpointer) &source->player);
+ }
+}
+
+GSourceFuncs swfdec_iterate_funcs = {
+ swfdec_iterate_prepare,
+ swfdec_iterate_check,
+ swfdec_iterate_dispatch,
+ swfdec_iterate_finalize
+};
+
+static void
+swfdec_iterate_source_advance_cb (SwfdecPlayer *player, guint msecs,
+ guint audio_frames, SwfdecIterateSource *source)
+{
+ g_time_val_add (&source->last, msecs * 1000 * source->speed);
+}
+
+GSource *
+swfdec_iterate_source_new (SwfdecPlayer *player, double speed)
+{
+ SwfdecIterateSource *source;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (speed > 0.0, NULL);
+
+ source = (SwfdecIterateSource *) g_source_new (&swfdec_iterate_funcs,
+ sizeof (SwfdecIterateSource));
+ source->player = player;
+ g_object_add_weak_pointer (G_OBJECT (source->player), (gpointer) &source->player);
+ source->speed = 1.0 / speed;
+ source->notify = g_signal_connect (player, "advance",
+ G_CALLBACK (swfdec_iterate_source_advance_cb), source);
+ g_get_current_time (&source->last);
+
+ return (GSource *) source;
+}
+
+void
+swfdec_iterate_source_set_speed (GSource *source, double speed)
+{
+ /* FIXME: need a return_if_fail if wrong source? */
+ g_return_if_fail (speed > 0.0);
+
+ ((SwfdecIterateSource *) source)->speed = 1.0 / speed;
+}
+
+guint
+swfdec_iterate_add (SwfdecPlayer *player)
+{
+ GSource *source;
+ guint id;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), 0);
+
+ source = swfdec_iterate_source_new (player, 1.0);
+
+ id = g_source_attach (source, NULL);
+ g_source_unref (source);
+
+ return id;
+}
diff --git a/swfdec-gtk/swfdec_source.h b/swfdec-gtk/swfdec_source.h
new file mode 100644
index 0000000..0c7c383
--- /dev/null
+++ b/swfdec-gtk/swfdec_source.h
@@ -0,0 +1,34 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_SOURCE_H_
+#define _SWFDEC_SOURCE_H_
+
+#include <libswfdec/swfdec.h>
+
+G_BEGIN_DECLS
+
+GSource * swfdec_iterate_source_new (SwfdecPlayer * player,
+ double speed);
+void swfdec_iterate_source_set_speed (GSource * source,
+ double speed);
+guint swfdec_iterate_add (SwfdecPlayer * player);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/.gitignore b/swfdec/.gitignore
new file mode 100644
index 0000000..9f923f0
--- /dev/null
+++ b/swfdec/.gitignore
@@ -0,0 +1,19 @@
+*~
+CVS
+.cvsignore
+.deps
+.libs
+
+Makefile
+Makefile.in
+*.o
+*.la
+*.lo
+*.loT
+
+swfdec_as_strings.h
+swfdec_asnative.h
+swfdec_enums.[ch]
+swfdec_marshal.[ch]
+
+compiler
diff --git a/swfdec/Makefile.am b/swfdec/Makefile.am
new file mode 100644
index 0000000..dc62604
--- /dev/null
+++ b/swfdec/Makefile.am
@@ -0,0 +1,372 @@
+SUBDIRS = jpeg
+
+CODECS =
+
+if HAVE_FFMPEG
+CODECS += swfdec_codec_ffmpeg.c
+endif
+if HAVE_GST
+CODECS += swfdec_codec_gst.c
+endif
+if HAVE_MAD
+CODECS += swfdec_codec_mad.c
+endif
+
+lib_LTLIBRARIES = libswfdec- at SWFDEC_MAJORMINOR@.la
+
+# these are files that must be in SRCDIR
+libswfdec_source_files = \
+ swfdec_accessibility.c \
+ swfdec_as_array.c \
+ swfdec_as_boolean.c \
+ swfdec_as_context.c \
+ swfdec_as_date.c \
+ swfdec_as_debugger.c \
+ swfdec_as_frame.c \
+ swfdec_as_function.c \
+ swfdec_as_interpret.c \
+ swfdec_as_math.c \
+ swfdec_as_native_function.c \
+ swfdec_as_number.c \
+ swfdec_as_object.c \
+ swfdec_as_script_function.c \
+ swfdec_as_stack.c \
+ swfdec_as_string.c \
+ swfdec_as_strings.c \
+ swfdec_as_super.c \
+ swfdec_as_types.c \
+ swfdec_amf.c \
+ swfdec_asbroadcaster.c \
+ swfdec_audio.c \
+ swfdec_audio_event.c \
+ swfdec_audio_flv.c \
+ swfdec_audio_stream.c \
+ swfdec_bevel_filter.c \
+ swfdec_bitmap_data.c \
+ swfdec_bitmap_filter.c \
+ swfdec_bits.c \
+ swfdec_blur_filter.c \
+ swfdec_buffer.c \
+ swfdec_button.c \
+ swfdec_button_movie.c \
+ swfdec_button_movie_as.c \
+ swfdec_cache.c \
+ swfdec_cached.c \
+ swfdec_camera.c \
+ swfdec_character.c \
+ swfdec_codec_adpcm.c \
+ swfdec_codec_audio.c \
+ $(CODECS) \
+ swfdec_codec_screen.c \
+ swfdec_codec_video.c \
+ swfdec_codec_vp6_alpha.c \
+ swfdec_color.c \
+ swfdec_color_as.c \
+ swfdec_color_matrix_filter.c \
+ swfdec_color_transform.c \
+ swfdec_convolution_filter.c \
+ swfdec_debug.c \
+ swfdec_decoder.c \
+ swfdec_displacement_map_filter.c \
+ swfdec_draw.c \
+ swfdec_drop_shadow_filter.c \
+ swfdec_event.c \
+ swfdec_external_interface.c \
+ swfdec_file_loader.c \
+ swfdec_file_reference.c \
+ swfdec_file_reference_list.c \
+ swfdec_filter.c \
+ swfdec_filter_as.c \
+ swfdec_flv_decoder.c \
+ swfdec_font.c \
+ swfdec_function_list.c \
+ swfdec_glow_filter.c \
+ swfdec_gradient_filter.c \
+ swfdec_gradient_pattern.c \
+ swfdec_graphic.c \
+ swfdec_graphic_movie.c \
+ swfdec_image.c \
+ swfdec_image_decoder.c \
+ swfdec_interval.c \
+ swfdec_key_as.c \
+ swfdec_load_object.c \
+ swfdec_load_object_as.c \
+ swfdec_loader.c \
+ swfdec_loadvars_as.c \
+ swfdec_local_connection.c \
+ swfdec_microphone.c \
+ swfdec_morph_movie.c \
+ swfdec_morphshape.c \
+ swfdec_mouse_as.c \
+ swfdec_movie.c \
+ swfdec_movie_as_drawing.c \
+ swfdec_movie_asprops.c \
+ swfdec_movie_clip_loader.c \
+ swfdec_net_connection.c \
+ swfdec_net_stream.c \
+ swfdec_net_stream_as.c \
+ swfdec_path.c \
+ swfdec_pattern.c \
+ swfdec_player.c \
+ swfdec_player_as.c \
+ swfdec_player_scripting.c \
+ swfdec_print_job.c \
+ swfdec_policy_file.c \
+ swfdec_rect.c \
+ swfdec_rectangle.c \
+ swfdec_resource.c \
+ swfdec_ringbuffer.c \
+ swfdec_sandbox.c \
+ swfdec_script.c \
+ swfdec_selection.c \
+ swfdec_shape.c \
+ swfdec_shape_parser.c \
+ swfdec_shared_object.c \
+ swfdec_socket.c \
+ swfdec_sound.c \
+ swfdec_sound_object.c \
+ swfdec_sprite.c \
+ swfdec_sprite_movie.c \
+ swfdec_sprite_movie_as.c \
+ swfdec_stage_as.c \
+ swfdec_stream.c \
+ swfdec_stream_target.c \
+ swfdec_stroke.c \
+ swfdec_style_sheet.c \
+ swfdec_swf_decoder.c \
+ swfdec_system.c \
+ swfdec_system_as.c \
+ swfdec_system_ime.c \
+ swfdec_system_security.c \
+ swfdec_tag.c \
+ swfdec_text.c \
+ swfdec_text_field.c \
+ swfdec_text_field_movie.c \
+ swfdec_text_field_movie_as.c \
+ swfdec_text_field_movie_html.c \
+ swfdec_text_format.c \
+ swfdec_text_renderer.c \
+ swfdec_text_snapshot.c \
+ swfdec_transform.c \
+ swfdec_url.c \
+ swfdec_utils.c \
+ swfdec_video.c \
+ swfdec_video_movie.c \
+ swfdec_video_movie_as.c \
+ swfdec_xml_node.c \
+ swfdec_xml.c \
+ swfdec_xml_socket.c
+
+libswfdec_ at SWFDEC_MAJORMINOR@_la_SOURCES = \
+ $(libswfdec_source_files) \
+ swfdec_enums.c \
+ swfdec_marshal.c
+
+libswfdec_ at SWFDEC_MAJORMINOR@_la_CFLAGS = \
+ $(GLOBAL_CFLAGS) $(CAIRO_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) \
+ -I$(top_srcdir) -I$(srcdir)/jpeg/ $(LIBOIL_CFLAGS) \
+ $(GST_CFLAGS) $(FFMPEG_CFLAGS) $(MAD_CFLAGS) \
+ -DG_LOG_DOMAIN=\"Swfdec\"
+libswfdec_ at SWFDEC_MAJORMINOR@_la_LDFLAGS = \
+ $(SYMBOLIC_LDFLAGS) \
+ -version-info $(SWFDEC_LIBVERSION) \
+ -export-symbols-regex '^(swfdec_.*)' \
+ $(CAIRO_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) $(LIBOIL_LIBS) -lz \
+ $(MAD_LIBS) $(FFMPEG_LIBS) $(GST_LIBS)
+
+public_headers = \
+ swfdec.h \
+ swfdec_as_array.h \
+ swfdec_as_context.h \
+ swfdec_as_debugger.h \
+ swfdec_as_frame.h \
+ swfdec_as_function.h \
+ swfdec_as_native_function.h \
+ swfdec_as_object.h \
+ swfdec_as_types.h \
+ swfdec_audio.h \
+ swfdec_buffer.h \
+ swfdec_file_loader.h \
+ swfdec_keys.h \
+ swfdec_loader.h \
+ swfdec_player.h \
+ swfdec_player_scripting.h \
+ swfdec_rectangle.h \
+ swfdec_script.h \
+ swfdec_socket.h \
+ swfdec_stream.h \
+ swfdec_system.h \
+ swfdec_url.h
+
+libswfdec_ at SWFDEC_MAJORMINOR@_la_LIBADD = jpeg/libjpeg.la
+libswfdec_ at SWFDEC_MAJORMINOR@includedir = $(includedir)/swfdec- at SWFDEC_MAJORMINOR@/libswfdec
+libswfdec_ at SWFDEC_MAJORMINOR@include_HEADERS = $(public_headers) swfdec_enums.h
+
+noinst_HEADERS = \
+ swfdec_as_boolean.h \
+ swfdec_as_frame_internal.h \
+ swfdec_as_initialize.h \
+ swfdec_as_internal.h \
+ swfdec_as_date.h \
+ swfdec_as_interpret.h \
+ swfdec_as_number.h \
+ swfdec_as_script_function.h \
+ swfdec_as_stack.h \
+ swfdec_as_string.h \
+ swfdec_as_strings.h \
+ swfdec_as_super.h \
+ swfdec_asnative.h \
+ swfdec_amf.h \
+ swfdec_audio_internal.h \
+ swfdec_audio_event.h \
+ swfdec_audio_flv.h \
+ swfdec_audio_stream.h \
+ swfdec_bits.h \
+ swfdec_button.h \
+ swfdec_button_movie.h \
+ swfdec_cache.h \
+ swfdec_cached.h \
+ swfdec_character.h \
+ swfdec_codec_audio.h \
+ swfdec_codec_video.h \
+ swfdec_color.h \
+ swfdec_debug.h \
+ swfdec_decoder.h \
+ swfdec_draw.h \
+ swfdec_text_field.h \
+ swfdec_text_field_movie.h \
+ swfdec_event.h \
+ swfdec_filter.h \
+ swfdec_flv_decoder.h \
+ swfdec_font.h \
+ swfdec_function_list.h \
+ swfdec_gradient_pattern.h \
+ swfdec_graphic.h \
+ swfdec_graphic_movie.h \
+ swfdec_image.h \
+ swfdec_image_decoder.h \
+ swfdec_initialize.h \
+ swfdec_internal.h \
+ swfdec_interval.h \
+ swfdec_load_object.h \
+ swfdec_loader_internal.h \
+ swfdec_marshal.h \
+ swfdec_morph_movie.h \
+ swfdec_morphshape.h \
+ swfdec_movie.h \
+ swfdec_movie_clip_loader.h \
+ swfdec_net_connection.h \
+ swfdec_net_stream.h \
+ swfdec_path.h \
+ swfdec_pattern.h \
+ swfdec_player_internal.h \
+ swfdec_policy_file.h \
+ swfdec_rect.h \
+ swfdec_resource.h \
+ swfdec_ringbuffer.h \
+ swfdec_sandbox.h \
+ swfdec_script_internal.h \
+ swfdec_shape.h \
+ swfdec_shape_parser.h \
+ swfdec_sound.h \
+ swfdec_sound_object.h \
+ swfdec_sprite.h \
+ swfdec_sprite_movie.h \
+ swfdec_swf_decoder.h \
+ swfdec_stream_target.h \
+ swfdec_stroke.h \
+ swfdec_style_sheet.h \
+ swfdec_tag.h \
+ swfdec_text.h \
+ swfdec_text_format.h \
+ swfdec_types.h \
+ swfdec_utils.h \
+ swfdec_video.h \
+ swfdec_video_movie.h \
+ swfdec_xml_node.h \
+ swfdec_xml.h \
+ swfdec_xml_socket.h
+
+EXTRA_DIST = \
+ compiler.c \
+ swfdec_as_initialize.as \
+ swfdec_initialize.as \
+ swfdec_marshal.list
+
+BUILT_SOURCES = \
+ swfdec_asnative.h \
+ swfdec_as_strings.h \
+ swfdec_enums.c \
+ swfdec_enums.h \
+ swfdec_marshal.c \
+ swfdec_marshal.h
+
+CLEANFILES = \
+ $(BUILT_SOURCES)
+
+swfdec_asnative.h: $(libswfdec_source_files)
+ (cd $(srcdir) \
+ && echo "#include \"swfdec_as_types.h\"" \
+ && echo "#define SWFDEC_AS_NATIVE(x,y,func) void func (SwfdecAsContext *cx, \\" \
+ && echo " SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret);" \
+ && echo "#define SWFDEC_AS_CONSTRUCTOR(x,y,func,type) SWFDEC_AS_NATIVE(x,y,func) GType type (void);" \
+ && grep -he "^SWFDEC_AS_CONSTRUCTOR" $(libswfdec_source_files) \
+ && grep -he "^SWFDEC_AS_NATIVE" $(libswfdec_source_files) \
+ && echo "#undef SWFDEC_AS_CONSTRUCTOR" \
+ && echo "#undef SWFDEC_AS_NATIVE" \
+ && echo "#define SWFDEC_AS_NATIVE(x,y,func) SWFDEC_AS_CONSTRUCTOR(x,y,func,NULL)" \
+ && echo "#define SWFDEC_AS_CONSTRUCTOR(x,y,func,type) { x, y, func, G_STRINGIFY (func), type }," \
+ && echo "static const struct { guint x, y; SwfdecAsNative func; const char *name; GType (* get_type) (void); } native_funcs[] = {" \
+ && grep -he "^SWFDEC_AS_CONSTRUCTOR" $(libswfdec_source_files) \
+ && grep -he "^SWFDEC_AS_NATIVE" $(libswfdec_source_files) \
+ && echo " { 0, 0, NULL }" \
+ && echo "};" \
+ && echo "#undef SWFDEC_AS_CONSTRUCTOR" \
+ && echo "#undef SWFDEC_AS_NATIVE" \
+ ) >> xgen-san \
+ && (cmp -s xgen-san swfdec_asnative.h || cp xgen-san swfdec_asnative.h) \
+ && rm -f xgen-san
+
+swfdec_marshal.h: swfdec_marshal.list Makefile
+ $(GLIB_GENMARSHAL) --prefix=swfdec_marshal $(srcdir)/swfdec_marshal.list --header >> xgen-smh \
+ && (cmp -s xgen-smh swfdec_marshal.h || cp xgen-smh swfdec_marshal.h) \
+ && rm -f xgen-smh
+
+swfdec_marshal.c: swfdec_marshal.list swfdec_marshal.h Makefile
+ (echo "#include \"swfdec_marshal.h\""; \
+ $(GLIB_GENMARSHAL) --prefix=swfdec_marshal $(srcdir)/swfdec_marshal.list --body;) >> xgen-smc \
+ && cp xgen-smc swfdec_marshal.c \
+ && rm -f xgen-smc
+
+swfdec_enums.h: $(public_headers) Makefile
+ ( cd $(srcdir) && $(GLIB_MKENUMS) \
+ --fhead "#ifndef __SWFDEC_ENUMS_H__\n#define __SWFDEC_ENUMS_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \
+ --fprod "/* enumerations from \"@filename@\" */\n" \
+ --vhead "GType @enum_name at _get_type (void) G_GNUC_CONST;\n#define SWFDEC_TYPE_ at ENUMSHORT@ (@enum_name at _get_type())\n" \
+ --ftail "G_END_DECLS\n\n#endif /* __SWFDEC_ENUMS_H__ */" \
+ $(public_headers) ) >> xgen-seh \
+ && (cmp -s xgen-seh swfdec_enums.h || cp xgen-seh swfdec_enums.h ) \
+ && rm -f xgen-seh
+
+swfdec_enums.c: $(public_headers) Makefile
+ ( cd $(srcdir) && $(GLIB_MKENUMS) \
+ --fhead "#include \"swfdec.h\"\n" \
+ --fprod "\n/* enumerations from \"@filename@\" */" \
+ --vhead "GType\n at enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G at Type@Value values[] = {" \
+ --vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
+ --vtail " { 0, NULL, NULL }\n };\n etype = g_ at type@_register_static (g_intern_static_string (\"@EnumName@\"), values);\n }\n return etype;\n}\n" \
+ $(public_headers) ) > xgen-sec \
+ && (cmp -s xgen-sec swfdec_enums.c || cp xgen-sec swfdec_enums.c ) \
+ && rm -f xgen-sec
+
+swfdec_as_strings.h: swfdec_as_strings.c
+ ( cd $(srcdir) && echo "/* This is a generated file. See swfdec_as_strings.c for details. */" \
+ && echo "#ifndef _SWFDEC_AS_STRINGS_H_" \
+ && echo "#define _SWFDEC_AS_STRINGS_H_" \
+ && echo "extern const char swfdec_as_strings[];" \
+ && grep " SWFDEC_AS_CONSTANT_STRING" swfdec_as_strings.c \
+ | sed "s/.*(\"\(.*\)\").*/\1/" \
+ | $(AWK) '{ if ($$0 == "") name = "EMPTY"; else if ($$0 == ",") name = "COMMA"; else if ($$0 == "/") name = "SLASH"; else name = $$0; gsub("[^a-zA-Z0-9\\$$]","_",name); print "#define SWFDEC_AS_STR_" name " &swfdec_as_strings[" x + 1 "]"; x = x + length ($$0) + 2 }' \
+ && echo "#endif" ) > xgen-sas \
+ && (cmp -s xgen-sas swfdec_as_strings.h || cp xgen-sas swfdec_as_strings.h ) \
+ && rm -f xgen-sas
diff --git a/swfdec/compiler.c b/swfdec/compiler.c
new file mode 100644
index 0000000..5593cec
--- /dev/null
+++ b/swfdec/compiler.c
@@ -0,0 +1,92 @@
+//gcc -Wall -Werror `pkg-config --libs --cflags libming glib-2.0` compiler.c -o compiler
+
+#include <glib.h>
+#include <ming.h>
+#include <string.h>
+
+/* This is what is used to compile the Actionscript parts of the source to
+ * includable C data that can later be executed.
+ * Note that this is pretty much a hack until someone writes a proper
+ * Actionscript compiler for Swfdec.
+ * Also note that the creation of the include-scripts should probably not be
+ * autorun, as we don't want to depend on external bugs, only on internal ones.
+ */
+static gboolean
+write_data (guint8 *data, gsize len)
+{
+ gsize i;
+
+ for (i = 0; i < len; i++) {
+ switch (i % 16) {
+ case 0:
+ if (i == 0)
+ g_print (" 0x%02X", data[i]);
+ else
+ g_print (",\n 0x%02X", data[i]);
+ break;
+ case 4:
+ case 8:
+ case 12:
+ g_print (", 0x%02X", data[i]);
+ break;
+ default:
+ g_print (", 0x%02X", data[i]);
+ break;
+ }
+ }
+ g_print ("\n");
+ return TRUE;
+}
+
+static char *
+get_name (const char *filename)
+{
+ char *end;
+
+ end = strrchr (filename, '/');
+ if (end)
+ filename = end + 1;
+ end = strchr (filename, '.');
+ if (end)
+ return g_strndup (filename, end - filename);
+ else
+ return g_strdup (filename);
+}
+
+int
+main (int argc, char **argv)
+{
+ SWFAction action;
+ char *contents;
+ GError *error = NULL;
+ guint i;
+ gsize len;
+ byte *data;
+
+ if (argc < 2) {
+ g_print ("usage: %s FILE ...\n\n", argv[0]);
+ return 1;
+ }
+
+ Ming_init ();
+ Ming_setSWFCompression (-1);
+
+ g_print ("/* This file is autogenerated, do not edit! */\n\n");
+ for (i = 1; i < argc; i++) {
+ if (!g_file_get_contents (argv[1], &contents, NULL, &error)) {
+ g_printerr ("%s\n", error->message);
+ g_error_free (error);
+ error = NULL;
+ return 1;
+ }
+ action = newSWFAction (contents);
+ data = SWFAction_getByteCode (action, &len);
+ contents = get_name (argv[i]);
+ g_print ("/* compiled from %s */\n", argv[i]);
+ g_print ("static const unsigned char %s[] = {\n", contents);
+ g_free (contents);
+ write_data (data, len);
+ g_print ("};\n\n");
+ }
+ return 0;
+}
diff --git a/swfdec/jpeg/.gitignore b/swfdec/jpeg/.gitignore
new file mode 100644
index 0000000..5bb735b
--- /dev/null
+++ b/swfdec/jpeg/.gitignore
@@ -0,0 +1,14 @@
+*~
+CVS
+.cvsignore
+.deps
+.libs
+
+Makefile
+Makefile.in
+*.o
+*.la
+*.lo
+
+jpeg_test
+jpeg_rgb_test
diff --git a/swfdec/jpeg/Makefile.am b/swfdec/jpeg/Makefile.am
new file mode 100644
index 0000000..d6475cc
--- /dev/null
+++ b/swfdec/jpeg/Makefile.am
@@ -0,0 +1,20 @@
+
+
+noinst_LTLIBRARIES = libjpeg.la
+
+libjpeg_la_SOURCES = \
+ jpeg.c \
+ jpeg_bits.c \
+ jpeg_huffman.c \
+ jpeg_rgb_decoder.c \
+ jpeg_tables.c
+
+noinst_HEADERS = \
+ cogcompat.h \
+ jpeg.h \
+ jpeg_bits.h \
+ jpeg_huffman.h \
+ jpeg_rgb_decoder.h
+
+libjpeg_la_CFLAGS = $(GLOBAL_CFLAGS) $(GLIB_CFLAGS) $(LIBOIL_CFLAGS) -I$(srcdir)/..
+
diff --git a/swfdec/jpeg/cogcompat.h b/swfdec/jpeg/cogcompat.h
new file mode 100644
index 0000000..bf2370f
--- /dev/null
+++ b/swfdec/jpeg/cogcompat.h
@@ -0,0 +1,14 @@
+
+#ifndef _COG_COMPAT_H_
+#define _COG_COMPAT_H_
+
+#include <swfdec_debug.h>
+
+#define COG_LOG(...) SWFDEC_LOG(__VA_ARGS__)
+#define COG_DEBUG(...) SWFDEC_DEBUG(__VA_ARGS__)
+#define COG_INFO(...) SWFDEC_INFO(__VA_ARGS__)
+#define COG_WARNING(...) SWFDEC_WARNING(__VA_ARGS__)
+#define COG_ERROR(...) SWFDEC_ERROR(__VA_ARGS__)
+
+#endif
+
diff --git a/swfdec/jpeg/jpeg.c b/swfdec/jpeg/jpeg.c
new file mode 100644
index 0000000..52143dc
--- /dev/null
+++ b/swfdec/jpeg/jpeg.c
@@ -0,0 +1,1126 @@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <liboil/liboil.h>
+#include <liboil/liboil-stdint.h>
+#include <cogcompat.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "jpeg.h"
+
+
+extern uint8_t jpeg_standard_tables[];
+extern int jpeg_standard_tables_size;
+
+void jpeg_decoder_define_huffman_tables (JpegDecoder * dec);
+void jpeg_decoder_define_arithmetic_conditioning (JpegDecoder *dec);
+void jpeg_decoder_define_quantization_tables (JpegDecoder *dec);
+void jpeg_decoder_define_restart_interval (JpegDecoder *dec);
+void jpeg_decoder_start_of_frame (JpegDecoder * dec, int marker);
+void jpeg_decoder_start_of_scan (JpegDecoder * dec);
+
+
+/* misc helper function declarations */
+
+static void jpeg_load_standard_huffman_tables (JpegDecoder * dec);
+
+static void jpeg_decoder_verify_header (JpegDecoder *dec);
+static void jpeg_decoder_init_decoder (JpegDecoder *dec);
+
+
+void
+jpeg_decoder_error(JpegDecoder *dec, const char *fmt, ...)
+{
+ va_list varargs;
+
+ if (dec->error) return;
+
+ va_start (varargs, fmt);
+#ifdef HAVE_VASPRINTF
+ vasprintf(&dec->error_message, fmt, varargs);
+#else
+ dec->error_message = malloc(250);
+ vsnprintf(dec->error_message, 250 - 1, fmt, varargs);
+ dec->error_message[250 - 1] = 0;
+#endif
+ va_end (varargs);
+
+ dec->error = TRUE;
+}
+
+#define jpeg_decoder_error(dec, ...) { \
+ COG_ERROR("decoder error: "__VA_ARGS__); \
+ jpeg_decoder_error (dec, __VA_ARGS__); \
+}
+
+static void
+jpeg_decoder_verify_header (JpegDecoder *dec)
+{
+ int max_quant_table = 0;
+ int i;
+
+ if (dec->sof_type != JPEG_MARKER_SOF_0) {
+ COG_ERROR("only handle baseline DCT");
+ dec->error = TRUE;
+ }
+
+ if (dec->width < 1) {
+ COG_ERROR("height can't be 0");
+ dec->error = TRUE;
+ }
+
+ switch (dec->sof_type) {
+ case JPEG_MARKER_SOF_0:
+ /* baseline DCT */
+ max_quant_table = 3;
+ if (dec->depth != 8) {
+ COG_ERROR("depth must be 8 (%d)", dec->depth);
+ dec->error = TRUE;
+ }
+ break;
+ case JPEG_MARKER_SOF_1:
+ /* extended DCT */
+ max_quant_table = 3;
+ if (dec->depth != 8 && dec->depth != 12) {
+ COG_ERROR("depth must be 8 or 12 (%d)", dec->depth);
+ dec->error = TRUE;
+ }
+ break;
+ case JPEG_MARKER_SOF_2:
+ /* progressive DCT */
+ max_quant_table = 3;
+ if (dec->depth != 8 && dec->depth != 12) {
+ COG_ERROR("depth must be 8 or 12 (%d)", dec->depth);
+ dec->error = TRUE;
+ }
+ break;
+ case JPEG_MARKER_SOF_3:
+ /* lossless DCT */
+ max_quant_table = 0;
+ if (dec->depth < 2 || dec->depth > 16) {
+ COG_ERROR("depth must be between 2 and 16 (%d)", dec->depth);
+ dec->error = TRUE;
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (dec->n_components < 0 || dec->n_components > 255) {
+ COG_ERROR("n_components must be in the range 0-255 (%d)",
+ dec->n_components);
+ dec->error = TRUE;
+ }
+ if (dec->sof_type == JPEG_MARKER_SOF_2 && dec->n_components > 4) {
+ COG_ERROR("n_components must be <= 4 for progressive DCT (%d)",
+ dec->n_components);
+ dec->error = TRUE;
+ }
+
+ for (i = 0; i < dec->n_components; i++) {
+ if (dec->components[i].id < 0 || dec->components[i].id > 255) {
+ COG_ERROR("component ID out of range");
+ dec->error = TRUE;
+ break;
+ }
+ if (dec->components[i].h_sample < 1 || dec->components[i].h_sample > 4 ||
+ dec->components[i].v_sample < 1 || dec->components[i].v_sample > 4) {
+ COG_ERROR("sample factor(s) for component %d out of range %d %d",
+ i, dec->components[i].h_sample, dec->components[i].v_sample);
+ dec->error = TRUE;
+ break;
+ }
+ if (dec->components[i].quant_table < 0 ||
+ dec->components[i].quant_table > max_quant_table) {
+ COG_ERROR("quant table for component %d out of range (%d)",
+ i, dec->components[i].quant_table);
+ dec->error = TRUE;
+ break;
+ }
+ }
+}
+
+static void
+jpeg_decoder_init_decoder (JpegDecoder *dec)
+{
+ int max_h_sample = 0;
+ int max_v_sample = 0;
+ int i;
+
+ /* decoder limitations */
+ if (dec->n_components != 3) {
+ jpeg_decoder_error(dec, "wrong number of components %d", dec->n_components);
+ return;
+ }
+ if (dec->sof_type != JPEG_MARKER_SOF_0) {
+ jpeg_decoder_error(dec, "only handle baseline DCT");
+ return;
+ }
+
+
+
+
+ for (i=0; i < dec->n_components; i++) {
+ max_h_sample = MAX (max_h_sample, dec->components[i].h_sample);
+ max_v_sample = MAX (max_v_sample, dec->components[i].v_sample);
+ }
+
+ dec->width_blocks =
+ (dec->width + 8 * max_h_sample - 1) / (8 * max_h_sample);
+ dec->height_blocks =
+ (dec->height + 8 * max_v_sample - 1) / (8 * max_v_sample);
+ for (i = 0; i < dec->n_components; i++) {
+ int rowstride;
+ int image_size;
+
+ dec->components[i].h_subsample = max_h_sample /
+ dec->components[i].h_sample;
+ dec->components[i].v_subsample = max_v_sample /
+ dec->components[i].v_sample;
+
+ rowstride = dec->width_blocks * 8 * max_h_sample /
+ dec->components[i].h_subsample;
+ image_size = rowstride *
+ (dec->height_blocks * 8 * max_v_sample /
+ dec->components[i].v_subsample);
+ dec->components[i].rowstride = rowstride;
+ dec->components[i].image = malloc (image_size);
+ }
+}
+
+#if 0
+static char *
+sprintbits (char *str, unsigned int bits, int n)
+{
+ int i;
+ int bit = 1 << (n - 1);
+
+ for (i = 0; i < n; i++) {
+ str[i] = (bits & bit) ? '1' : '0';
+ bit >>= 1;
+ }
+ str[i] = 0;
+
+ return str;
+}
+
+static void
+generate_code_table (int *huffsize)
+{
+ int code;
+ int i;
+ int j;
+ int k;
+ char str[33];
+
+ //int l;
+
+ code = 0;
+ k = 0;
+ for (i = 0; i < 16; i++) {
+ for (j = 0; j < huffsize[i]; j++) {
+ COG_DEBUG ("huffcode[%d] = %s", k,
+ sprintbits (str, code >> (15 - i), i + 1));
+ code++;
+ k++;
+ }
+ code <<= 1;
+ }
+
+}
+#endif
+
+static int
+huffman_table_init_jpeg (JpegDecoder *decoder, HuffmanTable *table, JpegBits * bits)
+{
+ int n_symbols;
+ int huffsize[16];
+ int i, j, k;
+ unsigned int symbol;
+ int n = 0;
+
+ huffman_table_init (table);
+
+ /* huffsize[i] is the number of symbols that have length
+ * (i+1) bits. Maximum bit length is 16 bits, so there are
+ * 16 entries. */
+ n_symbols = 0;
+ for (i = 0; i < 16; i++) {
+ huffsize[i] = jpeg_bits_get_u8 (bits);
+ n++;
+ n_symbols += huffsize[i];
+ }
+
+ /* Build up the symbol table. The first symbol is all 0's, with
+ * the number of bits determined by the first non-zero entry in
+ * huffsize[]. Subsequent symbols with the same bit length are
+ * incremented by 1. Increasing the bit length shifts the
+ * symbol 1 bit to the left. */
+ symbol = 0;
+ k = 0;
+ for (i = 0; i < 16; i++) {
+ for (j = 0; j < huffsize[i]; j++) {
+ huffman_table_add (table, symbol, i + 1, jpeg_bits_get_u8 (bits));
+ n++;
+ symbol++;
+ k++;
+ }
+ /* This checks that our symbol is actually less than the
+ * number of bits we think it is. This is only triggered
+ * for bad huffsize[] arrays. */
+ if (symbol >= (1U << (i + 1))) {
+ jpeg_decoder_error (decoder, "bad huffsize[] array");
+ return -1;
+ }
+
+ symbol <<= 1;
+ }
+
+ huffman_table_dump (table);
+
+ return n;
+}
+
+static int
+jpeg_decoder_find_component_by_id (JpegDecoder * dec, int id)
+{
+ int i;
+
+ for (i = 0; i < dec->n_components; i++) {
+ if (dec->components[i].id == id)
+ return i;
+ }
+ COG_DEBUG ("undefined component id %d", id);
+ return 0;
+}
+
+int
+jpeg_decoder_application0 (JpegDecoder * dec, JpegBits * bits)
+{
+ int length;
+
+ COG_DEBUG ("app0");
+
+ length = get_be_u16 (bits);
+ COG_DEBUG ("length=%d", length);
+
+ if (memcmp (bits->ptr, "JFIF", 4) == 0 && bits->ptr[4] == 0) {
+ int version;
+ int units;
+ int x_density;
+ int y_density;
+ int x_thumbnail;
+ int y_thumbnail;
+
+ COG_DEBUG ("JFIF");
+ bits->ptr += 5;
+
+ version = get_be_u16 (bits);
+ units = get_u8 (bits);
+ x_density = get_be_u16 (bits);
+ y_density = get_be_u16 (bits);
+ x_thumbnail = get_u8 (bits);
+ y_thumbnail = get_u8 (bits);
+
+ COG_DEBUG ("version = %04x", version);
+ COG_DEBUG ("units = %d", units);
+ COG_DEBUG ("x_density = %d", x_density);
+ COG_DEBUG ("y_density = %d", y_density);
+ COG_DEBUG ("x_thumbnail = %d", x_thumbnail);
+ COG_DEBUG ("y_thumbnail = %d", y_thumbnail);
+
+ }
+
+ if (memcmp (bits->ptr, "JFXX", 4) == 0 && bits->ptr[4] == 0) {
+ COG_DEBUG ("JFIF extension (not handled)");
+ bits->ptr += length - 2;
+ }
+
+ return length;
+}
+
+int
+jpeg_decoder_application_misc (JpegDecoder * dec, JpegBits * bits)
+{
+ int length;
+
+ COG_DEBUG ("appX");
+
+ length = get_be_u16 (bits);
+ COG_DEBUG ("length=%d", length);
+
+ COG_DEBUG ("JPEG application tag X ignored");
+ //dumpbits (bits);
+
+ bits->ptr += length - 2;
+
+ return length;
+}
+
+int
+jpeg_decoder_comment (JpegDecoder * dec, JpegBits * bits)
+{
+ int length;
+
+ COG_DEBUG ("comment");
+
+ length = get_be_u16 (bits);
+ COG_DEBUG ("length=%d", length);
+
+ //dumpbits (bits);
+
+ bits->ptr += length - 2;
+
+ return length;
+}
+
+int
+jpeg_decoder_restart_interval (JpegDecoder * dec, JpegBits * bits)
+{
+ int length;
+
+ COG_DEBUG ("comment");
+
+ length = get_be_u16 (bits);
+ COG_DEBUG ("length=%d", length);
+
+ dec->restart_interval = get_be_u16 (bits);
+ COG_DEBUG ("restart_interval=%d", dec->restart_interval);
+
+ return length;
+}
+
+int
+jpeg_decoder_restart (JpegDecoder * dec, JpegBits * bits)
+{
+ COG_DEBUG ("restart");
+
+ return 0;
+}
+
+void
+jpeg_decoder_decode_entropy_segment (JpegDecoder * dec)
+{
+ JpegBits * bits = &dec->bits;
+ JpegBits b2, *bits2 = &b2;
+ short block[64];
+ short block2[64];
+ unsigned char *newptr;
+ int len;
+ int maxlen;
+ int j;
+ int i;
+ int go;
+ int x, y;
+ int n;
+ int ret;
+
+ len = 0;
+ maxlen = jpeg_bits_available (bits) - 1;
+ j = 0;
+ while (len < maxlen) {
+ if (bits->ptr[len] == 0xff && bits->ptr[len + 1] != 0x00) {
+ break;
+ }
+ len++;
+ }
+ COG_DEBUG ("entropy length = %d", len);
+
+ /* we allocate extra space, since the getbits() code can
+ * potentially read past the end of the buffer */
+ newptr = malloc (len + 2);
+ for (i = 0; i < len; i++) {
+ newptr[j] = bits->ptr[i];
+ j++;
+ if (bits->ptr[i] == 0xff)
+ i++;
+ }
+ bits->ptr += len;
+
+ bits2->ptr = newptr;
+ bits2->idx = 0;
+ bits2->end = newptr + j;
+ newptr[j] = 0;
+ newptr[j + 1] = 0;
+
+ dec->dc[0] = dec->dc[1] = dec->dc[2] = dec->dc[3] = 128 * 8;
+ go = 1;
+ x = dec->x;
+ y = dec->y;
+ n = dec->restart_interval;
+ if (n == 0) n = (1<<26); /* max number of blocks */
+ while (go && n-- > 0) {
+ for (i = 0; i < dec->scan_list_length; i++) {
+ int dc_table_index;
+ int ac_table_index;
+ int quant_index;
+ unsigned char *ptr;
+ int component_index;
+
+ COG_DEBUG ("%d,%d: component=%d dc_table=%d ac_table=%d",
+ x, y,
+ dec->scan_list[i].component_index,
+ dec->scan_list[i].dc_table, dec->scan_list[i].ac_table);
+
+ component_index = dec->scan_list[i].component_index;
+ dc_table_index = dec->scan_list[i].dc_table;
+ ac_table_index = dec->scan_list[i].ac_table;
+ quant_index = dec->scan_list[i].quant_table;
+
+ ret = huffman_table_decode_macroblock (dec, block,
+ &dec->dc_huff_table[dc_table_index],
+ &dec->ac_huff_table[ac_table_index], bits2);
+ if (ret < 0) {
+ COG_DEBUG ("%d,%d: component=%d dc_table=%d ac_table=%d",
+ x, y,
+ dec->scan_list[i].component_index,
+ dec->scan_list[i].dc_table, dec->scan_list[i].ac_table);
+ n = 0;
+ break;
+ }
+
+ COG_DEBUG ("using quant table %d", quant_index);
+ oil_mult8x8_s16 (block2, block, dec->quant_tables[quant_index].quantizer,
+ sizeof (short) * 8, sizeof(short) * 8, sizeof (short) * 8);
+ dec->dc[component_index] += block2[0];
+ block2[0] = dec->dc[component_index];
+ oil_unzigzag8x8_s16 (block, sizeof (short) * 8, block2,
+ sizeof (short) * 8);
+ oil_idct8x8_s16 (block2, sizeof (short) * 8, block, sizeof (short) * 8);
+ oil_trans8x8_s16 (block, sizeof (short) * 8, block2, sizeof (short) * 8);
+
+ ptr = dec->components[component_index].image +
+ x * dec->components[component_index].h_sample +
+ dec->scan_list[i].offset +
+ dec->components[component_index].rowstride * y *
+ dec->components[component_index].v_sample;
+
+ oil_clipconv8x8_u8_s16 (ptr,
+ dec->components[component_index].rowstride,
+ block, sizeof (short) * 8);
+ }
+ x += 8;
+ if (x * dec->scan_h_subsample >= dec->width) {
+ x = 0;
+ y += 8;
+ }
+ if (y * dec->scan_v_subsample >= dec->height) {
+ go = 0;
+ }
+ }
+ dec->x = x;
+ dec->y = y;
+ free (newptr);
+}
+
+
+
+JpegDecoder *
+jpeg_decoder_new (void)
+{
+ JpegDecoder *dec;
+
+ oil_init ();
+
+ dec = malloc (sizeof(JpegDecoder));
+ memset (dec, 0, sizeof(JpegDecoder));
+
+ jpeg_load_standard_huffman_tables (dec);
+
+ return dec;
+}
+
+void
+jpeg_decoder_free (JpegDecoder * dec)
+{
+ int i;
+
+ for (i = 0; i < JPEG_LIMIT_COMPONENTS; i++) {
+ if (dec->components[i].image)
+ free (dec->components[i].image);
+ }
+
+ if (dec->data)
+ free (dec->data);
+
+ free (dec);
+}
+
+static int
+jpeg_decoder_get_marker (JpegDecoder *dec, int *marker)
+{
+ int a,b;
+ JpegBits *bits = &dec->bits;
+
+ if (jpeg_bits_available(bits) < 2) {
+ return FALSE;
+ }
+
+ a = jpeg_bits_get_u8(bits);
+ if (a != 0xff) {
+ jpeg_decoder_error(dec, "expected marker, not 0x%02x", a);
+ return FALSE;
+ }
+
+ do {
+ b = jpeg_bits_get_u8 (bits);
+ } while (b == 0xff && jpeg_bits_error(bits));
+
+ *marker = b;
+ return TRUE;
+}
+
+static void
+jpeg_decoder_skip (JpegDecoder *dec)
+{
+ int length;
+
+ length = jpeg_bits_get_u16_be (&dec->bits);
+ jpeg_bits_skip (&dec->bits, length - 2);
+}
+
+int
+jpeg_decoder_decode (JpegDecoder *dec)
+{
+ JpegBits *bits;
+ int marker;
+
+ dec->error = FALSE;
+
+ bits = &dec->bits;
+
+ /* Note: The spec is ambiguous as to whether fill bytes can come
+ * before the first marker. We'll assume yes. */
+ if (!jpeg_decoder_get_marker (dec, &marker)) {
+ return FALSE;
+ }
+ if (dec->strict && marker != JPEG_MARKER_SOI) {
+ jpeg_decoder_error(dec, "not a JPEG image");
+ return FALSE;
+ }
+
+ /* Interpret markers up to the start of frame */
+ while (!dec->error) {
+ if (!jpeg_decoder_get_marker (dec, &marker)) {
+ return FALSE;
+ }
+
+ if (marker == JPEG_MARKER_DEFINE_HUFFMAN_TABLES) {
+ jpeg_decoder_define_huffman_tables (dec);
+ } else if (marker == JPEG_MARKER_DEFINE_ARITHMETIC_CONDITIONING) {
+ jpeg_decoder_define_arithmetic_conditioning (dec);
+ } else if (marker == JPEG_MARKER_DEFINE_QUANTIZATION_TABLES) {
+ jpeg_decoder_define_quantization_tables (dec);
+ } else if (marker == JPEG_MARKER_DEFINE_RESTART_INTERVAL) {
+ jpeg_decoder_define_restart_interval (dec);
+ } else if (JPEG_MARKER_IS_APP(marker)) {
+ /* FIXME decode app segment */
+ jpeg_decoder_skip (dec);
+ } else if (marker == JPEG_MARKER_COMMENT) {
+ jpeg_decoder_skip (dec);
+ } else if (JPEG_MARKER_IS_START_OF_FRAME(marker)) {
+ break;
+ } else if (marker == JPEG_MARKER_SOI) {
+ if (dec->strict) {
+ jpeg_decoder_error (dec, "unexpected SOI");
+ return FALSE;
+ }
+ } else if (marker == JPEG_MARKER_EOI) {
+ if (dec->strict) {
+ jpeg_decoder_error (dec, "unexpected EOI");
+ return FALSE;
+ }
+ } else {
+ jpeg_decoder_error(dec, "unexpected marker 0x%02x", marker);
+ return FALSE;
+ }
+ }
+ if (dec->error) {
+ return FALSE;
+ }
+
+ jpeg_decoder_start_of_frame(dec, marker);
+
+ jpeg_decoder_verify_header (dec);
+ if (dec->error) {
+ return FALSE;
+ }
+
+ jpeg_decoder_init_decoder (dec);
+ if (dec->error) {
+ return FALSE;
+ }
+
+ /* In this section, we loop over parse units until we reach the end
+ * of the image. */
+ while (!dec->error) {
+ if (!jpeg_decoder_get_marker (dec, &marker)) {
+ return FALSE;
+ }
+
+ if (marker == JPEG_MARKER_DEFINE_HUFFMAN_TABLES) {
+ jpeg_decoder_define_huffman_tables (dec);
+ } else if (marker == JPEG_MARKER_DEFINE_ARITHMETIC_CONDITIONING) {
+ jpeg_decoder_define_arithmetic_conditioning (dec);
+ } else if (marker == JPEG_MARKER_DEFINE_QUANTIZATION_TABLES) {
+ jpeg_decoder_define_quantization_tables (dec);
+ } else if (marker == JPEG_MARKER_DEFINE_RESTART_INTERVAL) {
+ jpeg_decoder_define_restart_interval (dec);
+ } else if (JPEG_MARKER_IS_APP(marker)) {
+ jpeg_decoder_skip (dec);
+ } else if (marker == JPEG_MARKER_COMMENT) {
+ jpeg_decoder_skip (dec);
+ } else if (marker == JPEG_MARKER_SOS) {
+ jpeg_decoder_start_of_scan (dec);
+ if (dec->error) {
+ return FALSE;
+ }
+ jpeg_decoder_decode_entropy_segment (dec);
+ } else if (JPEG_MARKER_IS_RESET(marker)) {
+ jpeg_decoder_decode_entropy_segment (dec);
+ } else if (marker == JPEG_MARKER_SOI) {
+ if (dec->strict) {
+ jpeg_decoder_error (dec, "unexpected SOI");
+ return FALSE;
+ }
+ } else if (marker == JPEG_MARKER_EOI) {
+ if (dec->strict) {
+ jpeg_decoder_error (dec, "unexpected EOI");
+ return FALSE;
+ } else {
+ break;
+ }
+ } else {
+ jpeg_decoder_error(dec, "unexpected marker 0x%02x", marker);
+ return FALSE;
+ }
+ }
+ if (dec->error) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* handle markers */
+
+void
+jpeg_decoder_define_huffman_tables (JpegDecoder * dec)
+{
+ JpegBits *bits = &dec->bits;
+ int length;
+ int tc;
+ int th;
+ int x;
+ HuffmanTable *hufftab;
+
+ COG_DEBUG ("define huffman tables");
+
+ length = jpeg_bits_get_u16_be (bits);
+ if (length < 2) {
+ jpeg_decoder_error(dec, "length too short");
+ return;
+ }
+ length -= 2;
+
+ while (length > 0) {
+ x = jpeg_bits_get_u8 (bits);
+ length--;
+
+ tc = x >> 4;
+ th = x & 0xf;
+
+ COG_DEBUG ("huff table type %d (%s) idx %d", tc, tc ? "ac" : "dc", th);
+ if (tc > 1 || th > 3) {
+ jpeg_decoder_error(dec, "huffman table type or idx out of range");
+ return;
+ }
+
+ if (tc) {
+ hufftab = &dec->ac_huff_table[th];
+ length -= huffman_table_init_jpeg (dec, hufftab, bits);
+ } else {
+ hufftab = &dec->dc_huff_table[th];
+ length -= huffman_table_init_jpeg (dec, hufftab, bits);
+ }
+ if (dec->error) {
+ return;
+ }
+ }
+ if (length < 0) {
+ jpeg_decoder_error(dec, "huffman table overran available bytes");
+ return;
+ }
+}
+
+void
+jpeg_decoder_define_quantization_tables (JpegDecoder *dec)
+{
+ JpegBits *bits = &dec->bits;
+ JpegQuantTable *table;
+ int length;
+ int pq;
+ int tq;
+ int i;
+
+ COG_INFO ("define quantization table");
+
+ length = jpeg_bits_get_u16_be (bits);
+ if (length < 2) {
+ jpeg_decoder_error(dec, "length too short");
+ return;
+ }
+ length -= 2;
+
+ while (length > 0) {
+ int x;
+
+ x = jpeg_bits_get_u8 (bits);
+ length--;
+ pq = x >> 4;
+ tq = x & 0xf;
+
+ if (pq > 1) {
+ jpeg_decoder_error (dec, "bad pq value");
+ return;
+ }
+ if (tq > 3) {
+ jpeg_decoder_error (dec, "bad tq value");
+ return;
+ }
+
+ table = &dec->quant_tables[tq];
+ if (pq) {
+ for (i = 0; i < 64; i++) {
+ table->quantizer[i] = jpeg_bits_get_u16_be (bits);
+ length -= 2;
+ }
+ } else {
+ for (i = 0; i < 64; i++) {
+ table->quantizer[i] = jpeg_bits_get_u8 (bits);
+ length -= 1;
+ }
+ }
+ }
+ if (length < 0) {
+ jpeg_decoder_error(dec, "quantization table overran available bytes");
+ return;
+ }
+}
+
+void
+jpeg_decoder_define_restart_interval (JpegDecoder *dec)
+{
+ JpegBits *bits = &dec->bits;
+ int length;
+
+ length = jpeg_bits_get_u16_be (bits);
+ if (length != 4) {
+ jpeg_decoder_error(dec, "length supposed to be 4 (%d)", length);
+ return;
+ }
+
+ /* FIXME this needs to be checked somewhere */
+ dec->restart_interval = jpeg_bits_get_u16_be (bits);
+}
+
+void
+jpeg_decoder_define_arithmetic_conditioning (JpegDecoder *dec)
+{
+ /* we don't handle arithmetic coding, so skip it */
+ jpeg_decoder_skip (dec);
+}
+
+void
+jpeg_decoder_start_of_frame (JpegDecoder * dec, int marker)
+{
+ JpegBits *bits = &dec->bits;
+ int i;
+ int length;
+
+ COG_INFO ("start of frame");
+
+ dec->sof_type = marker;
+
+ length = jpeg_bits_get_u16_be (bits);
+
+ if (jpeg_bits_available(bits) < length) {
+ jpeg_decoder_error(dec, "not enough data for start_of_frame (%d < %d)",
+ length, jpeg_bits_available(bits));
+ return;
+ }
+
+ dec->depth = jpeg_bits_get_u8 (bits);
+ dec->height = jpeg_bits_get_u16_be (bits);
+ dec->width = jpeg_bits_get_u16_be (bits);
+ dec->n_components = jpeg_bits_get_u8 (bits);
+
+ COG_DEBUG (
+ "frame_length=%d depth=%d height=%d width=%d n_components=%d", length,
+ dec->depth, dec->height, dec->width, dec->n_components);
+
+ if (dec->n_components * 3 + 8 != length) {
+ jpeg_decoder_error(dec, "inconsistent header");
+ return;
+ }
+
+ for (i = 0; i < dec->n_components; i++) {
+ dec->components[i].id = get_u8 (bits);
+ dec->components[i].h_sample = getbits (bits, 4);
+ dec->components[i].v_sample = getbits (bits, 4);
+ dec->components[i].quant_table = get_u8 (bits);
+
+ COG_DEBUG (
+ "[%d] id=%d h_sample=%d v_sample=%d quant_table=%d", i,
+ dec->components[i].id, dec->components[i].h_sample,
+ dec->components[i].v_sample, dec->components[i].quant_table);
+ }
+}
+
+void
+jpeg_decoder_start_of_scan (JpegDecoder * dec)
+{
+ JpegBits *bits = &dec->bits;
+ int length;
+ int i;
+ int spectral_start;
+ int spectral_end;
+ int approx_high;
+ int approx_low;
+ int n;
+ int tmp;
+ int n_components;
+
+ COG_DEBUG ("start of scan");
+
+ length = jpeg_bits_get_u16_be (bits);
+ COG_DEBUG ("length=%d", length);
+
+ n_components = jpeg_bits_get_u8 (bits);
+ n = 0;
+ dec->scan_h_subsample = 0;
+ dec->scan_v_subsample = 0;
+ for (i = 0; i < n_components; i++) {
+ int component_id;
+ int dc_table;
+ int ac_table;
+ int x;
+ int y;
+ int idx;
+ int h_subsample;
+ int v_subsample;
+ int quant_index;
+
+ component_id = jpeg_bits_get_u8 (bits);
+ tmp = jpeg_bits_get_u8 (bits);
+ dc_table = tmp >> 4;
+ ac_table = tmp & 0xf;
+ idx = jpeg_decoder_find_component_by_id (dec, component_id);
+
+ h_subsample = dec->components[idx].h_sample;
+ v_subsample = dec->components[idx].v_sample;
+ quant_index = dec->components[idx].quant_table;
+
+ for (y = 0; y < v_subsample; y++) {
+ for (x = 0; x < h_subsample; x++) {
+ dec->scan_list[n].component_index = idx;
+ dec->scan_list[n].dc_table = dc_table;
+ dec->scan_list[n].ac_table = ac_table;
+ dec->scan_list[n].quant_table = quant_index;
+ dec->scan_list[n].x = x;
+ dec->scan_list[n].y = y;
+ dec->scan_list[n].offset =
+ y * 8 * dec->components[idx].rowstride + x * 8;
+ n++;
+ if (n > JPEG_LIMIT_SCAN_LIST_LENGTH) {
+ jpeg_decoder_error(dec, "scan list too long");
+ return;
+ }
+ }
+ }
+
+ dec->scan_h_subsample = MAX (dec->scan_h_subsample, h_subsample);
+ dec->scan_v_subsample = MAX (dec->scan_v_subsample, v_subsample);
+
+ COG_DEBUG ("component %d: idx=%d dc_table=%d ac_table=%d n=%d",
+ component_id, idx, dc_table, ac_table, n);
+ }
+ dec->scan_list_length = n;
+
+
+ spectral_start = jpeg_bits_get_u8 (bits);
+ spectral_end = jpeg_bits_get_u8 (bits);
+ COG_DEBUG ("spectral range [%d,%d]", spectral_start, spectral_end);
+ tmp = jpeg_bits_get_u8 (bits);
+ approx_high = tmp >> 4;
+ approx_low = tmp & 0xf;
+ COG_DEBUG ("approx range [%d,%d]", approx_low, approx_high);
+
+ dec->x = 0;
+ dec->y = 0;
+ dec->dc[0] = dec->dc[1] = dec->dc[2] = dec->dc[3] = 128 * 8;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+int
+jpeg_decoder_addbits (JpegDecoder * dec, unsigned char *data, unsigned int len)
+{
+ unsigned int offset;
+
+ offset = dec->bits.ptr - dec->data;
+
+ dec->data = realloc (dec->data, dec->data_len + len);
+ memcpy (dec->data + dec->data_len, data, len);
+ dec->data_len += len;
+
+ dec->bits.ptr = dec->data + offset;
+ dec->bits.end = dec->data + dec->data_len;
+
+ return 0;
+}
+
+int
+jpeg_decoder_get_image_size (JpegDecoder * dec, int *width, int *height)
+{
+ if (width)
+ *width = dec->width;
+ if (height)
+ *height = dec->height;
+
+ return 0;
+}
+
+int
+jpeg_decoder_get_component_ptr (JpegDecoder * dec, int id,
+ unsigned char **image, int *rowstride)
+{
+ int i;
+
+ i = jpeg_decoder_find_component_by_id (dec, id);
+ if (image)
+ *image = dec->components[i].image;
+ if (rowstride)
+ *rowstride = dec->components[i].rowstride;
+
+ return 0;
+}
+
+int
+jpeg_decoder_get_component_size (JpegDecoder * dec, int id,
+ int *width, int *height)
+{
+ int i;
+
+ /* subsampling sizes are rounded up */
+
+ i = jpeg_decoder_find_component_by_id (dec, id);
+ if (width)
+ *width = (dec->width - 1) / dec->components[i].h_subsample + 1;
+ if (height)
+ *height = (dec->height - 1) / dec->components[i].v_subsample + 1;
+
+ return 0;
+}
+
+int
+jpeg_decoder_get_component_subsampling (JpegDecoder * dec, int id,
+ int *h_subsample, int *v_subsample)
+{
+ int i;
+
+ i = jpeg_decoder_find_component_by_id (dec, id);
+ if (h_subsample)
+ *h_subsample = dec->components[i].h_subsample;
+ if (v_subsample)
+ *v_subsample = dec->components[i].v_subsample;
+
+ return 0;
+}
+
+#if 0
+int
+jpeg_decoder_parse (JpegDecoder * dec)
+{
+ JpegBits *bits = &dec->bits;
+ JpegBits b2;
+ unsigned int x;
+ unsigned int tag;
+ int i;
+
+ while (bits->ptr < bits->end) {
+ x = get_u8 (bits);
+ if (x != 0xff) {
+ int n = 0;
+
+ while (x != 0xff) {
+ x = get_u8 (bits);
+ n++;
+ }
+ OIL_DEBUG ("lost sync, skipped %d bytes", n);
+ }
+ while (x == 0xff) {
+ x = get_u8 (bits);
+ }
+ tag = x;
+ OIL_DEBUG ("tag %02x", tag);
+
+ b2 = *bits;
+
+ for (i = 0; i < n_jpeg_markers - 1; i++) {
+ if (tag == jpeg_markers[i].tag) {
+ break;
+ }
+ }
+ OIL_DEBUG ("tag: %s", jpeg_markers[i].name);
+ if (jpeg_markers[i].func) {
+ jpeg_markers[i].func (dec, &b2);
+ } else {
+ OIL_DEBUG ("unhandled or illegal JPEG marker (0x%02x)", tag);
+ dumpbits (&b2);
+ }
+ if (jpeg_markers[i].flags & JPEG_ENTROPY_SEGMENT) {
+ jpeg_decoder_decode_entropy_segment (dec, &b2);
+ }
+ syncbits (&b2);
+ bits->ptr = b2.ptr;
+ }
+
+ return 0;
+}
+#endif
+
+
+/* misc helper functins */
+
+static void
+jpeg_load_standard_huffman_tables (JpegDecoder * dec)
+{
+ JpegBits b, *bits = &b;
+
+ bits->ptr = jpeg_standard_tables;
+ bits->idx = 0;
+ bits->end = jpeg_standard_tables + jpeg_standard_tables_size;
+
+ huffman_table_init_jpeg (dec, &dec->dc_huff_table[0], bits);
+ huffman_table_init_jpeg (dec, &dec->ac_huff_table[0], bits);
+ huffman_table_init_jpeg (dec, &dec->dc_huff_table[1], bits);
+ huffman_table_init_jpeg (dec, &dec->ac_huff_table[1], bits);
+}
+
+
+
diff --git a/swfdec/jpeg/jpeg.h b/swfdec/jpeg/jpeg.h
new file mode 100644
index 0000000..6c0ba41
--- /dev/null
+++ b/swfdec/jpeg/jpeg.h
@@ -0,0 +1,190 @@
+
+#ifndef _JPEG_DECODER_H_
+#define _JPEG_DECODER_H_
+
+#include <jpeg/jpeg_bits.h>
+
+#include <stdint.h>
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#define JPEG_LIMIT_COMPONENTS 256
+#define JPEG_LIMIT_SCAN_LIST_LENGTH 10
+
+
+typedef struct _JpegDecoder JpegDecoder;
+typedef struct _JpegQuantTable JpegQuantTable;
+typedef struct _HuffmanEntry HuffmanEntry;
+typedef struct _HuffmanTable HuffmanTable;
+
+struct _HuffmanEntry {
+ unsigned int symbol;
+ unsigned int mask;
+ int n_bits;
+ unsigned char value;
+};
+
+struct _HuffmanTable {
+ int len;
+ HuffmanEntry entries[256];
+};
+
+struct _JpegQuantTable {
+ int pq;
+ int16_t quantizer[64];
+};
+
+struct _JpegDecoder {
+ int width;
+ int height;
+ int depth;
+ int n_components;
+ JpegBits bits;
+ int error;
+ int strict;
+ char *error_message;
+
+ int sof_type;
+
+ int width_blocks;
+ int height_blocks;
+
+ int restart_interval;
+
+ unsigned char *data;
+ unsigned int data_len;
+
+ struct{
+ int id;
+ int h_sample;
+ int v_sample;
+ int quant_table;
+
+ int h_subsample;
+ int v_subsample;
+ unsigned char *image;
+ int rowstride;
+ } components[JPEG_LIMIT_COMPONENTS];
+
+ JpegQuantTable quant_tables[4];
+ HuffmanTable dc_huff_table[4];
+ HuffmanTable ac_huff_table[4];
+
+ int scan_list_length;
+ struct{
+ int component_index;
+ int dc_table;
+ int ac_table;
+ int quant_table;
+ int x;
+ int y;
+ int offset;
+ }scan_list[JPEG_LIMIT_SCAN_LIST_LENGTH];
+ int scan_h_subsample;
+ int scan_v_subsample;
+
+ /* scan state */
+ int x,y;
+ int dc[4];
+};
+
+#define JPEG_MARKER_STUFFED 0x00
+#define JPEG_MARKER_TEM 0x01
+#define JPEG_MARKER_RES 0x02
+
+#define JPEG_MARKER_SOF_0 0xc0
+#define JPEG_MARKER_SOF_1 0xc1
+#define JPEG_MARKER_SOF_2 0xc2
+#define JPEG_MARKER_SOF_3 0xc3
+#define JPEG_MARKER_DEFINE_HUFFMAN_TABLES 0xc4
+#define JPEG_MARKER_SOF_5 0xc5
+#define JPEG_MARKER_SOF_6 0xc6
+#define JPEG_MARKER_SOF_7 0xc7
+#define JPEG_MARKER_JPG 0xc8
+#define JPEG_MARKER_SOF_9 0xc9
+#define JPEG_MARKER_SOF_10 0xca
+#define JPEG_MARKER_SOF_11 0xcb
+#define JPEG_MARKER_DEFINE_ARITHMETIC_CONDITIONING 0xcc
+#define JPEG_MARKER_SOF_13 0xcd
+#define JPEG_MARKER_SOF_14 0xce
+#define JPEG_MARKER_SOF_15 0xcf
+
+#define JPEG_MARKER_RST_0 0xd0
+#define JPEG_MARKER_RST_1 0xd1
+#define JPEG_MARKER_RST_2 0xd2
+#define JPEG_MARKER_RST_3 0xd3
+#define JPEG_MARKER_RST_4 0xd4
+#define JPEG_MARKER_RST_5 0xd5
+#define JPEG_MARKER_RST_6 0xd6
+#define JPEG_MARKER_RST_7 0xd7
+
+#define JPEG_MARKER_SOI 0xd8
+#define JPEG_MARKER_EOI 0xd9
+#define JPEG_MARKER_SOS 0xda
+#define JPEG_MARKER_DEFINE_QUANTIZATION_TABLES 0xdb
+#define JPEG_MARKER_DNL 0xdc
+#define JPEG_MARKER_DEFINE_RESTART_INTERVAL 0xdd
+#define JPEG_MARKER_DHP 0xde
+#define JPEG_MARKER_EXP 0xdf
+#define JPEG_MARKER_APP(x) (0xe0 + (x))
+#define JPEG_MARKER_JPG_(x) (0xf0 + (x))
+#define JPEG_MARKER_COMMENT 0xfe
+
+#define JPEG_MARKER_JFIF JPEG_MARKER_APP(0)
+
+#define JPEG_MARKER_IS_START_OF_FRAME(x) ((x)>=0xc0 && (x) <= 0xcf && (x)!=0xc4 && (x)!=0xc8 && (x)!=0xcc)
+#define JPEG_MARKER_IS_APP(x) ((x)>=0xe0 && (x) <= 0xef)
+#define JPEG_MARKER_IS_RESET(x) ((x)>=0xd0 && (x)<=0xd7)
+
+
+
+JpegDecoder *jpeg_decoder_new(void);
+void jpeg_decoder_free(JpegDecoder *dec);
+int jpeg_decoder_addbits(JpegDecoder *dec, unsigned char *data, unsigned int len);
+int jpeg_decoder_decode (JpegDecoder *dec);
+int jpeg_decoder_get_image_size(JpegDecoder *dec, int *width, int *height);
+int jpeg_decoder_get_component_size(JpegDecoder *dec, int id,
+ int *width, int *height);
+int jpeg_decoder_get_component_subsampling(JpegDecoder *dec, int id,
+ int *h_subsample, int *v_subsample);
+int jpeg_decoder_get_component_ptr(JpegDecoder *dec, int id,
+ unsigned char **image, int *rowstride);
+
+uint32_t *jpeg_decoder_get_argb_image (JpegDecoder *dec);
+int jpeg_decode_argb (uint8_t *data, int length, uint32_t **image,
+ int *width, int *height);
+
+void jpeg_decoder_error(JpegDecoder *dec, const char *fmt, ...);
+
+int jpeg_decoder_sof_baseline_dct(JpegDecoder *dec, JpegBits *bits);
+int jpeg_decoder_define_quant_table(JpegDecoder *dec, JpegBits *bits);
+int jpeg_decoder_define_huffman_table(JpegDecoder *dec, JpegBits *bits);
+int jpeg_decoder_sos(JpegDecoder *dec, JpegBits *bits);
+int jpeg_decoder_soi(JpegDecoder *dec, JpegBits *bits);
+int jpeg_decoder_eoi(JpegDecoder *dec, JpegBits *bits);
+int jpeg_decoder_application0(JpegDecoder *dec, JpegBits *bits);
+int jpeg_decoder_application_misc(JpegDecoder *dec, JpegBits *bits);
+int jpeg_decoder_comment(JpegDecoder *dec, JpegBits *bits);
+int jpeg_decoder_restart_interval(JpegDecoder *dec, JpegBits *bits);
+int jpeg_decoder_restart(JpegDecoder *dec, JpegBits *bits);
+void jpeg_decoder_decode_entropy_segment(JpegDecoder *dec);
+
+
+void huffman_table_init(HuffmanTable *table);
+
+void huffman_table_dump(HuffmanTable *table);
+void huffman_table_add(HuffmanTable *table, uint32_t code, int n_bits,
+ int value);
+unsigned int huffman_table_decode_jpeg(JpegDecoder *dec, HuffmanTable *tab, JpegBits *bits);
+int huffman_table_decode_macroblock(JpegDecoder *dec, short *block, HuffmanTable *dc_tab,
+ HuffmanTable *ac_tab, JpegBits *bits);
+int huffman_table_decode(JpegDecoder *dec, HuffmanTable *dc_tab, HuffmanTable *ac_tab, JpegBits *bits);
+
+
+#endif
+
diff --git a/swfdec/jpeg/jpeg_bits.c b/swfdec/jpeg/jpeg_bits.c
new file mode 100644
index 0000000..87700e9
--- /dev/null
+++ b/swfdec/jpeg/jpeg_bits.c
@@ -0,0 +1,154 @@
+
+#include <stdio.h>
+
+#include "jpeg_bits.h"
+
+/* FIXME */
+#define TRUE 1
+#define FALSE 0
+
+int jpeg_bits_error (JpegBits *bits)
+{
+ return bits->error;
+}
+
+int jpeg_bits_get_u8 (JpegBits *bits)
+{
+ if (bits->ptr < bits->end) {
+ return *bits->ptr++;
+ }
+ bits->error = TRUE;
+ return 0;
+}
+
+void jpeg_bits_skip (JpegBits *bits, int n)
+{
+ bits->ptr += n;
+ if (bits->ptr > bits->end) {
+ bits->error = TRUE;
+ bits->ptr = bits->end;
+ }
+}
+
+int jpeg_bits_get_u16_be (JpegBits *bits)
+{
+ int x;
+
+ x = jpeg_bits_get_u8 (bits) << 8;
+ x |= jpeg_bits_get_u8 (bits);
+
+ return x;
+}
+
+int jpeg_bits_available (JpegBits *bits)
+{
+ return bits->end - bits->ptr;
+}
+
+int bits_needbits(JpegBits *b, int n_bytes)
+{
+ if(b->ptr==NULL)return 1;
+ if(b->ptr + n_bytes > b->end)return 1;
+
+ return 0;
+}
+
+int getbit(JpegBits *b)
+{
+ int r;
+
+ r = ((*b->ptr)>>(7-b->idx))&1;
+
+ b->idx++;
+ if(b->idx>=8){
+ b->ptr++;
+ b->idx = 0;
+ }
+
+ return r;
+}
+
+unsigned int getbits(JpegBits *b, int n)
+{
+ unsigned long r = 0;
+ int i;
+
+ for(i=0;i<n;i++){
+ r <<=1;
+ r |= getbit(b);
+ }
+
+ return r;
+}
+
+unsigned int peekbits(JpegBits *b, int n)
+{
+ JpegBits tmp = *b;
+
+ return getbits(&tmp, n);
+}
+
+int getsbits(JpegBits *b, int n)
+{
+ unsigned long r = 0;
+ int i;
+
+ if(n==0)return 0;
+ r = -getbit(b);
+ for(i=1;i<n;i++){
+ r <<=1;
+ r |= getbit(b);
+ }
+
+ return r;
+}
+
+unsigned int peek_u8(JpegBits *b)
+{
+ return *b->ptr;
+}
+
+unsigned int get_u8(JpegBits *b)
+{
+ return *b->ptr++;
+}
+
+unsigned int get_u16(JpegBits *b)
+{
+ unsigned int r;
+
+ r = b->ptr[0] | (b->ptr[1]<<8);
+ b->ptr+=2;
+
+ return r;
+}
+
+unsigned int get_be_u16(JpegBits *b)
+{
+ unsigned int r;
+
+ r = (b->ptr[0]<<8) | b->ptr[1];
+ b->ptr+=2;
+
+ return r;
+}
+
+unsigned int get_u32(JpegBits *b)
+{
+ unsigned int r;
+
+ r = b->ptr[0] | (b->ptr[1]<<8) | (b->ptr[2]<<16) | (b->ptr[3]<<24);
+ b->ptr+=4;
+
+ return r;
+}
+
+void syncbits(JpegBits *b)
+{
+ if(b->idx){
+ b->ptr++;
+ b->idx=0;
+ }
+
+}
+
diff --git a/swfdec/jpeg/jpeg_bits.h b/swfdec/jpeg/jpeg_bits.h
new file mode 100644
index 0000000..90cdcec
--- /dev/null
+++ b/swfdec/jpeg/jpeg_bits.h
@@ -0,0 +1,32 @@
+
+#ifndef __BITS_H__
+#define __BITS_H__
+
+typedef struct _JpegBits JpegBits;
+struct _JpegBits {
+ unsigned char *ptr;
+ int idx;
+ unsigned char *end;
+ int error;
+};
+
+int jpeg_bits_error (JpegBits *bits);
+int jpeg_bits_get_u8 (JpegBits *bits);
+void jpeg_bits_skip (JpegBits *bits, int n);
+int jpeg_bits_get_u16_be (JpegBits *bits);
+int jpeg_bits_available (JpegBits *bits);
+
+int bits_needbits(JpegBits *b, int n_bytes);
+int getbit(JpegBits *b);
+unsigned int getbits(JpegBits *b, int n);
+unsigned int peekbits(JpegBits *b, int n);
+int getsbits(JpegBits *b, int n);
+unsigned int peek_u8(JpegBits *b);
+unsigned int get_u8(JpegBits *b);
+unsigned int get_u16(JpegBits *b);
+unsigned int get_be_u16(JpegBits *b);
+unsigned int get_u32(JpegBits *b);
+void syncbits(JpegBits *b);
+
+#endif
+
diff --git a/swfdec/jpeg/jpeg_huffman.c b/swfdec/jpeg/jpeg_huffman.c
new file mode 100644
index 0000000..d5b7f61
--- /dev/null
+++ b/swfdec/jpeg/jpeg_huffman.c
@@ -0,0 +1,168 @@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <cogcompat.h>
+#include <liboil/liboil.h>
+
+#include <string.h>
+
+#include "jpeg.h"
+
+/* misc helper function definitions */
+
+static char *sprintbits (char *str, unsigned int bits, int n);
+
+
+void
+huffman_table_dump (HuffmanTable * table)
+{
+ unsigned int n_bits;
+ unsigned int code;
+ char str[33];
+ int i;
+ HuffmanEntry *entry;
+
+ COG_DEBUG ("dumping huffman table %p", table);
+ for (i = 0; i < table->len; i++) {
+ entry = table->entries + i;
+ n_bits = entry->n_bits;
+ code = entry->symbol >> (16 - n_bits);
+ sprintbits (str, code, n_bits);
+ COG_DEBUG ("%s --> %d", str, entry->value);
+ }
+}
+
+void
+huffman_table_init (HuffmanTable *table)
+{
+ memset (table, 0, sizeof(HuffmanTable));
+}
+
+void
+huffman_table_add (HuffmanTable * table, uint32_t code, int n_bits, int value)
+{
+ HuffmanEntry *entry = table->entries + table->len;
+
+ entry->value = value;
+ entry->symbol = code << (16 - n_bits);
+ entry->mask = 0xffff ^ (0xffff >> n_bits);
+ entry->n_bits = n_bits;
+
+ table->len++;
+}
+
+unsigned int
+huffman_table_decode_jpeg (JpegDecoder *dec, HuffmanTable * tab, JpegBits * bits)
+{
+ unsigned int code;
+ int i;
+ char str[33];
+ HuffmanEntry *entry;
+
+ code = peekbits (bits, 16);
+ for (i = 0; i < tab->len; i++) {
+ entry = tab->entries + i;
+ if ((code & entry->mask) == entry->symbol) {
+ code = getbits (bits, entry->n_bits);
+ sprintbits (str, code, entry->n_bits);
+ COG_DEBUG ("%s --> %d", str, entry->value);
+ return entry->value;
+ }
+ }
+ COG_ERROR ("huffman sync lost");
+
+ return -1;
+}
+
+int
+huffman_table_decode_macroblock (JpegDecoder *dec, short *block, HuffmanTable * dc_tab,
+ HuffmanTable * ac_tab, JpegBits * bits)
+{
+ int r, s, x, rs;
+ int k;
+ char str[33];
+
+ memset (block, 0, sizeof (short) * 64);
+
+ s = huffman_table_decode_jpeg (dec, dc_tab, bits);
+ if (s < 0)
+ return -1;
+ x = getbits (bits, s);
+ if ((x >> (s - 1)) == 0) {
+ x -= (1 << s) - 1;
+ }
+ COG_DEBUG ("s=%d (block[0]=%d)", s, x);
+ block[0] = x;
+
+ for (k = 1; k < 64; k++) {
+ rs = huffman_table_decode_jpeg (dec, ac_tab, bits);
+ if (rs < 0) {
+ COG_DEBUG ("huffman error");
+ return -1;
+ }
+ if (bits->ptr > bits->end) {
+ COG_DEBUG ("overrun");
+ return -1;
+ }
+ s = rs & 0xf;
+ r = rs >> 4;
+ if (s == 0) {
+ if (r == 15) {
+ COG_DEBUG ("r=%d s=%d (skip 16)", r, s);
+ k += 15;
+ } else {
+ COG_DEBUG ("r=%d s=%d (eob)", r, s);
+ break;
+ }
+ } else {
+ k += r;
+ if (k >= 64) {
+ jpeg_decoder_error (dec, "macroblock overrun");
+ return -1;
+ }
+ x = getbits (bits, s);
+ sprintbits (str, x, s);
+ if ((x >> (s - 1)) == 0) {
+ x -= (1 << s) - 1;
+ }
+ block[k] = x;
+ COG_DEBUG ("r=%d s=%d (%s -> block[%d]=%d)", r, s, str, k, x);
+ }
+ }
+ return 0;
+}
+
+int
+huffman_table_decode (JpegDecoder *dec, HuffmanTable * dc_tab, HuffmanTable * ac_tab,
+ JpegBits * bits)
+{
+ int16_t zz[64];
+ int ret;
+
+ while (bits->ptr < bits->end) {
+ ret = huffman_table_decode_macroblock (dec, zz, dc_tab, ac_tab, bits);
+ if (ret < 0)
+ return -1;
+ }
+
+ return 0;
+}
+
+/* misc helper functins */
+
+static char *
+sprintbits (char *str, unsigned int bits, int n)
+{
+ int i;
+ int bit = 1 << (n - 1);
+
+ for (i = 0; i < n; i++) {
+ str[i] = (bits & bit) ? '1' : '0';
+ bit >>= 1;
+ }
+ str[i] = 0;
+
+ return str;
+}
diff --git a/swfdec/jpeg/jpeg_huffman.h b/swfdec/jpeg/jpeg_huffman.h
new file mode 100644
index 0000000..9763e09
--- /dev/null
+++ b/swfdec/jpeg/jpeg_huffman.h
@@ -0,0 +1,37 @@
+
+#ifndef _HUFFMAN_H_
+#define _HUFFMAN_H_
+
+#include <liboil/liboil-stdint.h>
+
+#include "jpeg_bits.h"
+
+typedef struct _HuffmanEntry HuffmanEntry;
+typedef struct _HuffmanTable HuffmanTable;
+
+struct _HuffmanEntry {
+ unsigned int symbol;
+ unsigned int mask;
+ int n_bits;
+ unsigned char value;
+};
+
+struct _HuffmanTable {
+ int len;
+ HuffmanEntry entries[256];
+};
+
+
+void huffman_table_init(HuffmanTable *table);
+
+void huffman_table_dump(HuffmanTable *table);
+void huffman_table_add(HuffmanTable *table, uint32_t code, int n_bits,
+ int value);
+unsigned int huffman_table_decode_jpeg(HuffmanTable *tab, JpegBits *bits);
+int huffman_table_decode_macroblock(short *block, HuffmanTable *dc_tab,
+ HuffmanTable *ac_tab, JpegBits *bits);
+int huffman_table_decode(HuffmanTable *dc_tab, HuffmanTable *ac_tab, JpegBits *bits);
+
+
+#endif
+
diff --git a/swfdec/jpeg/jpeg_markers.h b/swfdec/jpeg/jpeg_markers.h
new file mode 100644
index 0000000..584cb23
--- /dev/null
+++ b/swfdec/jpeg/jpeg_markers.h
@@ -0,0 +1,44 @@
+
+#define JPEG_MARKER_STUFFED 0x00
+#define JPEG_MARKER_TEM 0x01
+#define JPEG_MARKER_RES 0x02
+
+#define JPEG_MARKER_SOF_0 0xc0
+#define JPEG_MARKER_SOF_1 0xc1
+#define JPEG_MARKER_SOF_2 0xc2
+#define JPEG_MARKER_SOF_3 0xc3
+#define JPEG_MARKER_DHT 0xc4
+#define JPEG_MARKER_SOF_5 0xc5
+#define JPEG_MARKER_SOF_6 0xc6
+#define JPEG_MARKER_SOF_7 0xc7
+#define JPEG_MARKER_JPG 0xc8
+#define JPEG_MARKER_SOF_9 0xc9
+#define JPEG_MARKER_SOF_10 0xca
+#define JPEG_MARKER_SOF_11 0xcb
+#define JPEG_MARKER_DAC 0xcc
+#define JPEG_MARKER_SOF_13 0xcd
+#define JPEG_MARKER_SOF_14 0xce
+#define JPEG_MARKER_SOF_15 0xcf
+
+#define JPEG_MARKER_RST_0 0xd0
+#define JPEG_MARKER_RST_1 0xd1
+#define JPEG_MARKER_RST_2 0xd2
+#define JPEG_MARKER_RST_3 0xd3
+#define JPEG_MARKER_RST_4 0xd4
+#define JPEG_MARKER_RST_5 0xd5
+#define JPEG_MARKER_RST_6 0xd6
+#define JPEG_MARKER_RST_7 0xd7
+#define JPEG_MARKER_SOI 0xd8
+#define JPEG_MARKER_EOI 0xd9
+#define JPEG_MARKER_SOS 0xda
+#define JPEG_MARKER_DQT 0xdb
+#define JPEG_MARKER_DNL 0xdc
+#define JPEG_MARKER_DRI 0xdd
+#define JPEG_MARKER_DHP 0xde
+#define JPEG_MARKER_EXP 0xdf
+#define JPEG_MARKER_APP(x) (0xe0 + (x))
+#define JPEG_MARKER_JPG_(x) (0xf0 + (x))
+#define JPEG_MARKER_COM 0xfe
+
+#define JPEG_MARKER_JFIF JPEG_MARKER_APP(0)
+
diff --git a/swfdec/jpeg/jpeg_rgb_decoder.c b/swfdec/jpeg/jpeg_rgb_decoder.c
new file mode 100644
index 0000000..3c01914
--- /dev/null
+++ b/swfdec/jpeg/jpeg_rgb_decoder.c
@@ -0,0 +1,352 @@
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "jpeg.h"
+
+#include <liboil/liboil.h>
+#include <liboil/liboildebug.h>
+
+#define CLAMP(x,a,b) ((x)<(a) ? (a) : ((x)>(b) ? (b) : (x)))
+#define oil_argb(a,r,g,b) \
+ ((oil_clamp_255(a)<<24) | \
+ (oil_clamp_255(r)<<16) | \
+ (oil_clamp_255(g)<<8) | \
+ (oil_clamp_255(b)<<0))
+#define oil_max(x,y) ((x)>(y)?(x):(y))
+#define oil_min(x,y) ((x)<(y)?(x):(y))
+#define oil_clamp_255(x) oil_max(0,oil_min((x),255))
+
+
+static int16_t jfif_matrix[24] = {
+ 0, 0, -8192, -8192,
+ 16384, 0, 0, 0,
+ 0, 16384, 16384, 16384,
+ 0, 0, -5638, 29032,
+ 0, 22970, -11700, 0,
+ 0, 0, 0, 0
+};
+
+
+uint32_t * get_argb_444 (JpegDecoder *dec);
+uint32_t * get_argb_422 (JpegDecoder *dec);
+uint32_t * get_argb_422v (JpegDecoder *dec);
+uint32_t * get_argb_420 (JpegDecoder *dec);
+
+#if 0
+static void imagescale2h_u8 (unsigned char *dest, int d_rowstride,
+ unsigned char *src, int src_rowstride, int width, int height);
+static void imagescale2v_u8 (unsigned char *dest, int d_rowstride,
+ unsigned char *src, int src_rowstride, int width, int height);
+static void imagescale2h2v_u8 (unsigned char *dest, int d_rowstride,
+ unsigned char *src, int src_rowstride, int width, int height);
+static void scanlinescale2_u8 (unsigned char *dest, unsigned char *src,
+ int len);
+#endif
+
+
+int jpeg_decode_argb (uint8_t *data, int length, uint32_t **image,
+ int *width, int *height)
+{
+ JpegDecoder *dec;
+ int ret;
+
+ dec = jpeg_decoder_new();
+
+ jpeg_decoder_addbits (dec, data, length);
+ ret = jpeg_decoder_decode(dec);
+
+ if (!ret) return FALSE;
+
+ jpeg_decoder_get_image_size (dec, width, height);
+ *image = (uint32_t *)jpeg_decoder_get_argb_image (dec);
+ jpeg_decoder_free (dec);
+
+ return TRUE;
+}
+
+uint32_t *
+jpeg_decoder_get_argb_image (JpegDecoder *dec)
+{
+
+ if (dec->n_components == 3) {
+ if (dec->components[0].h_subsample == 1 &&
+ dec->components[0].v_subsample == 1 &&
+ dec->components[1].h_subsample == dec->components[2].h_subsample &&
+ dec->components[1].v_subsample == dec->components[2].v_subsample) {
+ if (dec->components[1].h_subsample == 1 &&
+ dec->components[1].v_subsample == 1) {
+ return get_argb_444 (dec);
+ } else if (dec->components[1].h_subsample == 2 &&
+ dec->components[1].v_subsample == 1) {
+ return get_argb_422 (dec);
+ } else if (dec->components[1].h_subsample == 1 &&
+ dec->components[1].v_subsample == 2) {
+ return get_argb_422v (dec);
+ } else if (dec->components[1].h_subsample == 2 &&
+ dec->components[1].v_subsample == 2) {
+ return get_argb_420 (dec);
+ }
+ }
+ }
+
+ return NULL;
+}
+
+static void
+yuv_mux (uint32_t *dest, uint8_t *src_y, uint8_t *src_u, uint8_t *src_v,
+ int n)
+{
+ int i;
+ for (i = 0; i < n; i++) {
+ dest[i] = oil_argb(255, src_y[i], src_u[i], src_v[i]);
+ }
+}
+
+static void
+upsample (uint8_t *d, uint8_t *s, int n)
+{
+ int i;
+
+ d[0] = s[0];
+
+ for (i = 0; i < n-3; i+=2) {
+ d[i + 1] = (3*s[i/2] + s[i/2+1] + 2)>>2;
+ d[i + 2] = (s[i/2] + 3*s[i/2+1] + 2)>>2;
+ }
+
+ if (n&1) {
+ i = n-3;
+ d[n-2] = s[n/2];
+ d[n-1] = s[n/2];
+ } else {
+ d[n-1] = s[n/2-1];
+ }
+
+}
+
+uint32_t *
+get_argb_444 (JpegDecoder *dec)
+{
+ uint32_t *tmp;
+ uint32_t *argb_image;
+ uint8_t *yp, *up, *vp;
+ uint32_t *argbp;
+ int j;
+
+ tmp = malloc (4 * dec->width * dec->height);
+ argb_image = malloc (4 * dec->width * dec->height);
+
+ yp = dec->components[0].image;
+ up = dec->components[1].image;
+ vp = dec->components[2].image;
+ argbp = argb_image;
+ for(j=0;j<dec->height;j++){
+ yuv_mux (tmp, yp, up, vp, dec->width);
+ oil_colorspace_argb(argbp, tmp, jfif_matrix, dec->width);
+ yp += dec->components[0].rowstride;
+ up += dec->components[1].rowstride;
+ vp += dec->components[2].rowstride;
+ argbp += dec->width;
+ }
+ free(tmp);
+ return argb_image;
+}
+
+uint32_t *
+get_argb_422 (JpegDecoder *dec)
+{
+ uint32_t *tmp;
+ uint8_t *tmp_u;
+ uint8_t *tmp_v;
+ uint32_t *argb_image;
+ uint8_t *yp, *up, *vp;
+ uint32_t *argbp;
+ int j;
+
+ tmp = malloc (4 * dec->width * dec->height);
+ tmp_u = malloc (dec->width);
+ tmp_v = malloc (dec->width);
+ argb_image = malloc (4 * dec->width * dec->height);
+
+ yp = dec->components[0].image;
+ up = dec->components[1].image;
+ vp = dec->components[2].image;
+ argbp = argb_image;
+ for(j=0;j<dec->height;j++){
+ upsample (tmp_u, up, dec->width);
+ upsample (tmp_v, vp, dec->width);
+ yuv_mux (tmp, yp, tmp_u, tmp_v, dec->width);
+ oil_colorspace_argb(argbp, tmp, jfif_matrix, dec->width);
+ yp += dec->components[0].rowstride;
+ up += dec->components[1].rowstride;
+ vp += dec->components[2].rowstride;
+ argbp += dec->width;
+ }
+ free(tmp);
+ free(tmp_u);
+ free(tmp_v);
+ return argb_image;
+}
+
+uint32_t *
+get_argb_422v (JpegDecoder *dec)
+{
+ uint32_t *tmp;
+ uint8_t *tmp_u;
+ uint8_t *tmp_v;
+ uint32_t *argb_image;
+ uint8_t *yp, *up, *vp;
+ uint32_t *argbp;
+ int halfheight;
+ int j;
+
+ tmp = malloc (4 * dec->width * dec->height);
+ tmp_u = malloc (dec->width);
+ tmp_v = malloc (dec->width);
+ argb_image = malloc (4 * dec->width * dec->height);
+
+ yp = dec->components[0].image;
+ up = dec->components[1].image;
+ vp = dec->components[2].image;
+ argbp = argb_image;
+ halfheight = (dec->height+1)>>1;
+ for(j=0;j<dec->height;j++){
+ uint32_t weight = 192 - 128*(j&1);
+
+ oil_merge_linear_u8(tmp_u,
+ up + dec->components[1].rowstride * CLAMP((j-1)/2,0,halfheight-1),
+ up + dec->components[1].rowstride * CLAMP((j+1)/2,0,halfheight-1),
+ &weight, dec->width);
+ oil_merge_linear_u8(tmp_v,
+ vp + dec->components[2].rowstride * CLAMP((j-1)/2,0,halfheight-1),
+ vp + dec->components[2].rowstride * CLAMP((j+1)/2,0,halfheight-1),
+ &weight, dec->width);
+
+ yuv_mux (tmp, yp, tmp_u, tmp_v, dec->width);
+ oil_colorspace_argb(argbp, tmp, jfif_matrix, dec->width);
+ yp += dec->components[0].rowstride;
+ argbp += dec->width;
+ }
+ free(tmp);
+ free(tmp_u);
+ free(tmp_v);
+ return argb_image;
+}
+
+uint32_t *
+get_argb_420 (JpegDecoder *dec)
+{
+ uint32_t *tmp;
+ uint8_t *tmp_u;
+ uint8_t *tmp_v;
+ uint8_t *tmp1;
+ uint32_t *argb_image;
+ uint8_t *yp, *up, *vp;
+ uint32_t *argbp;
+ int j;
+ int halfwidth;
+ int halfheight;
+
+ halfwidth = (dec->width + 1)>>1;
+ tmp = malloc (4 * dec->width * dec->height);
+ tmp_u = malloc (dec->width);
+ tmp_v = malloc (dec->width);
+ tmp1 = malloc (halfwidth);
+ argb_image = malloc (4 * dec->width * dec->height);
+
+ yp = dec->components[0].image;
+ up = dec->components[1].image;
+ vp = dec->components[2].image;
+ argbp = argb_image;
+ halfheight = (dec->height+1)>>1;
+ for(j=0;j<dec->height;j++){
+ uint32_t weight = 192 - 128*(j&1);
+
+ oil_merge_linear_u8(tmp1,
+ up + dec->components[1].rowstride * CLAMP((j-1)/2,0,halfheight-1),
+ up + dec->components[1].rowstride * CLAMP((j+1)/2,0,halfheight-1),
+ &weight, halfwidth);
+ upsample (tmp_u, tmp1, dec->width);
+ oil_merge_linear_u8(tmp1,
+ vp + dec->components[2].rowstride * CLAMP((j-1)/2,0,halfheight-1),
+ vp + dec->components[2].rowstride * CLAMP((j+1)/2,0,halfheight-1),
+ &weight, halfwidth);
+ upsample (tmp_v, tmp1, dec->width);
+
+ yuv_mux (tmp, yp, tmp_u, tmp_v, dec->width);
+ oil_colorspace_argb(argbp, tmp, jfif_matrix, dec->width);
+ yp += dec->components[0].rowstride;
+ argbp += dec->width;
+ }
+ free(tmp);
+ free(tmp_u);
+ free(tmp_v);
+ free(tmp1);
+ return argb_image;
+}
+
+#if 0
+int
+jpeg_rgb_decoder_get_image (JpegRGBDecoder * rgbdec,
+ unsigned char **image, int *rowstride, int *width, int *height)
+{
+ int i;
+
+ jpeg_decoder_get_image_size (rgbdec->dec, &rgbdec->width, &rgbdec->height);
+ for (i = 0; i < 3; i++) {
+ jpeg_decoder_get_component_ptr (rgbdec->dec, i + 1,
+ &rgbdec->component[i].image, &rgbdec->component[i].rowstride);
+ jpeg_decoder_get_component_subsampling (rgbdec->dec, i + 1,
+ &rgbdec->component[i].h_subsample, &rgbdec->component[i].v_subsample);
+ rgbdec->component[i].alloc = 0;
+ if (rgbdec->component[i].h_subsample > 1 ||
+ rgbdec->component[i].v_subsample > 1) {
+ unsigned char *dest;
+
+ dest = malloc (rgbdec->width * rgbdec->height);
+ if (rgbdec->component[i].v_subsample > 1) {
+ if (rgbdec->component[i].h_subsample > 1) {
+ imagescale2h2v_u8 (dest,
+ rgbdec->width,
+ rgbdec->component[i].image,
+ rgbdec->component[i].rowstride, rgbdec->width, rgbdec->height);
+ } else {
+ imagescale2v_u8 (dest,
+ rgbdec->width,
+ rgbdec->component[i].image,
+ rgbdec->component[i].rowstride, rgbdec->width, rgbdec->height);
+ }
+ } else {
+ imagescale2h_u8 (dest,
+ rgbdec->width,
+ rgbdec->component[i].image,
+ rgbdec->component[i].rowstride, rgbdec->width, rgbdec->height);
+ }
+ rgbdec->component[i].alloc = 1;
+ rgbdec->component[i].image = dest;
+ rgbdec->component[i].rowstride = rgbdec->width;
+ rgbdec->component[i].h_subsample = 1;
+ rgbdec->component[i].v_subsample = 1;
+ }
+ }
+
+ rgbdec->image = malloc (rgbdec->width * rgbdec->height * 4);
+
+ convert (rgbdec);
+
+ if (image)
+ *image = rgbdec->image;
+ if (rowstride)
+ *rowstride = rgbdec->width * 4;
+ if (width)
+ *width = rgbdec->width;
+ if (height)
+ *height = rgbdec->height;
+
+ return 0;
+}
+#endif
+
+
diff --git a/swfdec/jpeg/jpeg_rgb_decoder.h b/swfdec/jpeg/jpeg_rgb_decoder.h
new file mode 100644
index 0000000..08501ff
--- /dev/null
+++ b/swfdec/jpeg/jpeg_rgb_decoder.h
@@ -0,0 +1,18 @@
+
+#ifndef _JPEG_RGB_DECODER_H_
+#define _JPEG_RGB_DECODER_H_
+
+typedef struct jpeg_rgb_decoder_struct JpegRGBDecoder;
+
+
+JpegRGBDecoder *jpeg_rgb_decoder_new(void);
+void jpeg_rgb_decoder_free(JpegRGBDecoder *dec);
+int jpeg_rgb_decoder_addbits(JpegRGBDecoder *dec, unsigned char *data, unsigned int len);
+int jpeg_rgb_decoder_parse(JpegRGBDecoder *dec);
+int jpeg_rgb_decoder_get_image(JpegRGBDecoder *dec,
+ unsigned char **image, int *rowstride, int *width, int *height);
+
+
+
+#endif
+
diff --git a/swfdec/jpeg/jpeg_tables.c b/swfdec/jpeg/jpeg_tables.c
new file mode 100644
index 0000000..bd2d22a
--- /dev/null
+++ b/swfdec/jpeg/jpeg_tables.c
@@ -0,0 +1,54 @@
+
+unsigned char jpeg_standard_tables[] = {
+ 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
+
+ 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03,
+ 0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d,
+ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31,
+ 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32,
+ 0x81, 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52,
+ 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
+ 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
+ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45,
+ 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57,
+ 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
+ 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83,
+ 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94,
+ 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
+ 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
+ 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
+ 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8,
+ 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
+ 0xf9, 0xfa,
+
+ 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
+ 0x0a, 0x0b,
+
+ 0x00, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04,
+ 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77,
+ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06,
+ 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81,
+ 0x08, 0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33,
+ 0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
+ 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27, 0x28,
+ 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44,
+ 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56,
+ 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+ 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
+ 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92,
+ 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3,
+ 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
+ 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
+ 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
+ 0xd7, 0xd8, 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+ 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
+ 0xf9, 0xfa,
+};
+
+int jpeg_standard_tables_size = sizeof(jpeg_standard_tables);
+
diff --git a/swfdec/swfdec.h b/swfdec/swfdec.h
new file mode 100644
index 0000000..e2432eb
--- /dev/null
+++ b/swfdec/swfdec.h
@@ -0,0 +1,48 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SWFDEC_H__
+#define __SWFDEC_H__
+
+#include <libswfdec/swfdec_as_context.h>
+#include <libswfdec/swfdec_as_debugger.h>
+#include <libswfdec/swfdec_as_frame.h>
+#include <libswfdec/swfdec_as_function.h>
+#include <libswfdec/swfdec_as_native_function.h>
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_as_types.h>
+#include <libswfdec/swfdec_script.h>
+
+#include <libswfdec/swfdec_audio.h>
+#include <libswfdec/swfdec_buffer.h>
+#include <libswfdec/swfdec_enums.h>
+#include <libswfdec/swfdec_file_loader.h>
+#include <libswfdec/swfdec_keys.h>
+#include <libswfdec/swfdec_loader.h>
+#include <libswfdec/swfdec_player.h>
+#include <libswfdec/swfdec_player_scripting.h>
+#include <libswfdec/swfdec_rectangle.h>
+#include <libswfdec/swfdec_socket.h>
+#include <libswfdec/swfdec_stream.h>
+#include <libswfdec/swfdec_system.h>
+#include <libswfdec/swfdec_url.h>
+
+#endif
diff --git a/swfdec/swfdec_accessibility.c b/swfdec/swfdec_accessibility.c
new file mode 100644
index 0000000..46497d2
--- /dev/null
+++ b/swfdec/swfdec_accessibility.c
@@ -0,0 +1,50 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (1999, 0, swfdec_accessibility_isActive)
+void
+swfdec_accessibility_isActive (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Accessibility.isActive (static)");
+}
+
+SWFDEC_AS_NATIVE (1999, 1, swfdec_accessibility_sendEvent)
+void
+swfdec_accessibility_sendEvent (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Accessibility.sendEvent (static)");
+}
+
+SWFDEC_AS_NATIVE (1999, 2, swfdec_accessibility_updateProperties)
+void
+swfdec_accessibility_updateProperties (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Accessibility.updateProperties (static)");
+}
diff --git a/swfdec/swfdec_amf.c b/swfdec/swfdec_amf.c
new file mode 100644
index 0000000..688df0a
--- /dev/null
+++ b/swfdec/swfdec_amf.c
@@ -0,0 +1,225 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_amf.h"
+#include "swfdec_as_array.h"
+#include "swfdec_debug.h"
+
+typedef gboolean (* SwfdecAmfParseFunc) (SwfdecAsContext *cx, SwfdecBits *bits, SwfdecAsValue *val);
+extern const SwfdecAmfParseFunc parse_funcs[SWFDEC_AMF_N_TYPES];
+
+static gboolean
+swfdec_amf_parse_boolean (SwfdecAsContext *context, SwfdecBits *bits, SwfdecAsValue *val)
+{
+ SWFDEC_AS_VALUE_SET_BOOLEAN (val, swfdec_bits_get_u8 (bits) ? TRUE : FALSE);
+ return TRUE;
+}
+
+static gboolean
+swfdec_amf_parse_number (SwfdecAsContext *context, SwfdecBits *bits, SwfdecAsValue *val)
+{
+ SWFDEC_AS_VALUE_SET_NUMBER (val, swfdec_bits_get_bdouble (bits));
+ return TRUE;
+}
+
+static gboolean
+swfdec_amf_parse_string (SwfdecAsContext *context, SwfdecBits *bits, SwfdecAsValue *val)
+{
+ guint len = swfdec_bits_get_bu16 (bits);
+ char *s;
+
+ /* FIXME: the supplied version is likely incorrect */
+ s = swfdec_bits_get_string_length (bits, len, context->version);
+ if (s == NULL)
+ return FALSE;
+ SWFDEC_AS_VALUE_SET_STRING (val, swfdec_as_context_give_string (context, s));
+ return TRUE;
+}
+
+static gboolean
+swfdec_amf_parse_properties (SwfdecAsContext *context, SwfdecBits *bits, SwfdecAsObject *object)
+{
+ guint type;
+ SwfdecAmfParseFunc func;
+
+ while (swfdec_bits_left (bits)) {
+ SwfdecAsValue val;
+ const char *name;
+
+ if (!swfdec_amf_parse_string (context, bits, &val))
+ return FALSE;
+ name = SWFDEC_AS_VALUE_GET_STRING (&val);
+ type = swfdec_bits_get_u8 (bits);
+ if (type == SWFDEC_AMF_END_OBJECT)
+ break;
+ if (type >= SWFDEC_AMF_N_TYPES ||
+ (func = parse_funcs[type]) == NULL) {
+ SWFDEC_ERROR ("no parse func for AMF type %u", type);
+ goto error;
+ }
+ swfdec_as_object_set_variable (object, name, &val); /* GC... */
+ if (!func (context, bits, &val)) {
+ goto error;
+ }
+ swfdec_as_object_set_variable (object, name, &val);
+ }
+ /* no more bytes seems to end automatically */
+ return TRUE;
+
+error:
+ return FALSE;
+}
+
+static gboolean
+swfdec_amf_parse_object (SwfdecAsContext *context, SwfdecBits *bits, SwfdecAsValue *val)
+{
+ SwfdecAsObject *object;
+
+ object = swfdec_as_object_new (context);
+ if (object == NULL)
+ return FALSE;
+ if (!swfdec_amf_parse_properties (context, bits, object))
+ return FALSE;
+ SWFDEC_AS_VALUE_SET_OBJECT (val, object);
+ return TRUE;
+}
+
+static gboolean
+swfdec_amf_parse_mixed_array (SwfdecAsContext *context, SwfdecBits *bits, SwfdecAsValue *val)
+{
+ guint len;
+ SwfdecAsObject *array;
+
+ len = swfdec_bits_get_bu32 (bits);
+ array = swfdec_as_array_new (context);
+ if (array == NULL)
+ return FALSE;
+ if (!swfdec_amf_parse_properties (context, bits, array))
+ return FALSE;
+ SWFDEC_AS_VALUE_SET_OBJECT (val, array);
+ return TRUE;
+}
+
+static gboolean
+swfdec_amf_parse_array (SwfdecAsContext *context, SwfdecBits *bits, SwfdecAsValue *val)
+{
+ guint i, len;
+ SwfdecAsObject *array;
+ guint type;
+ SwfdecAmfParseFunc func;
+
+ len = swfdec_bits_get_bu32 (bits);
+ array = swfdec_as_array_new (context);
+ if (array == NULL)
+ return FALSE;
+ for (i = 0; i < len; i++) {
+ SwfdecAsValue tmp;
+ type = swfdec_bits_get_u8 (bits);
+ if (type >= SWFDEC_AMF_N_TYPES ||
+ (func = parse_funcs[type]) == NULL) {
+ SWFDEC_ERROR ("no parse func for AMF type %u", type);
+ goto fail;
+ }
+ if (!func (context, bits, &tmp))
+ goto fail;
+ swfdec_as_array_push (SWFDEC_AS_ARRAY (array), &tmp);
+ }
+
+ SWFDEC_AS_VALUE_SET_OBJECT (val, array);
+ return TRUE;
+
+fail:
+ return FALSE;
+}
+
+const SwfdecAmfParseFunc parse_funcs[SWFDEC_AMF_N_TYPES] = {
+ [SWFDEC_AMF_NUMBER] = swfdec_amf_parse_number,
+ [SWFDEC_AMF_BOOLEAN] = swfdec_amf_parse_boolean,
+ [SWFDEC_AMF_STRING] = swfdec_amf_parse_string,
+ [SWFDEC_AMF_OBJECT] = swfdec_amf_parse_object,
+ [SWFDEC_AMF_MIXED_ARRAY] = swfdec_amf_parse_mixed_array,
+ [SWFDEC_AMF_ARRAY] = swfdec_amf_parse_array,
+#if 0
+ SWFDEC_AMF_MOVIECLIP = 4,
+ SWFDEC_AMF_NULL = 5,
+ SWFDEC_AMF_UNDEFINED = 6,
+ SWFDEC_AMF_REFERENCE = 7,
+ SWFDEC_AMF_END_OBJECT = 9,
+ SWFDEC_AMF_ARRAY = 10,
+ SWFDEC_AMF_DATE = 11,
+ SWFDEC_AMF_BIG_STRING = 12,
+ SWFDEC_AMF_RECORDSET = 14,
+ SWFDEC_AMF_XML = 15,
+ SWFDEC_AMF_CLASS = 16,
+ SWFDEC_AMF_FLASH9 = 17,
+#endif
+};
+
+gboolean
+swfdec_amf_parse_one (SwfdecAsContext *context, SwfdecBits *bits,
+ SwfdecAmfType expected_type, SwfdecAsValue *rval)
+{
+ SwfdecAmfParseFunc func;
+ guint type;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), 0);
+ g_return_val_if_fail (context->global != NULL, 0);
+ g_return_val_if_fail (bits != NULL, FALSE);
+ g_return_val_if_fail (rval != NULL, FALSE);
+ g_return_val_if_fail (expected_type < SWFDEC_AMF_N_TYPES, FALSE);
+
+ type = swfdec_bits_get_u8 (bits);
+ if (type != expected_type) {
+ SWFDEC_ERROR ("parse object should be type %u, but is %u",
+ expected_type, type);
+ return FALSE;
+ }
+ if (type >= SWFDEC_AMF_N_TYPES ||
+ (func = parse_funcs[type]) == NULL) {
+ SWFDEC_ERROR ("no parse func for AMF type %u", type);
+ return FALSE;
+ }
+ return func (context, bits, rval);
+}
+
+guint
+swfdec_amf_parse (SwfdecAsContext *context, SwfdecBits *bits, guint n_items, ...)
+{
+ va_list args;
+ guint i;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), 0);
+ g_return_val_if_fail (context->global != NULL, 0);
+ g_return_val_if_fail (bits != NULL, 0);
+
+ va_start (args, n_items);
+ for (i = 0; i < n_items; i++) {
+ SwfdecAmfType type = va_arg (args, SwfdecAmfType);
+ SwfdecAsValue *val = va_arg (args, SwfdecAsValue *);
+ if (!swfdec_amf_parse_one (context, bits, type, val))
+ break;
+ }
+ va_end (args);
+ return i;
+}
+
diff --git a/swfdec/swfdec_amf.h b/swfdec/swfdec_amf.h
new file mode 100644
index 0000000..0f9c67e
--- /dev/null
+++ b/swfdec/swfdec_amf.h
@@ -0,0 +1,59 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SWFDEC_AMF_H__
+#define __SWFDEC_AMF_H__
+
+#include <libswfdec/swfdec_as_context.h>
+#include <libswfdec/swfdec_bits.h>
+
+typedef enum {
+ SWFDEC_AMF_NUMBER = 0,
+ SWFDEC_AMF_BOOLEAN = 1,
+ SWFDEC_AMF_STRING = 2,
+ SWFDEC_AMF_OBJECT = 3,
+ SWFDEC_AMF_MOVIECLIP = 4,
+ SWFDEC_AMF_NULL = 5,
+ SWFDEC_AMF_UNDEFINED = 6,
+ SWFDEC_AMF_REFERENCE = 7,
+ SWFDEC_AMF_MIXED_ARRAY = 8,
+ SWFDEC_AMF_END_OBJECT = 9,
+ SWFDEC_AMF_ARRAY = 10,
+ SWFDEC_AMF_DATE = 11,
+ SWFDEC_AMF_BIG_STRING = 12,
+ /* what is 13? */
+ SWFDEC_AMF_RECORDSET = 14,
+ SWFDEC_AMF_XML = 15,
+ SWFDEC_AMF_CLASS = 16,
+ SWFDEC_AMF_FLASH9 = 17,
+ /* add more items here */
+ SWFDEC_AMF_N_TYPES
+} SwfdecAmfType;
+
+gboolean swfdec_amf_parse_one (SwfdecAsContext * context,
+ SwfdecBits * bits,
+ SwfdecAmfType expected_type,
+ SwfdecAsValue * rval);
+guint swfdec_amf_parse (SwfdecAsContext * context,
+ SwfdecBits * bits,
+ guint n_items,
+ ...);
+
+
+#endif
diff --git a/swfdec/swfdec_as_array.c b/swfdec/swfdec_as_array.c
new file mode 100644
index 0000000..344c087
--- /dev/null
+++ b/swfdec/swfdec_as_array.c
@@ -0,0 +1,1399 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "swfdec_as_array.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_frame_internal.h"
+#include "swfdec_as_function.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_as_string.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_movie.h"
+#include "swfdec_debug.h"
+
+G_DEFINE_TYPE (SwfdecAsArray, swfdec_as_array, SWFDEC_TYPE_AS_OBJECT)
+
+/**
+ * SECTION:SwfdecAsArray
+ * @title: SwfdecAsArray
+ * @short_description: the array object
+ *
+ * The array object provides some convenience functions for creating and
+ * modifying arrays.
+ */
+
+/**
+ * SwfdecAsArray
+ *
+ * This is the type of the array object.
+ */
+
+/*
+ * Internal helper functions
+ */
+
+/* NB: type is important for overflow */
+static inline gint32
+swfdec_as_array_to_index (const char *str)
+{
+ char *end;
+ gulong l;
+
+ g_return_val_if_fail (str != NULL, -1);
+
+ l = strtoul (str, &end, 10);
+
+ if (*end != 0 || l > G_MAXINT32)
+ return -1;
+
+ return l;
+}
+
+static gint32
+swfdec_as_array_length_as_integer (SwfdecAsObject *object)
+{
+ SwfdecAsValue val;
+ gint32 length;
+
+ g_return_val_if_fail (object != NULL, 0);
+
+ swfdec_as_object_get_variable (object, SWFDEC_AS_STR_length, &val);
+ length = swfdec_as_value_to_integer (object->context, &val);
+
+ return length;
+}
+
+static gint32
+swfdec_as_array_length (SwfdecAsObject *object)
+{
+ gint32 length;
+
+ length = swfdec_as_array_length_as_integer (object);
+
+ if (length < 0)
+ return 0;
+
+ return length;
+}
+
+/**
+ * swfdec_as_array_get_length:
+ * @array: a #SwfdecAsArray
+ *
+ * Gets the current length of the @array.
+ *
+ * Returns: Current length of the @array, always >= 0
+ **/
+gint32
+swfdec_as_array_get_length (SwfdecAsArray *array)
+{
+ return swfdec_as_array_length (SWFDEC_AS_OBJECT (array));
+}
+
+static void
+swfdec_as_array_set_length_object (SwfdecAsObject *object, gint32 length)
+{
+ SwfdecAsValue val;
+
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+
+ SWFDEC_AS_VALUE_SET_INT (&val, length);
+ swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR_length, &val,
+ SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+}
+
+/**
+ * swfdec_as_array_set_length:
+ * @array: a #SwfdecAsArray
+ * @length: the new length
+ *
+ * Sets the length of the @array. Values outside the new length will be
+ * removed.
+ **/
+void
+swfdec_as_array_set_length (SwfdecAsArray *array, gint32 length)
+{
+ g_return_if_fail (SWFDEC_IS_AS_ARRAY (array));
+ g_return_if_fail (length >= 0);
+
+ swfdec_as_array_set_length_object (SWFDEC_AS_OBJECT (array), length);
+}
+
+typedef struct {
+ gint32 start_index;
+ gint32 num;
+} ForeachRemoveRangeData;
+
+static gboolean
+swfdec_as_array_foreach_remove_range (SwfdecAsObject *object,
+ const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
+{
+ ForeachRemoveRangeData *fdata = data;
+ gint32 idx;
+
+ idx = swfdec_as_array_to_index (variable);
+ if (idx == -1)
+ return FALSE;
+
+ if (idx >= fdata->start_index && idx < fdata->start_index + fdata->num)
+ return TRUE;
+
+ return FALSE;
+}
+
+static void
+swfdec_as_array_remove_range (SwfdecAsArray *array, gint32 start_index,
+ gint32 num)
+{
+ SwfdecAsObject *object = SWFDEC_AS_OBJECT (array);
+
+ g_return_if_fail (SWFDEC_IS_AS_ARRAY (array));
+ g_return_if_fail (start_index >= 0);
+ g_return_if_fail (num >= 0);
+ g_return_if_fail (start_index + num <= swfdec_as_array_length (object));
+
+ if (num == 0)
+ return;
+
+ // to avoid foreach loop, use special case when removing just one variable
+ if (num == 1) {
+ swfdec_as_object_delete_variable (object,
+ swfdec_as_integer_to_string (object->context, start_index));
+ } else {
+ ForeachRemoveRangeData fdata = { start_index, num };
+ swfdec_as_object_foreach_remove (object,
+ swfdec_as_array_foreach_remove_range, &fdata);
+ }
+}
+
+typedef struct {
+ gint32 start_index;
+ gint32 num;
+ gint32 to_index;
+} ForeachMoveRangeData;
+
+static const char *
+swfdec_as_array_foreach_move_range (SwfdecAsObject *object,
+ const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
+{
+ ForeachMoveRangeData *fdata = data;
+ gint32 idx;
+
+ idx = swfdec_as_array_to_index (variable);
+ if (idx == -1)
+ return variable;
+
+ if (idx >= fdata->start_index && idx < fdata->start_index + fdata->num) {
+ return swfdec_as_integer_to_string (object->context,
+ fdata->to_index + idx - fdata->start_index);
+ } else if (idx >= fdata->to_index && idx < fdata->to_index + fdata->num) {
+ return NULL;
+ } else {
+ return variable;
+ }
+}
+
+static void
+swfdec_as_array_move_range (SwfdecAsObject *object, gint32 from_index,
+ gint32 num, gint32 to_index)
+{
+ ForeachMoveRangeData fdata = { from_index, num, to_index };
+
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+ g_return_if_fail (from_index >= 0);
+ g_return_if_fail (num >= 0);
+ g_return_if_fail (from_index + num <= swfdec_as_array_length (object));
+ g_return_if_fail (to_index >= 0);
+
+ if (num == 0 || from_index == to_index)
+ return;
+
+ swfdec_as_object_foreach_rename (object, swfdec_as_array_foreach_move_range,
+ &fdata);
+
+ // only changes length if it becomes bigger, not if it becomes smaller
+ if (to_index + num > swfdec_as_array_length (object))
+ swfdec_as_array_set_length_object (object, to_index + num);
+}
+
+static void
+swfdec_as_array_set_range_with_flags (SwfdecAsObject *object,
+ gint32 start_index, gint32 num, const SwfdecAsValue *value,
+ SwfdecAsVariableFlag flags)
+{
+ gint32 i;
+ const char *var;
+
+ // allow negative indexes
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+ g_return_if_fail (num >= 0);
+ g_return_if_fail (num == 0 || value != NULL);
+
+ for (i = 0; i < num; i++) {
+ var = swfdec_as_integer_to_string (object->context, start_index + i);
+ swfdec_as_object_set_variable_and_flags (object, var, &value[i], flags);
+ }
+}
+
+static void
+swfdec_as_array_set_range (SwfdecAsObject *object, gint32 start_index,
+ gint32 num, const SwfdecAsValue *value)
+{
+ swfdec_as_array_set_range_with_flags (object, start_index, num, value, 0);
+}
+
+static void
+swfdec_as_array_append_internal (SwfdecAsObject *object, guint n,
+ const SwfdecAsValue *value)
+{
+ // allow negative length
+ swfdec_as_array_set_range (object,
+ swfdec_as_array_length_as_integer (object), n, value);
+}
+
+/**
+ * swfdec_as_array_push:
+ * @array: a #SwfdecAsArray
+ * @value: the value to add
+ *
+ * Adds the given @value to the @array. This is a macro that just calls
+ * swfdec_as_array_append_with_flags().
+ */
+
+/**
+ * swfdec_as_array_push_with_flags:
+ * @array: a #SwfdecAsArray
+ * @value: the value to add
+ * @flags: the #SwfdecAsVariableFlag flags to use
+ *
+ * Adds the given @value to the @array with the given @flags. This is a macro
+ * that just calls swfdec_as_array_append_with_flags().
+ */
+
+/**
+ * swfdec_as_array_append:
+ * @array: a #SwfdecAsArray
+ * @n: number of values to add
+ * @values: the values to add
+ *
+ * Appends the given @values to the @array. This is a macro that just calls
+ * swfdec_as_array_append_with_flags().
+ **/
+
+/**
+ * swfdec_as_array_append_with_flags:
+ * @array: a #SwfdecAsArray
+ * @n: number of values to add
+ * @values: the values to add
+ * @flags: the #SwfdecAsVariableFlag flags to use
+ *
+ * Appends the given @values to the @array using the given @flags.
+ **/
+void
+swfdec_as_array_append_with_flags (SwfdecAsArray *array, guint n,
+ const SwfdecAsValue *value, SwfdecAsVariableFlag flags)
+{
+ g_return_if_fail (SWFDEC_IS_AS_ARRAY (array));
+ g_return_if_fail (n == 0 || value != NULL);
+
+ // don't allow negative length
+ swfdec_as_array_set_range_with_flags (SWFDEC_AS_OBJECT (array),
+ swfdec_as_array_length (SWFDEC_AS_OBJECT (array)), n, value, flags);
+}
+
+/**
+ * swfdec_as_array_insert:
+ * @array: a #SwfdecAsArray
+ * @idx: index to insert the value to
+ * @value: a #SwfdecAsValue
+ *
+ * Inserts @value to @array at given index, making room for it by moving
+ * elements to bigger indexes if necessary. This is a macro that just calls
+ * swfdec_as_array_insert_with_flags().
+ **/
+/**
+ * swfdec_as_array_insert_with_flags:
+ * @array: a #SwfdecAsArray
+ * @idx: index to insert the value to
+ * @value: a #SwfdecAsValue
+ * @flags: the #SwfdecAsVariableFlag flags to use
+ *
+ * Inserts @value to @array at given index using given @flags, making room for
+ * it by moving elements to bigger indexes if necessary.
+ **/
+void
+swfdec_as_array_insert_with_flags (SwfdecAsArray *array, gint32 idx,
+ const SwfdecAsValue *value, SwfdecAsVariableFlag flags)
+{
+ gint32 length;
+ SwfdecAsObject *object;
+
+ g_return_if_fail (SWFDEC_IS_AS_ARRAY (array));
+ g_return_if_fail (idx >= 0);
+ g_return_if_fail (SWFDEC_IS_AS_VALUE (value));
+
+ object = SWFDEC_AS_OBJECT (array);
+ length = swfdec_as_array_length (object);
+
+ if (idx < length)
+ swfdec_as_array_move_range (object, idx, length - idx, idx + 1);
+ swfdec_as_array_set_range_with_flags (object, idx, 1, value, flags);
+}
+
+/**
+ * swfdec_as_array_remove:
+ * @array: a #SwfdecAsArray
+ * @idx: index of the value to remove
+ *
+ * Removes value at given index from the @array, elements with higher indexes
+ * will be moved towards the start of the @array.
+ **/
+void
+swfdec_as_array_remove (SwfdecAsArray *array, gint32 idx)
+{
+ gint32 length;
+ SwfdecAsObject *object;
+
+ g_return_if_fail (SWFDEC_IS_AS_ARRAY (array));
+ g_return_if_fail (idx >= 0);
+
+ object = SWFDEC_AS_OBJECT (array);
+ length = swfdec_as_array_length (object);
+
+ if (idx >= length)
+ return;
+
+ swfdec_as_array_move_range (object, idx + 1, length - (idx + 1), idx);
+ swfdec_as_array_set_length (array, length - 1);
+}
+
+/**
+ * swfdec_as_array_get_value:
+ * @array: a #SwfdecAsArray
+ * @idx: index of the value to get
+ * @value: a pointer to #SwfdecAsValue that will be set
+ *
+ * Gets a value from given index, if the value doesn't exists an undefined
+ * value is set.
+ **/
+void
+swfdec_as_array_get_value (SwfdecAsArray *array, gint32 idx,
+ SwfdecAsValue *value)
+{
+ const char *var;
+
+ g_assert (SWFDEC_IS_AS_ARRAY (array));
+ g_assert (idx >= 0);
+ g_assert (value != NULL);
+
+ var = swfdec_as_integer_to_string (SWFDEC_AS_OBJECT (array)->context, idx);
+ swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (array), var, value);
+}
+
+/**
+ * swfdec_as_array_set_value:
+ * @array: a #SwfdecAsArray
+ * @idx: index of the value to set
+ * @value: a pointer to #SwfdecAsValue
+ *
+ * Sets a @value to given index. The @array's length will be increased if
+ * necessary.
+ **/
+void
+swfdec_as_array_set_value (SwfdecAsArray *array, gint32 idx,
+ SwfdecAsValue *value)
+{
+ const char *var;
+
+ g_assert (SWFDEC_IS_AS_ARRAY (array));
+ g_assert (idx >= 0);
+ g_assert (SWFDEC_IS_AS_VALUE (value));
+
+ var = swfdec_as_integer_to_string (SWFDEC_AS_OBJECT (array)->context, idx);
+ swfdec_as_object_set_variable (SWFDEC_AS_OBJECT (array), var, value);
+}
+
+typedef struct {
+ SwfdecAsObject *object_to;
+ gint32 offset;
+ gint32 start_index;
+ gint32 num;
+} ForeachAppendArrayRangeData;
+
+static gboolean
+swfdec_as_array_foreach_append_array_range (SwfdecAsObject *object,
+ const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
+{
+ ForeachAppendArrayRangeData *fdata = data;
+ gint32 idx;
+ const char *var;
+
+ idx = swfdec_as_array_to_index (variable);
+ if (idx >= fdata->start_index && idx < fdata->start_index + fdata->num) {
+ var = swfdec_as_integer_to_string (fdata->object_to->context,
+ fdata->offset + (idx - fdata->start_index));
+ swfdec_as_object_set_variable (fdata->object_to, var, value);
+ }
+
+ return TRUE;
+}
+
+static void
+swfdec_as_array_append_array_range (SwfdecAsArray *array_to,
+ SwfdecAsObject *object_from, gint32 start_index, gint32 num)
+{
+ ForeachAppendArrayRangeData fdata;
+
+ g_return_if_fail (SWFDEC_IS_AS_ARRAY (array_to));
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object_from));
+ g_return_if_fail (start_index >= 0);
+ g_return_if_fail (
+ start_index + num <= swfdec_as_array_length (object_from));
+
+ if (num == 0)
+ return;
+
+ fdata.object_to = SWFDEC_AS_OBJECT (array_to);
+ fdata.offset = swfdec_as_array_length (SWFDEC_AS_OBJECT (array_to));
+ fdata.start_index = start_index;
+ fdata.num = num;
+
+ swfdec_as_array_set_length_object (fdata.object_to,
+ fdata.offset + fdata.num);
+ swfdec_as_object_foreach (object_from,
+ swfdec_as_array_foreach_append_array_range, &fdata);
+}
+
+static void
+swfdec_as_array_append_array (SwfdecAsArray *array_to,
+ SwfdecAsObject *object_from)
+{
+ swfdec_as_array_append_array_range (array_to, object_from, 0,
+ swfdec_as_array_length (object_from));
+}
+
+/*
+ * Class functions
+ */
+
+static void
+swfdec_as_array_set (SwfdecAsObject *object, const char *variable,
+ const SwfdecAsValue *val, guint flags)
+{
+ char *end;
+ gboolean indexvar = TRUE;
+ gint32 l = strtoul (variable, &end, 10);
+
+ if (*end != 0 || l > G_MAXINT32)
+ indexvar = FALSE;
+
+ // if we changed to smaller length, destroy all values that are outside it
+ if (!strcmp (variable, SWFDEC_AS_STR_length)) {
+ gint32 length_old = swfdec_as_array_length (object);
+ gint32 length_new = MAX (0,
+ swfdec_as_value_to_integer (object->context, val));
+ if (length_old > length_new) {
+ swfdec_as_array_remove_range (SWFDEC_AS_ARRAY (object), length_new,
+ length_old - length_new);
+ }
+ }
+
+ SWFDEC_AS_OBJECT_CLASS (swfdec_as_array_parent_class)->set (object, variable,
+ val, flags);
+
+ // if we added new value outside the current length, set a bigger length
+ if (indexvar) {
+ if (++l > swfdec_as_array_length_as_integer (object))
+ swfdec_as_array_set_length_object (object, l);
+ }
+}
+
+static void
+swfdec_as_array_class_init (SwfdecAsArrayClass *klass)
+{
+ SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
+
+ asobject_class->set = swfdec_as_array_set;
+}
+
+static void
+swfdec_as_array_init (SwfdecAsArray *array)
+{
+}
+
+/*
+ * The rest
+ */
+
+/**
+ * swfdec_as_array_new:
+ * @context: a #SwfdecAsContext
+ *
+ * Creates a new #SwfdecAsArray.
+ *
+ * Returns: the new array or %NULL on OOM.
+ **/
+SwfdecAsObject *
+swfdec_as_array_new (SwfdecAsContext *context)
+{
+ SwfdecAsObject *ret;
+ SwfdecAsValue val;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
+
+ if (!swfdec_as_context_use_mem (context, sizeof (SwfdecAsArray)))
+ return NULL;
+
+ ret = g_object_new (SWFDEC_TYPE_AS_ARRAY, NULL);
+ swfdec_as_object_add (ret, context, sizeof (SwfdecAsArray));
+ swfdec_as_object_get_variable (context->global, SWFDEC_AS_STR_Array, &val);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ swfdec_as_object_set_constructor (ret, SWFDEC_AS_VALUE_GET_OBJECT (&val));
+
+ swfdec_as_array_set_length (SWFDEC_AS_ARRAY (ret), 0);
+
+ return ret;
+}
+
+/*** AS CODE ***/
+
+SWFDEC_AS_NATIVE (252, 7, swfdec_as_array_join)
+void
+swfdec_as_array_join (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+ SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ int i, length;
+ const char *var, *str, *sep;
+ SwfdecAsValue val;
+
+ if (object == NULL || SWFDEC_IS_MOVIE (object))
+ return;
+
+ if (argc > 0) {
+ sep = swfdec_as_value_to_string (cx, &argv[0]);
+ } else {
+ sep = SWFDEC_AS_STR_COMMA;
+ }
+
+ length = swfdec_as_array_length (object);
+ if (length > 0) {
+ /* FIXME: implement this with the StringBuilder class */
+ GString *string;
+ swfdec_as_object_get_variable (object, SWFDEC_AS_STR_0, &val);
+ str = swfdec_as_value_to_string (cx, &val);
+ string = g_string_new (str);
+ for (i = 1; i < length; i++) {
+ var = swfdec_as_integer_to_string (cx, i);
+ swfdec_as_object_get_variable (object, var, &val);
+ var = swfdec_as_value_to_string (cx, &val);
+ g_string_append (string, sep);
+ g_string_append (string, var);
+ }
+ str = swfdec_as_context_give_string (cx, g_string_free (string, FALSE));
+ } else {
+ str = SWFDEC_AS_STR_EMPTY;
+ }
+
+ SWFDEC_AS_VALUE_SET_STRING (ret, str);
+}
+
+SWFDEC_AS_NATIVE (252, 9, swfdec_as_array_toString)
+void
+swfdec_as_array_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (object == NULL || SWFDEC_IS_MOVIE (object))
+ return;
+
+ swfdec_as_array_join (cx, object, 0, NULL, ret);
+}
+
+SWFDEC_AS_NATIVE (252, 1, swfdec_as_array_do_push)
+void
+swfdec_as_array_do_push (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (object == NULL || SWFDEC_IS_MOVIE (object))
+ return;
+
+ // if 0 args, just return the length
+ // manually set the length here to make the function work on non-Arrays
+ if (argc > 0) {
+ gint32 length = swfdec_as_array_length_as_integer (object);
+ swfdec_as_array_append_internal (object, argc, argv);
+ swfdec_as_array_set_length_object (object, length + argc);
+ }
+
+ SWFDEC_AS_VALUE_SET_INT (ret, swfdec_as_array_length_as_integer (object));
+}
+
+SWFDEC_AS_NATIVE (252, 2, swfdec_as_array_do_pop)
+void
+swfdec_as_array_do_pop (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ gint32 length;
+ const char *var;
+
+ if (object == NULL || SWFDEC_IS_MOVIE (object))
+ return;
+
+ // we allow negative indexes here, but not 0
+ length = swfdec_as_array_length_as_integer (object);
+ if (length == 0)
+ return;
+
+ var = swfdec_as_integer_to_string (object->context, length - 1);
+ swfdec_as_object_get_variable (object, var, ret);
+
+ // if Array, the length is reduced by one (which destroys the variable also)
+ // else the length is not reduced at all, but the variable is still deleted
+ if (SWFDEC_IS_AS_ARRAY (object)) {
+ swfdec_as_array_set_length_object (object, length - 1);
+ } else {
+ swfdec_as_object_delete_variable (object, var);
+ }
+}
+
+SWFDEC_AS_NATIVE (252, 5, swfdec_as_array_do_unshift)
+void
+swfdec_as_array_do_unshift (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ gint32 length;
+
+ if (object == NULL || SWFDEC_IS_MOVIE (object))
+ return;
+
+ if (argc) {
+ // don't allow negative length
+ length = swfdec_as_array_length (object);
+ swfdec_as_array_move_range (object, 0, length, argc);
+ swfdec_as_array_set_range (object, 0, argc, argv);
+ // if not Array, leave the length unchanged
+ if (!SWFDEC_IS_AS_ARRAY (object))
+ swfdec_as_array_set_length_object (object, length);
+ }
+
+ SWFDEC_AS_VALUE_SET_INT (ret, swfdec_as_array_length (object));
+}
+
+SWFDEC_AS_NATIVE (252, 4, swfdec_as_array_do_shift)
+void
+swfdec_as_array_do_shift (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ gint32 length;
+ const char *var;
+
+ if (object == NULL || SWFDEC_IS_MOVIE (object))
+ return;
+
+ // don't allow negative length
+ length = swfdec_as_array_length (object);
+ if (length <= 0)
+ return;
+
+ swfdec_as_object_get_variable (object, SWFDEC_AS_STR_0, ret);
+
+ swfdec_as_array_move_range (object, 1, length - 1, 0);
+
+ // if not Array, leave the length unchanged, and don't remove the element
+ if (SWFDEC_IS_AS_ARRAY (object)) {
+ swfdec_as_array_set_length_object (object, length - 1);
+ } else {
+ // we have to put the last element back, because we used move, not copy
+ SwfdecAsValue val;
+ if (length > 1) {
+ var = swfdec_as_integer_to_string (object->context, length - 2);
+ swfdec_as_object_get_variable (object, var, &val);
+ } else {
+ val = *ret;
+ }
+ var = swfdec_as_integer_to_string (object->context, length - 1);
+ swfdec_as_object_set_variable (object, var, &val);
+ }
+}
+
+static const char *
+swfdec_as_array_foreach_reverse (SwfdecAsObject *object, const char *variable,
+ SwfdecAsValue *value, guint flags, gpointer data)
+{
+ gint32 *length = data;
+ gint32 idx;
+
+ idx = swfdec_as_array_to_index (variable);
+ if (idx == -1 || idx >= *length)
+ return variable;
+
+ return swfdec_as_integer_to_string (object->context, *length - 1 - idx);
+}
+
+SWFDEC_AS_NATIVE (252, 11, swfdec_as_array_reverse)
+void
+swfdec_as_array_reverse (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ gint32 length;
+
+ if (object == NULL || SWFDEC_IS_MOVIE (object))
+ return;
+
+ length = swfdec_as_array_length (object);
+ swfdec_as_object_foreach_rename (object, swfdec_as_array_foreach_reverse,
+ &length);
+
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
+}
+
+SWFDEC_AS_NATIVE (252, 3, swfdec_as_array_concat)
+void
+swfdec_as_array_concat (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ guint j;
+ SwfdecAsObject *object_new;
+ SwfdecAsArray *array_new;
+ const char *var;
+
+ if (object == NULL || SWFDEC_IS_MOVIE (object))
+ return;
+
+ object_new = swfdec_as_array_new (cx);
+ if (object_new == NULL)
+ return;
+ array_new = SWFDEC_AS_ARRAY (object_new);
+
+ swfdec_as_array_append_array (array_new, object);
+
+ for (j = 0; j < argc; j++) {
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[j]) &&
+ SWFDEC_IS_AS_ARRAY (SWFDEC_AS_VALUE_GET_OBJECT (&argv[j])))
+ {
+ swfdec_as_array_append_array (array_new,
+ SWFDEC_AS_VALUE_GET_OBJECT (&argv[j]));
+ }
+ else
+ {
+ var = swfdec_as_integer_to_string (object->context,
+ swfdec_as_array_length (object_new));
+ swfdec_as_object_set_variable (object_new, var, &argv[j]);
+ }
+ }
+
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, object_new);
+}
+
+SWFDEC_AS_NATIVE (252, 6, swfdec_as_array_slice)
+void
+swfdec_as_array_slice (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+ SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ gint32 length, start_index, num;
+ SwfdecAsArray *array_new;
+
+ if (object == NULL || SWFDEC_IS_MOVIE (object))
+ return;
+
+ length = swfdec_as_array_length (object);
+
+ if (argc > 0) {
+ start_index = swfdec_as_value_to_integer (cx, &argv[0]);
+ if (start_index < 0)
+ start_index = length + start_index;
+ start_index = CLAMP (start_index, 0, length);
+ } else {
+ start_index = 0;
+ }
+
+ if (argc > 1) {
+ gint32 endIndex = swfdec_as_value_to_integer (cx, &argv[1]);
+ if (endIndex < 0)
+ endIndex = length + endIndex;
+ endIndex = CLAMP (endIndex, start_index, length);
+ num = endIndex - start_index;
+ } else {
+ num = length - start_index;
+ }
+
+ array_new = SWFDEC_AS_ARRAY (swfdec_as_array_new (cx));
+ if (array_new == NULL)
+ return;
+
+ swfdec_as_array_append_array_range (array_new, object, start_index, num);
+
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (array_new));
+}
+
+SWFDEC_AS_NATIVE (252, 8, swfdec_as_array_splice)
+void
+swfdec_as_array_splice (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ gint32 length, start_index, num_remove, num_add;
+ SwfdecAsArray *array_new;
+
+ if (object == NULL || SWFDEC_IS_MOVIE (object) || argc == 0)
+ return;
+
+ length = swfdec_as_array_length (object);
+
+ start_index = swfdec_as_value_to_integer (cx, &argv[0]);
+ if (start_index < 0)
+ start_index = length + start_index;
+ start_index = CLAMP (start_index, 0, length);
+
+ if (argc > 1) {
+ num_remove = CLAMP (swfdec_as_value_to_integer (cx, &argv[1]), 0,
+ length - start_index);
+ } else {
+ num_remove = length - start_index;
+ }
+
+ num_add = (argc > 2 ? argc - 2 : 0);
+
+ array_new = SWFDEC_AS_ARRAY (swfdec_as_array_new (cx));
+ if (array_new == NULL)
+ return;
+
+ swfdec_as_array_append_array_range (array_new, object, start_index,
+ num_remove);
+ swfdec_as_array_move_range (object, start_index + num_remove,
+ length - (start_index + num_remove), start_index + num_add);
+ if (num_remove > num_add)
+ swfdec_as_array_set_length_object (object, length - (num_remove - num_add));
+ if (argc > 2)
+ swfdec_as_array_set_range (object, start_index, argc - 2, argv + 2);
+
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (array_new));
+}
+
+// Sorting
+
+typedef enum {
+ ARRAY_SORT_OPTION_CASEINSENSITIVE = 1,
+ ARRAY_SORT_OPTION_DESCENDING = 2,
+ ARRAY_SORT_OPTION_UNIQUESORT = 4,
+ ARRAY_SORT_OPTION_RETURNINDEXEDARRAY = 8,
+ ARRAY_SORT_OPTION_NUMERIC = 16
+} ArraySortOptions;
+
+typedef struct {
+ SwfdecAsValue **order;
+ gint32 order_size;
+ SwfdecAsValue undefined;
+ gint32 defined_values;
+ gint32 length;
+ gint32 options;
+ SwfdecAsFunction *compare_custom_func;
+ const char ** fields;
+ SwfdecAsObject *object_new;
+} ForeachSortData;
+
+// inner function for swfdec_as_array_sort_compare
+static int
+swfdec_as_array_sort_compare_values (SwfdecAsContext *cx,
+ const SwfdecAsValue *a, const SwfdecAsValue *b, gint32 options,
+ SwfdecAsFunction *fun)
+{
+ int retval;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (cx), 0);
+ g_return_val_if_fail (SWFDEC_IS_AS_VALUE (a), 0);
+ g_return_val_if_fail (SWFDEC_IS_AS_VALUE (b), 0);
+ g_return_val_if_fail (SWFDEC_IS_AS_VALUE (b), 0);
+ g_return_val_if_fail (fun == NULL || SWFDEC_IS_AS_FUNCTION (fun), 0);
+
+ if (fun != NULL)
+ {
+ SwfdecAsValue argv[2] = { *a, *b };
+ SwfdecAsValue ret;
+ swfdec_as_function_call (fun, NULL, 2, argv, &ret);
+ swfdec_as_context_run (fun->object.context);
+ retval = swfdec_as_value_to_integer (cx, &ret);
+ }
+ else if (options & ARRAY_SORT_OPTION_NUMERIC &&
+ (SWFDEC_AS_VALUE_IS_NUMBER (a) ||
+ SWFDEC_AS_VALUE_IS_NUMBER (b)) &&
+ !SWFDEC_AS_VALUE_IS_UNDEFINED (a) &&
+ !SWFDEC_AS_VALUE_IS_UNDEFINED (b))
+ {
+ if (!SWFDEC_AS_VALUE_IS_NUMBER (a)) {
+ retval = 1;
+ } else if (!SWFDEC_AS_VALUE_IS_NUMBER (b)) {
+ retval = -1;
+ } else {
+ double an = swfdec_as_value_to_number (cx, a);
+ double bn = swfdec_as_value_to_number (cx, b);
+ retval = (an < bn ? -1 : (an > bn ? 1 : 0));
+ }
+ }
+ else if (options & ARRAY_SORT_OPTION_CASEINSENSITIVE)
+ {
+ retval = g_strcasecmp (swfdec_as_value_to_string (cx, a),
+ swfdec_as_value_to_string (cx, b));
+ }
+ else
+ {
+ retval = strcmp (swfdec_as_value_to_string (cx, a),
+ swfdec_as_value_to_string (cx, b));
+ }
+
+ if (options & ARRAY_SORT_OPTION_DESCENDING) {
+ return -retval;
+ } else {
+ return retval;
+ }
+}
+
+static int
+swfdec_as_array_sort_compare (SwfdecAsContext *cx, const SwfdecAsValue *a,
+ const SwfdecAsValue *b, gint32 options, SwfdecAsFunction *fun,
+ const char **fields)
+{
+ int i, retval;
+ SwfdecAsValue a_comp, b_comp;
+ SwfdecAsObject *object;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (cx), 0);
+ g_return_val_if_fail (SWFDEC_IS_AS_VALUE (a), 0);
+ g_return_val_if_fail (SWFDEC_IS_AS_VALUE (b), 0);
+ g_return_val_if_fail (SWFDEC_IS_AS_VALUE (b), 0);
+ g_return_val_if_fail (fun == NULL || SWFDEC_IS_AS_FUNCTION (fun), 0);
+ g_return_val_if_fail (fields == NULL || fields[0] != NULL, 0);
+
+ if (fields == NULL)
+ return swfdec_as_array_sort_compare_values (cx, a, b, options, fun);
+
+ i = 0;
+ do {
+ object = swfdec_as_value_to_object (cx, a);
+ if (object) {
+ swfdec_as_object_get_variable (object, fields[i], &a_comp);
+ } else {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (&a_comp);
+ }
+
+ object = swfdec_as_value_to_object (cx, b);
+ if (object) {
+ swfdec_as_object_get_variable (object, fields[i], &b_comp);
+ } else {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (&b_comp);
+ }
+
+ retval =
+ swfdec_as_array_sort_compare_values (cx, &a_comp, &b_comp, options, fun);
+ } while (retval == 0 && fields[++i] != NULL);
+
+ return retval;
+}
+
+// renames values in the array based on fdata->order values
+static const char *
+swfdec_as_array_foreach_sort_rename (SwfdecAsObject *object,
+ const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
+{
+ ForeachSortData *fdata = data;
+ gint32 idx, i;
+ gboolean after_undefined = FALSE;
+
+ idx = swfdec_as_array_to_index (variable);
+ if (idx == -1 || idx >= fdata->length)
+ return variable;
+
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (value))
+ return NULL;
+
+ for (i = 0; i < fdata->order_size; i++) {
+ if (fdata->order[i] == value) {
+ fdata->order[i] = NULL;
+ // leave room for undefined values
+ if (after_undefined)
+ i += fdata->length - fdata->defined_values - 1;
+ return swfdec_as_integer_to_string (object->context, i);
+ }
+ if (fdata->order[i] == &fdata->undefined)
+ after_undefined = TRUE;
+ }
+
+ g_assert_not_reached ();
+ return NULL;
+}
+
+// fills fdata->object_new array using indexes based on the fdata->order
+static gboolean
+swfdec_as_array_foreach_sort_indexedarray (SwfdecAsObject *object,
+ const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
+{
+ ForeachSortData *fdata = data;
+ SwfdecAsValue val;
+ const char *var;
+ gint32 idx, i;
+ gboolean after_undefined = FALSE;
+
+ idx = swfdec_as_array_to_index (variable);
+ if (idx == -1 || idx >= fdata->length)
+ return TRUE;
+
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (value))
+ return TRUE;
+
+ for (i = 0; i < fdata->order_size; i++) {
+ if (fdata->order[i] == value) {
+ fdata->order[i] = NULL;
+ // leave room for undefined values, that are filled in afterwards
+ if (after_undefined)
+ i += fdata->length - fdata->defined_values - 1;
+ var = swfdec_as_integer_to_string (object->context, i);
+ SWFDEC_AS_VALUE_SET_INT (&val, idx);
+ swfdec_as_object_set_variable (fdata->object_new, var, &val);
+ return TRUE;
+ }
+ if (fdata->order[i] == &fdata->undefined)
+ after_undefined = TRUE;
+ }
+
+ g_assert_not_reached ();
+ return FALSE;
+}
+
+// sets undefined values in the fdata->object_new array to indexes of undefined
+// values in the object array
+static void
+swfdec_as_array_sort_set_undefined_indexedarray (SwfdecAsObject *object,
+ ForeachSortData *fdata)
+{
+ SwfdecAsValue val;
+ const char *var;
+ gint32 idx, i, length, num;
+
+ for (idx = 0; idx < fdata->order_size; idx++) {
+ if (fdata->order[idx] == &fdata->undefined)
+ break;
+ }
+
+ num = 0;
+ length = swfdec_as_array_length (object);
+ for (i = 0; i < length - fdata->defined_values; i++) {
+ do {
+ var = swfdec_as_integer_to_string (object->context, num);
+ num++;
+ } while (swfdec_as_object_get_variable (object, var, &val) &&
+ !SWFDEC_AS_VALUE_IS_UNDEFINED (&val));
+ var = swfdec_as_integer_to_string (fdata->object_new->context, idx + i);
+ SWFDEC_AS_VALUE_SET_INT (&val, num - 1);
+ swfdec_as_object_set_variable (fdata->object_new, var, &val);
+ }
+}
+
+// tests if any value in the array is equal to a undefined value
+// (in the sense that sorting compare function returns 0)
+// used by uniquesort when there is exactly one undefined value in the array
+static gboolean
+swfdec_as_array_foreach_sort_compare_undefined (SwfdecAsObject *object,
+ const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
+{
+ ForeachSortData *fdata = data;
+ gint32 idx;
+
+ idx = swfdec_as_array_to_index (variable);
+ if (idx == -1 || idx >= fdata->length)
+ return TRUE;
+
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (value))
+ return TRUE;
+
+ // when testing for uniquesort the custom compare function is NOT used
+ if (swfdec_as_array_sort_compare (object->context, value, &fdata->undefined,
+ fdata->options, NULL, fdata->fields) == 0)
+ return FALSE;
+
+ return TRUE;
+}
+
+// fill fdata->order and fdata->defined_values
+static gboolean
+swfdec_as_array_foreach_sort_populate (SwfdecAsObject *object,
+ const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
+{
+ ForeachSortData *fdata = data;
+ gint32 idx, i;
+ gint cval = -1;
+
+ idx = swfdec_as_array_to_index (variable);
+ if (idx == -1 || idx >= fdata->length)
+ return TRUE;
+
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (value))
+ return TRUE;
+
+ fdata->defined_values++;
+
+ // find the position for this value
+ for (i = 0; i < fdata->order_size; i++)
+ {
+ if (fdata->order[i] == NULL ||
+ (cval = swfdec_as_array_sort_compare (object->context, value,
+ fdata->order[i], fdata->options, fdata->compare_custom_func,
+ fdata->fields)) <= 0)
+ {
+ SwfdecAsValue *tmp2, *tmp;
+
+ // if we are doing uniquesort, see if this value is the same as some
+ // earlier value
+ if (fdata->options & ARRAY_SORT_OPTION_UNIQUESORT &&
+ fdata->order[i] != NULL && fdata->order[i] != &fdata->undefined) {
+ // when using custom function, uniquesort is still based on the
+ // equality given by the normal method, not the custom function
+ if (fdata->compare_custom_func != NULL) {
+ if (swfdec_as_array_sort_compare (object->context, value,
+ fdata->order[i], fdata->options, NULL, fdata->fields) == 0) {
+ return FALSE;
+ }
+ } else {
+ if (cval == 0)
+ return FALSE;
+ }
+ }
+
+ // move rest of the values forward
+ tmp = fdata->order[i];
+ fdata->order[i] = value;
+ while (tmp != NULL && ++i < fdata->order_size) {
+ tmp2 = fdata->order[i];
+ fdata->order[i] = tmp;
+ tmp = tmp2;
+ }
+ return TRUE;
+ }
+ }
+
+ g_assert_not_reached ();
+ return FALSE;
+}
+
+static void
+swfdec_as_array_do_sort (SwfdecAsObject *object, gint32 options,
+ SwfdecAsFunction *custom_compare_func, const char **fields,
+ SwfdecAsValue *ret)
+{
+ ForeachSortData fdata;
+
+ // init foreach data
+ fdata.length = swfdec_as_array_length (object);
+ // FIXME: limit based on the actual amount of properties?
+ fdata.order_size = fdata.length + 1;
+ fdata.order = g_new0 (SwfdecAsValue *, fdata.order_size);
+ SWFDEC_AS_VALUE_SET_UNDEFINED (&fdata.undefined);
+ fdata.order[0] = &fdata.undefined;
+ fdata.defined_values = 0;
+ fdata.options = options;
+ fdata.compare_custom_func = custom_compare_func;
+ fdata.fields = fields;
+
+ // generate fdata.order which points to the values
+ if (!swfdec_as_object_foreach (object, swfdec_as_array_foreach_sort_populate,
+ &fdata))
+ {
+ // uniquesort failed
+ SWFDEC_AS_VALUE_SET_INT (ret, 0);
+ g_free (fdata.order);
+ return;
+ }
+
+ if (fdata.options & ARRAY_SORT_OPTION_UNIQUESORT &&
+ fdata.defined_values + 1 < fdata.length)
+ {
+ // uniquesort fails, because we have more than one undefined value
+ SWFDEC_AS_VALUE_SET_INT (ret, 0);
+ g_free (fdata.order);
+ return;
+ }
+
+ if (fdata.options & ARRAY_SORT_OPTION_UNIQUESORT &&
+ fdata.defined_values < fdata.length)
+ {
+ // uniquesort used, and we have exactly one undefined value test if
+ // anything equals to that
+ if (!swfdec_as_object_foreach (object,
+ swfdec_as_array_foreach_sort_compare_undefined, &fdata))
+ {
+ SWFDEC_AS_VALUE_SET_INT (ret, 0);
+ g_free (fdata.order);
+ return;
+ }
+ }
+
+ if (fdata.options & ARRAY_SORT_OPTION_RETURNINDEXEDARRAY) {
+ // make a new array and fill it with numbers based on the order
+ fdata.object_new = swfdec_as_array_new (object->context);
+ if (fdata.object_new != NULL) {
+ swfdec_as_object_foreach (object,
+ swfdec_as_array_foreach_sort_indexedarray, &fdata);
+ // we have values that have been set now, fill in the undefined values
+ swfdec_as_array_sort_set_undefined_indexedarray (object, &fdata);
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, fdata.object_new);
+ }
+ } else {
+ // rename properties based on the new order
+ swfdec_as_object_foreach_rename (object,
+ swfdec_as_array_foreach_sort_rename, &fdata);
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
+ }
+
+ g_free (fdata.order);
+}
+
+SWFDEC_AS_NATIVE (252, 10, swfdec_as_array_sort)
+void
+swfdec_as_array_sort (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+ SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ guint pos;
+ gint32 options;
+ SwfdecAsFunction *custom_compare_func;
+
+ if (object == NULL || SWFDEC_IS_MOVIE (object))
+ return;
+
+ pos = 0;
+ if (argc > 0 && !SWFDEC_AS_VALUE_IS_NUMBER (&argv[0])) {
+ SwfdecAsFunction *fun;
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]) ||
+ !SWFDEC_IS_AS_FUNCTION (
+ fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&argv[0])))
+ return;
+ custom_compare_func = fun;
+ pos++;
+ } else {
+ custom_compare_func = NULL;
+ }
+
+ if (argc > pos) {
+ options = swfdec_as_value_to_integer (cx, &argv[pos]);
+ } else {
+ options = 0;
+ }
+
+ swfdec_as_array_do_sort (object, options, custom_compare_func, NULL, ret);
+}
+
+SWFDEC_AS_NATIVE (252, 12, swfdec_as_array_sortOn)
+void
+swfdec_as_array_sortOn (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char **fields;
+ gint32 options;
+
+ if (object == NULL || SWFDEC_IS_MOVIE (object))
+ return;
+
+ if (argc < 1)
+ return;
+
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[0])) {
+ gint32 length, i;
+ SwfdecAsValue val;
+ SwfdecAsObject *array;
+
+ array = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
+ if (!SWFDEC_IS_AS_ARRAY (array)) {
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
+ return;
+ }
+ length = swfdec_as_array_get_length (SWFDEC_AS_ARRAY (array));
+ if (length <= 0) {
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
+ return;
+ }
+ fields = g_malloc (sizeof (const char *) * (length + 1));
+ for (i = 0; i < length; i++) {
+ swfdec_as_array_get_value (SWFDEC_AS_ARRAY (array), i, &val);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&val) &&
+ SWFDEC_IS_AS_STRING (SWFDEC_AS_VALUE_GET_OBJECT (&val))) {
+ fields[i] =
+ SWFDEC_AS_STRING (SWFDEC_AS_VALUE_GET_OBJECT (&val))->string;
+ } else {
+ fields[i] = swfdec_as_value_to_string (cx, &val);
+ }
+ }
+ fields[i] = NULL;
+ } else {
+ fields = g_malloc (sizeof (const char *) * 2);
+ fields[0] = swfdec_as_value_to_string (cx, &argv[0]);
+ fields[1] = NULL;
+ }
+
+ if (argc > 1) {
+ options = swfdec_as_value_to_integer (cx, &argv[1]);
+ } else {
+ options = 0;
+ }
+
+ swfdec_as_array_do_sort (object, options, NULL, fields, ret);
+
+ g_free (fields);
+}
+
+// Constructor
+
+SWFDEC_AS_CONSTRUCTOR (252, 0, swfdec_as_array_construct, swfdec_as_array_get_type)
+void
+swfdec_as_array_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecAsArray *array;
+
+ if (!cx->frame->construct) {
+ SwfdecAsValue val;
+ if (!swfdec_as_context_use_mem (cx, sizeof (SwfdecAsArray)))
+ return;
+ object = g_object_new (SWFDEC_TYPE_AS_ARRAY, NULL);
+ swfdec_as_object_add (object, cx, sizeof (SwfdecAsArray));
+ swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_Array, &val);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
+ swfdec_as_object_set_constructor (object,
+ SWFDEC_AS_VALUE_GET_OBJECT (&val));
+ } else {
+ SWFDEC_INFO ("\"Array\" is not an object");
+ }
+ }
+
+ array = SWFDEC_AS_ARRAY (object);
+ if (argc == 1 && SWFDEC_AS_VALUE_IS_NUMBER (&argv[0])) {
+ int l = swfdec_as_value_to_integer (cx, &argv[0]);
+ swfdec_as_array_set_length (array, l < 0 ? 0 : l);
+ } else if (argc > 0) {
+ swfdec_as_array_append (array, argc, argv);
+ } else {
+ swfdec_as_array_set_length (array, 0);
+ }
+
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
+}
diff --git a/swfdec/swfdec_as_array.h b/swfdec/swfdec_as_array.h
new file mode 100644
index 0000000..4c23a7f
--- /dev/null
+++ b/swfdec/swfdec_as_array.h
@@ -0,0 +1,84 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_ARRAY_H_
+#define _SWFDEC_AS_ARRAY_H_
+
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_as_types.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecAsArrayClass SwfdecAsArrayClass;
+
+#define SWFDEC_TYPE_AS_ARRAY (swfdec_as_array_get_type())
+#define SWFDEC_IS_AS_ARRAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_ARRAY))
+#define SWFDEC_IS_AS_ARRAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_ARRAY))
+#define SWFDEC_AS_ARRAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_ARRAY, SwfdecAsArray))
+#define SWFDEC_AS_ARRAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_ARRAY, SwfdecAsArrayClass))
+#define SWFDEC_AS_ARRAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_ARRAY, SwfdecAsArrayClass))
+
+struct _SwfdecAsArray {
+ /*< private >*/
+ SwfdecAsObject object;
+};
+
+struct _SwfdecAsArrayClass {
+ SwfdecAsObjectClass object_class;
+};
+
+GType swfdec_as_array_get_type (void);
+
+SwfdecAsObject *swfdec_as_array_new (SwfdecAsContext * context);
+
+#define swfdec_as_array_push(array,value) \
+ swfdec_as_array_append_with_flags ((array), 1, (value), 0)
+#define swfdec_as_array_push_with_flags(array,value,flags) \
+ swfdec_as_array_append_with_flags ((array), 1, (value), (flags))
+#define swfdec_as_array_append(array,n,values) \
+ swfdec_as_array_append_with_flags ((array), (n), (values), 0)
+void swfdec_as_array_append_with_flags (SwfdecAsArray * array,
+ guint n,
+ const SwfdecAsValue * values,
+ SwfdecAsVariableFlag flags);
+void swfdec_as_array_insert (SwfdecAsArray * array,
+ gint32 idx,
+ SwfdecAsValue * value);
+#define swfdec_as_array_insert(array,idx,value) \
+ swfdec_as_array_insert_with_flags ((array), (idx), (value), 0)
+void swfdec_as_array_insert_with_flags (SwfdecAsArray * array,
+ gint32 idx,
+ const SwfdecAsValue * value,
+ SwfdecAsVariableFlag flags);
+gint32 swfdec_as_array_get_length (SwfdecAsArray * array);
+void swfdec_as_array_set_length (SwfdecAsArray * array,
+ gint32 length);
+void swfdec_as_array_get_value (SwfdecAsArray * array,
+ gint32 idx,
+ SwfdecAsValue * value);
+void swfdec_as_array_set_value (SwfdecAsArray * array,
+ gint32 idx,
+ SwfdecAsValue * value);
+void swfdec_as_array_remove (SwfdecAsArray * array,
+ gint32 idx);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_as_boolean.c b/swfdec/swfdec_as_boolean.c
new file mode 100644
index 0000000..b3d81dd
--- /dev/null
+++ b/swfdec/swfdec_as_boolean.c
@@ -0,0 +1,103 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+
+#include "swfdec_as_boolean.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+
+G_DEFINE_TYPE (SwfdecAsBoolean, swfdec_as_boolean, SWFDEC_TYPE_AS_OBJECT)
+
+static void
+swfdec_as_boolean_class_init (SwfdecAsBooleanClass *klass)
+{
+}
+
+static void
+swfdec_as_boolean_init (SwfdecAsBoolean *boolean)
+{
+}
+
+/*** AS CODE ***/
+
+SWFDEC_AS_CONSTRUCTOR (107, 2, swfdec_as_boolean_construct, swfdec_as_boolean_get_type)
+void
+swfdec_as_boolean_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ gboolean b;
+
+ if (argc > 0) {
+ b = swfdec_as_value_to_boolean (object->context, &argv[0]);
+ } else {
+ b = FALSE;
+ }
+
+ if (swfdec_as_context_is_constructing (cx)) {
+ SWFDEC_AS_BOOLEAN (object)->boolean = b;
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
+ } else {
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, b);
+ }
+}
+
+SWFDEC_AS_NATIVE (107, 1, swfdec_as_boolean_toString)
+void
+swfdec_as_boolean_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecAsBoolean *b;
+
+ if (!SWFDEC_IS_AS_BOOLEAN (object))
+ return;
+ b = SWFDEC_AS_BOOLEAN (object);
+
+ SWFDEC_AS_VALUE_SET_STRING (ret, b->boolean ? SWFDEC_AS_STR_true : SWFDEC_AS_STR_false);
+}
+
+SWFDEC_AS_NATIVE (107, 0, swfdec_as_boolean_valueOf)
+void
+swfdec_as_boolean_valueOf (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecAsBoolean *b;
+
+ if (!SWFDEC_IS_AS_BOOLEAN (object))
+ return;
+ b = SWFDEC_AS_BOOLEAN (object);
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, b->boolean);
+}
+
+// only available as ASnative
+SWFDEC_AS_NATIVE (3, 2, swfdec_as_boolean_old_constructor)
+void
+swfdec_as_boolean_old_constructor (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("old 'Boolean' function (only available as ASnative)");
+}
diff --git a/swfdec/swfdec_as_boolean.h b/swfdec/swfdec_as_boolean.h
new file mode 100644
index 0000000..723f076
--- /dev/null
+++ b/swfdec/swfdec_as_boolean.h
@@ -0,0 +1,52 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_BOOLEAN_H_
+#define _SWFDEC_AS_BOOLEAN_H_
+
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_as_types.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecAsBoolean SwfdecAsBoolean;
+typedef struct _SwfdecAsBooleanClass SwfdecAsBooleanClass;
+
+#define SWFDEC_TYPE_AS_BOOLEAN (swfdec_as_boolean_get_type())
+#define SWFDEC_IS_AS_BOOLEAN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_BOOLEAN))
+#define SWFDEC_IS_AS_BOOLEAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_BOOLEAN))
+#define SWFDEC_AS_BOOLEAN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_BOOLEAN, SwfdecAsBoolean))
+#define SWFDEC_AS_BOOLEAN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_BOOLEAN, SwfdecAsBooleanClass))
+#define SWFDEC_AS_BOOLEAN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_BOOLEAN, SwfdecAsBooleanClass))
+
+struct _SwfdecAsBoolean {
+ SwfdecAsObject object;
+
+ gboolean boolean; /* boolean represented by this boolean object */
+};
+
+struct _SwfdecAsBooleanClass {
+ SwfdecAsObjectClass object_class;
+};
+
+GType swfdec_as_boolean_get_type (void);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_as_context.c b/swfdec/swfdec_as_context.c
new file mode 100644
index 0000000..ccce123
--- /dev/null
+++ b/swfdec/swfdec_as_context.c
@@ -0,0 +1,1461 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+#include <string.h>
+#include <stdlib.h>
+#include "swfdec_as_context.h"
+#include "swfdec_as_array.h"
+#include "swfdec_as_frame_internal.h"
+#include "swfdec_as_function.h"
+#include "swfdec_as_initialize.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_interpret.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_as_object.h"
+#include "swfdec_as_stack.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_as_types.h"
+#include "swfdec_debug.h"
+#include "swfdec_internal.h" /* for swfdec_player_preinit_global() */
+#include "swfdec_script.h"
+
+/*** GARBAGE COLLECTION DOCS ***/
+
+#define SWFDEC_AS_GC_MARK (1 << 0) /* only valid during GC */
+#define SWFDEC_AS_GC_ROOT (1 << 1) /* for objects: rooted, for strings: static */
+
+/**
+ * SECTION:Internals
+ * @title: Internals and garbage collection
+ * @short_description: understanding internals such as garbage collection
+ * @see_also: #SwfdecAsContext
+ *
+ * This section deals with the internals of the Swfdec Actionscript engine. You
+ * should probably read this first when trying to write code with it. If you're
+ * just trying to use Swfdec for creating Flash content, you can probably skip
+ * this section.
+ *
+ * First, I'd like to note that the Swfdec script engine has to be modeled very
+ * closely after the existing Flash players. So if there are some behaviours
+ * that seem stupid at first sight, it might very well be that it was chosen for
+ * a very particular reason. Now on to the features.
+ *
+ * The Swfdec script engine tries to imitate Actionscript as good as possible.
+ * Actionscript is similar to Javascript, but not equal. Depending on the
+ * version of the script executed it might be more or less similar. An important
+ * example is that Flash in versions up to 6 did case-insensitive variable
+ * lookups.
+ *
+ * The script engine starts its life when it is initialized via
+ * swfdec_as_context_startup (). At that point, the basic objects are created.
+ * After this function has been called, you can start executing code. All code
+ * execution happens by creating a new #SwfdecAsFrame and then calling
+ * swfdec_as_context_run() to execute it. This function is the single entry
+ * point for code execution. Convenience functions exist that make executing
+ * code easy, most notably swfdec_as_object_run() and
+ * swfdec_as_object_call().
+ *
+ * It is also easily possible to extend the environment by adding new objects.
+ * In fact, without doing so, the environment is pretty bare as it just contains
+ * the basic Math, String, Number, Array, Date and Boolean objects. This is done
+ * by adding #SwfdecAsNative functions to the environment. The easy way
+ * to do this is via swfdec_as_object_add_function().
+ *
+ * The Swfdec script engine is dynamically typed and knows about different types
+ * of values. See #SwfdecAsValue for the different values. Memory management is
+ * done using a mark and sweep garbage collector. You can initiate a garbage
+ * collection cycle by calling swfdec_as_context_gc() or
+ * swfdec_as_context_maybe_gc(). You should do this regularly to avoid excessive
+ * memory use. The #SwfdecAsContext will then collect the objects and strings it
+ * is keeping track of. If you want to use an object or string in the script
+ * engine, you'll have to add it first via swfdec_as_object_add() or
+ * swfdec_as_context_get_string() and swfdec_as_context_give_string(),
+ * respectively.
+ *
+ * Garbage-collected strings are special in Swfdec in that they are unique. This
+ * means the same string exists exactly once. Because of this you can do
+ * equality comparisons using == instead of strcmp. It also means that if you
+ * forget to add a string to the context before using it, your app will most
+ * likely not work, since the string will not compare equal to any other string.
+ *
+ * When a garbage collection cycle happens, all reachable objects and strings
+ * are marked and all unreachable ones are freed. This is done by calling the
+ * context class's mark function which will mark all reachable objects. This is
+ * usually called the "root set". For any reachable object, the object's mark
+ * function is called so that the object in turn can mark all objects it can
+ * reach itself. Marking is done via functions described below.
+ */
+
+/*** GTK-DOC ***/
+
+/**
+ * SECTION:SwfdecAsContext
+ * @title: SwfdecAsContext
+ * @short_description: the main script engine context
+ * @see_also: SwfdecPlayer
+ *
+ * A #SwfdecAsContext provides the main execution environment for Actionscript
+ * execution. It provides the objects typically available in ECMAScript and
+ * manages script execution, garbage collection etc. #SwfdecPlayer is a
+ * subclass of the context that implements Flash specific objects on top of it.
+ * However, it is possible to use the context for completely different functions
+ * where a sandboxed scripting environment is needed. An example is the Swfdec
+ * debugger.
+ * <note>The Actionscript engine is similar, but not equal to Javascript. It
+ * is not very different, but it is different.</note>
+ */
+
+/**
+ * SwfdecAsContext
+ *
+ * This is the main object ued to hold the state of a script engine. All members
+ * are private and should not be accessed.
+ *
+ * Subclassing this structure to get scripting support in your own appliation is
+ * encouraged.
+ */
+
+/**
+ * SwfdecAsContextState
+ * @SWFDEC_AS_CONTEXT_NEW: the context is not yet initialized,
+ * swfdec_as_context_startup() needs to be called.
+ * @SWFDEC_AS_CONTEXT_RUNNING: the context is running normally
+ * @SWFDEC_AS_CONTEXT_INTERRUPTED: the context has been interrupted by a
+ * debugger
+ * @SWFDEC_AS_CONTEXT_ABORTED: the context has aborted execution due to a
+ * fatal error
+ *
+ * The state of the context describes what operations are possible on the context.
+ * It will be in the state @SWFDEC_AS_CONTEXT_STATE_RUNNING almost all the time. If
+ * it is in the state @SWFDEC_AS_CONTEXT_STATE_ABORTED, it will not work anymore and
+ * every operation on it will instantly fail.
+ */
+
+/*** RUNNING STATE ***/
+
+/**
+ * swfdec_as_context_abort:
+ * @context: a #SwfdecAsContext
+ * @reason: a string describing why execution was aborted
+ *
+ * Aborts script execution in @context. Call this functon if the script engine
+ * encountered a fatal error and cannot continue. A possible reason for this is
+ * an out-of-memory condition.
+ **/
+void
+swfdec_as_context_abort (SwfdecAsContext *context, const char *reason)
+{
+ g_return_if_fail (context);
+
+ SWFDEC_ERROR ("%s", reason);
+ if (context->state != SWFDEC_AS_CONTEXT_ABORTED) {
+ context->state = SWFDEC_AS_CONTEXT_ABORTED;
+ g_object_notify (G_OBJECT (context), "aborted");
+ }
+}
+
+/*** MEMORY MANAGEMENT ***/
+
+/**
+ * swfdec_as_context_use_mem:
+ * @context: a #SwfdecAsContext
+ * @bytes: number of bytes to use
+ *
+ * Registers @bytes additional bytes as in use by the @context. This function
+ * keeps track of the memory that script code consumes. If too many memory is
+ * in use, this function may decide to stop the script engine with an out of
+ * memory error.
+ *
+ * Returns: %TRUE if the memory could be allocated. %FALSE on OOM.
+ **/
+gboolean
+swfdec_as_context_use_mem (SwfdecAsContext *context, gsize bytes)
+{
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), FALSE);
+ g_return_val_if_fail (bytes > 0, FALSE);
+
+ if (context->state == SWFDEC_AS_CONTEXT_ABORTED)
+ return FALSE;
+
+ context->memory += bytes;
+ context->memory_since_gc += bytes;
+ SWFDEC_LOG ("+%4"G_GSIZE_FORMAT" bytes, total %7"G_GSIZE_FORMAT" (%7"G_GSIZE_FORMAT" since GC)",
+ bytes, context->memory, context->memory_since_gc);
+ /* FIXME: Don't foget to abort on OOM */
+ return TRUE;
+}
+
+/**
+ * swfdec_as_context_unuse_mem:
+ * @context: a #SwfdecAsContext
+ * @bytes: number of bytes to release
+ *
+ * Releases a number of bytes previously allocated using
+ * swfdec_as_context_use_mem(). See that function for details.
+ **/
+void
+swfdec_as_context_unuse_mem (SwfdecAsContext *context, gsize bytes)
+{
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
+ g_return_if_fail (bytes > 0);
+ g_return_if_fail (context->memory >= bytes);
+
+ context->memory -= bytes;
+ SWFDEC_LOG ("-%4"G_GSIZE_FORMAT" bytes, total %7"G_GSIZE_FORMAT" (%7"G_GSIZE_FORMAT" since GC)",
+ bytes, context->memory, context->memory_since_gc);
+}
+
+/*** GC ***/
+
+static gboolean
+swfdec_as_context_remove_strings (gpointer key, gpointer value, gpointer data)
+{
+ SwfdecAsContext *context = data;
+ char *string;
+
+ string = (char *) value;
+ /* it doesn't matter that rooted strings aren't destroyed, they're constant */
+ if (string[0] & SWFDEC_AS_GC_ROOT) {
+ SWFDEC_LOG ("rooted: %s", (char *) key);
+ return FALSE;
+ } else if (string[0] & SWFDEC_AS_GC_MARK) {
+ SWFDEC_LOG ("marked: %s", (char *) key);
+ string[0] &= ~SWFDEC_AS_GC_MARK;
+ return FALSE;
+ } else {
+ gsize len;
+ SWFDEC_LOG ("deleted: %s", (char *) key);
+ len = (strlen ((char *) key) + 2);
+ swfdec_as_context_unuse_mem (context, len);
+ g_slice_free1 (len, value);
+ return TRUE;
+ }
+}
+
+static gboolean
+swfdec_as_context_remove_objects (gpointer key, gpointer value, gpointer debugger)
+{
+ SwfdecAsObject *object;
+
+ object = key;
+ /* we only check for mark here, not root, since this works on destroy, too */
+ if (object->flags & SWFDEC_AS_GC_MARK) {
+ object->flags &= ~SWFDEC_AS_GC_MARK;
+ SWFDEC_LOG ("%s: %s %p", (object->flags & SWFDEC_AS_GC_ROOT) ? "rooted" : "marked",
+ G_OBJECT_TYPE_NAME (object), object);
+ return FALSE;
+ } else {
+ SWFDEC_LOG ("deleted: %s %p", G_OBJECT_TYPE_NAME (object), object);
+ if (debugger) {
+ SwfdecAsDebuggerClass *klass = SWFDEC_AS_DEBUGGER_GET_CLASS (debugger);
+ if (klass->remove)
+ klass->remove (debugger, object->context, object);
+ }
+ swfdec_as_object_collect (object);
+ return TRUE;
+ }
+}
+
+static void
+swfdec_as_context_collect (SwfdecAsContext *context)
+{
+ SWFDEC_INFO (">> collecting garbage");
+ /* NB: This functions is called without GC from swfdec_as_context_dispose */
+ g_hash_table_foreach_remove (context->strings,
+ swfdec_as_context_remove_strings, context);
+ g_hash_table_foreach_remove (context->objects,
+ swfdec_as_context_remove_objects, context->debugger);
+ SWFDEC_INFO (">> done collecting garbage");
+}
+
+/**
+ * swfdec_as_object_mark:
+ * @object: a #SwfdecAsObject
+ *
+ * Mark @object as being in use. Calling this function is only valid during
+ * the marking phase of garbage collection.
+ **/
+void
+swfdec_as_object_mark (SwfdecAsObject *object)
+{
+ SwfdecAsObjectClass *klass;
+
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+
+ if (object->flags & SWFDEC_AS_GC_MARK)
+ return;
+ object->flags |= SWFDEC_AS_GC_MARK;
+ klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
+ g_assert (klass->mark);
+ klass->mark (object);
+}
+
+/**
+ * swfdec_as_string_mark:
+ * @string: a garbage-collected string
+ *
+ * Mark @string as being in use. Calling this function is only valid during
+ * the marking phase of garbage collection.
+ **/
+void
+swfdec_as_string_mark (const char *string)
+{
+ char *str;
+
+ g_return_if_fail (string != NULL);
+
+ str = (char *) string - 1;
+ if (*str == 0)
+ *str = SWFDEC_AS_GC_MARK;
+}
+
+/**
+ * swfdec_as_value_mark:
+ * @value: a #SwfdecAsValue
+ *
+ * Mark @value as being in use. This is just a convenience function that calls
+ * the right marking function depending on the value's type. Calling this
+ * function is only valid during the marking phase of garbage collection.
+ **/
+void
+swfdec_as_value_mark (SwfdecAsValue *value)
+{
+ g_return_if_fail (SWFDEC_IS_AS_VALUE (value));
+
+ if (SWFDEC_AS_VALUE_IS_OBJECT (value)) {
+ swfdec_as_object_mark (SWFDEC_AS_VALUE_GET_OBJECT (value));
+ } else if (SWFDEC_AS_VALUE_IS_STRING (value)) {
+ swfdec_as_string_mark (SWFDEC_AS_VALUE_GET_STRING (value));
+ }
+}
+
+static void
+swfdec_as_context_mark_roots (gpointer key, gpointer value, gpointer data)
+{
+ SwfdecAsObject *object = key;
+
+ if ((object->flags & (SWFDEC_AS_GC_MARK | SWFDEC_AS_GC_ROOT)) == SWFDEC_AS_GC_ROOT)
+ swfdec_as_object_mark (object);
+}
+
+static void
+swfdec_as_context_do_mark (SwfdecAsContext *context)
+{
+ /* This if is needed for SwfdecPlayer */
+ if (context->global) {
+ swfdec_as_object_mark (context->global);
+ swfdec_as_object_mark (context->Function);
+ swfdec_as_object_mark (context->Function_prototype);
+ swfdec_as_object_mark (context->Object);
+ swfdec_as_object_mark (context->Object_prototype);
+ }
+ if (context->exception)
+ swfdec_as_value_mark (&context->exception_value);
+ g_hash_table_foreach (context->objects, swfdec_as_context_mark_roots, NULL);
+}
+
+/**
+ * swfdec_as_context_gc:
+ * @context: a #SwfdecAsContext
+ *
+ * Calls the Swfdec Gargbage collector and reclaims any unused memory. You
+ * should call this function or swfdec_as_context_maybe_gc() regularly.
+ * <warning>Calling the GC during execution of code or initialization is not
+ * allowed.</warning>
+ **/
+void
+swfdec_as_context_gc (SwfdecAsContext *context)
+{
+ SwfdecAsContextClass *klass;
+
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
+ g_return_if_fail (context->frame == NULL);
+ g_return_if_fail (context->state == SWFDEC_AS_CONTEXT_RUNNING);
+
+ if (context->state == SWFDEC_AS_CONTEXT_ABORTED)
+ return;
+ SWFDEC_INFO ("invoking the garbage collector");
+ klass = SWFDEC_AS_CONTEXT_GET_CLASS (context);
+ g_assert (klass->mark);
+ klass->mark (context);
+ swfdec_as_context_collect (context);
+ context->memory_since_gc = 0;
+}
+
+static gboolean
+swfdec_as_context_needs_gc (SwfdecAsContext *context)
+{
+ return context->memory_since_gc >= context->memory_until_gc;
+}
+
+/**
+ * swfdec_as_context_maybe_gc:
+ * @context: a #SwfdecAsContext
+ *
+ * Calls the garbage collector if necessary. It's a good idea to call this
+ * function regularly instead of swfdec_as_context_gc() as it only does collect
+ * garage as needed. For example, #SwfdecPlayer calls this function after every
+ * frame advancement.
+ **/
+void
+swfdec_as_context_maybe_gc (SwfdecAsContext *context)
+{
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
+ g_return_if_fail (context->state == SWFDEC_AS_CONTEXT_RUNNING);
+ g_return_if_fail (context->frame == NULL);
+
+ if (swfdec_as_context_needs_gc (context))
+ swfdec_as_context_gc (context);
+}
+
+/*** SWFDEC_AS_CONTEXT ***/
+
+enum {
+ TRACE,
+ LAST_SIGNAL
+};
+
+enum {
+ PROP_0,
+ PROP_DEBUGGER,
+ PROP_RANDOM_SEED,
+ PROP_ABORTED,
+ PROP_UNTIL_GC
+};
+
+G_DEFINE_TYPE (SwfdecAsContext, swfdec_as_context, G_TYPE_OBJECT)
+static guint signals[LAST_SIGNAL] = { 0, };
+
+static void
+swfdec_as_context_get_property (GObject *object, guint param_id, GValue *value,
+ GParamSpec * pspec)
+{
+ SwfdecAsContext *context = SWFDEC_AS_CONTEXT (object);
+
+ switch (param_id) {
+ case PROP_DEBUGGER:
+ g_value_set_object (value, context->debugger);
+ break;
+ case PROP_ABORTED:
+ g_value_set_boolean (value, context->state == SWFDEC_AS_CONTEXT_ABORTED);
+ break;
+ case PROP_UNTIL_GC:
+ g_value_set_ulong (value, (gulong) context->memory_until_gc);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+swfdec_as_context_set_property (GObject *object, guint param_id, const GValue *value,
+ GParamSpec * pspec)
+{
+ SwfdecAsContext *context = SWFDEC_AS_CONTEXT (object);
+
+ switch (param_id) {
+ case PROP_DEBUGGER:
+ context->debugger = SWFDEC_AS_DEBUGGER (g_value_dup_object (value));
+ break;
+ case PROP_RANDOM_SEED:
+ g_rand_set_seed (context->rand, g_value_get_uint (value));
+ break;
+ case PROP_UNTIL_GC:
+ context->memory_until_gc = g_value_get_ulong (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+swfdec_as_context_dispose (GObject *object)
+{
+ SwfdecAsContext *context = SWFDEC_AS_CONTEXT (object);
+
+ while (context->stack)
+ swfdec_as_stack_pop_segment (context);
+ swfdec_as_context_collect (context);
+ if (context->memory != 0) {
+ g_critical ("%zu bytes of memory left over\n", context->memory);
+ }
+ g_assert (g_hash_table_size (context->objects) == 0);
+ g_hash_table_destroy (context->objects);
+ g_hash_table_destroy (context->strings);
+ g_rand_free (context->rand);
+ if (context->debugger) {
+ g_object_unref (context->debugger);
+ context->debugger = NULL;
+ }
+
+ G_OBJECT_CLASS (swfdec_as_context_parent_class)->dispose (object);
+}
+
+static void
+swfdec_as_context_class_init (SwfdecAsContextClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = swfdec_as_context_dispose;
+ object_class->get_property = swfdec_as_context_get_property;
+ object_class->set_property = swfdec_as_context_set_property;
+
+ g_object_class_install_property (object_class, PROP_DEBUGGER,
+ g_param_spec_object ("debugger", "debugger", "debugger used in this player",
+ SWFDEC_TYPE_AS_DEBUGGER, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class, PROP_RANDOM_SEED,
+ g_param_spec_uint ("random-seed", "random seed",
+ "seed used for calculating random numbers",
+ 0, G_MAXUINT32, 0, G_PARAM_WRITABLE)); /* FIXME: make this readwrite for replaying? */
+ g_object_class_install_property (object_class, PROP_ABORTED,
+ g_param_spec_boolean ("aborted", "aborted", "set when the script engine aborts due to an error",
+ FALSE, G_PARAM_READABLE));
+ g_object_class_install_property (object_class, PROP_UNTIL_GC,
+ g_param_spec_ulong ("memory-until-gc", "memory until gc",
+ "amount of bytes that need to be allocated before garbage collection triggers",
+ 0, G_MAXULONG, 8 * 1024 * 1024, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ /**
+ * SwfdecAsContext::trace:
+ * @context: the #SwfdecAsContext affected
+ * @text: the debugging string
+ *
+ * Emits a debugging string while running. The effect of calling any swfdec
+ * functions on the emitting @context is undefined.
+ */
+ signals[TRACE] = g_signal_new ("trace", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
+
+ klass->mark = swfdec_as_context_do_mark;
+}
+
+static void
+swfdec_as_context_init (SwfdecAsContext *context)
+{
+ const char *s;
+
+ context->version = G_MAXUINT;
+
+ context->strings = g_hash_table_new (g_str_hash, g_str_equal);
+ context->objects = g_hash_table_new (g_direct_hash, g_direct_equal);
+
+ for (s = swfdec_as_strings; *s == '\2'; s += strlen (s) + 1) {
+ g_hash_table_insert (context->strings, (char *) s + 1, (char *) s);
+ }
+ g_assert (*s == 0);
+ context->rand = g_rand_new ();
+ g_get_current_time (&context->start_time);
+}
+
+/*** STRINGS ***/
+
+static const char *
+swfdec_as_context_create_string (SwfdecAsContext *context, const char *string, gsize len)
+{
+ char *new;
+
+ if (!swfdec_as_context_use_mem (context, sizeof (char) * (2 + len)))
+ return SWFDEC_AS_STR_EMPTY;
+
+ new = g_slice_alloc (2 + len);
+ memcpy (&new[1], string, len);
+ new[len + 1] = 0;
+ new[0] = 0; /* GC flags */
+ g_hash_table_insert (context->strings, new + 1, new);
+
+ return new + 1;
+}
+
+/**
+ * swfdec_as_context_get_string:
+ * @context: a #SwfdecAsContext
+ * @string: a sting that is not garbage-collected
+ *
+ * Gets the garbage-collected version of @string. You need to call this function
+ * for every not garbage-collected string that you want to use in Swfdecs script
+ * interpreter.
+ *
+ * Returns: the garbage-collected version of @string
+ **/
+const char *
+swfdec_as_context_get_string (SwfdecAsContext *context, const char *string)
+{
+ const char *ret;
+ gsize len;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
+ g_return_val_if_fail (string != NULL, NULL);
+
+ if (g_hash_table_lookup_extended (context->strings, string, (gpointer) &ret, NULL))
+ return ret;
+
+ len = strlen (string);
+ return swfdec_as_context_create_string (context, string, len);
+}
+
+/**
+ * swfdec_as_context_give_string:
+ * @context: a #SwfdecAsContext
+ * @string: string to make refcounted
+ *
+ * Takes ownership of @string and returns a refcounted version of the same
+ * string. This function is the same as swfdec_as_context_get_string(), but
+ * takes ownership of @string.
+ *
+ * Returns: A refcounted string
+ **/
+const char *
+swfdec_as_context_give_string (SwfdecAsContext *context, char *string)
+{
+ const char *ret;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
+ g_return_val_if_fail (string != NULL, NULL);
+
+ ret = swfdec_as_context_get_string (context, string);
+ g_free (string);
+ return ret;
+}
+
+/**
+ * swfdec_as_context_is_constructing:
+ * @context: a #SwfdecAsConstruct
+ *
+ * Determines if the contexxt is currently constructing. This information is
+ * used by various constructors to do different things when they are
+ * constructing and when they are not. The Boolean, Number and String functions
+ * for example setup the newly constructed objects when constructing but only
+ * cast the provided argument when being called.
+ *
+ * Returns: %TRUE if the currently executing frame is a constructor
+ **/
+gboolean
+swfdec_as_context_is_constructing (SwfdecAsContext *context)
+{
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), FALSE);
+
+ return context->frame && context->frame->construct;
+}
+
+/**
+ * swfdec_as_context_get_frame:
+ * @context: a #SwfdecAsContext
+ *
+ * This is a debugging function. It gets the topmost stack frame that is
+ * currently executing. If no function is executing, %NULL is returned. You can
+ * easily get a backtrace with code like this:
+ * |[for (frame = swfdec_as_context_get_frame (context); frame != NULL;
+ * frame = swfdec_as_frame_get_next (frame)) {
+ * char *s = swfdec_as_object_get_debug (SWFDEC_AS_OBJECT (frame));
+ * g_print ("%s\n", s);
+ * g_free (s);
+ * }]|
+ *
+ * Returns: the currently executing frame or %NULL if none
+ **/
+SwfdecAsFrame *
+swfdec_as_context_get_frame (SwfdecAsContext *context)
+{
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
+
+ return context->frame;
+}
+
+/**
+ * swfdec_as_context_throw:
+ * @context: a #SwfdecAsContext
+ * @value: a #SwfdecAsValue to be thrown
+ *
+ * Throws a new exception in the @context using the given @value. This function
+ * can only be called if the @context is not already throwing an exception.
+ **/
+void
+swfdec_as_context_throw (SwfdecAsContext *context, const SwfdecAsValue *value)
+{
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
+ g_return_if_fail (SWFDEC_IS_AS_VALUE (value));
+ g_return_if_fail (!context->exception);
+
+ context->exception = TRUE;
+ context->exception_value = *value;
+}
+
+/**
+ * swfdec_as_context_catch:
+ * @context: a #SwfdecAsContext
+ * @value: a #SwfdecAsValue to be thrown
+ *
+ * Removes the currently thrown exception from @context and sets @value to the
+ * thrown value
+ *
+ * Returns: %TRUE if an exception was catched, %FALSE otherwise
+ **/
+gboolean
+swfdec_as_context_catch (SwfdecAsContext *context, SwfdecAsValue *value)
+{
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), FALSE);
+
+ if (!context->exception)
+ return FALSE;
+
+ if (value != NULL)
+ *value = context->exception_value;
+
+ context->exception = FALSE;
+ SWFDEC_AS_VALUE_SET_UNDEFINED (&context->exception_value);
+
+ return TRUE;
+}
+
+/**
+ * swfdec_as_context_get_time:
+ * @context: a #SwfdecAsContext
+ * @tv: a #GTimeVal to be set to the context's time
+ *
+ * This function queries the time to be used inside this context. By default,
+ * this is the same as g_get_current_time(), but it may be overwriten to allow
+ * things such as slower or faster playback.
+ **/
+void
+swfdec_as_context_get_time (SwfdecAsContext *context, GTimeVal *tv)
+{
+ SwfdecAsContextClass *klass;
+
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
+ g_return_if_fail (tv != NULL);
+
+ klass = SWFDEC_AS_CONTEXT_GET_CLASS (context);
+ if (klass->get_time)
+ klass->get_time (context, tv);
+ else
+ g_get_current_time (tv);
+}
+
+/**
+ * swfdec_as_context_run:
+ * @context: a #SwfdecAsContext
+ *
+ * Continues running the script engine. Executing code in this engine works
+ * in 2 steps: First, you push the frame to be executed onto the stack, then
+ * you call this function to execute it. So this function is the single entry
+ * point to script execution. This might be helpful when debugging your
+ * application.
+ * <note>A lot of convenience functions like swfdec_as_object_run() call this
+ * function automatically.</note>
+ **/
+void
+swfdec_as_context_run (SwfdecAsContext *context)
+{
+ SwfdecAsFrame *frame, *last_frame;
+ SwfdecScript *script;
+ const SwfdecActionSpec *spec;
+ const guint8 *startpc, *pc, *endpc, *nextpc, *exitpc;
+#ifndef G_DISABLE_ASSERT
+ SwfdecAsValue *check;
+#endif
+ guint action, len;
+ const guint8 *data;
+ guint original_version;
+ void (* step) (SwfdecAsDebugger *debugger, SwfdecAsContext *context);
+ gboolean check_block; /* some opcodes avoid a scope check */
+
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
+
+ if (context->frame == NULL || context->state == SWFDEC_AS_CONTEXT_ABORTED)
+ return;
+
+ if (context->debugger) {
+ SwfdecAsDebuggerClass *klass = SWFDEC_AS_DEBUGGER_GET_CLASS (context->debugger);
+ step = klass->step;
+ } else {
+ step = NULL;
+ }
+
+ last_frame = context->last_frame;
+ context->last_frame = context->frame->next;
+ original_version = context->version;
+start:
+ g_return_if_fail (context->global); /* check here because of swfdec_sandbox_(un)use() */
+ if (!swfdec_as_context_check_continue (context))
+ goto error;
+ /* setup data */
+ frame = context->frame;
+ if (frame == context->last_frame)
+ goto out;
+ if (context->call_depth > 256) {
+ /* we've exceeded our maximum call depth, throw an error and abort */
+ swfdec_as_context_abort (context, "Stack overflow");
+ goto error;
+ }
+ if (SWFDEC_IS_AS_NATIVE_FUNCTION (frame->function)) {
+ SwfdecAsNativeFunction *native = SWFDEC_AS_NATIVE_FUNCTION (frame->function);
+ SwfdecAsValue rval = { 0, };
+ if (frame->argc >= native->min_args &&
+ (native->type == 0 ||
+ g_type_is_a (G_OBJECT_TYPE (frame->thisp), native->type))) {
+ SwfdecAsValue *argv;
+ /* accumulate argv */
+ if (frame->argc == 0 || frame->argv != NULL) {
+ /* FIXME FIXME FIXME: no casting here please! */
+ argv = (SwfdecAsValue *) frame->argv;
+ } else {
+ SwfdecAsStack *stack;
+ SwfdecAsValue *cur;
+ guint i;
+ if (frame->argc > 128) {
+ SWFDEC_FIXME ("allow calling native functions with more than 128 args (this one has %u)",
+ frame->argc);
+ frame->argc = 128;
+ }
+ argv = g_new (SwfdecAsValue, frame->argc);
+ stack = context->stack;
+ cur = context->cur;
+ for (i = 0; i < frame->argc; i++) {
+ if (cur <= &stack->elements[0]) {
+ stack = stack->next;
+ cur = &stack->elements[stack->used_elements];
+ }
+ cur--;
+ argv[i] = *cur;
+ }
+ }
+ native->native (context, frame->thisp, frame->argc,
+ argv, &rval);
+ if (argv != frame->argv)
+ g_free (argv);
+ }
+ swfdec_as_frame_return (frame, &rval);
+ goto start;
+ }
+ g_assert (frame->script);
+ g_assert (frame->target);
+ script = frame->script;
+ context->version = script->version;
+ startpc = script->buffer->data;
+ endpc = startpc + script->buffer->length;
+ exitpc = script->exit;
+ pc = frame->pc;
+ check_block = TRUE;
+
+ while (context->state < SWFDEC_AS_CONTEXT_ABORTED) {
+ if (context->exception) {
+ swfdec_as_frame_handle_exception (frame);
+ if (frame != context->frame)
+ goto start;
+ pc = frame->pc;
+ continue;
+ }
+ if (pc == exitpc) {
+ swfdec_as_frame_return (frame, NULL);
+ goto start;
+ }
+ if (pc < startpc || pc >= endpc) {
+ SWFDEC_ERROR ("pc %p not in valid range [%p, %p) anymore", pc, startpc, endpc);
+ goto error;
+ }
+ if (check_block && (pc < frame->block_start || pc >= frame->block_end)) {
+ SWFDEC_LOG ("code exited block");
+ swfdec_as_frame_pop_block (frame);
+ pc = frame->pc;
+ if (frame != context->frame)
+ goto start;
+ }
+
+ /* decode next action */
+ action = *pc;
+ if (action == 0) {
+ swfdec_as_frame_return (frame, NULL);
+ goto start;
+ }
+ /* invoke debugger if there is one */
+ if (step) {
+ frame->pc = pc;
+ (* step) (context->debugger, context);
+ if (frame != context->frame ||
+ frame->pc != pc) {
+ goto start;
+ }
+ }
+ /* prepare action */
+ spec = swfdec_as_actions + action;
+ if (action & 0x80) {
+ if (pc + 2 >= endpc) {
+ SWFDEC_ERROR ("action %u length value out of range", action);
+ goto error;
+ }
+ data = pc + 3;
+ len = pc[1] | pc[2] << 8;
+ if (data + len > endpc) {
+ SWFDEC_ERROR ("action %u length %u out of range", action, len);
+ goto error;
+ }
+ nextpc = pc + 3 + len;
+ } else {
+ data = NULL;
+ len = 0;
+ nextpc = pc + 1;
+ }
+ /* check action is valid */
+ if (!spec->exec) {
+ SWFDEC_WARNING ("cannot interpret action %3u 0x%02X %s for version %u, skipping it", action,
+ action, spec->name ? spec->name : "Unknown", script->version);
+ frame->pc = pc = nextpc;
+ check_block = TRUE;
+ continue;
+ }
+ if (script->version < spec->version) {
+ SWFDEC_WARNING ("cannot interpret action %3u 0x%02X %s for version %u, using version %u instead",
+ action, action, spec->name ? spec->name : "Unknown", script->version, spec->version);
+ }
+ if (spec->remove > 0) {
+ if (spec->add > spec->remove)
+ swfdec_as_stack_ensure_free (context, spec->add - spec->remove);
+ swfdec_as_stack_ensure_size (context, spec->remove);
+ } else {
+ if (spec->add > 0)
+ swfdec_as_stack_ensure_free (context, spec->add);
+ }
+ if (context->state > SWFDEC_AS_CONTEXT_RUNNING) {
+ SWFDEC_WARNING ("context not running anymore, aborting");
+ goto error;
+ }
+#ifndef G_DISABLE_ASSERT
+ check = (spec->add >= 0 && spec->remove >= 0) ? context->cur + spec->add - spec->remove : NULL;
+#endif
+ /* execute action */
+ spec->exec (context, action, data, len);
+ /* adapt the pc if the action did not, otherwise, leave it alone */
+ /* FIXME: do this via flag? */
+ if (frame->pc == pc) {
+ frame->pc = pc = nextpc;
+ check_block = TRUE;
+ } else {
+ if (frame->pc < pc &&
+ !swfdec_as_context_check_continue (context)) {
+ goto error;
+ }
+ pc = frame->pc;
+ check_block = FALSE;
+ }
+ if (frame == context->frame) {
+#ifndef G_DISABLE_ASSERT
+ if (check != NULL && check != context->cur) {
+ g_error ("action %s was supposed to change the stack by %d (+%d -%d), but it changed by %td",
+ spec->name, spec->add - spec->remove, spec->add, spec->remove,
+ context->cur - check + spec->add - spec->remove);
+ }
+#endif
+ } else {
+ /* someone called/returned from a function, reread variables */
+ goto start;
+ }
+ }
+
+error:
+ while (context->frame != context->last_frame)
+ swfdec_as_frame_return (context->frame, NULL);
+out:
+ context->last_frame = last_frame;
+ context->version = original_version;
+ return;
+}
+
+/*** EVAL ***/
+
+static char *
+swfdec_as_slash_to_dot (const char *slash_str)
+{
+ const char *cur = slash_str;
+ GString *str = g_string_new ("");
+
+ if (*cur == '/') {
+ g_string_append (str, "_root");
+ } else {
+ goto start;
+ }
+ while (cur && *cur == '/') {
+ cur++;
+start:
+ if (str->len > 0)
+ g_string_append_c (str, '.');
+ if (cur[0] == '.' && cur[1] == '.') {
+ g_string_append (str, "_parent");
+ cur += 2;
+ } else {
+ char *slash = strchr (cur, '/');
+ if (slash) {
+ g_string_append_len (str, cur, slash - cur);
+ cur = slash;
+ } else {
+ g_string_append (str, cur);
+ cur = NULL;
+ }
+ }
+ /* cur should now point to the slash */
+ }
+ if (cur) {
+ if (*cur != '\0')
+ goto fail;
+ }
+ SWFDEC_DEBUG ("parsed slash-notated string \"%s\" into dot notation \"%s\"",
+ slash_str, str->str);
+ return g_string_free (str, FALSE);
+
+fail:
+ SWFDEC_WARNING ("failed to parse slash-notated string \"%s\" into dot notation", slash_str);
+ g_string_free (str, TRUE);
+ return NULL;
+}
+
+static void
+swfdec_as_context_eval_get_property (SwfdecAsContext *cx,
+ SwfdecAsObject *obj, const char *name, SwfdecAsValue *ret)
+{
+ if (obj) {
+ swfdec_as_object_get_variable (obj, name, ret);
+ } else {
+ if (cx->frame) {
+ swfdec_as_frame_get_variable (cx->frame, name, ret);
+ } else {
+ SWFDEC_WARNING ("eval called without a frame");
+ swfdec_as_object_get_variable (cx->global, name, ret);
+ }
+ }
+}
+
+static void
+swfdec_as_context_eval_set_property (SwfdecAsContext *cx,
+ SwfdecAsObject *obj, const char *name, const SwfdecAsValue *ret)
+{
+ if (obj == NULL) {
+ if (cx->frame == NULL) {
+ SWFDEC_ERROR ("no frame in eval_set?");
+ return;
+ }
+ swfdec_as_frame_set_variable (cx->frame, name, ret);
+ } else {
+ swfdec_as_object_set_variable (obj, name, ret);
+ }
+}
+
+static void
+swfdec_as_context_eval_internal (SwfdecAsContext *cx, SwfdecAsObject *obj, const char *str,
+ SwfdecAsValue *val, gboolean set)
+{
+ SwfdecAsValue cur;
+ char **varlist;
+ guint i;
+
+ SWFDEC_LOG ("eval called with \"%s\" on %p", str, obj);
+ if (strchr (str, '/')) {
+ char *work = swfdec_as_slash_to_dot (str);
+ if (!work) {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (val);
+ return;
+ }
+ varlist = g_strsplit (work, ".", -1);
+ g_free (work);
+ } else {
+ varlist = g_strsplit (str, ".", -1);
+ }
+ for (i = 0; varlist[i] != NULL; i++) {
+ const char *dot = swfdec_as_context_get_string (cx, varlist[i]);
+ if (varlist[i+1] != NULL) {
+ swfdec_as_context_eval_get_property (cx, obj, dot, &cur);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&cur)) {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (&cur);
+ break;
+ }
+ obj = SWFDEC_AS_VALUE_GET_OBJECT (&cur);
+ } else {
+ if (set) {
+ swfdec_as_context_eval_set_property (cx, obj, dot, val);
+ } else {
+ swfdec_as_context_eval_get_property (cx, obj, dot, &cur);
+ }
+ goto finish;
+ }
+ }
+ if (obj == NULL) {
+ if (cx->frame)
+ obj = cx->frame->target;
+ else
+ obj = cx->global;
+ }
+ g_assert (obj != NULL);
+ SWFDEC_AS_VALUE_SET_OBJECT (&cur, obj);
+
+finish:
+ g_strfreev (varlist);
+ *val = cur;
+}
+
+/**
+ * swfdec_as_context_eval:
+ * @context: a #SwfdecAsContext
+ * @obj: #SwfdecAsObject to use as source for evaluating or NULL for the
+ * current frame's scope
+ * @str: The string to evaluate
+ * @val: location for the return value
+ *
+ * This function works like the Actionscript eval function used on @obj.
+ * It handles both slash-style and dot-style notation. If an error occured
+ * during evaluation, the return value will be the undefined value.
+ **/
+void
+swfdec_as_context_eval (SwfdecAsContext *context, SwfdecAsObject *obj, const char *str,
+ SwfdecAsValue *val)
+{
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
+ g_return_if_fail (obj == NULL || SWFDEC_IS_AS_OBJECT (obj));
+ g_return_if_fail (str != NULL);
+ g_return_if_fail (val != NULL);
+
+ swfdec_as_context_eval_internal (context, obj, str, val, FALSE);
+}
+
+/**
+ * swfdec_as_context_eval_set:
+ * @context: a #SwfdecAsContext
+ * @obj: #SwfdecAsObject to use as source for evaluating or NULL for the
+ * default object.
+ * @str: The string to evaluate
+ * @val: the value to set the variable to
+ *
+ * Sets the variable referenced by @str to @val. If @str does not reference
+ * a valid property, nothing happens.
+ **/
+void
+swfdec_as_context_eval_set (SwfdecAsContext *context, SwfdecAsObject *obj, const char *str,
+ const SwfdecAsValue *val)
+{
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
+ g_return_if_fail (obj == NULL || SWFDEC_IS_AS_OBJECT (obj));
+ g_return_if_fail (str != NULL);
+ g_return_if_fail (val != NULL);
+
+ swfdec_as_context_eval_internal (context, obj, str, (SwfdecAsValue *) val, TRUE);
+}
+
+/*** AS CODE ***/
+
+static void
+swfdec_as_context_ASSetPropFlags_set_one_flag (SwfdecAsObject *object,
+ const char *s, guint *flags)
+{
+ swfdec_as_object_unset_variable_flags (object, s, flags[1]);
+ swfdec_as_object_set_variable_flags (object, s, flags[0]);
+}
+
+static gboolean
+swfdec_as_context_ASSetPropFlags_foreach (SwfdecAsObject *object,
+ const char *s, SwfdecAsValue *val, guint cur_flags, gpointer data)
+{
+ guint *flags = data;
+
+ /* shortcut if the flags already match */
+ if (cur_flags == ((cur_flags &~ flags[1]) | flags[0]))
+ return TRUE;
+
+ swfdec_as_context_ASSetPropFlags_set_one_flag (object, s, flags);
+ return TRUE;
+}
+
+SWFDEC_AS_NATIVE (1, 0, swfdec_as_context_ASSetPropFlags)
+void
+swfdec_as_context_ASSetPropFlags (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ guint flags[2]; /* flags and mask - array so we can pass it as data pointer */
+ SwfdecAsObject *obj;
+
+ if (argc < 3)
+ return;
+
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]))
+ return;
+ obj = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
+ flags[0] = swfdec_as_value_to_integer (cx, &argv[2]);
+ flags[1] = (argc > 3) ? swfdec_as_value_to_integer (cx, &argv[3]) : 0;
+
+ if (flags[0] == 0 && flags[1] == 0) {
+ // we should add autosizing length attribute here
+ SWFDEC_FIXME ("ASSetPropFlags to set special length attribute not implemented");
+ return;
+ }
+
+ if (SWFDEC_AS_VALUE_IS_NULL (&argv[1])) {
+ swfdec_as_object_foreach (obj, swfdec_as_context_ASSetPropFlags_foreach, flags);
+ } else {
+ char **split =
+ g_strsplit (swfdec_as_value_to_string (cx, &argv[1]), ",", -1);
+ guint i;
+ for (i = 0; split[i]; i++) {
+ swfdec_as_context_ASSetPropFlags_set_one_flag (obj,
+ swfdec_as_context_get_string (cx, split[i]), flags);
+ }
+ g_strfreev (split);
+ }
+}
+
+SWFDEC_AS_NATIVE (200, 19, swfdec_as_context_isFinite)
+void
+swfdec_as_context_isFinite (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ double d;
+
+ if (argc < 1)
+ return;
+
+ d = swfdec_as_value_to_number (cx, &argv[0]);
+ SWFDEC_AS_VALUE_SET_BOOLEAN (retval, isfinite (d) ? TRUE : FALSE);
+}
+
+SWFDEC_AS_NATIVE (200, 18, swfdec_as_context_isNaN)
+void
+swfdec_as_context_isNaN (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ double d;
+
+ if (argc < 1)
+ return;
+
+ d = swfdec_as_value_to_number (cx, &argv[0]);
+ SWFDEC_AS_VALUE_SET_BOOLEAN (retval, isnan (d) ? TRUE : FALSE);
+}
+
+SWFDEC_AS_NATIVE (100, 2, swfdec_as_context_parseInt)
+void
+swfdec_as_context_parseInt (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ const char *s;
+ char *tail;
+ int radix;
+ gint64 i;
+
+ if (argc < 1)
+ return;
+
+ s = swfdec_as_value_to_string (cx, &argv[0]);
+
+ if (argc >= 2) {
+ radix = swfdec_as_value_to_integer (cx, &argv[1]);
+
+ if (radix < 2 || radix > 36) {
+ SWFDEC_AS_VALUE_SET_NUMBER (retval, NAN);
+ return;
+ }
+
+ // special case, strtol parses things that we shouldn't parse
+ if (radix == 16) {
+ const char *end = s + strspn (s, " \t\r\n");
+ if (end != s && (end[0] == '-' || end[0] == '+'))
+ end++;
+ if (end != s && end[0] == '0' && (end[1] == 'x' || end[1] == 'X')) {
+ SWFDEC_AS_VALUE_SET_NUMBER (retval, 0);
+ return;
+ }
+ }
+ } else {
+ radix = 0;
+ }
+
+ // special case, don't allow sign in front of the 0x
+ if ((s[0] == '-' || s[0] == '+') && s[1] == '0' &&
+ (s[2] == 'x' || s[2] == 'X')) {
+ SWFDEC_AS_VALUE_SET_NUMBER (retval, NAN);
+ return;
+ }
+
+ if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) {
+ s = s + 2;
+ i = g_ascii_strtoll (s, &tail, (radix != 0 ? radix : 16));
+ } else if (s[0] == '0' && s[strspn (s, "01234567")] == '\0') {
+ i = g_ascii_strtoll (s, &tail, (radix != 0 ? radix : 8));
+ } else {
+ i = g_ascii_strtoll (s, &tail, (radix != 0 ? radix : 10));
+ }
+
+ if (tail == s) {
+ SWFDEC_AS_VALUE_SET_NUMBER (retval, NAN);
+ return;
+ }
+
+ if (i > G_MAXINT32 || i < G_MININT32) {
+ SWFDEC_AS_VALUE_SET_NUMBER (retval, i);
+ } else {
+ SWFDEC_AS_VALUE_SET_INT (retval, i);
+ }
+}
+
+SWFDEC_AS_NATIVE (100, 3, swfdec_as_context_parseFloat)
+void
+swfdec_as_context_parseFloat (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ char *s, *p, *tail;
+ double d;
+
+ if (argc < 1)
+ return;
+
+ // we need to remove everything after x or I, since strtod parses hexadecimal
+ // numbers and Infinity
+ s = g_strdup (swfdec_as_value_to_string (cx, &argv[0]));
+ if ((p = strpbrk (s, "xXiI")) != NULL) {
+ *p = '\0';
+ }
+
+ d = g_ascii_strtod (s, &tail);
+
+ if (tail == s) {
+ SWFDEC_AS_VALUE_SET_NUMBER (retval, NAN);
+ } else {
+ SWFDEC_AS_VALUE_SET_NUMBER (retval, d);
+ }
+
+ g_free (s);
+}
+
+static void
+swfdec_as_context_init_global (SwfdecAsContext *context)
+{
+ SwfdecAsValue val;
+
+ SWFDEC_AS_VALUE_SET_NUMBER (&val, NAN);
+ swfdec_as_object_set_variable (context->global, SWFDEC_AS_STR_NaN, &val);
+ SWFDEC_AS_VALUE_SET_NUMBER (&val, HUGE_VAL);
+ swfdec_as_object_set_variable (context->global, SWFDEC_AS_STR_Infinity, &val);
+}
+
+void
+swfdec_as_context_run_init_script (SwfdecAsContext *context, const guint8 *data,
+ gsize length, guint version)
+{
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
+ g_return_if_fail (data != NULL);
+ g_return_if_fail (length > 0);
+
+ if (version > 4) {
+ SwfdecBits bits;
+ SwfdecScript *script;
+ swfdec_bits_init_data (&bits, data, length);
+ script = swfdec_script_new_from_bits (&bits, "init", version);
+ if (script == NULL) {
+ g_warning ("script passed to swfdec_as_context_run_init_script is invalid");
+ return;
+ }
+ swfdec_as_object_run (context->global, script);
+ swfdec_script_unref (script);
+ } else {
+ SWFDEC_LOG ("not running init script, since version is <= 4");
+ }
+}
+
+/**
+ * swfdec_as_context_startup:
+ * @context: a #SwfdecAsContext
+ * @version: Flash version to use
+ *
+ * Starts up the context. This function must be called before any Actionscript
+ * is called on @context. The version is responsible for deciding which native
+ * functions and properties are available in the context.
+ **/
+void
+swfdec_as_context_startup (SwfdecAsContext *context)
+{
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
+ g_return_if_fail (context->state == SWFDEC_AS_CONTEXT_NEW);
+
+ if (context->cur == NULL &&
+ !swfdec_as_stack_push_segment (context))
+ return;
+ if (context->global == NULL)
+ context->global = swfdec_as_object_new_empty (context);
+ /* init the two internal functions */
+ /* FIXME: remove them for normal contexts? */
+ swfdec_player_preinit_global (context);
+ /* get the necessary objects up to define objects and functions sanely */
+ swfdec_as_function_init_context (context);
+ swfdec_as_object_init_context (context);
+ /* define the global object and other important ones */
+ swfdec_as_context_init_global (context);
+
+ /* run init script */
+ swfdec_as_context_run_init_script (context, swfdec_as_initialize, sizeof (swfdec_as_initialize), 8);
+
+ if (context->state == SWFDEC_AS_CONTEXT_NEW)
+ context->state = SWFDEC_AS_CONTEXT_RUNNING;
+}
+
+/**
+ * swfdec_as_context_check_continue:
+ * @context: the context that might be running too long
+ *
+ * Checks if the context has been running too long. If it has, it gets aborted.
+ *
+ * Returns: %TRUE if this player aborted.
+ **/
+gboolean
+swfdec_as_context_check_continue (SwfdecAsContext *context)
+{
+ SwfdecAsContextClass *klass;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), TRUE);
+
+ klass = SWFDEC_AS_CONTEXT_GET_CLASS (context);
+ if (klass->check_continue == NULL)
+ return TRUE;
+ if (!klass->check_continue (context)) {
+ swfdec_as_context_abort (context, "Runtime exceeded");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
+ * swfdec_as_context_is_aborted:
+ * @context: a #SwfdecAsContext
+ *
+ * Determines if the given context is aborted. An aborted context is not able
+ * to execute any scripts. Aborting can happen if the script engine detects bad
+ * scripts that cause excessive memory usage, infinite loops or other problems.
+ * In that case the script engine aborts for safety reasons.
+ *
+ * Returns: %TRUE if the player is aborted, %FALSE if it runs normally.
+ **/
+gboolean
+swfdec_as_context_is_aborted (SwfdecAsContext *context)
+{
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), TRUE);
+
+ return context->state == SWFDEC_AS_CONTEXT_ABORTED;
+}
+
diff --git a/swfdec/swfdec_as_context.h b/swfdec/swfdec_as_context.h
new file mode 100644
index 0000000..d5ef066
--- /dev/null
+++ b/swfdec/swfdec_as_context.h
@@ -0,0 +1,143 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_CONTEXT_H_
+#define _SWFDEC_AS_CONTEXT_H_
+
+#include <glib-object.h>
+#include <libswfdec/swfdec_as_types.h>
+
+G_BEGIN_DECLS
+
+typedef enum {
+ SWFDEC_AS_CONTEXT_NEW,
+ SWFDEC_AS_CONTEXT_RUNNING,
+ SWFDEC_AS_CONTEXT_INTERRUPTED,
+ SWFDEC_AS_CONTEXT_ABORTED
+} SwfdecAsContextState;
+
+typedef struct _SwfdecAsContextClass SwfdecAsContextClass;
+
+#define SWFDEC_TYPE_AS_CONTEXT (swfdec_as_context_get_type())
+#define SWFDEC_IS_AS_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_CONTEXT))
+#define SWFDEC_IS_AS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_CONTEXT))
+#define SWFDEC_AS_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_CONTEXT, SwfdecAsContext))
+#define SWFDEC_AS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_CONTEXT, SwfdecAsContextClass))
+#define SWFDEC_AS_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_CONTEXT, SwfdecAsContextClass))
+
+struct _SwfdecAsContext {
+ GObject object;
+
+ SwfdecAsContextState state; /* our current state */
+ SwfdecAsObject * global; /* the global object or NULL if not initialized yet.
+ In SwfdecPlayer is NULL unless a sandbox is in use */
+ GRand * rand; /* random number generator */
+ GTimeVal start_time; /* time this movie started (for GetTime action) */
+
+ /* GC properties */
+ gsize memory_until_gc;/* amount of memory allocations that trigger a GC */
+
+ /* bookkeeping for GC */
+ gsize memory; /* total memory currently in use */
+ gsize memory_since_gc;/* memory allocated since last GC run */
+ GHashTable * strings; /* string=>memory mapping the context manages */
+ GHashTable * objects; /* all objects the context manages */
+
+ /* execution state */
+ unsigned int version; /* currently active version */
+ unsigned int call_depth; /* current depth of call stack (equals length of frame list) */
+ SwfdecAsFrame * frame; /* topmost stack frame */
+ SwfdecAsFrame * last_frame; /* last frame before calling context_run */
+ gboolean exception; /* whether we are throwing an exception */
+ SwfdecAsValue exception_value; /* value of the exception being thrown, can be anything including undefined */
+
+ /* stack */
+ SwfdecAsValue * base; /* stack base */
+ SwfdecAsValue * end; /* end of stack */
+ SwfdecAsValue * cur; /* pointer to current top of stack */
+ SwfdecAsStack * stack; /* current stack */
+
+ /* magic objects - initialized during swfdec_as_context_startup() */
+ SwfdecAsObject * Function; /* Function */
+ SwfdecAsObject * Function_prototype; /* Function.prototype */
+ SwfdecAsObject * Object; /* Object */
+ SwfdecAsObject * Object_prototype; /* Object.prototype */
+
+ /* debugging */
+ SwfdecAsDebugger * debugger; /* debugger (or NULL if none) */
+};
+
+struct _SwfdecAsContextClass {
+ GObjectClass object_class;
+
+ /* mark all objects that should not be collected */
+ void (* mark) (SwfdecAsContext * context);
+ /* overwrite if you want to report a different time than gettimeofday */
+ void (* get_time) (SwfdecAsContext * context,
+ GTimeVal * tv);
+ /* overwrite if you want to abort on infinite loops */
+ gboolean (* check_continue) (SwfdecAsContext * context);
+};
+
+GType swfdec_as_context_get_type (void);
+
+void swfdec_as_context_startup (SwfdecAsContext * context);
+
+gboolean swfdec_as_context_is_aborted (SwfdecAsContext * context);
+gboolean swfdec_as_context_is_constructing
+ (SwfdecAsContext * context);
+SwfdecAsFrame * swfdec_as_context_get_frame (SwfdecAsContext * context);
+void swfdec_as_context_get_time (SwfdecAsContext * context,
+ GTimeVal * tv);
+const char * swfdec_as_context_get_string (SwfdecAsContext * context,
+ const char * string);
+const char * swfdec_as_context_give_string (SwfdecAsContext * context,
+ char * string);
+
+void swfdec_as_context_abort (SwfdecAsContext * context,
+ const char * reason);
+
+void swfdec_as_context_throw (SwfdecAsContext * context,
+ const SwfdecAsValue * value);
+gboolean swfdec_as_context_catch (SwfdecAsContext * context,
+ SwfdecAsValue * value);
+
+gboolean swfdec_as_context_use_mem (SwfdecAsContext * context,
+ gsize bytes);
+void swfdec_as_context_unuse_mem (SwfdecAsContext * context,
+ gsize bytes);
+void swfdec_as_object_mark (SwfdecAsObject * object);
+void swfdec_as_value_mark (SwfdecAsValue * value);
+void swfdec_as_string_mark (const char * string);
+void swfdec_as_context_gc (SwfdecAsContext * context);
+void swfdec_as_context_maybe_gc (SwfdecAsContext * context);
+
+void swfdec_as_context_run (SwfdecAsContext * context);
+
+void swfdec_as_context_eval (SwfdecAsContext * context,
+ SwfdecAsObject * obj,
+ const char * str,
+ SwfdecAsValue * val);
+void swfdec_as_context_eval_set (SwfdecAsContext * context,
+ SwfdecAsObject * obj,
+ const char * str,
+ const SwfdecAsValue * val);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_as_date.c b/swfdec/swfdec_as_date.c
new file mode 100644
index 0000000..890d274
--- /dev/null
+++ b/swfdec/swfdec_as_date.c
@@ -0,0 +1,1162 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include "swfdec_as_date.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_frame_internal.h"
+#include "swfdec_as_function.h"
+#include "swfdec_as_object.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_system.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_debug.h"
+
+G_DEFINE_TYPE (SwfdecAsDate, swfdec_as_date, SWFDEC_TYPE_AS_OBJECT)
+
+/*
+ * Class functions
+ */
+
+static void
+swfdec_as_date_class_init (SwfdecAsDateClass *klass)
+{
+}
+
+static void
+swfdec_as_date_init (SwfdecAsDate *date)
+{
+}
+
+/*** Helper functions ***/
+
+/* Kind of replacement for gmtime_r, timegm that works the way Flash works */
+
+#define MILLISECONDS_PER_SECOND 1000
+#define SECONDS_PER_MINUTE 60
+#define MINUTES_PER_HOUR 60
+#define HOURS_PER_DAY 24
+#define MONTHS_PER_YEAR 12
+
+#define MILLISECONDS_PER_MINUTE 60000
+#define MILLISECONDS_PER_HOUR 3600000
+#define MILLISECONDS_PER_DAY 86400000
+
+static const int month_offsets[2][13] = {
+ // Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Total
+ { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
+ { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
+};
+
+typedef struct {
+ int milliseconds;
+ int seconds;
+ int minutes;
+ int hours;
+ int day_of_month;
+ int month;
+ int year;
+
+ int day_of_week;
+} BrokenTime;
+
+static int
+swfdec_as_date_days_in_year (int year)
+{
+ if (year % 4) {
+ return 365;
+ } else if (year % 100) {
+ return 366;
+ } else if (year % 400) {
+ return 365;
+ } else {
+ return 366;
+ }
+}
+
+#define IS_LEAP(year) (swfdec_as_date_days_in_year ((year)) == 366)
+
+static double
+swfdec_as_date_days_since_utc_for_year (int year)
+{
+ double year_big = year;
+
+ return (
+ 365 * (year_big - 1970) +
+ floor (((year_big - 1969) / 4.0f)) -
+ floor (((year_big - 1901) / 100.0f)) +
+ floor (((year_big - 1601) / 400.0f))
+ );
+}
+
+static int
+swfdec_as_date_days_from_utc_to_year (double days)
+{
+ int low, high, pivot;
+
+ low = floor ((days >= 0 ? days / 366.0 : days / 365.0)) + 1970;
+ high = ceil ((days >= 0 ? days / 365.0 : days / 366.0)) + 1970;
+
+ while (low < high) {
+ pivot = ((double)low + (double)high) / 2.0;
+
+ if (swfdec_as_date_days_since_utc_for_year (pivot) <= days) {
+ if (swfdec_as_date_days_since_utc_for_year (pivot + 1) > days) {
+ high = low = pivot;
+ } else {
+ low = pivot + 1;
+ }
+ } else {
+ high = pivot - 1;
+ }
+ }
+
+ return low;
+}
+
+static void
+swfdec_as_date_milliseconds_to_brokentime (double milliseconds,
+ BrokenTime *brokentime)
+{
+ double remaining;
+ int year;
+
+ g_assert (brokentime != NULL);
+
+ /* special case: hours are calculated from different value */
+ if (isfinite (milliseconds)) {
+ remaining = floor (milliseconds + 0.5);
+ } else {
+ remaining = 0;
+ }
+
+ remaining = floor (remaining / MILLISECONDS_PER_HOUR);
+ brokentime->hours = fmod (remaining, HOURS_PER_DAY);
+
+ /* hours done, on with the rest */
+ if (isfinite (milliseconds)) {
+ remaining = milliseconds;
+ } else {
+ remaining = 0;
+ }
+
+ brokentime->milliseconds = fmod (remaining, MILLISECONDS_PER_SECOND);
+ remaining = floor (remaining / MILLISECONDS_PER_SECOND);
+
+ brokentime->seconds = fmod (remaining, SECONDS_PER_MINUTE);
+ remaining = floor (remaining / SECONDS_PER_MINUTE);
+
+ brokentime->minutes = fmod (remaining, MINUTES_PER_HOUR);
+ remaining = floor (remaining / MINUTES_PER_HOUR);
+ remaining = floor (remaining / HOURS_PER_DAY);
+
+ if (milliseconds < 0) {
+ if (brokentime->milliseconds < 0)
+ brokentime->milliseconds += MILLISECONDS_PER_SECOND;
+ if (brokentime->seconds < 0)
+ brokentime->seconds += SECONDS_PER_MINUTE;
+ if (brokentime->minutes < 0)
+ brokentime->minutes += MINUTES_PER_HOUR;
+ if (brokentime->hours < 0)
+ brokentime->hours += HOURS_PER_DAY;
+ }
+
+ // now remaining == days since 1970
+
+ if (isfinite (milliseconds)) {
+ brokentime->day_of_week = fmod ((remaining + 4), 7);
+ if (brokentime->day_of_week < 0)
+ brokentime->day_of_week += 7;
+ } else {
+ // special case
+ brokentime->day_of_week = 0;
+ }
+
+ year = swfdec_as_date_days_from_utc_to_year (remaining);
+ brokentime->year = year - 1900;
+
+ remaining -= swfdec_as_date_days_since_utc_for_year (year);
+ g_assert (remaining >= 0 && remaining <= 365);
+
+ brokentime->month = 0;
+ while (month_offsets[IS_LEAP (year)][brokentime->month + 1] <= remaining)
+ brokentime->month++;
+
+ brokentime->day_of_month =
+ remaining - month_offsets[IS_LEAP (year)][brokentime->month] + 1;
+}
+
+static double
+swfdec_as_date_brokentime_to_milliseconds (const BrokenTime *brokentime)
+{
+ double milliseconds;
+ int month, year;
+
+ year = 1900 + brokentime->year;
+
+ milliseconds = brokentime->milliseconds;
+ milliseconds += brokentime->seconds * MILLISECONDS_PER_SECOND;
+ milliseconds += brokentime->minutes * MILLISECONDS_PER_MINUTE;
+ milliseconds += brokentime->hours * MILLISECONDS_PER_HOUR;
+ milliseconds += (double)(brokentime->day_of_month - 1) * MILLISECONDS_PER_DAY;
+
+ milliseconds +=
+ swfdec_as_date_days_since_utc_for_year (year) * MILLISECONDS_PER_DAY;
+
+ for (month = brokentime->month; month < 0; month += MONTHS_PER_YEAR) {
+ milliseconds -=
+ (double)month_offsets[IS_LEAP (--year)][MONTHS_PER_YEAR] * MILLISECONDS_PER_DAY;
+ }
+
+ for (month = month; month >= MONTHS_PER_YEAR; month -= MONTHS_PER_YEAR) {
+ milliseconds +=
+ (double)month_offsets[IS_LEAP (year++)][MONTHS_PER_YEAR] * MILLISECONDS_PER_DAY;
+ }
+
+ milliseconds += (double)month_offsets[IS_LEAP (year)][month] * MILLISECONDS_PER_DAY;
+
+ return milliseconds;
+}
+
+/* Wrappers for swfdec_as_value_to_number because we need both double and int
+ * often, and need to generate the right valueOf etc. */
+
+// returns TRUE if d is not Infinite or NAN
+static gboolean
+swfdec_as_date_value_to_number_and_integer_floor (SwfdecAsContext *context,
+ const SwfdecAsValue *value, double *d, int *num)
+{
+ *d = swfdec_as_value_to_number (context, value);
+ if (!isfinite (*d)) {
+ *num = 0;
+ return FALSE;
+ }
+
+ *num = floor (*d);
+ return TRUE;
+}
+
+// returns TRUE if d is not Infinite or NAN
+static gboolean
+swfdec_as_date_value_to_number_and_integer (SwfdecAsContext *context,
+ const SwfdecAsValue *value, double *d, int *num)
+{
+ g_assert (d != NULL);
+ g_assert (num != NULL);
+
+ // undefined == NAN here, even in version < 7
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (value)) {
+ *d = NAN;
+ } else {
+ *d = swfdec_as_value_to_number (context, value);
+ }
+ if (!isfinite (*d)) {
+ *num = 0;
+ return FALSE;
+ }
+
+ if (*d < 0) {
+ *num = - (guint) fmod (-*d, 4294967296);
+ } else {
+ *num = (guint) fmod (*d, 4294967296);
+ }
+ return TRUE;
+}
+
+/* The functions to query/modify the current time */
+
+// returns TRUE with Infinite and -Infinite, because those values should be
+// handles like 0 that is returned by below functions
+static gboolean
+swfdec_as_date_is_valid (const SwfdecAsDate *date)
+{
+ return !isnan (date->milliseconds);
+}
+
+static void
+swfdec_as_date_set_invalid (SwfdecAsDate *date)
+{
+ date->milliseconds = NAN;
+}
+
+static double
+swfdec_as_date_get_milliseconds_utc (const SwfdecAsDate *date)
+{
+ g_assert (swfdec_as_date_is_valid (date));
+
+ if (isfinite (date->milliseconds)) {
+ return date->milliseconds;
+ } else {
+ return 0;
+ }
+}
+
+static void
+swfdec_as_date_set_milliseconds_utc (SwfdecAsDate *date, double milliseconds)
+{
+ date->milliseconds = milliseconds;
+}
+
+/*static double
+swfdec_as_date_get_milliseconds_local (const SwfdecAsDate *date)
+{
+ g_assert (swfdec_as_date_is_valid (date));
+
+ if (isfinite (date->milliseconds)) {
+ return date->milliseconds + (double) date->utc_offset * 60 * 1000;
+ } else {
+ return 0;
+ }
+}*/
+
+static void
+swfdec_as_date_set_milliseconds_local (SwfdecAsDate *date, double milliseconds)
+{
+ date->milliseconds =
+ milliseconds - (double) date->utc_offset * 60 * 1000;
+}
+
+static void
+swfdec_as_date_get_brokentime_utc (const SwfdecAsDate *date,
+ BrokenTime *brokentime)
+{
+ g_assert (swfdec_as_date_is_valid (date));
+
+ swfdec_as_date_milliseconds_to_brokentime (date->milliseconds, brokentime);
+}
+
+static void
+swfdec_as_date_set_brokentime_utc (SwfdecAsDate *date, BrokenTime *brokentime)
+{
+ date->milliseconds = swfdec_as_date_brokentime_to_milliseconds (brokentime);
+}
+
+static void
+swfdec_as_date_get_brokentime_local (const SwfdecAsDate *date,
+ BrokenTime *brokentime)
+{
+ g_assert (swfdec_as_date_is_valid (date));
+
+ swfdec_as_date_milliseconds_to_brokentime (
+ date->milliseconds + date->utc_offset * 60 * 1000, brokentime);
+}
+
+static void
+swfdec_as_date_set_brokentime_local (SwfdecAsDate *date, BrokenTime *brokentime)
+{
+ date->milliseconds = swfdec_as_date_brokentime_to_milliseconds (brokentime) -
+ date->utc_offset * 60 * 1000;
+}
+
+/* set and get function helpers */
+
+typedef enum {
+ FIELD_MILLISECONDS,
+ FIELD_SECONDS,
+ FIELD_MINUTES,
+ FIELD_HOURS,
+ FIELD_WEEK_DAYS,
+ FIELD_MONTH_DAYS,
+ FIELD_MONTHS,
+ FIELD_YEAR,
+ FIELD_FULL_YEAR
+} field_t;
+
+static int field_offsets[] = {
+ G_STRUCT_OFFSET (BrokenTime, milliseconds),
+ G_STRUCT_OFFSET (BrokenTime, seconds),
+ G_STRUCT_OFFSET (BrokenTime, minutes),
+ G_STRUCT_OFFSET (BrokenTime, hours),
+ G_STRUCT_OFFSET (BrokenTime, day_of_week),
+ G_STRUCT_OFFSET (BrokenTime, day_of_month),
+ G_STRUCT_OFFSET (BrokenTime, month),
+ G_STRUCT_OFFSET (BrokenTime, year),
+ G_STRUCT_OFFSET (BrokenTime, year)
+};
+
+static int
+swfdec_as_date_get_brokentime_value (SwfdecAsDate *date, gboolean utc,
+ int field_offset)
+{
+ BrokenTime brokentime;
+
+ if (utc) {
+ swfdec_as_date_get_brokentime_utc (date, &brokentime);
+ } else {
+ swfdec_as_date_get_brokentime_local (date, &brokentime);
+ }
+
+ return G_STRUCT_MEMBER (int, &brokentime, field_offset);
+}
+
+static void
+swfdec_as_date_set_brokentime_value (SwfdecAsDate *date, gboolean utc,
+ int field_offset, SwfdecAsContext *cx, int number)
+{
+ BrokenTime brokentime;
+
+ if (utc) {
+ swfdec_as_date_get_brokentime_utc (date, &brokentime);
+ } else {
+ swfdec_as_date_get_brokentime_local (date, &brokentime);
+ }
+
+ G_STRUCT_MEMBER (int, &brokentime, field_offset) = number;
+
+ if (utc) {
+ swfdec_as_date_set_brokentime_utc (date, &brokentime);
+ } else {
+ swfdec_as_date_set_brokentime_local (date, &brokentime);
+ }
+}
+
+static void
+swfdec_as_date_set_field (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret, field_t field,
+ gboolean utc)
+{
+ SwfdecAsDate *date;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_DATE, &date, "");
+
+ if (!swfdec_as_date_is_valid (date))
+ swfdec_as_value_to_number (cx, &argv[0]); // calls valueOf
+
+ if (swfdec_as_date_is_valid (date) && argc > 0)
+ {
+ gboolean set;
+ double milliseconds;
+ double d;
+ int number;
+
+ set = TRUE;
+ swfdec_as_date_value_to_number_and_integer (cx, &argv[0], &d, &number);
+
+ switch (field) {
+ case FIELD_MONTHS:
+ if (!isfinite (d)) {
+ if (!isnan (d)) {
+ swfdec_as_date_set_brokentime_value (date, utc,
+ field_offsets[FIELD_YEAR], cx, 0 - 1900);
+ }
+ swfdec_as_date_set_brokentime_value (date, utc, field_offsets[field],
+ cx, 0);
+ set = FALSE;
+ }
+ break;
+ case FIELD_YEAR:
+ // NOTE: Test against double, not the integer
+ if (d >= 100 || d < 0)
+ number -= 1900;
+ // fall trough
+ case FIELD_FULL_YEAR:
+ if (!isfinite (d)) {
+ swfdec_as_date_set_brokentime_value (date, utc, field_offsets[field],
+ cx, 0 - 1900);
+ set = FALSE;
+ }
+ break;
+ case FIELD_MILLISECONDS:
+ case FIELD_SECONDS:
+ case FIELD_MINUTES:
+ case FIELD_HOURS:
+ case FIELD_WEEK_DAYS:
+ case FIELD_MONTH_DAYS:
+ if (!isfinite (d)) {
+ swfdec_as_date_set_invalid (date);
+ set = FALSE;
+ }
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ if (set) {
+ swfdec_as_date_set_brokentime_value (date, utc, field_offsets[field], cx,
+ number);
+ }
+
+ if (swfdec_as_date_is_valid (date)) {
+ milliseconds = swfdec_as_date_get_milliseconds_utc (date);
+ if (milliseconds < -8.64e15 || milliseconds > 8.64e15)
+ swfdec_as_date_set_invalid (date);
+ }
+ }
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, date->milliseconds);
+}
+
+static void
+swfdec_as_date_get_field (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret, field_t field,
+ gboolean utc)
+{
+ SwfdecAsDate *date;
+ int number;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_DATE, &date, "");
+
+ if (!swfdec_as_date_is_valid (date)) {
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, NAN);
+ return;
+ }
+
+ number = swfdec_as_date_get_brokentime_value (date, utc,
+ field_offsets[field]);
+
+ if (field == FIELD_FULL_YEAR)
+ number += 1900;
+
+ SWFDEC_AS_VALUE_SET_INT (ret, number);
+}
+
+/*** AS CODE ***/
+
+SWFDEC_AS_NATIVE (103, 19, swfdec_as_date_toString)
+void
+swfdec_as_date_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ static const char *weekday_names[] =
+ { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
+ static const char *month_names[] =
+ { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+ SwfdecAsDate *date;
+ BrokenTime brokentime;
+ char *result;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_DATE, &date, "");
+
+ if (!swfdec_as_date_is_valid (date)) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, "Invalid Date");
+ return;
+ }
+
+ swfdec_as_date_get_brokentime_local (date, &brokentime);
+
+ result = g_strdup_printf ("%s %s %i %02i:%02i:%02i GMT%+03i%02i %i",
+ weekday_names[brokentime.day_of_week % 7],
+ month_names[brokentime.month % 12],
+ brokentime.day_of_month,
+ brokentime.hours, brokentime.minutes, brokentime.seconds,
+ date->utc_offset / 60, ABS (date->utc_offset % 60),
+ 1900 + brokentime.year);
+
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, result));
+}
+
+SWFDEC_AS_NATIVE (103, 16, swfdec_as_date_getTime)
+void
+swfdec_as_date_getTime (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecAsDate *date;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_DATE, &date, "");
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, date->milliseconds);
+}
+
+SWFDEC_AS_NATIVE (103, 18, swfdec_as_date_getTimezoneOffset)
+void
+swfdec_as_date_getTimezoneOffset (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecAsDate *date;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_DATE, &date, "");
+
+ // reverse of utc_offset
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, -(date->utc_offset));
+}
+
+// get* functions
+
+SWFDEC_AS_NATIVE (103, 8, swfdec_as_date_getMilliseconds)
+void
+swfdec_as_date_getMilliseconds (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_MILLISECONDS,
+ FALSE);
+}
+
+SWFDEC_AS_NATIVE (103, 128 + 8, swfdec_as_date_getUTCMilliseconds)
+void
+swfdec_as_date_getUTCMilliseconds (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_MILLISECONDS,
+ TRUE);
+}
+
+SWFDEC_AS_NATIVE (103, 7, swfdec_as_date_getSeconds)
+void
+swfdec_as_date_getSeconds (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_SECONDS, FALSE);
+}
+
+SWFDEC_AS_NATIVE (103, 128 + 7, swfdec_as_date_getUTCSeconds)
+void
+swfdec_as_date_getUTCSeconds (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_SECONDS, TRUE);
+}
+
+SWFDEC_AS_NATIVE (103, 6, swfdec_as_date_getMinutes)
+void
+swfdec_as_date_getMinutes (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_MINUTES, FALSE);
+}
+
+SWFDEC_AS_NATIVE (103, 128 + 6, swfdec_as_date_getUTCMinutes)
+void
+swfdec_as_date_getUTCMinutes (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_MINUTES, TRUE);
+}
+
+SWFDEC_AS_NATIVE (103, 5, swfdec_as_date_getHours)
+void
+swfdec_as_date_getHours (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_HOURS, FALSE);
+}
+
+SWFDEC_AS_NATIVE (103, 128 + 5, swfdec_as_date_getUTCHours)
+void
+swfdec_as_date_getUTCHours (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_HOURS, TRUE);
+}
+
+SWFDEC_AS_NATIVE (103, 4, swfdec_as_date_getDay)
+void
+swfdec_as_date_getDay (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+ SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_WEEK_DAYS,
+ FALSE);
+}
+
+SWFDEC_AS_NATIVE (103, 128 + 4, swfdec_as_date_getUTCDay)
+void
+swfdec_as_date_getUTCDay (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_WEEK_DAYS,
+ TRUE);
+}
+
+SWFDEC_AS_NATIVE (103, 3, swfdec_as_date_getDate)
+void
+swfdec_as_date_getDate (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_MONTH_DAYS,
+ FALSE);
+}
+
+SWFDEC_AS_NATIVE (103, 128 + 3, swfdec_as_date_getUTCDate)
+void
+swfdec_as_date_getUTCDate (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_MONTH_DAYS,
+ TRUE);
+}
+
+SWFDEC_AS_NATIVE (103, 2, swfdec_as_date_getMonth)
+void
+swfdec_as_date_getMonth (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_MONTHS, FALSE);
+}
+
+SWFDEC_AS_NATIVE (103, 128 + 2, swfdec_as_date_getUTCMonth)
+void
+swfdec_as_date_getUTCMonth (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_MONTHS, TRUE);
+}
+
+SWFDEC_AS_NATIVE (103, 1, swfdec_as_date_getYear)
+void
+swfdec_as_date_getYear (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_YEAR, FALSE);
+}
+
+SWFDEC_AS_NATIVE (103, 128 + 1, swfdec_as_date_getUTCYear)
+void
+swfdec_as_date_getUTCYear (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_YEAR, TRUE);
+}
+
+SWFDEC_AS_NATIVE (103, 0, swfdec_as_date_getFullYear)
+void
+swfdec_as_date_getFullYear (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_FULL_YEAR,
+ FALSE);
+}
+
+SWFDEC_AS_NATIVE (103, 128 + 0, swfdec_as_date_getUTCFullYear)
+void
+swfdec_as_date_getUTCFullYear (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_get_field (cx, object, argc, argv, ret, FIELD_FULL_YEAR,
+ TRUE);
+}
+
+// set* functions
+
+SWFDEC_AS_NATIVE (103, 17, swfdec_as_date_setTime)
+void
+swfdec_as_date_setTime (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecAsDate *date;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_DATE, &date, "");
+
+ if (argc > 0) {
+ swfdec_as_date_set_milliseconds_utc (date,
+ swfdec_as_value_to_integer (cx, &argv[0]));
+ }
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, date->milliseconds);
+}
+
+SWFDEC_AS_NATIVE (103, 15, swfdec_as_date_setMilliseconds)
+void
+swfdec_as_date_setMilliseconds (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_MILLISECONDS,
+ FALSE);
+}
+
+SWFDEC_AS_NATIVE (103, 128 + 15, swfdec_as_date_setUTCMilliseconds)
+void
+swfdec_as_date_setUTCMilliseconds (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_MILLISECONDS,
+ TRUE);
+}
+
+SWFDEC_AS_NATIVE (103, 14, swfdec_as_date_setSeconds)
+void
+swfdec_as_date_setSeconds (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_SECONDS, FALSE);
+}
+
+SWFDEC_AS_NATIVE (103, 128 + 14, swfdec_as_date_setUTCSeconds)
+void
+swfdec_as_date_setUTCSeconds (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_SECONDS, TRUE);
+}
+
+SWFDEC_AS_NATIVE (103, 13, swfdec_as_date_setMinutes)
+void
+swfdec_as_date_setMinutes (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_MINUTES, FALSE);
+}
+
+SWFDEC_AS_NATIVE (103, 128 + 13, swfdec_as_date_setUTCMinutes)
+void
+swfdec_as_date_setUTCMinutes (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_MINUTES, TRUE);
+}
+
+SWFDEC_AS_NATIVE (103, 12, swfdec_as_date_setHours)
+void
+swfdec_as_date_setHours (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_HOURS, FALSE);
+}
+
+SWFDEC_AS_NATIVE (103, 128 + 12, swfdec_as_date_setUTCHours)
+void
+swfdec_as_date_setUTCHours (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_HOURS, TRUE);
+}
+
+SWFDEC_AS_NATIVE (103, 11, swfdec_as_date_setDate)
+void
+swfdec_as_date_setDate (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_MONTH_DAYS,
+ FALSE);
+}
+
+SWFDEC_AS_NATIVE (103, 128 + 11, swfdec_as_date_setUTCDate)
+void
+swfdec_as_date_setUTCDate (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_MONTH_DAYS,
+ TRUE);
+}
+
+SWFDEC_AS_NATIVE (103, 10, swfdec_as_date_setMonth)
+void
+swfdec_as_date_setMonth (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_MONTHS, FALSE);
+}
+
+SWFDEC_AS_NATIVE (103, 128 + 10, swfdec_as_date_setUTCMonth)
+void
+swfdec_as_date_setUTCMonth (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_MONTHS, TRUE);
+}
+
+SWFDEC_AS_NATIVE (103, 20, swfdec_as_date_setYear)
+void
+swfdec_as_date_setYear (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_YEAR, FALSE);
+}
+
+SWFDEC_AS_NATIVE (103, 9, swfdec_as_date_setFullYear)
+void
+swfdec_as_date_setFullYear (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_FULL_YEAR,
+ FALSE);
+}
+
+SWFDEC_AS_NATIVE (103, 128 + 9, swfdec_as_date_setUTCFullYear)
+void
+swfdec_as_date_setUTCFullYear (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_as_date_set_field (cx, object, argc, argv, ret, FIELD_FULL_YEAR,
+ TRUE);
+}
+
+// Static methods
+
+SWFDEC_AS_NATIVE (103, 257, swfdec_as_date_UTC)
+void
+swfdec_as_date_UTC (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+ SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ guint i;
+ int year, num;
+ double d;
+ BrokenTime brokentime;
+
+ // special case: ignore undefined and everything after it
+ for (i = 0; i < argc; i++) {
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[i])) {
+ argc = i;
+ break;
+ }
+ }
+
+ memset (&brokentime, 0, sizeof (brokentime));
+
+ if (argc > 0) {
+ if (swfdec_as_date_value_to_number_and_integer_floor (cx, &argv[0], &d,
+ &num)) {
+ year = num;
+ } else {
+ // special case: if year is not finite set it to -1900
+ year = -1900;
+ }
+ } else {
+ return;
+ }
+
+ // if we don't got atleast two values, return undefined
+ // do it only here, so valueOf first arg is called
+ if (argc < 2)
+ return;
+
+ if (swfdec_as_date_value_to_number_and_integer (cx, &argv[1], &d,
+ &num)) {
+ brokentime.month = num;
+ } else {
+ // special case: if month is not finite set year to -1900
+ year = -1900;
+ brokentime.month = 0;
+ }
+
+ if (argc > 2) {
+ if (swfdec_as_date_value_to_number_and_integer (cx, &argv[2], &d,
+ &num)) {
+ brokentime.day_of_month = num;
+ } else {
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, d);
+ return;
+ }
+ } else {
+ brokentime.day_of_month = 1;
+ }
+
+ if (argc > 3) {
+ if (swfdec_as_date_value_to_number_and_integer (cx, &argv[3], &d,
+ &num)) {
+ brokentime.hours = num;
+ } else {
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, d);
+ return;
+ }
+ }
+
+ if (argc > 4) {
+ if (swfdec_as_date_value_to_number_and_integer (cx, &argv[4], &d,
+ &num)) {
+ brokentime.minutes = num;
+ } else {
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, d);
+ return;
+ }
+ }
+
+ if (argc > 5) {
+ if (swfdec_as_date_value_to_number_and_integer (cx, &argv[5], &d,
+ &num)) {
+ brokentime.seconds = num;
+ } else {
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, d);
+ return;
+ }
+ }
+
+ if (year >= 100) {
+ brokentime.year = year - 1900;
+ } else {
+ brokentime.year = year;
+ }
+
+ if (argc > 6) {
+ if (swfdec_as_date_value_to_number_and_integer (cx, &argv[6], &d,
+ &num)) {
+ brokentime.milliseconds = num;
+ } else {
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, d);
+ return;
+ }
+ }
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret,
+ swfdec_as_date_brokentime_to_milliseconds (&brokentime));
+}
+
+// Constructor
+
+SWFDEC_AS_CONSTRUCTOR (103, 256, swfdec_as_date_construct, swfdec_as_date_get_type)
+void
+swfdec_as_date_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ guint i;
+ SwfdecAsDate *date;
+
+ if (!cx->frame->construct) {
+ SwfdecAsValue val;
+ if (!swfdec_as_context_use_mem (cx, sizeof (SwfdecAsDate)))
+ return;
+ object = g_object_new (SWFDEC_TYPE_AS_DATE, NULL);
+ swfdec_as_object_add (object, cx, sizeof (SwfdecAsDate));
+ swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_Date, &val);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
+ swfdec_as_object_set_constructor (object,
+ SWFDEC_AS_VALUE_GET_OBJECT (&val));
+ } else {
+ SWFDEC_INFO ("\"Date\" is not an object");
+ }
+ }
+
+ date = SWFDEC_AS_DATE (object);
+
+ /* FIXME: find a general solution here */
+ if (SWFDEC_IS_PLAYER (SWFDEC_AS_OBJECT (date)->context)) {
+ date->utc_offset =
+ SWFDEC_PLAYER (SWFDEC_AS_OBJECT (date)->context)->priv->system->utc_offset;
+ }
+
+ // don't accept arguments when not constructing
+ if (!cx->frame->construct)
+ argc = 0;
+
+ // special case: ignore undefined and everything after it
+ for (i = 0; i < argc; i++) {
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[i])) {
+ argc = i;
+ break;
+ }
+ }
+
+ if (argc == 0) // current time, local
+ {
+ GTimeVal tv;
+
+ swfdec_as_context_get_time (cx, &tv);
+ swfdec_as_date_set_milliseconds_utc (date,
+ tv.tv_sec * 1000.0 + tv.tv_usec / 1000.0);
+ }
+ else if (argc == 1) // milliseconds from epoch, local
+ {
+ // need to save directly to keep fractions of a milliseconds
+ date->milliseconds = swfdec_as_value_to_number (cx, &argv[0]);
+ }
+ else // year, month etc. local
+ {
+ int year, num;
+ double d;
+ BrokenTime brokentime;
+
+ date->milliseconds = 0;
+
+ memset (&brokentime, 0, sizeof (brokentime));
+
+ i = 0;
+
+ if (argc > i) {
+ if (swfdec_as_date_value_to_number_and_integer_floor (cx, &argv[i++], &d,
+ &num)) {
+ year = num;
+ } else {
+ // special case: if year is not finite set it to -1900
+ year = -1900;
+ }
+ } else {
+ year = -1900;
+ }
+
+ if (argc > i) {
+ if (swfdec_as_date_value_to_number_and_integer (cx, &argv[i++], &d,
+ &num)) {
+ brokentime.month = num;
+ } else {
+ // special case: if month is not finite set year to -1900
+ year = -1900;
+ brokentime.month = 0;
+ }
+ }
+
+ if (argc > i) {
+ if (swfdec_as_date_value_to_number_and_integer (cx, &argv[i++], &d,
+ &num)) {
+ brokentime.day_of_month = num;
+ } else {
+ date->milliseconds = d;
+ }
+ } else {
+ brokentime.day_of_month = 1;
+ }
+
+ if (argc > i) {
+ if (swfdec_as_date_value_to_number_and_integer (cx, &argv[i++], &d,
+ &num)) {
+ brokentime.hours = num;
+ } else {
+ date->milliseconds = d;
+ }
+ }
+
+ if (argc > i) {
+ if (swfdec_as_date_value_to_number_and_integer (cx, &argv[i++], &d,
+ &num)) {
+ brokentime.minutes = num;
+ } else {
+ date->milliseconds = d;
+ }
+ }
+
+ if (argc > i) {
+ if (swfdec_as_date_value_to_number_and_integer (cx, &argv[i++], &d,
+ &num)) {
+ brokentime.seconds = num;
+ } else {
+ date->milliseconds = d;
+ }
+ }
+
+ if (year >= 100) {
+ brokentime.year = year - 1900;
+ } else {
+ brokentime.year = year;
+ }
+
+ if (argc > i) {
+ if (swfdec_as_date_value_to_number_and_integer (cx, &argv[i++], &d,
+ &num)) {
+ brokentime.milliseconds += num;
+ } else {
+ date->milliseconds = d;
+ }
+ }
+
+ if (date->milliseconds == 0) {
+ swfdec_as_date_set_milliseconds_local (date,
+ swfdec_as_date_brokentime_to_milliseconds (&brokentime));
+ }
+ }
+
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
+}
diff --git a/swfdec/swfdec_as_date.h b/swfdec/swfdec_as_date.h
new file mode 100644
index 0000000..b095520
--- /dev/null
+++ b/swfdec/swfdec_as_date.h
@@ -0,0 +1,60 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_DATE_H_
+#define _SWFDEC_AS_DATE_H_
+
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_as_types.h>
+#include <libswfdec/swfdec_script.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecAsDate SwfdecAsDate;
+typedef struct _SwfdecAsDateClass SwfdecAsDateClass;
+
+#define SWFDEC_TYPE_AS_DATE (swfdec_as_date_get_type())
+#define SWFDEC_IS_AS_DATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_DATE))
+#define SWFDEC_IS_AS_DATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_DATE))
+#define SWFDEC_AS_DATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_DATE, SwfdecAsDate))
+#define SWFDEC_AS_DATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_DATE, SwfdecAsDateClass))
+#define SWFDEC_AS_DATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_DATE, SwfdecAsDateClass))
+
+struct _SwfdecAsDate {
+ SwfdecAsObject object;
+
+ // time from epoch in UTC
+ double milliseconds;
+
+ // the difference between local timezone and UTC in minutes
+ int utc_offset;
+};
+
+struct _SwfdecAsDateClass {
+ SwfdecAsObjectClass object_class;
+};
+
+GType swfdec_as_date_get_type (void);
+
+SwfdecAsObject *swfdec_as_date_new (SwfdecAsContext * context);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_as_debugger.c b/swfdec/swfdec_as_debugger.c
new file mode 100644
index 0000000..d9f34f3
--- /dev/null
+++ b/swfdec/swfdec_as_debugger.c
@@ -0,0 +1,82 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "swfdec_as_debugger.h"
+#include "swfdec_as_context.h"
+
+G_DEFINE_TYPE (SwfdecAsDebugger, swfdec_as_debugger, G_TYPE_OBJECT)
+
+/**
+ * SECTION:SwfdecAsDebugger
+ * @title: SwfdecAsDebugger
+ * @short_description: the debugger object
+ * @see also: SwfdecAsContext
+ *
+ * The debugger object is a special object that can be set on a #SwfdecAsContext
+ * upon creation. If that is done, the debugger can then be used to inspect the
+ * running Actionscript application.
+ */
+
+/**
+ * SwfdecAsDebugger
+ *
+ * This is the type of the debugger object.
+ */
+
+/**
+ * SwfdecAsDebuggerClass:
+ * @add: Called whenever an object is added to the garbage collection engine
+ * using swfdec_as_object_add ()
+ * @remove: Called whenever an object is about to be collected by the garbage
+ * collector.
+ * @step: This function is called everytime just before a bytecode is executed
+ * by the script engine. So it's very powerful, but can also slow down
+ * the script engine a lot.
+ * @enter_frame: Called after a new #SwfdecAsFrame has been initialized and
+ * pushed to the top of the execution stack.
+ * @leave_frame: Called just after a #SwfdecAsFrame has been removed from the
+ * execution stack. The return value has not been forwarded to
+ * the parent when this function is called.
+ * @set_variable: Called whenever swfdec_as_object_set_variable() is called,
+ * before actually setting the variable. This function is also
+ * called when variables are set by internal code, not just when
+ * interpreting scripts. It also doesn't matter if setting the
+ * variable will succeed.
+ *
+ * The class object for the debugger. You need to override these functions to
+ * get useful functionality for the debugger.
+ */
+
+static void
+swfdec_as_debugger_class_init (SwfdecAsDebuggerClass *klass)
+{
+}
+
+static void
+swfdec_as_debugger_init (SwfdecAsDebugger *debugger)
+{
+}
+
diff --git a/swfdec/swfdec_as_debugger.h b/swfdec/swfdec_as_debugger.h
new file mode 100644
index 0000000..2e2c0e7
--- /dev/null
+++ b/swfdec/swfdec_as_debugger.h
@@ -0,0 +1,80 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_DEBUGGER_H_
+#define _SWFDEC_AS_DEBUGGER_H_
+
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_as_types.h>
+#include <libswfdec/swfdec_script.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecAsDebuggerClass SwfdecAsDebuggerClass;
+
+#define SWFDEC_TYPE_AS_DEBUGGER (swfdec_as_debugger_get_type())
+#define SWFDEC_IS_AS_DEBUGGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_DEBUGGER))
+#define SWFDEC_IS_AS_DEBUGGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_DEBUGGER))
+#define SWFDEC_AS_DEBUGGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_DEBUGGER, SwfdecAsDebugger))
+#define SWFDEC_AS_DEBUGGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_DEBUGGER, SwfdecAsDebuggerClass))
+#define SWFDEC_AS_DEBUGGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_DEBUGGER, SwfdecAsDebuggerClass))
+
+struct _SwfdecAsDebugger {
+ /*< private >*/
+ GObject object;
+};
+
+struct _SwfdecAsDebuggerClass {
+ /*< private >*/
+ GObjectClass object_class;
+
+ /*< public >*/
+ /* a new object was added to the GC */
+ void (* add) (SwfdecAsDebugger * debugger,
+ SwfdecAsContext * context,
+ SwfdecAsObject * object);
+ /* an object was removed from the GC */
+ void (* remove) (SwfdecAsDebugger * debugger,
+ SwfdecAsContext * context,
+ SwfdecAsObject * object);
+ /* called before executing a bytecode */
+ void (* step) (SwfdecAsDebugger * debugger,
+ SwfdecAsContext * context);
+ /* called after adding a frame from the function stack */
+ void (* enter_frame) (SwfdecAsDebugger * debugger,
+ SwfdecAsContext * context,
+ SwfdecAsFrame * frame);
+ /* called after removing a frame from the function stack */
+ void (* leave_frame) (SwfdecAsDebugger * debugger,
+ SwfdecAsContext * context,
+ SwfdecAsFrame * frame,
+ const SwfdecAsValue * return_value);
+ /* called before setting a variable */
+ void (* set_variable)(SwfdecAsDebugger * debugger,
+ SwfdecAsContext * context,
+ SwfdecAsObject * object,
+ const char * variable,
+ const SwfdecAsValue * value);
+};
+
+GType swfdec_as_debugger_get_type (void);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_as_frame.c b/swfdec/swfdec_as_frame.c
new file mode 100644
index 0000000..39888b6
--- /dev/null
+++ b/swfdec/swfdec_as_frame.c
@@ -0,0 +1,895 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_frame_internal.h"
+#include "swfdec_as_frame.h"
+#include "swfdec_as_array.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_stack.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_as_super.h"
+#include "swfdec_debug.h"
+
+/**
+ * SECTION:SwfdecAsFrame
+ * @title: SwfdecAsFrame
+ * @short_description: information about currently executing frames
+ *
+ * This section is only interesting for people that want to look into debugging.
+ * A SwfdecAsFrame describes a currently executing function while it is
+ * running. On every new function call, a new frame is created and pushed on top
+ * of the frame stack. To get the topmost one, use
+ * swfdec_as_context_get_frame(). After that you can inspect various properties
+ * of the frame, like the current stack.
+ *
+ * a #SwfdecAsFrame is a #SwfdecAsObject, so it is possible to set variables on
+ * it. These are local variables inside the executing function. So you can use
+ * functions such as swfdec_as_object_get_variable() to inspect them.
+ */
+
+/**
+ * SwfdecAsFrame:
+ *
+ * the object used to represent an executing function.
+ */
+
+/*** STACK ITERATOR ***/
+
+/**
+ * SwfdecAsStackIterator:
+ *
+ * This is a struct used to walk the stack of a frame. It is supposed to be
+ * allocated on the stack. All of its members are private.
+ */
+
+/**
+ * swfdec_as_stack_iterator_init_arguments:
+ * @iter: iterator to be initialized
+ * @frame: the frame to initialize from
+ *
+ * Initializes a stack iterator to walk the arguments passed to the given @frame. See
+ * swfdec_as_stack_iterator_init() about suggested iterator usage.
+ *
+ * Returns: The value of the first argument
+ **/
+SwfdecAsValue *
+swfdec_as_stack_iterator_init_arguments (SwfdecAsStackIterator *iter, SwfdecAsFrame *frame)
+{
+ SwfdecAsContext *context;
+
+ g_return_val_if_fail (iter != NULL, NULL);
+ g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
+
+ if (frame->argc == 0) {
+ iter->i = iter->n = 0;
+ iter->stack = NULL;
+ iter->current = NULL;
+ return NULL;
+ }
+ context = SWFDEC_AS_OBJECT (frame)->context;
+ if (frame->argv) {
+ iter->stack = NULL;
+ iter->current = (SwfdecAsValue *) frame->argv;
+ } else {
+ SwfdecAsStack *stack = context->stack;
+ SwfdecAsValue *end;
+ iter->current = frame->stack_begin - 1;
+ end = context->cur;
+ while (iter->current < stack->elements ||
+ iter->current > end) {
+ stack = stack->next;
+ end = &stack->elements[stack->used_elements];
+ }
+ iter->stack = stack;
+ }
+ iter->i = 0;
+ iter->n = frame->argc;
+ return iter->current;
+}
+
+/**
+ * swfdec_as_stack_iterator_init:
+ * @iter: a #SwfdecStackIterator
+ * @frame: the frame to initialize from
+ *
+ * Initializes @iter to walk the stack of @frame. The first value on the stack
+ * will alread be returned. This makes it possible to write a simple loop to
+ * print the whole stack:
+ * |[for (value = swfdec_as_stack_iterator_init (&iter, frame); value != NULL;
+ * value = swfdec_as_stack_iterator_next (&iter)) {
+ * char *s = swfdec_as_value_to_debug (value);
+ * g_print ("%s\n", s);
+ * g_free (s);
+ * }]|
+ *
+ * Returns: the topmost value on the stack of @frame or %NULL if none
+ **/
+SwfdecAsValue *
+swfdec_as_stack_iterator_init (SwfdecAsStackIterator *iter, SwfdecAsFrame *frame)
+{
+ SwfdecAsContext *context;
+ SwfdecAsStack *stack;
+
+ g_return_val_if_fail (iter != NULL, NULL);
+ g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
+
+ context = SWFDEC_AS_OBJECT (frame)->context;
+ iter->i = 0;
+ stack = context->stack;
+ if (context->frame == frame) {
+ iter->current = context->cur;
+ } else {
+ SwfdecAsFrame *follow = context->frame;
+ while (follow->next != frame)
+ follow = follow->next;
+ iter->current = follow->stack_begin;
+ /* FIXME: get rid of arguments on stack */
+ while (iter->current < &stack->elements[0] || iter->current > &stack->elements[stack->n_elements]) {
+ stack = stack->next;
+ g_assert (stack);
+ }
+ }
+ iter->stack = stack;
+ /* figure out number of args */
+ iter->n = iter->current - &stack->elements[0];
+ while (frame->stack_begin < &stack->elements[0] && frame->stack_begin > &stack->elements[stack->n_elements]) {
+ iter->n += stack->used_elements;
+ stack = stack->next;
+ };
+ g_assert (iter->n >= (guint) (frame->stack_begin - &stack->elements[0]));
+ iter->n -= frame->stack_begin - &stack->elements[0];
+ if (iter->n == 0)
+ return NULL;
+ if (iter->current == &iter->stack->elements[0]) {
+ iter->stack = iter->stack->next;
+ g_assert (iter->stack);
+ iter->current = &iter->stack->elements[iter->stack->used_elements];
+ }
+ iter->current--;
+ return iter->current;
+}
+
+/**
+ * swfdec_as_stack_iterator_next:
+ * @iter: a #SwfdecAsStackIterator
+ *
+ * Gets the next value on the stack.
+ *
+ * Returns: The next value on the stack or %NULL if no more values are on the stack
+ **/
+SwfdecAsValue *
+swfdec_as_stack_iterator_next (SwfdecAsStackIterator *iter)
+{
+ if (iter->i < iter->n)
+ iter->i++;
+ if (iter->i >= iter->n)
+ return NULL;
+ if (iter->stack) {
+ if (iter->current == &iter->stack->elements[0]) {
+ iter->stack = iter->stack->next;
+ g_assert (iter->stack);
+ iter->current = &iter->stack->elements[iter->stack->used_elements];
+ }
+ iter->current--;
+ } else {
+ iter->current++;
+ }
+ return iter->current;
+}
+
+/*** BLOCK HANDLING ***/
+
+typedef struct {
+ const guint8 * start; /* start of block */
+ const guint8 * end; /* end of block (hitting this address will exit the block) */
+ SwfdecAsFrameBlockFunc func; /* function to call when block is exited (or frame is destroyed) */
+ gpointer data; /* data to pass to function */
+} SwfdecAsFrameBlock;
+
+/**
+ * swfdec_as_frame_push_block:
+ * @frame: a #SwfdecAsFrame
+ * @start: start of block
+ * @end: byte after end of block
+ * @func: function to call when block gets exited
+ * @data: data to pass to @func
+ *
+ * Registers a function that guards a block of memory. When the function
+ * exits this block of memory, it will call this function. This can happen
+ * either when the program counter leaves the guarded region, when the
+ * function returns or when the context aborted due to an unrecoverable error.
+ **/
+void
+swfdec_as_frame_push_block (SwfdecAsFrame *frame, const guint8 *start,
+ const guint8 *end, SwfdecAsFrameBlockFunc func, gpointer data)
+{
+ SwfdecAsFrameBlock block = { start, end, func, data };
+
+ g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+ g_return_if_fail (start <= end);
+ g_return_if_fail (start >= frame->block_start);
+ g_return_if_fail (end <= frame->block_end);
+ g_return_if_fail (func != NULL);
+
+ frame->block_start = start;
+ frame->block_end = end;
+ g_array_append_val (frame->blocks, block);
+}
+
+void
+swfdec_as_frame_pop_block (SwfdecAsFrame *frame)
+{
+ SwfdecAsFrameBlockFunc func;
+ gpointer data;
+ SwfdecAsFrameBlock *block;
+
+ g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+ g_return_if_fail (frame->blocks->len > 0);
+
+ block = &g_array_index (frame->blocks, SwfdecAsFrameBlock, frame->blocks->len - 1);
+ func = block->func;
+ data = block->data;
+ g_array_set_size (frame->blocks, frame->blocks->len - 1);
+ if (frame->blocks->len) {
+ block--;
+ frame->block_start = block->start;
+ frame->block_end = block->end;
+ } else {
+ frame->block_start = frame->script->buffer->data;
+ frame->block_end = frame->script->buffer->data + frame->script->buffer->length;
+ }
+ /* only call function after we popped the block, so the block can push a new one */
+ func (frame, data);
+}
+
+/*** FRAME ***/
+
+G_DEFINE_TYPE (SwfdecAsFrame, swfdec_as_frame, SWFDEC_TYPE_AS_OBJECT)
+
+static void
+swfdec_as_frame_dispose (GObject *object)
+{
+ SwfdecAsFrame *frame = SWFDEC_AS_FRAME (object);
+
+ /* pop blocks while state is intact */
+ while (frame->blocks->len > 0)
+ swfdec_as_frame_pop_block (frame);
+
+ /* clean up */
+ g_slice_free1 (sizeof (SwfdecAsValue) * frame->n_registers, frame->registers);
+ if (frame->constant_pool) {
+ swfdec_constant_pool_free (frame->constant_pool);
+ frame->constant_pool = NULL;
+ }
+ if (frame->constant_pool_buffer) {
+ swfdec_buffer_unref (frame->constant_pool_buffer);
+ frame->constant_pool_buffer = NULL;
+ }
+ g_array_free (frame->blocks, TRUE);
+ g_slist_free (frame->scope_chain);
+ if (frame->script) {
+ swfdec_script_unref (frame->script);
+ frame->script = NULL;
+ }
+
+ G_OBJECT_CLASS (swfdec_as_frame_parent_class)->dispose (object);
+}
+
+static void
+swfdec_as_frame_mark (SwfdecAsObject *object)
+{
+ SwfdecAsFrame *frame = SWFDEC_AS_FRAME (object);
+ guint i;
+
+ if (frame->next)
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (frame->next));
+ g_slist_foreach (frame->scope_chain, (GFunc) swfdec_as_object_mark, NULL);
+ if (frame->thisp)
+ swfdec_as_object_mark (frame->thisp);
+ if (frame->super)
+ swfdec_as_object_mark (frame->super);
+ swfdec_as_object_mark (frame->target);
+ swfdec_as_object_mark (frame->original_target);
+ if (frame->function)
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (frame->function));
+ for (i = 0; i < frame->n_registers; i++) {
+ swfdec_as_value_mark (&frame->registers[i]);
+ }
+ /* don't mark argv, it's const, others have to take care of it */
+ SWFDEC_AS_OBJECT_CLASS (swfdec_as_frame_parent_class)->mark (object);
+}
+
+static char *
+swfdec_as_frame_debug (SwfdecAsObject *object)
+{
+ SwfdecAsFrame *frame = SWFDEC_AS_FRAME (object);
+ GString *string = g_string_new ("");
+ SwfdecAsStackIterator iter;
+ SwfdecAsValue *val;
+ char *s;
+ guint i;
+
+ if (frame->thisp) {
+ s = swfdec_as_object_get_debug (frame->thisp);
+ g_string_append (string, s);
+ g_string_append (string, ".");
+ g_free (s);
+ }
+ g_string_append (string, frame->function_name);
+ g_string_append (string, " (");
+ i = 0;
+ for (val = swfdec_as_stack_iterator_init_arguments (&iter, frame); val && i < 4;
+ val = swfdec_as_stack_iterator_next (&iter)) {
+ if (i > 0)
+ g_string_append (string, ", ");
+ i++;
+ if (i == 3 && frame->argc > 4) {
+ g_string_append (string, "...");
+ } else {
+ s = swfdec_as_value_to_debug (val);
+ g_string_append (string, s);
+ g_free (s);
+ }
+ }
+ g_string_append (string, ")");
+ return g_string_free (string, FALSE);
+}
+
+static void
+swfdec_as_frame_class_init (SwfdecAsFrameClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
+
+ object_class->dispose = swfdec_as_frame_dispose;
+
+ asobject_class->mark = swfdec_as_frame_mark;
+ asobject_class->debug = swfdec_as_frame_debug;
+}
+
+static void
+swfdec_as_frame_init (SwfdecAsFrame *frame)
+{
+ frame->function_name = "unnamed";
+ frame->blocks = g_array_new (FALSE, FALSE, sizeof (SwfdecAsFrameBlock));
+ frame->block_end = (gpointer) -1;
+}
+
+static void
+swfdec_as_frame_load (SwfdecAsFrame *frame)
+{
+ SwfdecAsContext *context = SWFDEC_AS_OBJECT (frame)->context;
+
+ frame->stack_begin = context->cur;
+ context->base = frame->stack_begin;
+ frame->next = context->frame;
+ context->frame = frame;
+ context->call_depth++;
+}
+
+SwfdecAsFrame *
+swfdec_as_frame_new (SwfdecAsContext *context, SwfdecScript *script)
+{
+ SwfdecAsFrame *frame;
+ gsize size;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
+ g_return_val_if_fail (script != NULL, NULL);
+
+ size = sizeof (SwfdecAsFrame) + sizeof (SwfdecAsValue) * script->n_registers;
+ if (!swfdec_as_context_use_mem (context, size))
+ return NULL;
+ frame = g_object_new (SWFDEC_TYPE_AS_FRAME, NULL);
+ swfdec_as_object_add (SWFDEC_AS_OBJECT (frame), context, size);
+ frame->script = swfdec_script_ref (script);
+ frame->function_name = script->name;
+ SWFDEC_DEBUG ("new frame for function %s", frame->function_name);
+ frame->pc = script->main;
+ frame->scope_chain = g_slist_prepend (frame->scope_chain, frame);
+ frame->n_registers = script->n_registers;
+ frame->registers = g_slice_alloc0 (sizeof (SwfdecAsValue) * frame->n_registers);
+ if (script->constant_pool) {
+ frame->constant_pool_buffer = swfdec_buffer_ref (script->constant_pool);
+ frame->constant_pool = swfdec_constant_pool_new_from_action (
+ script->constant_pool->data, script->constant_pool->length, script->version);
+ if (frame->constant_pool) {
+ swfdec_constant_pool_attach_to_context (frame->constant_pool, context);
+ } else {
+ SWFDEC_ERROR ("couldn't create constant pool");
+ }
+ }
+ swfdec_as_frame_load (frame);
+ return frame;
+}
+
+SwfdecAsFrame *
+swfdec_as_frame_new_native (SwfdecAsContext *context)
+{
+ SwfdecAsFrame *frame;
+ gsize size;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
+
+ size = sizeof (SwfdecAsFrame);
+ if (!swfdec_as_context_use_mem (context, size))
+ return NULL;
+ frame = g_object_new (SWFDEC_TYPE_AS_FRAME, NULL);
+ SWFDEC_DEBUG ("new native frame");
+ swfdec_as_object_add (SWFDEC_AS_OBJECT (frame), context, size);
+ swfdec_as_frame_load (frame);
+ return frame;
+}
+
+/**
+ * swfdec_as_frame_return:
+ * @frame: a #SwfdecAsFrame that is currently executing.
+ * @return_value: return value of the function or %NULL for none. An undefined
+ * value will be used in that case.
+ *
+ * Ends execution of the frame and instructs the frame's context to continue
+ * execution with its parent frame. This function may only be called on the
+ * currently executing frame.
+ **/
+void
+swfdec_as_frame_return (SwfdecAsFrame *frame, SwfdecAsValue *return_value)
+{
+ SwfdecAsContext *context;
+ SwfdecAsValue retval;
+ SwfdecAsFrame *next;
+
+ g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+ context = SWFDEC_AS_OBJECT (frame)->context;
+ g_return_if_fail (frame == context->frame);
+
+ /* save return value in case it was on the stack somewhere */
+ if (frame->construct) {
+ SWFDEC_AS_VALUE_SET_OBJECT (&retval, frame->thisp);
+ } else if (return_value) {
+ retval = *return_value;
+ } else {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (&retval);
+ }
+ /* pop frame and leftover stack */
+ next = frame->next;
+ context->frame = next;
+ g_assert (context->call_depth > 0);
+ context->call_depth--;
+ while (context->base > frame->stack_begin ||
+ context->end < frame->stack_begin)
+ swfdec_as_stack_pop_segment (context);
+ context->cur = frame->stack_begin;
+ /* setup stack for previous frame */
+ if (next) {
+ if (next->stack_begin >= &context->stack->elements[0] &&
+ next->stack_begin <= context->cur) {
+ context->base = next->stack_begin;
+ } else {
+ context->base = &context->stack->elements[0];
+ }
+ } else {
+ g_assert (context->stack->next == NULL);
+ context->base = &context->stack->elements[0];
+ }
+ /* pop argv if on stack */
+ if (frame->argv == NULL && frame->argc > 0) {
+ guint i = frame->argc;
+ while (TRUE) {
+ guint n = context->cur - context->base;
+ n = MIN (n, i);
+ swfdec_as_stack_pop_n (context, n);
+ i -= n;
+ if (i == 0)
+ break;
+ swfdec_as_stack_pop_segment (context);
+ }
+ }
+ if (context->debugger) {
+ SwfdecAsDebuggerClass *klass = SWFDEC_AS_DEBUGGER_GET_CLASS (context->debugger);
+
+ if (klass->leave_frame)
+ klass->leave_frame (context->debugger, context, frame, &retval);
+ }
+ /* set return value */
+ if (frame->return_value) {
+ *frame->return_value = retval;
+ } else {
+ swfdec_as_stack_ensure_free (context, 1);
+ *swfdec_as_stack_push (context) = retval;
+ }
+}
+
+/**
+ * swfdec_as_frame_set_this:
+ * @frame: a #SwfdecAsFrame
+ * @thisp: object to use as the this object
+ *
+ * Sets the object to be used as this pointer. If this function is not called,
+ * the this value will be undefined.
+ * You may only call this function once per @frame and it must be called
+ * directly after creating the frame and before calling swfdec_as_frame_preload().
+ **/
+void
+swfdec_as_frame_set_this (SwfdecAsFrame *frame, SwfdecAsObject *thisp)
+{
+ g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+ g_return_if_fail (frame->thisp == NULL);
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (thisp));
+
+ g_assert (!SWFDEC_IS_AS_SUPER (thisp));
+ frame->thisp = thisp;
+ if (frame->target == NULL) {
+ frame->target = thisp;
+ frame->original_target = thisp;
+ }
+}
+
+/**
+ * swfdec_as_frame_get_variable_and_flags:
+ * @frame: a #SwfdecAsFrame
+ * @variable: name of the variable
+ * @value: pointer to take value of the variable or %NULL
+ * @flags: pointer to take flags or %NULL
+ * @pobject: pointer to take the actual object that held the variable or %NULL
+ *
+ * Walks the scope chain of @frame trying to resolve the given @variable and if
+ * found, returns its value and flags. Note that there might be a difference
+ * between @pobject and the returned object, since the returned object will be
+ * part of the scope chain while @pobject will contain the actual property. It
+ * will be a prototype of the returned object though.
+ *
+ * Returns: Object in scope chain that contained the variable.
+ **/
+SwfdecAsObject *
+swfdec_as_frame_get_variable_and_flags (SwfdecAsFrame *frame, const char *variable,
+ SwfdecAsValue *value, guint *flags, SwfdecAsObject **pobject)
+{
+ GSList *walk;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
+ g_return_val_if_fail (variable != NULL, NULL);
+
+ for (walk = frame->scope_chain; walk; walk = walk->next) {
+ if (swfdec_as_object_get_variable_and_flags (walk->data, variable, value,
+ flags, pobject))
+ return walk->data;
+ }
+ /* we've walked the scope chain down. Now look in the special objects. */
+ /* 1) the target */
+ if (swfdec_as_object_get_variable_and_flags (frame->target, variable, value,
+ flags, pobject))
+ return frame->target;
+ /* 2) the global object */
+ if (swfdec_as_object_get_variable_and_flags (
+ SWFDEC_AS_OBJECT (frame)->context->global, variable, value, flags, pobject))
+ return SWFDEC_AS_OBJECT (frame)->context->global;
+
+ return NULL;
+}
+
+void
+swfdec_as_frame_set_variable_and_flags (SwfdecAsFrame *frame, const char *variable,
+ const SwfdecAsValue *value, guint default_flags)
+{
+ SwfdecAsObject *pobject, *set;
+ GSList *walk;
+
+ g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+ g_return_if_fail (variable != NULL);
+
+ set = NULL;
+ for (walk = frame->scope_chain; walk; walk = walk->next) {
+ if (swfdec_as_object_get_variable_and_flags (walk->data, variable, NULL, NULL, &pobject) &&
+ pobject == walk->data) {
+ set = walk->data;
+ break;
+ }
+ }
+ if (set == NULL)
+ set = frame->target;
+
+ swfdec_as_object_set_variable_and_flags (set, variable, value, default_flags);
+}
+
+SwfdecAsDeleteReturn
+swfdec_as_frame_delete_variable (SwfdecAsFrame *frame, const char *variable)
+{
+ GSList *walk;
+ SwfdecAsDeleteReturn ret;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), FALSE);
+ g_return_val_if_fail (variable != NULL, FALSE);
+
+ for (walk = frame->scope_chain; walk; walk = walk->next) {
+ ret = swfdec_as_object_delete_variable (walk->data, variable);
+ if (ret)
+ return ret;
+ }
+ /* we've walked the scope chain down. Now look in the special objects. */
+ /* 1) the target set via SetTarget */
+ ret = swfdec_as_object_delete_variable (frame->target, variable);
+ if (ret)
+ return ret;
+ /* 2) the global object */
+ return swfdec_as_object_delete_variable (SWFDEC_AS_OBJECT (frame)->context->global, variable);
+}
+
+/**
+ * swfdec_as_frame_set_target:
+ * @frame: a #SwfdecAsFrame
+ * @target: the new object to use as target or %NULL to unset
+ *
+ * Sets the new target to be used in this @frame. The target is a legacy
+ * Actionscript concept that is similar to "with". If you don't have to,
+ * you shouldn't use this function.
+ **/
+void
+swfdec_as_frame_set_target (SwfdecAsFrame *frame, SwfdecAsObject *target)
+{
+ g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+ g_return_if_fail (target == NULL || SWFDEC_IS_AS_OBJECT (target));
+
+ if (target) {
+ frame->target = target;
+ } else {
+ frame->target = frame->original_target;
+ }
+}
+
+void
+swfdec_as_frame_preload (SwfdecAsFrame *frame)
+{
+ SwfdecAsObject *object, *args;
+ guint i, current_reg = 1;
+ SwfdecScript *script;
+ SwfdecAsValue val;
+ const SwfdecAsValue *cur;
+ SwfdecAsContext *context;
+ SwfdecAsStackIterator iter;
+
+ g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+
+
+ /* setup */
+ object = SWFDEC_AS_OBJECT (frame);
+ context = object->context;
+ script = frame->script;
+ if (frame->script == NULL)
+ goto out;
+
+ /* create arguments and super object if necessary */
+ if ((script->flags & (SWFDEC_SCRIPT_PRELOAD_ARGS | SWFDEC_SCRIPT_SUPPRESS_ARGS)) != SWFDEC_SCRIPT_SUPPRESS_ARGS) {
+ SwfdecAsFrame *next;
+ args = swfdec_as_array_new (context);
+ if (!args)
+ goto out;
+ for (cur = swfdec_as_stack_iterator_init_arguments (&iter, frame); cur != NULL;
+ cur = swfdec_as_stack_iterator_next (&iter)) {
+ swfdec_as_array_push (SWFDEC_AS_ARRAY (args), cur);
+ }
+
+ next = frame->next;
+ while (next != NULL && (next->function == NULL ||
+ SWFDEC_IS_AS_NATIVE_FUNCTION (next->function))) {
+ next = next->next;
+ }
+ if (next != NULL) {
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (next->function));
+ } else {
+ SWFDEC_AS_VALUE_SET_NULL (&val);
+ }
+ swfdec_as_object_set_variable (args, SWFDEC_AS_STR_caller, &val);
+
+ if (frame->function != NULL) {
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (frame->function));
+ } else {
+ SWFDEC_AS_VALUE_SET_NULL (&val);
+ }
+ swfdec_as_object_set_variable (args, SWFDEC_AS_STR_callee, &val);
+ } else {
+ /* silence gcc */
+ args = NULL;
+ }
+
+ /* set the default variables (unless suppressed */
+ if (!(script->flags & SWFDEC_SCRIPT_SUPPRESS_THIS)) {
+ if (frame->thisp) {
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, frame->thisp);
+ } else {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (&val);
+ }
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_this, &val);
+ }
+ if (!(script->flags & SWFDEC_SCRIPT_SUPPRESS_ARGS)) {
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, args);
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_arguments, &val);
+ }
+ if (!(script->flags & SWFDEC_SCRIPT_SUPPRESS_SUPER)) {
+ if (frame->super) {
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, frame->super);
+ } else {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (&val);
+ }
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_super, &val);
+ }
+
+ /* set and preload argument variables */
+ SWFDEC_AS_VALUE_SET_UNDEFINED (&val);
+ cur = swfdec_as_stack_iterator_init_arguments (&iter, frame);
+ for (i = 0; i < script->n_arguments; i++) {
+ if (cur == NULL)
+ cur = &val;
+ /* set this value at the right place */
+ if (script->arguments[i].preload) {
+ if (script->arguments[i].preload < frame->n_registers) {
+ frame->registers[script->arguments[i].preload] = *cur;
+ } else {
+ SWFDEC_ERROR ("trying to set %uth argument %s in nonexisting register %u",
+ i, script->arguments[i].name, script->arguments[i].preload);
+ }
+ } else {
+ const char *tmp = swfdec_as_context_get_string (context, script->arguments[i].name);
+ swfdec_as_object_set_variable (object, tmp, cur);
+ }
+ /* get the next argument */
+ cur = swfdec_as_stack_iterator_next (&iter);
+ }
+
+ /* preload from flags */
+ if ((script->flags & (SWFDEC_SCRIPT_PRELOAD_THIS | SWFDEC_SCRIPT_SUPPRESS_THIS)) == SWFDEC_SCRIPT_PRELOAD_THIS
+ && current_reg < script->n_registers) {
+ if (frame->thisp) {
+ SWFDEC_AS_VALUE_SET_OBJECT (&frame->registers[current_reg++], frame->thisp);
+ } else {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (&frame->registers[current_reg++]);
+ }
+ }
+ if (script->flags & SWFDEC_SCRIPT_PRELOAD_ARGS && current_reg < script->n_registers) {
+ SWFDEC_AS_VALUE_SET_OBJECT (&frame->registers[current_reg++], args);
+ }
+ if (script->flags & SWFDEC_SCRIPT_PRELOAD_SUPER && current_reg < script->n_registers) {
+ if (frame->super) {
+ SWFDEC_AS_VALUE_SET_OBJECT (&frame->registers[current_reg++], frame->super);
+ } else {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (&frame->registers[current_reg++]);
+ }
+ }
+ if (script->flags & SWFDEC_SCRIPT_PRELOAD_ROOT && current_reg < script->n_registers) {
+ if (!swfdec_as_frame_get_variable (frame, SWFDEC_AS_STR__root, &frame->registers[current_reg])) {
+ SWFDEC_WARNING ("no root to preload");
+ }
+ current_reg++;
+ }
+ if (script->flags & SWFDEC_SCRIPT_PRELOAD_PARENT && current_reg < script->n_registers) {
+ if (!swfdec_as_frame_get_variable (frame, SWFDEC_AS_STR__parent, &frame->registers[current_reg])) {
+ SWFDEC_WARNING ("no root to preload");
+ }
+ current_reg++;
+ }
+ if (script->flags & SWFDEC_SCRIPT_PRELOAD_GLOBAL && current_reg < script->n_registers) {
+ SWFDEC_AS_VALUE_SET_OBJECT (&frame->registers[current_reg++], context->global);
+ }
+ /* set block boundaries */
+ frame->block_start = frame->script->buffer->data;
+ frame->block_end = frame->script->buffer->data + frame->script->buffer->length;
+
+out:
+ if (context->state == SWFDEC_AS_CONTEXT_ABORTED) {
+ swfdec_as_frame_return (frame, NULL);
+ return;
+ }
+ if (context->debugger) {
+ SwfdecAsDebuggerClass *klass = SWFDEC_AS_DEBUGGER_GET_CLASS (context->debugger);
+
+ if (klass->enter_frame)
+ klass->enter_frame (context->debugger, context, frame);
+ }
+}
+
+void
+swfdec_as_frame_handle_exception (SwfdecAsFrame *frame)
+{
+ SwfdecAsContext *cx;
+
+ g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+ cx = SWFDEC_AS_OBJECT (frame)->context;
+ g_return_if_fail (cx->exception);
+
+ /* pop blocks in the hope that we are inside a Try block */
+ while (cx->exception && frame->blocks->len) {
+ swfdec_as_frame_pop_block (frame);
+ }
+ /* no Try blocks caught it, exit frame */
+ if (cx->exception) {
+ swfdec_as_frame_return (frame, NULL);
+ }
+}
+
+/**
+ * swfdec_as_frame_get_next:
+ * @frame: a #SwfdecAsFrame
+ *
+ * Gets the next frame in the frame stack. The next frame is the frame that
+ * will be executed after this @frame.
+ *
+ * Returns: the next #SwfdecAsFrame or %NULL if this is the bottommost frame.
+ **/
+SwfdecAsFrame *
+swfdec_as_frame_get_next (SwfdecAsFrame *frame)
+{
+ g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
+
+ return frame->next;
+}
+
+/**
+ * swfdec_as_frame_get_function_name:
+ * @frame: a #SwfdecAsFrame
+ *
+ * Gets the name of the function that is currently executing. This function is
+ * intended for debugging purposes.
+ *
+ * Returns: a string. Do not free.
+ **/
+const char *
+swfdec_as_frame_get_function_name (SwfdecAsFrame *frame)
+{
+ g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
+
+ g_assert (frame->function_name);
+ return frame->function_name;
+}
+
+/**
+ * swfdec_as_frame_get_script:
+ * @frame: a #SwfdecAsFrame
+ *
+ * Gets the script associated with the given @frame. If the frame references
+ * a native function, there will be no script and this function returns %NULL.
+ *
+ * Returns: The script executed by this frame or %NULL
+ **/
+SwfdecScript *
+swfdec_as_frame_get_script (SwfdecAsFrame *frame)
+{
+ g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
+
+ return frame->script;
+}
+
+/**
+ * swfdec_as_frame_get_this:
+ * @frame: a #SwfdecAsFrame
+ *
+ * Gets the this object of the given @frame. If the frame has no this object,
+ * %NULL is returned.
+ *
+ * Returns: The this object of the frame or %NULL if none.
+ **/
+SwfdecAsObject *
+swfdec_as_frame_get_this (SwfdecAsFrame *frame)
+{
+ g_return_val_if_fail (SWFDEC_IS_AS_FRAME (frame), NULL);
+
+ return frame->thisp;
+}
+
diff --git a/swfdec/swfdec_as_frame.h b/swfdec/swfdec_as_frame.h
new file mode 100644
index 0000000..344eaa7
--- /dev/null
+++ b/swfdec/swfdec_as_frame.h
@@ -0,0 +1,63 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_FRAME_H_
+#define _SWFDEC_AS_FRAME_H_
+
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_as_types.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecAsFrameClass SwfdecAsFrameClass;
+typedef struct _SwfdecAsStackIterator SwfdecAsStackIterator;
+
+struct _SwfdecAsStackIterator {
+ /*< private >*/
+ SwfdecAsStack * stack;
+ SwfdecAsValue * current;
+ guint i;
+ guint n;
+};
+
+
+#define SWFDEC_TYPE_AS_FRAME (swfdec_as_frame_get_type())
+#define SWFDEC_IS_AS_FRAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_FRAME))
+#define SWFDEC_IS_AS_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_FRAME))
+#define SWFDEC_AS_FRAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_FRAME, SwfdecAsFrame))
+#define SWFDEC_AS_FRAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_FRAME, SwfdecAsFrameClass))
+#define SWFDEC_AS_FRAME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_FRAME, SwfdecAsFrameClass))
+
+GType swfdec_as_frame_get_type (void);
+
+SwfdecAsFrame * swfdec_as_frame_get_next (SwfdecAsFrame * frame);
+const char * swfdec_as_frame_get_function_name (SwfdecAsFrame * frame);
+SwfdecScript * swfdec_as_frame_get_script (SwfdecAsFrame * frame);
+SwfdecAsObject *swfdec_as_frame_get_this (SwfdecAsFrame * frame);
+
+SwfdecAsValue * swfdec_as_stack_iterator_init (SwfdecAsStackIterator * iter,
+ SwfdecAsFrame * frame);
+SwfdecAsValue * swfdec_as_stack_iterator_init_arguments
+ (SwfdecAsStackIterator * iter,
+ SwfdecAsFrame * frame);
+SwfdecAsValue * swfdec_as_stack_iterator_next (SwfdecAsStackIterator * iter);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_as_frame_internal.h b/swfdec/swfdec_as_frame_internal.h
new file mode 100644
index 0000000..866d1fa
--- /dev/null
+++ b/swfdec/swfdec_as_frame_internal.h
@@ -0,0 +1,106 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_FRAME_INTERNAL_H_
+#define _SWFDEC_AS_FRAME_INTERNAL_H_
+
+#include <libswfdec/swfdec_as_types.h>
+#include <libswfdec/swfdec_script_internal.h>
+
+G_BEGIN_DECLS
+
+typedef void (* SwfdecAsFrameBlockFunc) (SwfdecAsFrame *frame, gpointer data);
+
+struct _SwfdecAsFrame {
+ SwfdecAsObject object;
+
+ SwfdecAsFrame * next; /* next frame (FIXME: keep a list in the context instead?) */
+ SwfdecAsFunction * function; /* function we're executing or NULL if toplevel */
+ SwfdecAsObject * thisp; /* this object in current frame or NULL if none */
+ SwfdecAsObject * super; /* super object in current frame or NULL if none */
+ gboolean construct; /* TRUE if this is the constructor for thisp */
+ SwfdecAsValue * return_value; /* pointer to where to store the return value */
+ guint argc; /* number of arguments */
+ const SwfdecAsValue * argv; /* arguments or %NULL if taken from stack */
+ /* debugging */
+ const char * function_name; /* name of function */
+ /* script execution */
+ SwfdecScript * script; /* script being executed */
+ GSList * scope_chain; /* the scope chain (with objects etc) */
+ const guint8 * block_start; /* start of current block */
+ const guint8 * block_end; /* end of current block */
+ GArray * blocks; /* blocks we have entered (like With) */
+ SwfdecAsObject * target; /* target to use as last object in scope chain or for SetVariable */
+ SwfdecAsObject * original_target;/* original target (used when resetting target) */
+ gboolean is_local; /* TRUE if this frame takes local variables */
+ SwfdecAsValue * registers; /* the registers */
+ guint n_registers; /* number of allocated registers */
+ SwfdecConstantPool * constant_pool; /* constant pool currently in use */
+ SwfdecBuffer * constant_pool_buffer; /* buffer containing the raw data for constant_pool */
+ SwfdecAsValue * stack_begin; /* beginning of stack */
+ const guint8 * pc; /* program counter on stack */
+ /* native function */
+};
+
+struct _SwfdecAsFrameClass {
+ SwfdecAsObjectClass object_class;
+};
+
+SwfdecAsFrame * swfdec_as_frame_new (SwfdecAsContext * context,
+ SwfdecScript * script);
+SwfdecAsFrame * swfdec_as_frame_new_native (SwfdecAsContext * context);
+void swfdec_as_frame_return (SwfdecAsFrame * frame,
+ SwfdecAsValue * return_value);
+
+void swfdec_as_frame_set_this (SwfdecAsFrame * frame,
+ SwfdecAsObject * thisp);
+void swfdec_as_frame_preload (SwfdecAsFrame * frame);
+
+#define swfdec_as_frame_get_variable(frame, variable, value) \
+ swfdec_as_frame_get_variable_and_flags (frame, variable, value, NULL, NULL)
+SwfdecAsObject *swfdec_as_frame_get_variable_and_flags
+ (SwfdecAsFrame * frame,
+ const char * variable,
+ SwfdecAsValue * value,
+ guint * flags,
+ SwfdecAsObject ** pobject);
+#define swfdec_as_frame_set_variable(frame, variable, value) \
+ swfdec_as_frame_set_variable_and_flags (frame, variable, value, 0)
+void swfdec_as_frame_set_variable_and_flags
+ (SwfdecAsFrame * frame,
+ const char * variable,
+ const SwfdecAsValue * value,
+ guint default_flags);
+SwfdecAsDeleteReturn
+ swfdec_as_frame_delete_variable (SwfdecAsFrame * frame,
+ const char * variable);
+
+void swfdec_as_frame_set_target (SwfdecAsFrame * frame,
+ SwfdecAsObject * target);
+void swfdec_as_frame_push_block (SwfdecAsFrame * frame,
+ const guint8 * start,
+ const guint8 * end,
+ SwfdecAsFrameBlockFunc func,
+ gpointer data);
+void swfdec_as_frame_pop_block (SwfdecAsFrame * frame);
+void swfdec_as_frame_handle_exception(SwfdecAsFrame * frame);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_as_function.c b/swfdec/swfdec_as_function.c
new file mode 100644
index 0000000..cc0e975
--- /dev/null
+++ b/swfdec/swfdec_as_function.c
@@ -0,0 +1,279 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_function.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_frame_internal.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_stack.h"
+#include "swfdec_as_super.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+
+G_DEFINE_ABSTRACT_TYPE (SwfdecAsFunction, swfdec_as_function, SWFDEC_TYPE_AS_OBJECT)
+
+/**
+ * SECTION:SwfdecAsFunction
+ * @title: SwfdecAsFunction
+ * @short_description: script objects that can be executed
+ *
+ * Functions is the basic object for executing code in the Swfdec script engine.
+ * There is multiple different variants of functions, such as script-created
+ * ones and native functions.
+ *
+ * If you want to create your own functions, you should create native functions.
+ * The easiest way to do this is with swfdec_as_object_add_function() or
+ * swfdec_as_native_function_new().
+ *
+ * In Actionscript, every function can be used as a constructor. If you want to
+ * make a native function be used as a constructor for your own #SwfdecAsObject
+ * subclass, have a look at swfdec_as_native_function_set_construct_type().
+ */
+
+/**
+ * SwfdecAsFunction
+ *
+ * This is the base executable object in Swfdec. It is an abstract object. If
+ * you want to create functions yourself, use #SwfdecAsNativeFunction.
+ */
+
+static void
+swfdec_as_function_class_init (SwfdecAsFunctionClass *klass)
+{
+}
+
+static void
+swfdec_as_function_init (SwfdecAsFunction *function)
+{
+}
+
+/**
+ * swfdec_as_function_set_constructor:
+ * @fun: a #SwfdecAsFunction
+ *
+ * Sets the constructor and prototype of @fun. This is a shortcut for calling
+ * swfdec_as_object_set_constructor() with the right arguments.
+ **/
+void
+swfdec_as_function_set_constructor (SwfdecAsFunction *fun)
+{
+ SwfdecAsContext *context;
+ SwfdecAsObject *object;
+ SwfdecAsValue val;
+
+ g_return_if_fail (SWFDEC_IS_AS_FUNCTION (fun));
+
+ object = SWFDEC_AS_OBJECT (fun);
+ context = object->context;
+ if (context->Function == NULL)
+ return;
+
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Function);
+ swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR_constructor,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Function_prototype);
+ swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR___proto__,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT |
+ SWFDEC_AS_VARIABLE_VERSION_6_UP);
+}
+
+SwfdecAsFrame *
+swfdec_as_function_call_no_preload (SwfdecAsFunction *function,
+ SwfdecAsObject *thisp, guint n_args, const SwfdecAsValue *args,
+ SwfdecAsValue *return_value)
+{
+ SwfdecAsFrame *frame;
+ SwfdecAsFunctionClass *klass;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_FUNCTION (function), NULL);
+ g_return_val_if_fail (thisp == NULL || SWFDEC_IS_AS_OBJECT (thisp), NULL);
+
+ /* just to be sure... */
+ if (return_value)
+ SWFDEC_AS_VALUE_SET_UNDEFINED (return_value);
+
+ klass = SWFDEC_AS_FUNCTION_GET_CLASS (function);
+ g_assert (klass->call);
+ frame = klass->call (function);
+ /* FIXME: figure out what to do in these situations?
+ * It's a problem when called inside swfdec_as_function_call () as the
+ * user of that function expects success, but super may fail here */
+ if (frame == NULL)
+ return NULL;
+ /* second check especially for super object */
+ if (thisp != NULL && frame->thisp == NULL) {
+ swfdec_as_frame_set_this (frame, swfdec_as_object_resolve (thisp));
+ }
+ frame->is_local = TRUE;
+ frame->argc = n_args;
+ frame->argv = args;
+ frame->return_value = return_value;
+ return frame;
+}
+
+/**
+ * swfdec_as_function_call:
+ * @function: the #SwfdecAsFunction to call
+ * @thisp: this argument to use for the call or %NULL for none
+ * @n_args: number of arguments to pass to the function
+ * @args: the arguments to pass or %NULL to read the last @n_args stack elements.
+ * The memory must be unchanged until the function call has completed.
+ * This is after the call to swfdec_as_context_run () has finished.
+ * @return_value: pointer for return value or %NULL to push the return value to
+ * the stack
+ *
+ * Calls the given function. This means a #SwfdecAsFrame is created for the
+ * function and pushed on top of the execution stack. The function is however
+ * not executed. Call swfdec_as_context_run () to execute it.
+ **/
+void
+swfdec_as_function_call (SwfdecAsFunction *function, SwfdecAsObject *thisp, guint n_args,
+ const SwfdecAsValue *args, SwfdecAsValue *return_value)
+{
+ SwfdecAsFrame *frame;
+
+ g_return_if_fail (SWFDEC_IS_AS_FUNCTION (function));
+ g_return_if_fail (thisp == NULL || SWFDEC_IS_AS_OBJECT (thisp));
+
+ frame = swfdec_as_function_call_no_preload (function, thisp, n_args, args, return_value);
+ if (frame == NULL)
+ return;
+ if (thisp != NULL) {
+ swfdec_as_super_new (frame, thisp, thisp->prototype);
+ } else {
+ SWFDEC_FIXME ("does the super object really reference the function when thisp is NULL?");
+ swfdec_as_super_new (frame, SWFDEC_AS_OBJECT (function), SWFDEC_AS_OBJECT (function)->prototype);
+ }
+ swfdec_as_frame_preload (frame);
+}
+
+/*** AS CODE ***/
+
+SWFDEC_AS_NATIVE (101, 10, swfdec_as_function_do_call)
+void
+swfdec_as_function_do_call (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecAsFunction *fun;
+ SwfdecAsObject *thisp;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_FUNCTION, &fun, "|O", &thisp);
+
+ if (thisp == NULL) {
+ thisp = swfdec_as_object_new_empty (cx);
+ if (thisp == NULL)
+ return;
+ }
+ if (argc > 0) {
+ argc--;
+ argv++;
+ }
+ swfdec_as_function_call (fun, thisp, argc, argv, ret);
+ swfdec_as_context_run (cx);
+}
+
+SWFDEC_AS_NATIVE (101, 11, swfdec_as_function_apply)
+void
+swfdec_as_function_apply (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecAsValue *argv_pass = NULL;
+ int length = 0;
+ SwfdecAsFunction *fun;
+ SwfdecAsObject *thisp;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_FUNCTION, &fun, "|O", &thisp);
+
+ if (thisp == NULL) {
+ thisp = swfdec_as_object_new_empty (cx);
+ if (thisp == NULL)
+ return;
+ }
+
+ if (argc > 1 && SWFDEC_AS_VALUE_IS_OBJECT (&argv[1])) {
+ int i;
+ SwfdecAsObject *array;
+ SwfdecAsValue val;
+
+ array = SWFDEC_AS_VALUE_GET_OBJECT (&argv[1]);
+
+ swfdec_as_object_get_variable (array, SWFDEC_AS_STR_length, &val);
+ length = swfdec_as_value_to_integer (cx, &val);
+
+ if (length > 0) {
+ /* FIXME: find a smarter way to do this, like providing argv not as an array */
+ if (!swfdec_as_context_use_mem (cx, sizeof (SwfdecAsValue) * length))
+ return;
+ argv_pass = g_malloc (sizeof (SwfdecAsValue) * length);
+
+ for (i = 0; i < length; i++) {
+ swfdec_as_object_get_variable (array,
+ swfdec_as_integer_to_string (cx, i), &argv_pass[i]);
+ }
+ } else {
+ length = 0;
+ }
+ }
+
+ swfdec_as_function_call (fun, thisp, length, argv_pass, ret);
+ swfdec_as_context_run (cx);
+
+ if (argv_pass) {
+ swfdec_as_context_unuse_mem (cx, sizeof (SwfdecAsValue) * length);
+ g_free (argv_pass);
+ }
+}
+
+void
+swfdec_as_function_init_context (SwfdecAsContext *context)
+{
+ SwfdecAsObject *function, *proto;
+ SwfdecAsValue val;
+
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
+
+ function = SWFDEC_AS_OBJECT (swfdec_as_object_add_function (context->global,
+ SWFDEC_AS_STR_Function, 0, NULL, 0));
+ if (!function)
+ return;
+ swfdec_as_object_set_variable_flags (context->global, SWFDEC_AS_STR_Function, SWFDEC_AS_VARIABLE_VERSION_6_UP);
+ context->Function = function;
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, function);
+ swfdec_as_object_set_variable_and_flags (function, SWFDEC_AS_STR_constructor,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+ proto = swfdec_as_object_new_empty (context);
+ if (!proto)
+ return;
+ context->Function_prototype = proto;
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
+ swfdec_as_object_set_variable_and_flags (function, SWFDEC_AS_STR_prototype,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+ swfdec_as_object_set_variable_and_flags (function, SWFDEC_AS_STR___proto__,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT |
+ SWFDEC_AS_VARIABLE_VERSION_6_UP);
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, function);
+ swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+}
+
diff --git a/swfdec/swfdec_as_function.h b/swfdec/swfdec_as_function.h
new file mode 100644
index 0000000..534aad5
--- /dev/null
+++ b/swfdec/swfdec_as_function.h
@@ -0,0 +1,61 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_FUNCTION_H_
+#define _SWFDEC_AS_FUNCTION_H_
+
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_as_types.h>
+#include <libswfdec/swfdec_script.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecAsFunctionClass SwfdecAsFunctionClass;
+
+#define SWFDEC_TYPE_AS_FUNCTION (swfdec_as_function_get_type())
+#define SWFDEC_IS_AS_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_FUNCTION))
+#define SWFDEC_IS_AS_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_FUNCTION))
+#define SWFDEC_AS_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_FUNCTION, SwfdecAsFunction))
+#define SWFDEC_AS_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_FUNCTION, SwfdecAsFunctionClass))
+#define SWFDEC_AS_FUNCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_FUNCTION, SwfdecAsFunctionClass))
+
+/* FIXME: do two obejcts, one for scripts and one for native? */
+struct _SwfdecAsFunction {
+ /*< private >*/
+ SwfdecAsObject object;
+};
+
+struct _SwfdecAsFunctionClass {
+ SwfdecAsObjectClass object_class;
+
+ /* return a frame that calls this function or NULL if uncallable */
+ SwfdecAsFrame * (* call) (SwfdecAsFunction * function);
+};
+
+GType swfdec_as_function_get_type (void);
+
+void swfdec_as_function_call (SwfdecAsFunction * function,
+ SwfdecAsObject * thisp,
+ guint n_args,
+ const SwfdecAsValue * args,
+ SwfdecAsValue * return_value);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_as_initialize.as b/swfdec/swfdec_as_initialize.as
new file mode 100644
index 0000000..4e60ec2
--- /dev/null
+++ b/swfdec/swfdec_as_initialize.as
@@ -0,0 +1,100 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+/*** GENERAL ***/
+
+ASSetPropFlags = ASnative (1, 0);
+ASSetNative = ASnative (4, 0);
+ASSetNativeAccessor = ASnative (4, 1);
+
+/*** BASE OBJECTS ***/
+
+ASSetNative (Object.constructor.prototype, 101, "6call,6apply", 10);
+ASSetPropFlags (Object.constructor.prototype, null, 3);
+
+ASSetNative(Object.prototype, 101, "6watch,6unwatch,6addProperty,valueOf,toString,6hasOwnProperty,6isPrototypeOf,6isPropertyEnumerable");
+Object.prototype.toLocaleString = function () {
+ return this.toString ();
+};
+ASSetPropFlags (Object.prototype, null, 3);
+ASSetPropFlags (Object, null, 7);
+
+Boolean = ASconstructor(107, 2);
+ASSetNative(Boolean.prototype, 107, "valueOf,toString");
+ASSetPropFlags(Boolean.prototype, null, 3);
+
+Number = ASconstructor (106, 2);
+ASSetNative (Number.prototype, 106, "valueOf,toString");
+ASSetPropFlags(Number.prototype, null, 3);
+Number.NaN = NaN;
+Number.POSITIVE_INFINITY = Infinity;
+Number.NEGATIVE_INFINITY = -Infinity;
+Number.MIN_VALUE = 4.94065645841247e-324;
+Number.MAX_VALUE = 1.79769313486231e+308;
+ASSetPropFlags(Number, null, 7);
+
+String = ASconstructor(251, 0);
+ASSetNative(String.prototype, 251, "valueOf,toString,toUpperCase,toLowerCase,charAt,charCodeAt,concat,indexOf,lastIndexOf,slice,substring,split,substr", 1);
+ASSetPropFlags(String.prototype, null, 3);
+String.fromCharCode = ASnative(251, 14);
+ASSetPropFlags(String, null, 3);
+
+Math = {
+ E: 2.71828182845905,
+ LN10: 2.30258509299405,
+ LN2: 0.693147180559945,
+ LOG10E: 0.434294481903252,
+ LOG2E: 1.44269504088896,
+ PI: 3.14159265358979,
+ SQRT1_2: 0.707106781186548,
+ SQRT2: 1.4142135623731
+};
+ASSetNative (Math, 200, "abs,min,max,sin,cos,atan2,tan,exp,log,sqrt,round,random,floor,ceil,atan,asin,acos,pow");
+ASSetPropFlags (Math, null, 7);
+
+Date = ASconstructor (103, 256);
+ASSetNative (Date.prototype, 103, "getFullYear,getYear,getMonth,getDate,getDay,getHours,getMinutes,getSeconds,getMilliseconds,setFullYear,setMonth,setDate,setHours,setMinutes,setSeconds,setMilliseconds,getTime,setTime,getTimezoneOffset,toString,setYear");
+ASSetNative (Date.prototype, 103, "getUTCFullYear,getUTCYear,getUTCMonth,getUTCDate,getUTCDay,getUTCHours,getUTCMinutes,getUTCSeconds,getUTCMilliseconds,setUTCFullYear,setUTCMonth,setUTCDate,setUTCHours,setUTCMinutes,setUTCSeconds,setUTCMilliseconds", 128);
+Date.prototype.valueOf = Date.prototype.getTime;
+Date.UTC = ASnative (103, 257);
+ASSetPropFlags (Date.prototype, null, 3);
+ASSetPropFlags (Date, null, 7);
+
+Array = ASconstructor (252, 0);
+ASSetNative (Array.prototype, 252, "push,pop,concat,shift,unshift,slice,join,splice,toString,sort,reverse,sortOn", 1);
+ASSetPropFlags (Array.prototype, null, 3);
+Array.CASEINSENSITIVE = 1;
+Array.DESCENDING = 2;
+Array.UNIQUESORT = 4;
+Array.RETURNINDEXEDARRAY = 8;
+Array.NUMERIC = 16;
+
+/* GLOBAL FUNCTIONS */
+
+escape = ASnative (100, 0);
+unescape = ASnative (100, 1);
+parseInt = ASnative (100, 2);
+parseFloat = ASnative (100, 3);
+isNaN = ASnative (200, 18);
+isFinite = ASnative (200, 19);
+
+/*** GLOBAL PROPFLAGS */
+
+ASSetPropFlags (this, null, 1, 6);
diff --git a/swfdec/swfdec_as_initialize.h b/swfdec/swfdec_as_initialize.h
new file mode 100644
index 0000000..2fbca42
--- /dev/null
+++ b/swfdec/swfdec_as_initialize.h
@@ -0,0 +1,175 @@
+/* This file is autogenerated, do not edit! */
+
+/* compiled from swfdec_as_initialize.as */
+static const unsigned char swfdec_as_initialize[] = {
+ 0x88, 0xF3, 0x04, 0x36, 0x00, 0x41, 0x53, 0x53, 0x65, 0x74, 0x50, 0x72, 0x6F, 0x70, 0x46, 0x6C,
+ 0x61, 0x67, 0x73, 0x00, 0x41, 0x53, 0x6E, 0x61, 0x74, 0x69, 0x76, 0x65, 0x00, 0x41, 0x53, 0x53,
+ 0x65, 0x74, 0x4E, 0x61, 0x74, 0x69, 0x76, 0x65, 0x00, 0x41, 0x53, 0x53, 0x65, 0x74, 0x4E, 0x61,
+ 0x74, 0x69, 0x76, 0x65, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x6F, 0x72, 0x00, 0x4F, 0x62, 0x6A,
+ 0x65, 0x63, 0x74, 0x00, 0x63, 0x6F, 0x6E, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x6F, 0x72, 0x00,
+ 0x70, 0x72, 0x6F, 0x74, 0x6F, 0x74, 0x79, 0x70, 0x65, 0x00, 0x36, 0x63, 0x61, 0x6C, 0x6C, 0x2C,
+ 0x36, 0x61, 0x70, 0x70, 0x6C, 0x79, 0x00, 0x36, 0x77, 0x61, 0x74, 0x63, 0x68, 0x2C, 0x36, 0x75,
+ 0x6E, 0x77, 0x61, 0x74, 0x63, 0x68, 0x2C, 0x36, 0x61, 0x64, 0x64, 0x50, 0x72, 0x6F, 0x70, 0x65,
+ 0x72, 0x74, 0x79, 0x2C, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x4F, 0x66, 0x2C, 0x74, 0x6F, 0x53, 0x74,
+ 0x72, 0x69, 0x6E, 0x67, 0x2C, 0x36, 0x68, 0x61, 0x73, 0x4F, 0x77, 0x6E, 0x50, 0x72, 0x6F, 0x70,
+ 0x65, 0x72, 0x74, 0x79, 0x2C, 0x36, 0x69, 0x73, 0x50, 0x72, 0x6F, 0x74, 0x6F, 0x74, 0x79, 0x70,
+ 0x65, 0x4F, 0x66, 0x2C, 0x36, 0x69, 0x73, 0x50, 0x72, 0x6F, 0x70, 0x65, 0x72, 0x74, 0x79, 0x45,
+ 0x6E, 0x75, 0x6D, 0x65, 0x72, 0x61, 0x62, 0x6C, 0x65, 0x00, 0x74, 0x6F, 0x4C, 0x6F, 0x63, 0x61,
+ 0x6C, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x74, 0x68, 0x69, 0x73, 0x00, 0x74, 0x6F,
+ 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x42, 0x6F, 0x6F, 0x6C, 0x65, 0x61, 0x6E, 0x00, 0x41,
+ 0x53, 0x63, 0x6F, 0x6E, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x6F, 0x72, 0x00, 0x76, 0x61, 0x6C,
+ 0x75, 0x65, 0x4F, 0x66, 0x2C, 0x74, 0x6F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x4E, 0x75,
+ 0x6D, 0x62, 0x65, 0x72, 0x00, 0x4E, 0x61, 0x4E, 0x00, 0x50, 0x4F, 0x53, 0x49, 0x54, 0x49, 0x56,
+ 0x45, 0x5F, 0x49, 0x4E, 0x46, 0x49, 0x4E, 0x49, 0x54, 0x59, 0x00, 0x49, 0x6E, 0x66, 0x69, 0x6E,
+ 0x69, 0x74, 0x79, 0x00, 0x4E, 0x45, 0x47, 0x41, 0x54, 0x49, 0x56, 0x45, 0x5F, 0x49, 0x4E, 0x46,
+ 0x49, 0x4E, 0x49, 0x54, 0x59, 0x00, 0x4D, 0x49, 0x4E, 0x5F, 0x56, 0x41, 0x4C, 0x55, 0x45, 0x00,
+ 0x4D, 0x41, 0x58, 0x5F, 0x56, 0x41, 0x4C, 0x55, 0x45, 0x00, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67,
+ 0x00, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x4F, 0x66, 0x2C, 0x74, 0x6F, 0x53, 0x74, 0x72, 0x69, 0x6E,
+ 0x67, 0x2C, 0x74, 0x6F, 0x55, 0x70, 0x70, 0x65, 0x72, 0x43, 0x61, 0x73, 0x65, 0x2C, 0x74, 0x6F,
+ 0x4C, 0x6F, 0x77, 0x65, 0x72, 0x43, 0x61, 0x73, 0x65, 0x2C, 0x63, 0x68, 0x61, 0x72, 0x41, 0x74,
+ 0x2C, 0x63, 0x68, 0x61, 0x72, 0x43, 0x6F, 0x64, 0x65, 0x41, 0x74, 0x2C, 0x63, 0x6F, 0x6E, 0x63,
+ 0x61, 0x74, 0x2C, 0x69, 0x6E, 0x64, 0x65, 0x78, 0x4F, 0x66, 0x2C, 0x6C, 0x61, 0x73, 0x74, 0x49,
+ 0x6E, 0x64, 0x65, 0x78, 0x4F, 0x66, 0x2C, 0x73, 0x6C, 0x69, 0x63, 0x65, 0x2C, 0x73, 0x75, 0x62,
+ 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x2C, 0x73, 0x70, 0x6C, 0x69, 0x74, 0x2C, 0x73, 0x75, 0x62,
+ 0x73, 0x74, 0x72, 0x00, 0x66, 0x72, 0x6F, 0x6D, 0x43, 0x68, 0x61, 0x72, 0x43, 0x6F, 0x64, 0x65,
+ 0x00, 0x4D, 0x61, 0x74, 0x68, 0x00, 0x45, 0x00, 0x4C, 0x4E, 0x31, 0x30, 0x00, 0x4C, 0x4E, 0x32,
+ 0x00, 0x4C, 0x4F, 0x47, 0x31, 0x30, 0x45, 0x00, 0x4C, 0x4F, 0x47, 0x32, 0x45, 0x00, 0x50, 0x49,
+ 0x00, 0x53, 0x51, 0x52, 0x54, 0x31, 0x5F, 0x32, 0x00, 0x53, 0x51, 0x52, 0x54, 0x32, 0x00, 0x61,
+ 0x62, 0x73, 0x2C, 0x6D, 0x69, 0x6E, 0x2C, 0x6D, 0x61, 0x78, 0x2C, 0x73, 0x69, 0x6E, 0x2C, 0x63,
+ 0x6F, 0x73, 0x2C, 0x61, 0x74, 0x61, 0x6E, 0x32, 0x2C, 0x74, 0x61, 0x6E, 0x2C, 0x65, 0x78, 0x70,
+ 0x2C, 0x6C, 0x6F, 0x67, 0x2C, 0x73, 0x71, 0x72, 0x74, 0x2C, 0x72, 0x6F, 0x75, 0x6E, 0x64, 0x2C,
+ 0x72, 0x61, 0x6E, 0x64, 0x6F, 0x6D, 0x2C, 0x66, 0x6C, 0x6F, 0x6F, 0x72, 0x2C, 0x63, 0x65, 0x69,
+ 0x6C, 0x2C, 0x61, 0x74, 0x61, 0x6E, 0x2C, 0x61, 0x73, 0x69, 0x6E, 0x2C, 0x61, 0x63, 0x6F, 0x73,
+ 0x2C, 0x70, 0x6F, 0x77, 0x00, 0x44, 0x61, 0x74, 0x65, 0x00, 0x67, 0x65, 0x74, 0x46, 0x75, 0x6C,
+ 0x6C, 0x59, 0x65, 0x61, 0x72, 0x2C, 0x67, 0x65, 0x74, 0x59, 0x65, 0x61, 0x72, 0x2C, 0x67, 0x65,
+ 0x74, 0x4D, 0x6F, 0x6E, 0x74, 0x68, 0x2C, 0x67, 0x65, 0x74, 0x44, 0x61, 0x74, 0x65, 0x2C, 0x67,
+ 0x65, 0x74, 0x44, 0x61, 0x79, 0x2C, 0x67, 0x65, 0x74, 0x48, 0x6F, 0x75, 0x72, 0x73, 0x2C, 0x67,
+ 0x65, 0x74, 0x4D, 0x69, 0x6E, 0x75, 0x74, 0x65, 0x73, 0x2C, 0x67, 0x65, 0x74, 0x53, 0x65, 0x63,
+ 0x6F, 0x6E, 0x64, 0x73, 0x2C, 0x67, 0x65, 0x74, 0x4D, 0x69, 0x6C, 0x6C, 0x69, 0x73, 0x65, 0x63,
+ 0x6F, 0x6E, 0x64, 0x73, 0x2C, 0x73, 0x65, 0x74, 0x46, 0x75, 0x6C, 0x6C, 0x59, 0x65, 0x61, 0x72,
+ 0x2C, 0x73, 0x65, 0x74, 0x4D, 0x6F, 0x6E, 0x74, 0x68, 0x2C, 0x73, 0x65, 0x74, 0x44, 0x61, 0x74,
+ 0x65, 0x2C, 0x73, 0x65, 0x74, 0x48, 0x6F, 0x75, 0x72, 0x73, 0x2C, 0x73, 0x65, 0x74, 0x4D, 0x69,
+ 0x6E, 0x75, 0x74, 0x65, 0x73, 0x2C, 0x73, 0x65, 0x74, 0x53, 0x65, 0x63, 0x6F, 0x6E, 0x64, 0x73,
+ 0x2C, 0x73, 0x65, 0x74, 0x4D, 0x69, 0x6C, 0x6C, 0x69, 0x73, 0x65, 0x63, 0x6F, 0x6E, 0x64, 0x73,
+ 0x2C, 0x67, 0x65, 0x74, 0x54, 0x69, 0x6D, 0x65, 0x2C, 0x73, 0x65, 0x74, 0x54, 0x69, 0x6D, 0x65,
+ 0x2C, 0x67, 0x65, 0x74, 0x54, 0x69, 0x6D, 0x65, 0x7A, 0x6F, 0x6E, 0x65, 0x4F, 0x66, 0x66, 0x73,
+ 0x65, 0x74, 0x2C, 0x74, 0x6F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x2C, 0x73, 0x65, 0x74, 0x59,
+ 0x65, 0x61, 0x72, 0x00, 0x67, 0x65, 0x74, 0x55, 0x54, 0x43, 0x46, 0x75, 0x6C, 0x6C, 0x59, 0x65,
+ 0x61, 0x72, 0x2C, 0x67, 0x65, 0x74, 0x55, 0x54, 0x43, 0x59, 0x65, 0x61, 0x72, 0x2C, 0x67, 0x65,
+ 0x74, 0x55, 0x54, 0x43, 0x4D, 0x6F, 0x6E, 0x74, 0x68, 0x2C, 0x67, 0x65, 0x74, 0x55, 0x54, 0x43,
+ 0x44, 0x61, 0x74, 0x65, 0x2C, 0x67, 0x65, 0x74, 0x55, 0x54, 0x43, 0x44, 0x61, 0x79, 0x2C, 0x67,
+ 0x65, 0x74, 0x55, 0x54, 0x43, 0x48, 0x6F, 0x75, 0x72, 0x73, 0x2C, 0x67, 0x65, 0x74, 0x55, 0x54,
+ 0x43, 0x4D, 0x69, 0x6E, 0x75, 0x74, 0x65, 0x73, 0x2C, 0x67, 0x65, 0x74, 0x55, 0x54, 0x43, 0x53,
+ 0x65, 0x63, 0x6F, 0x6E, 0x64, 0x73, 0x2C, 0x67, 0x65, 0x74, 0x55, 0x54, 0x43, 0x4D, 0x69, 0x6C,
+ 0x6C, 0x69, 0x73, 0x65, 0x63, 0x6F, 0x6E, 0x64, 0x73, 0x2C, 0x73, 0x65, 0x74, 0x55, 0x54, 0x43,
+ 0x46, 0x75, 0x6C, 0x6C, 0x59, 0x65, 0x61, 0x72, 0x2C, 0x73, 0x65, 0x74, 0x55, 0x54, 0x43, 0x4D,
+ 0x6F, 0x6E, 0x74, 0x68, 0x2C, 0x73, 0x65, 0x74, 0x55, 0x54, 0x43, 0x44, 0x61, 0x74, 0x65, 0x2C,
+ 0x73, 0x65, 0x74, 0x55, 0x54, 0x43, 0x48, 0x6F, 0x75, 0x72, 0x73, 0x2C, 0x73, 0x65, 0x74, 0x55,
+ 0x54, 0x43, 0x4D, 0x69, 0x6E, 0x75, 0x74, 0x65, 0x73, 0x2C, 0x73, 0x65, 0x74, 0x55, 0x54, 0x43,
+ 0x53, 0x65, 0x63, 0x6F, 0x6E, 0x64, 0x73, 0x2C, 0x73, 0x65, 0x74, 0x55, 0x54, 0x43, 0x4D, 0x69,
+ 0x6C, 0x6C, 0x69, 0x73, 0x65, 0x63, 0x6F, 0x6E, 0x64, 0x73, 0x00, 0x76, 0x61, 0x6C, 0x75, 0x65,
+ 0x4F, 0x66, 0x00, 0x67, 0x65, 0x74, 0x54, 0x69, 0x6D, 0x65, 0x00, 0x55, 0x54, 0x43, 0x00, 0x41,
+ 0x72, 0x72, 0x61, 0x79, 0x00, 0x70, 0x75, 0x73, 0x68, 0x2C, 0x70, 0x6F, 0x70, 0x2C, 0x63, 0x6F,
+ 0x6E, 0x63, 0x61, 0x74, 0x2C, 0x73, 0x68, 0x69, 0x66, 0x74, 0x2C, 0x75, 0x6E, 0x73, 0x68, 0x69,
+ 0x66, 0x74, 0x2C, 0x73, 0x6C, 0x69, 0x63, 0x65, 0x2C, 0x6A, 0x6F, 0x69, 0x6E, 0x2C, 0x73, 0x70,
+ 0x6C, 0x69, 0x63, 0x65, 0x2C, 0x74, 0x6F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x2C, 0x73, 0x6F,
+ 0x72, 0x74, 0x2C, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x2C, 0x73, 0x6F, 0x72, 0x74, 0x4F,
+ 0x6E, 0x00, 0x43, 0x41, 0x53, 0x45, 0x49, 0x4E, 0x53, 0x45, 0x4E, 0x53, 0x49, 0x54, 0x49, 0x56,
+ 0x45, 0x00, 0x44, 0x45, 0x53, 0x43, 0x45, 0x4E, 0x44, 0x49, 0x4E, 0x47, 0x00, 0x55, 0x4E, 0x49,
+ 0x51, 0x55, 0x45, 0x53, 0x4F, 0x52, 0x54, 0x00, 0x52, 0x45, 0x54, 0x55, 0x52, 0x4E, 0x49, 0x4E,
+ 0x44, 0x45, 0x58, 0x45, 0x44, 0x41, 0x52, 0x52, 0x41, 0x59, 0x00, 0x4E, 0x55, 0x4D, 0x45, 0x52,
+ 0x49, 0x43, 0x00, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x00, 0x75, 0x6E, 0x65, 0x73, 0x63, 0x61,
+ 0x70, 0x65, 0x00, 0x70, 0x61, 0x72, 0x73, 0x65, 0x49, 0x6E, 0x74, 0x00, 0x70, 0x61, 0x72, 0x73,
+ 0x65, 0x46, 0x6C, 0x6F, 0x61, 0x74, 0x00, 0x69, 0x73, 0x4E, 0x61, 0x4E, 0x00, 0x69, 0x73, 0x46,
+ 0x69, 0x6E, 0x69, 0x74, 0x65, 0x00, 0x96, 0x13, 0x00, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x07, 0x01, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13,
+ 0x00, 0x08, 0x02, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00,
+ 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13, 0x00, 0x08, 0x03, 0x07, 0x01, 0x00, 0x00, 0x00,
+ 0x07, 0x04, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x0E,
+ 0x00, 0x07, 0x0A, 0x00, 0x00, 0x00, 0x08, 0x07, 0x07, 0x65, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0x05, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07,
+ 0x04, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00,
+ 0x02, 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x05, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E,
+ 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x09, 0x00, 0x08,
+ 0x08, 0x07, 0x65, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96,
+ 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x09, 0x8E, 0x08, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08,
+ 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0B, 0x52, 0x3E, 0x4F, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00,
+ 0x00, 0x00, 0x02, 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07,
+ 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00,
+ 0x02, 0x08, 0x04, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17,
+ 0x96, 0x13, 0x00, 0x08, 0x0C, 0x07, 0x02, 0x00, 0x00, 0x00, 0x07, 0x6B, 0x00, 0x00, 0x00, 0x07,
+ 0x02, 0x00, 0x00, 0x00, 0x08, 0x0D, 0x3D, 0x1D, 0x96, 0x09, 0x00, 0x08, 0x0E, 0x07, 0x6B, 0x00,
+ 0x00, 0x00, 0x08, 0x0C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03,
+ 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02,
+ 0x08, 0x0C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00,
+ 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x13, 0x00, 0x08, 0x0F, 0x07, 0x02, 0x00, 0x00, 0x00, 0x07,
+ 0x6A, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x0D, 0x3D, 0x1D, 0x96, 0x09, 0x00,
+ 0x08, 0x0E, 0x07, 0x6A, 0x00, 0x00, 0x00, 0x08, 0x0F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E,
+ 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07,
+ 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0x0F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x07,
+ 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x1C,
+ 0x96, 0x04, 0x00, 0x08, 0x10, 0x08, 0x10, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x1C, 0x96,
+ 0x04, 0x00, 0x08, 0x11, 0x08, 0x12, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x1C, 0x96, 0x04,
+ 0x00, 0x08, 0x13, 0x08, 0x12, 0x1C, 0x96, 0x05, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x0C, 0x4F,
+ 0x96, 0x02, 0x00, 0x08, 0x0F, 0x1C, 0x96, 0x0B, 0x00, 0x08, 0x14, 0x06, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x1C, 0x96, 0x0B, 0x00, 0x08, 0x15,
+ 0x06, 0xFF, 0xFF, 0xEF, 0x7F, 0xE2, 0xFF, 0xFF, 0xFF, 0x4F, 0x96, 0x08, 0x00, 0x07, 0x07, 0x00,
+ 0x00, 0x00, 0x02, 0x08, 0x0F, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00,
+ 0x3D, 0x17, 0x96, 0x13, 0x00, 0x08, 0x16, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFB, 0x00, 0x00,
+ 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x0D, 0x3D, 0x1D, 0x96, 0x0E, 0x00, 0x07, 0x01, 0x00,
+ 0x00, 0x00, 0x08, 0x17, 0x07, 0xFB, 0x00, 0x00, 0x00, 0x08, 0x16, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x08,
+ 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0x16, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E,
+ 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08,
+ 0x16, 0x1C, 0x96, 0x13, 0x00, 0x08, 0x18, 0x07, 0x0E, 0x00, 0x00, 0x00, 0x07, 0xFB, 0x00, 0x00,
+ 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00,
+ 0x00, 0x00, 0x02, 0x08, 0x16, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00,
+ 0x3D, 0x17, 0x96, 0x5F, 0x00, 0x08, 0x19, 0x08, 0x1A, 0x06, 0x0A, 0xBF, 0x05, 0x40, 0x74, 0x57,
+ 0x14, 0x8B, 0x08, 0x1B, 0x06, 0xB1, 0x6B, 0x02, 0x40, 0x1F, 0x55, 0xB5, 0xBB, 0x08, 0x1C, 0x06,
+ 0x42, 0x2E, 0xE6, 0x3F, 0xEC, 0x39, 0xFA, 0xFE, 0x08, 0x1D, 0x06, 0x7B, 0xCB, 0xDB, 0x3F, 0x11,
+ 0xE5, 0x26, 0x15, 0x08, 0x1E, 0x06, 0x47, 0x15, 0xF7, 0x3F, 0xEF, 0x82, 0x2B, 0x65, 0x08, 0x1F,
+ 0x06, 0xFB, 0x21, 0x09, 0x40, 0x11, 0x2D, 0x44, 0x54, 0x08, 0x20, 0x06, 0x9E, 0xA0, 0xE6, 0x3F,
+ 0xD1, 0x3B, 0x7F, 0x66, 0x08, 0x21, 0x06, 0x9E, 0xA0, 0xF6, 0x3F, 0xE3, 0x3B, 0x7F, 0x66, 0x07,
+ 0x08, 0x00, 0x00, 0x00, 0x43, 0x1D, 0x96, 0x09, 0x00, 0x08, 0x22, 0x07, 0xC8, 0x00, 0x00, 0x00,
+ 0x08, 0x19, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96,
+ 0x08, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x19, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03,
+ 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x13, 0x00, 0x08, 0x23, 0x07, 0x00, 0x01, 0x00,
+ 0x00, 0x07, 0x67, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x0D, 0x3D, 0x1D, 0x96,
+ 0x09, 0x00, 0x08, 0x24, 0x07, 0x67, 0x00, 0x00, 0x00, 0x08, 0x23, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x0E,
+ 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x08, 0x25, 0x07, 0x67, 0x00, 0x00, 0x00, 0x08, 0x23, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x02,
+ 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x23, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x04,
+ 0x00, 0x08, 0x26, 0x08, 0x23, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x02, 0x00, 0x08,
+ 0x27, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x23, 0x1C, 0x96, 0x13, 0x00, 0x08, 0x28, 0x07, 0x01,
+ 0x01, 0x00, 0x00, 0x07, 0x67, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D,
+ 0x4F, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0x23, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96,
+ 0x08, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x23, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03,
+ 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x13, 0x00, 0x08, 0x29, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x07, 0xFC, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x0D, 0x3D, 0x1D, 0x96,
+ 0x0E, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x2A, 0x07, 0xFC, 0x00, 0x00, 0x00, 0x08, 0x29,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08,
+ 0x02, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0x29, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x06, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D,
+ 0x17, 0x96, 0x02, 0x00, 0x08, 0x29, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x2B, 0x07, 0x01, 0x00, 0x00,
+ 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x29, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x2C, 0x07, 0x02, 0x00,
+ 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x29, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x2D, 0x07, 0x04,
+ 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x29, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x2E, 0x07,
+ 0x08, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x29, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x2F,
+ 0x07, 0x10, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x13, 0x00, 0x08, 0x30, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x07, 0x64, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13,
+ 0x00, 0x08, 0x31, 0x07, 0x01, 0x00, 0x00, 0x00, 0x07, 0x64, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00,
+ 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13, 0x00, 0x08, 0x32, 0x07, 0x02, 0x00, 0x00, 0x00,
+ 0x07, 0x64, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13,
+ 0x00, 0x08, 0x33, 0x07, 0x03, 0x00, 0x00, 0x00, 0x07, 0x64, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00,
+ 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13, 0x00, 0x08, 0x34, 0x07, 0x12, 0x00, 0x00, 0x00,
+ 0x07, 0xC8, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13,
+ 0x00, 0x08, 0x35, 0x07, 0x13, 0x00, 0x00, 0x00, 0x07, 0xC8, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00,
+ 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x0D, 0x00, 0x07, 0x06, 0x00, 0x00, 0x00, 0x07, 0x01,
+ 0x00, 0x00, 0x00, 0x02, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08,
+ 0x00, 0x3D, 0x17, 0x00
+};
+
diff --git a/swfdec/swfdec_as_internal.h b/swfdec/swfdec_as_internal.h
new file mode 100644
index 0000000..30a556c
--- /dev/null
+++ b/swfdec/swfdec_as_internal.h
@@ -0,0 +1,78 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_INTERNAL_H_
+#define _SWFDEC_AS_INTERNAL_H_
+
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_as_types.h>
+
+G_BEGIN_DECLS
+
+/* This header contains all the non-exported symbols that can't go into
+ * exported headers
+ */
+#define SWFDEC_AS_NATIVE(x, y, func) SWFDEC_AS_CONSTRUCTOR (x, y, func, NULL)
+#define SWFDEC_AS_CONSTRUCTOR(x, y, func, type) void func (SwfdecAsContext *cx, \
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret);
+
+#define SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT 256
+
+void swfdec_as_function_set_constructor (SwfdecAsFunction * fun);
+void swfdec_as_function_init_context (SwfdecAsContext * context);
+SwfdecAsFrame * swfdec_as_function_call_no_preload (SwfdecAsFunction * function,
+ SwfdecAsObject * thisp,
+ guint n_args,
+ const SwfdecAsValue * args,
+ SwfdecAsValue * return_value);
+
+/* swfdec_as_context.c */
+gboolean swfdec_as_context_check_continue (SwfdecAsContext * context);
+void swfdec_as_context_run_init_script (SwfdecAsContext * context,
+ const guint8 * data,
+ gsize length,
+ guint version);
+
+/* swfdec_as_object.c */
+typedef SwfdecAsVariableForeach SwfdecAsVariableForeachRemove;
+typedef const char *(* SwfdecAsVariableForeachRename) (SwfdecAsObject *object,
+ const char *variable, SwfdecAsValue *value, guint flags, gpointer data);
+
+SwfdecAsValue * swfdec_as_object_peek_variable (SwfdecAsObject * object,
+ const char * name);
+void swfdec_as_object_collect (SwfdecAsObject * object);
+guint swfdec_as_object_foreach_remove (SwfdecAsObject * object,
+ SwfdecAsVariableForeach func,
+ gpointer data);
+void swfdec_as_object_foreach_rename (SwfdecAsObject * object,
+ SwfdecAsVariableForeachRename func,
+ gpointer data);
+
+void swfdec_as_object_init_context (SwfdecAsContext * context);
+void swfdec_as_object_decode (SwfdecAsObject * obj,
+ const char * str);
+SwfdecAsObject * swfdec_as_object_get_prototype (SwfdecAsObject * object);
+void swfdec_as_object_add_native_variable (SwfdecAsObject * object,
+ const char * variable,
+ SwfdecAsNative get,
+ SwfdecAsNative set);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_as_interpret.c b/swfdec/swfdec_as_interpret.c
new file mode 100644
index 0000000..813c1ce
--- /dev/null
+++ b/swfdec/swfdec_as_interpret.c
@@ -0,0 +1,3268 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_interpret.h"
+#include "swfdec_as_array.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_frame_internal.h"
+#include "swfdec_as_function.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_script_function.h"
+#include "swfdec_as_stack.h"
+#include "swfdec_as_string.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_as_super.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+#include <errno.h>
+#include <math.h>
+#include <string.h>
+#include "swfdec_decoder.h"
+#include "swfdec_load_object.h"
+#include "swfdec_movie.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_sprite.h"
+#include "swfdec_sprite_movie.h"
+#include "swfdec_resource.h"
+#include "swfdec_text_field_movie.h" // for typeof
+
+/* Define this to get SWFDEC_WARN'd about missing properties of objects.
+ * This can be useful to find out about unimplemented native properties,
+ * but usually just causes a lot of spam. */
+//#define SWFDEC_WARN_MISSING_PROPERTIES
+
+/*** SUPPORT FUNCTIONS ***/
+
+#define swfdec_action_has_register(cx, i) \
+ ((i) < (cx)->frame->n_registers)
+
+/*** ALL THE ACTION IS HERE ***/
+
+static void
+swfdec_action_stop (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ if (SWFDEC_IS_SPRITE_MOVIE (cx->frame->target))
+ SWFDEC_SPRITE_MOVIE (cx->frame->target)->playing = FALSE;
+ else
+ SWFDEC_ERROR ("no movie to stop");
+}
+
+static void
+swfdec_action_play (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ if (SWFDEC_IS_SPRITE_MOVIE (cx->frame->target))
+ SWFDEC_SPRITE_MOVIE (cx->frame->target)->playing = TRUE;
+ else
+ SWFDEC_ERROR ("no movie to play");
+}
+
+static void
+swfdec_action_next_frame (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ if (SWFDEC_IS_SPRITE_MOVIE (cx->frame->target)) {
+ SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (cx->frame->target);
+ if (movie->frame < movie->n_frames) {
+ swfdec_sprite_movie_goto (movie, movie->frame + 1);
+ } else {
+ SWFDEC_INFO ("can't execute nextFrame, already at last frame");
+ }
+ } else {
+ SWFDEC_ERROR ("no movie to nextFrame on");
+ }
+}
+
+static void
+swfdec_action_previous_frame (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ if (SWFDEC_IS_SPRITE_MOVIE (cx->frame->target)) {
+ SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (cx->frame->target);
+ if (movie->frame > 1) {
+ swfdec_sprite_movie_goto (movie, movie->frame - 1);
+ } else {
+ SWFDEC_INFO ("can't execute previousFrame, already at first frame");
+ }
+ } else {
+ SWFDEC_ERROR ("no movie to previousFrame on");
+ }
+}
+
+static void
+swfdec_action_goto_frame (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ guint frame;
+
+ if (len != 2) {
+ SWFDEC_ERROR ("GotoFrame action length invalid (is %u, should be 2", len);
+ return;
+ }
+ frame = (data[0] | data[1] << 8);
+ if (SWFDEC_IS_SPRITE_MOVIE (cx->frame->target)) {
+ SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (cx->frame->target);
+ swfdec_sprite_movie_goto (movie, frame + 1);
+ movie->playing = FALSE;
+ } else {
+ SWFDEC_ERROR ("no movie to goto on");
+ }
+}
+
+static void
+swfdec_action_goto_label (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ if (!memchr (data, 0, len)) {
+ SWFDEC_ERROR ("GotoLabel action does not specify a string");
+ return;
+ }
+
+ if (SWFDEC_IS_SPRITE_MOVIE (cx->frame->target)) {
+ SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (cx->frame->target);
+ int frame;
+ if (movie->sprite == NULL ||
+ (frame = swfdec_sprite_get_frame (movie->sprite, (const char *) data)) == -1)
+ return;
+ swfdec_sprite_movie_goto (movie, frame + 1);
+ movie->playing = FALSE;
+ } else {
+ SWFDEC_ERROR ("no movie to goto on");
+ }
+}
+
+/* returns: frame to go to or 0 on error */
+static guint
+swfdec_value_to_frame (SwfdecAsContext *cx, SwfdecSpriteMovie *movie, SwfdecAsValue *val)
+{
+ int frame;
+
+ if (movie->sprite == NULL)
+ return 0;
+ if (SWFDEC_AS_VALUE_IS_STRING (val)) {
+ const char *name = SWFDEC_AS_VALUE_GET_STRING (val);
+ double d;
+ if (strchr (name, ':')) {
+ SWFDEC_ERROR ("FIXME: handle targets");
+ }
+ /* treat valid encoded numbers as numbers, otherwise assume it's a frame label */
+ d = swfdec_as_value_to_number (cx, val);
+ if (isnan (d))
+ frame = swfdec_sprite_get_frame (movie->sprite, name) + 1;
+ else
+ frame = d;
+ } else if (SWFDEC_AS_VALUE_IS_NUMBER (val)) {
+ frame = swfdec_as_value_to_integer (cx, val);
+ } else {
+ SWFDEC_WARNING ("cannot convert value to frame number");
+ /* FIXME: how do we treat undefined etc? */
+ frame = 0;
+ }
+ return frame <= 0 ? 0 : frame;
+}
+
+static void
+swfdec_action_goto_frame2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecBits bits;
+ guint bias;
+ gboolean play;
+ SwfdecAsValue *val;
+
+ swfdec_bits_init_data (&bits, data, len);
+ if (swfdec_bits_getbits (&bits, 6)) {
+ SWFDEC_WARNING ("reserved bits in GotoFrame2 aren't 0");
+ }
+ bias = swfdec_bits_getbit (&bits);
+ play = swfdec_bits_getbit (&bits);
+ if (bias) {
+ bias = swfdec_bits_get_u16 (&bits);
+ }
+ val = swfdec_as_stack_peek (cx, 1);
+ /* now set it */
+ if (SWFDEC_IS_SPRITE_MOVIE (cx->frame->target)) {
+ SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (cx->frame->target);
+ guint frame = swfdec_value_to_frame (cx, movie, val);
+ if (frame > 0) {
+ frame += bias;
+ frame = CLAMP (frame, 1, movie->n_frames);
+ swfdec_sprite_movie_goto (movie, frame);
+ movie->playing = play;
+ }
+ } else {
+ SWFDEC_ERROR ("no movie to GotoFrame2 on");
+ }
+ swfdec_as_stack_pop (cx);
+}
+
+static void
+swfdec_script_skip_actions (SwfdecAsContext *cx, guint jump)
+{
+ SwfdecScript *script = cx->frame->script;
+ const guint8 *pc = cx->frame->pc;
+ const guint8 *endpc = script->buffer->data + script->buffer->length;
+
+ /* jump instructions */
+ do {
+ if (pc >= endpc)
+ break;
+ if (*pc & 0x80) {
+ if (pc + 2 >= endpc)
+ break;
+ pc += 3 + (pc[1] | (pc[2] << 8));
+ } else {
+ pc++;
+ }
+ } while (jump-- > 0);
+ cx->frame->pc = pc;
+}
+
+#if 0
+static void
+swfdec_action_wait_for_frame2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ jsval val;
+
+ if (len != 1) {
+ SWFDEC_ERROR ("WaitForFrame2 needs a 1-byte data");
+ return JS_FALSE;
+ }
+ val = cx->fp->sp[-1];
+ cx->fp->sp--;
+ if (SWFDEC_IS_SPRITE_MOVIE (cx->frame->target)) {
+ SwfdecMovie *movie = SWFDEC_MOVIE (cx->frame->target);
+ int frame = swfdec_value_to_frame (cx, movie, val);
+ guint jump = data[2];
+ guint loaded;
+ if (frame < 0)
+ return JS_TRUE;
+ if (SWFDEC_IS_ROOT_MOVIE (movie)) {
+ SwfdecDecoder *dec = SWFDEC_ROOT_MOVIE (movie)->decoder;
+ loaded = dec->frames_loaded;
+ g_assert (loaded <= movie->n_frames);
+ } else {
+ loaded = movie->n_frames;
+ }
+ if (loaded <= (guint) frame)
+ swfdec_script_skip_actions (cx, jump);
+ } else {
+ SWFDEC_ERROR ("no movie to WaitForFrame2 on");
+ }
+ return JS_TRUE;
+}
+#endif
+
+static void
+swfdec_action_wait_for_frame (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecSpriteMovie *movie;
+ guint jump;
+ int frame, loaded;
+
+ if (len != 3) {
+ SWFDEC_ERROR ("WaitForFrame action length invalid (is %u, should be 3", len);
+ return;
+ }
+ if (!SWFDEC_IS_SPRITE_MOVIE (cx->frame->target)) {
+ SWFDEC_ERROR ("no movie for WaitForFrame");
+ return;
+ }
+
+ movie = SWFDEC_SPRITE_MOVIE (cx->frame->target);
+ frame = data[0] || (data[1] << 8);
+ jump = data[2];
+ loaded = swfdec_sprite_movie_get_frames_loaded (movie);
+ if (loaded < (int) movie->n_frames &&
+ loaded <= frame)
+ swfdec_script_skip_actions (cx, jump);
+}
+
+static void
+swfdec_action_constant_pool (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecConstantPool *pool;
+ SwfdecAsFrame *frame;
+
+ frame = cx->frame;
+ pool = swfdec_constant_pool_new_from_action (data, len, cx->version);
+ if (pool == NULL)
+ return;
+ swfdec_constant_pool_attach_to_context (pool, cx);
+ if (frame->constant_pool)
+ swfdec_constant_pool_free (frame->constant_pool);
+ frame->constant_pool = pool;
+ if (frame->constant_pool_buffer)
+ swfdec_buffer_unref (frame->constant_pool_buffer);
+ frame->constant_pool_buffer = swfdec_buffer_new_subbuffer (frame->script->buffer,
+ data - frame->script->buffer->data, len);
+}
+
+static void
+swfdec_action_push (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecBits bits;
+
+ swfdec_bits_init_data (&bits, data, len);
+ while (swfdec_bits_left (&bits)) {
+ guint type = swfdec_bits_get_u8 (&bits);
+ SWFDEC_LOG ("push type %u", type);
+ swfdec_as_stack_ensure_free (cx, 1);
+ switch (type) {
+ case 0: /* string */
+ {
+ char *s = swfdec_bits_get_string (&bits, cx->version);
+ if (s == NULL)
+ return;
+ SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_push (cx),
+ swfdec_as_context_give_string (cx, s));
+ break;
+ }
+ case 1: /* float */
+ SWFDEC_AS_VALUE_SET_NUMBER (swfdec_as_stack_push (cx),
+ swfdec_bits_get_float (&bits));
+ break;
+ case 2: /* null */
+ SWFDEC_AS_VALUE_SET_NULL (swfdec_as_stack_push (cx));
+ break;
+ case 3: /* undefined */
+ SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_push (cx));
+ break;
+ case 4: /* register */
+ {
+ guint regnum = swfdec_bits_get_u8 (&bits);
+ if (!swfdec_action_has_register (cx, regnum)) {
+ SWFDEC_ERROR ("cannot Push register %u: not enough registers", regnum);
+ SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_push (cx));
+ } else {
+ *swfdec_as_stack_push (cx) = cx->frame->registers[regnum];
+ }
+ break;
+ }
+ case 5: /* boolean */
+ SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_push (cx),
+ swfdec_bits_get_u8 (&bits) ? TRUE : FALSE);
+ break;
+ case 6: /* double */
+ SWFDEC_AS_VALUE_SET_NUMBER (swfdec_as_stack_push (cx),
+ swfdec_bits_get_double (&bits));
+ break;
+ case 7: /* 32bit int */
+ SWFDEC_AS_VALUE_SET_INT (swfdec_as_stack_push (cx),
+ (int) swfdec_bits_get_u32 (&bits));
+ break;
+ case 8: /* 8bit ConstantPool address */
+ {
+ guint i = swfdec_bits_get_u8 (&bits);
+ SwfdecConstantPool *pool = cx->frame->constant_pool;
+ if (pool == NULL) {
+ SWFDEC_ERROR ("no constant pool to push from");
+ return;
+ }
+ if (i >= swfdec_constant_pool_size (pool)) {
+ SWFDEC_ERROR ("constant pool index %u too high - only %u elements",
+ i, swfdec_constant_pool_size (pool));
+ return;
+ }
+ SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_push (cx),
+ swfdec_constant_pool_get (pool, i));
+ break;
+ }
+ case 9: /* 16bit ConstantPool address */
+ {
+ guint i = swfdec_bits_get_u16 (&bits);
+ SwfdecConstantPool *pool = cx->frame->constant_pool;
+ if (pool == NULL) {
+ SWFDEC_ERROR ("no constant pool to push from");
+ return;
+ }
+ if (i >= swfdec_constant_pool_size (pool)) {
+ SWFDEC_ERROR ("constant pool index %u too high - only %u elements",
+ i, swfdec_constant_pool_size (pool));
+ return;
+ }
+ SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_push (cx),
+ swfdec_constant_pool_get (pool, i));
+ break;
+ }
+ default:
+ SWFDEC_ERROR ("Push: type %u not implemented", type);
+ return;
+ }
+ }
+}
+
+/* NB: name must be GC'd */
+static SwfdecAsObject *
+super_special_movie_lookup_magic (SwfdecAsContext *cx, SwfdecAsObject *o, const char *name)
+{
+ SwfdecAsValue val;
+
+ if (o == NULL) {
+ o = swfdec_as_frame_get_variable (cx->frame, name, NULL);
+ if (o == NULL)
+ return NULL;
+ }
+ if (SWFDEC_IS_MOVIE (o)) {
+ SwfdecMovie *ret = swfdec_movie_get_by_name (SWFDEC_MOVIE (o), name, TRUE);
+ if (ret)
+ return SWFDEC_AS_OBJECT (ret);
+ }
+ if (!swfdec_as_object_get_variable (o, name, &val))
+ return NULL;
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return NULL;
+ return SWFDEC_AS_VALUE_GET_OBJECT (&val);
+}
+
+static SwfdecAsObject *
+swfdec_action_get_movie_by_slash_path (SwfdecAsContext *cx, const char *path)
+{
+ SwfdecAsObject *o;
+
+ o = cx->frame->target;
+ if (!SWFDEC_IS_MOVIE (o))
+ return NULL;
+ if (*path == '/') {
+ o = SWFDEC_AS_OBJECT (swfdec_movie_get_root (SWFDEC_MOVIE (o)));
+ path++;
+ }
+ while (*path) {
+ char *slash = strchr (path, '/');
+ const char *name;
+ if (slash) {
+ if (slash == path)
+ return NULL;
+ name = swfdec_as_context_give_string (cx, g_strndup (path, slash - path));
+ path = slash + 1;
+ } else {
+ name = swfdec_as_context_get_string (cx, path);
+ path += strlen (path);
+ }
+ o = super_special_movie_lookup_magic (cx, o, name);
+ if (!SWFDEC_IS_MOVIE (o))
+ return NULL;
+ }
+ return o;
+}
+
+SwfdecAsObject *
+swfdec_action_lookup_object (SwfdecAsContext *cx, SwfdecAsObject *o, const char *path, const char *end)
+{
+ gboolean dot_allowed = TRUE;
+ const char *start;
+
+ if (path == end) {
+ if (o == NULL)
+ o = cx->frame->target;
+ if (SWFDEC_IS_MOVIE (o))
+ return o;
+ else
+ return NULL;
+ }
+
+ if (path[0] == '/') {
+ if (o == NULL)
+ o = cx->frame->target;
+ if (!SWFDEC_IS_MOVIE (o))
+ return NULL;
+ o = SWFDEC_AS_OBJECT (swfdec_movie_get_root (SWFDEC_MOVIE (o)));
+ path++;
+ dot_allowed = FALSE;
+ }
+ while (path < end) {
+ for (start = path; path < end; path++) {
+ if (dot_allowed && path[0] == '.') {
+ if (end - path >= 2 && path[1] == '.') {
+ dot_allowed = FALSE;
+ continue;
+ }
+ } else if (path[0] == ':') {
+ if (path[1] == '/')
+ continue;
+ if (path == start) {
+ start++;
+ continue;
+ }
+ } else if (path[0] == '/') {
+ dot_allowed = FALSE;
+ } else if (path - start < 127) {
+ continue;
+ }
+
+ break;
+ }
+
+ /* parse variable */
+ if (start[0] == '.' && start[1] == '.' && start + 2 == path) {
+ if (o == NULL) {
+ GSList *walk;
+ for (walk = cx->frame->scope_chain; walk; walk = walk->next) {
+ if (SWFDEC_IS_MOVIE (walk->data)) {
+ o = walk->data;
+ break;
+ }
+ }
+ if (o == NULL)
+ o = cx->frame->target;
+ }
+ /* ".." goes back to parent */
+ if (!SWFDEC_IS_MOVIE (o))
+ return NULL;
+ o = SWFDEC_AS_OBJECT (SWFDEC_MOVIE (o)->parent);
+ if (o == NULL)
+ return NULL;
+ } else {
+ o = super_special_movie_lookup_magic (cx, o,
+ swfdec_as_context_give_string (cx, g_strndup (start, path - start)));
+ if (o == NULL)
+ return NULL;
+ }
+ if (path - start < 127)
+ path++;
+ }
+
+ return o;
+}
+
+/* FIXME: this function belongs into swfdec_movie.c */
+SwfdecMovie *
+swfdec_player_get_movie_from_value (SwfdecPlayer *player, SwfdecAsValue *val)
+{
+ SwfdecAsContext *cx;
+ const char *s;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (SWFDEC_IS_AS_VALUE (val), NULL);
+
+ cx = SWFDEC_AS_CONTEXT (player);
+ s = swfdec_as_value_to_string (cx, val);
+ return swfdec_player_get_movie_from_string (player, s);
+}
+
+SwfdecMovie *
+swfdec_player_get_movie_from_string (SwfdecPlayer *player, const char *s)
+{
+ SwfdecAsObject *ret;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (s != NULL, NULL);
+
+ ret = swfdec_action_lookup_object (SWFDEC_AS_CONTEXT (player), NULL, s, s + strlen (s));
+ if (!SWFDEC_IS_MOVIE (ret)) {
+ SWFDEC_WARNING ("\"%s\" does not reference a movie", s);
+ return NULL;
+ }
+ return SWFDEC_MOVIE (ret);
+}
+
+/**
+ * swfdec_action_get_movie_by_path:
+ * @cx: a #SwfdecAsContext
+ * @path: the path to look up
+ * @object: pointer that takes the object that was looked up. The object may be
+ * %NULL.
+ * @variable: pointer that takes variable part of the path. The variable will
+ * be either %NULL or a non-gc'ed variable name.
+ *
+ * Looks up a Flash4-compatible path using "/", ":" and "." style syntax.
+ *
+ * Returns: The #SwfdecMovie that was looked up or %NULL if the path does not
+ * specify a valid movie.
+ **/
+static gboolean
+swfdec_action_get_movie_by_path (SwfdecAsContext *cx, const char *path,
+ SwfdecAsObject **object, const char **variable)
+{
+ SwfdecAsObject *movie;
+ char *end, *s;
+
+ g_assert (path != NULL);
+ g_assert (object != NULL);
+ g_assert (variable != NULL);
+ g_assert (cx->frame != NULL);
+
+ /* find dot or colon */
+ end = strpbrk (path, ".:");
+
+ /* if no dot or colon, look up slash-path */
+ if (end == NULL) {
+ /* shortcut for the general case */
+ if (strchr (path, '/') != NULL) {
+ movie = swfdec_action_get_movie_by_slash_path (cx, path);
+ if (movie) {
+ *object = movie;
+ *variable = NULL;
+ return TRUE;
+ }
+ }
+
+ *object = NULL;
+ *variable = path;
+ return TRUE;
+ }
+ /* find last dot or colon */
+ while ((s = strpbrk (end + 1, ".:")) != NULL)
+ end = s;
+
+ /* variable to use is the part after the last dot or colon */
+ *variable = end + 1;
+ /* look up object for start of path */
+ if (path == end)
+ movie = NULL;
+ else
+ movie = swfdec_action_lookup_object (cx, NULL, path, end);
+ if (movie) {
+ *object = movie;
+ return TRUE;
+ } else {
+ *variable = NULL;
+ return FALSE;
+ }
+}
+
+static void
+swfdec_action_get_variable (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *val;
+ const char *s;
+ SwfdecAsObject *object;
+
+ val = swfdec_as_stack_peek (cx, 1);
+ s = swfdec_as_value_to_string (cx, val);
+ if (swfdec_action_get_movie_by_path (cx, s, &object, &s)) {
+ if (object) {
+ if (s) {
+ swfdec_as_object_get_variable (object, swfdec_as_context_get_string (cx, s), val);
+ } else {
+ SWFDEC_AS_VALUE_SET_OBJECT (val, object);
+ }
+ } else {
+ swfdec_as_frame_get_variable (cx->frame, swfdec_as_context_get_string (cx, s), val);
+ }
+ } else {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (val);
+#ifdef SWFDEC_WARN_MISSING_PROPERTIES
+ SWFDEC_WARNING ("no variable named %s", s);
+#endif
+ }
+}
+
+static void
+swfdec_action_set_variable (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ const char *s, *rest;
+ SwfdecAsObject *object;
+
+ s = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 2));
+ if (swfdec_action_get_movie_by_path (cx, s, &object, &rest)) {
+ if (object && rest) {
+ swfdec_as_object_set_variable (object, swfdec_as_context_get_string (cx, rest),
+ swfdec_as_stack_peek (cx, 1));
+ } else {
+ if (object)
+ rest = s;
+ else
+ rest = swfdec_as_context_get_string (cx, rest);
+ swfdec_as_frame_set_variable (cx->frame, rest, swfdec_as_stack_peek (cx, 1));
+ }
+ }
+ swfdec_as_stack_pop_n (cx, 2);
+}
+
+/* FIXME: this sucks */
+extern struct {
+ gboolean needs_movie;
+ const char * name; /* GC'd */
+ void (* get) (SwfdecMovie *movie, SwfdecAsValue *ret);
+ void (* set) (SwfdecMovie *movie, const SwfdecAsValue *val);
+} swfdec_movieclip_props[];
+static void
+swfdec_action_get_property (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecMovie *movie;
+ guint id;
+
+ id = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 1));
+ if (!SWFDEC_IS_PLAYER (cx)) {
+ SWFDEC_INFO ("tried using GetProperty in a non-SwfdecPlayer context");
+ goto error;
+ } else {
+ movie = swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx),
+ swfdec_as_stack_peek (cx, 2));
+ if (movie == NULL)
+ goto error;
+ }
+ if (id > (cx->version > 4 ? 21 : 18)) {
+ SWFDEC_WARNING ("trying to SetProperty %u, doesn't exist", id);
+ goto error;
+ }
+ swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (movie), swfdec_movieclip_props[id].name,
+ swfdec_as_stack_peek (cx, 2));
+ swfdec_as_stack_pop (cx);
+ return;
+
+error :
+ swfdec_as_stack_pop (cx);
+ SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 1));
+}
+
+static void
+swfdec_action_set_property (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecMovie *movie;
+ guint id;
+
+ id = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 2));
+ if (!SWFDEC_IS_PLAYER (cx)) {
+ SWFDEC_INFO ("tried using GetProperty in a non-SwfdecPlayer context");
+ goto error;
+ } else {
+ movie = swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx),
+ swfdec_as_stack_peek (cx, 3));
+ if (movie == NULL)
+ goto error;
+ }
+ if (id > (cx->version > 4 ? 21 : 18)) {
+ SWFDEC_WARNING ("trying to SetProperty %u, doesn't exist", id);
+ goto error;
+ }
+ swfdec_as_object_set_variable (SWFDEC_AS_OBJECT (movie), swfdec_movieclip_props[id].name,
+ swfdec_as_stack_peek (cx, 1));
+ swfdec_as_stack_pop_n (cx, 3);
+ return;
+
+error :
+ swfdec_as_stack_pop_n (cx, 3);
+}
+
+static void
+swfdec_action_get_member (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsObject *object = swfdec_as_value_to_object (cx, swfdec_as_stack_peek (cx, 2));
+ if (object) {
+ const char *name;
+ name = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1));
+ swfdec_as_object_get_variable (object, name, swfdec_as_stack_peek (cx, 2));
+#ifdef SWFDEC_WARN_MISSING_PROPERTIES
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (swfdec_as_stack_peek (cx, 2))) {
+ SWFDEC_WARNING ("no variable named %s:%s", G_OBJECT_TYPE_NAME (object), name);
+ }
+#endif
+ } else {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 2));
+ }
+ swfdec_as_stack_pop (cx);
+}
+
+static void
+swfdec_action_set_member (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ if (SWFDEC_AS_VALUE_IS_OBJECT (swfdec_as_stack_peek (cx, 3))) {
+ const char *name = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 2));
+ swfdec_as_object_set_variable (SWFDEC_AS_VALUE_GET_OBJECT (swfdec_as_stack_peek (cx, 3)),
+ name, swfdec_as_stack_peek (cx, 1));
+ }
+ swfdec_as_stack_pop_n (cx, 3);
+}
+
+static void
+swfdec_action_trace (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *val;
+ const char *s;
+
+ val = swfdec_as_stack_peek (cx, 1);
+ if (val->type == SWFDEC_AS_TYPE_UNDEFINED) {
+ s = SWFDEC_AS_STR_undefined;
+ } else if (val->type == SWFDEC_AS_TYPE_OBJECT &&
+ SWFDEC_IS_AS_STRING (swfdec_as_value_to_object (cx, val))) {
+ s = SWFDEC_AS_STRING (swfdec_as_value_to_object (cx, val))->string;
+ } else {
+ s = swfdec_as_value_to_string (cx, val);
+ }
+ swfdec_as_stack_pop (cx);
+ g_signal_emit_by_name (cx, "trace", s);
+}
+
+/* stack looks like this: [ function, this, arg1, arg2, ... ] */
+/* stack must be at least 2 elements big */
+static SwfdecAsFrame *
+swfdec_action_call (SwfdecAsContext *cx, guint n_args)
+{
+ SwfdecAsFrame *frame;
+ SwfdecAsFunction *fun;
+ SwfdecAsObject *thisp;
+
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (swfdec_as_stack_peek (cx, 1)))
+ goto error;
+ fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (swfdec_as_stack_peek (cx, 1));
+ if (!SWFDEC_IS_AS_FUNCTION (fun))
+ goto error;
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (swfdec_as_stack_peek (cx, 2))) {
+ thisp = NULL;
+ } else {
+ thisp = SWFDEC_AS_VALUE_GET_OBJECT (swfdec_as_stack_peek (cx, 2));
+ }
+ swfdec_as_stack_pop_n (cx, 2);
+ /* sanitize argument count */
+ if (n_args >= swfdec_as_stack_get_size (cx))
+ n_args = swfdec_as_stack_get_size (cx);
+ frame = swfdec_as_function_call_no_preload (fun, thisp, n_args, NULL, NULL);
+ if (frame == NULL)
+ return NULL;
+ if (SWFDEC_IS_AS_SUPER (fun)) {
+ SWFDEC_LOG ("replacing super object on frame");
+ swfdec_as_super_new_chain (frame, SWFDEC_AS_SUPER (fun), NULL);
+ }
+ return frame;
+
+error:
+ n_args += 2;
+ if (n_args > swfdec_as_stack_get_size (cx))
+ n_args = swfdec_as_stack_get_size (cx);
+ swfdec_as_stack_pop_n (cx, n_args);
+ SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_push (cx));
+ return NULL;
+}
+
+static void
+swfdec_action_call_function (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsFrame *frame = cx->frame;
+ SwfdecAsObject *obj;
+ guint n_args;
+ const char *name;
+ SwfdecAsValue *fun, *thisp;
+
+ swfdec_as_stack_ensure_size (cx, 2);
+ n_args = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 2));
+ name = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1));
+ thisp = swfdec_as_stack_peek (cx, 2);
+ fun = swfdec_as_stack_peek (cx, 1);
+ obj = swfdec_as_frame_get_variable (frame, name, fun);
+ if (obj) {
+ SWFDEC_AS_VALUE_SET_OBJECT (thisp, obj);
+ } else {
+ SWFDEC_AS_VALUE_SET_NULL (thisp);
+ SWFDEC_AS_VALUE_SET_UNDEFINED (fun);
+ }
+ frame = swfdec_action_call (cx, n_args);
+ if (frame) {
+ swfdec_as_frame_preload (frame);
+ } else {
+ SWFDEC_WARNING ("no function named %s", name);
+ }
+}
+
+static void
+swfdec_action_call_method (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsFrame *frame = cx->frame;
+ SwfdecAsValue *val;
+ SwfdecAsObject *obj;
+ SwfdecAsObject *pobj = NULL;
+ guint n_args;
+ const char *name;
+
+ swfdec_as_stack_ensure_size (cx, 3);
+ obj = swfdec_as_value_to_object (cx, swfdec_as_stack_peek (cx, 2));
+ n_args = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 3));
+ val = swfdec_as_stack_peek (cx, 1);
+ if (obj) {
+ name = swfdec_as_value_to_string (cx, val);
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (val) ||
+ name == SWFDEC_AS_STR_EMPTY) {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 3));
+ SWFDEC_AS_VALUE_SET_OBJECT (swfdec_as_stack_peek (cx, 2), obj);
+ name = "";
+ pobj = obj;
+ } else {
+ SWFDEC_AS_VALUE_SET_OBJECT (swfdec_as_stack_peek (cx, 3), obj);
+ swfdec_as_object_get_variable_and_flags (obj, name, swfdec_as_stack_peek (cx, 2), NULL, &pobj);
+ }
+ } else {
+ if (SWFDEC_AS_VALUE_IS_STRING (val))
+ name = SWFDEC_AS_VALUE_GET_STRING (val);
+ else
+ name = "???";
+ SWFDEC_AS_VALUE_SET_NULL (swfdec_as_stack_peek (cx, 3));
+ SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 2));
+ }
+ swfdec_as_stack_pop (cx);
+ frame = swfdec_action_call (cx, n_args);
+ if (frame) {
+ /* setup super to point to the right prototype */
+ if (SWFDEC_IS_AS_SUPER (obj)) {
+ swfdec_as_super_new_chain (frame, SWFDEC_AS_SUPER (obj), name);
+ } else if (cx->version > 6) {
+ swfdec_as_super_new (frame, obj, pobj == obj ? obj->prototype : pobj);
+ } else {
+ swfdec_as_super_new (frame, obj, obj->prototype);
+ }
+ swfdec_as_frame_preload (frame);
+ } else {
+ SWFDEC_WARNING ("no function named \"%s\" on object %s", name, obj ? G_OBJECT_TYPE_NAME(obj) : "unknown");
+ }
+}
+
+static void
+swfdec_action_pop (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ swfdec_as_stack_pop (cx);
+}
+
+static void
+swfdec_action_binary (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ double l, r;
+
+ r = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 1));
+ l = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 2));
+ switch (action) {
+ case SWFDEC_AS_ACTION_ADD:
+ l = l + r;
+ break;
+ case SWFDEC_AS_ACTION_SUBTRACT:
+ l = l - r;
+ break;
+ case SWFDEC_AS_ACTION_MULTIPLY:
+ l = l * r;
+ break;
+ case SWFDEC_AS_ACTION_DIVIDE:
+ if (cx->version < 5) {
+ if (r == 0) {
+ swfdec_as_stack_pop (cx);
+ SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_peek (cx, 1), SWFDEC_AS_STR__ERROR_);
+ return;
+ }
+ }
+ if (r == 0) {
+ if (l > 0)
+ l = INFINITY;
+ else if (l < 0)
+ l = -INFINITY;
+ else
+ l = NAN;
+ } else {
+ l = l / r;
+ }
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+ swfdec_as_stack_pop (cx);
+ SWFDEC_AS_VALUE_SET_NUMBER (swfdec_as_stack_peek (cx, 1), l);
+}
+
+static void
+swfdec_action_add2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *rval, *lval, rtmp, ltmp;
+
+ rval = swfdec_as_stack_peek (cx, 1);
+ lval = swfdec_as_stack_peek (cx, 2);
+ rtmp = *rval;
+ ltmp = *lval;
+ swfdec_as_value_to_primitive (&rtmp);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&rtmp) || SWFDEC_IS_MOVIE (SWFDEC_AS_VALUE_GET_OBJECT (&rtmp)))
+ rval = &rtmp;
+ swfdec_as_value_to_primitive (<mp);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (<mp) || SWFDEC_IS_MOVIE (SWFDEC_AS_VALUE_GET_OBJECT (<mp)))
+ lval = <mp;
+
+ if (SWFDEC_AS_VALUE_IS_STRING (lval) || SWFDEC_AS_VALUE_IS_STRING (rval)) {
+ const char *lstr, *rstr;
+ lstr = swfdec_as_value_to_string (cx, lval);
+ rstr = swfdec_as_value_to_string (cx, rval);
+ lstr = swfdec_as_str_concat (cx, lstr, rstr);
+ swfdec_as_stack_pop (cx);
+ SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_peek (cx, 1), lstr);
+ } else {
+ double d, d2;
+ d = swfdec_as_value_to_number (cx, lval);
+ d2 = swfdec_as_value_to_number (cx, rval);
+ d += d2;
+ swfdec_as_stack_pop (cx);
+ SWFDEC_AS_VALUE_SET_NUMBER (swfdec_as_stack_peek (cx, 1), d);
+ }
+}
+
+static void
+swfdec_action_new_comparison (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *lval, *rval;
+ double l, r;
+
+ rval = swfdec_as_stack_peek (cx, 1);
+ lval = swfdec_as_stack_peek (cx, 2);
+
+ /* swap if we do a greater comparison */
+ if (action == SWFDEC_AS_ACTION_GREATER) {
+ SwfdecAsValue *tmp = lval;
+ lval = rval;
+ rval = tmp;
+ }
+ /* comparison with object is always false */
+ swfdec_as_value_to_primitive (lval);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (lval) &&
+ !SWFDEC_IS_MOVIE (SWFDEC_AS_VALUE_GET_OBJECT (lval))) {
+ swfdec_as_stack_pop (cx);
+ SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1), FALSE);
+ return;
+ }
+ /* same for the rval */
+ swfdec_as_value_to_primitive (rval);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (rval) &&
+ !SWFDEC_IS_MOVIE (SWFDEC_AS_VALUE_GET_OBJECT (rval))) {
+ swfdec_as_stack_pop (cx);
+ SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1), FALSE);
+ return;
+ }
+ /* movieclips are not objects, but they evaluate to NaN, so we can handle them here */
+ if (SWFDEC_AS_VALUE_IS_OBJECT (rval) ||
+ SWFDEC_AS_VALUE_IS_OBJECT (lval)) {
+ swfdec_as_stack_pop (cx);
+ SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 1));
+ return;
+ }
+ /* if both are strings, compare strings */
+ if (SWFDEC_AS_VALUE_IS_STRING (rval) &&
+ SWFDEC_AS_VALUE_IS_STRING (lval)) {
+ const char *ls = SWFDEC_AS_VALUE_GET_STRING (lval);
+ const char *rs = SWFDEC_AS_VALUE_GET_STRING (rval);
+ int cmp;
+ if (ls == SWFDEC_AS_STR_EMPTY) {
+ cmp = rs == SWFDEC_AS_STR_EMPTY ? 0 : 1;
+ } else if (rs == SWFDEC_AS_STR_EMPTY) {
+ cmp = -1;
+ } else {
+ cmp = strcmp (ls, rs);
+ }
+ swfdec_as_stack_pop (cx);
+ SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1), cmp < 0);
+ return;
+ }
+ /* convert to numbers and compare those */
+ l = swfdec_as_value_to_number (cx, lval);
+ r = swfdec_as_value_to_number (cx, rval);
+ swfdec_as_stack_pop (cx);
+ /* NaN results in undefined */
+ if (isnan (l) || isnan (r)) {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 1));
+ return;
+ }
+ SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1), l < r);
+}
+
+static void
+swfdec_action_not (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ if (cx->version <= 4) {
+ double d = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 1));
+ SWFDEC_AS_VALUE_SET_NUMBER (swfdec_as_stack_peek (cx, 1), d == 0 ? 1 : 0);
+ } else {
+ SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1),
+ !swfdec_as_value_to_boolean (cx, swfdec_as_stack_peek (cx, 1)));
+ }
+}
+
+static void
+swfdec_action_jump (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ gint16 offset;
+
+ if (len != 2) {
+ SWFDEC_ERROR ("Jump action length invalid (is %u, should be 2", len);
+ return;
+ }
+ offset = data[0] | (data[1] << 8);
+ cx->frame->pc += 5 + (int) offset;
+}
+
+static void
+swfdec_action_if (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ if (len != 2) {
+ SWFDEC_ERROR ("Jump action length invalid (is %u, should be 2", len);
+ return;
+ }
+ if (swfdec_as_value_to_boolean (cx, swfdec_as_stack_peek (cx, 1))) {
+ gint16 offset = data[0] | (data[1] << 8);
+ cx->frame->pc += 5 + (int) offset;
+ }
+ swfdec_as_stack_pop (cx);
+}
+
+static void
+swfdec_action_decrement (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *val;
+
+ val = swfdec_as_stack_peek (cx, 1);
+ SWFDEC_AS_VALUE_SET_NUMBER (val, swfdec_as_value_to_number (cx, val) - 1);
+}
+
+static void
+swfdec_action_increment (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *val;
+
+ val = swfdec_as_stack_peek (cx, 1);
+ SWFDEC_AS_VALUE_SET_NUMBER (val, swfdec_as_value_to_number (cx, val) + 1);
+}
+
+static void
+swfdec_action_get_url (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecBits bits;
+ char *url, *target;
+
+ swfdec_bits_init_data (&bits, data, len);
+ url = swfdec_bits_get_string (&bits, cx->version);
+ target = swfdec_bits_get_string (&bits, cx->version);
+ if (url == NULL || target == NULL) {
+ SWFDEC_ERROR ("not enough data in GetURL");
+ g_free (url);
+ g_free (target);
+ return;
+ }
+ if (swfdec_bits_left (&bits)) {
+ SWFDEC_WARNING ("leftover bytes in GetURL action");
+ }
+ if (!SWFDEC_IS_PLAYER (cx)) {
+ SWFDEC_ERROR ("GetURL without a SwfdecPlayer");
+ } else {
+ swfdec_resource_load (SWFDEC_PLAYER (cx), target, url,
+ SWFDEC_LOADER_REQUEST_DEFAULT, NULL, NULL, FALSE);
+ }
+ g_free (url);
+ g_free (target);
+}
+
+static void
+swfdec_as_interpret_load_variables_on_finish (SwfdecAsObject *target,
+ const char *text)
+{
+ if (text != NULL)
+ swfdec_as_object_decode (target, text);
+
+ // only call onData for sprite movies
+ // FIXME: is it called even when loading fails?
+ swfdec_movie_queue_script (SWFDEC_MOVIE (target), SWFDEC_EVENT_DATA);
+}
+
+static void
+swfdec_action_get_url2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ const char *target, *url;
+ guint method, internal, variables;
+
+ if (len != 1) {
+ SWFDEC_ERROR ("GetURL2 requires 1 byte of data, not %u", len);
+ return;
+ }
+
+ method = data[0] & 3;
+ if (method == 3) {
+ SWFDEC_ERROR ("GetURL method 3 invalid");
+ method = 0;
+ }
+ internal = data[0] & 64;
+ variables = data[0] & 128;
+ if (method == 1 || method == 2) {
+ SWFDEC_FIXME ("encode variables");
+ }
+
+ target = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1));
+ url = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 2));
+
+ if (!SWFDEC_IS_PLAYER (cx)) {
+ SWFDEC_ERROR ("GetURL2 action requires a SwfdecPlayer");
+ } else if (variables) {
+ SwfdecMovie *movie;
+
+ movie = swfdec_player_get_movie_from_string (SWFDEC_PLAYER (cx), target);
+ if (movie != NULL) {
+ swfdec_load_object_create (SWFDEC_AS_OBJECT (movie), url, method, NULL, NULL,
+ swfdec_as_interpret_load_variables_on_finish);
+ }
+ } else {
+ swfdec_resource_load (SWFDEC_PLAYER (cx), target, url, method, NULL, NULL, internal);
+ }
+
+ swfdec_as_stack_pop_n (cx, 2);
+}
+
+static void
+swfdec_action_string_add (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ const char *lval, *rval;
+
+ rval = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1));
+ lval = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 2));
+ lval = swfdec_as_str_concat (cx, lval, rval);
+ SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_peek (cx, 2), lval);
+ swfdec_as_stack_pop (cx);
+}
+
+static void
+swfdec_action_push_duplicate (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *val = swfdec_as_stack_peek (cx, 1);
+
+ *swfdec_as_stack_push (cx) = *val;
+}
+
+static void
+swfdec_action_random_number (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ gint32 max;
+ SwfdecAsValue *val;
+
+ val = swfdec_as_stack_peek (cx, 1);
+ max = swfdec_as_value_to_integer (cx, val);
+
+ if (max <= 0)
+ SWFDEC_AS_VALUE_SET_NUMBER (val, 0);
+ else
+ SWFDEC_AS_VALUE_SET_NUMBER (val, g_rand_int_range (cx->rand, 0, max));
+}
+
+static void
+swfdec_action_old_compare (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ double l, r;
+ gboolean cond;
+
+ l = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 2));
+ r = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 1));
+ switch (action) {
+ case SWFDEC_AS_ACTION_EQUALS:
+ cond = l == r;
+ break;
+ case SWFDEC_AS_ACTION_LESS:
+ cond = l < r;
+ break;
+ default:
+ g_assert_not_reached ();
+ return;
+ }
+ swfdec_as_stack_pop (cx);
+ if (cx->version < 5) {
+ SWFDEC_AS_VALUE_SET_NUMBER (swfdec_as_stack_peek (cx, 1), cond ? 1 : 0);
+ } else {
+ SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1), cond);
+ }
+}
+
+static void
+swfdec_action_string_extract (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ int start, n, left;
+ const char *s;
+
+ n = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 1));
+ start = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 2));
+ s = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 3));
+ swfdec_as_stack_pop_n (cx, 2);
+ left = g_utf8_strlen (s, -1);
+ if (start > left) {
+ SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_peek (cx, 1), SWFDEC_AS_STR_EMPTY);
+ return;
+ } else if (start < 2) {
+ start = 0;
+ } else {
+ start--;
+ }
+ left -= start;
+ if (n < 0 || n > left)
+ n = left;
+
+ SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_peek (cx, 1),
+ swfdec_as_str_sub (cx, s, start, n));
+}
+
+static void
+swfdec_action_string_length (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ const char *s;
+ SwfdecAsValue *v;
+
+ v = swfdec_as_stack_peek (cx, 1);
+ s = swfdec_as_value_to_string (cx, v);
+ SWFDEC_AS_VALUE_SET_INT (v, g_utf8_strlen (s, -1));
+}
+
+static void
+swfdec_action_string_compare (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ const char *l, *r;
+ gboolean cond;
+
+ r = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1));
+ l = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 2));
+ switch (action) {
+ case SWFDEC_AS_ACTION_STRING_EQUALS:
+ cond = l == r;
+ break;
+ case SWFDEC_AS_ACTION_STRING_LESS:
+ cond = strcmp (l, r) < 0;
+ break;
+ default:
+ cond = FALSE;
+ g_assert_not_reached ();
+ break;
+ }
+ swfdec_as_stack_pop (cx);
+ if (cx->version < 5) {
+ SWFDEC_AS_VALUE_SET_NUMBER (swfdec_as_stack_peek (cx, 1), cond ? 1 : 0);
+ } else {
+ SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1), cond);
+ }
+}
+
+static void
+swfdec_action_equals2_5 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *rval, *lval;
+ SwfdecAsValue rtmp, ltmp;
+ SwfdecAsValueType ltype, rtype;
+ double l, r;
+ gboolean cond;
+
+ rval = swfdec_as_stack_peek (cx, 1);
+ lval = swfdec_as_stack_peek (cx, 2);
+ rtmp = *rval;
+ ltmp = *lval;
+ swfdec_as_value_to_primitive (&rtmp);
+ swfdec_as_value_to_primitive (<mp);
+ ltype = ltmp.type;
+ rtype = rtmp.type;
+
+ /* get objects compared */
+ if (ltype == SWFDEC_AS_TYPE_OBJECT && rtype == SWFDEC_AS_TYPE_OBJECT) {
+ SwfdecAsObject *lo = SWFDEC_AS_VALUE_GET_OBJECT (<mp);
+ SwfdecAsObject *ro = SWFDEC_AS_VALUE_GET_OBJECT (&rtmp);
+
+ if (SWFDEC_IS_MOVIE (lo) && SWFDEC_IS_MOVIE (ro)) {
+ lo = SWFDEC_AS_OBJECT (swfdec_movie_resolve (SWFDEC_MOVIE (lo)));
+ ro = SWFDEC_AS_OBJECT (swfdec_movie_resolve (SWFDEC_MOVIE (ro)));
+ } else if (SWFDEC_IS_MOVIE (lo)) {
+ swfdec_as_value_to_primitive (rval);
+ rtype = rval->type;
+ if (rtype != SWFDEC_AS_TYPE_OBJECT) {
+ cond = FALSE;
+ goto out;
+ }
+ ro = SWFDEC_AS_VALUE_GET_OBJECT (rval);
+ } else if (SWFDEC_IS_MOVIE (ro)) {
+ swfdec_as_value_to_primitive (lval);
+ ltype = lval->type;
+ if (ltype != SWFDEC_AS_TYPE_OBJECT) {
+ cond = FALSE;
+ goto out;
+ }
+ lo = SWFDEC_AS_VALUE_GET_OBJECT (lval);
+ } else {
+ lo = SWFDEC_AS_VALUE_GET_OBJECT (lval);
+ ro = SWFDEC_AS_VALUE_GET_OBJECT (rval);
+ }
+ cond = lo == ro;
+ goto out;
+ }
+
+ /* compare strings */
+ if (ltype == SWFDEC_AS_TYPE_STRING && rtype == SWFDEC_AS_TYPE_STRING) {
+ /* FIXME: flash 5 case insensitive? */
+ cond = SWFDEC_AS_VALUE_GET_STRING (<mp) == SWFDEC_AS_VALUE_GET_STRING (&rtmp);
+ goto out;
+ }
+
+ /* convert to numbers */
+ if (SWFDEC_AS_VALUE_IS_OBJECT (<mp) && !SWFDEC_IS_MOVIE (SWFDEC_AS_VALUE_GET_OBJECT (<mp))) {
+ l = swfdec_as_value_to_number (cx, lval);
+ } else {
+ l = swfdec_as_value_to_number (cx, <mp);
+ }
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&rtmp) && !SWFDEC_IS_MOVIE (SWFDEC_AS_VALUE_GET_OBJECT (&rtmp))) {
+ r = swfdec_as_value_to_number (cx, rval);
+ } else {
+ r = swfdec_as_value_to_number (cx, &rtmp);
+ }
+
+ /* get rid of undefined and null */
+ cond = rtype == SWFDEC_AS_TYPE_UNDEFINED || rtype == SWFDEC_AS_TYPE_NULL;
+ if (ltype == SWFDEC_AS_TYPE_UNDEFINED || ltype == SWFDEC_AS_TYPE_NULL) {
+ goto out;
+ } else if (cond) {
+ cond = FALSE;
+ goto out;
+ }
+
+ /* else compare as numbers */
+ if (isnan (l) && isnan (r))
+ cond = ltype == rtype;
+ else
+ cond = l == r;
+
+out:
+ swfdec_as_stack_pop (cx);
+ SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1), cond);
+}
+
+static void
+swfdec_action_equals2_6 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *rval, *lval;
+ SwfdecAsValueType ltype, rtype;
+ double l, r;
+ gboolean cond;
+
+ rval = swfdec_as_stack_peek (cx, 1);
+ lval = swfdec_as_stack_peek (cx, 2);
+ ltype = lval->type;
+ rtype = rval->type;
+
+ /* get objects compared */
+ if (ltype == SWFDEC_AS_TYPE_OBJECT && rtype == SWFDEC_AS_TYPE_OBJECT) {
+ SwfdecAsObject *lo = SWFDEC_AS_VALUE_GET_OBJECT (lval);
+ SwfdecAsObject *ro = SWFDEC_AS_VALUE_GET_OBJECT (rval);
+
+ if (SWFDEC_IS_MOVIE (lo) && SWFDEC_IS_MOVIE (ro)) {
+ lo = SWFDEC_AS_OBJECT (swfdec_movie_resolve (SWFDEC_MOVIE (lo)));
+ ro = SWFDEC_AS_OBJECT (swfdec_movie_resolve (SWFDEC_MOVIE (ro)));
+ } else if (SWFDEC_IS_MOVIE (lo)) {
+ swfdec_as_value_to_primitive (rval);
+ rtype = rval->type;
+ if (rtype != SWFDEC_AS_TYPE_OBJECT) {
+ cond = FALSE;
+ goto out;
+ }
+ ro = SWFDEC_AS_VALUE_GET_OBJECT (rval);
+ } else if (SWFDEC_IS_MOVIE (ro)) {
+ swfdec_as_value_to_primitive (lval);
+ ltype = lval->type;
+ if (ltype != SWFDEC_AS_TYPE_OBJECT) {
+ cond = FALSE;
+ goto out;
+ }
+ lo = SWFDEC_AS_VALUE_GET_OBJECT (lval);
+ }
+ cond = lo == ro;
+ goto out;
+ }
+
+ /* if one of the values is an object, call valueOf.
+ * If it's still an object, return FALSE */
+ swfdec_as_value_to_primitive (lval);
+ ltype = lval->type;
+ if (ltype == SWFDEC_AS_TYPE_OBJECT) {
+ cond = FALSE;
+ goto out;
+ }
+ swfdec_as_value_to_primitive (rval);
+ rtype = rval->type;
+ if (rtype == SWFDEC_AS_TYPE_OBJECT) {
+ cond = FALSE;
+ goto out;
+ }
+ /* now we have a comparison without objects */
+
+ /* get rid of undefined and null */
+ cond = rtype == SWFDEC_AS_TYPE_UNDEFINED || rtype == SWFDEC_AS_TYPE_NULL;
+ if (ltype == SWFDEC_AS_TYPE_UNDEFINED || ltype == SWFDEC_AS_TYPE_NULL) {
+ goto out;
+ } else if (cond) {
+ cond = FALSE;
+ goto out;
+ }
+
+ /* compare strings */
+ if (ltype == SWFDEC_AS_TYPE_STRING && rtype == SWFDEC_AS_TYPE_STRING) {
+ /* FIXME: flash 5 case insensitive? */
+ cond = SWFDEC_AS_VALUE_GET_STRING (lval) == SWFDEC_AS_VALUE_GET_STRING (rval);
+ goto out;
+ }
+
+ /* else compare as numbers */
+ l = swfdec_as_value_to_number (cx, lval);
+ r = swfdec_as_value_to_number (cx, rval);
+
+ if (isnan (l) && isnan (r))
+ cond = ltype == rtype;
+ else
+ cond = l == r;
+
+out:
+ swfdec_as_stack_pop (cx);
+ SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1), cond);
+}
+
+static void
+swfdec_action_equals2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ if (cx->version <= 5) {
+ swfdec_action_equals2_5 (cx, action, data, len);
+ } else {
+ swfdec_action_equals2_6 (cx, action, data, len);
+ }
+}
+
+static void
+swfdec_action_strict_equals (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *rval, *lval;
+ gboolean cond;
+
+ rval = swfdec_as_stack_peek (cx, 1);
+ lval = swfdec_as_stack_peek (cx, 2);
+
+ if (rval->type != lval->type) {
+ cond = FALSE;
+ } else {
+ switch (rval->type) {
+ case SWFDEC_AS_TYPE_UNDEFINED:
+ case SWFDEC_AS_TYPE_NULL:
+ cond = TRUE;
+ break;
+ case SWFDEC_AS_TYPE_BOOLEAN:
+ cond = SWFDEC_AS_VALUE_GET_BOOLEAN (rval) == SWFDEC_AS_VALUE_GET_BOOLEAN (lval);
+ break;
+ case SWFDEC_AS_TYPE_NUMBER:
+ {
+ double l, r;
+ r = SWFDEC_AS_VALUE_GET_NUMBER (rval);
+ l = SWFDEC_AS_VALUE_GET_NUMBER (lval);
+ cond = (l == r) || (isnan (l) && isnan (r));
+ }
+ break;
+ case SWFDEC_AS_TYPE_STRING:
+ cond = SWFDEC_AS_VALUE_GET_STRING (rval) == SWFDEC_AS_VALUE_GET_STRING (lval);
+ break;
+ case SWFDEC_AS_TYPE_OBJECT:
+ {
+ SwfdecAsObject *lo = SWFDEC_AS_VALUE_GET_OBJECT (lval);
+ SwfdecAsObject *ro = SWFDEC_AS_VALUE_GET_OBJECT (rval);
+ if (SWFDEC_IS_MOVIE (lo) && SWFDEC_IS_MOVIE (ro)) {
+ cond = swfdec_movie_resolve (SWFDEC_MOVIE (lo)) == swfdec_movie_resolve (SWFDEC_MOVIE (ro));
+ } else if (!SWFDEC_IS_MOVIE (lo) && !SWFDEC_IS_MOVIE (ro)) {
+ cond = lo == ro;
+ } else {
+ cond = FALSE;
+ }
+ }
+ break;
+ case SWFDEC_AS_TYPE_INT:
+ default:
+ g_assert_not_reached ();
+ cond = FALSE;
+ }
+ }
+
+ swfdec_as_stack_pop (cx);
+ SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 1), cond);
+}
+
+static void
+swfdec_action_do_set_target (SwfdecAsContext *cx, const char *target, const char *end)
+{
+ swfdec_as_frame_set_target (cx->frame, NULL);
+
+ if (target != end) {
+ SwfdecAsObject *o = swfdec_action_lookup_object (cx, NULL, target, end);
+ if (o == NULL) {
+ SWFDEC_WARNING ("target \"%s\" is not an object", target);
+ } else if (!SWFDEC_IS_MOVIE (o)) {
+ SWFDEC_FIXME ("target \"%s\" is not a movie, something weird is supposed to happen now", target);
+ o = NULL;
+ }
+ swfdec_as_frame_set_target (cx->frame, o);
+ }
+}
+
+static void
+swfdec_action_set_target (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ char *end;
+
+ end = memchr (data, 0, len);
+ if (end == NULL) {
+ SWFDEC_ERROR ("SetTarget action does not specify a string");
+ return;
+ }
+ swfdec_action_do_set_target (cx, (const char *) data, end);
+}
+
+static void
+swfdec_action_set_target2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ const char *s;
+
+ s = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1));
+ swfdec_action_do_set_target (cx, s, s + strlen (s));
+ swfdec_as_stack_pop (cx);
+}
+
+static void
+swfdec_action_start_drag (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecRect rect, *rectp = NULL;
+ SwfdecMovie *movie;
+ gboolean center;
+ guint stack_size = 3;
+
+ swfdec_as_stack_ensure_size (cx, 3);
+ center = swfdec_as_value_to_boolean (cx, swfdec_as_stack_peek (cx, 2));
+ if (swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 3))) {
+ swfdec_as_stack_ensure_size (cx, 7);
+ rect.x0 = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 7));
+ rect.y0 = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 6));
+ rect.x1 = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 5));
+ rect.y1 = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 4));
+ swfdec_rect_scale (&rect, &rect, SWFDEC_TWIPS_SCALE_FACTOR);
+ stack_size = 7;
+ rectp = ▭
+ }
+ if (!SWFDEC_IS_PLAYER (cx)) {
+ SWFDEC_ERROR ("called startDrag on a non-SwfdecPlayer");
+ } else {
+ movie = swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx), swfdec_as_stack_peek (cx, 1));
+ if (movie != NULL) {
+ swfdec_player_set_drag_movie (SWFDEC_PLAYER (cx), movie, center, rectp);
+ } else {
+ SWFDEC_ERROR ("startDrag on something not a Movie");
+ }
+ }
+ swfdec_as_stack_pop_n (cx, stack_size);
+}
+
+static void
+swfdec_action_end_drag (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ if (SWFDEC_IS_PLAYER (cx)) {
+ swfdec_player_set_drag_movie (SWFDEC_PLAYER (cx), NULL, FALSE, NULL);
+ } else {
+ SWFDEC_WARNING ("can't end a drag on non-players");
+ }
+}
+
+static void
+swfdec_action_stop_sounds (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ if (SWFDEC_IS_PLAYER (cx)) {
+ swfdec_player_stop_all_sounds (SWFDEC_PLAYER (cx));
+ }
+}
+
+static void
+swfdec_action_new_object (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *constructor;
+ SwfdecAsFunction *fun;
+ guint n_args;
+
+ swfdec_as_stack_ensure_size (cx, 2);
+ swfdec_action_get_variable (cx, action, data, len);
+ constructor = swfdec_as_stack_peek (cx, 1);
+ n_args = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 2));
+ n_args = MIN (swfdec_as_stack_get_size (cx) - 2, n_args);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (constructor) ||
+ !SWFDEC_IS_AS_FUNCTION (fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (constructor))) {
+ SWFDEC_WARNING ("not a constructor");
+ goto fail;
+ }
+
+ swfdec_as_stack_pop_n (cx, 2);
+ swfdec_as_object_create (fun, n_args, NULL, NULL);
+ return;
+
+fail:
+ swfdec_as_stack_pop_n (cx, n_args + 1);
+ SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 1));
+}
+
+static void
+swfdec_action_new_method (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *constructor;
+ SwfdecAsFunction *fun;
+ guint n_args;
+ const char *name;
+
+ swfdec_as_stack_ensure_size (cx, 3);
+ name = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1));
+
+ constructor = swfdec_as_stack_peek (cx, 2);
+ n_args = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 3));
+ n_args = MIN (swfdec_as_stack_get_size (cx) - 3, n_args);
+ if (name != SWFDEC_AS_STR_EMPTY) {
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (constructor)) {
+ SWFDEC_WARNING ("NewMethod called without an object to get variable %s from", name);
+ goto fail;
+ }
+ swfdec_as_object_get_variable (SWFDEC_AS_VALUE_GET_OBJECT (constructor),
+ name, constructor);
+ }
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (constructor) ||
+ !SWFDEC_IS_AS_FUNCTION (fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (constructor))) {
+ SWFDEC_WARNING ("%s is not a constructor", name);
+ goto fail;
+ }
+
+ swfdec_as_stack_pop_n (cx, 3);
+ swfdec_as_object_create (fun, n_args, NULL, NULL);
+ return;
+
+fail:
+ swfdec_as_stack_pop_n (cx, n_args + 2);
+ SWFDEC_AS_VALUE_SET_UNDEFINED (swfdec_as_stack_peek (cx, 1));
+}
+
+static void
+swfdec_action_init_object (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsObject *object;
+ guint i, n_args, size;
+
+ n_args = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 1));
+ swfdec_as_stack_pop (cx);
+ if (n_args * 2 > swfdec_as_stack_get_size (cx)) {
+ size = swfdec_as_stack_get_size (cx);
+ SWFDEC_FIXME ("InitObject action with too small stack, help!");
+ n_args = size / 2;
+ size &= 1;
+ } else {
+ size = 0;
+ }
+
+ object = swfdec_as_object_new (cx);
+ if (object == NULL)
+ return;
+ for (i = 0; i < n_args; i++) {
+ const char *s = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 2));
+ swfdec_as_object_set_variable (object, s, swfdec_as_stack_peek (cx, 1));
+ swfdec_as_stack_pop_n (cx, 2);
+ }
+ swfdec_as_stack_pop_n (cx, size);
+ SWFDEC_AS_VALUE_SET_OBJECT (swfdec_as_stack_push (cx), object);
+}
+
+static void
+swfdec_action_init_array (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ int i, n;
+ SwfdecAsObject *array;
+
+ swfdec_as_stack_ensure_size (cx, 1);
+ n = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 1));
+ swfdec_as_stack_pop (cx);
+ array = swfdec_as_array_new (cx);
+ if (array == NULL)
+ return;
+ /* NB: we can't increase the stack here, as the number can easily be MAXINT */
+ for (i = 0; i < n && swfdec_as_stack_get_size (cx) > 0; i++) {
+ swfdec_as_stack_ensure_size (cx, 1);
+ swfdec_as_array_push (SWFDEC_AS_ARRAY (array), swfdec_as_stack_pop (cx));
+ }
+ if (i != n) {
+ SwfdecAsValue val;
+ SWFDEC_AS_VALUE_SET_INT (&val, i);
+ swfdec_as_object_set_variable (array, SWFDEC_AS_STR_length, &val);
+ }
+ SWFDEC_AS_VALUE_SET_OBJECT (swfdec_as_stack_push (cx), array);
+}
+
+static void
+swfdec_action_define_function (SwfdecAsContext *cx, guint action,
+ const guint8 *data, guint len)
+{
+ char *function_name;
+ const char *name = NULL;
+ guint i, n_args, size, n_registers;
+ SwfdecBits bits;
+ SwfdecBuffer *buffer;
+ SwfdecAsFunction *fun;
+ SwfdecAsFrame *frame;
+ SwfdecScript *script;
+ guint flags = 0;
+ SwfdecScriptArgument *args;
+ gboolean v2 = (action == 0x8e);
+
+ frame = cx->frame;
+ swfdec_bits_init_data (&bits, data, len);
+ function_name = swfdec_bits_get_string (&bits, cx->version);
+ if (function_name == NULL) {
+ SWFDEC_ERROR ("could not parse function name");
+ return;
+ }
+ n_args = swfdec_bits_get_u16 (&bits);
+ if (v2) {
+ n_registers = swfdec_bits_get_u8 (&bits);
+ if (n_registers == 0)
+ n_registers = 4;
+ flags = swfdec_bits_get_u16 (&bits);
+ } else {
+ n_registers = 5;
+ }
+ if (n_args) {
+ args = g_new0 (SwfdecScriptArgument, n_args);
+ for (i = 0; i < n_args && swfdec_bits_left (&bits); i++) {
+ if (v2) {
+ args[i].preload = swfdec_bits_get_u8 (&bits);
+ if (args[i].preload && args[i].preload >= n_registers) {
+ SWFDEC_ERROR ("argument %u cannot be preloaded into register %u out of %u",
+ i, args[i].preload, n_registers);
+ /* FIXME: figure out correct error handling here */
+ args[i].preload = 0;
+ }
+ }
+ args[i].name = swfdec_bits_get_string (&bits, cx->version);
+ if (args[i].name == NULL || args[i].name == '\0') {
+ SWFDEC_ERROR ("empty argument name not allowed");
+ g_free (args);
+ return;
+ }
+ /* FIXME: check duplicate arguments */
+ }
+ } else {
+ args = NULL;
+ }
+ size = swfdec_bits_get_u16 (&bits);
+ /* check the script can be created */
+ if (frame->script->buffer->data + frame->script->buffer->length < frame->pc + 3 + len + size) {
+ SWFDEC_ERROR ("size of function is too big");
+ g_free (args);
+ g_free (function_name);
+ return;
+ }
+ /* create the script */
+ buffer = swfdec_buffer_new_subbuffer (frame->script->buffer,
+ frame->pc + 3 + len - frame->script->buffer->data, size);
+ swfdec_bits_init (&bits, buffer);
+ if (*function_name) {
+ name = function_name;
+ } else if (swfdec_as_stack_get_size (cx) > 0) {
+ /* This is kind of a hack that uses a feature of the Adobe compiler:
+ * foo = function () {} is compiled as these actions:
+ * Push "foo", DefineFunction, SetVariable/SetMember
+ * With this knowledge we can inspect the topmost stack member, since
+ * it will contain the name this function will soon be assigned to.
+ */
+ if (SWFDEC_AS_VALUE_IS_STRING (swfdec_as_stack_peek (cx, 1)))
+ name = SWFDEC_AS_VALUE_GET_STRING (swfdec_as_stack_peek (cx, 1));
+ }
+ if (name == NULL)
+ name = "unnamed_function";
+ script = swfdec_script_new_from_bits (&bits, name, cx->version);
+ swfdec_buffer_unref (buffer);
+ if (script == NULL) {
+ SWFDEC_ERROR ("failed to create script");
+ g_free (args);
+ g_free (function_name);
+ return;
+ }
+ if (frame->constant_pool_buffer)
+ script->constant_pool = swfdec_buffer_ref (frame->constant_pool_buffer);
+ script->flags = flags;
+ script->n_registers = n_registers;
+ script->n_arguments = n_args;
+ script->arguments = args;
+ /* see function-scope tests */
+ if (cx->version > 5) {
+ /* FIXME: or original target? */
+ fun = swfdec_as_script_function_new (frame->original_target, frame->scope_chain, script);
+ } else {
+ fun = swfdec_as_script_function_new (frame->original_target, NULL, script);
+ }
+ if (fun == NULL)
+ return;
+ /* This is a hack that should only trigger for functions defined in the init scripts.
+ * It is supposed to ensure that those functions inherit their target when being
+ * called instead of when being defined */
+ if (!SWFDEC_IS_MOVIE (frame->original_target))
+ SWFDEC_AS_SCRIPT_FUNCTION (fun)->target = NULL;
+ /* attach the function */
+ if (*function_name == '\0') {
+ swfdec_as_stack_ensure_free (cx, 1);
+ SWFDEC_AS_VALUE_SET_OBJECT (swfdec_as_stack_push (cx), SWFDEC_AS_OBJECT (fun));
+ } else {
+ SwfdecAsValue funval;
+ /* FIXME: really varobj? Not eval or sth like that? */
+ name = swfdec_as_context_get_string (cx, function_name);
+ SWFDEC_AS_VALUE_SET_OBJECT (&funval, SWFDEC_AS_OBJECT (fun));
+ swfdec_as_object_set_variable (frame->target, name, &funval);
+ }
+
+ /* update current context */
+ frame->pc += 3 + len + size;
+ g_free (function_name);
+}
+
+static void
+swfdec_action_bitwise (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ int a, b;
+
+ a = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 1));
+ b = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 2));
+
+ switch (action) {
+ case 0x60:
+ a = (int) (a & b);
+ break;
+ case 0x61:
+ a = (int) (a | b);
+ break;
+ case 0x62:
+ a = (int) (a ^ b);
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ swfdec_as_stack_pop (cx);
+ SWFDEC_AS_VALUE_SET_INT (swfdec_as_stack_peek (cx, 1), a);
+}
+
+static void
+swfdec_action_shift (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ int amount, value;
+
+ amount = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 1));
+ amount &= 31;
+ value = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 2));
+
+ switch (action) {
+ case 0x63:
+ value = value << amount;
+ break;
+ case 0x64:
+ value = ((gint) value) >> amount;
+ break;
+ case 0x65:
+ value = ((guint) value) >> amount;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ swfdec_as_stack_pop (cx);
+ SWFDEC_AS_VALUE_SET_INT (swfdec_as_stack_peek (cx, 1), value);
+}
+
+static void
+swfdec_action_to_integer (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *val = swfdec_as_stack_peek (cx, 1);
+
+ SWFDEC_AS_VALUE_SET_INT (val, swfdec_as_value_to_integer (cx, val));
+}
+
+static void
+swfdec_action_target_path (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *val;
+ SwfdecMovie *movie;
+ char *s;
+
+ val = swfdec_as_stack_peek (cx, 1);
+
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (val) ||
+ !SWFDEC_IS_MOVIE (movie = (SwfdecMovie *) SWFDEC_AS_VALUE_GET_OBJECT (val))) {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (val);
+ return;
+ }
+ s = swfdec_movie_get_path (movie, TRUE);
+ SWFDEC_AS_VALUE_SET_STRING (val, swfdec_as_context_give_string (cx, s));
+}
+
+static void
+swfdec_action_define_local (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsObject *target;
+ const char *name;
+
+ name = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 2));
+ if (cx->frame->is_local) {
+ target = SWFDEC_AS_OBJECT (cx->frame);
+ } else {
+ target = cx->frame->target;
+ }
+ swfdec_as_object_set_variable (target, name,
+ swfdec_as_stack_peek (cx, 1));
+ swfdec_as_stack_pop_n (cx, 2);
+}
+
+static void
+swfdec_action_define_local2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue val = { 0, };
+ SwfdecAsObject *target;
+ const char *name;
+
+ name = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1));
+ if (cx->frame->is_local) {
+ target = SWFDEC_AS_OBJECT (cx->frame);
+ } else {
+ target = cx->frame->target;
+ }
+ swfdec_as_object_set_variable (target, name, &val);
+ swfdec_as_stack_pop (cx);
+}
+
+static void
+swfdec_action_return (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ swfdec_as_frame_return (cx->frame, swfdec_as_stack_pop (cx));
+}
+
+static void
+swfdec_action_delete (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *val;
+ const char *name;
+ gboolean success = FALSE;
+
+ name = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1));
+ val = swfdec_as_stack_peek (cx, 2);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
+ success = swfdec_as_object_delete_variable (
+ SWFDEC_AS_VALUE_GET_OBJECT (val), name) == SWFDEC_AS_DELETE_DELETED;
+ }
+ SWFDEC_AS_VALUE_SET_BOOLEAN (val, success);
+ swfdec_as_stack_pop_n (cx, 1);
+}
+
+static void
+swfdec_action_delete2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *val;
+ const char *name;
+ gboolean success = FALSE;
+
+ val = swfdec_as_stack_peek (cx, 1);
+ name = swfdec_as_value_to_string (cx, val);
+ success = swfdec_as_frame_delete_variable (cx->frame, name) == SWFDEC_AS_DELETE_DELETED;
+ SWFDEC_AS_VALUE_SET_BOOLEAN (val, success);
+}
+
+static void
+swfdec_action_store_register (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ if (len != 1) {
+ SWFDEC_ERROR ("StoreRegister action requires a length of 1, but got %u", len);
+ return;
+ }
+ if (!swfdec_action_has_register (cx, *data)) {
+ SWFDEC_ERROR ("Cannot store into register %u, not enough registers", (guint) *data);
+ return;
+ }
+ cx->frame->registers[*data] = *swfdec_as_stack_peek (cx, 1);
+}
+
+static void
+swfdec_action_modulo (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ double x, y;
+
+ y = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 1));
+ x = swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 2));
+ /* yay, we're portable! */
+ if (y == 0.0) {
+ x = NAN;
+ } else {
+ errno = 0;
+ x = fmod (x, y);
+ if (errno != 0) {
+ SWFDEC_FIXME ("errno set after fmod");
+ }
+ }
+ swfdec_as_stack_pop (cx);
+ SWFDEC_AS_VALUE_SET_NUMBER (swfdec_as_stack_peek (cx, 1), x);
+}
+
+static void
+swfdec_action_swap (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ swfdec_as_stack_swap (cx, 1, 2);
+}
+
+static void
+swfdec_action_to_number (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SWFDEC_AS_VALUE_SET_NUMBER (swfdec_as_stack_peek (cx, 1),
+ swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 1)));
+}
+
+static void
+swfdec_action_to_string (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_peek (cx, 1),
+ swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 1)));
+}
+
+static void
+swfdec_action_type_of (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *val;
+ const char *type;
+
+ val = swfdec_as_stack_peek (cx, 1);
+ switch (val->type) {
+ case SWFDEC_AS_TYPE_NUMBER:
+ type = SWFDEC_AS_STR_number;
+ break;
+ case SWFDEC_AS_TYPE_BOOLEAN:
+ type = SWFDEC_AS_STR_boolean;
+ break;
+ case SWFDEC_AS_TYPE_STRING:
+ type = SWFDEC_AS_STR_string;
+ break;
+ case SWFDEC_AS_TYPE_UNDEFINED:
+ type = SWFDEC_AS_STR_undefined;
+ break;
+ case SWFDEC_AS_TYPE_NULL:
+ type = SWFDEC_AS_STR_null;
+ break;
+ case SWFDEC_AS_TYPE_OBJECT:
+ {
+ SwfdecAsObject *obj = SWFDEC_AS_VALUE_GET_OBJECT (val);
+ if (SWFDEC_IS_MOVIE (obj)) {
+ if (SWFDEC_IS_TEXT_FIELD_MOVIE (obj)) {
+ type = SWFDEC_AS_STR_object;
+ } else {
+ type = SWFDEC_AS_STR_movieclip;
+ }
+ } else if (SWFDEC_IS_AS_FUNCTION (obj)) {
+ type = SWFDEC_AS_STR_function;
+ } else {
+ type = SWFDEC_AS_STR_object;
+ }
+ }
+ break;
+ case SWFDEC_AS_TYPE_INT:
+ default:
+ g_assert_not_reached ();
+ type = SWFDEC_AS_STR_EMPTY;
+ break;
+ }
+ SWFDEC_AS_VALUE_SET_STRING (val, type);
+}
+
+static void
+swfdec_action_get_time (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ GTimeVal tv;
+ gulong diff;
+
+ swfdec_as_context_get_time (cx, &tv);
+ /* we assume here that swfdec_as_context_get_time always returns a tv > start_time */
+ diff = tv.tv_sec - cx->start_time.tv_sec;
+ if (diff > G_MAXULONG / 1000 - 1) {
+ SWFDEC_ERROR ("FIXME: time overflow");
+ }
+ diff *= 1000;
+ diff = diff + (tv.tv_usec - cx->start_time.tv_usec) / 1000;
+
+ SWFDEC_AS_VALUE_SET_INT (swfdec_as_stack_push (cx), diff);
+}
+
+static gboolean
+swfdec_action_is_instance_of (SwfdecAsObject *object,
+ SwfdecAsObject *constructor)
+{
+ SwfdecAsValue val;
+ SwfdecAsObject *class, *prototype;
+ GSList *iter;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), FALSE);
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (constructor), FALSE);
+
+ // FIXME: propflag tests are wrong, and we shouldn't get __proto__.prototype
+ swfdec_as_object_get_variable (constructor, SWFDEC_AS_STR_prototype, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return FALSE;
+ prototype = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+
+ class = object;
+ while ((class = swfdec_as_object_get_prototype (class)) != NULL) {
+ if (class == prototype)
+ return TRUE;
+ for (iter = class->interfaces; iter != NULL; iter = iter->next) {
+ if (iter->data == prototype)
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static void
+swfdec_action_instance_of (SwfdecAsContext *cx, guint action,
+ const guint8 *data, guint len)
+{
+ SwfdecAsValue *val;
+ SwfdecAsObject *object, *constructor;
+
+ val = swfdec_as_stack_pop (cx);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
+ constructor = SWFDEC_AS_VALUE_GET_OBJECT (val);
+ } else {
+ constructor = NULL;
+ }
+
+ val = swfdec_as_stack_pop (cx);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
+ object = SWFDEC_AS_VALUE_GET_OBJECT (val);
+ } else {
+ object = NULL;
+ }
+
+
+ if (object == NULL || constructor == NULL) {
+ SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_push (cx), FALSE);
+ return;
+ }
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_push (cx),
+ swfdec_action_is_instance_of (object, constructor));
+}
+
+static void
+swfdec_action_cast (SwfdecAsContext *cx, guint action, const guint8 *data,
+ guint len)
+{
+ SwfdecAsValue *val;
+ SwfdecAsObject *object, *constructor;
+
+ val = swfdec_as_stack_pop (cx);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
+ object = SWFDEC_AS_VALUE_GET_OBJECT (val);
+ } else {
+ object = NULL;
+ }
+
+ val = swfdec_as_stack_pop (cx);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
+ constructor = SWFDEC_AS_VALUE_GET_OBJECT (val);
+ } else {
+ constructor = NULL;
+ }
+
+ if (object == NULL || constructor == NULL) {
+ SWFDEC_AS_VALUE_SET_NULL (swfdec_as_stack_push (cx));
+ return;
+ }
+
+ if (swfdec_action_is_instance_of (object, constructor)) {
+ SWFDEC_AS_VALUE_SET_OBJECT (swfdec_as_stack_push (cx), object);
+ } else {
+ SWFDEC_AS_VALUE_SET_NULL (swfdec_as_stack_push (cx));
+ }
+}
+
+static void
+swfdec_action_implements (SwfdecAsContext *cx, guint action,
+ const guint8 *data, guint len)
+{
+ SwfdecAsValue *val, *argv;
+ SwfdecAsObject *object, *proto, *interface;
+ int argc, i;
+
+ swfdec_as_stack_ensure_size (cx, 2);
+
+ val = swfdec_as_stack_pop (cx);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
+ object = SWFDEC_AS_VALUE_GET_OBJECT (val);
+ swfdec_as_object_get_variable (object, SWFDEC_AS_STR_prototype, val);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (val)) {
+ proto = SWFDEC_AS_VALUE_GET_OBJECT (val);
+ } else {
+ proto = NULL;
+ }
+ } else {
+ object = NULL;
+ proto = NULL;
+ }
+
+ val = swfdec_as_stack_pop (cx);
+ argc = swfdec_as_value_to_integer (cx, val);
+
+ if (argc > 0) {
+ swfdec_as_stack_ensure_size (cx, argc);
+ argv = swfdec_as_stack_pop_n (cx, argc);
+ } else {
+ argv = NULL;
+ }
+
+ if (proto == NULL)
+ return;
+
+ for (i = 0; i < argc; i++) {
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[i]))
+ continue;
+ interface = SWFDEC_AS_VALUE_GET_OBJECT (&argv[i]);
+ swfdec_as_object_get_variable (interface, SWFDEC_AS_STR_prototype, val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (val))
+ continue;
+ proto->interfaces =
+ g_slist_prepend (proto->interfaces, SWFDEC_AS_VALUE_GET_OBJECT (val));
+ }
+}
+
+static void
+swfdec_action_extends (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *superclass, *subclass, proto;
+ SwfdecAsObject *prototype;
+ SwfdecAsObject *super;
+
+ superclass = swfdec_as_stack_peek (cx, 1);
+ subclass = swfdec_as_stack_peek (cx, 2);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (superclass) ||
+ !SWFDEC_IS_AS_FUNCTION (SWFDEC_AS_VALUE_GET_OBJECT (superclass))) {
+ SWFDEC_ERROR ("superclass is not a function");
+ goto fail;
+ }
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (subclass)) {
+ SWFDEC_ERROR ("subclass is not an object");
+ goto fail;
+ }
+ super = SWFDEC_AS_VALUE_GET_OBJECT (superclass);
+ prototype = swfdec_as_object_new_empty (cx);
+ if (prototype == NULL)
+ goto fail;
+ swfdec_as_object_get_variable (super, SWFDEC_AS_STR_prototype, &proto);
+ swfdec_as_object_set_variable (prototype, SWFDEC_AS_STR___proto__, &proto);
+ if (cx->version > 5) {
+ swfdec_as_object_set_variable_and_flags (prototype, SWFDEC_AS_STR___constructor__,
+ superclass, SWFDEC_AS_VARIABLE_HIDDEN);
+ }
+ SWFDEC_AS_VALUE_SET_OBJECT (&proto, prototype);
+ swfdec_as_object_set_variable (SWFDEC_AS_VALUE_GET_OBJECT (subclass),
+ SWFDEC_AS_STR_prototype, &proto);
+fail:
+ swfdec_as_stack_pop_n (cx, 2);
+}
+
+static gboolean
+swfdec_action_enumerate_foreach (SwfdecAsObject *object, const char *variable,
+ SwfdecAsValue *value, guint flags, gpointer listp)
+{
+ GSList **list = listp;
+
+ if (flags & SWFDEC_AS_VARIABLE_HIDDEN)
+ return TRUE;
+
+ *list = g_slist_remove (*list, variable);
+ *list = g_slist_prepend (*list, (gpointer) variable);
+ return TRUE;
+}
+
+static void
+swfdec_action_do_enumerate (SwfdecAsContext *cx, SwfdecAsObject *object)
+{
+ guint i;
+ GSList *walk, *list = NULL;
+
+ for (i = 0; i < 256 && object; i++) {
+ swfdec_as_object_foreach (object, swfdec_action_enumerate_foreach, &list);
+ object = swfdec_as_object_get_prototype (object);
+ }
+ if (i == 256) {
+ swfdec_as_context_abort (object->context, "Prototype recursion limit exceeded");
+ g_slist_free (list);
+ return;
+ }
+ list = g_slist_reverse (list);
+ i = 0;
+ for (walk = list; walk; walk = walk->next) {
+ /* 8 is an arbitrary value */
+ if (i % 8 == 0) {
+ swfdec_as_stack_ensure_free (cx, 8);
+ i = 0;
+ }
+ i++;
+ SWFDEC_AS_VALUE_SET_STRING (swfdec_as_stack_push (cx), walk->data);
+ }
+ g_slist_free (list);
+}
+
+static void
+swfdec_action_enumerate2 (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *val;
+ SwfdecAsObject *obj;
+
+ val = swfdec_as_stack_peek (cx, 1);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (val)) {
+ SWFDEC_WARNING ("Enumerate called without an object");
+ SWFDEC_AS_VALUE_SET_UNDEFINED (val);
+ return;
+ }
+ obj = SWFDEC_AS_VALUE_GET_OBJECT (val);
+ SWFDEC_AS_VALUE_SET_UNDEFINED (val);
+ swfdec_action_do_enumerate (cx, obj);
+}
+
+static void
+swfdec_action_enumerate (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ /* FIXME: make this proper functions */
+ swfdec_action_get_variable (cx, action, data, len);
+ swfdec_action_enumerate2 (cx, action, data, len);
+}
+
+static void
+swfdec_action_logical (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ gboolean l, r;
+
+ if (cx->version <= 4) {
+ l = (swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 1)) != 0);
+ // don't call second parameter if not necessary
+ if ((action == SWFDEC_AS_ACTION_AND && !l) ||
+ (action != SWFDEC_AS_ACTION_AND && l)) {
+ r = (swfdec_as_value_to_number (cx, swfdec_as_stack_peek (cx, 2)) != 0);
+ } else {
+ r = FALSE;
+ }
+ } else {
+ l = swfdec_as_value_to_boolean (cx, swfdec_as_stack_peek (cx, 1));
+ r = swfdec_as_value_to_boolean (cx, swfdec_as_stack_peek (cx, 2));
+ }
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (swfdec_as_stack_peek (cx, 2),
+ (action == SWFDEC_AS_ACTION_AND) ? (l && r) : (l || r));
+ swfdec_as_stack_pop (cx);
+}
+
+static void
+swfdec_action_char_to_ascii (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *val = swfdec_as_stack_peek (cx, 1);
+ const char *s = swfdec_as_value_to_string (cx, val);
+
+ if (cx->version <= 5) {
+ char *ascii = g_convert (s, -1, "LATIN1", "UTF-8", NULL, NULL, NULL);
+
+ if (ascii == NULL) {
+ /* This can happen if a Flash 5 movie gets loaded into a Flash 7 movie */
+ SWFDEC_FIXME ("Someone threw unconvertible text %s at Flash <= 5", s);
+ SWFDEC_AS_VALUE_SET_INT (val, 0); /* FIXME: what to return??? */
+ } else {
+ SWFDEC_AS_VALUE_SET_INT (val, (guchar) ascii[0]);
+ g_free (ascii);
+ }
+ } else {
+ gunichar *uni = g_utf8_to_ucs4_fast (s, -1, NULL);
+
+ if (uni == NULL) {
+ /* This should never happen, everything is valid UTF-8 in here */
+ g_warning ("conversion of character %s failed", s);
+ SWFDEC_AS_VALUE_SET_INT (val, 0);
+ } else {
+ SWFDEC_AS_VALUE_SET_INT (val, uni[0]);
+ g_free (uni);
+ }
+ }
+}
+
+static void
+swfdec_action_ascii_to_char (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsValue *val = swfdec_as_stack_peek (cx, 1);
+
+ if (cx->version <= 5) {
+ char s[3];
+ char *utf8;
+ guint i;
+
+ if (action == SWFDEC_AS_ACTION_ASCII_TO_CHAR) {
+ s[0] = ((guint) swfdec_as_value_to_integer (cx, val)) % 256;
+ s[1] = 0;
+ } else {
+ g_assert (action == SWFDEC_AS_ACTION_MB_ASCII_TO_CHAR);
+
+ i = ((guint) swfdec_as_value_to_integer (cx, val));
+ if (i > 255) {
+ s[0] = i / 256;
+ s[1] = i % 256;
+ s[2] = 0;
+ } else {
+ s[0] = i;
+ s[1] = 0;
+ }
+ }
+
+ utf8 = g_convert (s, -1, "UTF-8", "LATIN1", NULL, NULL, NULL);
+ if (utf8 == NULL) {
+ g_warning ("conversion of character %u failed", (guint) s[0]);
+ SWFDEC_AS_VALUE_SET_STRING (val, SWFDEC_AS_STR_EMPTY);
+ } else {
+ SWFDEC_AS_VALUE_SET_STRING (val, swfdec_as_context_get_string (cx, utf8));
+ g_free (utf8);
+ }
+ } else {
+ char *s;
+ gunichar c = ((guint) swfdec_as_value_to_integer (cx, val)) % 65536;
+
+ s = g_ucs4_to_utf8 (&c, 1, NULL, NULL, NULL);
+ if (s == NULL) {
+ g_warning ("conversion of character %u failed", (guint) c);
+ SWFDEC_AS_VALUE_SET_STRING (val, SWFDEC_AS_STR_EMPTY);
+ } else {
+ SWFDEC_AS_VALUE_SET_STRING (val, swfdec_as_context_get_string (cx, s));
+ g_free (s);
+ }
+ }
+}
+
+static void
+swfdec_action_throw (SwfdecAsContext *cx, guint action, const guint8 *data,
+ guint len)
+{
+ swfdec_as_context_throw (cx, swfdec_as_stack_pop (cx));
+}
+
+typedef struct {
+ const guint8 * catch_start;
+ const guint8 * finally_start;
+ guint catch_size;
+ guint finally_size;
+
+ gboolean use_register;
+ union {
+ guint register_number;
+ char * variable_name;
+ };
+} TryData;
+
+static void
+swfdec_action_try_data_free (gpointer data)
+{
+ TryData *try_data = data;
+
+ g_return_if_fail (try_data != NULL);
+
+ if (!try_data->use_register)
+ g_free (try_data->variable_name);
+ g_free (try_data);
+}
+
+static void
+swfdec_action_try_end_finally (SwfdecAsFrame *frame, gpointer data)
+{
+ SwfdecAsValue *exception_value = data;
+ SwfdecAsContext *cx;
+
+ g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+ g_return_if_fail (SWFDEC_IS_AS_VALUE (exception_value));
+
+ cx = SWFDEC_AS_OBJECT (frame)->context;
+
+ // finally has ended and we had exception stored, throw it
+ if (!cx->exception)
+ swfdec_as_context_throw (cx, exception_value);
+
+ g_free (data);
+}
+
+static void
+swfdec_action_try_end_catch (SwfdecAsFrame *frame, gpointer data)
+{
+ TryData *try_data = data;
+ SwfdecAsContext *cx;
+ SwfdecAsValue *exception_value, val;
+
+ g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+ g_return_if_fail (try_data != NULL);
+
+ cx = SWFDEC_AS_OBJECT (frame)->context;
+
+ if (swfdec_as_context_catch (cx, &val))
+ {
+ // we got an exception while in catch block:
+ // create new block for finally to pass on the exception
+ // jump to that block
+
+ exception_value = g_malloc (sizeof (SwfdecAsValue));
+ *exception_value = val;
+
+ // FIXME: the exception value is not marked while finally block runs
+ swfdec_as_frame_push_block (frame, try_data->finally_start,
+ try_data->finally_start + try_data->finally_size,
+ swfdec_action_try_end_finally, exception_value);
+ frame->pc = try_data->finally_start;
+ }
+
+ swfdec_action_try_data_free (try_data);
+}
+
+static void
+swfdec_action_try_end_try (SwfdecAsFrame *frame, gpointer data)
+{
+ TryData *try_data = data;
+ SwfdecAsContext *cx;
+ SwfdecAsValue val;
+
+ g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+ g_return_if_fail (try_data != NULL);
+
+ // if we don't have a catch block, we handle try block exactly like it was
+ // catch block
+ if (!try_data->catch_start) {
+ swfdec_action_try_end_catch (frame, try_data);
+ return;
+ }
+
+ cx = SWFDEC_AS_OBJECT (frame)->context;
+
+ if (swfdec_as_context_catch (cx, &val))
+ {
+ // we got an exception while in try block:
+ // set the exception variable
+ // add new block for catch and jump to it
+
+ if (try_data->use_register)
+ {
+ if (try_data->register_number < frame->n_registers) {
+ frame->registers[try_data->register_number] = val;
+ } else {
+ SWFDEC_ERROR ("cannot set Error to register %u: not enough registers",
+ try_data->register_number);
+ }
+ }
+ else
+ {
+ // FIXME: this is duplicate of SetVariable
+ SwfdecAsObject *object;
+ const char *s, *rest;
+
+ s = swfdec_as_context_get_string (cx, try_data->variable_name);
+ if (swfdec_action_get_movie_by_path (cx, s, &object, &rest)) {
+ if (object && rest) {
+ swfdec_as_object_set_variable (object,
+ swfdec_as_context_get_string (cx, rest), &val);
+ } else {
+ if (object) {
+ rest = s;
+ } else {
+ rest = swfdec_as_context_get_string (cx, rest);
+ }
+ swfdec_as_frame_set_variable (frame, rest, &val);
+ }
+ }
+ else
+ {
+ SWFDEC_ERROR ("cannot set Error to variable %s",
+ try_data->variable_name);
+ }
+ }
+
+ swfdec_as_frame_push_block (frame, try_data->catch_start,
+ try_data->catch_start + try_data->catch_size,
+ swfdec_action_try_end_catch, try_data);
+ frame->pc = try_data->catch_start;
+ }
+ else
+ {
+ swfdec_action_try_data_free (try_data);
+ }
+}
+
+static void
+swfdec_action_try (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecBits bits;
+ TryData *try_data;
+ guint try_size;
+ gboolean use_finally, use_catch;
+
+ if (len < 8) {
+ SWFDEC_ERROR ("With action requires a length of at least 8, but got %u",
+ len);
+ return;
+ }
+
+ try_data = g_malloc0 (sizeof (TryData));
+
+ swfdec_bits_init_data (&bits, data, len);
+
+ swfdec_bits_getbits (&bits, 5); // reserved
+ try_data->use_register = swfdec_bits_getbit (&bits);
+ use_finally = swfdec_bits_getbit (&bits);
+ use_catch = swfdec_bits_getbit (&bits);
+
+ try_size = swfdec_bits_get_u16 (&bits);
+ try_data->catch_size = swfdec_bits_get_u16 (&bits);
+ try_data->finally_size = swfdec_bits_get_u16 (&bits);
+ if (use_catch)
+ try_data->catch_start = data + len + try_size;
+ if (use_finally)
+ try_data->finally_start = try_data->catch_start + try_data->catch_size;
+
+ if (try_data->use_register) {
+ try_data->register_number = swfdec_bits_get_u8 (&bits);
+ } else {
+ try_data->variable_name =
+ swfdec_bits_get_string (&bits, cx->version);
+ }
+
+ if (swfdec_bits_left (&bits)) {
+ SWFDEC_WARNING ("leftover bytes in Try action");
+ }
+
+ if (try_data->catch_start || try_data->finally_start) {
+ swfdec_as_frame_push_block (cx->frame, data + len, data + len + try_size,
+ swfdec_action_try_end_try, try_data);
+ } else {
+ SWFDEC_WARNING ("Try with neither catch nor finally block");
+ swfdec_action_try_data_free (try_data);
+ }
+}
+
+static void
+swfdec_action_pop_with (SwfdecAsFrame *frame, gpointer with_object)
+{
+ g_assert (frame->scope_chain->data == with_object);
+ frame->scope_chain = g_slist_delete_link (frame->scope_chain, frame->scope_chain);
+}
+
+static void
+swfdec_action_with (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecAsObject *object;
+ guint offset;
+
+ if (len != 2) {
+ SWFDEC_ERROR ("With action requires a length of 2, but got %u", len);
+ swfdec_as_stack_pop (cx);
+ return;
+ }
+ offset = data[0] | (data[1] << 8);
+ object = swfdec_as_value_to_object (cx, swfdec_as_stack_peek (cx, 1));
+ if (object == NULL) {
+ SWFDEC_INFO ("With called without an object, skipping");
+ cx->frame->pc = (guint8 *) data + len + offset;
+ } else {
+ cx->frame->scope_chain = g_slist_prepend (cx->frame->scope_chain, object);
+ swfdec_as_frame_push_block (cx->frame, data + len, data + len + offset,
+ swfdec_action_pop_with, object);
+ }
+ swfdec_as_stack_pop (cx);
+}
+
+static void
+swfdec_action_remove_sprite (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ if (!SWFDEC_IS_MOVIE (cx->frame->target)) {
+ SWFDEC_FIXME ("target is not a movie in RemoveSprite");
+ } else if (!SWFDEC_IS_PLAYER (cx)) {
+ SWFDEC_INFO ("tried using RemoveSprite in a non-SwfdecPlayer context");
+ } else {
+ SwfdecMovie *movie = swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx),
+ swfdec_as_stack_peek (cx, 1));
+ if (movie && swfdec_depth_classify (movie->depth) == SWFDEC_DEPTH_CLASS_DYNAMIC) {
+ SWFDEC_LOG ("removing clip %s", movie->name);
+ swfdec_movie_remove (movie);
+ } else {
+ SWFDEC_INFO ("cannot remove movie");
+ }
+ }
+ swfdec_as_stack_pop (cx);
+}
+
+static void
+swfdec_action_clone_sprite (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
+{
+ SwfdecMovie *movie, *new_movie;
+ const char *new_name;
+ int depth;
+
+ depth = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx, 1)) - 16384;
+ new_name = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx, 2));
+ if (!SWFDEC_IS_MOVIE (cx->frame->target)) {
+ SWFDEC_FIXME ("target is not a movie in CloneSprite");
+ } else if (!SWFDEC_IS_PLAYER (cx)) {
+ SWFDEC_INFO ("tried using CloneSprite in a non-SwfdecPlayer context");
+ } else {
+ movie = swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx),
+ swfdec_as_stack_peek (cx, 3));
+ if (movie == NULL) {
+ SWFDEC_ERROR ("Object is not an SwfdecMovie object");
+ swfdec_as_stack_pop_n (cx, 3);
+ return;
+ }
+ new_movie = swfdec_movie_duplicate (movie, new_name, depth);
+ if (new_movie) {
+ SWFDEC_LOG ("duplicated %s as %s to depth %u", movie->name, new_movie->name, new_movie->depth);
+ }
+ }
+ swfdec_as_stack_pop_n (cx, 3);
+}
+
+/*** PRINT FUNCTIONS ***/
+
+static char *
+swfdec_action_print_with (guint action, const guint8 *data, guint len)
+{
+ if (len != 2) {
+ SWFDEC_ERROR ("With action requires a length of 2, but got %u", len);
+ return NULL;
+ }
+ return g_strdup_printf ("With %u", data[0] | (data[1] << 8));
+}
+
+static char *
+swfdec_action_print_store_register (guint action, const guint8 *data, guint len)
+{
+ if (len != 1) {
+ SWFDEC_ERROR ("StoreRegister action requires a length of 1, but got %u", len);
+ return NULL;
+ }
+ return g_strdup_printf ("StoreRegister %u", (guint) *data);
+}
+
+static char *
+swfdec_action_print_set_target (guint action, const guint8 *data, guint len)
+{
+ if (!memchr (data, 0, len)) {
+ SWFDEC_ERROR ("SetTarget action does not specify a string");
+ return NULL;
+ }
+ return g_strconcat ("SetTarget ", data, NULL);
+}
+
+static char *
+swfdec_action_print_define_function (guint action, const guint8 *data, guint len)
+{
+ SwfdecBits bits;
+ GString *string;
+ const char *function_name;
+ guint i, n_args, size;
+ gboolean v2 = (action == 0x8e);
+
+ string = g_string_new (v2 ? "DefineFunction2 " : "DefineFunction ");
+ swfdec_bits_init_data (&bits, data, len);
+ /* FIXME: version! */
+ function_name = swfdec_bits_get_string (&bits, 7);
+ if (function_name == NULL) {
+ SWFDEC_ERROR ("could not parse function name");
+ g_string_free (string, TRUE);
+ return NULL;
+ }
+ if (*function_name) {
+ g_string_append (string, function_name);
+ g_string_append_c (string, ' ');
+ }
+ n_args = swfdec_bits_get_u16 (&bits);
+ g_string_append_c (string, '(');
+ if (v2) {
+ /* n_regs = */ swfdec_bits_get_u8 (&bits);
+ /* flags = */ swfdec_bits_get_u16 (&bits);
+ }
+
+ for (i = 0; i < n_args; i++) {
+ guint preload;
+ const char *arg_name;
+ if (v2)
+ preload = swfdec_bits_get_u8 (&bits);
+ else
+ preload = 0;
+ arg_name = swfdec_bits_get_string (&bits, 7);
+ if (preload == 0 && (arg_name == NULL || *arg_name == '\0')) {
+ SWFDEC_ERROR ("empty argument name not allowed");
+ g_string_free (string, TRUE);
+ return NULL;
+ }
+ if (i)
+ g_string_append (string, ", ");
+ g_string_append (string, arg_name);
+ if (preload)
+ g_string_append_printf (string, " (%u)", preload);
+ }
+ g_string_append_c (string, ')');
+ size = swfdec_bits_get_u16 (&bits);
+ g_string_append_printf (string, " %u", size);
+ return g_string_free (string, FALSE);
+}
+
+static char *
+swfdec_action_print_get_url2 (guint action, const guint8 *data, guint len)
+{
+ guint method;
+
+ if (len != 1) {
+ SWFDEC_ERROR ("GetURL2 requires 1 byte of data, not %u", len);
+ return NULL;
+ }
+ method = data[0] >> 6;
+ if (method == 3) {
+ SWFDEC_ERROR ("GetURL method 3 invalid");
+ method = 0;
+ }
+ if (method) {
+ SWFDEC_FIXME ("implement encoding variables using %s", method == 1 ? "GET" : "POST");
+ }
+ return g_strdup_printf ("GetURL2%s%s%s", method == 0 ? "" : (method == 1 ? " GET" : " POST"),
+ data[0] & 2 ? " LoadTarget" : "", data[0] & 1 ? " LoadVariables" : "");
+}
+
+static char *
+swfdec_action_print_get_url (guint action, const guint8 *data, guint len)
+{
+ SwfdecBits bits;
+ char *url, *target, *ret;
+
+ swfdec_bits_init_data (&bits, data, len);
+ url = swfdec_bits_get_string (&bits, 7);
+ target = swfdec_bits_get_string (&bits, 7);
+ if (url == NULL) {
+ SWFDEC_ERROR ("not enough data in GetURL");
+ url = g_strdup ("???");
+ }
+ if (target == NULL) {
+ SWFDEC_ERROR ("not enough data in GetURL");
+ target = g_strdup ("???");
+ }
+ if (swfdec_bits_left (&bits)) {
+ SWFDEC_WARNING ("leftover bytes in GetURL action");
+ }
+ ret = g_strdup_printf ("GetURL %s %s", url, target);
+ g_free (url);
+ g_free (target);
+ return ret;
+}
+
+static char *
+swfdec_action_print_if (guint action, const guint8 *data, guint len)
+{
+ gint16 offset;
+
+ if (len != 2) {
+ SWFDEC_ERROR ("If action length invalid (is %u, should be 2", len);
+ return NULL;
+ }
+ offset = data[0] | (data[1] << 8);
+ return g_strdup_printf ("If %d", (int) offset);
+}
+
+static char *
+swfdec_action_print_jump (guint action, const guint8 *data, guint len)
+{
+ gint16 offset;
+
+ if (len != 2) {
+ SWFDEC_ERROR ("Jump action length invalid (is %u, should be 2", len);
+ return NULL;
+ }
+ offset = data[0] | (data[1] << 8);
+ return g_strdup_printf ("Jump %d", (int) offset);
+}
+
+static char *
+swfdec_action_print_push (guint action, const guint8 *data, guint len)
+{
+ gboolean first = TRUE;
+ SwfdecBits bits;
+ GString *string = g_string_new ("Push");
+
+ swfdec_bits_init_data (&bits, data, len);
+ while (swfdec_bits_left (&bits)) {
+ guint type = swfdec_bits_get_u8 (&bits);
+ if (first)
+ g_string_append (string, " ");
+ else
+ g_string_append (string, ", ");
+ first = FALSE;
+ switch (type) {
+ case 0: /* string */
+ {
+ /* FIXME: need version! */
+ char *s = swfdec_bits_get_string (&bits, 7);
+ if (!s) {
+ g_string_free (string, TRUE);
+ return NULL;
+ }
+ g_string_append_c (string, '"');
+ g_string_append (string, s);
+ g_string_append_c (string, '"');
+ g_free (s);
+ break;
+ }
+ case 1: /* float */
+ g_string_append_printf (string, "%g", swfdec_bits_get_float (&bits));
+ break;
+ case 2: /* null */
+ g_string_append (string, "null");
+ break;
+ case 3: /* undefined */
+ g_string_append (string, "void");
+ break;
+ case 4: /* register */
+ g_string_append_printf (string, "Register %u", swfdec_bits_get_u8 (&bits));
+ break;
+ case 5: /* boolean */
+ g_string_append (string, swfdec_bits_get_u8 (&bits) ? "True" : "False");
+ break;
+ case 6: /* double */
+ g_string_append_printf (string, "%g", swfdec_bits_get_double (&bits));
+ break;
+ case 7: /* 32bit int */
+ g_string_append_printf (string, "%d", swfdec_bits_get_u32 (&bits));
+ break;
+ case 8: /* 8bit ConstantPool address */
+ g_string_append_printf (string, "Pool %u", swfdec_bits_get_u8 (&bits));
+ break;
+ case 9: /* 16bit ConstantPool address */
+ g_string_append_printf (string, "Pool %u", swfdec_bits_get_u16 (&bits));
+ break;
+ default:
+ SWFDEC_ERROR ("Push: type %u not implemented", type);
+ return NULL;
+ }
+ }
+ return g_string_free (string, FALSE);
+}
+
+/* NB: constant pool actions are special in that they are called at init time */
+static char *
+swfdec_action_print_constant_pool (guint action, const guint8 *data, guint len)
+{
+ guint i;
+ GString *string;
+ SwfdecConstantPool *pool;
+
+ /* FIXME: version */
+ pool = swfdec_constant_pool_new_from_action (data, len, 6);
+ if (pool == NULL)
+ return g_strdup ("ConstantPool (invalid)");
+ string = g_string_new ("ConstantPool");
+ for (i = 0; i < swfdec_constant_pool_size (pool); i++) {
+ g_string_append (string, i ? ", " : " ");
+ g_string_append (string, swfdec_constant_pool_get (pool, i));
+ g_string_append_printf (string, " (%u)", i);
+ }
+ return g_string_free (string, FALSE);
+}
+
+#if 0
+static char *
+swfdec_action_print_wait_for_frame2 (guint action, const guint8 *data, guint len)
+{
+ if (len != 1) {
+ SWFDEC_ERROR ("WaitForFrame2 needs a 1-byte data");
+ return NULL;
+ }
+ return g_strdup_printf ("WaitForFrame2 %u", (guint) *data);
+}
+#endif
+
+static char *
+swfdec_action_print_goto_frame2 (guint action, const guint8 *data, guint len)
+{
+ gboolean play, bias;
+ SwfdecBits bits;
+
+ swfdec_bits_init_data (&bits, data, len);
+ if (swfdec_bits_getbits (&bits, 6)) {
+ SWFDEC_WARNING ("reserved bits in GotoFrame2 aren't 0");
+ }
+ bias = swfdec_bits_getbit (&bits);
+ play = swfdec_bits_getbit (&bits);
+ if (bias) {
+ return g_strdup_printf ("GotoFrame2 %s +%u", play ? "play" : "stop",
+ swfdec_bits_get_u16 (&bits));
+ } else {
+ return g_strdup_printf ("GotoFrame2 %s", play ? "play" : "stop");
+ }
+}
+
+static char *
+swfdec_action_print_goto_frame (guint action, const guint8 *data, guint len)
+{
+ guint frame;
+
+ if (len != 2)
+ return NULL;
+
+ frame = data[0] | (data[1] << 8);
+ return g_strdup_printf ("GotoFrame %u", frame);
+}
+
+static char *
+swfdec_action_print_goto_label (guint action, const guint8 *data, guint len)
+{
+ if (!memchr (data, 0, len)) {
+ SWFDEC_ERROR ("GotoLabel action does not specify a string");
+ return NULL;
+ }
+
+ return g_strdup_printf ("GotoLabel %s", data);
+}
+
+static char *
+swfdec_action_print_wait_for_frame (guint action, const guint8 *data, guint len)
+{
+ guint frame, jump;
+
+ if (len != 3)
+ return NULL;
+
+ frame = data[0] | (data[1] << 8);
+ jump = data[2];
+ return g_strdup_printf ("WaitForFrame %u %u", frame, jump);
+}
+
+/*** BIG FUNCTION TABLE ***/
+
+const SwfdecActionSpec swfdec_as_actions[256] = {
+ /* version 1 */
+ [SWFDEC_AS_ACTION_NEXT_FRAME] = { "NextFrame", NULL, 0, 0, swfdec_action_next_frame, 1 },
+ [SWFDEC_AS_ACTION_PREVIOUS_FRAME] = { "PreviousFrame", NULL, 0, 0, swfdec_action_previous_frame, 1 },
+ [SWFDEC_AS_ACTION_PLAY] = { "Play", NULL, 0, 0, swfdec_action_play, 1 },
+ [SWFDEC_AS_ACTION_STOP] = { "Stop", NULL, 0, 0, swfdec_action_stop, 1 },
+ [SWFDEC_AS_ACTION_TOGGLE_QUALITY] = { "ToggleQuality", NULL, -1, -1, NULL, 1 },
+ /* version 2 */
+ [SWFDEC_AS_ACTION_STOP_SOUNDS] = { "StopSounds", NULL, 0, 0, swfdec_action_stop_sounds, 2 },
+ /* version 4 */
+ [SWFDEC_AS_ACTION_ADD] = { "Add", NULL, 2, 1, swfdec_action_binary, 4 },
+ [SWFDEC_AS_ACTION_SUBTRACT] = { "Subtract", NULL, 2, 1, swfdec_action_binary, 4 },
+ [SWFDEC_AS_ACTION_MULTIPLY] = { "Multiply", NULL, 2, 1, swfdec_action_binary, 4 },
+ [SWFDEC_AS_ACTION_DIVIDE] = { "Divide", NULL, 2, 1, swfdec_action_binary, 4 },
+ [SWFDEC_AS_ACTION_EQUALS] = { "Equals", NULL, 2, 1, swfdec_action_old_compare, 4 },
+ [SWFDEC_AS_ACTION_LESS] = { "Less", NULL, 2, 1, swfdec_action_old_compare, 4 },
+ [SWFDEC_AS_ACTION_AND] = { "And", NULL, 2, 1, swfdec_action_logical, 4 },
+ [SWFDEC_AS_ACTION_OR] = { "Or", NULL, 2, 1, swfdec_action_logical, 4 },
+ [SWFDEC_AS_ACTION_NOT] = { "Not", NULL, 1, 1, swfdec_action_not, 4 },
+ [SWFDEC_AS_ACTION_STRING_EQUALS] = { "StringEquals", NULL, 2, 1, swfdec_action_string_compare, 4 },
+ [SWFDEC_AS_ACTION_STRING_LENGTH] = { "StringLength", NULL, 1, 1, swfdec_action_string_length, 4 },
+ [SWFDEC_AS_ACTION_STRING_EXTRACT] = { "StringExtract", NULL, 3, 1, swfdec_action_string_extract, 4 },
+ [SWFDEC_AS_ACTION_POP] = { "Pop", NULL, 1, 0, swfdec_action_pop, 4 },
+ [SWFDEC_AS_ACTION_TO_INTEGER] = { "ToInteger", NULL, 1, 1, swfdec_action_to_integer, 4 },
+ [SWFDEC_AS_ACTION_GET_VARIABLE] = { "GetVariable", NULL, 1, 1, swfdec_action_get_variable, 4 },
+ [SWFDEC_AS_ACTION_SET_VARIABLE] = { "SetVariable", NULL, 2, 0, swfdec_action_set_variable, 4 },
+ /* version 3 */
+ [SWFDEC_AS_ACTION_SET_TARGET2] = { "SetTarget2", NULL, 1, 0, swfdec_action_set_target2, 3 },
+ /* version 4 */
+ [SWFDEC_AS_ACTION_STRING_ADD] = { "StringAdd", NULL, 2, 1, swfdec_action_string_add, 4 },
+ [SWFDEC_AS_ACTION_GET_PROPERTY] = { "GetProperty", NULL, 2, 1, swfdec_action_get_property, 4 },
+ [SWFDEC_AS_ACTION_SET_PROPERTY] = { "SetProperty", NULL, 3, 0, swfdec_action_set_property, 4 },
+ [SWFDEC_AS_ACTION_CLONE_SPRITE] = { "CloneSprite", NULL, 3, 0, swfdec_action_clone_sprite, 4 },
+ [SWFDEC_AS_ACTION_REMOVE_SPRITE] = { "RemoveSprite", NULL, 1, 0, swfdec_action_remove_sprite, 4 },
+ [SWFDEC_AS_ACTION_TRACE] = { "Trace", NULL, 1, 0, swfdec_action_trace, 4 },
+ [SWFDEC_AS_ACTION_START_DRAG] = { "StartDrag", NULL, -1, 0, swfdec_action_start_drag, 4 },
+ [SWFDEC_AS_ACTION_END_DRAG] = { "EndDrag", NULL, 0, 0, swfdec_action_end_drag, 4 },
+ [SWFDEC_AS_ACTION_STRING_LESS] = { "StringLess", NULL, 2, 1, swfdec_action_string_compare, 4 },
+ /* version 7 */
+ [SWFDEC_AS_ACTION_THROW] = { "Throw", NULL, 1, 0, swfdec_action_throw, 7 },
+ [SWFDEC_AS_ACTION_CAST] = { "Cast", NULL, 2, 1, swfdec_action_cast, 7 },
+ [SWFDEC_AS_ACTION_IMPLEMENTS] = { "Implements", NULL, -1, 0, swfdec_action_implements, 7 },
+ /* version 4 */
+ [SWFDEC_AS_ACTION_RANDOM] = { "RandomNumber", NULL, 1, 1, swfdec_action_random_number, 4 },
+ [SWFDEC_AS_ACTION_MB_STRING_LENGTH] = { "MBStringLength", NULL, -1, -1, NULL, 4 },
+ [SWFDEC_AS_ACTION_CHAR_TO_ASCII] = { "CharToAscii", NULL, 1, 1, swfdec_action_char_to_ascii, 4 },
+ [SWFDEC_AS_ACTION_ASCII_TO_CHAR] = { "AsciiToChar", NULL, 1, 1, swfdec_action_ascii_to_char, 4 },
+ [SWFDEC_AS_ACTION_GET_TIME] = { "GetTime", NULL, 0, 1, swfdec_action_get_time, 4 },
+ [SWFDEC_AS_ACTION_MB_STRING_EXTRACT] = { "MBStringExtract", NULL, 3, 1, swfdec_action_string_extract, 4 },
+ [SWFDEC_AS_ACTION_MB_CHAR_TO_ASCII] = { "MBCharToAscii", NULL, -1, -1, NULL, 4 },
+ [SWFDEC_AS_ACTION_MB_ASCII_TO_CHAR] = { "MBAsciiToChar", NULL, 1, 1, swfdec_action_ascii_to_char, 4 },
+ /* version 5 */
+ [SWFDEC_AS_ACTION_DELETE] = { "Delete", NULL, 2, 1, swfdec_action_delete, 5 },
+ [SWFDEC_AS_ACTION_DELETE2] = { "Delete2", NULL, 1, 1, swfdec_action_delete2, 5 },
+ [SWFDEC_AS_ACTION_DEFINE_LOCAL] = { "DefineLocal", NULL, 2, 0, swfdec_action_define_local, 5 },
+ [SWFDEC_AS_ACTION_CALL_FUNCTION] = { "CallFunction", NULL, -1, 1, swfdec_action_call_function, 5 },
+ [SWFDEC_AS_ACTION_RETURN] = { "Return", NULL, 1, 0, swfdec_action_return, 5 },
+ [SWFDEC_AS_ACTION_MODULO] = { "Modulo", NULL, 2, 1, swfdec_action_modulo, 5 },
+ [SWFDEC_AS_ACTION_NEW_OBJECT] = { "NewObject", NULL, -1, 1, swfdec_action_new_object, 5 },
+ [SWFDEC_AS_ACTION_DEFINE_LOCAL2] = { "DefineLocal2", NULL, 1, 0, swfdec_action_define_local2, 5 },
+ [SWFDEC_AS_ACTION_INIT_ARRAY] = { "InitArray", NULL, -1, 1, swfdec_action_init_array, 5 },
+ [SWFDEC_AS_ACTION_INIT_OBJECT] = { "InitObject", NULL, -1, 1, swfdec_action_init_object, 5 },
+ [SWFDEC_AS_ACTION_TYPE_OF] = { "TypeOf", NULL, 1, 1, swfdec_action_type_of, 5 },
+ [SWFDEC_AS_ACTION_TARGET_PATH] = { "TargetPath", NULL, 1, 1, swfdec_action_target_path, 5 },
+ [SWFDEC_AS_ACTION_ENUMERATE] = { "Enumerate", NULL, 1, -1, swfdec_action_enumerate, 5 },
+ [SWFDEC_AS_ACTION_ADD2] = { "Add2", NULL, 2, 1, swfdec_action_add2, 5 },
+ [SWFDEC_AS_ACTION_LESS2] = { "Less2", NULL, 2, 1, swfdec_action_new_comparison, 5 },
+ [SWFDEC_AS_ACTION_EQUALS2] = { "Equals2", NULL, 2, 1, swfdec_action_equals2, 5 },
+ [SWFDEC_AS_ACTION_TO_NUMBER] = { "ToNumber", NULL, 1, 1, swfdec_action_to_number, 5 },
+ [SWFDEC_AS_ACTION_TO_STRING] = { "ToString", NULL, 1, 1, swfdec_action_to_string, 5 },
+ [SWFDEC_AS_ACTION_PUSH_DUPLICATE] = { "PushDuplicate", NULL, 1, 2, swfdec_action_push_duplicate, 5 },
+ [SWFDEC_AS_ACTION_SWAP] = { "Swap", NULL, 2, 2, swfdec_action_swap, 5 },
+ /* version 4 */
+ [SWFDEC_AS_ACTION_GET_MEMBER] = { "GetMember", NULL, 2, 1, swfdec_action_get_member, 4 },
+ [SWFDEC_AS_ACTION_SET_MEMBER] = { "SetMember", NULL, 3, 0, swfdec_action_set_member, 4 },
+ /* version 5 */
+ [SWFDEC_AS_ACTION_INCREMENT] = { "Increment", NULL, 1, 1, swfdec_action_increment, 5 },
+ [SWFDEC_AS_ACTION_DECREMENT] = { "Decrement", NULL, 1, 1, swfdec_action_decrement, 5 },
+ [SWFDEC_AS_ACTION_CALL_METHOD] = { "CallMethod", NULL, -1, 1, swfdec_action_call_method, 5 },
+ [SWFDEC_AS_ACTION_NEW_METHOD] = { "NewMethod", NULL, -1, 1, swfdec_action_new_method, 5 },
+ /* version 6 */
+ [SWFDEC_AS_ACTION_INSTANCE_OF] = { "InstanceOf", NULL, 2, 1, swfdec_action_instance_of, 6 },
+ [SWFDEC_AS_ACTION_ENUMERATE2] = { "Enumerate2", NULL, 1, -1, swfdec_action_enumerate2, 6 },
+ [SWFDEC_AS_ACTION_BREAKPOINT] = { "Breakpoint", NULL, -1, -1, NULL, 6 },
+ /* version 5 */
+ [SWFDEC_AS_ACTION_BIT_AND] = { "BitAnd", NULL, 2, 1, swfdec_action_bitwise, 5 },
+ [SWFDEC_AS_ACTION_BIT_OR] = { "BitOr", NULL, 2, 1, swfdec_action_bitwise, 5 },
+ [SWFDEC_AS_ACTION_BIT_XOR] = { "BitXor", NULL, 2, 1, swfdec_action_bitwise, 5 },
+ [SWFDEC_AS_ACTION_BIT_LSHIFT] = { "BitLShift", NULL, 2, 1, swfdec_action_shift, 5 },
+ [SWFDEC_AS_ACTION_BIT_RSHIFT] = { "BitRShift", NULL, 2, 1, swfdec_action_shift, 5 },
+ [SWFDEC_AS_ACTION_BIT_URSHIFT] = { "BitURShift", NULL, 2, 1, swfdec_action_shift, 5 },
+ /* version 6 */
+ [SWFDEC_AS_ACTION_STRICT_EQUALS] = { "StrictEquals", NULL, 2, 1, swfdec_action_strict_equals, 6 },
+ [SWFDEC_AS_ACTION_GREATER] = { "Greater", NULL, 2, 1, swfdec_action_new_comparison, 6 },
+ [SWFDEC_AS_ACTION_STRING_GREATER] = { "StringGreater", NULL, -1, -1, NULL, 6 },
+ /* version 7 */
+ [SWFDEC_AS_ACTION_EXTENDS] = { "Extends", NULL, 2, 0, swfdec_action_extends, 7 },
+ /* version 1 */
+ [SWFDEC_AS_ACTION_GOTO_FRAME] = { "GotoFrame", swfdec_action_print_goto_frame, 0, 0, swfdec_action_goto_frame, 1 },
+ [SWFDEC_AS_ACTION_GET_URL] = { "GetURL", swfdec_action_print_get_url, 0, 0, swfdec_action_get_url, 1 },
+ /* version 5 */
+ [SWFDEC_AS_ACTION_STORE_REGISTER] = { "StoreRegister", swfdec_action_print_store_register, 1, 1, swfdec_action_store_register, 5 },
+ [SWFDEC_AS_ACTION_CONSTANT_POOL] = { "ConstantPool", swfdec_action_print_constant_pool, 0, 0, swfdec_action_constant_pool, 5 },
+ [SWFDEC_AS_ACTION_STRICT_MODE] = { "StrictMode", NULL, -1, -1, NULL, 5 },
+ /* version 1 */
+ [SWFDEC_AS_ACTION_WAIT_FOR_FRAME] = { "WaitForFrame", swfdec_action_print_wait_for_frame, 0, 0, swfdec_action_wait_for_frame, 1 },
+ [SWFDEC_AS_ACTION_SET_TARGET] = { "SetTarget", swfdec_action_print_set_target, 0, 0, swfdec_action_set_target, 1 },
+ /* version 3 */
+ [SWFDEC_AS_ACTION_GOTO_LABEL] = { "GotoLabel", swfdec_action_print_goto_label, 0, 0, swfdec_action_goto_label, 3 },
+#if 0
+ /* version 4 */
+ [0x8d] = { "WaitForFrame2", swfdec_action_print_wait_for_frame2, 1, 0, { NULL, swfdec_action_wait_for_frame2, swfdec_action_wait_for_frame2, swfdec_action_wait_for_frame2, swfdec_action_wait_for_frame2 } },
+#endif
+ /* version 7 */
+ [SWFDEC_AS_ACTION_DEFINE_FUNCTION2] = { "DefineFunction2", swfdec_action_print_define_function, 0, -1, swfdec_action_define_function, 7 },
+ [SWFDEC_AS_ACTION_TRY] = { "Try", NULL, 0, 0, swfdec_action_try, 7 },
+ /* version 5 */
+ [SWFDEC_AS_ACTION_WITH] = { "With", swfdec_action_print_with, 1, 0, swfdec_action_with, 5 },
+ /* version 4 */
+ [SWFDEC_AS_ACTION_PUSH] = { "Push", swfdec_action_print_push, 0, -1, swfdec_action_push, 4 },
+ [SWFDEC_AS_ACTION_JUMP] = { "Jump", swfdec_action_print_jump, 0, 0, swfdec_action_jump, 4 },
+ [SWFDEC_AS_ACTION_GET_URL2] = { "GetURL2", swfdec_action_print_get_url2, 2, 0, swfdec_action_get_url2, 4 },
+ /* version 5 */
+ [SWFDEC_AS_ACTION_DEFINE_FUNCTION] = { "DefineFunction", swfdec_action_print_define_function, 0, -1, swfdec_action_define_function, 5 },
+ /* version 4 */
+ [SWFDEC_AS_ACTION_IF] = { "If", swfdec_action_print_if, 1, 0, swfdec_action_if, 4 },
+ [SWFDEC_AS_ACTION_CALL] = { "Call", NULL, -1, -1, NULL, 4 },
+ [SWFDEC_AS_ACTION_GOTO_FRAME2] = { "GotoFrame2", swfdec_action_print_goto_frame2, 1, 0, swfdec_action_goto_frame2, 4 }
+};
+
diff --git a/swfdec/swfdec_as_interpret.h b/swfdec/swfdec_as_interpret.h
new file mode 100644
index 0000000..6b9402b
--- /dev/null
+++ b/swfdec/swfdec_as_interpret.h
@@ -0,0 +1,150 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_INTERPRET_H_
+#define _SWFDEC_AS_INTERPRET_H_
+
+#include <libswfdec/swfdec_as_types.h>
+
+G_BEGIN_DECLS
+
+typedef struct {
+ const char * name; /* name identifying the action */
+ char * (* print) (guint action, const guint8 *data, guint len);
+ int remove; /* values removed from stack or -1 for dynamic */
+ int add; /* values added to the stack or -1 for dynamic */
+ void (* exec) (SwfdecAsContext *cx, guint action, const guint8 *data, guint len);
+ guint version; /* the version this action was introduced in */
+} SwfdecActionSpec;
+
+extern const SwfdecActionSpec swfdec_as_actions[256];
+
+/* all known actions */
+typedef enum {
+ SWFDEC_AS_ACTION_NEXT_FRAME = 0x04,
+ SWFDEC_AS_ACTION_PREVIOUS_FRAME = 0x05,
+ SWFDEC_AS_ACTION_PLAY = 0x06,
+ SWFDEC_AS_ACTION_STOP = 0x07,
+ SWFDEC_AS_ACTION_TOGGLE_QUALITY = 0x08,
+ SWFDEC_AS_ACTION_STOP_SOUNDS = 0x09,
+ SWFDEC_AS_ACTION_ADD = 0x0A,
+ SWFDEC_AS_ACTION_SUBTRACT = 0x0B,
+ SWFDEC_AS_ACTION_MULTIPLY = 0x0C,
+ SWFDEC_AS_ACTION_DIVIDE = 0x0D,
+ SWFDEC_AS_ACTION_EQUALS = 0x0E,
+ SWFDEC_AS_ACTION_LESS = 0x0F,
+ SWFDEC_AS_ACTION_AND = 0x10,
+ SWFDEC_AS_ACTION_OR = 0x11,
+ SWFDEC_AS_ACTION_NOT = 0x12,
+ SWFDEC_AS_ACTION_STRING_EQUALS = 0x13,
+ SWFDEC_AS_ACTION_STRING_LENGTH = 0x14,
+ SWFDEC_AS_ACTION_STRING_EXTRACT = 0x15,
+ SWFDEC_AS_ACTION_POP = 0x17,
+ SWFDEC_AS_ACTION_TO_INTEGER = 0x18,
+ SWFDEC_AS_ACTION_GET_VARIABLE = 0x1C,
+ SWFDEC_AS_ACTION_SET_VARIABLE = 0x1D,
+ SWFDEC_AS_ACTION_SET_TARGET2 = 0x20,
+ SWFDEC_AS_ACTION_STRING_ADD = 0x21,
+ SWFDEC_AS_ACTION_GET_PROPERTY = 0x22,
+ SWFDEC_AS_ACTION_SET_PROPERTY = 0x23,
+ SWFDEC_AS_ACTION_CLONE_SPRITE = 0x24,
+ SWFDEC_AS_ACTION_REMOVE_SPRITE = 0x25,
+ SWFDEC_AS_ACTION_TRACE = 0x26,
+ SWFDEC_AS_ACTION_START_DRAG = 0x27,
+ SWFDEC_AS_ACTION_END_DRAG = 0x28,
+ SWFDEC_AS_ACTION_STRING_LESS = 0x29,
+ SWFDEC_AS_ACTION_THROW = 0x2A,
+ SWFDEC_AS_ACTION_CAST = 0x2B,
+ SWFDEC_AS_ACTION_IMPLEMENTS = 0x2C,
+ SWFDEC_AS_ACTION_RANDOM = 0x30,
+ SWFDEC_AS_ACTION_MB_STRING_LENGTH = 0x31,
+ SWFDEC_AS_ACTION_CHAR_TO_ASCII = 0x32,
+ SWFDEC_AS_ACTION_ASCII_TO_CHAR = 0x33,
+ SWFDEC_AS_ACTION_GET_TIME = 0x34,
+ SWFDEC_AS_ACTION_MB_STRING_EXTRACT = 0x35,
+ SWFDEC_AS_ACTION_MB_CHAR_TO_ASCII = 0x36,
+ SWFDEC_AS_ACTION_MB_ASCII_TO_CHAR = 0x37,
+ SWFDEC_AS_ACTION_DELETE = 0x3A,
+ SWFDEC_AS_ACTION_DELETE2 = 0x3B,
+ SWFDEC_AS_ACTION_DEFINE_LOCAL = 0x3C,
+ SWFDEC_AS_ACTION_CALL_FUNCTION = 0x3D,
+ SWFDEC_AS_ACTION_RETURN = 0x3E,
+ SWFDEC_AS_ACTION_MODULO = 0x3F,
+ SWFDEC_AS_ACTION_NEW_OBJECT = 0x40,
+ SWFDEC_AS_ACTION_DEFINE_LOCAL2 = 0x41,
+ SWFDEC_AS_ACTION_INIT_ARRAY = 0x42,
+ SWFDEC_AS_ACTION_INIT_OBJECT = 0x43,
+ SWFDEC_AS_ACTION_TYPE_OF = 0x44,
+ SWFDEC_AS_ACTION_TARGET_PATH = 0x45,
+ SWFDEC_AS_ACTION_ENUMERATE = 0x46,
+ SWFDEC_AS_ACTION_ADD2 = 0x47,
+ SWFDEC_AS_ACTION_LESS2 = 0x48,
+ SWFDEC_AS_ACTION_EQUALS2 = 0x49,
+ SWFDEC_AS_ACTION_TO_NUMBER = 0x4A,
+ SWFDEC_AS_ACTION_TO_STRING = 0x4B,
+ SWFDEC_AS_ACTION_PUSH_DUPLICATE = 0x4C,
+ SWFDEC_AS_ACTION_SWAP = 0x4D,
+ SWFDEC_AS_ACTION_GET_MEMBER = 0x4E,
+ SWFDEC_AS_ACTION_SET_MEMBER = 0x4F,
+ SWFDEC_AS_ACTION_INCREMENT = 0x50,
+ SWFDEC_AS_ACTION_DECREMENT = 0x51,
+ SWFDEC_AS_ACTION_CALL_METHOD = 0x52,
+ SWFDEC_AS_ACTION_NEW_METHOD = 0x53,
+ SWFDEC_AS_ACTION_INSTANCE_OF = 0x54,
+ SWFDEC_AS_ACTION_ENUMERATE2 = 0x55,
+ SWFDEC_AS_ACTION_BREAKPOINT = 0x5F,
+ SWFDEC_AS_ACTION_BIT_AND = 0x60,
+ SWFDEC_AS_ACTION_BIT_OR = 0x61,
+ SWFDEC_AS_ACTION_BIT_XOR = 0x62,
+ SWFDEC_AS_ACTION_BIT_LSHIFT = 0x63,
+ SWFDEC_AS_ACTION_BIT_RSHIFT = 0x64,
+ SWFDEC_AS_ACTION_BIT_URSHIFT = 0x65,
+ SWFDEC_AS_ACTION_STRICT_EQUALS = 0x66,
+ SWFDEC_AS_ACTION_GREATER = 0x67,
+ SWFDEC_AS_ACTION_STRING_GREATER = 0x68,
+ SWFDEC_AS_ACTION_EXTENDS = 0x69,
+ SWFDEC_AS_ACTION_GOTO_FRAME = 0x81,
+ SWFDEC_AS_ACTION_GET_URL = 0x83,
+ SWFDEC_AS_ACTION_STORE_REGISTER = 0x87,
+ SWFDEC_AS_ACTION_CONSTANT_POOL = 0x88,
+ SWFDEC_AS_ACTION_STRICT_MODE = 0x89,
+ SWFDEC_AS_ACTION_WAIT_FOR_FRAME = 0x8A,
+ SWFDEC_AS_ACTION_SET_TARGET = 0x8B,
+ SWFDEC_AS_ACTION_GOTO_LABEL = 0x8C,
+ SWFDEC_AS_ACTION_WAIT_FOR_FRAME2 = 0x8D,
+ SWFDEC_AS_ACTION_DEFINE_FUNCTION2 = 0x8E,
+ SWFDEC_AS_ACTION_TRY = 0x8F,
+ SWFDEC_AS_ACTION_WITH = 0x94,
+ SWFDEC_AS_ACTION_PUSH = 0x96,
+ SWFDEC_AS_ACTION_JUMP = 0x99,
+ SWFDEC_AS_ACTION_GET_URL2 = 0x9A,
+ SWFDEC_AS_ACTION_DEFINE_FUNCTION = 0x9B,
+ SWFDEC_AS_ACTION_IF = 0x9D,
+ SWFDEC_AS_ACTION_CALL = 0x9E,
+ SWFDEC_AS_ACTION_GOTO_FRAME2 = 0x9F
+} SwfdecAsAction;
+
+// FIXME: move
+SwfdecAsObject * swfdec_action_lookup_object (SwfdecAsContext * cx,
+ SwfdecAsObject * o,
+ const char * path,
+ const char * end);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_as_math.c b/swfdec/swfdec_as_math.c
new file mode 100644
index 0000000..30b0c6e
--- /dev/null
+++ b/swfdec/swfdec_as_math.c
@@ -0,0 +1,149 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+
+#include "swfdec_as_object.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_debug.h"
+
+/*** AS CODE ***/
+
+#define MATH_FUN(name) \
+void \
+swfdec_as_math_ ## name (SwfdecAsContext *cx, SwfdecAsObject *object, \
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret) \
+{ \
+ double d; \
+\
+ SWFDEC_AS_CHECK (0, NULL, "n", &d); \
+\
+ d = name (d); \
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, d); \
+}
+
+SWFDEC_AS_NATIVE (200, 16, swfdec_as_math_acos)
+MATH_FUN (acos)
+SWFDEC_AS_NATIVE (200, 15, swfdec_as_math_asin)
+MATH_FUN (asin)
+SWFDEC_AS_NATIVE (200, 14, swfdec_as_math_atan)
+MATH_FUN (atan)
+SWFDEC_AS_NATIVE (200, 13, swfdec_as_math_ceil)
+MATH_FUN (ceil)
+SWFDEC_AS_NATIVE (200, 4, swfdec_as_math_cos)
+MATH_FUN (cos)
+SWFDEC_AS_NATIVE (200, 7, swfdec_as_math_exp)
+MATH_FUN (exp)
+SWFDEC_AS_NATIVE (200, 12, swfdec_as_math_floor)
+MATH_FUN (floor)
+SWFDEC_AS_NATIVE (200, 8, swfdec_as_math_log)
+MATH_FUN (log)
+SWFDEC_AS_NATIVE (200, 3, swfdec_as_math_sin)
+MATH_FUN (sin)
+SWFDEC_AS_NATIVE (200, 9, swfdec_as_math_sqrt)
+MATH_FUN (sqrt)
+SWFDEC_AS_NATIVE (200, 6, swfdec_as_math_tan)
+MATH_FUN (tan)
+
+SWFDEC_AS_NATIVE (200, 0, swfdec_as_math_abs)
+void
+swfdec_as_math_abs (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ double d;
+
+ SWFDEC_AS_CHECK (0, NULL, "n", &d);
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, fabs (d));
+}
+
+SWFDEC_AS_NATIVE (200, 5, swfdec_as_math_atan2)
+void
+swfdec_as_math_atan2 (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ double x, y;
+
+ SWFDEC_AS_CHECK (0, NULL, "nn", &y, &x);
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, atan2 (y, x));
+}
+
+SWFDEC_AS_NATIVE (200, 2, swfdec_as_math_max)
+void
+swfdec_as_math_max (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ double x, y;
+
+ SWFDEC_AS_CHECK (0, NULL, "nn", &x, &y);
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, MAX (x, y));
+}
+
+SWFDEC_AS_NATIVE (200, 1, swfdec_as_math_min)
+void
+swfdec_as_math_min (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ double x, y;
+
+ SWFDEC_AS_CHECK (0, NULL, "nn", &x, &y);
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, MIN (x, y));
+}
+
+SWFDEC_AS_NATIVE (200, 17, swfdec_as_math_pow)
+void
+swfdec_as_math_pow (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ double x, y;
+
+ SWFDEC_AS_CHECK (0, NULL, "nn", &x, &y);
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, pow (x, y));
+}
+
+SWFDEC_AS_NATIVE (200, 11, swfdec_as_math_random)
+void
+swfdec_as_math_random (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, g_rand_double (cx->rand));
+}
+
+SWFDEC_AS_NATIVE (200, 10, swfdec_as_math_round)
+void
+swfdec_as_math_round (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ double d;
+
+ SWFDEC_AS_CHECK (0, NULL, "n", &d);
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, floor (d + 0.5));
+}
diff --git a/swfdec/swfdec_as_native_function.c b/swfdec/swfdec_as_native_function.c
new file mode 100644
index 0000000..74ba3e6
--- /dev/null
+++ b/swfdec/swfdec_as_native_function.c
@@ -0,0 +1,395 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_native_function.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_frame_internal.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_stack.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+
+/*** GTK-DOC ***/
+
+/**
+ * SwfdecAsNative:
+ * @context: #SwfdecAsContext
+ * @thisp: the this object. <warning>Can be %NULL.</warning>
+ * @argc: number of arguments passed to this function
+ * @argv: the @argc arguments passed to this function
+ * @retval: set to the return value. Initialized to undefined by default
+ *
+ * This is the prototype for all native functions.
+ */
+
+/**
+ * SwfdecAsNativeFunction:
+ *
+ * This is the object type for native functions.
+ */
+
+/*** IMPLEMENTATION ***/
+
+G_DEFINE_TYPE (SwfdecAsNativeFunction, swfdec_as_native_function, SWFDEC_TYPE_AS_FUNCTION)
+
+static SwfdecAsFrame *
+swfdec_as_native_function_call (SwfdecAsFunction *function)
+{
+ SwfdecAsNativeFunction *native = SWFDEC_AS_NATIVE_FUNCTION (function);
+ SwfdecAsFrame *frame;
+ SwfdecAsContext *cx;
+
+ cx = SWFDEC_AS_OBJECT (function)->context;
+ frame = swfdec_as_frame_new_native (cx);
+ if (frame == NULL)
+ return NULL;
+ g_assert (native->name);
+ frame->function_name = native->name;
+ frame->function = function;
+ /* We copy the target here so we have a proper SwfdecMovie reference inside native
+ * functions. This is for example necessary for swfdec_player_get_movie_by_value()
+ * and probably other stuff that does variable lookups inside native functions.
+ */
+ /* FIXME: copy target or original target? */
+ if (frame->next) {
+ frame->target = frame->next->original_target;
+ frame->original_target = frame->target;
+ }
+ return frame;
+}
+
+static char *
+swfdec_as_native_function_debug (SwfdecAsObject *object)
+{
+ SwfdecAsNativeFunction *native = SWFDEC_AS_NATIVE_FUNCTION (object);
+
+ return g_strdup_printf ("%s ()", native->name);
+}
+
+static void
+swfdec_as_native_function_dispose (GObject *object)
+{
+ SwfdecAsNativeFunction *function = SWFDEC_AS_NATIVE_FUNCTION (object);
+
+ g_free (function->name);
+ function->name = NULL;
+
+ G_OBJECT_CLASS (swfdec_as_native_function_parent_class)->dispose (object);
+}
+
+static void
+swfdec_as_native_function_class_init (SwfdecAsNativeFunctionClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
+ SwfdecAsFunctionClass *function_class = SWFDEC_AS_FUNCTION_CLASS (klass);
+
+ object_class->dispose = swfdec_as_native_function_dispose;
+
+ asobject_class->debug = swfdec_as_native_function_debug;
+
+ function_class->call = swfdec_as_native_function_call;
+}
+
+static void
+swfdec_as_native_function_init (SwfdecAsNativeFunction *function)
+{
+}
+
+/**
+ * swfdec_as_native_function_new:
+ * @context: a #SwfdecAsContext
+ * @name: name of the function
+ * @native: function to call when executed
+ * @min_args: minimum number of arguments required
+ * @prototype: The object to be used as "prototype" property for the created
+ * function or %NULL for none.
+ *
+ * Creates a new native function, that will execute @native when called. The
+ * @min_args parameter sets a requirement for the minimum number of arguments
+ * to pass to @native. If the function gets called with less arguments, it
+ * will just redurn undefined. You might want to use
+ * swfdec_as_object_add_function() instead of this function.
+ *
+ * Returns: a new #SwfdecAsFunction or %NULL on OOM
+ **/
+SwfdecAsFunction *
+swfdec_as_native_function_new (SwfdecAsContext *context, const char *name,
+ SwfdecAsNative native, guint min_args, SwfdecAsObject *prototype)
+{
+ SwfdecAsNativeFunction *fun;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
+ g_return_val_if_fail (native != NULL, NULL);
+ g_return_val_if_fail (prototype == NULL || SWFDEC_IS_AS_OBJECT (prototype), NULL);
+
+ if (!swfdec_as_context_use_mem (context, sizeof (SwfdecAsNativeFunction)))
+ return NULL;
+ fun = g_object_new (SWFDEC_TYPE_AS_NATIVE_FUNCTION, NULL);
+ if (fun == NULL)
+ return NULL;
+ fun->native = native;
+ fun->min_args = min_args;
+ fun->name = g_strdup (name);
+ swfdec_as_object_add (SWFDEC_AS_OBJECT (fun), context, sizeof (SwfdecAsNativeFunction));
+ /* need to set prototype before setting the constructor or Function.constructor
+ * being CONSTANT disallows setting it. */
+ if (prototype) {
+ SwfdecAsValue val;
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, prototype);
+ swfdec_as_object_set_variable_and_flags (SWFDEC_AS_OBJECT (fun), SWFDEC_AS_STR_prototype,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+ }
+ swfdec_as_function_set_constructor (SWFDEC_AS_FUNCTION (fun));
+
+ return SWFDEC_AS_FUNCTION (fun);
+}
+
+/**
+ * swfdec_as_native_function_set_object_type:
+ * @function: a #SwfdecAsNativeFunction
+ * @type: required #GType for the this object
+ *
+ * Sets the required type for the this object to @type. If the this object
+ * isn't of the required type, the function will not be called and its
+ * return value will be undefined.
+ **/
+void
+swfdec_as_native_function_set_object_type (SwfdecAsNativeFunction *function, GType type)
+{
+ GTypeQuery query;
+
+ g_return_if_fail (SWFDEC_IS_AS_NATIVE_FUNCTION (function));
+ g_return_if_fail (g_type_is_a (type, SWFDEC_TYPE_AS_OBJECT));
+
+ g_type_query (type, &query);
+ function->type = type;
+}
+
+/**
+ * swfdec_as_native_function_set_construct_type:
+ * @function: a #SwfdecAsNativeFunction
+ * @type: #GType used when constructing an object with @function
+ *
+ * Sets the @type to be used when using @function as a constructor. If this is
+ * not set, using @function as a constructor will create a #SwfdecAsObject.
+ **/
+void
+swfdec_as_native_function_set_construct_type (SwfdecAsNativeFunction *function, GType type)
+{
+ GTypeQuery query;
+
+ g_return_if_fail (SWFDEC_IS_AS_NATIVE_FUNCTION (function));
+ g_return_if_fail (g_type_is_a (type, SWFDEC_TYPE_AS_OBJECT));
+
+ g_type_query (type, &query);
+ function->construct_type = type;
+ function->construct_size = query.instance_size;
+}
+
+/**
+ * SWFDEC_AS_CHECK:
+ * @type: required type of this object or 0 for ignoring
+ * @result: converted this object
+ * @...: conversion string and pointers taking converted values
+ *
+ * This is a shortcut macro for calling swfdec_as_native_function_check() at
+ * the beginning of a native function. See that function for details.
+ * It requires the native function parameters to have the default name. So your
+ * function must be declared like this:
+ * |[static void
+ * my_function (SwfdecAsContext *cx, SwfdecAsObject *object,
+ * guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval);]|
+ */
+/**
+ * swfdec_as_native_function_check:
+ * @cx: a #SwfdecAsContext
+ * @object: this object passed to the native function
+ * @type: expected type of @object or 0 for any
+ * @result: pointer to variable taking cast result of @object
+ * @argc: count of arguments passed to the function
+ * @argv: arguments passed to the function
+ * @args: argument conversion string
+ * @...: pointers to variables taking converted arguments
+ *
+ * This function is a convenience function to validate and convert arguments to
+ * a native function while avoiding common pitfalls. You typically want to call
+ * it at the beginning of every native function you write. Or you can use the
+ * SWFDEC_AS_CHECK() macro instead which calls this function.
+ * The @cx, @object, @argc and @argv paramters should be passed verbatim from
+ * the function call to your native function. If @type is not 0, @object is then
+ * checked to be of that type and cast to @result. After that the @args string
+ * is used to convert the arguments. Every character in @args describes the
+ * conversion of one argument. For that argument, you have to pass a pointer
+ * that takes the value. For the conversion, the default conversion functions
+ * like swfdec_as_value_to_string() are used. If not enough arguments are
+ * available, the function stops converting and returns %NULL. The following
+ * conversion characters are allowed:<itemizedlist>
+ * <listitem><para>"b": convert to boolean. Requires a %gboolean pointer
+ * </para></listitem>
+ * <listitem><para>"i": convert to integer. Requires an %integer pointer
+ * </para></listitem>
+ * <listitem><para>"n": convert to number. Requires a %double pointer
+ * </para></listitem>
+ * <listitem><para>"o": convert to object. Requires a #SwfdecAsObject pointer.
+ * If the conversion fails, this function immediately return %
+ * FALSE.</para></listitem>
+ * <listitem><para>"O": convert to object or %NULL. Requires a #SwfdecAsObject
+ * pointer.</para></listitem>
+ * <listitem><para>"s": convert to garbage-collected string. Requires a const
+ * %char pointer</para></listitem>
+ * <listitem><para>"v": copy the value. The given argument must be a pointer
+ * to a #SwfdecAsValue</para></listitem>
+ * <listitem><para>"|": optional arguments follow. Optional arguments will be
+ * initialized to the empty value for their type. This
+ * conversion character is only allowed once in the conversion
+ * string.</para></listitem>
+ * </itemizedlist>
+ *
+ * Returns: %TRUE if the conversion succeeded, %FALSE otherwise
+ **/
+gboolean
+swfdec_as_native_function_check (SwfdecAsContext *cx, SwfdecAsObject *object,
+ GType type, gpointer *result, guint argc, SwfdecAsValue *argv,
+ const char *args, ...)
+{
+ gboolean ret;
+ va_list varargs;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (cx), FALSE);
+ g_return_val_if_fail (type == 0 || result != NULL, FALSE);
+
+ va_start (varargs, args);
+ ret = swfdec_as_native_function_checkv (cx, object, type, result, argc, argv, args, varargs);
+ va_end (varargs);
+ return ret;
+}
+
+/**
+ * swfdec_as_native_function_checkv:
+ * @cx: a #SwfdecAsContext
+ * @object: this object passed to the native function
+ * @type: expected type of @object
+ * @result: pointer to variable taking cast result of @object
+ * @argc: count of arguments passed to the function
+ * @argv: arguments passed to the function
+ * @args: argument conversion string
+ * @varargs: pointers to variables taking converted arguments
+ *
+ * This is the valist version of swfdec_as_native_function_check(). See that
+ * function for details.
+ *
+ * Returns: %TRUE if the conversion succeeded, %FALSE otherwise
+ **/
+gboolean
+swfdec_as_native_function_checkv (SwfdecAsContext *cx, SwfdecAsObject *object,
+ GType type, gpointer *result, guint argc, SwfdecAsValue *argv,
+ const char *args, va_list varargs)
+{
+ guint i;
+ gboolean optional = FALSE;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (cx), FALSE);
+ g_return_val_if_fail (type == 0 || result != NULL, FALSE);
+
+ /* check that we got a valid type */
+ if (type) {
+ if (!G_TYPE_CHECK_INSTANCE_TYPE (object, type))
+ return FALSE;
+ *result = object;
+ }
+ for (i = 0; *args; i++, args++) {
+ if (!optional && i >= argc && *args != '|')
+ break;
+ switch (*args) {
+ case 'v':
+ {
+ SwfdecAsValue *val = va_arg (varargs, SwfdecAsValue *);
+ if (i < argc)
+ *val = argv[i];
+ else
+ SWFDEC_AS_VALUE_SET_UNDEFINED (val);
+ }
+ break;
+ case 'b':
+ {
+ gboolean *b = va_arg (varargs, gboolean *);
+ if (i < argc)
+ *b = swfdec_as_value_to_boolean (cx, &argv[i]);
+ else
+ *b = FALSE;
+ }
+ break;
+ case 'i':
+ {
+ int *j = va_arg (varargs, int *);
+ if (i < argc)
+ *j = swfdec_as_value_to_integer (cx, &argv[i]);
+ else
+ *j = 0;
+ }
+ break;
+ case 'n':
+ {
+ double *d = va_arg (varargs, double *);
+ if (i < argc)
+ *d = swfdec_as_value_to_number (cx, &argv[i]);
+ else
+ *d = 0;
+ }
+ break;
+ case 's':
+ {
+ const char **s = va_arg (varargs, const char **);
+ if (i < argc)
+ *s = swfdec_as_value_to_string (cx, &argv[i]);
+ else
+ *s = SWFDEC_AS_STR_EMPTY;
+ }
+ break;
+ case 'o':
+ case 'O':
+ {
+ SwfdecAsObject **o = va_arg (varargs, SwfdecAsObject **);
+ if (i < argc)
+ *o = swfdec_as_value_to_object (cx, &argv[i]);
+ else
+ *o = NULL;
+ if (*o == NULL && *args != 'O')
+ return FALSE;
+ }
+ break;
+ case '|':
+ g_return_val_if_fail (optional == FALSE, FALSE);
+ optional = TRUE;
+ i--;
+ break;
+ default:
+ g_warning ("'%c' is not a valid type conversion", *args);
+ return FALSE;
+ }
+ }
+ if (*args)
+ return FALSE;
+ return TRUE;
+}
diff --git a/swfdec/swfdec_as_native_function.h b/swfdec/swfdec_as_native_function.h
new file mode 100644
index 0000000..88c172d
--- /dev/null
+++ b/swfdec/swfdec_as_native_function.h
@@ -0,0 +1,95 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_NATIVE_FUNCTION_H_
+#define _SWFDEC_AS_NATIVE_FUNCTION_H_
+
+#include <libswfdec/swfdec_as_function.h>
+#include <libswfdec/swfdec_as_types.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecAsNativeFunction SwfdecAsNativeFunction;
+typedef struct _SwfdecAsNativeFunctionClass SwfdecAsNativeFunctionClass;
+
+#define SWFDEC_TYPE_AS_NATIVE_FUNCTION (swfdec_as_native_function_get_type())
+#define SWFDEC_IS_AS_NATIVE_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_NATIVE_FUNCTION))
+#define SWFDEC_IS_AS_NATIVE_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_NATIVE_FUNCTION))
+#define SWFDEC_AS_NATIVE_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_NATIVE_FUNCTION, SwfdecAsNativeFunction))
+#define SWFDEC_AS_NATIVE_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_NATIVE_FUNCTION, SwfdecAsNativeFunctionClass))
+#define SWFDEC_AS_NATIVE_FUNCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_NATIVE_FUNCTION, SwfdecAsNativeFunctionClass))
+
+/* FIXME: do two obejcts, one for scripts and one for native? */
+struct _SwfdecAsNativeFunction {
+ /*< private >*/
+ SwfdecAsFunction function;
+
+ SwfdecAsNative native; /* native call or NULL when script */
+ char * name; /* function name */
+ /* checks for calling this function */
+ GType type; /* required type for this object when caling function */
+ guint min_args; /* minimum number of required arguments */
+ /* constructor info */
+ GType construct_type; /* type used when used as a constructor or 0 */
+ guint construct_size; /* instance size of type */
+};
+
+struct _SwfdecAsNativeFunctionClass {
+ SwfdecAsFunctionClass function_class;
+};
+
+GType swfdec_as_native_function_get_type (void);
+
+SwfdecAsFunction *swfdec_as_native_function_new (SwfdecAsContext * context,
+ const char * name,
+ SwfdecAsNative native,
+ guint min_args,
+ SwfdecAsObject * prototype);
+
+void swfdec_as_native_function_set_object_type
+ (SwfdecAsNativeFunction *function,
+ GType type);
+void swfdec_as_native_function_set_construct_type
+ (SwfdecAsNativeFunction *function,
+ GType type);
+
+gboolean swfdec_as_native_function_check (SwfdecAsContext * cx,
+ SwfdecAsObject * object,
+ GType type,
+ gpointer * result,
+ guint argc,
+ SwfdecAsValue * argv,
+ const char * args,
+ ...);
+gboolean swfdec_as_native_function_checkv(SwfdecAsContext * cx,
+ SwfdecAsObject * object,
+ GType type,
+ gpointer * result,
+ guint argc,
+ SwfdecAsValue * argv,
+ const char * args,
+ va_list varargs);
+#define SWFDEC_AS_CHECK(type,result,...) G_STMT_START {\
+ if (!swfdec_as_native_function_check (cx, object, type, (gpointer) result, argc, argv, __VA_ARGS__)) \
+ return; \
+}G_STMT_END
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_as_number.c b/swfdec/swfdec_as_number.c
new file mode 100644
index 0000000..71472ee
--- /dev/null
+++ b/swfdec/swfdec_as_number.c
@@ -0,0 +1,121 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+
+#include "swfdec_as_number.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_frame.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+
+G_DEFINE_TYPE (SwfdecAsNumber, swfdec_as_number, SWFDEC_TYPE_AS_OBJECT)
+
+static void
+swfdec_as_number_class_init (SwfdecAsNumberClass *klass)
+{
+}
+
+static void
+swfdec_as_number_init (SwfdecAsNumber *number)
+{
+}
+
+/*** AS CODE ***/
+
+SWFDEC_AS_CONSTRUCTOR (106, 2, swfdec_as_number_construct, swfdec_as_number_get_type)
+void
+swfdec_as_number_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ double d;
+
+ if (argc > 0) {
+ d = swfdec_as_value_to_number (object->context, &argv[0]);
+ } else {
+ d = NAN;
+ }
+
+ if (swfdec_as_context_is_constructing (cx)) {
+ SwfdecAsNumber *num = SWFDEC_AS_NUMBER (object);
+ num->number = d;
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
+ } else {
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, d);
+ }
+}
+
+SWFDEC_AS_NATIVE (106, 1, swfdec_as_number_toString)
+void
+swfdec_as_number_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecAsNumber *num;
+ SwfdecAsValue val;
+ const char *s;
+
+ if (!SWFDEC_IS_AS_NUMBER (object))
+ return;
+
+ num = SWFDEC_AS_NUMBER (object);
+ if (argc > 0) {
+ SWFDEC_FIXME ("radix is not yet implemented");
+ }
+ SWFDEC_AS_VALUE_SET_NUMBER (&val, num->number);
+ s = swfdec_as_value_to_string (object->context, &val);
+ SWFDEC_AS_VALUE_SET_STRING (ret, s);
+}
+
+SWFDEC_AS_NATIVE (106, 0, swfdec_as_number_valueOf)
+void
+swfdec_as_number_valueOf (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecAsNumber *num;
+
+ if (!SWFDEC_IS_AS_NUMBER (object))
+ return;
+
+ num = SWFDEC_AS_NUMBER (object);
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, num->number);
+}
+
+// only available as ASnative
+SWFDEC_AS_NATIVE (3, 1, swfdec_as_number_old_constructor)
+void
+swfdec_as_number_old_constructor (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("old 'Number' function (only available as ASnative)");
+}
+
+// only available as ASnative
+SWFDEC_AS_NATIVE (3, 4, swfdec_as_number_old_toString)
+void
+swfdec_as_number_old_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("old 'Number.prototype.toString' function (only available as ASnative)");
+}
diff --git a/swfdec/swfdec_as_number.h b/swfdec/swfdec_as_number.h
new file mode 100644
index 0000000..9b6ede0
--- /dev/null
+++ b/swfdec/swfdec_as_number.h
@@ -0,0 +1,52 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_NUMBER_H_
+#define _SWFDEC_AS_NUMBER_H_
+
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_as_types.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecAsNumber SwfdecAsNumber;
+typedef struct _SwfdecAsNumberClass SwfdecAsNumberClass;
+
+#define SWFDEC_TYPE_AS_NUMBER (swfdec_as_number_get_type())
+#define SWFDEC_IS_AS_NUMBER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_NUMBER))
+#define SWFDEC_IS_AS_NUMBER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_NUMBER))
+#define SWFDEC_AS_NUMBER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_NUMBER, SwfdecAsNumber))
+#define SWFDEC_AS_NUMBER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_NUMBER, SwfdecAsNumberClass))
+#define SWFDEC_AS_NUMBER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_NUMBER, SwfdecAsNumberClass))
+
+struct _SwfdecAsNumber {
+ SwfdecAsObject object;
+
+ double number; /* number represented by this number object */
+};
+
+struct _SwfdecAsNumberClass {
+ SwfdecAsObjectClass object_class;
+};
+
+GType swfdec_as_number_get_type (void);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_as_object.c b/swfdec/swfdec_as_object.c
new file mode 100644
index 0000000..d898f01
--- /dev/null
+++ b/swfdec/swfdec_as_object.c
@@ -0,0 +1,1773 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+
+#include "swfdec_as_object.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_frame_internal.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_as_stack.h"
+#include "swfdec_as_string.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_as_super.h"
+#include "swfdec_debug.h"
+#include "swfdec_movie.h"
+
+/**
+ * SECTION:SwfdecAsObject
+ * @title: SwfdecAsObject
+ * @short_description: the base object type for scriptable objects
+ *
+ * This is the basic object type in Swfdec. Every object used by the script
+ * engine must be a #SwfdecAsObject. It handles memory management and assigning
+ * variables to it. Almost all functions that are called on objects require that
+ * the objects have been added to the garbage collector previously. For
+ * custom-created objects, you need to do this using swfdec_as_object_add(),
+ * built-in functions that create objects do this manually.
+ *
+ * Note that you cannot know the lifetime of a #SwfdecAsObject, since scripts
+ * may assign it as a variable to other objects. So you should not assume to
+ * know when an object gets removed.
+ */
+
+/**
+ * SwfdecAsObject:
+ *
+ * Every object value inside the Swfdec script engine must be a SwfdecAsObject.
+ * If you want to add custom objects to your script engine, you need to create a
+ * subclass. The class provides a number of virtual functions that you can
+ * override to achieve the desired behaviour.
+ */
+
+/**
+ * SwfdecAsVariableFlag:
+ * @SWFDEC_AS_VARIABLE_HIDDEN: Do not include variable in enumerations and
+ * swfdec_as_object_foreach().
+ * @SWFDEC_AS_VARIABLE_PERMANENT: Do not allow swfdec_as_object_delete_variable()
+ * to delete this variable.
+ * @SWFDEC_AS_VARIABLE_CONSTANT: Do not allow changing the value with
+ * swfdec_as_object_set_variable().
+ * @SWFDEC_AS_VARIABLE_VERSION_6_UP: This symbol is only visible in version 6
+ * and above.
+ * @SWFDEC_AS_VARIABLE_VERSION_NOT_6: This symbols is visible in all versions
+ * but version 6.
+ * @SWFDEC_AS_VARIABLE_VERSION_7_UP: This symbol is only visible in version 7
+ * and above.
+ * @SWFDEC_AS_VARIABLE_VERSION_8_UP: This symbol is only visible in version 8
+ * and above.
+ * @SWFDEC_AS_VARIABLE_VERSION_9_UP: This symbol is only visible in version 9
+ * and above.
+ *
+ * These flags are used to describe various properties of a variable inside
+ * Swfdec. You can manually set them with swfdec_as_object_set_variable_flags().
+ */
+
+/**
+ * SwfdecAsDeleteReturn:
+ * @SWFDEC_AS_DELETE_NOT_FOUND: The variable was not found and therefore
+ * couldn't be deleted.
+ * @SWFDEC_AS_DELETE_DELETED: The variable was deleted.
+ * @SWFDEC_AS_DELETE_NOT_DELETED: The variable was found but could not be
+ * deleted.
+ *
+ * This is the return value used by swfdec_as_object_delete_variable(). It
+ * describes the various outcomes of trying to delete a variable.
+ */
+
+/**
+ * SwfdecAsVariableForeach:
+ * @object: The object this function is run on
+ * @variable: garbage-collected name of the current variables
+ * @value: value of the current variable
+ * @flags: Flags associated with the current variable
+ * @data: User data passed to swfdec_as_object_foreach()
+ *
+ * Function prototype for the swfdec_as_object_foreach() function.
+ *
+ * Returns: %TRUE to continue running the foreach function, %FALSE to stop
+ */
+
+typedef struct _SwfdecAsVariable SwfdecAsVariable;
+struct _SwfdecAsVariable {
+ guint flags; /* SwfdecAsVariableFlag values */
+ SwfdecAsValue value; /* value of property */
+ SwfdecAsFunction * get; /* getter set with swfdec_as_object_add_property */
+ SwfdecAsFunction * set; /* setter or %NULL */
+};
+
+typedef struct {
+ SwfdecAsFunction * watch; /* watcher or %NULL */
+ SwfdecAsValue watch_data; /* user data to watcher */
+ guint refcount; /* refcount - misused for recursion detection */
+} SwfdecAsWatch;
+
+G_DEFINE_TYPE (SwfdecAsObject, swfdec_as_object, G_TYPE_OBJECT)
+
+static void
+swfdec_as_object_dispose (GObject *gobject)
+{
+ SwfdecAsObject *object = SWFDEC_AS_OBJECT (gobject);
+
+ g_assert (object->properties == NULL);
+ g_slist_free (object->interfaces);
+ object->interfaces = NULL;
+
+ G_OBJECT_CLASS (swfdec_as_object_parent_class)->dispose (gobject);
+}
+
+static void
+swfdec_as_object_mark_property (gpointer key, gpointer value, gpointer unused)
+{
+ SwfdecAsVariable *var = value;
+
+ swfdec_as_string_mark (key);
+ if (var->get) {
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (var->get));
+ if (var->set)
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (var->set));
+ } else {
+ swfdec_as_value_mark (&var->value);
+ }
+}
+
+static void
+swfdec_as_object_mark_watch (gpointer key, gpointer value, gpointer unused)
+{
+ SwfdecAsWatch *watch = value;
+
+ swfdec_as_string_mark (key);
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (watch->watch));
+ swfdec_as_value_mark (&watch->watch_data);
+}
+
+static void
+swfdec_as_object_do_mark (SwfdecAsObject *object)
+{
+ if (object->prototype)
+ swfdec_as_object_mark (object->prototype);
+ g_hash_table_foreach (object->properties, swfdec_as_object_mark_property, NULL);
+ if (object->watches)
+ g_hash_table_foreach (object->watches, swfdec_as_object_mark_watch, NULL);
+ g_slist_foreach (object->interfaces, (GFunc) swfdec_as_object_mark, NULL);
+}
+
+static void
+swfdec_as_object_do_add (SwfdecAsObject *object)
+{
+}
+
+static gboolean
+swfdec_as_object_lookup_case_insensitive (gpointer key, gpointer value, gpointer user_data)
+{
+ return g_ascii_strcasecmp (key, user_data) == 0;
+}
+
+static gboolean
+swfdec_as_variable_name_is_valid (const char *name)
+{
+ return name != SWFDEC_AS_STR_EMPTY;
+}
+
+static inline SwfdecAsVariable *
+swfdec_as_object_hash_lookup (SwfdecAsObject *object, const char *variable)
+{
+ SwfdecAsVariable *var = g_hash_table_lookup (object->properties, variable);
+
+ if (var || object->context->version >= 7)
+ return var;
+ var = g_hash_table_find (object->properties, swfdec_as_object_lookup_case_insensitive, (gpointer) variable);
+ return var;
+}
+
+static inline SwfdecAsVariable *
+swfdec_as_object_hash_create (SwfdecAsObject *object, const char *variable, guint flags)
+{
+ SwfdecAsVariable *var;
+
+ if (!swfdec_as_context_use_mem (object->context, sizeof (SwfdecAsVariable)))
+ return NULL;
+ if (!swfdec_as_variable_name_is_valid (variable))
+ return NULL;
+ var = g_slice_new0 (SwfdecAsVariable);
+ var->flags = flags;
+ g_hash_table_insert (object->properties, (gpointer) variable, var);
+
+ return var;
+}
+
+static gboolean
+swfdec_as_object_variable_enabled_in_version (SwfdecAsVariable *var,
+ guint version)
+{
+ if (var->flags & SWFDEC_AS_VARIABLE_VERSION_6_UP && version < 6)
+ return FALSE;
+ if (var->flags & SWFDEC_AS_VARIABLE_VERSION_NOT_6 && version == 6)
+ return FALSE;
+ if (var->flags & SWFDEC_AS_VARIABLE_VERSION_7_UP && version < 7)
+ return FALSE;
+ if (var->flags & SWFDEC_AS_VARIABLE_VERSION_8_UP && version < 8)
+ return FALSE;
+ if (var->flags & SWFDEC_AS_VARIABLE_VERSION_9_UP && version < 9)
+ return FALSE;
+
+ return TRUE;
+}
+
+static gboolean
+swfdec_as_object_do_get (SwfdecAsObject *object, SwfdecAsObject *orig,
+ const char *variable, SwfdecAsValue *val, guint *flags)
+{
+ SwfdecAsVariable *var = swfdec_as_object_hash_lookup (object, variable);
+
+ if (var == NULL)
+ return FALSE;
+
+ /* variable flag checks */
+ if (!swfdec_as_object_variable_enabled_in_version (var,
+ object->context->version))
+ return FALSE;
+
+ if (var->get) {
+ swfdec_as_function_call (var->get, orig, 0, NULL, val);
+ swfdec_as_context_run (object->context);
+ *flags = var->flags;
+ } else {
+ *val = var->value;
+ *flags = var->flags;
+ }
+ return TRUE;
+}
+
+static SwfdecAsWatch *
+swfdec_as_watch_new (SwfdecAsFunction *function)
+{
+ SwfdecAsWatch *watch;
+
+ if (!swfdec_as_context_use_mem (SWFDEC_AS_OBJECT (function)->context,
+ sizeof (SwfdecAsWatch)))
+ return NULL;
+
+ watch = g_slice_new (SwfdecAsWatch);
+ watch->refcount = 1;
+ watch->watch = function;
+ SWFDEC_AS_VALUE_SET_UNDEFINED (&watch->watch_data);
+ return watch;
+}
+
+static inline gboolean
+swfdec_as_watch_can_recurse (SwfdecAsWatch *watch)
+{
+ guint version;
+
+ version = SWFDEC_AS_OBJECT (watch->watch)->context->version;
+ if (version <= 6) {
+ return watch->refcount <= 1;
+ } else {
+ return watch->refcount <= 64 + 1;
+ }
+}
+
+static inline void
+swfdec_as_watch_ref (SwfdecAsWatch *watch)
+{
+ watch->refcount++;
+}
+
+static inline void
+swfdec_as_watch_unref (SwfdecAsWatch *watch)
+{
+ watch->refcount--;
+ if (watch->refcount == 0) {
+ swfdec_as_context_unuse_mem (SWFDEC_AS_OBJECT (watch->watch)->context,
+ sizeof (SwfdecAsWatch));
+ g_slice_free (SwfdecAsWatch, watch);
+ }
+}
+
+/*
+ * Like swfdec_as_object_get_prototype, but doesn't check 8_UP flag when
+ * version is 7 and doesn't check if the property has been deleted if version
+ * is 6 or earlier
+ */
+static SwfdecAsObject *
+swfdec_as_object_get_prototype_internal (SwfdecAsObject *object)
+{
+ int version;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL);
+
+ version = object->context->version;
+
+ if (object->prototype == NULL)
+ return NULL;
+
+ if (object->prototype_flags & SWFDEC_AS_VARIABLE_VERSION_6_UP && version < 6)
+ return NULL;
+ // don't check for NOT_6 flag
+ if (object->prototype_flags & SWFDEC_AS_VARIABLE_VERSION_7_UP && version < 7)
+ return NULL;
+ // don't check 8_UP or 9_UP for version 6, 7 or 8
+ if (object->prototype_flags & (SWFDEC_AS_VARIABLE_VERSION_8_UP | SWFDEC_AS_VARIABLE_VERSION_9_UP) && version < 6)
+ return NULL;
+ // check that it exists, if version < 7
+ if (version < 7 &&
+ !swfdec_as_object_hash_lookup (object, SWFDEC_AS_STR___proto__))
+ return NULL;
+
+ return object->prototype;
+}
+
+/*
+ * Get's the object->prototype, if propflags allow it for current version and
+ * if it hasn't been deleted from the object already
+ */
+SwfdecAsObject *
+swfdec_as_object_get_prototype (SwfdecAsObject *object)
+{
+ int version;
+ SwfdecAsObject *prototype;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL);
+
+ version = object->context->version;
+
+ prototype = swfdec_as_object_get_prototype_internal (object);
+
+ if (prototype == NULL)
+ return NULL;
+ // check 8_UP for version 7, still not for version 6
+ if (object->prototype_flags & SWFDEC_AS_VARIABLE_VERSION_8_UP &&
+ version == 7)
+ return NULL;
+ // check 9_UP flag for version 8, still not for version 7 or 6
+ if (object->prototype_flags & SWFDEC_AS_VARIABLE_VERSION_9_UP &&
+ version == 8)
+ return NULL;
+ // require it to exist even on version >= 7
+ if (version >= 7 &&
+ !swfdec_as_object_hash_lookup (object, SWFDEC_AS_STR___proto__))
+ return NULL;
+
+ return object->prototype;
+}
+
+static SwfdecAsVariable *
+swfdec_as_object_hash_lookup_with_prototype (SwfdecAsObject *object,
+ const char *variable, SwfdecAsObject **proto)
+{
+ SwfdecAsVariable *var;
+ SwfdecAsObject *proto_;
+
+ g_return_val_if_fail (swfdec_as_variable_name_is_valid (variable), NULL);
+
+ proto_ = NULL;
+
+ // match first level variable even if it has version flags that hide it in
+ // this version
+ var = swfdec_as_object_hash_lookup (object, variable);
+ if (var == NULL && variable != SWFDEC_AS_STR___proto__) {
+ guint i;
+
+ proto_ = swfdec_as_object_get_prototype (object);
+
+ for (i = 0; i < SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT && proto_; i++) {
+ var = swfdec_as_object_hash_lookup (proto_, variable);
+ if (var && var->get)
+ break;
+ proto_ = swfdec_as_object_get_prototype (proto_);
+ var = NULL;
+ }
+
+ if (i == SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT) {
+ swfdec_as_context_abort (object->context, "Prototype recursion limit exceeded");
+ return NULL;
+ }
+ }
+
+ if (proto != NULL)
+ *proto = proto_;
+
+ return var;
+}
+
+static void
+swfdec_as_object_do_set (SwfdecAsObject *object, const char *variable,
+ const SwfdecAsValue *val, guint flags)
+{
+ SwfdecAsVariable *var;
+ SwfdecAsWatch *watch;
+ SwfdecAsObject *proto;
+
+ if (!swfdec_as_variable_name_is_valid (variable))
+ return;
+
+ var = swfdec_as_object_hash_lookup_with_prototype (object, variable, &proto);
+ if (swfdec_as_context_is_aborted (object->context))
+ return;
+
+ // if variable is disabled in this version
+ if (var != NULL && !swfdec_as_object_variable_enabled_in_version (var,
+ object->context->version)) {
+ if (proto == NULL) {
+ // it's at the top level, remove getter and setter plus overwrite
+ var->get = NULL;
+ var->set = NULL;
+ } else {
+ // it's in proto, we create a new one at the top level
+ var = NULL;
+ }
+ }
+
+ if (var == NULL) {
+ var = swfdec_as_object_hash_create (object, variable, flags);
+ if (var == NULL)
+ return;
+ } else {
+ if (var->flags & SWFDEC_AS_VARIABLE_CONSTANT)
+ return;
+ // remove the flags that could make this variable hidden
+ if (object->context->version == 6) {
+ // version 6, so let's forget SWFDEC_AS_VARIABLE_VERSION_7_UP flag, oops!
+ // we will still set the value though, even if that flag is set
+ var->flags &= ~(SWFDEC_AS_VARIABLE_VERSION_6_UP |
+ SWFDEC_AS_VARIABLE_VERSION_NOT_6 | SWFDEC_AS_VARIABLE_VERSION_8_UP |
+ SWFDEC_AS_VARIABLE_VERSION_9_UP);
+ } else {
+ var->flags &= ~(SWFDEC_AS_VARIABLE_VERSION_6_UP |
+ SWFDEC_AS_VARIABLE_VERSION_NOT_6 | SWFDEC_AS_VARIABLE_VERSION_7_UP |
+ SWFDEC_AS_VARIABLE_VERSION_8_UP | SWFDEC_AS_VARIABLE_VERSION_9_UP);
+ }
+ }
+ if (object->watches) {
+ SwfdecAsValue ret = *val;
+ watch = g_hash_table_lookup (object->watches, variable);
+ /* FIXME: figure out if this limit here is correct. Add a watch in Flash 7
+ * and set a variable using Flash 6 */
+ if (watch && swfdec_as_watch_can_recurse (watch)) {
+ SwfdecAsValue args[4];
+ SWFDEC_AS_VALUE_SET_STRING (&args[0], variable);
+ args[1] = var->value;
+ args[2] = *val;
+ args[3] = watch->watch_data;
+ swfdec_as_watch_ref (watch);
+ swfdec_as_function_call (watch->watch, object, 4, args, &ret);
+ swfdec_as_context_run (object->context);
+ swfdec_as_watch_unref (watch);
+ var = swfdec_as_object_hash_lookup_with_prototype (object, variable,
+ NULL);
+ if (swfdec_as_context_is_aborted (object->context))
+ return;
+ if (var == NULL) {
+ SWFDEC_INFO ("watch removed variable %s", variable);
+ return;
+ }
+ }
+
+ var->value = ret;
+ } else {
+ watch = NULL;
+ }
+ if (var->get) {
+ if (var->set) {
+ SwfdecAsValue tmp;
+ swfdec_as_function_call (var->set, object, 1, val, &tmp);
+ swfdec_as_context_run (object->context);
+ }
+ } else if (watch == NULL) {
+ var->value = *val;
+ }
+
+ if (variable == SWFDEC_AS_STR___proto__) {
+ if (SWFDEC_AS_VALUE_IS_OBJECT (val) &&
+ !SWFDEC_IS_MOVIE (SWFDEC_AS_VALUE_GET_OBJECT (val))) {
+ object->prototype = SWFDEC_AS_VALUE_GET_OBJECT (val);
+ object->prototype_flags = var->flags;
+ } else {
+ object->prototype = NULL;
+ object->prototype_flags = 0;
+ }
+ }
+}
+
+static void
+swfdec_as_object_do_set_flags (SwfdecAsObject *object, const char *variable, guint flags, guint mask)
+{
+ SwfdecAsVariable *var = swfdec_as_object_hash_lookup (object, variable);
+
+ if (var) {
+ var->flags = (var->flags & ~mask) | flags;
+
+ if (variable == SWFDEC_AS_STR___proto__)
+ object->prototype_flags = var->flags;
+ }
+}
+
+static void
+swfdec_as_object_free_property (gpointer key, gpointer value, gpointer data)
+{
+ SwfdecAsObject *object = data;
+
+ swfdec_as_context_unuse_mem (object->context, sizeof (SwfdecAsVariable));
+ g_slice_free (SwfdecAsVariable, value);
+}
+
+static SwfdecAsDeleteReturn
+swfdec_as_object_do_delete (SwfdecAsObject *object, const char *variable)
+{
+ SwfdecAsVariable *var;
+
+ var = g_hash_table_lookup (object->properties, variable);
+ if (var == NULL)
+ return SWFDEC_AS_DELETE_NOT_FOUND;
+ if (var->flags & SWFDEC_AS_VARIABLE_PERMANENT)
+ return SWFDEC_AS_DELETE_NOT_DELETED;
+
+ // Note: We won't remove object->prototype, even if __proto__ is deleted
+
+ swfdec_as_object_free_property (NULL, var, object);
+ if (!g_hash_table_remove (object->properties, variable)) {
+ g_assert_not_reached ();
+ }
+ return SWFDEC_AS_DELETE_DELETED;
+}
+
+typedef struct {
+ SwfdecAsObject * object;
+ SwfdecAsVariableForeach func;
+ gpointer data;
+ gboolean retval;
+} ForeachData;
+
+static void
+swfdec_as_object_hash_foreach (gpointer key, gpointer value, gpointer data)
+{
+ ForeachData *fdata = data;
+ SwfdecAsVariable *var = value;
+
+ if (!fdata->retval)
+ return;
+
+ fdata->retval = fdata->func (fdata->object, key, &var->value, var->flags, fdata->data);
+}
+
+/* FIXME: does not do Adobe Flash's order for Enumerate actions */
+static gboolean
+swfdec_as_object_do_foreach (SwfdecAsObject *object, SwfdecAsVariableForeach func, gpointer data)
+{
+ ForeachData fdata = { object, func, data, TRUE };
+
+ g_hash_table_foreach (object->properties, swfdec_as_object_hash_foreach, &fdata);
+ return fdata.retval;
+}
+
+typedef struct {
+ SwfdecAsObject * object;
+ SwfdecAsVariableForeachRemove func;
+ gpointer data;
+} ForeachRemoveData;
+
+static gboolean
+swfdec_as_object_hash_foreach_remove (gpointer key, gpointer value, gpointer data)
+{
+ ForeachRemoveData *fdata = data;
+ SwfdecAsVariable *var = value;
+
+ if (!fdata->func (fdata->object, key, &var->value, var->flags, fdata->data))
+ return FALSE;
+
+ swfdec_as_object_free_property (NULL, var, fdata->object);
+ return TRUE;
+}
+
+/**
+ * swfdec_as_object_foreach_remove:
+ * @object: a #SwfdecAsObject
+ * @func: function that determines which object to remove
+ * @data: data to pass to @func
+ *
+ * Removes all variables form @object where @func returns %TRUE. This is an
+ * internal function for array operations.
+ *
+ * Returns: he number of variables removed
+ **/
+guint
+swfdec_as_object_foreach_remove (SwfdecAsObject *object, SwfdecAsVariableForeach func,
+ gpointer data)
+{
+ ForeachRemoveData fdata = { object, func, data };
+
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), 0);
+ g_return_val_if_fail (func != NULL, 0);
+
+ return g_hash_table_foreach_remove (object->properties,
+ swfdec_as_object_hash_foreach_remove, &fdata);
+}
+
+typedef struct {
+ SwfdecAsObject * object;
+ GHashTable * properties_new;
+ SwfdecAsVariableForeachRename func;
+ gpointer data;
+} ForeachRenameData;
+
+static gboolean
+swfdec_as_object_hash_foreach_rename (gpointer key, gpointer value, gpointer data)
+{
+ ForeachRenameData *fdata = data;
+ SwfdecAsVariable *var = value;
+ const char *key_new;
+
+ key_new = fdata->func (fdata->object, key, &var->value, var->flags, fdata->data);
+ if (key_new) {
+ g_hash_table_insert (fdata->properties_new, (gpointer) key_new, var);
+ } else {
+ swfdec_as_object_free_property (NULL, var, fdata->object);
+ }
+
+ return TRUE;
+}
+
+/**
+ * swfdec_as_object_foreach_rename:
+ * @object: a #SwfdecAsObject
+ * @func: function determining the new name
+ * @data: data to pass to @func
+ *
+ * Calls @func for each variable of @object. The function is then supposed
+ * to return the new name of the variable or %NULL if the variable should be
+ * removed. This is an internal function for array operations.
+ **/
+void
+swfdec_as_object_foreach_rename (SwfdecAsObject *object, SwfdecAsVariableForeachRename func,
+ gpointer data)
+{
+ ForeachRenameData fdata = { object, NULL, func, data };
+
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+ g_return_if_fail (func != NULL);
+
+ fdata.properties_new = g_hash_table_new (g_direct_hash, g_direct_equal);
+ g_hash_table_foreach_remove (object->properties, swfdec_as_object_hash_foreach_rename, &fdata);
+ g_hash_table_destroy (object->properties);
+ object->properties = fdata.properties_new;
+}
+
+static char *
+swfdec_as_object_do_debug (SwfdecAsObject *object)
+{
+ if (G_OBJECT_TYPE (object) != SWFDEC_TYPE_AS_OBJECT)
+ return g_strdup (G_OBJECT_TYPE_NAME (object));
+
+ return g_strdup ("Object");
+}
+
+static void
+swfdec_as_object_class_init (SwfdecAsObjectClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = swfdec_as_object_dispose;
+
+ klass->mark = swfdec_as_object_do_mark;
+ klass->add = swfdec_as_object_do_add;
+ klass->get = swfdec_as_object_do_get;
+ klass->set = swfdec_as_object_do_set;
+ klass->set_flags = swfdec_as_object_do_set_flags;
+ klass->del = swfdec_as_object_do_delete;
+ klass->foreach = swfdec_as_object_do_foreach;
+ klass->debug = swfdec_as_object_do_debug;
+}
+
+static void
+swfdec_as_object_init (SwfdecAsObject *object)
+{
+}
+
+/**
+ * swfdec_as_object_new_empty:
+ * @context: a #SwfdecAsContext
+ *
+ * Creates an empty object. The prototype and constructor properties of the
+ * returned object will not be set. You probably want to call
+ * swfdec_as_object_set_constructor() on the returned object yourself.
+ * You may want to use swfdec_as_object_new() instead.
+ *
+ * Returns: A new #SwfdecAsObject adde to @context or %NULL on OOM.
+ **/
+SwfdecAsObject *
+swfdec_as_object_new_empty (SwfdecAsContext *context)
+{
+ SwfdecAsObject *object;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
+
+ if (!swfdec_as_context_use_mem (context, sizeof (SwfdecAsObject)))
+ return NULL;
+ object = g_object_new (SWFDEC_TYPE_AS_OBJECT, NULL);
+ swfdec_as_object_add (object, context, sizeof (SwfdecAsObject));
+ return object;
+}
+
+/**
+ * swfdec_as_object_new:
+ * @context: a #SwfdecAsContext
+ *
+ * Allocates a new Object. This does the same as the Actionscript code
+ * "new Object()".
+ *
+ * Returns: the new object or NULL on out of memory.
+ **/
+SwfdecAsObject *
+swfdec_as_object_new (SwfdecAsContext *context)
+{
+ SwfdecAsObject *object;
+ SwfdecAsValue val;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
+ g_assert (context->Object);
+ g_assert (context->Object_prototype);
+
+ object = swfdec_as_object_new_empty (context);
+ if (object == NULL)
+ return NULL;
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object);
+ swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR_constructor,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object_prototype);
+ swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR___proto__,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+ return object;
+}
+
+/**
+ * swfdec_as_object_add:
+ * @object: #SwfdecAsObject to make garbage-collected
+ * @context: #SwfdecAsContext that should manage the object
+ * @size: size the object currently uses
+ *
+ * Takes over the reference to @object for the garbage collector of @context.
+ * The object may not already be part of a different context. The given @size
+ * must have been allocated before with swfdec_as_context_use_mem ().
+ * Note that after swfdec_as_object_add() the garbage collector might hold the
+ * only reference to @object.
+ **/
+void
+swfdec_as_object_add (SwfdecAsObject *object, SwfdecAsContext *context, gsize size)
+{
+ SwfdecAsObjectClass *klass;
+
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
+ g_return_if_fail (object->properties == NULL);
+
+ object->context = context;
+ object->size = size;
+ g_hash_table_insert (context->objects, object, object);
+ object->properties = g_hash_table_new (g_direct_hash, g_direct_equal);
+ klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
+ g_return_if_fail (klass->add);
+ klass->add (object);
+ if (context->debugger) {
+ SwfdecAsDebuggerClass *dklass = SWFDEC_AS_DEBUGGER_GET_CLASS (context->debugger);
+ if (dklass->add)
+ dklass->add (context->debugger, context, object);
+ }
+}
+
+/* This is a huge hack design-wise, but we can't use watch->watch,
+ * it might be gone already */
+static gboolean
+swfdec_as_object_steal_watches (gpointer key, gpointer value, gpointer object)
+{
+ SwfdecAsWatch *watch = value;
+
+ g_assert (watch->refcount == 1);
+ watch->watch = (SwfdecAsFunction *) object;
+ swfdec_as_watch_unref (watch);
+ return TRUE;
+}
+
+void
+swfdec_as_object_collect (SwfdecAsObject *object)
+{
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+ g_return_if_fail (object->properties != NULL);
+
+ g_hash_table_foreach (object->properties, swfdec_as_object_free_property, object);
+ g_hash_table_destroy (object->properties);
+ object->properties = NULL;
+ if (object->watches) {
+ g_hash_table_foreach_steal (object->watches, swfdec_as_object_steal_watches, object);
+ g_hash_table_destroy (object->watches);
+ object->watches = NULL;
+ }
+ if (object->size)
+ swfdec_as_context_unuse_mem (object->context, object->size);
+ g_object_unref (object);
+}
+
+/**
+ * swfdec_as_object_set_variable:
+ * @object: a #SwfdecAsObject
+ * @variable: garbage-collected name of the variable to set
+ * @value: value to set the variable to
+ *
+ * Sets a variable on @object. It is not guaranteed that getting the variable
+ * after setting it results in the same value. This is a mcaro that calls
+ * swfdec_as_object_set_variable_and_flags()
+ **/
+/**
+ * swfdec_as_object_set_variable_and_flags:
+ * @object: a #SwfdecAsObject
+ * @variable: garbage-collected name of the variable to set
+ * @value: value to set the variable to
+ * @default_flags: flags to use if creating the variable anew - the flags will
+ * be ignored if the property already exists.
+ *
+ * Sets a variable on @object. It is not guaranteed that getting the variable
+ * after setting it results in the same value, because various mechanisms (like
+ * the Actionscript Object.addProperty function or constant variables) can
+ * avoid this.
+ **/
+void
+swfdec_as_object_set_variable_and_flags (SwfdecAsObject *object,
+ const char *variable, const SwfdecAsValue *value, guint default_flags)
+{
+ SwfdecAsObjectClass *klass;
+
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+ g_return_if_fail (variable != NULL);
+ g_return_if_fail (SWFDEC_IS_AS_VALUE (value));
+
+ if (object->context->debugger) {
+ SwfdecAsDebugger *debugger = object->context->debugger;
+ SwfdecAsDebuggerClass *dklass = SWFDEC_AS_DEBUGGER_GET_CLASS (debugger);
+ if (dklass->set_variable)
+ dklass->set_variable (debugger, object->context, object, variable, value);
+ }
+ klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
+ klass->set (object, variable, value, default_flags);
+}
+
+/**
+ * swfdec_as_object_peek_variable:
+ * @object: the object to query
+ * @name: name of the variable to query
+ *
+ * Checks if the given @object contains a variable wih the given @name and if
+ * so, returns a pointer to its value. This pointer will be valid until calling
+ * a setting function on the given object again.
+ * <warning><para>This function is internal as it provides a pointer to an
+ * internal structure. Do not use it unless you are sure you need to. This
+ * function skips prototypes, variables added via swfdec_as_value_add_variable()
+ * and does not verify visibility flags.</para></warning>
+ *
+ * Returns: a pointer to the queried variable or %NULL if it doesn't exist
+ **/
+SwfdecAsValue *
+swfdec_as_object_peek_variable (SwfdecAsObject *object, const char *name)
+{
+ SwfdecAsVariable *var;
+
+ var = swfdec_as_object_hash_lookup (object, name);
+ if (var == NULL ||
+ var->get != NULL)
+ return NULL;
+
+ return &var->value;
+}
+
+/**
+ * swfdec_as_object_get_variable:
+ * @object: a #SwfdecAsObject
+ * @variable: a garbage-collected string containing the name of the variable
+ * @value: pointer to a #SwfdecAsValue that takes the return value or %NULL
+ *
+ * Gets the value of the given @variable on @object. It walks the prototype
+ * chain. This is a shortcut macro for
+ * swfdec_as_object_get_variable_and_flags().
+ *
+ * Returns: %TRUE if the variable existed, %FALSE otherwise
+ */
+
+/**
+ * swfdec_as_object_get_variable_and_flags:
+ * @object: a #SwfdecAsObject
+ * @variable: a garbage-collected string containing the name of the variable
+ * @value: pointer to a #SwfdecAsValue that takes the return value or %NULL
+ * @flags: pointer to a guint taking the variable's flags or %NULL
+ * @pobject: pointer to set to the object that really holds the property or
+ * %NULL
+ *
+ * Looks up @variable on @object. It also walks the object's prototype chain.
+ * If the variable exists, its value, flags and the real object containing the
+ * variable will be set and %TRUE will be returned.
+ *
+ * Returns: %TRUE if the variable exists, %FALSE otherwise
+ **/
+gboolean
+swfdec_as_object_get_variable_and_flags (SwfdecAsObject *object,
+ const char *variable, SwfdecAsValue *value, guint *flags, SwfdecAsObject **pobject)
+{
+ SwfdecAsObjectClass *klass;
+ guint i;
+ SwfdecAsValue tmp_val;
+ guint tmp_flags;
+ SwfdecAsObject *tmp_pobject, *cur;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), FALSE);
+ g_return_val_if_fail (variable != NULL, FALSE);
+
+ if (value == NULL)
+ value = &tmp_val;
+ if (flags == NULL)
+ flags = &tmp_flags;
+ if (pobject == NULL)
+ pobject = &tmp_pobject;
+
+ cur = object;
+ for (i = 0; i <= SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT && cur != NULL; i++) {
+ klass = SWFDEC_AS_OBJECT_GET_CLASS (cur);
+ if (klass->get (cur, object, variable, value, flags)) {
+ *pobject = cur;
+ return TRUE;
+ }
+ cur = swfdec_as_object_get_prototype_internal (cur);
+ }
+ if (i > SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT) {
+ swfdec_as_context_abort (object->context, "Prototype recursion limit exceeded");
+ *flags = 0;
+ *pobject = NULL;
+ return FALSE;
+ }
+ //SWFDEC_WARNING ("no such variable %s", variable);
+ SWFDEC_AS_VALUE_SET_UNDEFINED (value);
+ *flags = 0;
+ *pobject = NULL;
+ return FALSE;
+}
+
+/**
+ * swfdec_as_object_has_variable:
+ * @object: a #SwfdecAsObject
+ * @variable: garbage-collected variable name
+ *
+ * Checks if a user-set @variable with the given name exists on @object. This
+ * function does not check variables that are available via an overwritten get
+ * function of the object's class.
+ *
+ * Returns: %TRUE if the @object contains the given @variable
+ **/
+gboolean
+swfdec_as_object_has_variable (SwfdecAsObject *object, const char *variable)
+{
+ guint i;
+ SwfdecAsVariable *var;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), FALSE);
+
+ for (i = 0; i <= SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT && object != NULL; i++) {
+ var = swfdec_as_object_hash_lookup (object, variable);
+ if (var) {
+ /* FIXME: propflags? */
+ return TRUE;
+ }
+ object = swfdec_as_object_get_prototype_internal (object);
+ }
+ return FALSE;
+}
+
+/**
+ * swfdec_as_object_delete_variable:
+ * @object: a #SwfdecAsObject
+ * @variable: garbage-collected name of the variable
+ *
+ * Deletes the given variable if possible. If the variable is protected from
+ * deletion, it will not be deleted.
+ *
+ * Returns: See #SwfdecAsDeleteReturn for details of the return value.
+ **/
+SwfdecAsDeleteReturn
+swfdec_as_object_delete_variable (SwfdecAsObject *object, const char *variable)
+{
+ SwfdecAsObjectClass *klass;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), FALSE);
+ g_return_val_if_fail (variable != NULL, FALSE);
+
+ klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
+ return klass->del (object, variable);
+}
+
+/**
+ * swfdec_as_object_delete_all_variables:
+ * @object: a #SwfdecAsObject
+ *
+ * Deletes all user-set variables from the given object.
+ **/
+void
+swfdec_as_object_delete_all_variables (SwfdecAsObject *object)
+{
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+
+ g_hash_table_foreach (object->properties, swfdec_as_object_free_property, object);
+ g_hash_table_remove_all (object->properties);
+}
+
+/**
+ * swfdec_as_object_set_variable_flags:
+ * @object: a #SwfdecAsObject
+ * @variable: the variable to modify
+ * @flags: flags to set
+ *
+ * Sets the given flags for the given variable.
+ **/
+void
+swfdec_as_object_set_variable_flags (SwfdecAsObject *object,
+ const char *variable, SwfdecAsVariableFlag flags)
+{
+ SwfdecAsObjectClass *klass;
+
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+ g_return_if_fail (variable != NULL);
+
+ klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
+ klass->set_flags (object, variable, flags, flags);
+}
+
+/**
+ * swfdec_as_object_unset_variable_flags:
+ * @object: a #SwfdecAsObject
+ * @variable: the variable to modify
+ * @flags: flags to unset
+ *
+ * Unsets the given flags for the given variable. The variable must exist in
+ * @object.
+ **/
+void
+swfdec_as_object_unset_variable_flags (SwfdecAsObject *object,
+ const char *variable, SwfdecAsVariableFlag flags)
+{
+ SwfdecAsObjectClass *klass;
+
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+ g_return_if_fail (variable != NULL);
+
+ klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
+ klass->set_flags (object, variable, 0, flags);
+}
+
+/**
+ * swfdec_as_object_foreach:
+ * @object: a #SwfdecAsObject
+ * @func: function to call
+ * @data: data to pass to @func
+ *
+ * Calls @func for every variable of @object or until @func returns %FALSE. The
+ * variables of @object must not be modified by @func.
+ *
+ * Returns: %TRUE if @func always returned %TRUE
+ **/
+gboolean
+swfdec_as_object_foreach (SwfdecAsObject *object, SwfdecAsVariableForeach func,
+ gpointer data)
+{
+ SwfdecAsObjectClass *klass;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), FALSE);
+ g_return_val_if_fail (func != NULL, FALSE);
+
+ klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
+ g_return_val_if_fail (klass->foreach != NULL, FALSE);
+ return klass->foreach (object, func, data);
+}
+
+/*** SIMPLIFICATIONS ***/
+
+static void
+swfdec_as_object_do_nothing (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+}
+
+/**
+ * swfdec_as_object_add_function:
+ * @object: a #SwfdecAsObject
+ * @name: name of the function. The string does not have to be
+ * garbage-collected.
+ * @type: the required type of the this Object to make this function execute.
+ * May be 0 to accept any type.
+ * @native: a native function or %NULL to just not do anything
+ * @min_args: minimum number of arguments to pass to @native
+ *
+ * Adds @native as a variable named @name to @object. The newly added variable
+ * will not be enumerated.
+ *
+ * Returns: the newly created #SwfdecAsFunction or %NULL on error.
+ **/
+SwfdecAsFunction *
+swfdec_as_object_add_function (SwfdecAsObject *object, const char *name, GType type,
+ SwfdecAsNative native, guint min_args)
+{
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (type == 0 || g_type_is_a (type, SWFDEC_TYPE_AS_OBJECT), NULL);
+
+ return swfdec_as_object_add_constructor (object, name, type, 0, native, min_args, NULL);
+}
+
+/**
+ * swfdec_as_object_add_constructor:
+ * @object: a #SwfdecAsObject
+ * @name: name of the function. The string does not have to be
+ * garbage-collected.
+ * @type: the required type of the this Object to make this function execute.
+ * May be 0 to accept any type.
+ * @construct_type: type used when using this function as a constructor. May
+ * be 0 to use the default type.
+ * @native: a native function or %NULL to just not do anything
+ * @min_args: minimum number of arguments to pass to @native
+ * @prototype: An optional object to be set as the "prototype" property of the
+ * new function. The prototype will be hidden and constant.
+ *
+ * Adds @native as a constructor named @name to @object. The newly added variable
+ * will not be enumerated.
+ *
+ * Returns: the newly created #SwfdecAsFunction or %NULL on error.
+ **/
+SwfdecAsFunction *
+swfdec_as_object_add_constructor (SwfdecAsObject *object, const char *name, GType type,
+ GType construct_type, SwfdecAsNative native, guint min_args, SwfdecAsObject *prototype)
+{
+ SwfdecAsFunction *function;
+ SwfdecAsValue val;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (type == 0 || g_type_is_a (type, SWFDEC_TYPE_AS_OBJECT), NULL);
+ g_return_val_if_fail (construct_type == 0 || g_type_is_a (construct_type, SWFDEC_TYPE_AS_OBJECT), NULL);
+ g_return_val_if_fail (prototype == NULL || SWFDEC_IS_AS_OBJECT (prototype), NULL);
+
+ if (!native)
+ native = swfdec_as_object_do_nothing;
+ function = swfdec_as_native_function_new (object->context, name, native, min_args, prototype);
+ if (function == NULL)
+ return NULL;
+ if (type != 0)
+ swfdec_as_native_function_set_object_type (SWFDEC_AS_NATIVE_FUNCTION (function), type);
+ if (construct_type != 0)
+ swfdec_as_native_function_set_construct_type (SWFDEC_AS_NATIVE_FUNCTION (function), construct_type);
+ name = swfdec_as_context_get_string (object->context, name);
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (function));
+ /* FIXME: I'd like to make sure no such property exists yet */
+ swfdec_as_object_set_variable_and_flags (object, name, &val,
+ SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+ return function;
+}
+
+/**
+ * swfdec_as_object_run:
+ * @object: a #SwfdecAsObject
+ * @script: script to execute
+ *
+ * Executes the given @script with @object as this pointer.
+ **/
+void
+swfdec_as_object_run (SwfdecAsObject *object, SwfdecScript *script)
+{
+ SwfdecAsContext *context;
+ SwfdecAsFrame *frame;
+
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+ g_return_if_fail (script != NULL);
+
+ context = object->context;
+ frame = swfdec_as_frame_new (context, script);
+ if (frame == NULL)
+ return;
+ swfdec_as_frame_set_this (frame, object);
+ swfdec_as_frame_preload (frame);
+ swfdec_as_context_run (context);
+ swfdec_as_stack_pop (context);
+}
+
+/**
+ * swfdec_as_object_call:
+ * @object: a #SwfdecAsObject
+ * @name: garbage-collected string naming the function to call.
+ * @argc: number of arguments to provide to function
+ * @argv: arguments or %NULL when @argc is 0
+ * @return_value: location to take the return value of the call or %NULL to
+ * ignore the return value.
+ *
+ * Calls the function named @name on the given object. This function is
+ * essentially equal to the folloeing Actionscript code:
+ * <informalexample><programlisting>
+ * @return_value = @object. at name (@argv[0], ..., @argv[argc-1]);
+ * </programlisting></informalexample>
+ **/
+void
+swfdec_as_object_call (SwfdecAsObject *object, const char *name, guint argc,
+ SwfdecAsValue *argv, SwfdecAsValue *return_value)
+{
+ SwfdecAsValue tmp;
+ SwfdecAsFunction *fun;
+
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+ g_return_if_fail (name != NULL);
+ g_return_if_fail (argc == 0 || argv != NULL);
+ g_return_if_fail (object->context->global != NULL); /* for SwfdecPlayer */
+
+ if (return_value)
+ SWFDEC_AS_VALUE_SET_UNDEFINED (return_value);
+ swfdec_as_object_get_variable (object, name, &tmp);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&tmp))
+ return;
+ fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&tmp);
+ if (!SWFDEC_IS_AS_FUNCTION (fun))
+ return;
+ swfdec_as_function_call (fun, object, argc, argv, return_value ? return_value : &tmp);
+ if (swfdec_as_context_is_aborted (object->context))
+ return;
+ swfdec_as_context_run (object->context);
+}
+
+/**
+ * swfdec_as_object_create:
+ * @fun: constructor
+ * @n_args: number of arguments
+ * @args: arguments to pass to constructor
+ * @return_value: pointer for return value or %NULL to push the return value to
+ * the stack
+ *
+ * Creates a new object for the given constructor and pushes the constructor on
+ * top of the stack. To actually run the constructor, you need to call
+ * swfdec_as_context_run().
+ **/
+void
+swfdec_as_object_create (SwfdecAsFunction *fun, guint n_args,
+ const SwfdecAsValue *args, SwfdecAsValue *return_value)
+{
+ SwfdecAsValue val;
+ SwfdecAsObject *new;
+ SwfdecAsContext *context;
+ SwfdecAsFunction *cur;
+ SwfdecAsFrame *frame;
+ guint size = 0;
+ GType type = 0;
+
+ g_return_if_fail (SWFDEC_IS_AS_FUNCTION (fun));
+
+ context = SWFDEC_AS_OBJECT (fun)->context;
+ cur = fun;
+ do {
+ if (SWFDEC_IS_AS_NATIVE_FUNCTION (cur)) {
+ SwfdecAsNativeFunction *native = SWFDEC_AS_NATIVE_FUNCTION (cur);
+ if (native->construct_size) {
+ type = native->construct_type;
+ size = native->construct_size;
+ break;
+ }
+ }
+ swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (cur), SWFDEC_AS_STR_prototype, &val);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
+ SwfdecAsObject *proto = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+ swfdec_as_object_get_variable (proto, SWFDEC_AS_STR___constructor__, &val);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
+ cur = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&val);
+ if (SWFDEC_IS_AS_FUNCTION (cur)) {
+ continue;
+ }
+ }
+ }
+ cur = NULL;
+ } while (type == 0 && cur != NULL);
+ if (type == 0) {
+ type = SWFDEC_TYPE_AS_OBJECT;
+ size = sizeof (SwfdecAsObject);
+ }
+ if (!swfdec_as_context_use_mem (context, size))
+ return;
+
+ new = g_object_new (type, NULL);
+ swfdec_as_object_add (new, context, size);
+ /* set initial variables */
+ if (swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (fun), SWFDEC_AS_STR_prototype, &val)) {
+ swfdec_as_object_set_variable_and_flags (new, SWFDEC_AS_STR___proto__,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+ }
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (fun));
+ if (context->version < 7) {
+ swfdec_as_object_set_variable_and_flags (new, SWFDEC_AS_STR_constructor,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN);
+ }
+ swfdec_as_object_set_variable_and_flags (new, SWFDEC_AS_STR___constructor__,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_VERSION_6_UP);
+
+ frame = swfdec_as_function_call_no_preload (fun, new, n_args, args, return_value);
+ frame->construct = TRUE;
+ swfdec_as_super_new (frame, new, new->prototype);
+ swfdec_as_frame_preload (frame);
+}
+
+/**
+ * swfdec_as_object_set_constructor:
+ * @object: a #SwfdecAsObject
+ * @construct: the constructor of @object
+ *
+ * Sets the constructor variables for @object. Most objects get these
+ * variables set automatically, but for objects you created yourself, you want
+ * to call this function. This is essentially the same as the following script
+ * code:
+ * |[ object.constructor = construct;
+ * object.__proto__ = construct.prototype; ]|
+ **/
+void
+swfdec_as_object_set_constructor (SwfdecAsObject *object, SwfdecAsObject *construct)
+{
+ SwfdecAsValue val;
+
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (construct));
+
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, construct);
+ swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR_constructor,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+ swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (construct),
+ SWFDEC_AS_STR_prototype, &val);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
+ SwfdecAsObject *proto = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
+ swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR___proto__,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+ } else {
+ SWFDEC_WARNING ("constructor has no prototype, not setting any");
+ }
+}
+
+/**
+ * swfdec_as_object_add_variable:
+ * @object: a #SwfdecAsObject
+ * @variable: name of the variable
+ * @get: getter function to call when reading the variable
+ * @set: setter function to call when writing the variable or %NULL if read-only
+ * @default_flags: flags to use if creating the variable anew - the flags will
+ * be ignored if the property already exists.
+ *
+ * Adds a variable to @object in the same way as the Actionscript code
+ * "object.addProperty()" would do. Accessing the variable will from now on be
+ * handled by calling the @get or @set functions. A previous value of the
+ * variable or a previous call to this function will be overwritten.
+ **/
+void
+swfdec_as_object_add_variable (SwfdecAsObject *object, const char *variable,
+ SwfdecAsFunction *get, SwfdecAsFunction *set, guint default_flags)
+{
+ SwfdecAsVariable *var;
+
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+ g_return_if_fail (variable != NULL);
+ g_return_if_fail (SWFDEC_IS_AS_FUNCTION (get));
+ g_return_if_fail (set == NULL || SWFDEC_IS_AS_FUNCTION (set));
+
+ var = swfdec_as_object_hash_lookup (object, variable);
+ if (var == NULL)
+ var = swfdec_as_object_hash_create (object, variable, default_flags);
+ if (var == NULL)
+ return;
+ var->get = get;
+ var->set = set;
+}
+
+void
+swfdec_as_object_add_native_variable (SwfdecAsObject *object,
+ const char *variable, SwfdecAsNative get, SwfdecAsNative set)
+{
+ SwfdecAsFunction *get_func, *set_func;
+
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+ g_return_if_fail (variable != NULL);
+ g_return_if_fail (get != NULL);
+
+ get_func =
+ swfdec_as_native_function_new (object->context, variable, get, 0, NULL);
+ if (get_func == NULL)
+ return;
+
+ if (set != NULL) {
+ set_func =
+ swfdec_as_native_function_new (object->context, variable, set, 0, NULL);
+ } else {
+ set_func = NULL;
+ }
+
+ swfdec_as_object_add_variable (object, variable, get_func, set_func, 0);
+}
+
+/*** AS CODE ***/
+
+SWFDEC_AS_NATIVE (101, 2, swfdec_as_object_addProperty)
+void
+swfdec_as_object_addProperty (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ SwfdecAsFunction *get, *set;
+ const char *name;
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
+ if (argc < 3)
+ return;
+ name = swfdec_as_value_to_string (cx, &argv[0]);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[1]) ||
+ !SWFDEC_IS_AS_FUNCTION ((get = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&argv[1]))))
+ return;
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[2])) {
+ set = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&argv[2]);
+ if (!SWFDEC_IS_AS_FUNCTION (set))
+ return;
+ } else if (SWFDEC_AS_VALUE_IS_NULL (&argv[2])) {
+ set = NULL;
+ } else {
+ return;
+ }
+
+ swfdec_as_object_add_variable (object, name, get, set, 0);
+ SWFDEC_AS_VALUE_SET_BOOLEAN (retval, TRUE);
+}
+
+SWFDEC_AS_NATIVE (101, 5, swfdec_as_object_hasOwnProperty)
+void
+swfdec_as_object_hasOwnProperty (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ SwfdecAsVariable *var;
+ const char *name;
+
+ if (object == NULL)
+ return;
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
+
+ // return false even if no params
+ if (argc < 1)
+ return;
+
+ name = swfdec_as_value_to_string (object->context, &argv[0]);
+
+ if (!(var = swfdec_as_object_hash_lookup (object, name)))
+ return;
+
+ /* This functions only checks NOT 6 flag, and checks it on ALL VERSIONS */
+ if (var->flags & SWFDEC_AS_VARIABLE_VERSION_NOT_6)
+ return;
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (retval, TRUE);
+}
+
+SWFDEC_AS_NATIVE (101, 7, swfdec_as_object_isPropertyEnumerable)
+void
+swfdec_as_object_isPropertyEnumerable (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *retval)
+{
+ SwfdecAsVariable *var;
+ const char *name;
+
+ if (object == NULL)
+ return;
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
+
+ // return false even if no params
+ if (argc < 1)
+ return;
+
+ name = swfdec_as_value_to_string (object->context, &argv[0]);
+
+ if (!(var = swfdec_as_object_hash_lookup (object, name)))
+ return;
+
+ if (var->flags & SWFDEC_AS_VARIABLE_HIDDEN)
+ return;
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (retval, TRUE);
+}
+
+SWFDEC_AS_NATIVE (101, 6, swfdec_as_object_isPrototypeOf)
+void
+swfdec_as_object_isPrototypeOf (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *retval)
+{
+ SwfdecAsObject *class;
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
+
+ // return false even if no params
+ if (argc < 1)
+ return;
+
+ class = swfdec_as_value_to_object (cx, &argv[0]);
+ if (class == NULL)
+ return;
+
+ while ((class = swfdec_as_object_get_prototype (class)) != NULL) {
+ if (object == class) {
+ SWFDEC_AS_VALUE_SET_BOOLEAN (retval, TRUE);
+ return;
+ }
+ }
+
+ // not found, nothing to do
+}
+
+SWFDEC_AS_NATIVE (101, 0, swfdec_as_object_watch)
+void
+swfdec_as_object_watch (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ SwfdecAsWatch *watch;
+ const char *name;
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
+
+ if (argc < 2)
+ return;
+
+ name = swfdec_as_value_to_string (cx, &argv[0]);
+
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[1]))
+ return;
+
+ if (!SWFDEC_IS_AS_FUNCTION (SWFDEC_AS_VALUE_GET_OBJECT (&argv[1])))
+ return;
+
+ if (object->watches == NULL) {
+ object->watches = g_hash_table_new_full (g_direct_hash, g_direct_equal,
+ NULL, (GDestroyNotify) swfdec_as_watch_unref);
+ watch = NULL;
+ } else {
+ watch = g_hash_table_lookup (object->watches, name);
+ }
+ if (watch == NULL) {
+ watch = swfdec_as_watch_new (SWFDEC_AS_FUNCTION (SWFDEC_AS_VALUE_GET_OBJECT (&argv[1])));
+ if (watch == NULL)
+ return;
+ g_hash_table_insert (object->watches, (char *) name, watch);
+ } else {
+ watch->watch = SWFDEC_AS_FUNCTION (SWFDEC_AS_VALUE_GET_OBJECT (&argv[1]));
+ }
+
+ if (argc >= 3) {
+ watch->watch_data = argv[2];
+ } else {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (&watch->watch_data);
+ }
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (retval, TRUE);
+}
+
+SWFDEC_AS_NATIVE (101, 1, swfdec_as_object_unwatch)
+void
+swfdec_as_object_unwatch (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ SwfdecAsVariable *var;
+ const char *name;
+
+ if (object == NULL)
+ return;
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (retval, FALSE);
+
+ if (argc < 1)
+ return;
+
+ name = swfdec_as_value_to_string (cx, &argv[0]);
+
+ // special case: can't unwatch native properties
+ if ((var = swfdec_as_object_hash_lookup (object, name))&& var->get != NULL)
+ return;
+
+ if (object->watches != NULL &&
+ g_hash_table_remove (object->watches, name)) {
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (retval, TRUE);
+
+ if (g_hash_table_size (object->watches) == 0) {
+ g_hash_table_destroy (object->watches);
+ object->watches = NULL;
+ }
+ }
+}
+
+SWFDEC_AS_NATIVE (101, 3, swfdec_as_object_valueOf)
+void
+swfdec_as_object_valueOf (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ if (object != NULL)
+ SWFDEC_AS_VALUE_SET_OBJECT (retval, object);
+}
+
+SWFDEC_AS_NATIVE (101, 4, swfdec_as_object_toString)
+void
+swfdec_as_object_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ if (SWFDEC_IS_AS_FUNCTION (object)) {
+ SWFDEC_AS_VALUE_SET_STRING (retval, SWFDEC_AS_STR__type_Function_);
+ } else {
+ SWFDEC_AS_VALUE_SET_STRING (retval, SWFDEC_AS_STR__object_Object_);
+ }
+}
+
+// only available as ASnative
+SWFDEC_AS_NATIVE (3, 3, swfdec_as_object_old_constructor)
+void
+swfdec_as_object_old_constructor (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("old 'Object' function (only available as ASnative)");
+}
+
+void
+swfdec_as_object_decode (SwfdecAsObject *object, const char *str)
+{
+ SwfdecAsContext *cx = object->context;
+ SwfdecAsValue val;
+ char **varlist, *p, *unescaped;
+ guint i;
+
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+ g_return_if_fail (str != NULL);
+
+ varlist = g_strsplit (str, "&", -1);
+
+ for (i = 0; varlist[i] != NULL; i++) {
+ p = strchr (varlist[i], '=');
+ if (p != NULL) {
+ *p++ = '\0';
+ if (*p == '\0')
+ p = NULL;
+ }
+
+ if (p != NULL) {
+ unescaped = swfdec_as_string_unescape (cx, p);
+ if (unescaped != NULL) {
+ SWFDEC_AS_VALUE_SET_STRING (&val,
+ swfdec_as_context_give_string (cx, unescaped));
+ } else {
+ SWFDEC_AS_VALUE_SET_STRING (&val, SWFDEC_AS_STR_EMPTY);
+ }
+ } else {
+ SWFDEC_AS_VALUE_SET_STRING (&val, SWFDEC_AS_STR_EMPTY);
+ }
+ unescaped = swfdec_as_string_unescape (cx, varlist[i]);
+ if (unescaped != NULL) {
+ swfdec_as_object_set_variable (object,
+ swfdec_as_context_give_string (cx, unescaped), &val);
+ }
+ }
+ g_strfreev (varlist);
+}
+
+void
+swfdec_as_object_init_context (SwfdecAsContext *context)
+{
+ SwfdecAsValue val;
+ SwfdecAsObject *object, *proto;
+
+ proto = swfdec_as_object_new_empty (context);
+ if (!proto)
+ return;
+ object = SWFDEC_AS_OBJECT (swfdec_as_object_add_function (context->global,
+ SWFDEC_AS_STR_Object, 0, NULL, 0));
+ if (!object)
+ return;
+ context->Object = object;
+ context->Object_prototype = proto;
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
+ /* first, set our own */
+ swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR_prototype,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT |
+ SWFDEC_AS_VARIABLE_CONSTANT);
+
+ /* then finish the function prototype (use this order or
+ * SWFDEC_AS_VARIABLE_CONSTANT won't let us */
+ swfdec_as_object_set_variable_and_flags (context->Function_prototype,
+ SWFDEC_AS_STR___proto__, &val,
+ SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, object);
+ swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+}
+
+/**
+ * swfdec_as_object_get_debug:
+ * @object: a #SwfdecAsObject
+ *
+ * Gets a representation string suitable for debugging. This function is
+ * guaranteed to not modify the state of the script engine, unlike
+ * swfdec_as_value_to_string() for example.
+ *
+ * Returns: A newly allocated string. Free it with g_free() after use.
+ **/
+char *
+swfdec_as_object_get_debug (SwfdecAsObject *object)
+{
+ SwfdecAsObjectClass *klass;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL);
+
+ klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
+ return klass->debug (object);
+}
+
+/**
+ * swfdec_as_object_resolve:
+ * @object: a #SwfdecAsObject
+ *
+ * Resolves the object to its real object. Some internal objects should not be
+ * exposed to scripts, for example #SwfdecAsFrame objects. If an object you want
+ * to expose might be internal, call this function to resolve it to an object
+ * that is safe to expose.
+ *
+ * Returns: a non-internal object
+ **/
+SwfdecAsObject *
+swfdec_as_object_resolve (SwfdecAsObject *object)
+{
+ SwfdecAsObjectClass *klass;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL);
+
+ klass = SWFDEC_AS_OBJECT_GET_CLASS (object);
+ if (klass->resolve == NULL)
+ return object;
+
+ return klass->resolve (object);
+}
diff --git a/swfdec/swfdec_as_object.h b/swfdec/swfdec_as_object.h
new file mode 100644
index 0000000..2fe888f
--- /dev/null
+++ b/swfdec/swfdec_as_object.h
@@ -0,0 +1,190 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_OBJECT_H_
+#define _SWFDEC_AS_OBJECT_H_
+
+#include <glib-object.h>
+#include <libswfdec/swfdec_as_types.h>
+
+G_BEGIN_DECLS
+
+/* NB: matches ASSetPropFlags */
+typedef enum {
+ SWFDEC_AS_VARIABLE_HIDDEN = (1 << 0),
+ SWFDEC_AS_VARIABLE_PERMANENT = (1 << 1),
+ SWFDEC_AS_VARIABLE_CONSTANT = (1 << 2),
+
+ SWFDEC_AS_VARIABLE_VERSION_6_UP = (1 << 7),
+ SWFDEC_AS_VARIABLE_VERSION_NOT_6 = (1 << 8),
+ SWFDEC_AS_VARIABLE_VERSION_7_UP = (1 << 10),
+ SWFDEC_AS_VARIABLE_VERSION_8_UP = (1 << 12),
+ SWFDEC_AS_VARIABLE_VERSION_9_UP = (1 << 13),
+} SwfdecAsVariableFlag;
+
+typedef enum {
+ SWFDEC_AS_DELETE_NOT_FOUND = 0,
+ SWFDEC_AS_DELETE_DELETED,
+ SWFDEC_AS_DELETE_NOT_DELETED
+} SwfdecAsDeleteReturn;
+
+typedef struct _SwfdecAsObjectClass SwfdecAsObjectClass;
+typedef gboolean (* SwfdecAsVariableForeach) (SwfdecAsObject *object,
+ const char *variable, SwfdecAsValue *value, guint flags, gpointer data);
+
+#define SWFDEC_TYPE_AS_OBJECT (swfdec_as_object_get_type())
+#define SWFDEC_IS_AS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_OBJECT))
+#define SWFDEC_IS_AS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_OBJECT))
+#define SWFDEC_AS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_OBJECT, SwfdecAsObject))
+#define SWFDEC_AS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_OBJECT, SwfdecAsObjectClass))
+#define SWFDEC_AS_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_OBJECT, SwfdecAsObjectClass))
+
+struct _SwfdecAsObject {
+ /*< protected >*/
+ GObject object;
+ SwfdecAsContext * context; /* context the object belongs to */
+ /*< private >*/
+ SwfdecAsObject * prototype; /* prototype object (referred to as __proto__) */
+ guint prototype_flags; /* propflags for the prototype object */
+ GHashTable * properties; /* string->SwfdecAsVariable mapping or NULL when not in GC */
+ GHashTable * watches; /* string->WatchData mapping or NULL when not watching anything */
+ guint8 flags; /* GC flags */
+ gsize size; /* size reserved in GC */
+ GSList * interfaces; /* list of interfaces this object implements */
+};
+
+struct _SwfdecAsObjectClass {
+ GObjectClass object_class;
+
+ /* mark everything that should survive during GC */
+ void (* mark) (SwfdecAsObject * object);
+ /* object was added to the context */
+ void (* add) (SwfdecAsObject * object);
+ /* get the value and flags for a variables */
+ gboolean (* get) (SwfdecAsObject * object,
+ SwfdecAsObject * orig,
+ const char * variable,
+ SwfdecAsValue * val,
+ guint * flags);
+ /* set the variable - and return it (or NULL on error) */
+ void (* set) (SwfdecAsObject * object,
+ const char * variable,
+ const SwfdecAsValue * val,
+ guint default_flags);
+ /* set flags of a variable */
+ void (* set_flags) (SwfdecAsObject * object,
+ const char * variable,
+ guint flags,
+ guint mask);
+ /* delete the variable - return TRUE if it exists */
+ SwfdecAsDeleteReturn (* del) (SwfdecAsObject * object,
+ const char * variable);
+ /* call with every variable until func returns FALSE */
+ gboolean (* foreach) (SwfdecAsObject * object,
+ SwfdecAsVariableForeach func,
+ gpointer data);
+ /* get the real object referenced by this object (useful for internal objects) */
+ SwfdecAsObject * (* resolve) (SwfdecAsObject * object);
+ /* get a debug string representation for this object */
+ char * (* debug) (SwfdecAsObject * object);
+};
+
+GType swfdec_as_object_get_type (void);
+
+SwfdecAsObject *swfdec_as_object_new (SwfdecAsContext * context);
+SwfdecAsObject *swfdec_as_object_new_empty (SwfdecAsContext * context);
+void swfdec_as_object_create (SwfdecAsFunction * fun,
+ guint n_args,
+ const SwfdecAsValue * args,
+ SwfdecAsValue * return_value);
+void swfdec_as_object_set_constructor(SwfdecAsObject * object,
+ SwfdecAsObject * construct);
+SwfdecAsObject *swfdec_as_object_resolve (SwfdecAsObject * object);
+char * swfdec_as_object_get_debug (SwfdecAsObject * object);
+
+void swfdec_as_object_add (SwfdecAsObject * object,
+ SwfdecAsContext * context,
+ gsize size);
+
+/* I'd like to name these [gs]et_property, but binding authors will complain
+ * about overlap with g_object_[gs]et_property then */
+#define swfdec_as_object_set_variable(object, variable, value) \
+ swfdec_as_object_set_variable_and_flags (object, variable, value, 0)
+void swfdec_as_object_set_variable_and_flags
+ (SwfdecAsObject * object,
+ const char * variable,
+ const SwfdecAsValue * value,
+ guint default_flags);
+void swfdec_as_object_add_variable (SwfdecAsObject * object,
+ const char * variable,
+ SwfdecAsFunction * get,
+ SwfdecAsFunction * set,
+ SwfdecAsVariableFlag default_flags);
+#define swfdec_as_object_get_variable(object, variable, value) \
+ swfdec_as_object_get_variable_and_flags (object, variable, value, NULL, NULL)
+gboolean swfdec_as_object_get_variable_and_flags
+ (SwfdecAsObject * object,
+ const char * variable,
+ SwfdecAsValue * value,
+ guint * flags,
+ SwfdecAsObject ** pobject);
+gboolean swfdec_as_object_has_variable (SwfdecAsObject * object,
+ const char * variable);
+SwfdecAsDeleteReturn
+ swfdec_as_object_delete_variable(SwfdecAsObject * object,
+ const char * variable);
+void swfdec_as_object_delete_all_variables
+ (SwfdecAsObject * object);
+void swfdec_as_object_set_variable_flags
+ (SwfdecAsObject * object,
+ const char * variable,
+ SwfdecAsVariableFlag flags);
+void swfdec_as_object_unset_variable_flags
+ (SwfdecAsObject * object,
+ const char * variable,
+ SwfdecAsVariableFlag flags);
+gboolean swfdec_as_object_foreach (SwfdecAsObject * object,
+ SwfdecAsVariableForeach func,
+ gpointer data);
+
+SwfdecAsFunction *swfdec_as_object_add_function (SwfdecAsObject * object,
+ const char * name,
+ GType type,
+ SwfdecAsNative native,
+ guint min_args);
+SwfdecAsFunction *swfdec_as_object_add_constructor
+ (SwfdecAsObject * object,
+ const char * name,
+ GType type,
+ GType construct_type,
+ SwfdecAsNative native,
+ guint min_args,
+ SwfdecAsObject * prototype);
+
+void swfdec_as_object_call (SwfdecAsObject * object,
+ const char * name,
+ guint argc,
+ SwfdecAsValue * argv,
+ SwfdecAsValue * return_value);
+void swfdec_as_object_run (SwfdecAsObject * object,
+ SwfdecScript * script);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_as_script_function.c b/swfdec/swfdec_as_script_function.c
new file mode 100644
index 0000000..c696305
--- /dev/null
+++ b/swfdec/swfdec_as_script_function.c
@@ -0,0 +1,154 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_script_function.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_frame_internal.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_stack.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+
+G_DEFINE_TYPE (SwfdecAsScriptFunction, swfdec_as_script_function, SWFDEC_TYPE_AS_FUNCTION)
+
+static SwfdecAsFrame *
+swfdec_as_script_function_call (SwfdecAsFunction *function)
+{
+ SwfdecAsScriptFunction *script = SWFDEC_AS_SCRIPT_FUNCTION (function);
+ SwfdecAsFrame *frame;
+
+ frame = swfdec_as_frame_new (SWFDEC_AS_OBJECT (function)->context, script->script);
+ if (frame == NULL)
+ return NULL;
+ frame->scope_chain = g_slist_concat (frame->scope_chain, g_slist_copy (script->scope_chain));
+ frame->function = function;
+ frame->target = script->target;
+ frame->original_target = script->target;
+ return frame;
+}
+
+static void
+swfdec_as_script_function_dispose (GObject *object)
+{
+ SwfdecAsScriptFunction *script = SWFDEC_AS_SCRIPT_FUNCTION (object);
+
+ if (script->script) {
+ swfdec_script_unref (script->script);
+ script->script = NULL;
+ }
+ g_slist_free (script->scope_chain);
+ script->scope_chain = NULL;
+
+ G_OBJECT_CLASS (swfdec_as_script_function_parent_class)->dispose (object);
+}
+
+static void
+swfdec_as_script_function_mark (SwfdecAsObject *object)
+{
+ SwfdecAsScriptFunction *script = SWFDEC_AS_SCRIPT_FUNCTION (object);
+
+ g_slist_foreach (script->scope_chain, (GFunc) swfdec_as_object_mark, NULL);
+
+ SWFDEC_AS_OBJECT_CLASS (swfdec_as_script_function_parent_class)->mark (object);
+}
+
+static char *
+swfdec_as_script_function_debug (SwfdecAsObject *object)
+{
+ SwfdecAsScriptFunction *script = SWFDEC_AS_SCRIPT_FUNCTION (object);
+ SwfdecScript *s = script->script;
+ GString *string;
+ guint i;
+
+ string = g_string_new (s->name);
+ g_string_append (string, " (");
+ for (i = 0; i < s->n_arguments; i++) {
+ if (i > 0)
+ g_string_append (string, ", ");
+ g_string_append (string, s->arguments[i].name);
+ }
+ g_string_append (string, ")");
+
+ return g_string_free (string, FALSE);
+}
+
+static void
+swfdec_as_script_function_class_init (SwfdecAsScriptFunctionClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
+ SwfdecAsFunctionClass *function_class = SWFDEC_AS_FUNCTION_CLASS (klass);
+
+ object_class->dispose = swfdec_as_script_function_dispose;
+
+ asobject_class->mark = swfdec_as_script_function_mark;
+ asobject_class->debug = swfdec_as_script_function_debug;
+
+ function_class->call = swfdec_as_script_function_call;
+}
+
+static void
+swfdec_as_script_function_init (SwfdecAsScriptFunction *script_function)
+{
+}
+
+SwfdecAsFunction *
+swfdec_as_script_function_new (SwfdecAsObject *target, const GSList *scope_chain, SwfdecScript *script)
+{
+ SwfdecAsValue val;
+ SwfdecAsScriptFunction *fun;
+ SwfdecAsObject *proto;
+ SwfdecAsContext *context;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (target), NULL);
+ g_return_val_if_fail (script != NULL, NULL);
+
+ context = target->context;
+ if (!swfdec_as_context_use_mem (context, sizeof (SwfdecAsScriptFunction)))
+ return NULL;
+ fun = g_object_new (SWFDEC_TYPE_AS_SCRIPT_FUNCTION, NULL);
+ if (fun == NULL)
+ return NULL;
+ fun->scope_chain = g_slist_copy ((GSList *) scope_chain);
+ fun->script = script;
+ fun->target = target;
+ swfdec_as_object_add (SWFDEC_AS_OBJECT (fun), context, sizeof (SwfdecAsScriptFunction));
+ /* set prototype */
+ proto = swfdec_as_object_new_empty (context);
+ if (proto == NULL)
+ return NULL;
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
+ swfdec_as_object_set_variable_and_flags (SWFDEC_AS_OBJECT (fun),
+ SWFDEC_AS_STR_prototype, &val,
+ SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+ swfdec_as_function_set_constructor (SWFDEC_AS_FUNCTION (fun));
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (fun));
+ swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object_prototype);
+ swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR___proto__,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+
+ return SWFDEC_AS_FUNCTION (fun);
+}
+
diff --git a/swfdec/swfdec_as_script_function.h b/swfdec/swfdec_as_script_function.h
new file mode 100644
index 0000000..1972e15
--- /dev/null
+++ b/swfdec/swfdec_as_script_function.h
@@ -0,0 +1,61 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_SCRIPT_FUNCTION_H_
+#define _SWFDEC_AS_SCRIPT_FUNCTION_H_
+
+#include <libswfdec/swfdec_as_function.h>
+#include <libswfdec/swfdec_as_types.h>
+#include <libswfdec/swfdec_script.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecAsScriptFunction SwfdecAsScriptFunction;
+typedef struct _SwfdecAsScriptFunctionClass SwfdecAsScriptFunctionClass;
+
+#define SWFDEC_TYPE_AS_SCRIPT_FUNCTION (swfdec_as_script_function_get_type())
+#define SWFDEC_IS_AS_SCRIPT_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_SCRIPT_FUNCTION))
+#define SWFDEC_IS_AS_SCRIPT_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_SCRIPT_FUNCTION))
+#define SWFDEC_AS_SCRIPT_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_SCRIPT_FUNCTION, SwfdecAsScriptFunction))
+#define SWFDEC_AS_SCRIPT_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_SCRIPT_FUNCTION, SwfdecAsScriptFunctionClass))
+#define SWFDEC_AS_SCRIPT_FUNCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_SCRIPT_FUNCTION, SwfdecAsScriptFunctionClass))
+
+/* FIXME: do two obejcts, one for scripts and one for native? */
+struct _SwfdecAsScriptFunction {
+ SwfdecAsFunction function;
+
+ /* for script script_functions */
+ SwfdecScript * script; /* script being executed or NULL when native */
+ GSList * scope_chain; /* scope this script_function was defined in */
+ SwfdecAsObject * target; /* target this object was defined in or NULL if in init script */
+};
+
+struct _SwfdecAsScriptFunctionClass {
+ SwfdecAsFunctionClass function_class;
+};
+
+GType swfdec_as_script_function_get_type (void);
+
+SwfdecAsFunction * swfdec_as_script_function_new (SwfdecAsObject * target,
+ const GSList * scope_chain,
+ SwfdecScript * script);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_as_stack.c b/swfdec/swfdec_as_stack.c
new file mode 100644
index 0000000..f86e1e0
--- /dev/null
+++ b/swfdec/swfdec_as_stack.c
@@ -0,0 +1,200 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include "swfdec_as_stack.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_frame_internal.h"
+#include "swfdec_debug.h"
+
+/* FIXME: make this configurable? */
+#define SWFDEC_AS_STACK_SIZE 8192 /* random big number */
+
+/* minimum number of elements that need to stay free that makes us remove a stack segment */
+#define SWFDEC_AS_STACK_LEFTOVER 16
+
+static SwfdecAsStack *
+swfdec_as_stack_new (SwfdecAsContext *context, guint n_elements)
+{
+ gsize size;
+ SwfdecAsStack *stack;
+
+ size = sizeof (SwfdecAsStack) + n_elements * sizeof (SwfdecAsValue);
+ if (!swfdec_as_context_use_mem (context, size))
+ return NULL;
+
+ stack = g_slice_alloc (size);
+ stack->n_elements = n_elements;
+ stack->used_elements = 0;
+ stack->next = NULL;
+ return stack;
+}
+
+static void
+swfdec_as_stack_set (SwfdecAsContext *context, SwfdecAsStack *stack)
+{
+ context->stack = stack;
+ context->base = &stack->elements[0];
+ context->cur = context->base + stack->used_elements;
+ context->end = context->base + SWFDEC_AS_STACK_SIZE;
+}
+
+gboolean
+swfdec_as_stack_push_segment (SwfdecAsContext *context)
+{
+ SwfdecAsStack *stack;
+
+ /* finish current stack */
+ if (context->stack) {
+ context->stack->used_elements = context->cur - context->base;
+ g_assert (context->stack->used_elements <= context->stack->n_elements);
+ }
+
+ stack = swfdec_as_stack_new (context, SWFDEC_AS_STACK_SIZE);
+ if (stack == NULL)
+ return FALSE;
+ SWFDEC_DEBUG ("pushing new stack segment %p", stack);
+ stack->next = context->stack;
+ swfdec_as_stack_set (context, stack);
+ return TRUE;
+}
+
+static void
+swfdec_as_stack_free (SwfdecAsContext *context, SwfdecAsStack *stack)
+{
+ gsize size;
+
+ size = sizeof (SwfdecAsStack) + stack->n_elements * sizeof (SwfdecAsValue);
+ swfdec_as_context_unuse_mem (context, size);
+ g_slice_free1 (size, stack);
+}
+
+void
+swfdec_as_stack_pop_segment (SwfdecAsContext *context)
+{
+ SwfdecAsStack *stack = context->stack;
+ if (stack->next) {
+ swfdec_as_stack_set (context, stack->next);
+ } else {
+ context->base = context->cur = context->end = NULL;
+ context->stack = NULL;
+ }
+ SWFDEC_DEBUG ("popping stack segment %p, next is %p", stack, context->stack);
+ swfdec_as_stack_free (context, stack);
+}
+
+void
+swfdec_as_stack_mark (SwfdecAsStack *stack)
+{
+ guint i;
+
+ for (i = 0; i < stack->used_elements; i++) {
+ swfdec_as_value_mark (&stack->elements[i]);
+ }
+ if (stack->next)
+ swfdec_as_stack_mark (stack->next);
+}
+
+void
+swfdec_as_stack_ensure_size (SwfdecAsContext *context, guint n_elements)
+{
+ guint current;
+ SwfdecAsStack *next;
+
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
+ g_return_if_fail (n_elements < SWFDEC_AS_STACK_SIZE / 2);
+
+ current = (guint) (context->cur - context->base);
+ if (G_LIKELY (current >= n_elements))
+ return;
+ next = context->stack->next;
+ /* check if we can move this to the last stack */
+ if (next && context->base != context->frame->stack_begin &&
+ (next->n_elements - next->used_elements > SWFDEC_AS_STACK_LEFTOVER + current)) {
+ memmove (&next->elements[next->used_elements], context->base, current * sizeof (SwfdecAsValue));
+ next->used_elements += current;
+ swfdec_as_stack_pop_segment (context);
+ return;
+ }
+ if (current) {
+ n_elements -= current;
+ memmove (context->base + n_elements, context->base, current * sizeof (SwfdecAsValue));
+ }
+ context->cur += n_elements;
+ if (n_elements) {
+ if (next && context->base != context->frame->stack_begin) {
+ /* this should be true by a huge amount */
+ g_assert (next->used_elements >= n_elements);
+ if (context->frame->stack_begin <= &next->elements[next->used_elements] &&
+ context->frame->stack_begin >= &next->elements[0]) {
+ current = &next->elements[next->used_elements] - context->frame->stack_begin;
+ current = MIN (n_elements, current);
+ } else {
+ current = n_elements;
+ }
+ next->used_elements -= current;
+ n_elements -= current;
+ memmove (context->base + n_elements, &next->elements[next->used_elements], current * sizeof (SwfdecAsValue));
+ }
+ if (n_elements) {
+ memset (context->base, 0, n_elements * sizeof (SwfdecAsValue));
+ }
+ }
+}
+
+void
+swfdec_as_stack_ensure_free (SwfdecAsContext *context, guint n_elements)
+{
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
+ g_return_if_fail (n_elements < SWFDEC_AS_STACK_SIZE / 2);
+
+ if (G_LIKELY ((guint) (context->end - context->cur) >= n_elements))
+ return;
+
+ if (!swfdec_as_stack_push_segment (context))
+ context->cur = context->end - n_elements;
+}
+
+guint
+swfdec_as_stack_get_size (SwfdecAsContext *context)
+{
+ SwfdecAsStack *stack;
+ SwfdecAsValue *target;
+ guint ret;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), 0);
+
+ if (context->frame == NULL)
+ return 0;
+ target = context->frame->stack_begin;
+ if (target == context->base)
+ return context->cur - context->base;
+ stack = context->stack->next;
+ ret = context->cur - context->base;
+ while (target < &stack->elements[0] && target > &stack->elements[stack->used_elements]) {
+ ret += stack->n_elements;
+ stack = stack->next;
+ }
+ ret += &stack->elements[stack->used_elements] - target;
+ return ret;
+}
diff --git a/swfdec/swfdec_as_stack.h b/swfdec/swfdec_as_stack.h
new file mode 100644
index 0000000..26e66ea
--- /dev/null
+++ b/swfdec/swfdec_as_stack.h
@@ -0,0 +1,101 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_STACK_H_
+#define _SWFDEC_AS_STACK_H_
+
+#include <libswfdec/swfdec_as_types.h>
+
+G_BEGIN_DECLS
+
+struct _SwfdecAsStack {
+ guint n_elements; /* number of elements */
+ guint used_elements; /* elements in use (only set on stored stack) */
+ SwfdecAsStack * next; /* pointer to next stack */
+ SwfdecAsValue elements[0]; /* the elements */
+};
+
+gboolean swfdec_as_stack_push_segment (SwfdecAsContext * context);
+void swfdec_as_stack_pop_segment (SwfdecAsContext * context);
+
+//#define SWFDEC_MAD_CHECKS
+#ifdef SWFDEC_MAD_CHECKS
+#include <libswfdec/swfdec_as_context.h>
+static inline SwfdecAsValue *
+swfdec_as_stack_peek (SwfdecAsContext *cx, guint n)
+{
+ g_assert (cx != NULL);
+ g_assert (n > 0);
+ g_assert (cx->cur - n >= cx->base);
+
+ return &(cx)->cur[-(gssize)(n)];
+}
+
+static inline SwfdecAsValue *
+swfdec_as_stack_pop (SwfdecAsContext *cx)
+{
+ g_assert (cx != NULL);
+ g_assert (cx->cur > cx->base);
+
+ return --cx->cur;
+}
+
+static inline SwfdecAsValue *
+swfdec_as_stack_pop_n (SwfdecAsContext *cx, guint n)
+{
+ g_assert (cx != NULL);
+ g_assert ((guint) (cx->cur - cx->base) >= n);
+
+ return cx->cur -= n;
+}
+
+static inline SwfdecAsValue *
+swfdec_as_stack_push (SwfdecAsContext *cx)
+{
+ g_assert (cx != NULL);
+ g_assert (cx->cur < cx->end);
+
+ cx->cur->type = SWFDEC_AS_TYPE_OBJECT + 1;
+ return cx->cur++;
+}
+#else /* SWFDEC_MAD_CHECKS */
+#define swfdec_as_stack_peek(cx,n) (&(cx)->cur[-(gssize)(n)])
+#define swfdec_as_stack_pop(cx) (--(cx)->cur)
+#define swfdec_as_stack_pop_n(cx, n) ((cx)->cur -= (n))
+#define swfdec_as_stack_push(cx) ((cx)->cur++)
+#endif
+#define swfdec_as_stack_swap(cx,x,y) G_STMT_START { \
+ SwfdecAsContext *__cx = (cx); \
+ SwfdecAsValue __tmp; \
+ guint __x = (x), __y = (y); \
+ __tmp = *swfdec_as_stack_peek(__cx, __x); \
+ *swfdec_as_stack_peek(__cx, __x) = *swfdec_as_stack_peek(__cx, __y); \
+ *swfdec_as_stack_peek(__cx, __y) = __tmp; \
+}G_STMT_END
+
+void swfdec_as_stack_mark (SwfdecAsStack * stack);
+void swfdec_as_stack_ensure_size (SwfdecAsContext * context,
+ guint n_elements);
+void swfdec_as_stack_ensure_free (SwfdecAsContext * context,
+ guint n_elements);
+guint swfdec_as_stack_get_size (SwfdecAsContext * context);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_as_string.c b/swfdec/swfdec_as_string.c
new file mode 100644
index 0000000..69f5719
--- /dev/null
+++ b/swfdec/swfdec_as_string.c
@@ -0,0 +1,914 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+#include <string.h>
+
+#include "swfdec_as_string.h"
+#include "swfdec_as_array.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+
+G_DEFINE_TYPE (SwfdecAsString, swfdec_as_string, SWFDEC_TYPE_AS_OBJECT)
+
+static void
+swfdec_as_string_do_mark (SwfdecAsObject *object)
+{
+ SwfdecAsString *string = SWFDEC_AS_STRING (object);
+
+ swfdec_as_string_mark (string->string);
+
+ SWFDEC_AS_OBJECT_CLASS (swfdec_as_string_parent_class)->mark (object);
+}
+
+static char *
+swfdec_as_string_debug (SwfdecAsObject *object)
+{
+ SwfdecAsString *string = SWFDEC_AS_STRING (object);
+
+ return g_strdup (string->string);
+}
+
+static void
+swfdec_as_string_class_init (SwfdecAsStringClass *klass)
+{
+ SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
+
+ asobject_class->mark = swfdec_as_string_do_mark;
+ asobject_class->debug = swfdec_as_string_debug;
+}
+
+static void
+swfdec_as_string_init (SwfdecAsString *string)
+{
+ string->string = SWFDEC_AS_STR_EMPTY;
+}
+
+/*** AS CODE ***/
+
+static const char *
+swfdec_as_string_object_to_string (SwfdecAsContext *context,
+ SwfdecAsObject *object)
+{
+ SwfdecAsValue val;
+
+ g_return_val_if_fail (object == NULL || SWFDEC_IS_AS_OBJECT (object),
+ SWFDEC_AS_STR_EMPTY);
+
+ if (object == NULL) {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (&val);
+ } else {
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, object);
+ }
+
+ return swfdec_as_value_to_string (context, &val);
+}
+
+static inline const char *
+swfdec_as_str_nth_char (const char *s, guint n)
+{
+ while (*s && n--)
+ s = g_utf8_next_char (s);
+ return s;
+}
+
+SWFDEC_AS_NATIVE (251, 9, swfdec_as_string_lastIndexOf)
+void
+swfdec_as_string_lastIndexOf (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *string = swfdec_as_string_object_to_string (cx, object);
+ gsize len;
+ const char *s;
+
+ if (argc < 1)
+ return;
+
+ s = swfdec_as_value_to_string (cx, &argv[0]);
+ if (argc == 2) {
+ int offset = swfdec_as_value_to_integer (cx, &argv[1]);
+ if (offset < 0) {
+ SWFDEC_AS_VALUE_SET_INT (ret, -1);
+ return;
+ }
+ len = g_utf8_offset_to_pointer (string, offset + 1) - string;
+ } else {
+ len = G_MAXSIZE;
+ }
+ s = g_strrstr_len (string, len, s);
+ if (s) {
+ SWFDEC_AS_VALUE_SET_INT (ret, g_utf8_pointer_to_offset (string, s));
+ } else {
+ SWFDEC_AS_VALUE_SET_INT (ret, -1);
+ }
+}
+
+SWFDEC_AS_NATIVE (251, 8, swfdec_as_string_indexOf)
+void
+swfdec_as_string_indexOf (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *string = swfdec_as_string_object_to_string (cx, object);
+ int offset=0, len, i=-1;
+ const char *s, *t = NULL;
+
+ if (argc < 1)
+ return;
+
+ s = swfdec_as_value_to_string (cx, &argv[0]);
+ if (argc == 2)
+ offset = swfdec_as_value_to_integer (cx, &argv[1]);
+ if (offset < 0)
+ offset = 0;
+ len = g_utf8_strlen (string, -1);
+ if (offset < len) {
+ t = strstr (g_utf8_offset_to_pointer (string, offset), s);
+ }
+ if (t != NULL) {
+ i = g_utf8_pointer_to_offset (string, t);
+ }
+
+ SWFDEC_AS_VALUE_SET_INT (ret, i);
+}
+
+SWFDEC_AS_NATIVE (251, 5, swfdec_as_string_charAt)
+void
+swfdec_as_string_charAt (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *string = swfdec_as_string_object_to_string (cx, object);
+ int i;
+ const char *s, *t;
+
+ if (argc < 1)
+ return;
+
+ i = swfdec_as_value_to_integer (cx, &argv[0]);
+ if (i < 0) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_EMPTY);
+ return;
+ }
+ s = swfdec_as_str_nth_char (string, i);
+ if (*s == 0) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_EMPTY);
+ return;
+ }
+ t = g_utf8_next_char (s);
+ s = swfdec_as_context_give_string (cx, g_strndup (s, t - s));
+ SWFDEC_AS_VALUE_SET_STRING (ret, s);
+}
+
+SWFDEC_AS_NATIVE (251, 6, swfdec_as_string_charCodeAt)
+void
+swfdec_as_string_charCodeAt (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *string = swfdec_as_string_object_to_string (cx, object);
+ int i;
+ const char *s;
+ gunichar c;
+
+ if (argc < 1)
+ return;
+
+ i = swfdec_as_value_to_integer (cx, &argv[0]);
+ if (i < 0) {
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, NAN);
+ return;
+ }
+ s = swfdec_as_str_nth_char (string, i);
+ if (*s == 0) {
+ if (cx->version > 5) {
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, NAN);
+ } else {
+ SWFDEC_AS_VALUE_SET_INT (ret, 0);
+ }
+ return;
+ }
+ c = g_utf8_get_char (s);
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, c);
+}
+
+static void
+swfdec_as_string_fromCharCode_5 (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ guint i, c;
+ guint8 append;
+ GError *error = NULL;
+ char *s;
+ GByteArray *array = g_byte_array_new ();
+
+ if (argc > 0) {
+ for (i = 0; i < argc; i++) {
+ c = ((guint) swfdec_as_value_to_integer (cx, &argv[i])) % 65536;
+ if (c > 255) {
+ append = c / 256;
+ g_byte_array_append (array, &append, 1);
+ }
+ append = c;
+ g_byte_array_append (array, &append, 1);
+ }
+
+ /* FIXME: are these the correct charset names? */
+ s = g_convert ((char *) array->data, array->len, "UTF-8", "LATIN1", NULL, NULL, &error);
+ } else{
+ s = g_strdup ("");
+ }
+
+ if (s) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (cx, s));
+ g_free (s);
+ } else {
+ SWFDEC_ERROR ("%s", error->message);
+ g_error_free (error);
+ }
+ g_byte_array_free (array, TRUE);
+}
+
+static void
+swfdec_as_string_fromCharCode_6 (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ gunichar tmp[8];
+ gunichar *chars;
+ guint i;
+ char *s;
+ GError *error = NULL;
+
+ if (argc <= 8)
+ chars = tmp;
+ else
+ chars = g_new (gunichar, argc);
+
+ for (i = 0; i < argc; i++) {
+ chars[i] = ((guint) swfdec_as_value_to_integer (cx, &argv[i])) % 65536;
+ }
+
+ s = g_ucs4_to_utf8 (chars, argc, NULL, NULL, &error);
+ if (s) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (cx, s));
+ g_free (s);
+ } else {
+ SWFDEC_ERROR ("%s", error->message);
+ g_error_free (error);
+ }
+
+ if (chars != tmp)
+ g_free (chars);
+}
+
+SWFDEC_AS_NATIVE (251, 14, swfdec_as_string_fromCharCode)
+void
+swfdec_as_string_fromCharCode (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (cx->version <= 5) {
+ swfdec_as_string_fromCharCode_5 (cx, object, argc, argv, ret);
+ } else {
+ swfdec_as_string_fromCharCode_6 (cx, object, argc, argv, ret);
+ }
+}
+
+SWFDEC_AS_CONSTRUCTOR (251, 0, swfdec_as_string_construct, swfdec_as_string_get_type)
+void
+swfdec_as_string_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *s;
+
+ if (argc > 0) {
+ s = swfdec_as_value_to_string (cx, &argv[0]);
+ } else {
+ s = SWFDEC_AS_STR_EMPTY;
+ }
+
+ if (swfdec_as_context_is_constructing (cx)) {
+ SwfdecAsString *string = SWFDEC_AS_STRING (object);
+ SwfdecAsValue val;
+
+ string->string = s;
+ SWFDEC_AS_VALUE_SET_INT (&val, g_utf8_strlen (string->string, -1));
+ swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR_length,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
+ } else {
+ SWFDEC_AS_VALUE_SET_STRING (ret, s);
+ }
+}
+
+SWFDEC_AS_NATIVE (251, 2, swfdec_as_string_toString)
+void
+swfdec_as_string_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_AS_STRING (object))
+ return;
+
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STRING (object)->string);
+}
+
+SWFDEC_AS_NATIVE (251, 1, swfdec_as_string_valueOf)
+void
+swfdec_as_string_valueOf (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_AS_STRING (object))
+ return;
+
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STRING (object)->string);
+}
+
+#if 0
+charAt(index:Number) : String
+charCodeAt(index:Number) : Number
+concat(value:Object) : String
+indexOf(value:String, [startIndex:Number]) : Number
+slice(start:Number, end:Number) : String
+split(delimiter:String, [limit:Number]) : Array
+#endif
+
+static void
+swfdec_as_string_split_5 (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecAsArray *arr;
+ SwfdecAsValue val;
+ const char *str, *end, *delim;
+ int count;
+
+ if (argc < 1)
+ return;
+
+ str = swfdec_as_string_object_to_string (cx, object);
+ arr = SWFDEC_AS_ARRAY (swfdec_as_array_new (cx));
+ if (arr == NULL)
+ return;
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (arr));
+ /* hi, i'm the special case */
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0])) {
+ delim = SWFDEC_AS_STR_COMMA;
+ } else {
+ delim = swfdec_as_value_to_string (cx, &argv[0]);
+ }
+ if (delim == SWFDEC_AS_STR_EMPTY) {
+ SWFDEC_AS_VALUE_SET_STRING (&val, str);
+ swfdec_as_array_push (arr, &val);
+ return;
+ }
+ if (argc > 1) {
+ swfdec_as_value_to_string (cx, &argv[0]);
+ count = swfdec_as_value_to_integer (cx, &argv[1]);
+ } else {
+ count = G_MAXINT;
+ }
+ if (count <= 0)
+ return;
+ if (str == SWFDEC_AS_STR_EMPTY || delim[1] != 0) {
+ SWFDEC_AS_VALUE_SET_STRING (&val, str);
+ swfdec_as_array_push (arr, &val);
+ return;
+ }
+ while (count > 0) {
+ end = strchr (str, delim[0]);
+ if (end == NULL) {
+ SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_get_string (cx, str));
+ swfdec_as_array_push (arr, &val);
+ break;
+ }
+ SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_give_string (cx, g_strndup (str, end - str)));
+ swfdec_as_array_push (arr, &val);
+ if (count)
+ count--;
+ str = end + 1;
+ }
+}
+
+static void
+swfdec_as_string_split_6 (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecAsArray *arr;
+ SwfdecAsValue val;
+ const char *str, *end, *delim;
+ int count;
+ guint len;
+
+ if (argc < 1)
+ return;
+
+ str = swfdec_as_string_object_to_string (cx, object);
+ arr = SWFDEC_AS_ARRAY (swfdec_as_array_new (cx));
+ if (arr == NULL)
+ return;
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (arr));
+ /* hi, i'm the special case */
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0])) {
+ SWFDEC_AS_VALUE_SET_STRING (&val, str);
+ swfdec_as_array_push (arr, &val);
+ return;
+ }
+ delim = swfdec_as_value_to_string (cx, &argv[0]);
+ if (str == SWFDEC_AS_STR_EMPTY) {
+ SWFDEC_AS_VALUE_SET_STRING (&val, str);
+ swfdec_as_array_push (arr, &val);
+ return;
+ }
+ if (argc > 1)
+ count = swfdec_as_value_to_integer (cx, &argv[1]);
+ else
+ count = G_MAXINT;
+ if (count <= 0)
+ return;
+ len = strlen (delim);
+ while (count > 0) {
+ if (delim == SWFDEC_AS_STR_EMPTY) {
+ if (*str)
+ end = str + 1;
+ else
+ break;
+ } else {
+ end = strstr (str, delim);
+ if (end == NULL) {
+ SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_get_string (cx, str));
+ swfdec_as_array_push (arr, &val);
+ break;
+ }
+ }
+ SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_give_string (cx, g_strndup (str, end - str)));
+ swfdec_as_array_push (arr, &val);
+ if (count)
+ count--;
+ str = end + len;
+ }
+}
+
+SWFDEC_AS_NATIVE (251, 12, swfdec_as_string_split)
+void
+swfdec_as_string_split (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (cx->version <= 5) {
+ swfdec_as_string_split_5 (cx, object, argc, argv, ret);
+ } else {
+ swfdec_as_string_split_6 (cx, object, argc, argv, ret);
+ }
+}
+
+SWFDEC_AS_NATIVE (251, 10, swfdec_as_string_slice)
+void
+swfdec_as_string_slice (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ int start, end, length;
+ const char *str;
+
+ if (argc == 0)
+ return;
+
+ str = swfdec_as_string_object_to_string (cx, object);
+ length = strlen (str);
+
+ start = swfdec_as_value_to_integer (cx, &argv[0]);
+ if (start < 0)
+ start += length;
+ start = CLAMP (start, 0, length);
+
+ if (argc > 1) {
+ end = swfdec_as_value_to_integer (cx, &argv[1]);
+ if (end < 0)
+ end += length;
+ end = CLAMP (end, start, length);
+ } else {
+ end = length;
+ }
+
+ SWFDEC_AS_VALUE_SET_STRING (ret,
+ swfdec_as_context_give_string (cx, g_strndup (str + start, end - start)));
+}
+
+SWFDEC_AS_NATIVE (251, 7, swfdec_as_string_concat)
+void
+swfdec_as_string_concat (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ guint i;
+ GString *string;
+
+ string = g_string_new (swfdec_as_string_object_to_string (cx, object));
+
+ for (i = 0; i < argc; i++) {
+ string = g_string_append (string, swfdec_as_value_to_string (cx, &argv[i]));
+ }
+
+ SWFDEC_AS_VALUE_SET_STRING (ret,
+ swfdec_as_context_give_string (cx, g_string_free (string, FALSE)));
+}
+
+const char *
+swfdec_as_str_sub (SwfdecAsContext *cx, const char *str, guint offset, guint len)
+{
+ const char *end;
+
+ str = g_utf8_offset_to_pointer (str, offset);
+ end = g_utf8_offset_to_pointer (str, len);
+ str = swfdec_as_context_give_string (cx, g_strndup (str, end - str));
+ return str;
+}
+
+SWFDEC_AS_NATIVE (251, 13, swfdec_as_string_substr)
+void
+swfdec_as_string_substr (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *string = swfdec_as_string_object_to_string (cx, object);
+ int from, to, len;
+
+ if (argc < 1)
+ return;
+
+ from = swfdec_as_value_to_integer (cx, &argv[0]);
+ len = g_utf8_strlen (string, -1);
+
+ if (argc > 1 && !SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[1])) {
+ to = swfdec_as_value_to_integer (cx, &argv[1]);
+ /* FIXME: wtf? */
+ if (to < 0) {
+ if (-to <= from)
+ to = 0;
+ else
+ to += len;
+ if (to < 0)
+ to = 0;
+ if (from < 0 && to >= -from)
+ to = 0;
+ }
+ } else {
+ to = G_MAXINT;
+ }
+ if (from < 0)
+ from += len;
+ from = CLAMP (from, 0, len);
+ to = CLAMP (to, 0, len - from);
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_str_sub (cx, string, from, to));
+}
+
+SWFDEC_AS_NATIVE (251, 11, swfdec_as_string_substring)
+void
+swfdec_as_string_substring (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *string = swfdec_as_string_object_to_string (cx, object);
+ int from, to, len;
+
+ if (argc < 1)
+ return;
+
+ len = g_utf8_strlen (string, -1);
+ from = swfdec_as_value_to_integer (cx, &argv[0]);
+ if (argc > 1 && !SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[1])) {
+ to = swfdec_as_value_to_integer (cx, &argv[1]);
+ } else {
+ to = len;
+ }
+ from = MAX (from, 0);
+ if (from >= len) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_EMPTY);
+ return;
+ }
+ to = CLAMP (to, 0, len);
+ if (to < from) {
+ int tmp = to;
+ to = from;
+ from = tmp;
+ }
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_str_sub (cx, string, from, to - from));
+}
+
+SWFDEC_AS_NATIVE (251, 4, swfdec_as_string_toLowerCase)
+void
+swfdec_as_string_toLowerCase (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *string = swfdec_as_string_object_to_string (cx, object);
+ char *s;
+
+ s = g_utf8_strdown (string, -1);
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, s));
+}
+
+SWFDEC_AS_NATIVE (251, 3, swfdec_as_string_toUpperCase)
+void
+swfdec_as_string_toUpperCase (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *string = swfdec_as_string_object_to_string (cx, object);
+ char *s;
+
+ s = g_utf8_strup (string, -1);
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, s));
+}
+
+// only available as ASnative
+SWFDEC_AS_NATIVE (102, 1, swfdec_as_string_old_toLowerCase)
+void
+swfdec_as_string_old_toLowerCase (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *string = swfdec_as_string_object_to_string (cx, object);
+ char *s;
+
+ s = g_ascii_strdown (string, -1);
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, s));
+}
+
+// only available as ASnative
+SWFDEC_AS_NATIVE (102, 0, swfdec_as_string_old_toUpperCase)
+void
+swfdec_as_string_old_toUpperCase (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *string = swfdec_as_string_object_to_string (cx, object);
+ char *s;
+
+ s = g_ascii_strup (string, -1);
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, s));
+}
+
+/* escape and unescape are implemented here so the mad string functions share the same place */
+
+static char *
+swfdec_as_string_unescape_5 (SwfdecAsContext *cx, const char *msg)
+{
+ GByteArray *array;
+ char cur = 0; /* currently decoded character */
+ char *out, *in, *s;
+ guint decoding = 0; /* set if we're decoding a %XY string */
+
+/* attention: c is a char* */
+#define APPEND(chr) G_STMT_START{ \
+ g_byte_array_append (array, (guchar *) chr, 1); \
+}G_STMT_END
+ in = s = g_convert (msg, -1, "LATIN1", "UTF-8", NULL, NULL, NULL);
+ if (s == NULL) {
+ SWFDEC_FIXME ("%s can not be converted to utf8 - is this Flash 5 or what?", msg);
+ return NULL;
+ }
+ array = g_byte_array_new ();
+ while (*s != 0) {
+ if (decoding) {
+ decoding++;
+ if (*s >= '0' && *s <= '9') {
+ cur = cur * 16 + *s - '0';
+ } else if (*s >= 'A' && *s <= 'F') {
+ cur = cur * 16 + *s - 'A' + 10;
+ } else if (*s >= 'a' && *s <= 'f') {
+ cur = cur * 16 + *s - 'a' + 10;
+ } else {
+ cur = 0;
+ decoding = 0;
+ }
+ if (decoding == 3) {
+ APPEND (&cur);
+ cur = 0;
+ decoding = 0;
+ }
+ } else if (*s == '%') {
+ decoding = 1;
+ } else if (*s == '+') {
+ char tmp = ' ';
+ APPEND (&tmp);
+ } else {
+ APPEND (s);
+ }
+ s++;
+ }
+ g_free (in);
+ if (array->len == 0) {
+ g_byte_array_free (array, TRUE);
+ return NULL;
+ }
+ cur = 0;
+ g_byte_array_append (array, (guchar *) &cur, 1);
+ out = g_convert ((char *) array->data, -1, "UTF-8", "LATIN1", NULL, NULL, NULL);
+ g_byte_array_free (array, TRUE);
+ if (out) {
+ return out;
+ } else {
+ g_warning ("can't convert %s to UTF-8", msg);
+ g_free (out);
+ return g_strdup ("");
+ }
+#undef APPEND
+}
+
+char *
+swfdec_as_string_escape (SwfdecAsContext *cx, const char *s)
+{
+ GByteArray *array;
+ char *in = NULL;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (cx), NULL);
+ g_return_val_if_fail (s != NULL, NULL);
+
+ array = g_byte_array_new ();
+ if (cx->version <= 5) {
+ in = g_convert (s, -1, "LATIN1", "UTF-8", NULL, NULL, NULL);
+ if (s == NULL) {
+ SWFDEC_FIXME ("%s can not be converted to utf8 - is this Flash 5 or what?", s);
+ return NULL;
+ } else {
+ s = in;
+ }
+ }
+ while (*s) {
+ if ((*s >= '0' && *s <= '9') ||
+ (*s >= 'A' && *s <= 'Z') ||
+ (*s >= 'a' && *s <= 'z')) {
+ g_byte_array_append (array, (guchar *) s, 1);
+ } else {
+ guchar add[3] = { '%', 0, 0 };
+ add[1] = (guchar) *s / 16;
+ add[2] = (guchar) *s % 16;
+ add[1] += add[1] < 10 ? '0' : ('A' - 10);
+ add[2] += add[2] < 10 ? '0' : ('A' - 10);
+ g_byte_array_append (array, add, 3);
+ }
+ s++;
+ }
+ g_byte_array_append (array, (guchar *) s, 1);
+ g_free (in);
+ return (char *) g_byte_array_free (array, FALSE);
+}
+
+SWFDEC_AS_NATIVE (100, 0, swfdec_as_string_escape_internal)
+void
+swfdec_as_string_escape_internal (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *s;
+ char *result;
+
+ SWFDEC_AS_CHECK (0, NULL, "s", &s);
+
+ result = swfdec_as_string_escape (cx, s);
+ if (result != NULL) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (cx, result));
+ g_free (result);
+ } else {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (ret);
+ }
+}
+
+static char *
+swfdec_as_string_unescape_6 (SwfdecAsContext *cx, const char *s)
+{
+ GByteArray *array;
+ const char *msg;
+ char cur = 0; /* currently decoded character */
+ guint decoding = 0; /* set if we're decoding a %XY string */
+ guint utf8left = 0; /* how many valid utf8 chars are still required */
+ const guchar invalid[3] = { 0xEF, 0xBF, 0xBD };
+
+/* attention: c is a char* */
+#define APPEND(chr) G_STMT_START{ \
+ guchar c = *chr; \
+ if (utf8left) { \
+ if ((c & 0xC0) == 0x80) { \
+ g_byte_array_append (array, &c, 1); \
+ utf8left--; \
+ } else { \
+ guint __len = array->len - 1; \
+ while ((array->data[__len] & 0xC0) != 0xC0) \
+ __len--; \
+ g_byte_array_set_size (array, __len); \
+ g_byte_array_append (array, invalid, 3); \
+ utf8left = 0; \
+ } \
+ } else { \
+ if (c < 0x80) { \
+ g_byte_array_append (array, &c, 1); \
+ } else if (c < 0xC0) { \
+ guchar __foo = 0xC2; \
+ g_byte_array_append (array, &__foo, 1); \
+ g_byte_array_append (array, &c, 1); \
+ } else if (c > 0xF7) { \
+ break; \
+ } else { \
+ g_byte_array_append (array, &c, 1); \
+ utf8left = (c < 0xE0) ? 1 : ((c < 0xF0) ? 2 : 3); \
+ } \
+ } \
+}G_STMT_END
+ array = g_byte_array_new ();
+ msg = s;
+ while (*s != 0) {
+ if (decoding) {
+ decoding++;
+ if (*s >= '0' && *s <= '9') {
+ cur = cur * 16 + *s - '0';
+ } else if (*s >= 'A' && *s <= 'F') {
+ cur = cur * 16 + *s - 'A' + 10;
+ } else if (*s >= 'a' && *s <= 'f') {
+ cur = cur * 16 + *s - 'a' + 10;
+ } else {
+ cur = 0;
+ decoding = 0;
+ if ((guchar) *s > 0x7F) {
+ APPEND (s);
+ }
+ }
+ if (decoding == 3) {
+ APPEND (&cur);
+ cur = 0;
+ decoding = 0;
+ }
+ } else if (*s == '%') {
+ decoding = 1;
+ } else if (*s == '+') {
+ char tmp = ' ';
+ APPEND (&tmp);
+ } else {
+ APPEND (s);
+ }
+ s++;
+ }
+ cur = 0;
+ /* loop for break statement in APPEND macro */
+ if (utf8left) {
+ guint __len = array->len - 1;
+ while ((array->data[__len] & 0xC0) != 0xC0)
+ __len--;
+ g_byte_array_set_size (array, __len);
+ }
+ g_byte_array_append (array, (guchar *) &cur, 1);
+ if (g_utf8_validate ((char *) array->data, -1, NULL)) {
+ return (char *) g_byte_array_free (array, FALSE);
+ } else {
+ g_warning ("%s unescaped is invalid UTF-8", msg);
+ g_byte_array_free (array, TRUE);
+ return g_strdup ("");
+ }
+#undef APPEND
+}
+
+char *
+swfdec_as_string_unescape (SwfdecAsContext *context, const char *string)
+{
+ if (context->version < 6) {
+ return swfdec_as_string_unescape_5 (context, string);
+ } else {
+ return swfdec_as_string_unescape_6 (context, string);
+ }
+}
+
+SWFDEC_AS_NATIVE (100, 1, swfdec_as_string_unescape_internal)
+void
+swfdec_as_string_unescape_internal (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *s;
+ char *result;
+
+ SWFDEC_AS_CHECK (0, NULL, "s", &s);
+
+ result = swfdec_as_string_unescape (cx, s);
+ if (result != NULL) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (cx, result));
+ g_free (result);
+ } else {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (ret);
+ }
+}
+
+// only available as ASnative
+SWFDEC_AS_NATIVE (3, 0, swfdec_as_string_old_constructor)
+void
+swfdec_as_string_old_constructor (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("old 'String' function (only available as ASnative)");
+}
diff --git a/swfdec/swfdec_as_string.h b/swfdec/swfdec_as_string.h
new file mode 100644
index 0000000..c0cd621
--- /dev/null
+++ b/swfdec/swfdec_as_string.h
@@ -0,0 +1,62 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_STRING_H_
+#define _SWFDEC_AS_STRING_H_
+
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_as_types.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecAsString SwfdecAsString;
+typedef struct _SwfdecAsStringClass SwfdecAsStringClass;
+
+#define SWFDEC_TYPE_AS_STRING (swfdec_as_string_get_type())
+#define SWFDEC_IS_AS_STRING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_STRING))
+#define SWFDEC_IS_AS_STRING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_STRING))
+#define SWFDEC_AS_STRING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_STRING, SwfdecAsString))
+#define SWFDEC_AS_STRING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_STRING, SwfdecAsStringClass))
+#define SWFDEC_AS_STRING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_STRING, SwfdecAsStringClass))
+
+struct _SwfdecAsString {
+ SwfdecAsObject object;
+
+ const char * string; /* string represented by this string object */
+};
+
+struct _SwfdecAsStringClass {
+ SwfdecAsObjectClass object_class;
+};
+
+GType swfdec_as_string_get_type (void);
+
+const char * swfdec_as_str_sub (SwfdecAsContext * cx,
+ const char * str,
+ guint offset,
+ guint len);
+
+char * swfdec_as_string_escape (SwfdecAsContext * context,
+ const char * string);
+char * swfdec_as_string_unescape (SwfdecAsContext * context,
+ const char * string);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_as_strings.c b/swfdec/swfdec_as_strings.c
new file mode 100644
index 0000000..7f880aa
--- /dev/null
+++ b/swfdec/swfdec_as_strings.c
@@ -0,0 +1,491 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define SWFDEC_AS_CONSTANT_STRING(str) "\2" str "\0"
+const char swfdec_as_strings[] =
+ SWFDEC_AS_CONSTANT_STRING ("")
+ SWFDEC_AS_CONSTANT_STRING ("__proto__")
+ SWFDEC_AS_CONSTANT_STRING ("this")
+ SWFDEC_AS_CONSTANT_STRING ("code")
+ SWFDEC_AS_CONSTANT_STRING ("level")
+ SWFDEC_AS_CONSTANT_STRING ("description")
+ SWFDEC_AS_CONSTANT_STRING ("status")
+ SWFDEC_AS_CONSTANT_STRING ("NetConnection.Connect.Success")
+ SWFDEC_AS_CONSTANT_STRING ("onLoad")
+ SWFDEC_AS_CONSTANT_STRING ("onEnterFrame")
+ SWFDEC_AS_CONSTANT_STRING ("onUnload")
+ SWFDEC_AS_CONSTANT_STRING ("onMouseMove")
+ SWFDEC_AS_CONSTANT_STRING ("onMouseDown")
+ SWFDEC_AS_CONSTANT_STRING ("onMouseUp")
+ SWFDEC_AS_CONSTANT_STRING ("onKeyUp")
+ SWFDEC_AS_CONSTANT_STRING ("onKeyDown")
+ SWFDEC_AS_CONSTANT_STRING ("onData")
+ SWFDEC_AS_CONSTANT_STRING ("onPress")
+ SWFDEC_AS_CONSTANT_STRING ("onRelease")
+ SWFDEC_AS_CONSTANT_STRING ("onReleaseOutside")
+ SWFDEC_AS_CONSTANT_STRING ("onRollOver")
+ SWFDEC_AS_CONSTANT_STRING ("onRollOut")
+ SWFDEC_AS_CONSTANT_STRING ("onDragOver")
+ SWFDEC_AS_CONSTANT_STRING ("onDragOut")
+ SWFDEC_AS_CONSTANT_STRING ("onConstruct")
+ SWFDEC_AS_CONSTANT_STRING ("onStatus")
+ SWFDEC_AS_CONSTANT_STRING ("error")
+ SWFDEC_AS_CONSTANT_STRING ("NetStream.Buffer.Empty")
+ SWFDEC_AS_CONSTANT_STRING ("NetStream.Buffer.Full")
+ SWFDEC_AS_CONSTANT_STRING ("NetStream.Buffer.Flush")
+ SWFDEC_AS_CONSTANT_STRING ("NetStream.Play.Start")
+ SWFDEC_AS_CONSTANT_STRING ("NetStream.Play.Stop")
+ SWFDEC_AS_CONSTANT_STRING ("NetStream.Play.StreamNotFound")
+ SWFDEC_AS_CONSTANT_STRING ("undefined")
+ SWFDEC_AS_CONSTANT_STRING ("null")
+ SWFDEC_AS_CONSTANT_STRING ("[object Object]")
+ SWFDEC_AS_CONSTANT_STRING ("true")
+ SWFDEC_AS_CONSTANT_STRING ("false")
+ SWFDEC_AS_CONSTANT_STRING ("_x")
+ SWFDEC_AS_CONSTANT_STRING ("_y")
+ SWFDEC_AS_CONSTANT_STRING ("_xscale")
+ SWFDEC_AS_CONSTANT_STRING ("_yscale")
+ SWFDEC_AS_CONSTANT_STRING ("_currentframe")
+ SWFDEC_AS_CONSTANT_STRING ("_totalframes")
+ SWFDEC_AS_CONSTANT_STRING ("_alpha")
+ SWFDEC_AS_CONSTANT_STRING ("_visible")
+ SWFDEC_AS_CONSTANT_STRING ("_width")
+ SWFDEC_AS_CONSTANT_STRING ("_height")
+ SWFDEC_AS_CONSTANT_STRING ("_rotation")
+ SWFDEC_AS_CONSTANT_STRING ("_target")
+ SWFDEC_AS_CONSTANT_STRING ("_framesloaded")
+ SWFDEC_AS_CONSTANT_STRING ("_name")
+ SWFDEC_AS_CONSTANT_STRING ("_droptarget")
+ SWFDEC_AS_CONSTANT_STRING ("_url")
+ SWFDEC_AS_CONSTANT_STRING ("_highquality")
+ SWFDEC_AS_CONSTANT_STRING ("_focusrect")
+ SWFDEC_AS_CONSTANT_STRING ("_soundbuftime")
+ SWFDEC_AS_CONSTANT_STRING ("_quality")
+ SWFDEC_AS_CONSTANT_STRING ("_xmouse")
+ SWFDEC_AS_CONSTANT_STRING ("_ymouse")
+ SWFDEC_AS_CONSTANT_STRING ("_parent")
+ SWFDEC_AS_CONSTANT_STRING ("_root")
+ SWFDEC_AS_CONSTANT_STRING ("#ERROR#")
+ SWFDEC_AS_CONSTANT_STRING ("number")
+ SWFDEC_AS_CONSTANT_STRING ("boolean")
+ SWFDEC_AS_CONSTANT_STRING ("string")
+ SWFDEC_AS_CONSTANT_STRING ("movieclip")
+ SWFDEC_AS_CONSTANT_STRING ("function")
+ SWFDEC_AS_CONSTANT_STRING ("object")
+ SWFDEC_AS_CONSTANT_STRING ("toString")
+ SWFDEC_AS_CONSTANT_STRING ("valueOf")
+ SWFDEC_AS_CONSTANT_STRING ("Function")
+ SWFDEC_AS_CONSTANT_STRING ("prototype")
+ SWFDEC_AS_CONSTANT_STRING ("constructor")
+ SWFDEC_AS_CONSTANT_STRING ("Object")
+ SWFDEC_AS_CONSTANT_STRING ("hasOwnProperty")
+ SWFDEC_AS_CONSTANT_STRING ("NUMERIC")
+ SWFDEC_AS_CONSTANT_STRING ("RETURNINDEXEDARRAY")
+ SWFDEC_AS_CONSTANT_STRING ("UNIQUESORT")
+ SWFDEC_AS_CONSTANT_STRING ("DESCENDING")
+ SWFDEC_AS_CONSTANT_STRING ("CASEINSENSITIVE")
+ SWFDEC_AS_CONSTANT_STRING ("Array")
+ SWFDEC_AS_CONSTANT_STRING ("ASSetPropFlags")
+ SWFDEC_AS_CONSTANT_STRING ("0")
+ SWFDEC_AS_CONSTANT_STRING ("-Infinity")
+ SWFDEC_AS_CONSTANT_STRING ("Infinity")
+ SWFDEC_AS_CONSTANT_STRING ("NaN")
+ SWFDEC_AS_CONSTANT_STRING ("Number")
+ SWFDEC_AS_CONSTANT_STRING ("NAN")
+ SWFDEC_AS_CONSTANT_STRING ("MAX_VALUE")
+ SWFDEC_AS_CONSTANT_STRING ("MIN_VALUE")
+ SWFDEC_AS_CONSTANT_STRING ("NEGATIVE_INFINITY")
+ SWFDEC_AS_CONSTANT_STRING ("POSITIVE_INFINITY")
+ SWFDEC_AS_CONSTANT_STRING ("[type Object]")
+ SWFDEC_AS_CONSTANT_STRING ("startDrag")
+ SWFDEC_AS_CONSTANT_STRING ("Mouse")
+ SWFDEC_AS_CONSTANT_STRING ("hide")
+ SWFDEC_AS_CONSTANT_STRING ("show")
+ SWFDEC_AS_CONSTANT_STRING ("addListener")
+ SWFDEC_AS_CONSTANT_STRING ("removeListener")
+ SWFDEC_AS_CONSTANT_STRING ("MovieClip")
+ SWFDEC_AS_CONSTANT_STRING ("attachMovie")
+ SWFDEC_AS_CONSTANT_STRING ("duplicateMovieClip")
+ SWFDEC_AS_CONSTANT_STRING ("getBytesLoaded")
+ SWFDEC_AS_CONSTANT_STRING ("getBytesTotal")
+ SWFDEC_AS_CONSTANT_STRING ("getDepth")
+ SWFDEC_AS_CONSTANT_STRING ("getNextHighestDepth")
+ SWFDEC_AS_CONSTANT_STRING ("getURL")
+ SWFDEC_AS_CONSTANT_STRING ("gotoAndPlay")
+ SWFDEC_AS_CONSTANT_STRING ("gotoAndStop")
+ SWFDEC_AS_CONSTANT_STRING ("hitTest")
+ SWFDEC_AS_CONSTANT_STRING ("nextFrame")
+ SWFDEC_AS_CONSTANT_STRING ("play")
+ SWFDEC_AS_CONSTANT_STRING ("prevFrame")
+ SWFDEC_AS_CONSTANT_STRING ("removeMovieClip")
+ SWFDEC_AS_CONSTANT_STRING ("stop")
+ SWFDEC_AS_CONSTANT_STRING ("stopDrag")
+ SWFDEC_AS_CONSTANT_STRING ("swapDepths")
+ SWFDEC_AS_CONSTANT_STRING ("super")
+ SWFDEC_AS_CONSTANT_STRING ("length")
+ SWFDEC_AS_CONSTANT_STRING ("[type Function]")
+ SWFDEC_AS_CONSTANT_STRING ("arguments")
+ SWFDEC_AS_CONSTANT_STRING (",")
+ SWFDEC_AS_CONSTANT_STRING ("registerClass")
+ SWFDEC_AS_CONSTANT_STRING ("__constructor__")
+ SWFDEC_AS_CONSTANT_STRING ("_global")
+ SWFDEC_AS_CONSTANT_STRING ("aa")
+ SWFDEC_AS_CONSTANT_STRING ("ab")
+ SWFDEC_AS_CONSTANT_STRING ("ba")
+ SWFDEC_AS_CONSTANT_STRING ("bb")
+ SWFDEC_AS_CONSTANT_STRING ("ga")
+ SWFDEC_AS_CONSTANT_STRING ("gb")
+ SWFDEC_AS_CONSTANT_STRING ("ra")
+ SWFDEC_AS_CONSTANT_STRING ("rb")
+ SWFDEC_AS_CONSTANT_STRING ("getRGB")
+ SWFDEC_AS_CONSTANT_STRING ("getTransform")
+ SWFDEC_AS_CONSTANT_STRING ("setRGB")
+ SWFDEC_AS_CONSTANT_STRING ("setTransform")
+ SWFDEC_AS_CONSTANT_STRING ("Color")
+ SWFDEC_AS_CONSTANT_STRING ("push")
+ SWFDEC_AS_CONSTANT_STRING ("parseInt")
+ SWFDEC_AS_CONSTANT_STRING ("Math")
+ SWFDEC_AS_CONSTANT_STRING ("abs")
+ SWFDEC_AS_CONSTANT_STRING ("acos")
+ SWFDEC_AS_CONSTANT_STRING ("asin")
+ SWFDEC_AS_CONSTANT_STRING ("atan")
+ SWFDEC_AS_CONSTANT_STRING ("ceil")
+ SWFDEC_AS_CONSTANT_STRING ("cos")
+ SWFDEC_AS_CONSTANT_STRING ("exp")
+ SWFDEC_AS_CONSTANT_STRING ("floor")
+ SWFDEC_AS_CONSTANT_STRING ("log")
+ SWFDEC_AS_CONSTANT_STRING ("sin")
+ SWFDEC_AS_CONSTANT_STRING ("sqrt")
+ SWFDEC_AS_CONSTANT_STRING ("tan")
+ SWFDEC_AS_CONSTANT_STRING ("E")
+ SWFDEC_AS_CONSTANT_STRING ("LN10")
+ SWFDEC_AS_CONSTANT_STRING ("LN2")
+ SWFDEC_AS_CONSTANT_STRING ("LOG10E")
+ SWFDEC_AS_CONSTANT_STRING ("LOG2E")
+ SWFDEC_AS_CONSTANT_STRING ("PI")
+ SWFDEC_AS_CONSTANT_STRING ("SQRT1_2")
+ SWFDEC_AS_CONSTANT_STRING ("SQRT2")
+ SWFDEC_AS_CONSTANT_STRING ("atan2")
+ SWFDEC_AS_CONSTANT_STRING ("min")
+ SWFDEC_AS_CONSTANT_STRING ("max")
+ SWFDEC_AS_CONSTANT_STRING ("pow")
+ SWFDEC_AS_CONSTANT_STRING ("random")
+ SWFDEC_AS_CONSTANT_STRING ("round")
+ SWFDEC_AS_CONSTANT_STRING ("String")
+ SWFDEC_AS_CONSTANT_STRING ("fromCharCode")
+ SWFDEC_AS_CONSTANT_STRING ("substr")
+ SWFDEC_AS_CONSTANT_STRING ("substring")
+ SWFDEC_AS_CONSTANT_STRING ("toLowerCase")
+ SWFDEC_AS_CONSTANT_STRING ("toUpperCase")
+ SWFDEC_AS_CONSTANT_STRING ("isFinite")
+ SWFDEC_AS_CONSTANT_STRING ("isNaN")
+ SWFDEC_AS_CONSTANT_STRING ("setInterval")
+ SWFDEC_AS_CONSTANT_STRING ("clearInterval")
+ SWFDEC_AS_CONSTANT_STRING ("escape")
+ SWFDEC_AS_CONSTANT_STRING ("unescape")
+ SWFDEC_AS_CONSTANT_STRING ("charAt")
+ SWFDEC_AS_CONSTANT_STRING ("charCodeAt")
+ SWFDEC_AS_CONSTANT_STRING ("NetConnection")
+ SWFDEC_AS_CONSTANT_STRING ("connect")
+ SWFDEC_AS_CONSTANT_STRING ("createEmptyMovieClip")
+ SWFDEC_AS_CONSTANT_STRING ("split")
+ SWFDEC_AS_CONSTANT_STRING ("join")
+ SWFDEC_AS_CONSTANT_STRING ("pop")
+ SWFDEC_AS_CONSTANT_STRING ("shift")
+ SWFDEC_AS_CONSTANT_STRING ("unshift")
+ SWFDEC_AS_CONSTANT_STRING ("reverse")
+ SWFDEC_AS_CONSTANT_STRING ("concat")
+ SWFDEC_AS_CONSTANT_STRING ("slice")
+ SWFDEC_AS_CONSTANT_STRING ("splice")
+ SWFDEC_AS_CONSTANT_STRING ("sort")
+ SWFDEC_AS_CONSTANT_STRING ("sortOn")
+ SWFDEC_AS_CONSTANT_STRING ("NetStream")
+ SWFDEC_AS_CONSTANT_STRING ("pause")
+ SWFDEC_AS_CONSTANT_STRING ("seek")
+ SWFDEC_AS_CONSTANT_STRING ("setBufferTime")
+ SWFDEC_AS_CONSTANT_STRING ("load")
+ SWFDEC_AS_CONSTANT_STRING ("XML")
+ SWFDEC_AS_CONSTANT_STRING ("Video")
+ SWFDEC_AS_CONSTANT_STRING ("attachVideo")
+ SWFDEC_AS_CONSTANT_STRING ("clear")
+ SWFDEC_AS_CONSTANT_STRING ("time")
+ SWFDEC_AS_CONSTANT_STRING ("bytesLoaded")
+ SWFDEC_AS_CONSTANT_STRING ("bytesTotal")
+ SWFDEC_AS_CONSTANT_STRING ("indexOf")
+ SWFDEC_AS_CONSTANT_STRING ("call")
+ SWFDEC_AS_CONSTANT_STRING ("Boolean")
+ SWFDEC_AS_CONSTANT_STRING ("addProperty")
+ SWFDEC_AS_CONSTANT_STRING ("ASnative")
+ SWFDEC_AS_CONSTANT_STRING ("_listeners")
+ SWFDEC_AS_CONSTANT_STRING ("broadcastMessage")
+ SWFDEC_AS_CONSTANT_STRING ("showAll")
+ SWFDEC_AS_CONSTANT_STRING ("noBorder")
+ SWFDEC_AS_CONSTANT_STRING ("exactFit")
+ SWFDEC_AS_CONSTANT_STRING ("noScale")
+ SWFDEC_AS_CONSTANT_STRING ("Stage")
+ SWFDEC_AS_CONSTANT_STRING ("onResize")
+ SWFDEC_AS_CONSTANT_STRING ("getBounds")
+ SWFDEC_AS_CONSTANT_STRING ("xMin")
+ SWFDEC_AS_CONSTANT_STRING ("xMax")
+ SWFDEC_AS_CONSTANT_STRING ("yMin")
+ SWFDEC_AS_CONSTANT_STRING ("yMax")
+ SWFDEC_AS_CONSTANT_STRING ("close")
+ SWFDEC_AS_CONSTANT_STRING ("_bytesLoaded")
+ SWFDEC_AS_CONSTANT_STRING ("_bytesTotal")
+ SWFDEC_AS_CONSTANT_STRING ("xmlDecl")
+ SWFDEC_AS_CONSTANT_STRING ("docTypeDecl")
+ SWFDEC_AS_CONSTANT_STRING ("XMLNode")
+ SWFDEC_AS_CONSTANT_STRING ("namespaceURI")
+ SWFDEC_AS_CONSTANT_STRING ("localName")
+ SWFDEC_AS_CONSTANT_STRING ("prefix")
+ SWFDEC_AS_CONSTANT_STRING ("previousSibling")
+ SWFDEC_AS_CONSTANT_STRING ("parentNode")
+ SWFDEC_AS_CONSTANT_STRING ("nodeName")
+ SWFDEC_AS_CONSTANT_STRING ("nodeType")
+ SWFDEC_AS_CONSTANT_STRING ("nodeValue")
+ SWFDEC_AS_CONSTANT_STRING ("nextSibling")
+ SWFDEC_AS_CONSTANT_STRING ("lastChild")
+ SWFDEC_AS_CONSTANT_STRING ("firstChild")
+ SWFDEC_AS_CONSTANT_STRING ("childNodes")
+ SWFDEC_AS_CONSTANT_STRING ("cloneNode")
+ SWFDEC_AS_CONSTANT_STRING ("removeNode")
+ SWFDEC_AS_CONSTANT_STRING ("insertBefore")
+ SWFDEC_AS_CONSTANT_STRING ("appendChild")
+ SWFDEC_AS_CONSTANT_STRING ("getNamespaceForPrefix")
+ SWFDEC_AS_CONSTANT_STRING ("getPrefixForNamespace")
+ SWFDEC_AS_CONSTANT_STRING ("hasChildNodes")
+ SWFDEC_AS_CONSTANT_STRING ("attributes")
+ SWFDEC_AS_CONSTANT_STRING ("loaded")
+ SWFDEC_AS_CONSTANT_STRING ("lastIndexOf")
+ SWFDEC_AS_CONSTANT_STRING ("hasAudio")
+ SWFDEC_AS_CONSTANT_STRING ("hasStreamingAudio")
+ SWFDEC_AS_CONSTANT_STRING ("hasStreamingVideo")
+ SWFDEC_AS_CONSTANT_STRING ("hasEmbeddedVideo")
+ SWFDEC_AS_CONSTANT_STRING ("hasMP3")
+ SWFDEC_AS_CONSTANT_STRING ("hasAudioEncoder")
+ SWFDEC_AS_CONSTANT_STRING ("hasVideoEncoder")
+ SWFDEC_AS_CONSTANT_STRING ("hasAccessibility")
+ SWFDEC_AS_CONSTANT_STRING ("hasPrinting")
+ SWFDEC_AS_CONSTANT_STRING ("hasScreenPlayback")
+ SWFDEC_AS_CONSTANT_STRING ("hasScreenBroadcast")
+ SWFDEC_AS_CONSTANT_STRING ("isDebugger")
+ SWFDEC_AS_CONSTANT_STRING ("version")
+ SWFDEC_AS_CONSTANT_STRING ("manufacturer")
+ SWFDEC_AS_CONSTANT_STRING ("screenResolutionX")
+ SWFDEC_AS_CONSTANT_STRING ("screenResolutionY")
+ SWFDEC_AS_CONSTANT_STRING ("screenDPI")
+ SWFDEC_AS_CONSTANT_STRING ("screenColor")
+ SWFDEC_AS_CONSTANT_STRING ("pixelAspectRatio")
+ SWFDEC_AS_CONSTANT_STRING ("os")
+ SWFDEC_AS_CONSTANT_STRING ("language")
+ SWFDEC_AS_CONSTANT_STRING ("hasIME")
+ SWFDEC_AS_CONSTANT_STRING ("playerType")
+ SWFDEC_AS_CONSTANT_STRING ("avHardwareDisable")
+ SWFDEC_AS_CONSTANT_STRING ("localFileReadDisable")
+ SWFDEC_AS_CONSTANT_STRING ("windowlessDisable")
+ SWFDEC_AS_CONSTANT_STRING ("hasTLS")
+ SWFDEC_AS_CONSTANT_STRING ("serverString")
+ SWFDEC_AS_CONSTANT_STRING ("$version")
+ SWFDEC_AS_CONSTANT_STRING ("contentType")
+ SWFDEC_AS_CONSTANT_STRING ("application/x-www-form-urlencoded")
+ SWFDEC_AS_CONSTANT_STRING ("ignoreWhite")
+ SWFDEC_AS_CONSTANT_STRING ("ASconstructor")
+ SWFDEC_AS_CONSTANT_STRING ("Date")
+ SWFDEC_AS_CONSTANT_STRING ("UTC")
+ SWFDEC_AS_CONSTANT_STRING ("getTime")
+ SWFDEC_AS_CONSTANT_STRING ("getTimezoneOffset")
+ SWFDEC_AS_CONSTANT_STRING ("getMilliseconds")
+ SWFDEC_AS_CONSTANT_STRING ("getUTCMilliseconds")
+ SWFDEC_AS_CONSTANT_STRING ("getSeconds")
+ SWFDEC_AS_CONSTANT_STRING ("getUTCSeconds")
+ SWFDEC_AS_CONSTANT_STRING ("getMinutes")
+ SWFDEC_AS_CONSTANT_STRING ("getUTCMinutes")
+ SWFDEC_AS_CONSTANT_STRING ("getHours")
+ SWFDEC_AS_CONSTANT_STRING ("getUTCHours")
+ SWFDEC_AS_CONSTANT_STRING ("getDay")
+ SWFDEC_AS_CONSTANT_STRING ("getUTCDay")
+ SWFDEC_AS_CONSTANT_STRING ("getDate")
+ SWFDEC_AS_CONSTANT_STRING ("getUTCDate")
+ SWFDEC_AS_CONSTANT_STRING ("getMonth")
+ SWFDEC_AS_CONSTANT_STRING ("getUTCMonth")
+ SWFDEC_AS_CONSTANT_STRING ("getYear")
+ SWFDEC_AS_CONSTANT_STRING ("getUTCYear")
+ SWFDEC_AS_CONSTANT_STRING ("getFullYear")
+ SWFDEC_AS_CONSTANT_STRING ("getUTCFullYear")
+ SWFDEC_AS_CONSTANT_STRING ("setTime")
+ SWFDEC_AS_CONSTANT_STRING ("setMilliseconds")
+ SWFDEC_AS_CONSTANT_STRING ("setUTCMilliseconds")
+ SWFDEC_AS_CONSTANT_STRING ("setSeconds")
+ SWFDEC_AS_CONSTANT_STRING ("setUTCSeconds")
+ SWFDEC_AS_CONSTANT_STRING ("setMinutes")
+ SWFDEC_AS_CONSTANT_STRING ("setUTCMinutes")
+ SWFDEC_AS_CONSTANT_STRING ("setHours")
+ SWFDEC_AS_CONSTANT_STRING ("setUTCHours")
+ SWFDEC_AS_CONSTANT_STRING ("setDate")
+ SWFDEC_AS_CONSTANT_STRING ("setUTCDate")
+ SWFDEC_AS_CONSTANT_STRING ("setMonth")
+ SWFDEC_AS_CONSTANT_STRING ("setUTCMonth")
+ SWFDEC_AS_CONSTANT_STRING ("setYear")
+ SWFDEC_AS_CONSTANT_STRING ("setUTCYear")
+ SWFDEC_AS_CONSTANT_STRING ("setFullYear")
+ SWFDEC_AS_CONSTANT_STRING ("setUTCFullYear")
+ SWFDEC_AS_CONSTANT_STRING ("target")
+ SWFDEC_AS_CONSTANT_STRING ("isPropertyEnumerable")
+ SWFDEC_AS_CONSTANT_STRING ("watch")
+ SWFDEC_AS_CONSTANT_STRING ("unwatch")
+ SWFDEC_AS_CONSTANT_STRING ("apply")
+ SWFDEC_AS_CONSTANT_STRING ("isPrototypeOf")
+ SWFDEC_AS_CONSTANT_STRING ("/")
+ SWFDEC_AS_CONSTANT_STRING ("_typewriter")
+ SWFDEC_AS_CONSTANT_STRING ("_sans")
+ SWFDEC_AS_CONSTANT_STRING ("_serif")
+ SWFDEC_AS_CONSTANT_STRING ("align")
+ SWFDEC_AS_CONSTANT_STRING ("left")
+ SWFDEC_AS_CONSTANT_STRING ("right")
+ SWFDEC_AS_CONSTANT_STRING ("center")
+ SWFDEC_AS_CONSTANT_STRING ("justify")
+ SWFDEC_AS_CONSTANT_STRING ("font")
+ SWFDEC_AS_CONSTANT_STRING ("url")
+ SWFDEC_AS_CONSTANT_STRING ("bullet")
+ SWFDEC_AS_CONSTANT_STRING ("bold")
+ SWFDEC_AS_CONSTANT_STRING ("italic")
+ SWFDEC_AS_CONSTANT_STRING ("kerning")
+ SWFDEC_AS_CONSTANT_STRING ("underline")
+ SWFDEC_AS_CONSTANT_STRING ("blockIndent")
+ SWFDEC_AS_CONSTANT_STRING ("color")
+ SWFDEC_AS_CONSTANT_STRING ("indent")
+ SWFDEC_AS_CONSTANT_STRING ("leading")
+ SWFDEC_AS_CONSTANT_STRING ("leftMargin")
+ SWFDEC_AS_CONSTANT_STRING ("rightMargin")
+ SWFDEC_AS_CONSTANT_STRING ("size")
+ SWFDEC_AS_CONSTANT_STRING ("tabStops")
+ SWFDEC_AS_CONSTANT_STRING ("letterSpacing")
+ SWFDEC_AS_CONSTANT_STRING ("display")
+ SWFDEC_AS_CONSTANT_STRING ("none")
+ SWFDEC_AS_CONSTANT_STRING ("inline")
+ SWFDEC_AS_CONSTANT_STRING ("block")
+ SWFDEC_AS_CONSTANT_STRING ("TextField")
+ SWFDEC_AS_CONSTANT_STRING ("text")
+ SWFDEC_AS_CONSTANT_STRING ("htmlText")
+ SWFDEC_AS_CONSTANT_STRING ("html")
+ SWFDEC_AS_CONSTANT_STRING ("TextFormat")
+ SWFDEC_AS_CONSTANT_STRING ("Times New Roman")
+ SWFDEC_AS_CONSTANT_STRING ("condenseWhite")
+ SWFDEC_AS_CONSTANT_STRING ("textColor")
+ SWFDEC_AS_CONSTANT_STRING ("embedFonts")
+ SWFDEC_AS_CONSTANT_STRING ("autoSize")
+ SWFDEC_AS_CONSTANT_STRING ("wordWrap")
+ SWFDEC_AS_CONSTANT_STRING ("border")
+ SWFDEC_AS_CONSTANT_STRING ("Key")
+ SWFDEC_AS_CONSTANT_STRING ("background")
+ SWFDEC_AS_CONSTANT_STRING ("backgroundColor")
+ SWFDEC_AS_CONSTANT_STRING ("borderColor")
+ SWFDEC_AS_CONSTANT_STRING ("multiline")
+ SWFDEC_AS_CONSTANT_STRING ("type")
+ SWFDEC_AS_CONSTANT_STRING ("input")
+ SWFDEC_AS_CONSTANT_STRING ("dynamic")
+ SWFDEC_AS_CONSTANT_STRING ("scroll")
+ SWFDEC_AS_CONSTANT_STRING ("maxChars")
+ SWFDEC_AS_CONSTANT_STRING ("selectable")
+ SWFDEC_AS_CONSTANT_STRING ("password")
+ SWFDEC_AS_CONSTANT_STRING ("variable")
+ SWFDEC_AS_CONSTANT_STRING ("restrict")
+ SWFDEC_AS_CONSTANT_STRING ("mouseWheelEnabled")
+ SWFDEC_AS_CONSTANT_STRING ("_level0")
+ SWFDEC_AS_CONSTANT_STRING ("hscroll")
+ SWFDEC_AS_CONSTANT_STRING ("maxhscroll")
+ SWFDEC_AS_CONSTANT_STRING ("maxscroll")
+ SWFDEC_AS_CONSTANT_STRING ("bottomScroll")
+ SWFDEC_AS_CONSTANT_STRING ("Sans")
+ SWFDEC_AS_CONSTANT_STRING ("Serif")
+ SWFDEC_AS_CONSTANT_STRING ("Monospace")
+ SWFDEC_AS_CONSTANT_STRING ("textHeight")
+ SWFDEC_AS_CONSTANT_STRING ("textWidth")
+ SWFDEC_AS_CONSTANT_STRING ("onScroller")
+ SWFDEC_AS_CONSTANT_STRING ("styleSheet")
+ SWFDEC_AS_CONSTANT_STRING ("_styles")
+ SWFDEC_AS_CONSTANT_STRING ("onLoadStart")
+ SWFDEC_AS_CONSTANT_STRING ("onLoadComplete")
+ 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")
+ SWFDEC_AS_CONSTANT_STRING ("creationDate")
+ SWFDEC_AS_CONSTANT_STRING ("creator")
+ SWFDEC_AS_CONSTANT_STRING ("modificationDate")
+ SWFDEC_AS_CONSTANT_STRING ("name")
+ SWFDEC_AS_CONSTANT_STRING ("postData")
+ SWFDEC_AS_CONSTANT_STRING ("PrintJob")
+ SWFDEC_AS_CONSTANT_STRING ("orientation")
+ SWFDEC_AS_CONSTANT_STRING ("pageHeight")
+ SWFDEC_AS_CONSTANT_STRING ("pageWidth")
+ SWFDEC_AS_CONSTANT_STRING ("paperHeight")
+ SWFDEC_AS_CONSTANT_STRING ("paperWidth")
+ SWFDEC_AS_CONSTANT_STRING ("callee")
+ SWFDEC_AS_CONSTANT_STRING ("caller")
+ SWFDEC_AS_CONSTANT_STRING ("enableDebugConsole")
+ SWFDEC_AS_CONSTANT_STRING ("remote")
+ SWFDEC_AS_CONSTANT_STRING ("localWithFile")
+ SWFDEC_AS_CONSTANT_STRING ("localWithNetwork")
+ SWFDEC_AS_CONSTANT_STRING ("localTrusted")
+ SWFDEC_AS_CONSTANT_STRING ("normal")
+ SWFDEC_AS_CONSTANT_STRING ("layer")
+ SWFDEC_AS_CONSTANT_STRING ("multiply")
+ SWFDEC_AS_CONSTANT_STRING ("screen")
+ SWFDEC_AS_CONSTANT_STRING ("lighten")
+ SWFDEC_AS_CONSTANT_STRING ("darken")
+ SWFDEC_AS_CONSTANT_STRING ("difference")
+ SWFDEC_AS_CONSTANT_STRING ("add")
+ SWFDEC_AS_CONSTANT_STRING ("subtract")
+ SWFDEC_AS_CONSTANT_STRING ("invert")
+ SWFDEC_AS_CONSTANT_STRING ("alpha")
+ SWFDEC_AS_CONSTANT_STRING ("erase")
+ SWFDEC_AS_CONSTANT_STRING ("overlay")
+ SWFDEC_AS_CONSTANT_STRING ("hardlight")
+ SWFDEC_AS_CONSTANT_STRING ("getTextExtent")
+ SWFDEC_AS_CONSTANT_STRING ("domain")
+ SWFDEC_AS_CONSTANT_STRING ("linear")
+ SWFDEC_AS_CONSTANT_STRING ("radial")
+ SWFDEC_AS_CONSTANT_STRING ("matrixType")
+ SWFDEC_AS_CONSTANT_STRING ("box")
+ SWFDEC_AS_CONSTANT_STRING ("a")
+ SWFDEC_AS_CONSTANT_STRING ("b")
+ SWFDEC_AS_CONSTANT_STRING ("c")
+ SWFDEC_AS_CONSTANT_STRING ("d")
+ SWFDEC_AS_CONSTANT_STRING ("e")
+ SWFDEC_AS_CONSTANT_STRING ("f")
+ SWFDEC_AS_CONSTANT_STRING ("g")
+ SWFDEC_AS_CONSTANT_STRING ("h")
+ SWFDEC_AS_CONSTANT_STRING ("i")
+ SWFDEC_AS_CONSTANT_STRING ("r")
+ SWFDEC_AS_CONSTANT_STRING ("w")
+ SWFDEC_AS_CONSTANT_STRING ("x")
+ SWFDEC_AS_CONSTANT_STRING ("y")
+ SWFDEC_AS_CONSTANT_STRING ("idMap")
+ SWFDEC_AS_CONSTANT_STRING ("id")
+ SWFDEC_AS_CONSTANT_STRING ("onClose")
+ SWFDEC_AS_CONSTANT_STRING ("onConnect")
+ /* add more here */
+;
diff --git a/swfdec/swfdec_as_super.c b/swfdec/swfdec_as_super.c
new file mode 100644
index 0000000..9e67b40
--- /dev/null
+++ b/swfdec/swfdec_as_super.c
@@ -0,0 +1,217 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+
+#include "swfdec_as_super.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_frame_internal.h"
+#include "swfdec_as_function.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_movie.h"
+
+G_DEFINE_TYPE (SwfdecAsSuper, swfdec_as_super, SWFDEC_TYPE_AS_FUNCTION)
+
+static SwfdecAsFrame *
+swfdec_as_super_call (SwfdecAsFunction *function)
+{
+ SwfdecAsSuper *super = SWFDEC_AS_SUPER (function);
+ SwfdecAsValue val;
+ SwfdecAsFunction *fun;
+ SwfdecAsFunctionClass *klass;
+ SwfdecAsFrame *frame;
+
+ if (super->object == NULL) {
+ SWFDEC_WARNING ("super () called without an object.");
+ return NULL;
+ }
+
+ swfdec_as_object_get_variable (super->object, SWFDEC_AS_STR___constructor__, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val) ||
+ !SWFDEC_IS_AS_FUNCTION (fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&val)))
+ return NULL;
+
+ klass = SWFDEC_AS_FUNCTION_GET_CLASS (fun);
+ frame = klass->call (fun);
+ if (frame == NULL)
+ return NULL;
+ /* We set the real function here. 1) swfdec_as_context_run() requires it.
+ * And b) it makes more sense reading the constructor's name than reading "super"
+ * in a debugger
+ */
+ frame->function = fun;
+ frame->construct = frame->next->construct;
+ swfdec_as_frame_set_this (frame, super->thisp);
+ return frame;
+}
+
+static gboolean
+swfdec_as_super_get (SwfdecAsObject *object, SwfdecAsObject *orig,
+ const char *variable, SwfdecAsValue *val, guint *flags)
+{
+ SwfdecAsSuper *super = SWFDEC_AS_SUPER (object);
+ SwfdecAsObjectClass *klass;
+ SwfdecAsObject *cur;
+ guint i;
+
+ if (super->object == NULL) {
+ SWFDEC_WARNING ("super.%s () called without an object.", variable);
+ return FALSE;
+ }
+ cur = super->object->prototype;
+ for (i = 0; i <= SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT && cur != NULL; i++) {
+ klass = SWFDEC_AS_OBJECT_GET_CLASS (cur);
+ /* FIXME: is the orig pointer correct? */
+ if (klass->get (cur, super->object, variable, val, flags))
+ return TRUE;
+ /* FIXME: need get_prototype_internal here? */
+ cur = swfdec_as_object_get_prototype (cur);
+ }
+ if (i > SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT)
+ swfdec_as_context_abort (object->context, "Prototype recursion limit exceeded");
+ SWFDEC_AS_VALUE_SET_UNDEFINED (val);
+ *flags = 0;
+ return FALSE;
+}
+
+static void
+swfdec_as_super_set (SwfdecAsObject *object, const char *variable, const SwfdecAsValue *val, guint flags)
+{
+ /* This seems to be ignored completely */
+}
+
+static void
+swfdec_as_super_set_flags (SwfdecAsObject *object, const char *variable, guint flags, guint mask)
+{
+ /* if we have no variables, we also can't set its flags... */
+}
+
+static SwfdecAsDeleteReturn
+swfdec_as_super_delete (SwfdecAsObject *object, const char *variable)
+{
+ /* if we have no variables... */
+ return SWFDEC_AS_DELETE_NOT_FOUND;
+}
+
+static SwfdecAsObject *
+swfdec_as_super_resolve (SwfdecAsObject *object)
+{
+ SwfdecAsSuper *super = SWFDEC_AS_SUPER (object);
+
+ return super->thisp;
+}
+
+static void
+swfdec_as_super_class_init (SwfdecAsSuperClass *klass)
+{
+ SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
+ SwfdecAsFunctionClass *function_class = SWFDEC_AS_FUNCTION_CLASS (klass);
+
+ asobject_class->get = swfdec_as_super_get;
+ asobject_class->set = swfdec_as_super_set;
+ asobject_class->set_flags = swfdec_as_super_set_flags;
+ asobject_class->del = swfdec_as_super_delete;
+ asobject_class->resolve = swfdec_as_super_resolve;
+
+ function_class->call = swfdec_as_super_call;
+}
+
+static void
+swfdec_as_super_init (SwfdecAsSuper *super)
+{
+}
+
+void
+swfdec_as_super_new (SwfdecAsFrame *frame, SwfdecAsObject *thisp, SwfdecAsObject *ref)
+{
+ SwfdecAsContext *context;
+ SwfdecAsSuper *super;
+
+ g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (thisp));
+ g_return_if_fail (ref == NULL || SWFDEC_IS_AS_OBJECT (ref));
+
+ if (frame->super != NULL)
+ return;
+ context = SWFDEC_AS_OBJECT (frame)->context;
+ if (context->version <= 5)
+ return;
+
+ if (!swfdec_as_context_use_mem (context, sizeof (SwfdecAsSuper)))
+ return;
+ super = g_object_new (SWFDEC_TYPE_AS_SUPER, NULL);
+ frame->super = SWFDEC_AS_OBJECT (super);
+ swfdec_as_object_add (SWFDEC_AS_OBJECT (super), context, sizeof (SwfdecAsSuper));
+ super->thisp = thisp;
+ if (context->version <= 5) {
+ super->object = NULL;
+ } else {
+ super->object = ref;
+ }
+}
+
+/**
+ * swfdec_as_super_new_chain:
+ * @frame: the frame that is called
+ * @super: the super object to chain from
+ * @chain_to: object to chain to. Must be in the prototype chain of @super. Or
+ * %NULL to just use the super object's prototype
+ *
+ * This function creates a super object relative to the given @super object. It
+ * is only needed when calling functions on the @super object.
+ **/
+void
+swfdec_as_super_new_chain (SwfdecAsFrame *frame, SwfdecAsSuper *super,
+ const char *function_name)
+{
+ SwfdecAsObject *ref;
+ SwfdecAsContext *context;
+
+ g_return_if_fail (SWFDEC_IS_AS_FRAME (frame));
+ g_return_if_fail (SWFDEC_IS_AS_SUPER (super));
+
+ if (frame->super != NULL)
+ return;
+
+ if (super->object == NULL)
+ return;
+ ref = super->object->prototype;
+ if (ref == NULL)
+ return;
+ context = SWFDEC_AS_OBJECT (frame)->context;
+ if (function_name && context->version > 6) {
+ /* skip prototypes to find the next one that has this function defined */
+ SwfdecAsObject *res;
+ if (swfdec_as_object_get_variable_and_flags (ref,
+ function_name, NULL, NULL, &res) && ref != res) {
+ while (ref->prototype != res) {
+ ref = ref->prototype;
+ g_return_if_fail (ref);
+ }
+ }
+ }
+ swfdec_as_super_new (frame, super->thisp, ref);
+}
+
diff --git a/swfdec/swfdec_as_super.h b/swfdec/swfdec_as_super.h
new file mode 100644
index 0000000..ad082e9
--- /dev/null
+++ b/swfdec/swfdec_as_super.h
@@ -0,0 +1,59 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_SUPER_H_
+#define _SWFDEC_AS_SUPER_H_
+
+#include <libswfdec/swfdec_as_function.h>
+#include <libswfdec/swfdec_as_types.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecAsSuper SwfdecAsSuper;
+typedef struct _SwfdecAsSuperClass SwfdecAsSuperClass;
+
+#define SWFDEC_TYPE_AS_SUPER (swfdec_as_super_get_type())
+#define SWFDEC_IS_AS_SUPER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AS_SUPER))
+#define SWFDEC_IS_AS_SUPER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AS_SUPER))
+#define SWFDEC_AS_SUPER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AS_SUPER, SwfdecAsSuper))
+#define SWFDEC_AS_SUPER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AS_SUPER, SwfdecAsSuperClass))
+#define SWFDEC_AS_SUPER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AS_SUPER, SwfdecAsSuperClass))
+
+struct _SwfdecAsSuper {
+ SwfdecAsFunction function;
+
+ SwfdecAsObject * thisp; /* object super was called on */
+ SwfdecAsObject * object; /* current prototype we reference or NULL if none */
+};
+
+struct _SwfdecAsSuperClass {
+ SwfdecAsFunctionClass function_class;
+};
+
+GType swfdec_as_super_get_type (void);
+
+void swfdec_as_super_new (SwfdecAsFrame * frame,
+ SwfdecAsObject * thisp,
+ SwfdecAsObject * ref);
+void swfdec_as_super_new_chain (SwfdecAsFrame * frame,
+ SwfdecAsSuper * super,
+ const char * function_name);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_as_types.c b/swfdec/swfdec_as_types.c
new file mode 100644
index 0000000..e5253d3
--- /dev/null
+++ b/swfdec/swfdec_as_types.c
@@ -0,0 +1,677 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+#include <string.h>
+
+#include "swfdec_as_types.h"
+#include "swfdec_as_object.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_function.h"
+#include "swfdec_as_number.h"
+#include "swfdec_as_stack.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_as_super.h"
+#include "swfdec_debug.h"
+#include "swfdec_movie.h"
+
+/*** GTK-DOC ***/
+
+/**
+ * SECTION:SwfdecAsValue
+ * @title: SwfdecAsValue
+ * @short_description: exchanging values with the Actionscript engine
+ *
+ * This section describes how values are handled inside the Actionscript
+ * engine. Since Actionscript is a dynamically typed language, the variable type
+ * has to be carried with every value. #SwfdecAsValue accomplishes that. Swfdec
+ * allows two possible ways of accessing these values: The common method is to
+ * use the provided functions to explicitly convert the values to a given type
+ * with a function such as swfdec_as_value_to_string (). This is convenient,
+ * but can be very slow as it can call back into the Actionscript engine when
+ * converting various objects. So it can be unsuitable in some cases.
+ * A different possibiltiy is accessing the values directly using the accessor
+ * macros. You must check the type before doing so though. For setting values,
+ * there only exist macros, since type conversion is not necessary.
+ */
+
+/**
+ * SwfdecAsValueType:
+ * @SWFDEC_AS_TYPE_UNDEFINED: the special undefined value
+ * @SWFDEC_AS_TYPE_BOOLEAN: a boolean value - true or false
+ * @SWFDEC_AS_TYPE_INT: reserved value for integers. Should the need arise for
+ * performance enhancements - especially on embedded
+ * devices - it might be useful to implement this type.
+ * For now, this type will never appear in Swfdec. Using
+ * it will cause Swfdec to crash.
+ * @SWFDEC_AS_TYPE_NUMBER: a double value - also used for integer numbers
+ * @SWFDEC_AS_TYPE_STRING: a string. Strings are garbage-collected and unique.
+ * @SWFDEC_AS_TYPE_NULL: the spaecial null value
+ * @SWFDEC_AS_TYPE_OBJECT: an object - must be of type #SwfdecAsObject
+ *
+ * These are the possible values the Swfdec Actionscript engine knows about.
+ */
+
+/**
+ * SwfdecAsValue:
+ * @type: the type of this value.
+ *
+ * This is the type used to present an opaque value in the Actionscript
+ * engine. See #SwfdecAsValueType for possible types. It's similar in
+ * spirit to #GValue. The value held is garbage-collected. Apart from the type
+ * member, use the provided macros to access this structure.
+ * <note>If you memset a SwfdecAsValue to 0, it is a valid undefined value.</note>
+ */
+
+/**
+ * SWFDEC_AS_VALUE_SET_UNDEFINED:
+ * @val: value to set as undefined
+ *
+ * Sets @val to the special undefined value. If you create a temporary value,
+ * you can instead use code such as |[ SwfdecAsValue val = { 0, }; ]|
+ */
+
+/**
+ * SWFDEC_AS_VALUE_GET_BOOLEAN:
+ * @val: value to get, the value must reference a boolean
+ *
+ * Gets the boolean associated with value. If you are not sure if the value is
+ * a boolean, use swfdec_as_value_to_boolean () instead.
+ *
+ * Returns: %TRUE or %FALSE
+ */
+
+/**
+ * SWFDEC_AS_VALUE_SET_BOOLEAN:
+ * @val: value to set
+ * @b: boolean value to set, must be either %TRUE or %FALSE
+ *
+ * Sets @val to the specified boolean value.
+ */
+
+/**
+ * SWFDEC_AS_VALUE_GET_NUMBER:
+ * @val: value to get, the value must reference a number
+ *
+ * Gets the number associated with @val. If you are not sure that the value is
+ * a valid number value, consider using swfdec_as_value_to_number() or
+ * swfdec_as_value_to_int() instead.
+ *
+ * Returns: a double. It can be NaN or +-Infinity, but not -0.0
+ */
+
+/**
+ * SWFDEC_AS_VALUE_SET_NUMBER:
+ * @val: value to set
+ * @d: double value to set
+ *
+ * Sets @val to the given value. If you are sure the value is a valid
+ * integer value, use SWFDEC_AS_VALUE_SET_INT() instead.
+ */
+
+/**
+ * SWFDEC_AS_VALUE_SET_INT:
+ * @val: value to set
+ * @d: integer value to set
+ *
+ * Sets @val to the given value. Currently this macro is equivalent to
+ * SWFDEC_AS_VALUE_SET_NUMBER(), but this may change in future versions of
+ * Swfdec.
+ */
+
+/**
+ * SWFDEC_AS_VALUE_GET_STRING:
+ * @val: value to get, the value must reference a string
+ *
+ * Gets the string associated with @val. If you are not sure that the value is
+ * a string value, consider using swfdec_as_value_to_string() instead.
+ *
+ * Returns: a garbage-collected string.
+ */
+
+/**
+ * SWFDEC_AS_VALUE_SET_STRING:
+ * @val: value to set
+ * @s: garbage-collected string to use
+ *
+ * Sets @val to the given string value.
+ */
+
+/**
+ * SWFDEC_AS_VALUE_SET_NULL:
+ * @val: value to set
+ *
+ * Sets @val to the special null value.
+ */
+
+/**
+ * SWFDEC_AS_VALUE_GET_OBJECT:
+ * @val: value to get, the value must reference an object
+ *
+ * Gets the object associated with @val. If you are not sure that the value is
+ * an object value, consider using swfdec_as_value_to_object() instead.
+ *
+ * Returns: a #SwfdecAsObject
+ */
+
+/**
+ * SWFDEC_AS_VALUE_SET_OBJECT:
+ * @val: value to set
+ * @o: garbage-collected #SwfdecAsObject to use
+ *
+ * Sets @val to the given object. The object must have been added to the
+ * garbage collector via swfdec_as_object_add() previously.
+ */
+
+/*** actual code ***/
+
+/**
+ * swfdec_as_str_concat:
+ * @cx: a #SwfdecAsContext
+ * @s1: first string
+ * @s2: second string
+ *
+ * Convenience function to concatenate two garbage-collected strings. This
+ * function is equivalent to g_strconcat ().
+ *
+ * Returns: A new garbage-collected string
+ **/
+const char *
+swfdec_as_str_concat (SwfdecAsContext *cx, const char * s1, const char *s2)
+{
+ const char *ret;
+ char *s;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (cx), SWFDEC_AS_STR_EMPTY);
+ g_return_val_if_fail (s1, SWFDEC_AS_STR_EMPTY);
+ g_return_val_if_fail (s2, SWFDEC_AS_STR_EMPTY);
+
+ s = g_strconcat (s1, s2, NULL);
+ ret = swfdec_as_context_get_string (cx, s);
+ g_free (s);
+
+ return ret;
+}
+
+/**
+ * swfdec_as_integer_to_string:
+ * @context: a #SwfdecAsContext
+ * @i: an integer that fits into 32 bits
+ *
+ * Converts @d into a string using the same conversion algorithm as the
+ * official Flash player.
+ *
+ * Returns: a garbage-collected string
+ **/
+const char *
+swfdec_as_integer_to_string (SwfdecAsContext *context, int i)
+{
+ return swfdec_as_context_give_string (context, g_strdup_printf ("%d", i));
+}
+
+/**
+ * swfdec_as_double_to_string:
+ * @context: a #SwfdecAsContext
+ * @d: a double
+ *
+ * Converts @d into a string using the same conversion algorithm as the
+ * official Flash player.
+ *
+ * Returns: a garbage-collected string
+ **/
+/* FIXME: this function is still buggy - and it's ugly as hell.
+ * Someone with the right expertise should rewrite it
+ * Some pointers:
+ * http://www.cs.indiana.edu/~burger/FP-Printing-PLDI96.pdf
+ * http://lxr.mozilla.org/mozilla/source/js/tamarin/core/MathUtils.cpp
+ */
+const char *
+swfdec_as_double_to_string (SwfdecAsContext *context, double d)
+{
+ gboolean found = FALSE, gotdot = FALSE;
+ guint digits = 15;
+ char tmp[50], *end, *start, *s;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), SWFDEC_AS_STR_EMPTY);
+
+ if (isnan (d))
+ return SWFDEC_AS_STR_NaN;
+ if (isinf (d))
+ return d < 0 ? SWFDEC_AS_STR__Infinity : SWFDEC_AS_STR_Infinity;
+ /* stupid -0.0 */
+ if (fabs (d) == 0.0)
+ return SWFDEC_AS_STR_0;
+
+ tmp[0] = ' ';
+ s = &tmp[1];
+ if (ABS (d) > 0.00001 && ABS (d) < 1e+15) {
+ g_ascii_formatd (s, 50, "%.22f", d);
+ } else {
+ g_ascii_formatd (s, 50, "%.25e", d);
+ }
+ start = s;
+ /* skip - sign */
+ if (*start == '-')
+ start++;
+ /* count digits (maximum allowed is 15) */
+ while (digits) {
+ if (*start == '.') {
+ start++;
+ gotdot = TRUE;
+ continue;
+ }
+ if (*start < '0' || *start > '9')
+ break;
+ if (found || *start != '0') {
+ digits--;
+ found = TRUE;
+ }
+ start++;
+ }
+ end = start;
+ /* go to end of string */
+ while (*end != 'e' && *end != 0)
+ end++;
+ /* round using the next digit */
+ if (*start >= '5' && *start <= '9') {
+ char *finish = NULL;
+ /* skip all 9s at the end */
+ while (start[-1] == '9')
+ start--;
+ /* if we're before the dot, replace 9s with 0s */
+ if (start[-1] == '.') {
+ finish = start;
+ start--;
+ }
+ while (start[-1] == '9') {
+ start[-1] = '0';
+ start--;
+ }
+ /* write out correct number */
+ if (start[-1] == '-') {
+ s--;
+ start[-2] = '-';
+ start[-1] = '1';
+ } else if (start[-1] == ' ') {
+ s--;
+ start[-1] = '1';
+ } else {
+ start[-1]++;
+ }
+ /* reposition cursor at end */
+ if (finish)
+ start = finish;
+ }
+ /* remove trailing zeros (note we skipped zero above, so there will be non-0 bytes left) */
+ if (gotdot) {
+ while (start[-1] == '0')
+ start--;
+ if (start[-1] == '.')
+ start--;
+ }
+ /* add exponent */
+ if (*end == 'e') {
+ /* 'e' */
+ *start++ = *end++;
+ /* + or - */
+ *start++ = *end++;
+ /* skip 0s */
+ while (*end == '0')
+ end++;
+ /* add rest */
+ while (*end != 0)
+ *start++ = *end++;
+ }
+ /* end string */
+ *start = 0;
+ return swfdec_as_context_get_string (context, s);
+}
+
+/**
+ * swfdec_as_value_to_string:
+ * @context: a #SwfdecAsContext
+ * @value: value to be expressed as string
+ *
+ * Converts @value to a string according to the rules of Flash. This might
+ * cause calling back into the script engine if the @value is an object. In
+ * that case, the object's valueOf function is called.
+ * <warning>Never use this function for debugging purposes.</warning>
+ *
+ * Returns: a garbage-collected string representing @value. The value will
+ * never be %NULL.
+ **/
+const char *
+swfdec_as_value_to_string (SwfdecAsContext *context, const SwfdecAsValue *value)
+{
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), SWFDEC_AS_STR_EMPTY);
+ g_return_val_if_fail (SWFDEC_IS_AS_VALUE (value), SWFDEC_AS_STR_EMPTY);
+
+ switch (value->type) {
+ case SWFDEC_AS_TYPE_STRING:
+ return SWFDEC_AS_VALUE_GET_STRING (value);
+ case SWFDEC_AS_TYPE_UNDEFINED:
+ if (context->version > 6)
+ return SWFDEC_AS_STR_undefined;
+ else
+ return SWFDEC_AS_STR_EMPTY;
+ case SWFDEC_AS_TYPE_BOOLEAN:
+ return SWFDEC_AS_VALUE_GET_BOOLEAN (value) ? SWFDEC_AS_STR_true : SWFDEC_AS_STR_false;
+ case SWFDEC_AS_TYPE_NULL:
+ return SWFDEC_AS_STR_null;
+ case SWFDEC_AS_TYPE_NUMBER:
+ return swfdec_as_double_to_string (context, SWFDEC_AS_VALUE_GET_NUMBER (value));
+ case SWFDEC_AS_TYPE_OBJECT:
+ {
+ SwfdecAsObject *object = SWFDEC_AS_VALUE_GET_OBJECT (value);
+ if (SWFDEC_IS_MOVIE (object)) {
+ SwfdecMovie *movie = swfdec_movie_resolve (SWFDEC_MOVIE (object));
+ if (movie == NULL) {
+ return SWFDEC_AS_STR_EMPTY;
+ } else {
+ char *str = swfdec_movie_get_path (SWFDEC_MOVIE (object), TRUE);
+ return swfdec_as_context_give_string (context, str);
+ }
+ } else {
+ SwfdecAsValue ret;
+ swfdec_as_object_call (object, SWFDEC_AS_STR_toString, 0, NULL, &ret);
+ if (SWFDEC_AS_VALUE_IS_STRING (&ret))
+ return SWFDEC_AS_VALUE_GET_STRING (&ret);
+ else if (SWFDEC_IS_AS_SUPER (SWFDEC_AS_VALUE_GET_OBJECT (value)))
+ return SWFDEC_AS_STR__type_Object_;
+ else if (SWFDEC_IS_AS_FUNCTION (SWFDEC_AS_VALUE_GET_OBJECT (value)))
+ return SWFDEC_AS_STR__type_Function_;
+ else
+ return SWFDEC_AS_STR__type_Object_;
+ }
+ }
+ case SWFDEC_AS_TYPE_INT:
+ default:
+ g_assert_not_reached ();
+ return SWFDEC_AS_STR_EMPTY;
+ }
+}
+
+/**
+ * swfdec_as_value_to_debug:
+ * @value: a #SwfdecAsValue
+ *
+ * Converts the given @value to a string in a safe way. It will not call into
+ * the scripting engine. Its intended use is for output in debuggers.
+ *
+ * Returns: a newly allocated string. Free with g_free().
+ **/
+char *
+swfdec_as_value_to_debug (const SwfdecAsValue *value)
+{
+ g_return_val_if_fail (SWFDEC_IS_AS_VALUE (value), NULL);
+
+ switch (value->type) {
+ case SWFDEC_AS_TYPE_STRING:
+ return g_shell_quote (SWFDEC_AS_VALUE_GET_STRING (value));
+ case SWFDEC_AS_TYPE_UNDEFINED:
+ return g_strdup ("undefined");
+ case SWFDEC_AS_TYPE_BOOLEAN:
+ return g_strdup (SWFDEC_AS_VALUE_GET_BOOLEAN (value) ? "true" : "false");
+ case SWFDEC_AS_TYPE_NULL:
+ return g_strdup ("null");
+ case SWFDEC_AS_TYPE_NUMBER:
+ return g_strdup_printf ("%g", SWFDEC_AS_VALUE_GET_NUMBER (value));
+ case SWFDEC_AS_TYPE_OBJECT:
+ return swfdec_as_object_get_debug (SWFDEC_AS_VALUE_GET_OBJECT (value));
+ case SWFDEC_AS_TYPE_INT:
+ default:
+ g_assert_not_reached ();
+ return NULL;
+ }
+}
+
+/**
+ * swfdec_as_value_to_number:
+ * @context: a #SwfdecAsContext
+ * @value: a #SwfdecAsValue used by context
+ *
+ * Converts the value to a number according to Flash's conversion routines and
+ * the current Flash version. This conversion routine is similar, but not equal
+ * to ECMAScript. For objects, it can call back into the script engine by
+ * calling the object's valueOf function.
+ *
+ * Returns: a double value. It can be NaN or +-Infinity. It will not be -0.0.
+ **/
+double
+swfdec_as_value_to_number (SwfdecAsContext *context, const SwfdecAsValue *value)
+{
+ SwfdecAsValue tmp;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), 0.0);
+ g_return_val_if_fail (SWFDEC_IS_AS_VALUE (value), 0.0);
+
+ tmp = *value;
+ swfdec_as_value_to_primitive (&tmp);
+
+ switch (tmp.type) {
+ case SWFDEC_AS_TYPE_UNDEFINED:
+ case SWFDEC_AS_TYPE_NULL:
+ return (context->version >= 7) ? NAN : 0.0;
+ case SWFDEC_AS_TYPE_BOOLEAN:
+ return SWFDEC_AS_VALUE_GET_BOOLEAN (&tmp) ? 1 : 0;
+ case SWFDEC_AS_TYPE_NUMBER:
+ return SWFDEC_AS_VALUE_GET_NUMBER (&tmp);
+ case SWFDEC_AS_TYPE_STRING:
+ {
+ const char *s;
+ char *end;
+ double d;
+
+ // FIXME: We should most likely copy Tamarin's code here (MathUtils.cpp)
+ s = SWFDEC_AS_VALUE_GET_STRING (&tmp);
+ if (s == SWFDEC_AS_STR_EMPTY)
+ return NAN;
+ if (context->version > 5 && s[0] == '0' &&
+ (s[1] == 'x' || s[1] == 'X')) {
+ d = g_ascii_strtoll (s + 2, &end, 16);
+ } else if (context->version > 5 && s[0] == '0' &&
+ s[strspn (s, "01234567")] == '\0') {
+ d = g_ascii_strtoll (s, &end, 8);
+ } else {
+ if (strpbrk (s, "xXiI") != NULL)
+ return NAN;
+ d = g_ascii_strtod (s, &end);
+ }
+ if (*end == '\0')
+ return d == -0.0 ? 0.0 : d;
+ else
+ return NAN;
+ }
+ case SWFDEC_AS_TYPE_OBJECT:
+ return NAN;
+ case SWFDEC_AS_TYPE_INT:
+ default:
+ g_assert_not_reached ();
+ return NAN;
+ }
+}
+
+/**
+ * swfdec_as_double_to_integer:
+ * @d: any double
+ *
+ * Converts the given double to an integer using the same rules as the Flash
+ * player.
+ *
+ * Returns: an integer
+ **/
+int
+swfdec_as_double_to_integer (double d)
+{
+ if (!isfinite (d))
+ return 0;
+ if (d < 0) {
+ d = fmod (-d, 4294967296.0);
+ return - (guint) d;
+ } else {
+ d = fmod (d, 4294967296.0);
+ return (guint) d;
+ }
+}
+
+/**
+ * swfdec_as_value_to_integer:
+ * @context: a #SwfdecAsContext
+ * @value: value to convert
+ *
+ * Converts the given value to an integer. This is done similar to the
+ * conversion used by swfdec_as_value_to_number().
+ *
+ * Returns: An Integer that can be represented in 32 bits.
+ **/
+int
+swfdec_as_value_to_integer (SwfdecAsContext *context, const SwfdecAsValue *value)
+{
+ double d;
+
+ d = swfdec_as_value_to_number (context, value);
+ return swfdec_as_double_to_integer (d);
+}
+
+/**
+ * swfdec_as_value_to_object:
+ * @context: a #SwfdecAsContext
+ * @value: value to convert
+ *
+ * Converts a given value to its representation as an object. The object
+ * representation for primitive types is a wrapper object of the corresponding
+ * class (Number for numbers, String for strings, Boolean for bools). If the
+ * value does not have an object representing it, such as undefined and null
+ * values, %NULL is returned.
+ *
+ * Returns: object representing @value or %NULL.
+ **/
+SwfdecAsObject *
+swfdec_as_value_to_object (SwfdecAsContext *context, const SwfdecAsValue *value)
+{
+ SwfdecAsFunction *fun;
+ SwfdecAsValue val;
+ const char *s;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
+ g_return_val_if_fail (SWFDEC_IS_AS_VALUE (value), NULL);
+
+ switch (value->type) {
+ case SWFDEC_AS_TYPE_UNDEFINED:
+ case SWFDEC_AS_TYPE_NULL:
+ return NULL;
+ case SWFDEC_AS_TYPE_NUMBER:
+ s = SWFDEC_AS_STR_Number;
+ break;
+ case SWFDEC_AS_TYPE_STRING:
+ s = SWFDEC_AS_STR_String;
+ break;
+ case SWFDEC_AS_TYPE_BOOLEAN:
+ s = SWFDEC_AS_STR_Boolean;
+ break;
+ case SWFDEC_AS_TYPE_OBJECT:
+ return SWFDEC_AS_VALUE_GET_OBJECT (value);
+ case SWFDEC_AS_TYPE_INT:
+ default:
+ g_assert_not_reached ();
+ return NULL;
+ }
+
+ swfdec_as_object_get_variable (context->global, s, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val) ||
+ !SWFDEC_IS_AS_FUNCTION (fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&val)))
+ return NULL;
+ swfdec_as_object_create (fun, 1, value, &val);
+ swfdec_as_context_run (context);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
+ return SWFDEC_AS_VALUE_GET_OBJECT (&val);
+ } else {
+ SWFDEC_ERROR ("did not construct an object");
+ return NULL;
+ }
+}
+
+/**
+* swfdec_as_value_to_boolean:
+* @context: a #SwfdecAsContext
+* @value: value to convert
+*
+* Converts the given value to a boolean according to Flash's rules. Note that
+* these rules changed significantly for strings between Flash 6 and 7.
+*
+* Returns: either %TRUE or %FALSE.
+**/
+gboolean
+swfdec_as_value_to_boolean (SwfdecAsContext *context, const SwfdecAsValue *value)
+{
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), FALSE);
+ g_return_val_if_fail (SWFDEC_IS_AS_VALUE (value), FALSE);
+
+ /* FIXME: what do we do when called in flash 4? */
+ switch (value->type) {
+ case SWFDEC_AS_TYPE_UNDEFINED:
+ case SWFDEC_AS_TYPE_NULL:
+ return FALSE;
+ case SWFDEC_AS_TYPE_BOOLEAN:
+ return SWFDEC_AS_VALUE_GET_BOOLEAN (value);
+ case SWFDEC_AS_TYPE_NUMBER:
+ {
+ double d = SWFDEC_AS_VALUE_GET_NUMBER (value);
+ return d != 0.0 && !isnan (d);
+ }
+ case SWFDEC_AS_TYPE_STRING:
+ if (context->version <= 6) {
+ double d = swfdec_as_value_to_number (context, value);
+ return d != 0.0 && !isnan (d);
+ } else {
+ return SWFDEC_AS_VALUE_GET_STRING (value) != SWFDEC_AS_STR_EMPTY;
+ }
+ case SWFDEC_AS_TYPE_OBJECT:
+ return TRUE;
+ case SWFDEC_AS_TYPE_INT:
+ default:
+ g_assert_not_reached ();
+ return FALSE;
+ }
+}
+
+/**
+* swfdec_as_value_to_primitive:
+* @value: value to convert
+*
+* Tries to convert the given @value inline to its primitive value. Primitive
+* values are values that are not objects. If the value is an object, the
+* object's valueOf function is called. If the result of that function is still
+* an object, it is returned nonetheless.
+**/
+void
+swfdec_as_value_to_primitive (SwfdecAsValue *value)
+{
+ g_return_if_fail (SWFDEC_IS_AS_VALUE (value));
+
+ if (SWFDEC_AS_VALUE_IS_OBJECT (value) && !SWFDEC_IS_MOVIE (SWFDEC_AS_VALUE_GET_OBJECT (value))) {
+ swfdec_as_object_call (SWFDEC_AS_VALUE_GET_OBJECT (value), SWFDEC_AS_STR_valueOf,
+ 0, NULL, value);
+ }
+}
+
diff --git a/swfdec/swfdec_as_types.h b/swfdec/swfdec_as_types.h
new file mode 100644
index 0000000..ff22c8f
--- /dev/null
+++ b/swfdec/swfdec_as_types.h
@@ -0,0 +1,139 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AS_TYPES_H_
+#define _SWFDEC_AS_TYPES_H_
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* fundamental types */
+typedef enum {
+ SWFDEC_AS_TYPE_UNDEFINED = 0,
+ SWFDEC_AS_TYPE_BOOLEAN,
+ SWFDEC_AS_TYPE_INT, /* unimplemented, but reserved if someone wants it */
+ SWFDEC_AS_TYPE_NUMBER,
+ SWFDEC_AS_TYPE_STRING,
+ SWFDEC_AS_TYPE_NULL,
+ SWFDEC_AS_TYPE_OBJECT
+} SwfdecAsValueType;
+
+typedef struct _SwfdecAsArray SwfdecAsArray;
+typedef struct _SwfdecAsContext SwfdecAsContext;
+typedef struct _SwfdecAsDebugger SwfdecAsDebugger;
+typedef struct _SwfdecAsFrame SwfdecAsFrame;
+typedef struct _SwfdecAsFunction SwfdecAsFunction;
+typedef struct _SwfdecAsObject SwfdecAsObject;
+typedef struct _SwfdecAsScope SwfdecAsScope;
+typedef struct _SwfdecAsStack SwfdecAsStack;
+typedef struct _SwfdecAsValue SwfdecAsValue;
+typedef void (* SwfdecAsNative) (SwfdecAsContext * context,
+ SwfdecAsObject * thisp,
+ guint argc,
+ SwfdecAsValue * argv,
+ SwfdecAsValue * retval);
+typedef struct _SwfdecScript SwfdecScript;
+
+
+/* IMPORTANT: a SwfdecAsValue memset to 0 is a valid undefined value */
+struct _SwfdecAsValue {
+ SwfdecAsValueType type;
+ /*< private >*/
+ union {
+ gboolean boolean;
+ double number;
+ const char * string;
+ SwfdecAsObject * object;
+ } value;
+};
+
+#define SWFDEC_IS_AS_VALUE(val) ((val) != NULL && (val)->type <= SWFDEC_TYPE_AS_OBJECT)
+
+#define SWFDEC_AS_VALUE_IS_UNDEFINED(val) ((val)->type == SWFDEC_AS_TYPE_UNDEFINED)
+#define SWFDEC_AS_VALUE_SET_UNDEFINED(val) (val)->type = SWFDEC_AS_TYPE_UNDEFINED
+
+#define SWFDEC_AS_VALUE_IS_BOOLEAN(val) ((val)->type == SWFDEC_AS_TYPE_BOOLEAN)
+#define SWFDEC_AS_VALUE_GET_BOOLEAN(val) ((val)->value.boolean)
+#define SWFDEC_AS_VALUE_SET_BOOLEAN(val,b) G_STMT_START { \
+ SwfdecAsValue *__val = (val); \
+ gboolean __tmp = (b); \
+ g_assert (__tmp == TRUE || __tmp == FALSE); \
+ (__val)->value.boolean = __tmp; \
+ (__val)->type = SWFDEC_AS_TYPE_BOOLEAN; \
+} G_STMT_END
+
+#define SWFDEC_AS_VALUE_IS_NUMBER(val) ((val)->type == SWFDEC_AS_TYPE_NUMBER)
+#define SWFDEC_AS_VALUE_GET_NUMBER(val) ((val)->value.number)
+#define SWFDEC_AS_VALUE_SET_NUMBER(val,d) G_STMT_START { \
+ SwfdecAsValue *__val = (val); \
+ (__val)->value.number = (d); \
+ (__val)->type = SWFDEC_AS_TYPE_NUMBER; \
+} G_STMT_END
+
+#define SWFDEC_AS_VALUE_SET_INT(val,d) SWFDEC_AS_VALUE_SET_NUMBER(val,(int) (d))
+
+#define SWFDEC_AS_VALUE_IS_STRING(val) ((val)->type == SWFDEC_AS_TYPE_STRING)
+#define SWFDEC_AS_VALUE_GET_STRING(val) ((val)->value.string)
+#define SWFDEC_AS_VALUE_SET_STRING(val,s) G_STMT_START { \
+ SwfdecAsValue *__val = (val); \
+ (__val)->value.string = s; \
+ (__val)->type = SWFDEC_AS_TYPE_STRING; \
+} G_STMT_END
+
+#define SWFDEC_AS_VALUE_IS_NULL(val) ((val)->type == SWFDEC_AS_TYPE_NULL)
+#define SWFDEC_AS_VALUE_SET_NULL(val) (val)->type = SWFDEC_AS_TYPE_NULL
+
+#define SWFDEC_AS_VALUE_IS_OBJECT(val) ((val)->type == SWFDEC_AS_TYPE_OBJECT)
+#define SWFDEC_AS_VALUE_GET_OBJECT(val) ((val)->value.object)
+#define SWFDEC_AS_VALUE_SET_OBJECT(val,o) G_STMT_START { \
+ SwfdecAsValue *__val = (val); \
+ SwfdecAsObject *__o = (o); \
+ g_assert (__o != NULL); \
+ (__val)->type = SWFDEC_AS_TYPE_OBJECT; \
+ (__val)->value.object = __o; \
+} G_STMT_END
+
+/* value conversion functions */
+gboolean swfdec_as_value_to_boolean (SwfdecAsContext * context,
+ const SwfdecAsValue * value);
+int swfdec_as_value_to_integer (SwfdecAsContext * context,
+ const SwfdecAsValue * value);
+double swfdec_as_value_to_number (SwfdecAsContext * context,
+ const SwfdecAsValue * value);
+SwfdecAsObject *swfdec_as_value_to_object (SwfdecAsContext * context,
+ const SwfdecAsValue * value);
+void swfdec_as_value_to_primitive (SwfdecAsValue * value);
+const char * swfdec_as_value_to_string (SwfdecAsContext * context,
+ const SwfdecAsValue * value);
+char * swfdec_as_value_to_debug (const SwfdecAsValue * value);
+
+/* special conversion functions */
+const char * swfdec_as_integer_to_string (SwfdecAsContext * context,
+ int i);
+int swfdec_as_double_to_integer (double d);
+const char * swfdec_as_double_to_string (SwfdecAsContext * context,
+ double d);
+const char * swfdec_as_str_concat (SwfdecAsContext * cx,
+ const char * s1,
+ const char * s2);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_asbroadcaster.c b/swfdec/swfdec_asbroadcaster.c
new file mode 100644
index 0000000..f15b828
--- /dev/null
+++ b/swfdec/swfdec_asbroadcaster.c
@@ -0,0 +1,84 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_as_object.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_frame_internal.h"
+#include "swfdec_debug.h"
+
+/*** AS CODE ***/
+
+SWFDEC_AS_NATIVE (101, 12, broadcastMessage)
+void
+broadcastMessage (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecAsValue val;
+ SwfdecAsObject *listeners, *o;
+ gint i, length;
+ const char *name;
+ GSList *list = NULL, *walk;
+
+ if (object == NULL)
+ return;
+
+ if (argc < 1)
+ return;
+ name = swfdec_as_value_to_string (cx, &argv[0]);
+ argv += 1;
+ argc--;
+
+ swfdec_as_object_get_variable (object, SWFDEC_AS_STR__listeners, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return;
+
+ listeners = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+ swfdec_as_object_get_variable (listeners, SWFDEC_AS_STR_length, &val);
+ length = swfdec_as_value_to_integer (cx, &val);
+
+ /* return undefined if we won't try to call anything */
+ if (length <= 0)
+ return;
+
+ /* FIXME: solve this wth foreach, so it gets faster for weird cases */
+ for (i = 0; i < length; i++) {
+ swfdec_as_object_get_variable (listeners, swfdec_as_integer_to_string (cx, i), &val);
+ o = swfdec_as_value_to_object (cx, &val);
+ if (o == NULL)
+ continue;
+ list = g_slist_prepend (list, o);
+ }
+ if (list == NULL)
+ return;
+
+ list = g_slist_reverse (list);
+ for (walk = list; walk; walk = walk->next) {
+ swfdec_as_object_call (walk->data, name, argc, argv, &val);
+ }
+ g_slist_free (list);
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, TRUE);
+}
+
diff --git a/swfdec/swfdec_audio.c b/swfdec/swfdec_audio.c
new file mode 100644
index 0000000..e9a5e5f
--- /dev/null
+++ b/swfdec/swfdec_audio.c
@@ -0,0 +1,346 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include "swfdec_audio_internal.h"
+#include "swfdec_debug.h"
+#include "swfdec_player_internal.h"
+
+/**
+ * SECTION:SwfdecAudio
+ * @title: SwfdecAudio
+ * @see_also: SwfdecPlayer
+ * @short_description: object used for audio output
+ *
+ * SwfdecAudio is the way audio output is provided by a #SwfdecPlayer. See
+ * its documentation on how to access #SwfdecAudio objects.
+ *
+ * An audio object gives access to one audio stream played inside a player.
+ * You are responsible for outputting this data, swfdec does not try to do this
+ * for you.
+ *
+ * Audio data is always provided in 16bit host-endian stereo. If the data was
+ * encoded into a different format originally, Swfdec will already have decoded
+ * it. The data is always referenced relative to the player. Sample 0
+ * references the first sample to be played at the current position. If the
+ * player gets iterated, sample 0 changes. There is no way to access samples
+ * belonging to a previous state.
+ */
+
+/**
+ * SwfdecAudio
+ *
+ * This object is used for audio output. It is an abstract class.
+ */
+
+G_DEFINE_ABSTRACT_TYPE (SwfdecAudio, swfdec_audio, G_TYPE_OBJECT)
+
+static void
+swfdec_audio_dispose (GObject *object)
+{
+ SwfdecAudio *audio = SWFDEC_AUDIO (object);
+
+ g_assert (audio->player == NULL);
+
+ G_OBJECT_CLASS (swfdec_audio_parent_class)->dispose (object);
+}
+
+static void
+swfdec_audio_class_init (SwfdecAudioClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = swfdec_audio_dispose;
+}
+
+static void
+swfdec_audio_init (SwfdecAudio *audio)
+{
+}
+
+/**
+ * swfdec_audio_add:
+ * @audio: audio to add
+ * @player: a #SwfdecPlayer to attach to or NULL
+ *
+ * Registers a new audio object for playback in @player. If player is %NULL,
+ * this function does nothing.
+ * The starting point of the audio stream will be equivalent the player's time.
+ **/
+void
+swfdec_audio_add (SwfdecAudio *audio, SwfdecPlayer *player)
+{
+ SwfdecPlayerPrivate *priv;
+
+ g_return_if_fail (SWFDEC_IS_AUDIO (audio));
+ g_return_if_fail (audio->player == NULL);
+ if (player == NULL)
+ return;
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+ g_object_ref (audio);
+ audio->player = player;
+ priv = player->priv;
+ priv->audio = g_list_append (priv->audio, audio);
+ SWFDEC_INFO ("adding %s %p", G_OBJECT_TYPE_NAME (audio), audio);
+}
+
+void
+swfdec_audio_remove (SwfdecAudio *audio)
+{
+ g_return_if_fail (SWFDEC_IS_AUDIO (audio));
+
+ if (audio->player != NULL) {
+ SwfdecPlayerPrivate *priv = audio->player->priv;
+ SWFDEC_INFO ("removing %s %p", G_OBJECT_TYPE_NAME (audio), audio);
+ priv->audio = g_list_remove (priv->audio, audio);
+ if (audio->added) {
+ g_signal_emit_by_name (audio->player, "audio-removed", audio);
+ audio->added = FALSE;
+ }
+ audio->player = NULL;
+ g_object_unref (audio);
+ }
+}
+
+/**
+ * swfdec_audio_iterate:
+ * @audio: the #SwfdecAudio to iterate
+ * @n_samples: number of samples to remove
+ *
+ * Iterates the @audio. Iterating means discarding the first @n_samples
+ * samples of the audio stream.
+ *
+ * Returns: maximum number of remaining frames. If G_MAXUINT is returned,
+ * then the number of frames isn't known yet.
+ **/
+guint
+swfdec_audio_iterate (SwfdecAudio *audio, guint n_samples)
+{
+ SwfdecAudioClass *klass;
+
+ g_return_val_if_fail (SWFDEC_IS_AUDIO (audio), 0);
+ g_return_val_if_fail (n_samples > 0, 0);
+
+ klass = SWFDEC_AUDIO_GET_CLASS (audio);
+ g_assert (klass->iterate);
+ return klass->iterate (audio, n_samples);
+}
+
+/**
+ * swfdec_audio_render:
+ * @audio: a #SwfdecAudio
+ * @dest: memory area to render to
+ * @start_offset: offset in samples at which to start rendering. The offset is
+ * calculated relative to the last iteration, so the value set
+ * by swfdec_player_set_audio_advance() is ignored.
+ * @n_samples: amount of samples to render.
+ *
+ * Renders the samples from @audio into the area pointed to by @dest. The data
+ * is added to @dest, so you probably want to initialize @dest to silence
+ * before calling this function.
+ **/
+void
+swfdec_audio_render (SwfdecAudio *audio, gint16 *dest,
+ guint start_offset, guint n_samples)
+{
+ SwfdecAudioClass *klass;
+
+ g_return_if_fail (SWFDEC_IS_AUDIO (audio));
+ g_return_if_fail (dest != NULL);
+ g_return_if_fail (n_samples > 0);
+
+ klass = SWFDEC_AUDIO_GET_CLASS (audio);
+ klass->render (audio, dest, start_offset, n_samples);
+}
+
+/**
+ * swfdec_player_render_audio:
+ * @player: a #SwfdecPlayer
+ * @dest: location to add audio signal to. The audio signal will be in
+ * 44100kHz signed 16bit stereo.
+ * @start_offset: offset in samples at which to start rendering. The offset is
+ * calculated relative to the last iteration, so the value set
+ * by swfdec_player_set_audio_advance() is ignored.
+ * @n_samples: amount of samples to render.
+ *
+ * Renders the data for this frame into the given location. The data is added to @dest,
+ * so you probably want to initialize @dest to silence before calling this function.
+ **/
+void
+swfdec_player_render_audio (SwfdecPlayer *player, gint16* dest,
+ guint start_offset, guint n_samples)
+{
+ GList *walk;
+ SwfdecAudio *audio;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (dest != NULL);
+ g_return_if_fail (n_samples > 0);
+
+ SWFDEC_LOG ("rendering offset %u, samples %u", start_offset, n_samples);
+ for (walk = player->priv->audio; walk; walk = walk->next) {
+ audio = walk->data;
+ swfdec_audio_render (audio, dest, start_offset, n_samples);
+ }
+}
+
+/*** SWFDEC_AUDIO_FORMAT ***/
+
+/* SwfdecAudioFormat is represented in the least significant bits of a uint:
+ * - the LSBit is 1 if it's 16bit audio, 0 for 8bit
+ * - the next bit is 1 for stereo, 0 for mono
+ * - the other two bits are for the rate, see swfdec_audio_format_new()
+ * This is the same format the Flash file format uses to store audio formats.
+ */
+
+SwfdecAudioFormat
+swfdec_audio_format_parse (SwfdecBits *bits)
+{
+ g_return_val_if_fail (bits != NULL, 0);
+
+ return swfdec_bits_getbits (bits, 4);
+}
+
+SwfdecAudioFormat
+swfdec_audio_format_new (guint rate, guint channels, gboolean is_16bit)
+{
+ SwfdecAudioFormat ret;
+
+ g_return_val_if_fail (channels == 1 || channels == 2, 0);
+
+ switch (rate) {
+ case 44100:
+ ret = 3 << 2;
+ break;
+ case 22050:
+ ret = 2 << 2;
+ break;
+ case 11025:
+ ret = 1 << 2;
+ break;
+ case 5512:
+ ret = 0 << 2;
+ break;
+ default:
+ g_return_val_if_reached (0);
+ break;
+ }
+ if (is_16bit)
+ ret |= 2;
+ if (channels == 2)
+ ret |= 1;
+
+ return ret;
+}
+
+guint
+swfdec_audio_format_get_channels (SwfdecAudioFormat format)
+{
+ g_return_val_if_fail (SWFDEC_IS_AUDIO_FORMAT (format), 2);
+
+ return (format & 0x1) + 1;
+}
+
+gboolean
+swfdec_audio_format_is_16bit (SwfdecAudioFormat format)
+{
+ g_return_val_if_fail (SWFDEC_IS_AUDIO_FORMAT (format), TRUE);
+
+ return format & 0x2 ? TRUE : FALSE;
+}
+
+guint
+swfdec_audio_format_get_rate (SwfdecAudioFormat format)
+{
+ g_return_val_if_fail (SWFDEC_IS_AUDIO_FORMAT (format), 44100);
+
+ return 44100 / swfdec_audio_format_get_granularity (format);
+}
+
+/**
+ * swfdec_audio_format_get_granularity:
+ * @format: an auio format
+ *
+ * The granularity is a Swfdec-specific name, describing how often a sample in
+ * a 44100Hz audio stream is defined. So for example 44100Hz has a granularity
+ * of 1 and 11025Hz has a granularity of 4 (because only every fourth sample
+ * is defined).
+ *
+ * Returns: the granularity of the format
+ **/
+guint
+swfdec_audio_format_get_granularity (SwfdecAudioFormat format)
+{
+ g_return_val_if_fail (SWFDEC_IS_AUDIO_FORMAT (format), 1);
+
+ return 1 << (3 - (format >> 2));
+}
+
+const char *
+swfdec_audio_format_to_string (SwfdecAudioFormat format)
+{
+ static const char *names[] = {
+ "8bit 5.5kHz mono",
+ "8bit 5.5kHz stereo",
+ "16bit 5.5kHz mono",
+ "16bit 5.5kHz stereo",
+ "8bit 11kHz mono",
+ "8bit 11kHz stereo",
+ "16bit 11kHz mono",
+ "16bit 11kHz stereo",
+ "8bit 22kHz mono",
+ "8bit 22kHz stereo",
+ "16bit 22kHz mono",
+ "16bit 22kHz stereo",
+ "8bit 44kHz mono",
+ "8bit 44kHz stereo",
+ "16bit 44kHz mono",
+ "16bit 44kHz stereo"
+ };
+ g_return_val_if_fail (SWFDEC_IS_AUDIO_FORMAT (format), "");
+
+ return names[format];
+}
+
+/**
+ * swfdec_audio_format_get_bytes_per_sample:
+ * @format: audio format to check
+ *
+ * Computes the number of bytes required to store one sample of audio encoded
+ * in @format.
+ *
+ * Returns: The number of bytes for one sample
+ **/
+guint
+swfdec_audio_format_get_bytes_per_sample (SwfdecAudioFormat format)
+{
+ guint bps[4] = { 1, 2, 2, 4 };
+
+ g_return_val_if_fail (SWFDEC_IS_AUDIO_FORMAT (format), 1);
+
+ return bps [format & 0x3];
+}
+
diff --git a/swfdec/swfdec_audio.h b/swfdec/swfdec_audio.h
new file mode 100644
index 0000000..4352faf
--- /dev/null
+++ b/swfdec/swfdec_audio.h
@@ -0,0 +1,47 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AUDIO_H_
+#define _SWFDEC_AUDIO_H_
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecAudio SwfdecAudio;
+typedef struct _SwfdecAudioClass SwfdecAudioClass;
+
+#define SWFDEC_TYPE_AUDIO (swfdec_audio_get_type())
+#define SWFDEC_IS_AUDIO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AUDIO))
+#define SWFDEC_IS_AUDIO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AUDIO))
+#define SWFDEC_AUDIO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AUDIO, SwfdecAudio))
+#define SWFDEC_AUDIO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AUDIO, SwfdecAudioClass))
+#define SWFDEC_AUDIO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AUDIO, SwfdecAudioClass))
+
+GType swfdec_audio_get_type (void);
+
+void swfdec_audio_render (SwfdecAudio * audio,
+ gint16 * dest,
+ guint start_offset,
+ guint n_samples);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_audio_event.c b/swfdec/swfdec_audio_event.c
new file mode 100644
index 0000000..fa43359
--- /dev/null
+++ b/swfdec/swfdec_audio_event.c
@@ -0,0 +1,330 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include "swfdec_audio_event.h"
+#include "swfdec_debug.h"
+#include "swfdec_player_internal.h"
+
+
+G_DEFINE_TYPE (SwfdecAudioEvent, swfdec_audio_event, SWFDEC_TYPE_AUDIO)
+
+
+static guint
+swfdec_audio_event_iterate (SwfdecAudio *audio, guint remove)
+{
+ SwfdecAudioEvent *event = SWFDEC_AUDIO_EVENT (audio);
+
+ if (event->n_samples == 0)
+ return 0;
+
+ event->offset += remove;
+ event->loop += event->offset / event->n_samples;
+ event->offset %= event->n_samples;
+
+ if (event->loop < event->n_loops)
+ return event->n_samples * (event->n_loops - event->loop) - event->offset;
+ else
+ return 0;
+}
+
+static guint16
+swfdec_audio_event_get_envelop_volume (SwfdecAudioEvent *event, guint pos,
+ guint offset, guint channel)
+{
+ double distance;
+
+ g_return_val_if_fail (SWFDEC_IS_AUDIO_EVENT (event), 32768);
+ g_return_val_if_fail (pos <= event->n_envelopes, 32768);
+ g_return_val_if_fail (channel == 0 || channel == 1, 32768);
+
+ if (event->n_envelopes == 0)
+ return 32768;
+
+ if (pos == 0)
+ return event->envelope[pos].volume[channel];
+
+ if (pos == event->n_envelopes)
+ return event->envelope[pos - 1].volume[channel];
+
+ distance = event->envelope[pos].offset - event->envelope[pos - 1].offset;
+ g_return_val_if_fail (offset >= event->envelope[pos - 1].offset, 1);
+ offset -= event->envelope[pos - 1].offset;
+ g_return_val_if_fail (offset < distance, 1);
+
+ return event->envelope[pos - 1].volume[channel] * (1 - offset / distance) +
+ event->envelope[pos].volume[channel] * (offset / distance);
+}
+
+static void
+swfdec_audio_event_render (SwfdecAudio *audio, gint16* dest, guint start,
+ guint n_samples)
+{
+ SwfdecAudioEvent *event = SWFDEC_AUDIO_EVENT (audio);
+ guint offset = event->offset + start;
+ guint loop, samples, global_offset, pos, i, granularity, channels;
+ gint16 *dest_end;
+
+ if (event->n_samples == 0)
+ return;
+
+ granularity = swfdec_audio_format_get_granularity (event->decoded_format);
+ channels = swfdec_audio_format_get_channels (event->decoded_format);
+
+ global_offset = (channels - 1) * granularity * (event->loop *
+ ((event->stop_sample != 0 ? event->stop_sample : event->n_samples) -
+ event->start_sample) + event->offset - event->start_sample);
+
+ dest_end = dest;
+ loop = event->loop + offset / event->n_samples;
+ offset %= event->n_samples;
+ for (; loop < event->n_loops && n_samples > 0; loop++) {
+ samples = MIN (n_samples, event->n_samples - offset);
+ swfdec_sound_buffer_render (dest_end, event->decoded,
+ event->decoded_format, loop == 0 ? NULL : event->decoded, offset,
+ samples);
+ n_samples -= samples;
+ dest_end += samples * 2;
+ offset = 0;
+ }
+
+ if (event->n_envelopes == 0)
+ return;
+
+ pos = 0;
+ for (i = 0; i < (guint) (dest_end - dest); i++) {
+ while (pos < event->n_envelopes &&
+ event->envelope[pos].offset <= global_offset + (i / 2))
+ pos++;
+ if (channels == 1) {
+ dest[i] *= (swfdec_audio_event_get_envelop_volume (event, pos,
+ global_offset + (i / 2), 0) * 0.5 +
+ swfdec_audio_event_get_envelop_volume (event, pos,
+ global_offset + (i / 2), 1) * 0.5) / 32768.0;
+ } else {
+ dest[i] *= swfdec_audio_event_get_envelop_volume (event, pos,
+ global_offset + (i / 2), i % 2) / 32768.0;
+ }
+ }
+}
+
+static void
+swfdec_audio_event_dispose (GObject *object)
+{
+ SwfdecAudioEvent *audio = SWFDEC_AUDIO_EVENT (object);
+
+ g_free (audio->envelope);
+ audio->envelope = NULL;
+ audio->n_envelopes = 0;
+ if (audio->decoded) {
+ swfdec_buffer_unref (audio->decoded);
+ audio->decoded = NULL;
+ }
+
+ G_OBJECT_CLASS (swfdec_audio_event_parent_class)->dispose (object);
+}
+
+static void
+swfdec_audio_event_class_init (SwfdecAudioEventClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ SwfdecAudioClass *audio_class = SWFDEC_AUDIO_CLASS (klass);
+
+ object_class->dispose = swfdec_audio_event_dispose;
+
+ audio_class->iterate = swfdec_audio_event_iterate;
+ audio_class->render = swfdec_audio_event_render;
+}
+
+static void
+swfdec_audio_event_init (SwfdecAudioEvent *audio_event)
+{
+}
+
+static void
+swfdec_audio_event_decode (SwfdecAudioEvent *event)
+{
+ guint granule, bytes_per_sample;
+
+ event->decoded = swfdec_sound_get_decoded (event->sound,
+ &event->decoded_format);
+ if (event->decoded == NULL) {
+ SWFDEC_INFO ("Could not decode audio. Will assume %u samples of silence instead.",
+ event->sound->n_samples);
+ event->decoded = swfdec_buffer_new_and_alloc0 (event->sound->n_samples / 4);
+ event->decoded_format = swfdec_audio_format_new (5512, 1, FALSE);
+ } else {
+ swfdec_buffer_ref (event->decoded);
+ }
+ granule = swfdec_audio_format_get_granularity (event->decoded_format);
+ bytes_per_sample = swfdec_audio_format_get_channels (event->decoded_format) *
+ (swfdec_audio_format_is_16bit (event->decoded_format) ? 2 : 1);
+ if (event->start_sample) {
+ guint skip;
+ if (event->start_sample % granule) {
+ SWFDEC_FIXME ("figure out how high resolution start samples work");
+ }
+ skip = bytes_per_sample * (event->start_sample / granule);
+ if (skip >= event->decoded->length) {
+ SWFDEC_WARNING ("start sample %u > total number of samples %"G_GSIZE_FORMAT,
+ event->start_sample / granule, event->decoded->length / bytes_per_sample);
+ swfdec_buffer_unref (event->decoded);
+ event->decoded = swfdec_buffer_new ();
+ } else {
+ SwfdecBuffer *sub = swfdec_buffer_new_subbuffer (event->decoded,
+ skip, event->decoded->length - skip);
+ swfdec_buffer_unref (event->decoded);
+ event->decoded = sub;
+ }
+ }
+ if (event->stop_sample) {
+ guint keep;
+ if (event->stop_sample % granule) {
+ SWFDEC_FIXME ("figure out how high resolution stop samples work");
+ }
+ keep = bytes_per_sample * (event->stop_sample / granule - event->start_sample / granule);
+ if (keep > event->decoded->length) {
+ SWFDEC_WARNING ("stop sample %u outside of decoded number of samples %"G_GSIZE_FORMAT,
+ event->stop_sample / granule, event->decoded->length / bytes_per_sample +
+ event->start_sample / granule);
+ } else if (keep < event->decoded->length) {
+ SwfdecBuffer *sub = swfdec_buffer_new_subbuffer (event->decoded,
+ 0, keep);
+ swfdec_buffer_unref (event->decoded);
+ event->decoded = sub;
+ }
+ }
+ event->n_samples = event->decoded->length / bytes_per_sample * granule;
+ SWFDEC_LOG ("total 44100Hz samples: %u", event->n_samples);
+}
+
+static SwfdecAudioEvent *
+swfdec_audio_event_create (SwfdecSound *sound, guint offset, guint end_offset, guint n_loops)
+{
+ SwfdecAudioEvent *event;
+
+ event = g_object_new (SWFDEC_TYPE_AUDIO_EVENT, NULL);
+ event->sound = sound;
+ event->start_sample = offset;
+ event->n_loops = n_loops;
+ event->stop_sample = end_offset;
+ swfdec_audio_event_decode (event);
+ event->offset = 0;
+
+ return event;
+}
+
+/**
+ * swfdec_audio_event_new:
+ * @player: the #SwfdecPlayer to play the sound in
+ * @sound: the sound to be played
+ * @offset: offset into sound at which to start playing
+ * @n_loops: number of times the sound should be played
+ *
+ * Starts playing back a sound from the given offset and loops the sound
+ * @n_loops times.
+ *
+ * Returns: a new #SwfdecAudio
+ **/
+SwfdecAudio *
+swfdec_audio_event_new (SwfdecPlayer *player, SwfdecSound *sound, guint offset,
+ guint n_loops)
+{
+ SwfdecAudioEvent *event;
+
+ g_return_val_if_fail (player == NULL || SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (SWFDEC_IS_SOUND (sound), NULL);
+
+ event = swfdec_audio_event_create (sound, offset, 0, n_loops);
+ swfdec_audio_add (SWFDEC_AUDIO (event), player);
+
+ return SWFDEC_AUDIO (event);
+}
+
+static SwfdecAudio *
+swfdec_audio_event_get (SwfdecPlayer *player, SwfdecSound *sound)
+{
+ GList *walk;
+
+ if (player == NULL)
+ return NULL;
+
+ for (walk = player->priv->audio; walk; walk = walk->next) {
+ SwfdecAudio *audio = walk->data;
+ if (!SWFDEC_IS_AUDIO_EVENT (audio))
+ continue;
+ if (SWFDEC_AUDIO_EVENT (audio)->sound == sound) {
+ return audio;
+ }
+ }
+ return NULL;
+}
+
+/**
+ * swfdec_audio_event_new_from_chunk:
+ * @player: a #SwfdecPlayer or NULL
+ * @event: a sound event to start playing back
+ *
+ * Starts playback of the given sound event (or, when @player is NULL, creates
+ * an element for playing back the given sound).
+ *
+ * Returns: the sound effect or NULL if no new sound was created.
+ **/
+SwfdecAudio *
+swfdec_audio_event_new_from_chunk (SwfdecPlayer *player, SwfdecSoundChunk *chunk)
+{
+ SwfdecAudioEvent *event;
+
+ g_return_val_if_fail (player == NULL || SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (chunk != NULL, NULL);
+
+ if (chunk->stop) {
+ SwfdecAudio *audio = swfdec_audio_event_get (player, chunk->sound);
+ if (audio) {
+ SWFDEC_LOG ("stopping sound %d", SWFDEC_CHARACTER (chunk->sound)->id);
+ swfdec_audio_remove (audio);
+ }
+ return NULL;
+ }
+ SWFDEC_LOG ("adding sound %d to playing sounds", SWFDEC_CHARACTER (chunk->sound)->id);
+ if (chunk->no_restart &&
+ (event = (SwfdecAudioEvent *) swfdec_audio_event_get (player, chunk->sound))) {
+ SWFDEC_DEBUG ("sound %d is already playing, reusing it",
+ SWFDEC_CHARACTER (event->sound)->id);
+ g_object_ref (event);
+ return SWFDEC_AUDIO (event);
+ }
+ event = swfdec_audio_event_create (chunk->sound, chunk->start_sample,
+ chunk->stop_sample, chunk->loop_count);
+ event->n_envelopes = chunk->n_envelopes;
+ if (event->n_envelopes)
+ event->envelope = g_memdup (chunk->envelope, sizeof (SwfdecSoundEnvelope) * event->n_envelopes);
+ SWFDEC_DEBUG ("playing sound %d from offset %d now", SWFDEC_CHARACTER (event->sound)->id,
+ event->start_sample);
+ swfdec_audio_add (SWFDEC_AUDIO (event), player);
+
+ return SWFDEC_AUDIO (event);
+}
+
diff --git a/swfdec/swfdec_audio_event.h b/swfdec/swfdec_audio_event.h
new file mode 100644
index 0000000..40a0eb6
--- /dev/null
+++ b/swfdec/swfdec_audio_event.h
@@ -0,0 +1,74 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AUDIO_EVENT_H_
+#define _SWFDEC_AUDIO_EVENT_H_
+
+#include <libswfdec/swfdec_audio_internal.h>
+#include <libswfdec/swfdec_sound.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecAudioEvent SwfdecAudioEvent;
+typedef struct _SwfdecAudioEventClass SwfdecAudioEventClass;
+
+#define SWFDEC_TYPE_AUDIO_EVENT (swfdec_audio_event_get_type())
+#define SWFDEC_IS_AUDIO_EVENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AUDIO_EVENT))
+#define SWFDEC_IS_AUDIO_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AUDIO_EVENT))
+#define SWFDEC_AUDIO_EVENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AUDIO_EVENT, SwfdecAudioEvent))
+#define SWFDEC_AUDIO_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AUDIO_EVENT, SwfdecAudioEventClass))
+#define SWFDEC_AUDIO_EVENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AUDIO_EVENT, SwfdecAudioEventClass))
+
+struct _SwfdecAudioEvent
+{
+ SwfdecAudio audio;
+
+ /* static data */
+ SwfdecSound * sound; /* sound we're playing */
+ guint start_sample; /* sample at which to start playing */
+ guint stop_sample; /* first sample to not play anymore or 0 for playing all */
+ guint n_loops; /* amount of times this sample still needs to be played back */
+ guint n_envelopes; /* amount of points in the envelope */
+ SwfdecSoundEnvelope * envelope; /* volume envelope or NULL if none */
+ /* dynamic data */
+ SwfdecBuffer * decoded; /* the decoded buffer we play back */
+ SwfdecAudioFormat decoded_format; /* format of the decoded buffer */
+ guint offset; /* current offset in 44.1kHz */
+ guint loop; /* current loop we're in */
+ guint n_samples; /* length of decoded buffer in 44.1kHz samples - can be 0 */
+};
+
+struct _SwfdecAudioEventClass
+{
+ SwfdecAudioClass audio_class;
+};
+
+GType swfdec_audio_event_get_type (void);
+
+SwfdecAudio * swfdec_audio_event_new (SwfdecPlayer * player,
+ SwfdecSound * sound,
+ guint offset,
+ guint n_loops);
+SwfdecAudio * swfdec_audio_event_new_from_chunk (SwfdecPlayer * player,
+ SwfdecSoundChunk * chunk);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_audio_flv.c b/swfdec/swfdec_audio_flv.c
new file mode 100644
index 0000000..59de5c5
--- /dev/null
+++ b/swfdec/swfdec_audio_flv.c
@@ -0,0 +1,227 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include "swfdec_audio_flv.h"
+#include "swfdec_debug.h"
+#include "swfdec_sound.h"
+
+
+G_DEFINE_TYPE (SwfdecAudioFlv, swfdec_audio_flv, SWFDEC_TYPE_AUDIO)
+
+static void
+swfdec_audio_flv_dispose (GObject *object)
+{
+ SwfdecAudioFlv *flv = SWFDEC_AUDIO_FLV (object);
+
+ if (flv->decoder != NULL) {
+ swfdec_audio_decoder_free (flv->decoder);
+ flv->decoder = NULL;
+ }
+ g_queue_foreach (flv->playback_queue, (GFunc) swfdec_buffer_unref, NULL);
+ g_queue_free (flv->playback_queue);
+ g_object_unref (flv->flvdecoder);
+
+ G_OBJECT_CLASS (swfdec_audio_flv_parent_class)->dispose (object);
+}
+
+static SwfdecBuffer *
+swfdec_audio_flv_decode_one (SwfdecAudioFlv *flv)
+{
+ SwfdecBuffer *buffer;
+ guint format;
+ SwfdecAudioFormat in;
+ guint now, soon;
+
+ if (g_queue_is_empty (flv->playback_queue)) {
+ /* sync */
+ guint last;
+ swfdec_flv_decoder_get_audio (flv->flvdecoder,
+ SWFDEC_TICKS_TO_MSECS (flv->timestamp),
+ NULL, NULL, &last, NULL);
+ flv->playback_skip = SWFDEC_TICKS_TO_SAMPLES (
+ flv->timestamp - SWFDEC_MSECS_TO_TICKS (last));
+ flv->next_timestamp = last;
+ SWFDEC_DEBUG ("syncing to %ums: next timestamp to decode is %ums, skipping %u samples",
+ (guint) SWFDEC_TICKS_TO_MSECS (flv->timestamp),
+ flv->next_timestamp, flv->playback_skip);
+ }
+ if (flv->decoder)
+ buffer = swfdec_audio_decoder_pull (flv->decoder);
+ else
+ buffer = NULL;
+ while (buffer == NULL) {
+ if (flv->decoder && flv->next_timestamp == 0)
+ return NULL;
+ buffer = swfdec_flv_decoder_get_audio (flv->flvdecoder, flv->next_timestamp,
+ &format, &in, &now, &soon);
+
+ if (flv->next_timestamp != now) {
+ /* FIXME: do sync on first frame here */
+ SWFDEC_WARNING ("FIXME: didn't get requested timestamp - still loading?");
+ }
+ /* FIXME FIXME FIXME: This avoids decoding the last frame forever, however it ensures sync */
+ if (soon == 0)
+ return NULL;
+ flv->next_timestamp = soon;
+ if (flv->in == 0) {
+ /* init */
+ if (flv->decoder) {
+ swfdec_audio_decoder_free (flv->decoder);
+ flv->decoder = NULL;
+ }
+ flv->format = format;
+ flv->in = in;
+ flv->decoder = swfdec_audio_decoder_new (flv->format, flv->in);
+ if (flv->decoder == NULL)
+ return NULL;
+ } else if (format != flv->format ||
+ in != flv->in) {
+ SWFDEC_ERROR ("FIXME: format change not implemented");
+ return NULL;
+ } else if (flv->decoder == NULL) {
+ return NULL;
+ }
+ swfdec_audio_decoder_push (flv->decoder, buffer);
+ if (flv->next_timestamp == 0)
+ swfdec_audio_decoder_push (flv->decoder, NULL);
+ buffer = swfdec_audio_decoder_pull (flv->decoder);
+ }
+
+ g_queue_push_tail (flv->playback_queue, buffer);
+ return buffer;
+}
+
+static void
+swfdec_audio_flv_render (SwfdecAudio *audio, gint16* dest,
+ guint start, guint n_samples)
+{
+ SwfdecAudioFlv *flv = SWFDEC_AUDIO_FLV (audio);
+ GList *walk;
+ guint samples;
+ SwfdecBuffer *buffer, *previous;
+
+ g_assert (start < G_MAXINT);
+ start += flv->playback_skip;
+ SWFDEC_LOG ("flv %p rendering offset %u, samples %u", flv, start, n_samples);
+ walk = g_queue_peek_head_link (flv->playback_queue);
+ previous = NULL;
+ while (n_samples) {
+ if (walk) {
+ buffer = walk->data;
+ walk = walk->next;
+ } else {
+ buffer = swfdec_audio_flv_decode_one (flv);
+ if (!buffer)
+ break;
+ }
+ samples = swfdec_sound_buffer_get_n_samples (buffer,
+ swfdec_audio_decoder_get_format (flv->decoder));
+ if (start) {
+ if (samples <= start) {
+ start -= samples;
+ continue;
+ }
+ samples -= start;
+ SWFDEC_LOG ("rendering %u samples, skipping %u",
+ samples, start);
+ } else {
+ SWFDEC_LOG ("rendering %u samples", samples);
+ }
+ samples = MIN (samples, n_samples);
+ swfdec_sound_buffer_render (dest, buffer,
+ swfdec_audio_decoder_get_format (flv->decoder), previous, start,
+ samples);
+ start = 0;
+ n_samples -= samples;
+ dest += 2 * samples;
+ previous = buffer;
+ }
+}
+
+static guint
+swfdec_audio_flv_iterate (SwfdecAudio *audio, guint remove)
+{
+ SwfdecAudioFlv *flv = SWFDEC_AUDIO_FLV (audio);
+ SwfdecBuffer *buffer;
+ guint next;
+
+ flv->playback_skip += remove;
+ buffer = g_queue_peek_head (flv->playback_queue);
+ while (buffer && flv->playback_skip >=
+ swfdec_sound_buffer_get_n_samples (buffer, swfdec_audio_decoder_get_format (flv->decoder))
+ + swfdec_audio_format_get_granularity (swfdec_audio_decoder_get_format (flv->decoder))) {
+ buffer = g_queue_pop_head (flv->playback_queue);
+ SWFDEC_LOG ("removing buffer with %u samples",
+ swfdec_sound_buffer_get_n_samples (buffer,
+ swfdec_audio_decoder_get_format (flv->decoder)));
+ flv->playback_skip -= swfdec_sound_buffer_get_n_samples (buffer,
+ swfdec_audio_decoder_get_format (flv->decoder));
+ swfdec_buffer_unref (buffer);
+ buffer = g_queue_peek_head (flv->playback_queue);
+ }
+ flv->timestamp += SWFDEC_SAMPLES_TO_TICKS (remove);
+
+ if (!g_queue_is_empty (flv->playback_queue))
+ return G_MAXUINT;
+ swfdec_flv_decoder_get_audio (flv->flvdecoder,
+ SWFDEC_TICKS_TO_MSECS (flv->timestamp),
+ NULL, NULL, NULL, &next);
+ return next ? G_MAXUINT : 0;
+}
+
+static void
+swfdec_audio_flv_class_init (SwfdecAudioFlvClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ SwfdecAudioClass *audio_class = SWFDEC_AUDIO_CLASS (klass);
+
+ object_class->dispose = swfdec_audio_flv_dispose;
+
+ audio_class->iterate = swfdec_audio_flv_iterate;
+ audio_class->render = swfdec_audio_flv_render;
+}
+
+static void
+swfdec_audio_flv_init (SwfdecAudioFlv *flv)
+{
+ flv->playback_queue = g_queue_new ();
+}
+
+SwfdecAudio *
+swfdec_audio_flv_new (SwfdecPlayer *player, SwfdecFlvDecoder *decoder, guint timestamp)
+{
+ SwfdecAudioFlv *flv;
+
+ flv = g_object_new (SWFDEC_TYPE_AUDIO_FLV, NULL);
+
+ SWFDEC_DEBUG ("new audio flv for decoder %p, starting at %ums",
+ decoder, timestamp);
+ g_object_ref (decoder);
+ flv->flvdecoder = decoder;
+ flv->timestamp = SWFDEC_MSECS_TO_TICKS (timestamp);
+ swfdec_audio_add (SWFDEC_AUDIO (flv), player);
+
+ return SWFDEC_AUDIO (flv);
+}
+
diff --git a/swfdec/swfdec_audio_flv.h b/swfdec/swfdec_audio_flv.h
new file mode 100644
index 0000000..52ac2a5
--- /dev/null
+++ b/swfdec/swfdec_audio_flv.h
@@ -0,0 +1,66 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AUDIO_FLV_H_
+#define _SWFDEC_AUDIO_FLV_H_
+
+#include <libswfdec/swfdec_audio_internal.h>
+#include <libswfdec/swfdec_flv_decoder.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecAudioFlv SwfdecAudioFlv;
+typedef struct _SwfdecAudioFlvClass SwfdecAudioFlvClass;
+
+#define SWFDEC_TYPE_AUDIO_FLV (swfdec_audio_flv_get_type())
+#define SWFDEC_IS_AUDIO_FLV(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AUDIO_FLV))
+#define SWFDEC_IS_AUDIO_FLV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AUDIO_FLV))
+#define SWFDEC_AUDIO_FLV(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AUDIO_FLV, SwfdecAudioFlv))
+#define SWFDEC_AUDIO_FLV_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AUDIO_FLV, SwfdecAudioFlvClass))
+#define SWFDEC_AUDIO_FLV_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AUDIO_FLV, SwfdecAudioFlvClass))
+
+struct _SwfdecAudioFlv
+{
+ SwfdecAudio audio;
+
+ SwfdecFlvDecoder * flvdecoder; /* decoder we play back */
+ guint format; /* codec format of audio */
+ gboolean width; /* width of audio */
+ SwfdecAudioFormat in; /* input format of data */
+ SwfdecAudioDecoder * decoder; /* decoder used for playback */
+
+ SwfdecTick timestamp; /* current playback timestamp */
+ guint next_timestamp; /* next timestamp in FLV file we request from */
+ guint playback_skip; /* number of samples to skip at start of queue */
+ GQueue * playback_queue; /* all the samples we've decoded so far */
+};
+
+struct _SwfdecAudioFlvClass
+{
+ SwfdecAudioClass audio_class;
+};
+
+GType swfdec_audio_flv_get_type (void);
+
+SwfdecAudio * swfdec_audio_flv_new (SwfdecPlayer * player,
+ SwfdecFlvDecoder * decoder,
+ guint timestamp);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_audio_internal.h b/swfdec/swfdec_audio_internal.h
new file mode 100644
index 0000000..512f6e7
--- /dev/null
+++ b/swfdec/swfdec_audio_internal.h
@@ -0,0 +1,77 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AUDIO_INTERNAL_H_
+#define _SWFDEC_AUDIO_INTERNAL_H_
+
+#include <libswfdec/swfdec.h>
+#include <libswfdec/swfdec_audio.h>
+#include <libswfdec/swfdec_bits.h>
+#include <libswfdec/swfdec_types.h>
+
+G_BEGIN_DECLS
+
+typedef guint SwfdecAudioFormat;
+#define SWFDEC_IS_AUDIO_FORMAT(format) ((format) <= 0xF)
+#define SWFDEC_AUDIO_FORMAT_INVALID ((SwfdecAudioFormat) -1)
+
+
+struct _SwfdecAudio {
+ GObject object;
+
+ SwfdecPlayer * player; /* the player that plays us */
+ gboolean added; /* set to TRUE after the added signal has been emitted */
+};
+
+struct _SwfdecAudioClass {
+ GObjectClass object_class;
+
+ guint (* iterate) (SwfdecAudio * audio,
+ guint n_samples);
+ void (* render) (SwfdecAudio * audio,
+ gint16 * dest,
+ guint start,
+ guint n_samples);
+};
+
+void swfdec_audio_add (SwfdecAudio * audio,
+ SwfdecPlayer * player);
+void swfdec_audio_remove (SwfdecAudio * audio);
+
+guint swfdec_audio_iterate (SwfdecAudio * audio,
+ guint n_samples);
+
+SwfdecAudioFormat swfdec_audio_format_parse (SwfdecBits * bits);
+SwfdecAudioFormat swfdec_audio_format_new (guint rate,
+ guint channels,
+ gboolean is_16bit);
+guint swfdec_audio_format_get_channels(SwfdecAudioFormat format);
+gboolean swfdec_audio_format_is_16bit (SwfdecAudioFormat format);
+guint swfdec_audio_format_get_rate (SwfdecAudioFormat format);
+guint swfdec_audio_format_get_granularity
+ (SwfdecAudioFormat format);
+guint swfdec_audio_format_get_bytes_per_sample
+ (SwfdecAudioFormat format);
+const char * swfdec_audio_format_to_string (SwfdecAudioFormat format);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_audio_stream.c b/swfdec/swfdec_audio_stream.c
new file mode 100644
index 0000000..d4eb6ca
--- /dev/null
+++ b/swfdec/swfdec_audio_stream.c
@@ -0,0 +1,205 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include "swfdec_audio_stream.h"
+#include "swfdec_debug.h"
+#include "swfdec_sound.h"
+#include "swfdec_sprite.h"
+
+
+G_DEFINE_TYPE (SwfdecAudioStream, swfdec_audio_stream, SWFDEC_TYPE_AUDIO)
+
+static void
+swfdec_audio_stream_dispose (GObject *object)
+{
+ SwfdecAudioStream *stream = SWFDEC_AUDIO_STREAM (object);
+
+ if (stream->decoder != NULL) {
+ swfdec_audio_decoder_free (stream->decoder);
+ stream->decoder = NULL;
+ }
+ g_queue_foreach (stream->playback_queue, (GFunc) swfdec_buffer_unref, NULL);
+ g_queue_free (stream->playback_queue);
+
+ G_OBJECT_CLASS (swfdec_audio_stream_parent_class)->dispose (object);
+}
+
+static SwfdecBuffer *
+swfdec_audio_stream_decode_one (SwfdecAudioStream *stream)
+{
+ SwfdecSpriteFrame *frame;
+ SwfdecBuffer *buffer;
+
+ g_assert (!stream->done);
+ if (stream->decoder == NULL)
+ return NULL;
+
+ while (!(buffer = swfdec_audio_decoder_pull (stream->decoder)) &&
+ !stream->done) {
+ if (stream->current_frame >= stream->sprite->n_frames)
+ goto end;
+ frame = &stream->sprite->frames[stream->current_frame];
+ stream->current_frame++;
+ if (frame->sound_head != stream->sound)
+ goto end;
+ if (frame->sound_samples == 0)
+ continue;
+ if (frame->sound_block)
+ swfdec_audio_decoder_push (stream->decoder, frame->sound_block);
+ continue;
+end:
+ swfdec_audio_decoder_push (stream->decoder, NULL);
+ stream->done = TRUE;
+ }
+ return buffer;
+}
+
+static void
+swfdec_audio_stream_render (SwfdecAudio *audio, gint16* dest,
+ guint start, guint n_samples)
+{
+ SwfdecAudioStream *stream = SWFDEC_AUDIO_STREAM (audio);
+ GList *walk;
+ guint samples;
+ SwfdecBuffer *buffer, *previous;
+
+ g_assert (start < G_MAXINT);
+ start += stream->playback_skip;
+ SWFDEC_LOG ("stream %p rendering offset %u, samples %u", stream, start, n_samples);
+ walk = g_queue_peek_head_link (stream->playback_queue);
+ previous = NULL;
+ while (n_samples) {
+ if (walk) {
+ buffer = walk->data;
+ walk = walk->next;
+ } else {
+ if (stream->done)
+ break;
+ buffer = swfdec_audio_stream_decode_one (stream);
+ if (!buffer)
+ break;
+ g_queue_push_tail (stream->playback_queue, buffer);
+ }
+ samples = swfdec_sound_buffer_get_n_samples (buffer,
+ swfdec_audio_decoder_get_format (stream->decoder));
+ if (start) {
+ if (samples <= start) {
+ start -= samples;
+ continue;
+ }
+ samples -= start;
+ SWFDEC_LOG ("rendering %u samples, skipping %u",
+ samples, start);
+ } else {
+ SWFDEC_LOG ("rendering %u samples", samples);
+ }
+ samples = MIN (samples, n_samples);
+ swfdec_sound_buffer_render (dest, buffer,
+ swfdec_audio_decoder_get_format (stream->decoder),
+ previous, start, samples);
+ start = 0;
+ n_samples -= samples;
+ dest += 2 * samples;
+ previous = buffer;
+ }
+}
+
+static guint
+swfdec_audio_stream_iterate (SwfdecAudio *audio, guint remove)
+{
+ SwfdecAudioStream *stream = SWFDEC_AUDIO_STREAM (audio);
+ SwfdecBuffer *buffer;
+
+ stream->playback_skip += remove;
+ buffer = g_queue_peek_head (stream->playback_queue);
+ while (buffer && stream->playback_skip >=
+ swfdec_sound_buffer_get_n_samples (buffer, swfdec_audio_decoder_get_format (stream->decoder))
+ + swfdec_audio_format_get_granularity (swfdec_audio_decoder_get_format (stream->decoder))) {
+ buffer = g_queue_pop_head (stream->playback_queue);
+ SWFDEC_LOG ("removing buffer with %u samples",
+ swfdec_sound_buffer_get_n_samples (buffer,
+ swfdec_audio_decoder_get_format (stream->decoder)));
+ stream->playback_skip -= swfdec_sound_buffer_get_n_samples (buffer,
+ swfdec_audio_decoder_get_format (stream->decoder));
+ swfdec_buffer_unref (buffer);
+ buffer = g_queue_peek_head (stream->playback_queue);
+ }
+
+ if (!stream->done) {
+ return G_MAXUINT;
+ } else {
+ GList *walk;
+ guint ret = 0;
+ SwfdecAudioFormat format = swfdec_audio_decoder_get_format (stream->decoder);
+
+ for (walk = g_queue_peek_head_link (stream->playback_queue); walk; walk = walk->next) {
+ ret += swfdec_sound_buffer_get_n_samples (walk->data, format);
+ }
+ return ret - stream->playback_skip;
+ }
+}
+
+static void
+swfdec_audio_stream_class_init (SwfdecAudioStreamClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ SwfdecAudioClass *audio_class = SWFDEC_AUDIO_CLASS (klass);
+
+ object_class->dispose = swfdec_audio_stream_dispose;
+
+ audio_class->iterate = swfdec_audio_stream_iterate;
+ audio_class->render = swfdec_audio_stream_render;
+}
+
+static void
+swfdec_audio_stream_init (SwfdecAudioStream *stream)
+{
+ stream->playback_queue = g_queue_new ();
+}
+
+SwfdecAudio *
+swfdec_audio_stream_new (SwfdecPlayer *player, SwfdecSprite *sprite, guint start_frame)
+{
+ SwfdecAudioStream *stream;
+ SwfdecSpriteFrame *frame;
+
+ stream = g_object_new (SWFDEC_TYPE_AUDIO_STREAM, NULL);
+
+ SWFDEC_DEBUG ("new audio stream for sprite %d, starting at %u",
+ SWFDEC_CHARACTER (sprite)->id, start_frame);
+ stream->sprite = sprite;
+ frame = &sprite->frames[start_frame];
+ g_assert (frame->sound_head);
+ stream->sound = frame->sound_head;
+ stream->playback_skip = frame->sound_skip;
+ stream->current_frame = start_frame;
+ stream->decoder = swfdec_audio_decoder_new (stream->sound->codec,
+ stream->sound->format);
+ swfdec_audio_add (SWFDEC_AUDIO (stream), player);
+
+ return SWFDEC_AUDIO (stream);
+}
+
diff --git a/swfdec/swfdec_audio_stream.h b/swfdec/swfdec_audio_stream.h
new file mode 100644
index 0000000..306c9c8
--- /dev/null
+++ b/swfdec/swfdec_audio_stream.h
@@ -0,0 +1,65 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_AUDIO_STREAM_H_
+#define _SWFDEC_AUDIO_STREAM_H_
+
+#include <libswfdec/swfdec_audio_internal.h>
+#include <libswfdec/swfdec_codec_audio.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecAudioStream SwfdecAudioStream;
+typedef struct _SwfdecAudioStreamClass SwfdecAudioStreamClass;
+
+#define SWFDEC_TYPE_AUDIO_STREAM (swfdec_audio_stream_get_type())
+#define SWFDEC_IS_AUDIO_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_AUDIO_STREAM))
+#define SWFDEC_IS_AUDIO_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_AUDIO_STREAM))
+#define SWFDEC_AUDIO_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_AUDIO_STREAM, SwfdecAudioStream))
+#define SWFDEC_AUDIO_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_AUDIO_STREAM, SwfdecAudioStreamClass))
+#define SWFDEC_AUDIO_STREAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_AUDIO_STREAM, SwfdecAudioStreamClass))
+
+struct _SwfdecAudioStream
+{
+ SwfdecAudio audio;
+
+ SwfdecSprite * sprite; /* sprite we're playing back */
+ SwfdecSound * sound; /* sound we're playing */
+ SwfdecAudioDecoder * decoder; /* decoder used for this frame */
+ guint playback_skip; /* number of samples to skip at the beginning of queue */
+ GQueue * playback_queue; /* all the samples we've decoded so far */
+ guint current_frame; /* last decoded frame */
+ gboolean done; /* TRUE when no new data will be made available */
+};
+
+struct _SwfdecAudioStreamClass
+{
+ SwfdecAudioClass audio_class;
+};
+
+GType swfdec_audio_stream_get_type (void);
+
+SwfdecAudio * swfdec_audio_stream_new (SwfdecPlayer * player,
+ SwfdecSprite * sprite,
+ guint start_frame);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_bevel_filter.c b/swfdec/swfdec_bevel_filter.c
new file mode 100644
index 0000000..4e6c4f7
--- /dev/null
+++ b/swfdec/swfdec_bevel_filter.c
@@ -0,0 +1,226 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (1107, 1, swfdec_bevel_filter_get_distance)
+void
+swfdec_bevel_filter_get_distance (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.distance (get)");
+}
+
+SWFDEC_AS_NATIVE (1107, 2, swfdec_bevel_filter_set_distance)
+void
+swfdec_bevel_filter_set_distance (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.distance (set)");
+}
+
+SWFDEC_AS_NATIVE (1107, 3, swfdec_bevel_filter_get_angle)
+void
+swfdec_bevel_filter_get_angle (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.angle (get)");
+}
+
+SWFDEC_AS_NATIVE (1107, 4, swfdec_bevel_filter_set_angle)
+void
+swfdec_bevel_filter_set_angle (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.angle (set)");
+}
+
+SWFDEC_AS_NATIVE (1107, 5, swfdec_bevel_filter_get_highlightColor)
+void
+swfdec_bevel_filter_get_highlightColor (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.highlightColor (get)");
+}
+
+SWFDEC_AS_NATIVE (1107, 6, swfdec_bevel_filter_set_highlightColor)
+void
+swfdec_bevel_filter_set_highlightColor (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.highlightColor (set)");
+}
+
+SWFDEC_AS_NATIVE (1107, 7, swfdec_bevel_filter_get_highlightAlpha)
+void
+swfdec_bevel_filter_get_highlightAlpha (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.highlightAlpha (get)");
+}
+
+SWFDEC_AS_NATIVE (1107, 8, swfdec_bevel_filter_set_highlightAlpha)
+void
+swfdec_bevel_filter_set_highlightAlpha (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.highlightAlpha (set)");
+}
+
+SWFDEC_AS_NATIVE (1107, 9, swfdec_bevel_filter_get_shadowColor)
+void
+swfdec_bevel_filter_get_shadowColor (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.shadowColor (get)");
+}
+
+SWFDEC_AS_NATIVE (1107, 10, swfdec_bevel_filter_set_shadowColor)
+void
+swfdec_bevel_filter_set_shadowColor (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.shadowColor (set)");
+}
+
+SWFDEC_AS_NATIVE (1107, 11, swfdec_bevel_filter_get_shadowAlpha)
+void
+swfdec_bevel_filter_get_shadowAlpha (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.shadowAlpha (get)");
+}
+
+SWFDEC_AS_NATIVE (1107, 12, swfdec_bevel_filter_set_shadowAlpha)
+void
+swfdec_bevel_filter_set_shadowAlpha (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.shadowAlpha (set)");
+}
+
+SWFDEC_AS_NATIVE (1107, 13, swfdec_bevel_filter_get_quality)
+void
+swfdec_bevel_filter_get_quality (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.quality (get)");
+}
+
+SWFDEC_AS_NATIVE (1107, 14, swfdec_bevel_filter_set_quality)
+void
+swfdec_bevel_filter_set_quality (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.quality (set)");
+}
+
+SWFDEC_AS_NATIVE (1107, 15, swfdec_bevel_filter_get_strength)
+void
+swfdec_bevel_filter_get_strength (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.strength (get)");
+}
+
+SWFDEC_AS_NATIVE (1107, 16, swfdec_bevel_filter_set_strength)
+void
+swfdec_bevel_filter_set_strength (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.strength (set)");
+}
+
+SWFDEC_AS_NATIVE (1107, 17, swfdec_bevel_filter_get_knockout)
+void
+swfdec_bevel_filter_get_knockout (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.knockout (get)");
+}
+
+SWFDEC_AS_NATIVE (1107, 18, swfdec_bevel_filter_set_knockout)
+void
+swfdec_bevel_filter_set_knockout (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.knockout (set)");
+}
+
+SWFDEC_AS_NATIVE (1107, 19, swfdec_bevel_filter_get_blurX)
+void
+swfdec_bevel_filter_get_blurX (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.blurX (get)");
+}
+
+SWFDEC_AS_NATIVE (1107, 20, swfdec_bevel_filter_set_blurX)
+void
+swfdec_bevel_filter_set_blurX (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.blurX (set)");
+}
+
+SWFDEC_AS_NATIVE (1107, 21, swfdec_bevel_filter_get_blurY)
+void
+swfdec_bevel_filter_get_blurY (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.blurY (get)");
+}
+
+SWFDEC_AS_NATIVE (1107, 22, swfdec_bevel_filter_set_blurY)
+void
+swfdec_bevel_filter_set_blurY (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.blurY (set)");
+}
+
+SWFDEC_AS_NATIVE (1107, 23, swfdec_bevel_filter_get_type)
+void
+swfdec_bevel_filter_get_type (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.type (get)");
+}
+
+SWFDEC_AS_NATIVE (1107, 24, swfdec_bevel_filter_set_type)
+void
+swfdec_bevel_filter_set_type (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter.type (set)");
+}
+
+// constructor
+SWFDEC_AS_NATIVE (1107, 0, swfdec_bevel_filter_construct)
+void
+swfdec_bevel_filter_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BevelFilter");
+}
diff --git a/swfdec/swfdec_bitmap_data.c b/swfdec/swfdec_bitmap_data.c
new file mode 100644
index 0000000..4686140
--- /dev/null
+++ b/swfdec/swfdec_bitmap_data.c
@@ -0,0 +1,306 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+// static
+SWFDEC_AS_NATIVE (1100, 40, swfdec_bitmap_data_loadBitmap)
+void
+swfdec_bitmap_data_loadBitmap (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.loadBitmap (static)");
+}
+
+// properties
+SWFDEC_AS_NATIVE (1100, 100, swfdec_bitmap_data_get_width)
+void
+swfdec_bitmap_data_get_width (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.width (get)");
+}
+
+SWFDEC_AS_NATIVE (1100, 101, swfdec_bitmap_data_set_width)
+void
+swfdec_bitmap_data_set_width (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.width (set)");
+}
+
+SWFDEC_AS_NATIVE (1100, 102, swfdec_bitmap_data_get_height)
+void
+swfdec_bitmap_data_get_height (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.height (get)");
+}
+
+SWFDEC_AS_NATIVE (1100, 103, swfdec_bitmap_data_set_height)
+void
+swfdec_bitmap_data_set_height (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.height (set)");
+}
+
+SWFDEC_AS_NATIVE (1100, 104, swfdec_bitmap_data_get_rectangle)
+void
+swfdec_bitmap_data_get_rectangle (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.rectangle (get)");
+}
+
+SWFDEC_AS_NATIVE (1100, 105, swfdec_bitmap_data_set_rectangle)
+void
+swfdec_bitmap_data_set_rectangle (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.rectangle (set)");
+}
+
+SWFDEC_AS_NATIVE (1100, 106, swfdec_bitmap_data_get_transparent)
+void
+swfdec_bitmap_data_get_transparent (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.transparent (get)");
+}
+
+SWFDEC_AS_NATIVE (1100, 107, swfdec_bitmap_data_set_transparent)
+void
+swfdec_bitmap_data_set_transparent (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.transparent (set)");
+}
+
+// normal
+SWFDEC_AS_NATIVE (1100, 1, swfdec_bitmap_data_getPixel)
+void
+swfdec_bitmap_data_getPixel (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.getPixel");
+}
+
+SWFDEC_AS_NATIVE (1100, 2, swfdec_bitmap_data_setPixel)
+void
+swfdec_bitmap_data_setPixel (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.setPixel");
+}
+
+SWFDEC_AS_NATIVE (1100, 3, swfdec_bitmap_data_fillRect)
+void
+swfdec_bitmap_data_fillRect (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.fillRect");
+}
+
+SWFDEC_AS_NATIVE (1100, 4, swfdec_bitmap_data_copyPixels)
+void
+swfdec_bitmap_data_copyPixels (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.copyPixels");
+}
+
+SWFDEC_AS_NATIVE (1100, 5, swfdec_bitmap_data_applyFilter)
+void
+swfdec_bitmap_data_applyFilter (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.applyFilter");
+}
+
+SWFDEC_AS_NATIVE (1100, 6, swfdec_bitmap_data_scroll)
+void
+swfdec_bitmap_data_scroll (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.scroll");
+}
+
+SWFDEC_AS_NATIVE (1100, 7, swfdec_bitmap_data_threshold)
+void
+swfdec_bitmap_data_threshold (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.threshold");
+}
+
+SWFDEC_AS_NATIVE (1100, 8, swfdec_bitmap_data_draw)
+void
+swfdec_bitmap_data_draw (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.draw");
+}
+
+SWFDEC_AS_NATIVE (1100, 9, swfdec_bitmap_data_pixelDissolve)
+void
+swfdec_bitmap_data_pixelDissolve (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.pixelDissolve");
+}
+
+SWFDEC_AS_NATIVE (1100, 10, swfdec_bitmap_data_getPixel32)
+void
+swfdec_bitmap_data_getPixel32 (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.getPixel32");
+}
+
+SWFDEC_AS_NATIVE (1100, 11, swfdec_bitmap_data_setPixel32)
+void
+swfdec_bitmap_data_setPixel32 (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.setPixel32");
+}
+
+SWFDEC_AS_NATIVE (1100, 12, swfdec_bitmap_data_floodFill)
+void
+swfdec_bitmap_data_floodFill (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.floodFill");
+}
+
+SWFDEC_AS_NATIVE (1100, 13, swfdec_bitmap_data_getColorBoundsRect)
+void
+swfdec_bitmap_data_getColorBoundsRect (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.getColorBoundsRect");
+}
+
+SWFDEC_AS_NATIVE (1100, 14, swfdec_bitmap_data_perlinNoise)
+void
+swfdec_bitmap_data_perlinNoise (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.perlinNoise");
+}
+
+SWFDEC_AS_NATIVE (1100, 15, swfdec_bitmap_data_colorTransform)
+void
+swfdec_bitmap_data_colorTransform (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.colorTransform");
+}
+
+SWFDEC_AS_NATIVE (1100, 16, swfdec_bitmap_data_hitTest)
+void
+swfdec_bitmap_data_hitTest (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.hitTest");
+}
+
+SWFDEC_AS_NATIVE (1100, 17, swfdec_bitmap_data_paletteMap)
+void
+swfdec_bitmap_data_paletteMap (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.paletteMap");
+}
+
+SWFDEC_AS_NATIVE (1100, 18, swfdec_bitmap_data_merge)
+void
+swfdec_bitmap_data_merge (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.merge");
+}
+
+SWFDEC_AS_NATIVE (1100, 19, swfdec_bitmap_data_noise)
+void
+swfdec_bitmap_data_noise (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.noise");
+}
+
+SWFDEC_AS_NATIVE (1100, 20, swfdec_bitmap_data_copyChannel)
+void
+swfdec_bitmap_data_copyChannel (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.copyChannel");
+}
+
+SWFDEC_AS_NATIVE (1100, 21, swfdec_bitmap_data_clone)
+void
+swfdec_bitmap_data_clone (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.clone");
+}
+
+SWFDEC_AS_NATIVE (1100, 22, swfdec_bitmap_data_dispose)
+void
+swfdec_bitmap_data_dispose (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.dispose");
+}
+
+SWFDEC_AS_NATIVE (1100, 23, swfdec_bitmap_data_generateFilterRect)
+void
+swfdec_bitmap_data_generateFilterRect (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.generateFilterRect");
+}
+
+SWFDEC_AS_NATIVE (1100, 24, swfdec_bitmap_data_compare)
+void
+swfdec_bitmap_data_compare (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData.compare");
+}
+
+// constructor
+SWFDEC_AS_NATIVE (1100, 0, swfdec_bitmap_data_construct)
+void
+swfdec_bitmap_data_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapData");
+}
diff --git a/swfdec/swfdec_bitmap_filter.c b/swfdec/swfdec_bitmap_filter.c
new file mode 100644
index 0000000..ae9af4c
--- /dev/null
+++ b/swfdec/swfdec_bitmap_filter.c
@@ -0,0 +1,43 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (1112, 1, swfdec_bitmap_filter_getPixel)
+void
+swfdec_bitmap_filter_getPixel (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BitmapFilter.clone");
+}
+
+SWFDEC_AS_NATIVE (1112, 0, swfdec_bitmap_filter_construct)
+void
+swfdec_bitmap_filter_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ // FIXME: this is just commented out so that it won't always output warning
+ // when running initialization scripts
+ //SWFDEC_STUB ("BitmapFilter");
+}
diff --git a/swfdec/swfdec_bits.c b/swfdec/swfdec_bits.c
new file mode 100644
index 0000000..1cf166d
--- /dev/null
+++ b/swfdec/swfdec_bits.c
@@ -0,0 +1,760 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include <zlib.h>
+
+#include "swfdec_bits.h"
+#include "swfdec_color.h"
+#include "swfdec_debug.h"
+#include "swfdec_rect.h"
+
+
+#define SWFDEC_BITS_CHECK(b,n) G_STMT_START { \
+ if (swfdec_bits_left(b) < (n)) { \
+ SWFDEC_ERROR ("reading past end of buffer"); \
+ b->ptr = b->end; \
+ b->idx = 0; \
+ return 0; \
+ } \
+}G_STMT_END
+#define SWFDEC_BYTES_CHECK(b,n) G_STMT_START { \
+ g_assert (b->end >= b->ptr); \
+ g_assert (b->idx == 0); \
+ if ((unsigned long) (b->end - b->ptr) < n) { \
+ SWFDEC_ERROR ("reading past end of buffer"); \
+ b->ptr = b->end; \
+ b->idx = 0; \
+ return 0; \
+ } \
+} G_STMT_END
+
+/**
+ * swfdec_bits_init:
+ * @bits: a #SwfdecBits
+ * @buffer: buffer to use for data or NULL
+ *
+ * initializes @bits for use with the data in @buffer. The buffer will not be
+ * referenced, so you are responsible for keeping it around while @bits is used.
+ **/
+void
+swfdec_bits_init (SwfdecBits *bits, SwfdecBuffer *buffer)
+{
+ g_return_if_fail (bits != NULL);
+
+ if (buffer) {
+ bits->buffer = buffer;
+ bits->ptr = buffer->data;
+ bits->idx = 0;
+ bits->end = buffer->data + buffer->length;
+ } else {
+ memset (bits, 0, sizeof (SwfdecBits));
+ }
+}
+
+/**
+ * swfdec_bits_init_bits:
+ * @bits: a #SwfdecBits
+ * @from: a #SwfdecBits to initialize from
+ * @bytes: number of bytes to move to @bits
+ *
+ * Initializes @bits for use with the next @bytes bytes from @from. If not
+ * enough bytes are available, less bytes will be available in @bits. @from
+ * will skip the bytes now available in @bits. If you want to know if this
+ * function moves enough bytes, you should ensure that enough data is
+ * available using swfdec_bits_left() before calling this function.
+ **/
+void
+swfdec_bits_init_bits (SwfdecBits *bits, SwfdecBits *from, guint bytes)
+{
+ g_return_if_fail (bits != NULL);
+ g_return_if_fail (from != NULL);
+ g_return_if_fail (from->idx == 0);
+
+ bits->buffer = from->buffer;
+ bits->ptr = from->ptr;
+ if (bytes > (guint) (from->end - from->ptr))
+ bytes = from->end - from->ptr;
+ bits->end = bits->ptr + bytes;
+ bits->idx = 0;
+ from->ptr = bits->end;
+}
+
+/**
+ * swfdec_bits_init_data:
+ * @bits: the #SwfdecBits to initialize
+ * @data: data to initialize with
+ * @len: length of the data
+ *
+ * Initializes @bits for use with the given @data. All operations on @bits will
+ * return copies of the data, so after use, you can free the supplied data. Using
+ * %NULL for @data is valid if @len is 0.
+ **/
+void
+swfdec_bits_init_data (SwfdecBits *bits, const guint8 *data, guint len)
+{
+ g_return_if_fail (bits != NULL);
+ g_return_if_fail (data != NULL || len == 0);
+
+ bits->buffer = NULL;
+ bits->ptr = data;
+ bits->idx = 0;
+ bits->end = bits->ptr + len;
+}
+
+guint
+swfdec_bits_left (const SwfdecBits *b)
+{
+ if (b->ptr == NULL)
+ return 0;
+ g_assert (b->end >= b->ptr);
+ g_assert (b->end > b->ptr || b->idx == 0);
+ return (b->end - b->ptr) * 8 - b->idx;
+}
+
+int
+swfdec_bits_getbit (SwfdecBits * b)
+{
+ int r;
+
+ SWFDEC_BITS_CHECK (b, 1);
+
+ r = ((*b->ptr) >> (7 - b->idx)) & 1;
+
+ b->idx++;
+ if (b->idx >= 8) {
+ b->ptr++;
+ b->idx = 0;
+ }
+
+ return r;
+}
+
+guint
+swfdec_bits_getbits (SwfdecBits * b, guint n)
+{
+ unsigned long r = 0;
+ guint i;
+
+ SWFDEC_BITS_CHECK (b, n);
+
+ while (n > 0) {
+ i = MIN (n, 8 - b->idx);
+ r <<= i;
+ r |= ((*b->ptr) >> (8 - i - b->idx)) & ((1 << i) - 1);
+ n -= i;
+ if (i == 8) {
+ b->ptr++;
+ } else {
+ b->idx += i;
+ if (b->idx >= 8) {
+ b->ptr++;
+ b->idx = 0;
+ }
+ }
+ }
+ return r;
+}
+
+guint
+swfdec_bits_peekbits (const SwfdecBits * b, guint n)
+{
+ SwfdecBits tmp = *b;
+
+ return swfdec_bits_getbits (&tmp, n);
+}
+
+int
+swfdec_bits_getsbits (SwfdecBits * b, guint n)
+{
+ unsigned long r = 0;
+
+ SWFDEC_BITS_CHECK (b, n);
+
+ if (n == 0)
+ return 0;
+ r = -swfdec_bits_getbit (b);
+ r = (r << (n - 1)) | swfdec_bits_getbits (b, n - 1);
+ return r;
+}
+
+guint
+swfdec_bits_peek_u8 (const SwfdecBits * b)
+{
+ g_assert (b->idx == 0);
+ g_assert (b->ptr <= b->end);
+ if (b->ptr == b->end)
+ return 0;
+
+ return *b->ptr;
+}
+
+guint
+swfdec_bits_get_u8 (SwfdecBits * b)
+{
+ SWFDEC_BYTES_CHECK (b, 1);
+
+ return *b->ptr++;
+}
+
+guint
+swfdec_bits_get_u16 (SwfdecBits * b)
+{
+ guint r;
+
+ SWFDEC_BYTES_CHECK (b, 2);
+
+ r = b->ptr[0] | (b->ptr[1] << 8);
+ b->ptr += 2;
+
+ return r;
+}
+
+int
+swfdec_bits_get_s16 (SwfdecBits * b)
+{
+ short r;
+
+ SWFDEC_BYTES_CHECK (b, 2);
+
+ r = b->ptr[0] | (b->ptr[1] << 8);
+ b->ptr += 2;
+
+ return r;
+}
+
+guint
+swfdec_bits_get_u32 (SwfdecBits * b)
+{
+ guint r;
+
+ SWFDEC_BYTES_CHECK (b, 4);
+
+ r = b->ptr[0] | (b->ptr[1] << 8) | (b->ptr[2] << 16) | (b->ptr[3] << 24);
+ b->ptr += 4;
+
+ return r;
+}
+
+guint
+swfdec_bits_get_bu16 (SwfdecBits *b)
+{
+ guint r;
+
+ SWFDEC_BYTES_CHECK (b, 2);
+
+ r = (b->ptr[0] << 8) | b->ptr[1];
+ b->ptr += 2;
+
+ return r;
+}
+
+guint
+swfdec_bits_get_bu24 (SwfdecBits *b)
+{
+ guint r;
+
+ SWFDEC_BYTES_CHECK (b, 3);
+
+ r = (b->ptr[0] << 16) | (b->ptr[1] << 8) | b->ptr[2];
+ b->ptr += 3;
+
+ return r;
+}
+
+guint
+swfdec_bits_get_bu32 (SwfdecBits *b)
+{
+ guint r;
+
+ SWFDEC_BYTES_CHECK (b, 4);
+
+ r = (b->ptr[0] << 24) | (b->ptr[1] << 16) | (b->ptr[2] << 8) | b->ptr[3];
+ b->ptr += 4;
+
+ return r;
+}
+
+float
+swfdec_bits_get_float (SwfdecBits * b)
+{
+ union {
+ gint32 i;
+ float f;
+ } conv;
+
+ SWFDEC_BYTES_CHECK (b, 4);
+
+ conv.i = (b->ptr[3] << 24) | (b->ptr[2] << 16) | (b->ptr[1] << 8) | b->ptr[0];
+ b->ptr += 4;
+
+ return conv.f;
+}
+
+/* fixup mad byte ordering of doubles in flash files.
+ * If little endian x86 byte order is 0 1 2 3 4 5 6 7 and PPC32 byte order is
+ * 7 6 5 4 3 2 1 0, then Flash uses 4 5 6 7 0 1 2 3.
+ * If your architecture has a different byte ordering for storing doubles,
+ * this conversion function will fail. To find out your byte ordering, you can
+ * use this command line:
+ * python -c "import struct; print struct.unpack('8c', struct.pack('d', 7.949928895127363e-275))"
+ */
+double
+swfdec_bits_get_double (SwfdecBits * b)
+{
+ union {
+ guint32 i[2];
+ double d;
+ } conv;
+
+ SWFDEC_BYTES_CHECK (b, 8);
+
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+ conv.i[1] = (b->ptr[3] << 24) | (b->ptr[2] << 16) | (b->ptr[1] << 8) | b->ptr[0];
+ conv.i[0] = (b->ptr[7] << 24) | (b->ptr[6] << 16) | (b->ptr[5] << 8) | b->ptr[4];
+#else
+ conv.i[0] = (b->ptr[3] << 24) | (b->ptr[2] << 16) | (b->ptr[1] << 8) | b->ptr[0];
+ conv.i[1] = (b->ptr[7] << 24) | (b->ptr[6] << 16) | (b->ptr[5] << 8) | b->ptr[4];
+#if 0
+ conv.i[0] = (b->ptr[0] << 24) | (b->ptr[1] << 16) | (b->ptr[2] << 8) | b->ptr[3];
+ conv.i[1] = (b->ptr[4] << 24) | (b->ptr[5] << 16) | (b->ptr[6] << 8) | b->ptr[7];
+#endif
+#endif
+ b->ptr += 8;
+
+ return conv.d;
+}
+
+double
+swfdec_bits_get_bdouble (SwfdecBits * b)
+{
+ double d;
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+ guint64 tmp;
+ gpointer p;
+#endif
+
+ SWFDEC_BYTES_CHECK (b, 8);
+
+#if G_BYTE_ORDER == G_BIG_ENDIAN
+ memcpy (&d, b->ptr, 8);
+#elif G_BYTE_ORDER == G_LITTLE_ENDIAN
+ memcpy (&tmp, b->ptr, 8);
+ tmp = GUINT64_FROM_BE (tmp);
+ p = &tmp;
+ d = *((double *) p);
+#endif
+ b->ptr += 8;
+
+ return d;
+}
+
+void
+swfdec_bits_syncbits (SwfdecBits * b)
+{
+ if (b->idx) {
+ b->ptr++;
+ b->idx = 0;
+ }
+}
+
+void
+swfdec_bits_get_color_transform (SwfdecBits * bits, SwfdecColorTransform * ct)
+{
+ int has_add;
+ int has_mult;
+ int n_bits;
+
+ ct->mask = FALSE;
+ has_add = swfdec_bits_getbit (bits);
+ has_mult = swfdec_bits_getbit (bits);
+ n_bits = swfdec_bits_getbits (bits, 4);
+ if (has_mult) {
+ ct->ra = swfdec_bits_getsbits (bits, n_bits);
+ ct->ga = swfdec_bits_getsbits (bits, n_bits);
+ ct->ba = swfdec_bits_getsbits (bits, n_bits);
+ ct->aa = swfdec_bits_getsbits (bits, n_bits);
+ } else {
+ ct->ra = 256;
+ ct->ga = 256;
+ ct->ba = 256;
+ ct->aa = 256;
+ }
+ if (has_add) {
+ ct->rb = swfdec_bits_getsbits (bits, n_bits);
+ ct->gb = swfdec_bits_getsbits (bits, n_bits);
+ ct->bb = swfdec_bits_getsbits (bits, n_bits);
+ ct->ab = swfdec_bits_getsbits (bits, n_bits);
+ } else {
+ ct->rb = 0;
+ ct->gb = 0;
+ ct->bb = 0;
+ ct->ab = 0;
+ }
+ swfdec_bits_syncbits (bits);
+}
+
+void
+swfdec_bits_get_matrix (SwfdecBits * bits, cairo_matrix_t *matrix,
+ cairo_matrix_t *inverse)
+{
+ int has_scale;
+ int has_rotate;
+ int n_translate_bits;
+
+ has_scale = swfdec_bits_getbit (bits);
+ if (has_scale) {
+ int n_scale_bits = swfdec_bits_getbits (bits, 5);
+ matrix->xx = SWFDEC_FIXED_TO_DOUBLE (swfdec_bits_getsbits (bits, n_scale_bits));
+ matrix->yy = SWFDEC_FIXED_TO_DOUBLE (swfdec_bits_getsbits (bits, n_scale_bits));
+
+ SWFDEC_LOG ("scalefactors: x = %d/65536, y = %d/65536",
+ SWFDEC_DOUBLE_TO_FIXED (matrix->xx), SWFDEC_DOUBLE_TO_FIXED (matrix->yy));
+ } else {
+ SWFDEC_LOG ("no scalefactors given");
+ matrix->xx = 1.0;
+ matrix->yy = 1.0;
+ }
+ has_rotate = swfdec_bits_getbit (bits);
+ if (has_rotate) {
+ int n_rotate_bits = swfdec_bits_getbits (bits, 5);
+ matrix->yx = SWFDEC_FIXED_TO_DOUBLE (swfdec_bits_getsbits (bits, n_rotate_bits));
+ matrix->xy = SWFDEC_FIXED_TO_DOUBLE (swfdec_bits_getsbits (bits, n_rotate_bits));
+
+ SWFDEC_LOG ("skew: xy = %d/65536, yx = %d/65536",
+ SWFDEC_DOUBLE_TO_FIXED (matrix->xy),
+ SWFDEC_DOUBLE_TO_FIXED (matrix->yx));
+ } else {
+ SWFDEC_LOG ("no rotation");
+ matrix->xy = 0;
+ matrix->yx = 0;
+ }
+ n_translate_bits = swfdec_bits_getbits (bits, 5);
+ matrix->x0 = swfdec_bits_getsbits (bits, n_translate_bits);
+ matrix->y0 = swfdec_bits_getsbits (bits, n_translate_bits);
+
+ swfdec_matrix_ensure_invertible (matrix, inverse);
+ swfdec_bits_syncbits (bits);
+}
+
+static const char *
+swfdec_bits_skip_string (SwfdecBits *bits)
+{
+ char *s;
+ const char *end;
+ guint len;
+
+ SWFDEC_BYTES_CHECK (bits, 1);
+ end = memchr (bits->ptr, 0, bits->end - bits->ptr);
+ if (end == NULL) {
+ SWFDEC_ERROR ("could not parse string");
+ return NULL;
+ }
+
+ len = end - (const char *) bits->ptr;
+ s = (char *) bits->ptr;
+ bits->ptr += len + 1;
+
+ return s;
+}
+
+/**
+ * swfdec_bits_get_string:
+ * @bits: a #SwfdecBits
+ * @version: Flash player version
+ *
+ * Prior to Flash 6, strings used to be encoded as LATIN1. Since Flash 6,
+ * strings are encoded as UTF-8. This version does that check automatically
+ * and converts strings to UTF-8.
+ *
+ * Returns: a UTF-8 encoded string or %NULL on error
+ **/
+char *
+swfdec_bits_get_string (SwfdecBits *bits, guint version)
+{
+ const char *s;
+
+ g_return_val_if_fail (bits != NULL, NULL);
+
+ s = swfdec_bits_skip_string (bits);
+ if (s == NULL)
+ return NULL;
+
+ if (version < 6) {
+ char *ret = g_convert (s, -1, "UTF-8", "LATIN1", NULL , NULL, NULL);
+ if (ret == NULL)
+ g_warning ("Could not convert string from LATIN1 to UTF-8");
+ return ret;
+ } else {
+ if (!g_utf8_validate (s, -1, NULL)) {
+ SWFDEC_ERROR ("parsed string is not valid utf-8");
+ return NULL;
+ }
+ return g_strdup (s);
+ }
+}
+
+/**
+ * swfdec_bits_skip_bytes:
+ * @bits: a #SwfdecBits
+ * @n_bytes: number of bytes to skip
+ *
+ * Skips up to @n_bytes bytes in @bits. If not enough bytes are available,
+ * only the available amount is skipped and a warning is printed.
+ *
+ * Returns: the number of bytes actually skipped
+ **/
+guint
+swfdec_bits_skip_bytes (SwfdecBits *bits, guint n_bytes)
+{
+ g_assert (bits->idx == 0);
+ if ((guint) (bits->end - bits->ptr) < n_bytes) {
+ SWFDEC_WARNING ("supposed to skip %u bytes, but only %td available",
+ n_bytes, bits->end - bits->ptr);
+ n_bytes = bits->end - bits->ptr;
+ }
+ bits->ptr += n_bytes;
+ return n_bytes;
+}
+
+/**
+ * swfdec_bits_get_string_length:
+ * @bits: a #SwfdecBits
+ * @len: number of bytes to read
+ * @version: flash version number
+ *
+ * Reads the next @len bytes (not characters!) into a string and validates
+ * its encoding is correct based on supplied version number.
+ *
+ * Returns: a new UTF-8 string or %NULL on error
+ **/
+char *
+swfdec_bits_get_string_length (SwfdecBits * bits, guint len, guint version)
+{
+ char *ret;
+
+ if (len == 0)
+ return g_strdup ("");
+ SWFDEC_BYTES_CHECK (bits, len);
+
+ ret = g_strndup ((char *) bits->ptr, len);
+ bits->ptr += len;
+
+ if (version < 6) {
+ char *tmp = g_convert (ret, -1, "UTF-8", "LATIN1", NULL , NULL, NULL);
+ g_free(ret);
+ ret = tmp;
+ } else {
+ if (!g_utf8_validate (ret, -1, NULL)) {
+ SWFDEC_ERROR ("parsed string is not valid utf-8");
+ g_free (ret);
+ ret = NULL;
+ }
+ }
+
+ return ret;
+}
+
+SwfdecColor
+swfdec_bits_get_color (SwfdecBits * bits)
+{
+ guint r, g, b;
+
+ r = swfdec_bits_get_u8 (bits);
+ g = swfdec_bits_get_u8 (bits);
+ b = swfdec_bits_get_u8 (bits);
+
+ return SWFDEC_COLOR_COMBINE (r, g, b, 0xff);
+}
+
+SwfdecColor
+swfdec_bits_get_rgba (SwfdecBits * bits)
+{
+ guint r, g, b, a;
+
+ r = swfdec_bits_get_u8 (bits);
+ g = swfdec_bits_get_u8 (bits);
+ b = swfdec_bits_get_u8 (bits);
+ a = swfdec_bits_get_u8 (bits);
+
+ return SWFDEC_COLOR_COMBINE (r, g, b, a);
+}
+
+void
+swfdec_bits_get_rect (SwfdecBits * bits, SwfdecRect *rect)
+{
+ int nbits;
+
+ nbits = swfdec_bits_getbits (bits, 5);
+ rect->x0 = swfdec_bits_getsbits (bits, nbits);
+ rect->x1 = swfdec_bits_getsbits (bits, nbits);
+ rect->y0 = swfdec_bits_getsbits (bits, nbits);
+ rect->y1 = swfdec_bits_getsbits (bits, nbits);
+
+ swfdec_bits_syncbits (bits);
+}
+
+/**
+ * swfdec_bits_get_buffer:
+ * @bits: #SwfdecBits
+ * @len: length of buffer or -1 for maximum
+ *
+ * Gets the contents of the next @len bytes of @bits and buts them in a new
+ * subbuffer. If @len is 0 (or @len is -1 and no more data is available), this
+ * is considered a reading error and %NULL is returned.
+ *
+ * Returns: the new #SwfdecBuffer or NULL if the requested amount of data
+ * isn't available
+ **/
+SwfdecBuffer *
+swfdec_bits_get_buffer (SwfdecBits *bits, int len)
+{
+ SwfdecBuffer *buffer;
+
+ g_return_val_if_fail (len >= -1, NULL);
+
+ if (len > 0) {
+ SWFDEC_BYTES_CHECK (bits, (guint) len);
+ } else {
+ g_assert (bits->idx == 0);
+ len = bits->end - bits->ptr;
+ g_assert (len >= 0);
+ }
+ if (len == 0)
+ return NULL;
+ if (bits->buffer) {
+ buffer = swfdec_buffer_new_subbuffer (bits->buffer, bits->ptr - bits->buffer->data, len);
+ } else {
+ buffer = swfdec_buffer_new_and_alloc (len);
+ memcpy (buffer->data, bits->ptr, len);
+ }
+ bits->ptr += len;
+ return buffer;
+}
+
+static void *
+swfdec_bits_zalloc (void *opaque, guint items, guint size)
+{
+ return g_malloc (items * size);
+}
+
+static void
+swfdec_bits_zfree (void *opaque, void *addr)
+{
+ g_free (addr);
+}
+
+/**
+ * swfdec_bits_decompress:
+ * @bits: a #SwfdecBits
+ * @compressed: number of bytes to decompress or -1 for the rest
+ * @decompressed: number of bytes to expect in the decompressed result or -1
+ * if unknown
+ *
+ * Decompresses the next @compressed bytes of data in @bits using the zlib
+ * decompression algorithm and returns the result in a buffer. If @decompressed
+ * was set and not enough data is available, the return buffer will be filled
+ * up with 0 bytes.
+ *
+ * Returns: a new #SwfdecBuffer containing the decompressed data or NULL on
+ * failure. If @decompressed > 0, the buffer's length will be @decompressed.
+ **/
+SwfdecBuffer *
+swfdec_bits_decompress (SwfdecBits *bits, int compressed, int decompressed)
+{
+ z_stream z = { 0, };
+ SwfdecBuffer *buffer;
+ int result;
+
+ g_return_val_if_fail (bits != NULL, NULL);
+ g_return_val_if_fail (compressed >= -1, NULL);
+ g_return_val_if_fail (decompressed > 0 || decompressed == -1, NULL);
+
+ /* prepare the bits structure */
+ if (compressed > 0) {
+ SWFDEC_BYTES_CHECK (bits, (guint) compressed);
+ } else {
+ g_assert (bits->idx == 0);
+ compressed = bits->end - bits->ptr;
+ g_assert (compressed >= 0);
+ }
+ if (compressed == 0)
+ return NULL;
+
+ z.zalloc = swfdec_bits_zalloc;
+ z.zfree = swfdec_bits_zfree;
+ z.opaque = NULL;
+ z.next_in = (Bytef *) bits->ptr;
+ z.avail_in = compressed;
+ result = inflateInit (&z);
+ if (result != Z_OK) {
+ SWFDEC_ERROR ("Error initialising zlib: %d %s", result, z.msg ? z.msg : "");
+ goto fail;
+ }
+ buffer = swfdec_buffer_new_and_alloc (decompressed > 0 ? decompressed : compressed * 2);
+ z.next_out = buffer->data;
+ z.avail_out = buffer->length;
+ while (TRUE) {
+ result = inflate (&z, decompressed > 0 ? Z_FINISH : 0);
+ switch (result) {
+ case Z_STREAM_END:
+ goto out;
+ case Z_OK:
+ if (decompressed < 0) {
+ buffer->data = g_realloc (buffer->data, buffer->length + compressed);
+ buffer->length += compressed;
+ z.next_out = buffer->data + z.total_out;
+ z.avail_out = buffer->length - z.total_out;
+ goto out;
+ }
+ /* else fall through */
+ default:
+ SWFDEC_ERROR ("error decompressing data: inflate returned %d %s",
+ result, z.msg ? z.msg : "");
+ swfdec_buffer_unref (buffer);
+ goto fail;
+ }
+ }
+out:
+ if (decompressed < 0) {
+ buffer->length = z.total_out;
+ } else {
+ if (buffer->length < z.total_out) {
+ SWFDEC_WARNING ("Not enough data decompressed: %lu instead of %"G_GSIZE_FORMAT" expected",
+ (gulong) z.total_out, buffer->length);
+ memset (buffer->data + z.total_out, 0, buffer->length - z.total_out);
+ }
+ }
+ result = inflateEnd (&z);
+ if (result != Z_OK) {
+ SWFDEC_ERROR ("error in inflateEnd: %d %s", result, z.msg ? z.msg : "");
+ }
+ bits->ptr += compressed;
+ return buffer;
+
+fail:
+ bits->ptr += compressed;
+ return NULL;
+}
diff --git a/swfdec/swfdec_bits.h b/swfdec/swfdec_bits.h
new file mode 100644
index 0000000..c56bc99
--- /dev/null
+++ b/swfdec/swfdec_bits.h
@@ -0,0 +1,75 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SWFDEC_BITS_H__
+#define __SWFDEC_BITS_H__
+
+#include <cairo.h>
+#include <libswfdec/swfdec_color.h>
+#include <libswfdec/swfdec_buffer.h>
+
+typedef struct _SwfdecBits SwfdecBits;
+
+struct _SwfdecBits
+{
+ SwfdecBuffer * buffer; /* buffer data is taken from or NULL */
+ const unsigned char * ptr; /* current location to read from */
+ guint idx; /* bits already read from ptr */
+ const unsigned char * end; /* pointer after last byte */
+};
+
+void swfdec_bits_init (SwfdecBits *bits, SwfdecBuffer *buffer);
+void swfdec_bits_init_data (SwfdecBits *bits, const guint8 *data, guint len);
+void swfdec_bits_init_bits (SwfdecBits *bits, SwfdecBits *from, guint bytes);
+guint swfdec_bits_left (const SwfdecBits *b);
+int swfdec_bits_getbit (SwfdecBits * b);
+guint swfdec_bits_getbits (SwfdecBits * b, guint n);
+guint swfdec_bits_peekbits (const SwfdecBits * b, guint n);
+int swfdec_bits_getsbits (SwfdecBits * b, guint n);
+guint swfdec_bits_peek_u8 (const SwfdecBits * b);
+guint swfdec_bits_get_u8 (SwfdecBits * b);
+guint swfdec_bits_get_u16 (SwfdecBits * b);
+int swfdec_bits_get_s16 (SwfdecBits * b);
+guint swfdec_bits_get_u32 (SwfdecBits * b);
+guint swfdec_bits_get_bu16 (SwfdecBits *b);
+guint swfdec_bits_get_bu24 (SwfdecBits *b);
+guint swfdec_bits_get_bu32 (SwfdecBits *b);
+float swfdec_bits_get_float (SwfdecBits * b);
+double swfdec_bits_get_double (SwfdecBits * b);
+double swfdec_bits_get_bdouble (SwfdecBits * b);
+void swfdec_bits_syncbits (SwfdecBits * b);
+
+void swfdec_bits_get_color_transform (SwfdecBits * bits,
+ SwfdecColorTransform * ct);
+void swfdec_bits_get_matrix (SwfdecBits * bits, cairo_matrix_t *matrix,
+ cairo_matrix_t *inverse);
+guint swfdec_bits_skip_bytes (SwfdecBits *bits, guint bytes);
+char *swfdec_bits_get_string_length (SwfdecBits * bits, guint len, guint version);
+char *swfdec_bits_get_string (SwfdecBits *bits, guint version);
+SwfdecColor swfdec_bits_get_color (SwfdecBits * bits);
+SwfdecColor swfdec_bits_get_rgba (SwfdecBits * bits);
+void swfdec_bits_get_rect (SwfdecBits * bits, SwfdecRect *rect);
+SwfdecBuffer *swfdec_bits_get_buffer (SwfdecBits *bits, int len);
+SwfdecBuffer *swfdec_bits_decompress (SwfdecBits *bits, int compressed,
+ int decompressed);
+
+
+#endif
diff --git a/swfdec/swfdec_blur_filter.c b/swfdec/swfdec_blur_filter.c
new file mode 100644
index 0000000..3a40c40
--- /dev/null
+++ b/swfdec/swfdec_blur_filter.c
@@ -0,0 +1,82 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (1102, 1, swfdec_blur_filter_get_blurX)
+void
+swfdec_blur_filter_get_blurX (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BlurFilter.blurX (get)");
+}
+
+SWFDEC_AS_NATIVE (1102, 2, swfdec_blur_filter_set_blurX)
+void
+swfdec_blur_filter_set_blurX (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BlurFilter.blurX (set)");
+}
+
+SWFDEC_AS_NATIVE (1102, 3, swfdec_blur_filter_get_blurY)
+void
+swfdec_blur_filter_get_blurY (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BlurFilter.blurY (get)");
+}
+
+SWFDEC_AS_NATIVE (1102, 4, swfdec_blur_filter_set_blurY)
+void
+swfdec_blur_filter_set_blurY (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BlurFilter.blurY (set)");
+}
+
+SWFDEC_AS_NATIVE (1102, 5, swfdec_blur_filter_get_quality)
+void
+swfdec_blur_filter_get_quality (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BlurFilter.quality (get)");
+}
+
+SWFDEC_AS_NATIVE (1102, 6, swfdec_blur_filter_set_quality)
+void
+swfdec_blur_filter_set_quality (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BlurFilter.quality (set)");
+}
+
+// constructor
+SWFDEC_AS_NATIVE (1102, 0, swfdec_blur_filter_construct)
+void
+swfdec_blur_filter_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("BlurFilter");
+}
diff --git a/swfdec/swfdec_buffer.c b/swfdec/swfdec_buffer.c
new file mode 100644
index 0000000..3420d10
--- /dev/null
+++ b/swfdec/swfdec_buffer.c
@@ -0,0 +1,641 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <swfdec_buffer.h>
+#include <glib.h>
+#include <string.h>
+#include <swfdec_debug.h>
+#include <liboil/liboil.h>
+
+/*** gtk-doc ***/
+
+/**
+ * SECTION:SwfdecBuffer
+ * @title: SwfdecBuffer
+ * @short_description: memory region handling
+ *
+ * This section describes how memory is to be handled when interacting with the
+ * Swfdec library. Memory regions are refcounted and passed using a
+ * #SwfdecBuffer. If large memory segments need to be handled that may span
+ * multiple buffers, Swfdec uses a #SwfdecBufferQueue.
+ */
+
+/*** SwfdecBuffer ***/
+
+/**
+ * SwfdecBuffer:
+ * @data: the data. read-only
+ * @length: number of bytes in @data. read-only
+ *
+ * To allow for easy sharing of memory regions, #SwfdecBuffer was created.
+ * Every buffer refers to a memory region and its size and takes care of
+ * freeing that region when the buffer is no longer needed. They are
+ * reference countedto make it easy to refer to the same region from various
+ * independant parts of your code. Buffers also support some advanced
+ * functionalities like extracting parts of the buffer using
+ * swfdec_buffer_new_subbuffer() or using mmapped files with
+ * swfdec_buffer_new_from_file() without the need for a different API.
+ */
+
+/**
+ * SwfdecBufferFreeFunc:
+ * @data: The data to free
+ * @priv: The private data registered for passing to this function
+ *
+ * This is the function prototype for the function that is called for freeing
+ * the memory pointed to by a buffer. See swfdec_buffer_new() for an example.
+ */
+
+GType
+swfdec_buffer_get_type (void)
+{
+ static GType type_swfdec_buffer = 0;
+
+ if (!type_swfdec_buffer)
+ type_swfdec_buffer = g_boxed_type_register_static
+ ("SwfdecBuffer",
+ (GBoxedCopyFunc) swfdec_buffer_ref,
+ (GBoxedFreeFunc) swfdec_buffer_unref);
+
+ return type_swfdec_buffer;
+}
+
+/**
+ * swfdec_buffer_new:
+ *
+ * Creates a new #SwfdecBuffer to be filled by the user. Use like this:
+ * <informalexample><programlisting>SwfdecBuffer *buffer = swfdec_buffer_new ();
+ * buffer->data = mydata;
+ * buffer->length = mydata_length;
+ * buffer->free = mydata_freefunc;
+ * buffer->priv = mydata_private;</programlisting></informalexample>
+ *
+ * Returns: a new #SwfdecBuffer referencing nothing.
+ **/
+SwfdecBuffer *
+swfdec_buffer_new (void)
+{
+ SwfdecBuffer *buffer;
+
+ buffer = g_new0 (SwfdecBuffer, 1);
+ buffer->ref_count = 1;
+ return buffer;
+}
+
+/**
+ * swfdec_buffer_new_and_alloc:
+ * @size: amount of bytes to allocate
+ *
+ * Creates a new buffer and allocates new memory of @size bytes to be used with
+ * the buffer.
+ *
+ * Returns: a new #SwfdecBuffer with buffer->data pointing to new data
+ **/
+SwfdecBuffer *
+swfdec_buffer_new_and_alloc (gsize size)
+{
+ SwfdecBuffer *buffer = swfdec_buffer_new ();
+
+ buffer->data = g_malloc (size);
+ buffer->length = size;
+ buffer->free = (SwfdecBufferFreeFunc) g_free;
+
+ return buffer;
+}
+
+/**
+ * swfdec_buffer_new_and_alloc0:
+ * @size: amount of bytes to allocate
+ *
+ * Createsa new buffer just like swfdec_buffer_new_and_alloc(), but ensures
+ * that the returned data gets initialized to be 0.
+ *
+ * Returns: a new #SwfdecBuffer with buffer->data pointing to new data
+ **/
+SwfdecBuffer *
+swfdec_buffer_new_and_alloc0 (gsize size)
+{
+ SwfdecBuffer *buffer = swfdec_buffer_new ();
+
+ buffer->data = g_malloc0 (size);
+ buffer->length = size;
+ buffer->free = (SwfdecBufferFreeFunc) g_free;
+
+ return buffer;
+}
+
+/**
+ * swfdec_buffer_new_for_data:
+ * @data: memory region allocated with g_malloc()
+ * @size: size of @data in bytes
+ *
+ * Takes ownership of @data and creates a new buffer managing it.
+ *
+ * Returns: a new #SwfdecBuffer pointing to @data
+ **/
+SwfdecBuffer *
+swfdec_buffer_new_for_data (unsigned char *data, gsize size)
+{
+ SwfdecBuffer *buffer;
+
+ g_return_val_if_fail (data != NULL, NULL);
+ g_return_val_if_fail (size > 0, NULL);
+
+ buffer = swfdec_buffer_new ();
+ buffer->data = data;
+ buffer->length = size;
+ buffer->free = (SwfdecBufferFreeFunc) g_free;
+
+ return buffer;
+}
+
+static void
+swfdec_buffer_free_subbuffer (unsigned char *data, gpointer priv)
+{
+ swfdec_buffer_unref (priv);
+}
+
+/**
+ * swfdec_buffer_new_subbuffer:
+ * @buffer: #SwfdecBuffer managing the region of memory
+ * @offset: starting offset into data
+ * @length: amount of bytes to manage
+ *
+ * Creates a #SwfdecBuffer for managing a partial section of the memory pointed
+ * to by @buffer.
+ *
+ * Returns: a new #SwfdecBuffer managing the indicated region.
+ **/
+SwfdecBuffer *
+swfdec_buffer_new_subbuffer (SwfdecBuffer * buffer, gsize offset, gsize length)
+{
+ SwfdecBuffer *subbuffer;
+
+ g_return_val_if_fail (buffer != NULL, NULL);
+ g_return_val_if_fail (offset + length <= buffer->length, NULL);
+
+ subbuffer = swfdec_buffer_new ();
+
+ subbuffer->priv = swfdec_buffer_ref (swfdec_buffer_get_super (buffer));
+ subbuffer->data = buffer->data + offset;
+ subbuffer->length = length;
+ subbuffer->free = swfdec_buffer_free_subbuffer;
+
+ return subbuffer;
+}
+
+/**
+ * swfdec_buffer_get_super:
+ * @buffer: a #SwfdecBuffer
+ *
+ * Returns the largest buffer that contains the memory pointed to by @buffer.
+ * This will either be the passed @buffer itself, or if the buffer was created
+ * via swfdec_buffer_new_subbuffer(), the buffer used for that.
+ *
+ * Returns: The largest @buffer available that contains the memory pointed to
+ * by @buffer.
+ **/
+SwfdecBuffer *
+swfdec_buffer_get_super (SwfdecBuffer *buffer)
+{
+ g_return_val_if_fail (buffer != NULL, NULL);
+
+ if (buffer->free == swfdec_buffer_free_subbuffer)
+ buffer = buffer->priv;
+
+ g_assert (buffer->free != swfdec_buffer_free_subbuffer);
+ return buffer;
+}
+
+static void
+swfdec_buffer_free_mapped (unsigned char *data, gpointer priv)
+{
+ g_mapped_file_free (priv);
+}
+
+/**
+ * swfdec_buffer_new_from_file:
+ * @filename: file to read
+ * @error: return location for a #GError or %NULL
+ *
+ * Creates a buffer containing the contents of the given file. If loading the
+ * file fails, %NULL is returned and @error is set. The error can be
+ * any of the errors that are valid for g_file_get_contents().
+ *
+ * Returns: a new #SwfdecBuffer or %NULL on failure
+ **/
+SwfdecBuffer *
+swfdec_buffer_new_from_file (const char *filename, GError **error)
+{
+ GMappedFile *file;
+ char *data;
+ gsize length;
+
+ g_return_val_if_fail (filename != NULL, NULL);
+
+ file = g_mapped_file_new (filename, FALSE, NULL);
+ if (file != NULL) {
+ SwfdecBuffer *buffer = swfdec_buffer_new ();
+ buffer->data = (unsigned char *) g_mapped_file_get_contents (file),
+ buffer->length = g_mapped_file_get_length (file);
+ buffer->free = swfdec_buffer_free_mapped;
+ buffer->priv = file;
+ return buffer;
+ }
+
+ if (!g_file_get_contents (filename, &data, &length, error))
+ return NULL;
+
+ return swfdec_buffer_new_for_data ((guint8 *) data, length);
+}
+
+/**
+ * swfdec_buffer_ref:
+ * @buffer: a #SwfdecBuffer
+ *
+ * increases the reference count of @buffer by one.
+ *
+ * Returns: The passed in @buffer.
+ **/
+SwfdecBuffer *
+swfdec_buffer_ref (SwfdecBuffer * buffer)
+{
+ g_return_val_if_fail (buffer != NULL, NULL);
+ g_return_val_if_fail (buffer->ref_count > 0, NULL);
+
+ buffer->ref_count++;
+ return buffer;
+}
+
+/**
+ * swfdec_buffer_unref:
+ * @buffer: a #SwfdecBuffer
+ *
+ * Decreases the reference count of @buffer by one. If no reference to this
+ * buffer exists anymore, the buffer and the memory it manages are freed.
+ **/
+void
+swfdec_buffer_unref (SwfdecBuffer * buffer)
+{
+ g_return_if_fail (buffer != NULL);
+ g_return_if_fail (buffer->ref_count > 0);
+
+ buffer->ref_count--;
+ if (buffer->ref_count == 0) {
+ if (buffer->free)
+ buffer->free (buffer->data, buffer->priv);
+ g_free (buffer);
+ }
+}
+
+/*** SwfdecBufferQueue ***/
+
+/**
+ * SwfdecBufferQueue:
+ *
+ * A #SwfdecBufferQueue is a queue of continuous buffers that allows reading
+ * its data in chunks of pre-defined sizes. It is used to transform a data
+ * stream that was provided by buffers of random sizes to buffers of the right
+ * size.
+ */
+
+GType
+swfdec_buffer_queue_get_type (void)
+{
+ static GType type_swfdec_buffer_queue = 0;
+
+ if (!type_swfdec_buffer_queue)
+ type_swfdec_buffer_queue = g_boxed_type_register_static
+ ("SwfdecBufferQueue",
+ (GBoxedCopyFunc) swfdec_buffer_queue_ref,
+ (GBoxedFreeFunc) swfdec_buffer_queue_unref);
+
+ return type_swfdec_buffer_queue;
+}
+
+/**
+ * swfdec_buffer_queue_new:
+ *
+ * Creates a new empty buffer queue.
+ *
+ * Returns: a new buffer queue. Use swfdec_buffer_queue_unref () to free it.
+ **/
+SwfdecBufferQueue *
+swfdec_buffer_queue_new (void)
+{
+ SwfdecBufferQueue *buffer_queue;
+
+ buffer_queue = g_new0 (SwfdecBufferQueue, 1);
+ buffer_queue->ref_count = 1;
+ return buffer_queue;
+}
+
+/**
+ * swfdec_buffer_queue_get_depth:
+ * @queue: a #SwfdecBufferQueue
+ *
+ * Returns the number of bytes currently in @queue.
+ *
+ * Returns: amount of bytes in @queue.
+ **/
+guint
+swfdec_buffer_queue_get_depth (SwfdecBufferQueue * queue)
+{
+ g_return_val_if_fail (queue != NULL, 0);
+
+ return queue->depth;
+}
+
+/**
+ * swfdec_buffer_queue_get_offset:
+ * @queue: a #SwfdecBufferQueue
+ *
+ * Queries the amount of bytes that has already been pulled out of
+ * @queue using functions like swfdec_buffer_queue_pull().
+ *
+ * Returns: Number of bytes that were already pulled from this queue.
+ **/
+guint
+swfdec_buffer_queue_get_offset (SwfdecBufferQueue * queue)
+{
+ g_return_val_if_fail (queue != NULL, 0);
+
+ return queue->offset;
+}
+
+/**
+ * swfdec_buffer_queue_clear:
+ * @queue: a #SwfdecBufferQueue
+ *
+ * Resets @queue into to initial state. All buffers it contains will be
+ * released and the offset will be reset to 0.
+ **/
+void
+swfdec_buffer_queue_clear (SwfdecBufferQueue *queue)
+{
+ g_return_if_fail (queue != NULL);
+
+ g_list_foreach (queue->buffers, (GFunc) swfdec_buffer_unref, NULL);
+ g_list_free (queue->buffers);
+ memset (queue, 0, sizeof (SwfdecBufferQueue));
+}
+
+/**
+ * swfdec_buffer_queue_push:
+ * @queue: a #SwfdecBufferQueue
+ * @buffer: #SwfdecBuffer to append to @queue
+ *
+ * Appends the given @buffer to the buffers already in @queue. This function
+ * will take ownership of the given @buffer. Use swfdec_buffer_ref () before
+ * calling this function to keep a reference.
+ **/
+void
+swfdec_buffer_queue_push (SwfdecBufferQueue * queue, SwfdecBuffer * buffer)
+{
+ g_return_if_fail (queue != NULL);
+ g_return_if_fail (buffer != NULL);
+
+ if (buffer->length == 0) {
+ swfdec_buffer_unref (buffer);
+ return;
+ }
+ queue->buffers = g_list_append (queue->buffers, buffer);
+ queue->depth += buffer->length;
+}
+
+/**
+ * swfdec_buffer_queue_pull_buffer:
+ * @queue: a #SwfdecBufferQueue
+ *
+ * Pulls the first buffer out of @queue and returns it. This function is
+ * equivalent to calling swfdec_buffer_queue_pull() with the size of the
+ * first buffer in it.
+ *
+ * Returns: The first buffer in @queue or %NULL if @queue is empty.
+ **/
+SwfdecBuffer *
+swfdec_buffer_queue_pull_buffer (SwfdecBufferQueue * queue)
+{
+ SwfdecBuffer *buffer;
+
+ g_return_val_if_fail (queue != NULL, NULL);
+ if (queue->buffers == NULL)
+ return NULL;
+
+ buffer = queue->buffers->data;
+
+ return swfdec_buffer_queue_pull (queue, buffer->length);
+}
+
+/**
+ * swfdec_buffer_queue_pull:
+ * @queue: a #SwfdecBufferQueue
+ * @length: amount of bytes to pull
+ *
+ * If enough data is still available in @queue, the first @length bytes are
+ * put into a new buffer and that buffer is returned. The @length bytes are
+ * removed from the head of the queue. If not enough data is available, %NULL
+ * is returned.
+ *
+ * Returns: a new #SwfdecBuffer or %NULL
+ **/
+SwfdecBuffer *
+swfdec_buffer_queue_pull (SwfdecBufferQueue * queue, guint length)
+{
+ GList *g;
+ SwfdecBuffer *newbuffer;
+ SwfdecBuffer *buffer;
+ SwfdecBuffer *subbuffer;
+
+ g_return_val_if_fail (queue != NULL, NULL);
+ g_return_val_if_fail (length > 0, NULL);
+
+ if (queue->depth < length)
+ return NULL;
+
+ /* FIXME: This function should share code with swfdec_buffer_queue_peek */
+ SWFDEC_LOG ("pulling %d, %d available", length, queue->depth);
+
+ g = g_list_first (queue->buffers);
+ buffer = g->data;
+
+ if (buffer->length > length) {
+ newbuffer = swfdec_buffer_new_subbuffer (buffer, 0, length);
+
+ subbuffer = swfdec_buffer_new_subbuffer (buffer, length,
+ buffer->length - length);
+ g->data = subbuffer;
+ swfdec_buffer_unref (buffer);
+ } else if (buffer->length == length) {
+ queue->buffers = g_list_remove (queue->buffers, buffer);
+ newbuffer = buffer;
+ } else {
+ guint offset = 0;
+
+ newbuffer = swfdec_buffer_new_and_alloc (length);
+
+ while (offset < length) {
+ g = g_list_first (queue->buffers);
+ buffer = g->data;
+
+ if (buffer->length > length - offset) {
+ guint n = length - offset;
+
+ oil_copy_u8 (newbuffer->data + offset, buffer->data, n);
+ subbuffer = swfdec_buffer_new_subbuffer (buffer, n, buffer->length - n);
+ g->data = subbuffer;
+ swfdec_buffer_unref (buffer);
+ offset += n;
+ } else {
+ oil_copy_u8 (newbuffer->data + offset, buffer->data, buffer->length);
+
+ queue->buffers = g_list_delete_link (queue->buffers, g);
+ offset += buffer->length;
+ swfdec_buffer_unref (buffer);
+ }
+ }
+ }
+
+ queue->depth -= length;
+ queue->offset += length;
+
+ return newbuffer;
+}
+
+/**
+ * swfdec_buffer_queue_peek_buffer:
+ * @queue: a #SwfdecBufferQueue
+ *
+ * Gets the first buffer out of @queue and returns it. This function is
+ * equivalent to calling swfdec_buffer_queue_peek() with the size of the
+ * first buffer in it.
+ *
+ * Returns: The first buffer in @queue or %NULL if @queue is empty. Use
+ * swfdec_buffer_unref() after use.
+ **/
+SwfdecBuffer *
+swfdec_buffer_queue_peek_buffer (SwfdecBufferQueue * queue)
+{
+ SwfdecBuffer *buffer;
+
+ g_return_val_if_fail (queue != NULL, NULL);
+ if (queue->buffers == NULL)
+ return NULL;
+
+ buffer = queue->buffers->data;
+
+ return swfdec_buffer_queue_peek (queue, buffer->length);
+}
+
+/**
+ * swfdec_buffer_queue_peek:
+ * @queue: a #SwfdecBufferQueue to read from
+ * @length: amount of bytes to peek
+ *
+ * Creates a new buffer with the first @length bytes from @queue, but unlike
+ * swfdec_buffer_queue_pull(), does not remove them from @queue.
+ *
+ * Returns: NULL if the requested amount of data wasn't available or a new
+ * readonly #SwfdecBuffer. Use swfdec_buffer_unref() after use.
+ **/
+SwfdecBuffer *
+swfdec_buffer_queue_peek (SwfdecBufferQueue * queue, guint length)
+{
+ GList *g;
+ SwfdecBuffer *newbuffer;
+ SwfdecBuffer *buffer;
+ guint offset = 0;
+
+ g_return_val_if_fail (length > 0, NULL);
+
+ if (queue->depth < length)
+ return NULL;
+
+ SWFDEC_LOG ("peeking %d, %d available", length, queue->depth);
+
+ g = g_list_first (queue->buffers);
+ buffer = g->data;
+ if (buffer->length > length) {
+ newbuffer = swfdec_buffer_new_subbuffer (buffer, 0, length);
+ } else {
+ newbuffer = swfdec_buffer_new_and_alloc (length);
+ while (offset < length) {
+ buffer = g->data;
+
+ if (buffer->length > length - offset) {
+ int n = length - offset;
+
+ oil_copy_u8 (newbuffer->data + offset, buffer->data, n);
+ offset += n;
+ } else {
+ oil_copy_u8 (newbuffer->data + offset, buffer->data, buffer->length);
+ offset += buffer->length;
+ }
+ g = g_list_next (g);
+ }
+ }
+
+ return newbuffer;
+}
+
+/**
+ * swfdec_buffer_queue_ref:
+ * @queue: a #SwfdecBufferQueue
+ *
+ * increases the reference count of @queue by one.
+ *
+ * Returns: The passed in @queue.
+ **/
+SwfdecBufferQueue *
+swfdec_buffer_queue_ref (SwfdecBufferQueue * queue)
+{
+ g_return_val_if_fail (queue != NULL, NULL);
+ g_return_val_if_fail (queue->ref_count > 0, NULL);
+
+ queue->ref_count++;
+ return queue;
+}
+
+/**
+ * swfdec_buffer_queue_unref:
+ * @queue: a #SwfdecBufferQueue
+ *
+ * Decreases the reference count of @queue by one. If no reference
+ * to this buffer exists anymore, the buffer and the memory
+ * it manages are freed.
+ **/
+void
+swfdec_buffer_queue_unref (SwfdecBufferQueue * queue)
+{
+ g_return_if_fail (queue != NULL);
+ g_return_if_fail (queue->ref_count > 0);
+
+ queue->ref_count--;
+ if (queue->ref_count == 0) {
+ swfdec_buffer_queue_clear (queue);
+ g_free (queue);
+ }
+}
+
diff --git a/swfdec/swfdec_buffer.h b/swfdec/swfdec_buffer.h
new file mode 100644
index 0000000..248f425
--- /dev/null
+++ b/swfdec/swfdec_buffer.h
@@ -0,0 +1,85 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SWFDEC_BUFFER_H__
+#define __SWFDEC_BUFFER_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+typedef struct _SwfdecBuffer SwfdecBuffer;
+typedef struct _SwfdecBufferQueue SwfdecBufferQueue;
+
+typedef void (* SwfdecBufferFreeFunc) (unsigned char *data, gpointer priv);
+
+struct _SwfdecBuffer
+{
+ unsigned char * data; /* memory region (consider as read only) */
+ gsize length; /* length of the memory region pointer do by @data */
+
+ /*< private >*/
+ int ref_count; /* guess */
+
+ SwfdecBufferFreeFunc free; /* function to call to free @data */
+ gpointer priv; /* data to pass to @free */
+};
+
+#define SWFDEC_TYPE_BUFFER swfdec_buffer_get_type()
+GType swfdec_buffer_get_type (void);
+
+struct _SwfdecBufferQueue
+{
+ /*< private >*/
+ GList *buffers;
+ guint depth;
+ guint offset;
+
+ int ref_count;
+};
+
+#define SWFDEC_TYPE_BUFFER_QUEUE swfdec_buffer_queue_get_type()
+GType swfdec_buffer_queue_get_type (void);
+
+SwfdecBuffer *swfdec_buffer_new (void);
+SwfdecBuffer *swfdec_buffer_new_and_alloc (gsize size);
+SwfdecBuffer *swfdec_buffer_new_and_alloc0 (gsize size);
+SwfdecBuffer *swfdec_buffer_new_for_data (unsigned char *data, gsize size);
+SwfdecBuffer *swfdec_buffer_new_subbuffer (SwfdecBuffer * buffer, gsize offset,
+ gsize length);
+SwfdecBuffer *swfdec_buffer_new_from_file (const char *filename, GError **error);
+SwfdecBuffer *swfdec_buffer_ref (SwfdecBuffer * buffer);
+SwfdecBuffer *swfdec_buffer_get_super (SwfdecBuffer *buffer);
+void swfdec_buffer_unref (SwfdecBuffer * buffer);
+
+SwfdecBufferQueue *swfdec_buffer_queue_new (void);
+void swfdec_buffer_queue_clear (SwfdecBufferQueue *queue);
+guint swfdec_buffer_queue_get_depth (SwfdecBufferQueue * queue);
+guint swfdec_buffer_queue_get_offset (SwfdecBufferQueue * queue);
+void swfdec_buffer_queue_push (SwfdecBufferQueue * queue,
+ SwfdecBuffer * buffer);
+SwfdecBuffer *swfdec_buffer_queue_pull (SwfdecBufferQueue * queue, guint length);
+SwfdecBuffer *swfdec_buffer_queue_pull_buffer (SwfdecBufferQueue * queue);
+SwfdecBuffer *swfdec_buffer_queue_peek (SwfdecBufferQueue * queue, guint length);
+SwfdecBuffer *swfdec_buffer_queue_peek_buffer (SwfdecBufferQueue * queue);
+SwfdecBufferQueue *swfdec_buffer_queue_ref (SwfdecBufferQueue * queue);
+void swfdec_buffer_queue_unref (SwfdecBufferQueue * queue);
+#endif
+
diff --git a/swfdec/swfdec_button.c b/swfdec/swfdec_button.c
new file mode 100644
index 0000000..471b936
--- /dev/null
+++ b/swfdec/swfdec_button.c
@@ -0,0 +1,302 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <string.h>
+#include "swfdec_button.h"
+#include "swfdec_button_movie.h"
+#include "swfdec_debug.h"
+#include "swfdec_filter.h"
+#include "swfdec_sound.h"
+#include "swfdec_sprite.h"
+
+
+G_DEFINE_TYPE (SwfdecButton, swfdec_button, SWFDEC_TYPE_GRAPHIC)
+
+static void
+swfdec_button_init (SwfdecButton * button)
+{
+}
+
+static void
+swfdec_button_dispose (GObject *object)
+{
+ guint i;
+ SwfdecButton *button = SWFDEC_BUTTON (object);
+
+ g_slist_foreach (button->records, (GFunc) swfdec_buffer_unref, NULL);
+ g_slist_free (button->records);
+ button->records = NULL;
+ if (button->events != NULL) {
+ swfdec_event_list_free (button->events);
+ button->events = NULL;
+ }
+ for (i = 0; i < 4; i++) {
+ if (button->sounds[i]) {
+ swfdec_sound_chunk_free (button->sounds[i]);
+ button->sounds[i] = NULL;
+ }
+ }
+
+ G_OBJECT_CLASS (swfdec_button_parent_class)->dispose (G_OBJECT (button));
+}
+
+static SwfdecMovie *
+swfdec_button_create_movie (SwfdecGraphic *graphic, gsize *size)
+{
+ SwfdecButton *button = SWFDEC_BUTTON (graphic);
+ SwfdecButtonMovie *movie = g_object_new (SWFDEC_TYPE_BUTTON_MOVIE, NULL);
+
+ movie->button = g_object_ref (button);
+ *size = sizeof (SwfdecButtonMovie);
+ if (button->events)
+ SWFDEC_MOVIE (movie)->events = swfdec_event_list_copy (button->events);
+
+ return SWFDEC_MOVIE (movie);
+}
+
+static void
+swfdec_button_class_init (SwfdecButtonClass * g_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+ SwfdecGraphicClass *graphic_class = SWFDEC_GRAPHIC_CLASS (g_class);
+
+ object_class->dispose = swfdec_button_dispose;
+
+ graphic_class->create_movie = swfdec_button_create_movie;
+}
+
+static guint
+swfdec_button_translate_conditions (guint conditions, gboolean menu)
+{
+ static const guint events[][2] = {
+ /* idle => over up */ { 1 << SWFDEC_EVENT_ROLL_OVER, 1 << SWFDEC_EVENT_ROLL_OVER },
+ /* over up => idle */ { 1 << SWFDEC_EVENT_ROLL_OUT, 1 << SWFDEC_EVENT_ROLL_OUT },
+ /* over up => over down */ { 1 << SWFDEC_EVENT_PRESS, 1 << SWFDEC_EVENT_PRESS },
+ /* over down => over up */ { 1 << SWFDEC_EVENT_RELEASE, 1 << SWFDEC_EVENT_RELEASE },
+ /* over down => out down */ { 1 << SWFDEC_EVENT_DRAG_OUT, 0 },
+ /* out down => over down */ { 1 << SWFDEC_EVENT_DRAG_OVER, 0 },
+ /* out down => idle */ { 1 << SWFDEC_EVENT_RELEASE_OUTSIDE, 1 << SWFDEC_EVENT_RELEASE_OUTSIDE },
+ /* idle => over down */ { 0, 1 << SWFDEC_EVENT_DRAG_OVER },
+ /* over down => idle */ { 0, 1 << SWFDEC_EVENT_DRAG_OUT }
+ };
+ guint i, ret;
+
+ ret = 0;
+ for (i = 0; i <= G_N_ELEMENTS (events); i++) {
+ if (conditions & (1 << i))
+ ret |= events[i][menu ? 1 : 0];
+ }
+ return ret;
+}
+
+int
+tag_func_define_button_2 (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecBits bits;
+ int id, reserved;
+ guint length;
+ SwfdecButton *button;
+ char *script_name;
+
+ id = swfdec_bits_get_u16 (&s->b);
+ button = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_BUTTON);
+ if (!button)
+ return SWFDEC_STATUS_OK;
+
+ SWFDEC_LOG (" ID: %d", id);
+
+ reserved = swfdec_bits_getbits (&s->b, 7);
+ button->menubutton = swfdec_bits_getbit (&s->b) ? TRUE : FALSE;
+ length = swfdec_bits_get_u16 (&s->b);
+
+ SWFDEC_LOG (" reserved = %d", reserved);
+ SWFDEC_LOG (" menu = %d", button->menubutton);
+ SWFDEC_LOG (" length of region = %d", length);
+
+ if (length)
+ swfdec_bits_init_bits (&bits, &s->b, length > 2 ? length - 2 : 0);
+ else
+ swfdec_bits_init_bits (&bits, &s->b, swfdec_bits_left (&s->b) / 8);
+ while (swfdec_bits_peek_u8 (&bits)) {
+ SwfdecBits tmp;
+ SwfdecBuffer *buffer;
+ cairo_matrix_t trans;
+ SwfdecColorTransform ctrans;
+ guint states, gid;
+ gboolean has_blend_mode, has_filters;
+
+ /* we parse the placement info into buffers each containing one palcement */
+ tmp = bits;
+
+ if (s->version >= 8) {
+ reserved = swfdec_bits_getbits (&bits, 2);
+ has_blend_mode = swfdec_bits_getbit (&bits);
+ has_filters = swfdec_bits_getbit (&bits);
+ SWFDEC_LOG (" reserved = %d", reserved);
+ SWFDEC_LOG (" has_blend_mode = %d", has_blend_mode);
+ SWFDEC_LOG (" has_filters = %d", has_filters);
+ } else {
+ reserved = swfdec_bits_getbits (&bits, 4);
+ has_blend_mode = 0;
+ has_filters = 0;
+ SWFDEC_LOG (" reserved = %d", reserved);
+ }
+ states = swfdec_bits_getbits (&bits, 4);
+ gid = swfdec_bits_get_u16 (&bits);
+ swfdec_bits_get_u16 (&bits);
+
+ SWFDEC_LOG (" states: %s%s%s%s",
+ states & (1 << SWFDEC_BUTTON_HIT) ? "HIT " : "",
+ states & (1 << SWFDEC_BUTTON_DOWN) ? "DOWN " : "",
+ states & (1 << SWFDEC_BUTTON_OVER) ? "OVER " : "",
+ states & (1 << SWFDEC_BUTTON_UP) ? "UP " : "");
+
+ swfdec_bits_get_matrix (&bits, &trans, NULL);
+ SWFDEC_LOG ("matrix: %g %g %g %g %g %g",
+ trans.xx, trans.yy,
+ trans.xy, trans.yx,
+ trans.x0, trans.y0);
+ swfdec_bits_get_color_transform (&bits, &ctrans);
+
+ if (has_filters) {
+ GSList *list = swfdec_filter_parse (SWFDEC_DECODER (s)->player, &bits);
+ g_slist_free (list);
+ }
+ if (has_blend_mode) {
+ guint blend_mode = swfdec_bits_get_u8 (&bits);
+ SWFDEC_LOG (" blend mode = %u", blend_mode);
+ }
+ buffer = swfdec_bits_get_buffer (&tmp, (swfdec_bits_left (&tmp) - swfdec_bits_left (&bits)) / 8);
+ if (buffer == NULL)
+ break;
+ button->records = g_slist_prepend (button->records, buffer);
+ /* add hit state movies to button's extents */
+ if (states & (1 << SWFDEC_BUTTON_HIT)) {
+ SwfdecGraphic *graphic = swfdec_swf_decoder_get_character (s, gid);
+ if (SWFDEC_IS_GRAPHIC (graphic)) {
+ SwfdecRect rect;
+ swfdec_rect_transform (&rect, &graphic->extents, &trans);
+ swfdec_rect_union (&SWFDEC_GRAPHIC (button)->extents, &SWFDEC_GRAPHIC (button)->extents, &rect);
+ } else {
+ SWFDEC_ERROR ("graphic for id %u not found", gid);
+ }
+ }
+ }
+ swfdec_bits_get_u8 (&bits);
+ if (swfdec_bits_left (&bits)) {
+ SWFDEC_WARNING ("%u bytes left when parsing button records", swfdec_bits_left (&bits) / 8);
+ }
+ button->records = g_slist_reverse (button->records);
+
+ script_name = g_strdup_printf ("Button%u", SWFDEC_CHARACTER (button)->id);
+ while (length != 0) {
+ guint condition, key;
+
+ length = swfdec_bits_get_u16 (&s->b);
+ if (length)
+ swfdec_bits_init_bits (&bits, &s->b, length > 2 ? length - 2 : 0);
+ else
+ swfdec_bits_init_bits (&bits, &s->b, swfdec_bits_left (&s->b) / 8);
+ condition = swfdec_bits_get_u16 (&bits);
+ key = condition >> 9;
+ condition &= 0x1FF;
+ condition = swfdec_button_translate_conditions (condition, button->menubutton);
+
+ SWFDEC_LOG (" length = %d", length);
+
+ if (button->events == NULL)
+ button->events = swfdec_event_list_new (SWFDEC_DECODER (s)->player);
+ SWFDEC_LOG (" new event for condition %u (key %u)", condition, key);
+ swfdec_event_list_parse (button->events, &bits, s->version, condition, key,
+ script_name);
+ if (swfdec_bits_left (&bits)) {
+ SWFDEC_WARNING ("%u bytes left after parsing script", swfdec_bits_left (&bits) / 8);
+ }
+ }
+ g_free (script_name);
+
+ return SWFDEC_STATUS_OK;
+}
+
+int
+tag_func_define_button (SwfdecSwfDecoder * s, guint tag)
+{
+ guint id, flags;
+ SwfdecButton *button;
+
+ id = swfdec_bits_get_u16 (&s->b);
+ button = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_BUTTON);
+ if (!button)
+ return SWFDEC_STATUS_OK;
+
+ SWFDEC_LOG (" ID: %d", id);
+
+ while (swfdec_bits_peek_u8 (&s->b)) {
+ SwfdecBits tmp;
+ SwfdecBuffer *buffer;
+ cairo_matrix_t matrix;
+ guint gid;
+
+ tmp = s->b;
+ flags = swfdec_bits_get_u8 (&tmp);
+ gid = swfdec_bits_get_u16 (&tmp);
+ swfdec_bits_get_u16 (&tmp);
+ swfdec_bits_get_matrix (&tmp, &matrix, NULL);
+ buffer = swfdec_bits_get_buffer (&s->b, (swfdec_bits_left (&s->b) - swfdec_bits_left (&tmp)) / 8);
+ if (buffer == NULL)
+ break;
+ button->records = g_slist_prepend (button->records, buffer);
+ /* add hit state movies to button's extents */
+ if (flags & (1 << SWFDEC_BUTTON_HIT)) {
+ SwfdecGraphic *graphic = swfdec_swf_decoder_get_character (s, gid);
+ if (SWFDEC_IS_GRAPHIC (graphic)) {
+ SwfdecRect rect;
+ swfdec_rect_transform (&rect, &graphic->extents, &matrix);
+ swfdec_rect_union (&SWFDEC_GRAPHIC (button)->extents, &SWFDEC_GRAPHIC (button)->extents, &rect);
+ } else {
+ SWFDEC_ERROR ("graphic for id %u not found", gid);
+ }
+ }
+ }
+
+ swfdec_bits_get_u8 (&s->b);
+ button->records = g_slist_reverse (button->records);
+
+ if (swfdec_bits_peek_u8 (&s->b)) {
+ char *script_name = g_strdup_printf ("Button%u", id);
+ button->events = swfdec_event_list_new (SWFDEC_DECODER (s)->player);
+ SWFDEC_LOG (" event for button press");
+ swfdec_event_list_parse (button->events, &s->b, s->version, 1 << SWFDEC_EVENT_RELEASE,
+ 0, script_name);
+ g_free (script_name);
+ } else {
+ swfdec_bits_get_u8 (&s->b);
+ }
+ if (swfdec_bits_left (&s->b)) {
+ SWFDEC_WARNING ("%u bytes left after parsing script", swfdec_bits_left (&s->b) / 8);
+ }
+
+ return SWFDEC_STATUS_OK;
+}
+
diff --git a/swfdec/swfdec_button.h b/swfdec/swfdec_button.h
new file mode 100644
index 0000000..ddf5900
--- /dev/null
+++ b/swfdec/swfdec_button.h
@@ -0,0 +1,83 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_BUTTON_H_
+#define _SWFDEC_BUTTON_H_
+
+#include <libswfdec/swfdec_graphic.h>
+#include <libswfdec/swfdec_color.h>
+
+G_BEGIN_DECLS
+//typedef struct _SwfdecButton SwfdecButton;
+typedef struct _SwfdecButtonClass SwfdecButtonClass;
+
+#define SWFDEC_TYPE_BUTTON (swfdec_button_get_type())
+#define SWFDEC_IS_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_BUTTON))
+#define SWFDEC_IS_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_BUTTON))
+#define SWFDEC_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_BUTTON, SwfdecButton))
+#define SWFDEC_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_BUTTON, SwfdecButtonClass))
+
+/* these values have to be kept in line with record parsing */
+typedef enum {
+ SWFDEC_BUTTON_INIT = -1,
+ SWFDEC_BUTTON_UP = 0,
+ SWFDEC_BUTTON_OVER = 1,
+ SWFDEC_BUTTON_DOWN = 2,
+ SWFDEC_BUTTON_HIT = 3
+} SwfdecButtonState;
+
+/* these values have to be kept in line with condition parsing */
+typedef enum {
+ SWFDEC_BUTTON_IDLE_TO_OVER_UP = 0,
+ SWFDEC_BUTTON_OVER_UP_TO_IDLE = 1,
+ SWFDEC_BUTTON_OVER_UP_TO_OVER_DOWN = 2,
+ SWFDEC_BUTTON_OVER_DOWN_TO_OVER_UP = 3,
+ SWFDEC_BUTTON_OVER_DOWN_TO_OUT_DOWN = 4,
+ SWFDEC_BUTTON_OUT_DOWN_TO_OVER_DOWN = 5,
+ SWFDEC_BUTTON_OUT_DOWN_TO_IDLE = 6,
+ SWFDEC_BUTTON_IDLE_TO_OVER_DOWN = 7,
+ SWFDEC_BUTTON_OVER_DOWN_TO_IDLE = 8
+} SwfdecButtonCondition;
+
+struct _SwfdecButton {
+ SwfdecGraphic graphic; /* graphic->extents is used for HIT area extents only */
+
+ gboolean menubutton; /* treat as menubutton */
+
+ GSList * records; /* the contained objects */
+ SwfdecEventList * events; /* the events triggered by this button */
+ SwfdecSoundChunk * sounds[4]; /* for meaning of index see DefineButtonSound */
+};
+
+struct _SwfdecButtonClass
+{
+ SwfdecGraphicClass graphic_class;
+};
+
+GType swfdec_button_get_type (void);
+
+int tag_func_define_button (SwfdecSwfDecoder * s,
+ guint tag);
+int tag_func_define_button_2 (SwfdecSwfDecoder * s,
+ guint tag);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_button_movie.c b/swfdec/swfdec_button_movie.c
new file mode 100644
index 0000000..e7ccdba
--- /dev/null
+++ b/swfdec/swfdec_button_movie.c
@@ -0,0 +1,320 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_button_movie.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_audio_event.h"
+#include "swfdec_debug.h"
+#include "swfdec_event.h"
+#include "swfdec_filter.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_resource.h"
+
+G_DEFINE_TYPE (SwfdecButtonMovie, swfdec_button_movie, SWFDEC_TYPE_MOVIE)
+
+static void
+swfdec_button_movie_update_extents (SwfdecMovie *movie,
+ SwfdecRect *extents)
+{
+ swfdec_rect_union (extents, extents,
+ &SWFDEC_GRAPHIC (SWFDEC_BUTTON_MOVIE (movie)->button)->extents);
+}
+
+static void
+swfdec_button_movie_perform_place (SwfdecButtonMovie *button, SwfdecBits *bits)
+{
+ SwfdecMovie *movie = SWFDEC_MOVIE (button);
+ gboolean has_blend_mode, has_filters, v2;
+ SwfdecColorTransform ctrans;
+ SwfdecGraphic *graphic;
+ SwfdecPlayer *player;
+ cairo_matrix_t trans;
+ guint id, blend_mode;
+ SwfdecMovie *new;
+ int depth;
+
+ swfdec_bits_getbits (bits, 2); /* reserved */
+ has_blend_mode = swfdec_bits_getbit (bits);
+ has_filters = swfdec_bits_getbit (bits);
+ SWFDEC_LOG (" has_blend_mode = %d", has_blend_mode);
+ SWFDEC_LOG (" has_filters = %d", has_filters);
+ swfdec_bits_getbits (bits, 4); /* states */
+ id = swfdec_bits_get_u16 (bits);
+ depth = swfdec_bits_get_u16 (bits);
+ depth -= 16384;
+ if (swfdec_movie_find (movie, depth)) {
+ SWFDEC_WARNING ("depth %d already occupied, skipping placement.", depth + 16384);
+ return;
+ }
+ graphic = swfdec_swf_decoder_get_character (SWFDEC_SWF_DECODER (movie->resource->decoder), id);
+ if (!SWFDEC_IS_GRAPHIC (graphic)) {
+ SWFDEC_ERROR ("id %u does not specify a graphic", id);
+ return;
+ }
+
+ player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
+ new = swfdec_movie_new (player, depth, movie, movie->resource, graphic, NULL);
+ swfdec_bits_get_matrix (bits, &trans, NULL);
+ if (swfdec_bits_left (bits)) {
+ v2 = TRUE;
+ swfdec_bits_get_color_transform (bits, &ctrans);
+ if (has_blend_mode) {
+ blend_mode = swfdec_bits_get_u8 (bits);
+ SWFDEC_LOG (" blend mode = %u", blend_mode);
+ } else {
+ blend_mode = 0;
+ }
+ if (has_filters) {
+ GSList *filters = swfdec_filter_parse (player, bits);
+ g_slist_free (filters);
+ }
+ } else {
+ /* DefineButton1 record */
+ v2 = FALSE;
+ if (has_blend_mode || has_filters) {
+ SWFDEC_ERROR ("cool, a DefineButton1 with filters or blend mode");
+ }
+ blend_mode = 0;
+ }
+ swfdec_movie_set_static_properties (new, &trans, v2 ? &ctrans : NULL, 0, 0, blend_mode, NULL);
+ swfdec_movie_queue_script (new, SWFDEC_EVENT_INITIALIZE);
+ swfdec_movie_queue_script (new, SWFDEC_EVENT_CONSTRUCT);
+ swfdec_movie_queue_script (new, SWFDEC_EVENT_LOAD);
+ swfdec_movie_initialize (new);
+ if (swfdec_bits_left (bits)) {
+ SWFDEC_WARNING ("button record for id %u has %u bytes left", id,
+ swfdec_bits_left (bits) / 8);
+ }
+}
+
+static void
+swfdec_button_movie_set_state (SwfdecButtonMovie *button, SwfdecButtonState state)
+{
+ SwfdecMovie *movie = SWFDEC_MOVIE (button);
+ SwfdecMovie *child;
+ SwfdecBits bits;
+ GSList *walk;
+ guint old, new, i;
+ int depth;
+
+ if (button->state == state) {
+ SWFDEC_LOG ("not changing state, it's already in %d", state);
+ return;
+ }
+ SWFDEC_DEBUG ("changing state from %d to %d", button->state, state);
+ /* remove all movies that aren't in the new state */
+ new = 1 << state;
+ if (button->state >= 0) {
+ old = 1 << button->state;
+ for (walk = button->button->records; walk; walk = walk->next) {
+ swfdec_bits_init (&bits, walk->data);
+ i = swfdec_bits_get_u8 (&bits);
+ if ((i & old) && !(i & new)) {
+ swfdec_bits_get_u16 (&bits);
+ depth = swfdec_bits_get_u16 (&bits);
+ child = swfdec_movie_find (movie, depth - 16384);
+ if (child) {
+ swfdec_movie_remove (child);
+ } else {
+ SWFDEC_WARNING ("no child at depth %d, none removed", depth);
+ }
+ }
+ }
+ } else {
+ /* to make sure that this never triggers when initializing */
+ old = 0;
+ }
+ button->state = state;
+ /* add all movies that are in the new state */
+ for (walk = button->button->records; walk; walk = walk->next) {
+ swfdec_bits_init (&bits, walk->data);
+ i = swfdec_bits_peek_u8 (&bits);
+ if ((i & old) || !(i & new))
+ continue;
+ swfdec_button_movie_perform_place (button, &bits);
+ }
+}
+
+static gboolean
+swfdec_button_movie_mouse_events (SwfdecMovie *movie)
+{
+ return TRUE;
+}
+
+static void
+swfdec_button_movie_mouse_in (SwfdecMovie *movie)
+{
+ if (swfdec_player_is_mouse_pressed (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context)))
+ swfdec_button_movie_set_state (SWFDEC_BUTTON_MOVIE (movie), SWFDEC_BUTTON_DOWN);
+ else
+ swfdec_button_movie_set_state (SWFDEC_BUTTON_MOVIE (movie), SWFDEC_BUTTON_OVER);
+
+ SWFDEC_MOVIE_CLASS (swfdec_button_movie_parent_class)->mouse_in (movie);
+}
+
+static void
+swfdec_button_movie_mouse_out (SwfdecMovie *movie)
+{
+ SwfdecButtonMovie *button = SWFDEC_BUTTON_MOVIE (movie);
+
+ if (swfdec_player_is_mouse_pressed (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context))) {
+ if (button->button->menubutton) {
+ swfdec_button_movie_set_state (SWFDEC_BUTTON_MOVIE (movie), SWFDEC_BUTTON_UP);
+ } else {
+ swfdec_button_movie_set_state (SWFDEC_BUTTON_MOVIE (movie), SWFDEC_BUTTON_OVER);
+ }
+ } else {
+ swfdec_button_movie_set_state (button, SWFDEC_BUTTON_UP);
+ }
+
+ SWFDEC_MOVIE_CLASS (swfdec_button_movie_parent_class)->mouse_out (movie);
+}
+
+static void
+swfdec_button_movie_mouse_press (SwfdecMovie *movie, guint button)
+{
+ if (button != 0)
+ return;
+ swfdec_button_movie_set_state (SWFDEC_BUTTON_MOVIE (movie), SWFDEC_BUTTON_DOWN);
+
+ SWFDEC_MOVIE_CLASS (swfdec_button_movie_parent_class)->mouse_press (movie, button);
+}
+
+static void
+swfdec_button_movie_mouse_release (SwfdecMovie *movie, guint button)
+{
+ SwfdecPlayer *player;
+
+ if (button != 0)
+ return;
+ player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
+ if (player->priv->mouse_below == movie) {
+ swfdec_button_movie_set_state (SWFDEC_BUTTON_MOVIE (movie), SWFDEC_BUTTON_OVER);
+
+ SWFDEC_MOVIE_CLASS (swfdec_button_movie_parent_class)->mouse_release (movie, button);
+ } else {
+ swfdec_button_movie_set_state (SWFDEC_BUTTON_MOVIE (movie), SWFDEC_BUTTON_UP);
+
+ /* NB: We don't chain to parent here for menubuttons*/
+ if (!SWFDEC_BUTTON_MOVIE (movie)->button->menubutton)
+ SWFDEC_MOVIE_CLASS (swfdec_button_movie_parent_class)->mouse_release (movie, button);
+ }
+}
+
+static void
+swfdec_button_movie_init_movie (SwfdecMovie *mov)
+{
+ SwfdecButtonMovie *movie = SWFDEC_BUTTON_MOVIE (mov);
+
+ swfdec_button_movie_set_state (movie, SWFDEC_BUTTON_UP);
+}
+
+static gboolean
+swfdec_button_movie_hit_test (SwfdecButtonMovie *button, double x, double y)
+{
+ SwfdecSwfDecoder *dec;
+ GSList *walk;
+ double tmpx, tmpy;
+
+ dec = SWFDEC_SWF_DECODER (SWFDEC_MOVIE (button)->resource->decoder);
+ for (walk = button->button->records; walk; walk = walk->next) {
+ SwfdecGraphic *graphic;
+ SwfdecBits bits;
+ cairo_matrix_t matrix, inverse;
+ guint id;
+
+ swfdec_bits_init (&bits, walk->data);
+
+ if ((swfdec_bits_get_u8 (&bits) & (1 << SWFDEC_BUTTON_HIT)) == 0)
+ continue;
+
+ id = swfdec_bits_get_u16 (&bits);
+ swfdec_bits_get_u16 (&bits); /* depth */
+ graphic = swfdec_swf_decoder_get_character (dec, id);
+ if (!SWFDEC_IS_GRAPHIC (graphic)) {
+ SWFDEC_ERROR ("id %u is no graphic", id);
+ continue;
+ }
+ tmpx = x;
+ tmpy = y;
+ swfdec_bits_get_matrix (&bits, &matrix, &inverse);
+ cairo_matrix_transform_point (&inverse, &tmpx, &tmpy);
+
+ SWFDEC_LOG ("Checking button contents at %g %g (transformed from %g %g)", tmpx, tmpy, x, y);
+ if (swfdec_graphic_mouse_in (graphic, tmpx, tmpy))
+ return TRUE;
+ SWFDEC_LOG (" missed");
+ }
+ return FALSE;
+}
+
+static SwfdecMovie *
+swfdec_button_movie_contains (SwfdecMovie *movie, double x, double y, gboolean events)
+{
+ if (events) {
+ /* check for movies in a higher layer that react to events */
+ SwfdecMovie *ret;
+ ret = SWFDEC_MOVIE_CLASS (swfdec_button_movie_parent_class)->contains (movie, x, y, TRUE);
+ if (ret && ret != movie && swfdec_movie_get_mouse_events (ret))
+ return ret;
+ }
+
+ return swfdec_button_movie_hit_test (SWFDEC_BUTTON_MOVIE (movie), x, y) ? movie : NULL;
+}
+
+static void
+swfdec_button_movie_dispose (GObject *object)
+{
+ SwfdecButtonMovie *button = SWFDEC_BUTTON_MOVIE (object);
+
+ if (button->button) {
+ g_object_unref (button->button);
+ button->button = NULL;
+ }
+ G_OBJECT_CLASS (swfdec_button_movie_parent_class)->dispose (object);
+}
+
+static void
+swfdec_button_movie_class_init (SwfdecButtonMovieClass * g_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+ SwfdecMovieClass *movie_class = SWFDEC_MOVIE_CLASS (g_class);
+
+ object_class->dispose = swfdec_button_movie_dispose;
+ movie_class->init_movie = swfdec_button_movie_init_movie;
+ movie_class->update_extents = swfdec_button_movie_update_extents;
+ movie_class->contains = swfdec_button_movie_contains;
+
+ movie_class->mouse_events = swfdec_button_movie_mouse_events;
+ movie_class->mouse_in = swfdec_button_movie_mouse_in;
+ movie_class->mouse_out = swfdec_button_movie_mouse_out;
+ movie_class->mouse_press = swfdec_button_movie_mouse_press;
+ movie_class->mouse_release = swfdec_button_movie_mouse_release;
+}
+
+static void
+swfdec_button_movie_init (SwfdecButtonMovie *movie)
+{
+ movie->state = SWFDEC_BUTTON_INIT;
+}
+
diff --git a/swfdec/swfdec_button_movie.h b/swfdec/swfdec_button_movie.h
new file mode 100644
index 0000000..1f6dfaf
--- /dev/null
+++ b/swfdec/swfdec_button_movie.h
@@ -0,0 +1,54 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_BUTTON_MOVIE_H_
+#define _SWFDEC_BUTTON_MOVIE_H_
+
+#include <glib-object.h>
+#include <libswfdec/swfdec_movie.h>
+#include <libswfdec/swfdec_button.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _SwfdecButtonMovie SwfdecButtonMovie;
+typedef struct _SwfdecButtonMovieClass SwfdecButtonMovieClass;
+
+#define SWFDEC_TYPE_BUTTON_MOVIE (swfdec_button_movie_get_type())
+#define SWFDEC_IS_BUTTON_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_BUTTON_MOVIE))
+#define SWFDEC_IS_BUTTON_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_BUTTON_MOVIE))
+#define SWFDEC_BUTTON_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_BUTTON_MOVIE, SwfdecButtonMovie))
+#define SWFDEC_BUTTON_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_BUTTON_MOVIE, SwfdecButtonMovieClass))
+
+struct _SwfdecButtonMovie {
+ SwfdecMovie movie;
+
+ SwfdecButton * button; /* button we render */
+ SwfdecButtonState state; /* current state we're in */
+};
+
+struct _SwfdecButtonMovieClass {
+ SwfdecMovieClass movie_class;
+};
+
+GType swfdec_button_movie_get_type (void);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_button_movie_as.c b/swfdec/swfdec_button_movie_as.c
new file mode 100644
index 0000000..c6c2f36
--- /dev/null
+++ b/swfdec/swfdec_button_movie_as.c
@@ -0,0 +1,108 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+// properties
+SWFDEC_AS_NATIVE (105, 4, swfdec_button_get_scale9Grid)
+void
+swfdec_button_get_scale9Grid (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Button.scale9Grid (get)");
+}
+
+SWFDEC_AS_NATIVE (105, 5, swfdec_button_set_scale9Grid)
+void
+swfdec_button_set_scale9Grid (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Button.scale9Grid (set)");
+}
+
+SWFDEC_AS_NATIVE (105, 6, swfdec_button_get_filters)
+void
+swfdec_button_get_filters (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Button.filters (get)");
+}
+
+SWFDEC_AS_NATIVE (105, 7, swfdec_button_set_filters)
+void
+swfdec_button_set_filters (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Button.filters (set)");
+}
+
+SWFDEC_AS_NATIVE (105, 8, swfdec_button_get_cacheAsBitmap)
+void
+swfdec_button_get_cacheAsBitmap (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Button.cacheAsBitmap (get)");
+}
+
+SWFDEC_AS_NATIVE (105, 9, swfdec_button_set_cacheAsBitmap)
+void
+swfdec_button_set_cacheAsBitmap (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Button.cacheAsBitmap (set)");
+}
+
+SWFDEC_AS_NATIVE (105, 10, swfdec_button_get_blendMode)
+void
+swfdec_button_get_blendMode (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Button.blendMode (get)");
+}
+
+SWFDEC_AS_NATIVE (105, 11, swfdec_button_set_blendMode)
+void
+swfdec_button_set_blendMode (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Button.blendMode (set)");
+}
+
+// normal
+SWFDEC_AS_NATIVE (105, 3, swfdec_button_movie_getDepth)
+void
+swfdec_button_movie_getDepth (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Button.getDepth");
+}
+
+// constructor
+SWFDEC_AS_NATIVE (105, 0, swfdec_button_movie_construct)
+void
+swfdec_button_movie_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Button");
+}
diff --git a/swfdec/swfdec_cache.c b/swfdec/swfdec_cache.c
new file mode 100644
index 0000000..48104e6
--- /dev/null
+++ b/swfdec/swfdec_cache.c
@@ -0,0 +1,164 @@
+/* Swfdec
+ * Copyright (C) 2005 David Schleef <ds at schleef.org>
+ * 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_cache.h"
+#include "swfdec_debug.h"
+
+SwfdecCache *
+swfdec_cache_new (gulong max_size)
+{
+ SwfdecCache *cache;
+
+ g_return_val_if_fail (max_size > 0, NULL);
+
+ cache = g_new0 (SwfdecCache, 1);
+ cache->refcount = 1;
+ cache->queue = g_queue_new ();
+ cache->max_size = max_size;
+
+ return cache;
+}
+
+void
+swfdec_cache_ref (SwfdecCache *cache)
+{
+ g_return_if_fail (cache != NULL);
+
+ cache->refcount++;
+}
+
+void
+swfdec_cache_unref (SwfdecCache *cache)
+{
+ g_return_if_fail (cache != NULL);
+ g_return_if_fail (cache->refcount > 0);
+
+ cache->refcount--;
+ if (cache->refcount > 0)
+ return;
+
+ g_queue_free (cache->queue);
+ g_free (cache);
+}
+
+gulong
+swfdec_cache_get_usage (SwfdecCache *cache)
+{
+ g_return_val_if_fail (cache != NULL, 0);
+
+ return cache->usage;
+}
+
+void
+swfdec_cache_shrink (SwfdecCache *cache, gulong max_usage)
+{
+ g_return_if_fail (cache != NULL);
+
+ while (cache->usage > max_usage) {
+ SwfdecCacheHandle *handle = g_queue_pop_tail (cache->queue);
+ g_assert (handle);
+ cache->usage -= handle->size;
+ SWFDEC_LOG ("%p removing %p (%lu => %lu)", cache, handle,
+ cache->usage + handle->size, cache->usage);
+ handle->unload (handle);
+ }
+}
+
+gulong
+swfdec_cache_get_size (SwfdecCache *cache)
+{
+ g_return_val_if_fail (cache != NULL, 0);
+
+ return cache->max_size;
+}
+
+void
+swfdec_cache_set_size (SwfdecCache *cache, gulong max_usage)
+{
+ g_return_if_fail (cache != NULL);
+
+ swfdec_cache_shrink (cache, max_usage);
+ cache->max_size = max_usage;
+}
+
+/**
+ * swfdec_cache_add_handle:
+ * @cache: a #SwfdecCache
+ * @handle: a handle to add
+ *
+ * Adds @handle to @cache. If not enough space is available in the cache,
+ * the cache will unload existing handles first. If handle is already part
+ * of cache, its usage information will be updated. This will make it less
+ * likely that it gets unloaded.
+ **/
+void
+swfdec_cache_add_handle (SwfdecCache *cache, const SwfdecCacheHandle *handle)
+{
+ GList *list;
+
+ g_return_if_fail (cache != NULL);
+ g_return_if_fail (handle != NULL);
+ g_return_if_fail (handle->size > 0);
+ g_return_if_fail (handle->unload != NULL);
+
+ list = g_queue_find (cache->queue, handle);
+ if (list) {
+ /* bring to front of queue */
+ g_queue_unlink (cache->queue, list);
+ g_queue_push_head_link (cache->queue, list);
+ } else {
+ swfdec_cache_shrink (cache, cache->max_size - handle->size);
+ g_queue_push_head (cache->queue, (gpointer) handle);
+ cache->usage += handle->size;
+ SWFDEC_LOG ("%p adding %p (%lu => %lu)", cache, handle,
+ cache->usage - handle->size, cache->usage);
+ }
+}
+
+/**
+ * swfdec_cache_remove_handle:
+ * @cache: a #SwfdecCache
+ * @handle: the handle to remove
+ *
+ * Removes the given @handle from the @cache, if it was part of it. If the
+ * handle wasn't part of the cache, nothing happens.
+ **/
+void
+swfdec_cache_remove_handle (SwfdecCache *cache, const SwfdecCacheHandle *handle)
+{
+ GList *list;
+
+ g_return_if_fail (cache != NULL);
+ g_return_if_fail (handle != NULL);
+ g_return_if_fail (handle->size > 0);
+ g_return_if_fail (handle->unload != NULL);
+
+ list = g_queue_find (cache->queue, handle);
+ if (list) {
+ g_queue_delete_link (cache->queue, list);
+ cache->usage -= handle->size;
+ SWFDEC_LOG ("%p removing %p (%lu => %lu)", cache, handle,
+ cache->usage + handle->size, cache->usage);
+ }
+}
diff --git a/swfdec/swfdec_cache.h b/swfdec/swfdec_cache.h
new file mode 100644
index 0000000..5e58aa4
--- /dev/null
+++ b/swfdec/swfdec_cache.h
@@ -0,0 +1,63 @@
+/* Swfdec
+ * Copyright (C) 2005 David Schleef <ds at schleef.org>
+ * 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_CACHE_H_
+#define _SWFDEC_CACHE_H_
+
+#include <libswfdec/swfdec_types.h>
+
+G_BEGIN_DECLS
+
+//typedef struct _SwfdecCache SwfdecCache;
+//typedef struct _SwfdecCacheHandle SwfdecCacheHandle;
+
+struct _SwfdecCache {
+ guint refcount; /* reference count */
+ gulong max_size; /* max size of cache */
+ gulong usage; /* current size of cache */
+
+ GQueue * queue; /* queue of loaded SwfdecCacheHandle, sorted by most recently used */
+};
+
+struct _SwfdecCacheHandle {
+ gulong size; /* size of this item */
+
+ GDestroyNotify unload; /* function called when unloading this handle */
+};
+
+SwfdecCache * swfdec_cache_new (gulong max_size);
+void swfdec_cache_ref (SwfdecCache * cache);
+void swfdec_cache_unref (SwfdecCache * cache);
+
+gulong swfdec_cache_get_size (SwfdecCache * cache);
+void swfdec_cache_set_size (SwfdecCache * cache,
+ gulong max_usage);
+gulong swfdec_cache_get_usage (SwfdecCache * cache);
+void swfdec_cache_shrink (SwfdecCache * cache,
+ gulong max_usage);
+void swfdec_cache_add_handle (SwfdecCache * cache,
+ const SwfdecCacheHandle *handle);
+void swfdec_cache_remove_handle (SwfdecCache * cache,
+ const SwfdecCacheHandle *handle);
+
+
+G_END_DECLS
+
+#endif
diff --git a/swfdec/swfdec_cached.c b/swfdec/swfdec_cached.c
new file mode 100644
index 0000000..4279d1e
--- /dev/null
+++ b/swfdec/swfdec_cached.c
@@ -0,0 +1,123 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_cached.h"
+#include "swfdec_debug.h"
+
+
+G_DEFINE_ABSTRACT_TYPE (SwfdecCached, swfdec_cached, SWFDEC_TYPE_CHARACTER)
+
+static void
+swfdec_cached_dispose (GObject *object)
+{
+ SwfdecCached * cached = SWFDEC_CACHED (object);
+
+ swfdec_cached_unload (cached);
+ swfdec_cached_set_cache (cached, NULL);
+
+ G_OBJECT_CLASS (swfdec_cached_parent_class)->dispose (object);
+}
+
+static void
+swfdec_cached_class_init (SwfdecCachedClass * g_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+
+ object_class->dispose = swfdec_cached_dispose;
+}
+
+static void
+swfdec_cached_init (SwfdecCached * cached)
+{
+}
+
+void
+swfdec_cached_set_cache (SwfdecCached *cached, SwfdecCache *cache)
+{
+ g_return_if_fail (SWFDEC_IS_CACHED (cached));
+
+ if (cached->cache) {
+ if (cached->handle.unload)
+ swfdec_cache_remove_handle (cached->cache, &cached->handle);
+ swfdec_cache_unref (cached->cache);
+ }
+ cached->cache = cache;
+ if (cache) {
+ swfdec_cache_ref (cache);
+ if (cached->handle.unload)
+ swfdec_cache_add_handle (cached->cache, &cached->handle);
+ }
+}
+
+static void
+swfdec_cached_unload_func (gpointer data)
+{
+ SwfdecCached *cached = SWFDEC_CACHED ((void *) ((guint8 *) data - G_STRUCT_OFFSET (SwfdecCached, handle)));
+
+ cached->handle.unload = NULL;
+ swfdec_cached_unload (cached);
+}
+
+void
+swfdec_cached_load (SwfdecCached *cached, guint size)
+{
+ g_return_if_fail (SWFDEC_IS_CACHED (cached));
+ g_return_if_fail (cached->handle.unload == NULL);
+ g_return_if_fail (size > 0);
+
+ cached->handle.unload = swfdec_cached_unload_func;
+ cached->handle.size = size;
+ if (cached->cache)
+ swfdec_cache_add_handle (cached->cache, &cached->handle);
+}
+
+void
+swfdec_cached_use (SwfdecCached *cached)
+{
+ g_return_if_fail (SWFDEC_IS_CACHED (cached));
+ g_return_if_fail (cached->handle.unload != NULL);
+
+ if (cached->cache)
+ swfdec_cache_add_handle (cached->cache, &cached->handle);
+}
+
+void
+swfdec_cached_unload (SwfdecCached *cached)
+{
+ g_return_if_fail (SWFDEC_IS_CACHED (cached));
+
+ if (cached->handle.unload) {
+ if (cached->cache)
+ swfdec_cache_remove_handle (cached->cache, &cached->handle);
+ cached->handle.unload = NULL;
+ }
+ if (cached->handle.size) {
+ SwfdecCachedClass *klass;
+
+ klass = SWFDEC_CACHED_GET_CLASS (cached);
+ cached->handle.size = 0;
+ g_return_if_fail (klass->unload != NULL);
+ klass->unload (cached);
+ }
+}
+
diff --git a/swfdec/swfdec_cached.h b/swfdec/swfdec_cached.h
new file mode 100644
index 0000000..bc9a1f7
--- /dev/null
+++ b/swfdec/swfdec_cached.h
@@ -0,0 +1,65 @@
+/* Swfdec
+ * Copyright (c) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_CACHED_H_
+#define _SWFDEC_CACHED_H_
+
+#include <cairo.h>
+#include <libswfdec/swfdec_cache.h>
+#include <libswfdec/swfdec_character.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecCached SwfdecCached;
+typedef struct _SwfdecCachedClass SwfdecCachedClass;
+
+#define SWFDEC_TYPE_CACHED (swfdec_cached_get_type())
+#define SWFDEC_IS_CACHED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_CACHED))
+#define SWFDEC_IS_CACHED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_CACHED))
+#define SWFDEC_CACHED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_CACHED, SwfdecCached))
+#define SWFDEC_CACHED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_CACHED, SwfdecCachedClass))
+#define SWFDEC_CACHED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_CACHED, SwfdecCachedClass))
+
+
+struct _SwfdecCached {
+ SwfdecCharacter character;
+
+ SwfdecCache * cache; /* cache to use for cached */
+ SwfdecCacheHandle handle; /* handle to unload surface */
+};
+
+struct _SwfdecCachedClass
+{
+ SwfdecCharacterClass character_class;
+
+ void (* unload) (SwfdecCached * cached);
+};
+
+GType swfdec_cached_get_type (void);
+
+void swfdec_cached_load (SwfdecCached * cached,
+ guint size);
+void swfdec_cached_use (SwfdecCached * cached);
+void swfdec_cached_unload (SwfdecCached * cached);
+void swfdec_cached_set_cache (SwfdecCached * cached,
+ SwfdecCache * cache);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_camera.c b/swfdec/swfdec_camera.c
new file mode 100644
index 0000000..96b6e42
--- /dev/null
+++ b/swfdec/swfdec_camera.c
@@ -0,0 +1,89 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (2102, 200, swfdec_camera_get)
+void
+swfdec_camera_get (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+ SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Camera.get (static)");
+}
+
+SWFDEC_AS_NATIVE (2102, 201, swfdec_camera_names_get)
+void
+swfdec_camera_names_get (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Camera.names (static)");
+}
+
+SWFDEC_AS_NATIVE (2102, 0, swfdec_camera_setMode)
+void
+swfdec_camera_setMode (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+ SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Camera.setMode");
+}
+
+SWFDEC_AS_NATIVE (2102, 1, swfdec_camera_setQuality)
+void
+swfdec_camera_setQuality (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Camera.setQuality");
+}
+
+SWFDEC_AS_NATIVE (2102, 2, swfdec_camera_setKeyFrameInterval)
+void
+swfdec_camera_setKeyFrameInterval (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Camera.setKeyFrameInterval");
+}
+
+SWFDEC_AS_NATIVE (2102, 3, swfdec_camera_setMotionLevel)
+void
+swfdec_camera_setMotionLevel (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Camera.setMotionLevel");
+}
+
+SWFDEC_AS_NATIVE (2102, 4, swfdec_camera_setLoopback)
+void
+swfdec_camera_setLoopback (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Camera.setLoopback");
+}
+
+SWFDEC_AS_NATIVE (2102, 5, swfdec_camera_setCursor)
+void
+swfdec_camera_setCursor (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Camera.setCursor");
+}
diff --git a/swfdec/swfdec_character.c b/swfdec/swfdec_character.c
new file mode 100644
index 0000000..db1aff5
--- /dev/null
+++ b/swfdec/swfdec_character.c
@@ -0,0 +1,42 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_character.h"
+#include "swfdec_debug.h"
+#include "swfdec_decoder.h"
+
+
+G_DEFINE_ABSTRACT_TYPE (SwfdecCharacter, swfdec_character, G_TYPE_OBJECT)
+
+static void
+swfdec_character_class_init (SwfdecCharacterClass *klass)
+{
+}
+
+static void
+swfdec_character_init (SwfdecCharacter *character)
+{
+}
+
diff --git a/swfdec/swfdec_character.h b/swfdec/swfdec_character.h
new file mode 100644
index 0000000..50b577b
--- /dev/null
+++ b/swfdec/swfdec_character.h
@@ -0,0 +1,62 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_CHARACTER_H_
+#define _SWFDEC_CHARACTER_H_
+
+#include <glib-object.h>
+#include <libswfdec/swfdec_types.h>
+#include <libswfdec/swfdec_rect.h>
+
+G_BEGIN_DECLS
+//typedef struct _SwfdecCharacter SwfdecCharacter;
+typedef struct _SwfdecCharacterClass SwfdecCharacterClass;
+
+#define SWFDEC_TYPE_CHARACTER (swfdec_character_get_type())
+#define SWFDEC_IS_CHARACTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_CHARACTER))
+#define SWFDEC_IS_CHARACTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_CHARACTER))
+#define SWFDEC_CHARACTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_CHARACTER, SwfdecCharacter))
+#define SWFDEC_CHARACTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_CHARACTER, SwfdecCharacterClass))
+#define SWFDEC_CHARACTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_CHARACTER, SwfdecCharacterClass))
+
+struct _SwfdecCharacter
+{
+ GObject object;
+
+ int id; /* id of this character in the character list */
+};
+
+struct _SwfdecCharacterClass
+{
+ GObjectClass object_class;
+};
+
+GType swfdec_character_get_type (void);
+gpointer swfdec_character_new (SwfdecDecoder *dec, GType type);
+
+gboolean swfdec_character_mouse_in (SwfdecCharacter *character,
+ double x, double y, int button);
+void swfdec_character_render (SwfdecCharacter *character, cairo_t *cr,
+ const SwfdecColorTransform *color, const SwfdecRect *inval, gboolean fill);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_codec_adpcm.c b/swfdec/swfdec_codec_adpcm.c
new file mode 100644
index 0000000..0aa39ab
--- /dev/null
+++ b/swfdec/swfdec_codec_adpcm.c
@@ -0,0 +1,186 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_codec_audio.h"
+#include "swfdec_bits.h"
+#include "swfdec_debug.h"
+#include "swfdec_internal.h"
+
+typedef struct {
+ SwfdecAudioDecoder decoder;
+ SwfdecBufferQueue * queue;
+} SwfdecAudioDecoderAdpcm;
+
+static const int indexTable[4][16] = {
+ { -1, 2 },
+ { -1, -1, 2, 4 },
+ { -1, -1, -1, -1, 2, 4, 6, 8 },
+ { -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16 }
+};
+
+static const int stepSizeTable[89] = {
+ 7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
+ 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
+ 50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
+ 130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
+ 337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
+ 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
+ 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
+ 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
+ 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
+};
+
+static SwfdecBuffer *
+swfdec_audio_decoder_adpcm_decode_chunk (SwfdecBits *bits, guint n_bits, guint channels)
+{
+ SwfdecBuffer *ret;
+ guint len;
+ guint i, j, ch;
+ guint index[2];
+ int pred[2];
+ gint16 *out;
+ guint delta, sign, sign_mask;
+ int diff;
+ const int *realIndexTable;
+ guint step[2];
+
+ realIndexTable = indexTable[n_bits - 2];
+ for (ch = 0; ch < channels; ch++) {
+ /* can't use get_s16 here since that would be aligned */
+ pred[ch] = swfdec_bits_getsbits (bits, 16);
+ index[ch] = swfdec_bits_getbits (bits, 6);
+ if (index[ch] >= G_N_ELEMENTS (stepSizeTable)) {
+ SWFDEC_ERROR ("initial index too big: %u, max allowed is %td",
+ index[ch], G_N_ELEMENTS (stepSizeTable) - 1);
+ index[ch] = G_N_ELEMENTS (stepSizeTable) - 1;
+ }
+ step[ch] = stepSizeTable[index[ch]];
+ }
+ len = swfdec_bits_left (bits) / channels / n_bits;
+ len = MIN (len, 4095);
+ ret = swfdec_buffer_new_and_alloc ((len + 1) * sizeof (gint16) * channels);
+ out = (gint16 *) (void *) ret->data;
+ /* output initial value */
+ SWFDEC_LOG ("decoding %u samples", len + 1);
+ for (ch = 0; ch < channels; ch++)
+ *out++ = pred[ch];
+ sign_mask = 1 << (n_bits - 1);
+ for (i = 0; i < len; i++) {
+ for (ch = 0; ch < channels; ch++) {
+ /* Step 1 - get the delta value */
+ delta = swfdec_bits_getbits (bits, n_bits);
+
+ /* Step 2 - Separate sign and magnitude */
+ sign = delta & sign_mask;
+ delta -= sign;
+
+ /* Step 3 - Find new index value (for later) */
+ index[ch] += realIndexTable[delta];
+ if ( index[ch] >= G_MAXINT ) index[ch] = 0; /* underflow */
+ if ( index[ch] >= G_N_ELEMENTS (stepSizeTable) ) index[ch] = G_N_ELEMENTS (stepSizeTable) - 1;
+
+ /* Step 4 - Compute difference and new predicted value */
+ j = n_bits - 1;
+ diff = step[ch] >> j;
+ do {
+ j--;
+ if (delta & 1)
+ diff += step[ch] >> j;
+ delta >>= 1;
+ } while (j > 0 && delta);
+
+ if ( sign )
+ pred[ch] -= diff;
+ else
+ pred[ch] += diff;
+
+ /* Step 5 - clamp output value */
+ pred[ch] = CLAMP (pred[ch], -32768, 32767);
+
+ /* Step 6 - Update step value */
+ step[ch] = stepSizeTable[index[ch]];
+
+ /* Step 7 - Output value */
+ *out++ = pred[ch];
+ }
+ }
+ return ret;
+}
+
+static void
+swfdec_audio_decoder_adpcm_push (SwfdecAudioDecoder *dec, SwfdecBuffer *buffer)
+{
+ SwfdecAudioDecoderAdpcm *adpcm = (SwfdecAudioDecoderAdpcm *) dec;
+ guint channels, n_bits;
+ SwfdecBits bits;
+
+ if (buffer == NULL)
+ return;
+
+ channels = swfdec_audio_format_get_channels (dec->format);
+ swfdec_bits_init (&bits, buffer);
+ n_bits = swfdec_bits_getbits (&bits, 2) + 2;
+ SWFDEC_DEBUG ("starting decoding: %u channels, %u bits", channels, n_bits);
+ /* 22 is minimum required header size */
+ while (swfdec_bits_left (&bits) >= 22) {
+ buffer = swfdec_audio_decoder_adpcm_decode_chunk (&bits, n_bits, channels);
+ if (buffer)
+ swfdec_buffer_queue_push (adpcm->queue, buffer);
+ }
+}
+
+static SwfdecBuffer *
+swfdec_audio_decoder_adpcm_pull (SwfdecAudioDecoder *dec)
+{
+ SwfdecAudioDecoderAdpcm *adpcm = (SwfdecAudioDecoderAdpcm *) dec;
+
+ return swfdec_buffer_queue_pull_buffer (adpcm->queue);
+}
+
+static void
+swfdec_audio_decoder_adpcm_free (SwfdecAudioDecoder *dec)
+{
+ SwfdecAudioDecoderAdpcm *adpcm = (SwfdecAudioDecoderAdpcm *) dec;
+
+ swfdec_buffer_queue_unref (adpcm->queue);
+ g_slice_free (SwfdecAudioDecoderAdpcm, adpcm);
+}
+
+SwfdecAudioDecoder *
+swfdec_audio_decoder_adpcm_new (guint type, SwfdecAudioFormat format)
+{
+ SwfdecAudioDecoderAdpcm *adpcm;
+
+ if (type != SWFDEC_AUDIO_CODEC_ADPCM)
+ return NULL;
+ adpcm = g_slice_new (SwfdecAudioDecoderAdpcm);
+ adpcm->decoder.format = swfdec_audio_format_new (swfdec_audio_format_get_rate (format),
+ swfdec_audio_format_get_channels (format), TRUE);
+ adpcm->decoder.push = swfdec_audio_decoder_adpcm_push;
+ adpcm->decoder.pull = swfdec_audio_decoder_adpcm_pull;
+ adpcm->decoder.free = swfdec_audio_decoder_adpcm_free;
+ adpcm->queue = swfdec_buffer_queue_new ();
+
+ return &adpcm->decoder;
+}
+
diff --git a/swfdec/swfdec_codec_audio.c b/swfdec/swfdec_codec_audio.c
new file mode 100644
index 0000000..34edbe9
--- /dev/null
+++ b/swfdec/swfdec_codec_audio.c
@@ -0,0 +1,284 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_codec_audio.h"
+#include "swfdec_debug.h"
+#include "swfdec_internal.h"
+
+/*** UNCOMPRESSED SOUND ***/
+
+typedef struct {
+ SwfdecAudioDecoder decoder;
+ SwfdecBufferQueue * queue; /* queue collecting output buffers */
+} SwfdecAudioDecoderUncompressed;
+
+static void
+swfdec_audio_decoder_uncompressed_decode_8bit (SwfdecAudioDecoder *decoder,
+ SwfdecBuffer *buffer)
+{
+ SwfdecBuffer *ret;
+ gint16 *out;
+ guint8 *in;
+ guint i;
+
+ if (buffer == NULL)
+ return;
+
+ ret = swfdec_buffer_new_and_alloc (buffer->length * 2);
+ out = (gint16 *) (void *) ret->data;
+ in = buffer->data;
+ for (i = 0; i < buffer->length; i++) {
+ *out = ((gint16) *in << 8) ^ (-1);
+ out++;
+ in++;
+ }
+ swfdec_buffer_queue_push (((SwfdecAudioDecoderUncompressed *) decoder)->queue, ret);
+}
+
+static void
+swfdec_audio_decoder_uncompressed_decode_16bit (SwfdecAudioDecoder *decoder,
+ SwfdecBuffer *buffer)
+{
+ if (buffer == NULL)
+ return;
+
+ swfdec_buffer_ref (buffer);
+ swfdec_buffer_queue_push (((SwfdecAudioDecoderUncompressed *) decoder)->queue, buffer);
+}
+
+static SwfdecBuffer *
+swfdec_audio_decoder_uncompressed_pull (SwfdecAudioDecoder *decoder)
+{
+ SwfdecAudioDecoderUncompressed *dec = (SwfdecAudioDecoderUncompressed *) decoder;
+
+ return swfdec_buffer_queue_pull_buffer (dec->queue);
+}
+
+static void
+swfdec_audio_decoder_uncompressed_free (SwfdecAudioDecoder *decoder)
+{
+ SwfdecAudioDecoderUncompressed *dec = (SwfdecAudioDecoderUncompressed *) decoder;
+
+ swfdec_buffer_queue_unref (dec->queue);
+ g_free (dec);
+}
+
+static SwfdecAudioDecoder *
+swfdec_audio_decoder_uncompressed_new (guint type, SwfdecAudioFormat format)
+{
+ SwfdecAudioDecoderUncompressed *dec;
+
+ if (type != SWFDEC_AUDIO_CODEC_UNDEFINED &&
+ type != SWFDEC_AUDIO_CODEC_UNCOMPRESSED)
+ return NULL;
+ if (type == SWFDEC_AUDIO_CODEC_UNDEFINED) {
+ SWFDEC_WARNING ("endianness of audio unknown, assuming little endian");
+ }
+ dec = g_new (SwfdecAudioDecoderUncompressed, 1);
+ dec->decoder.format = format;
+ if (swfdec_audio_format_is_16bit (format))
+ dec->decoder.push = swfdec_audio_decoder_uncompressed_decode_16bit;
+ else
+ dec->decoder.push = swfdec_audio_decoder_uncompressed_decode_8bit;
+ dec->decoder.pull = swfdec_audio_decoder_uncompressed_pull;
+ dec->decoder.free = swfdec_audio_decoder_uncompressed_free;
+ dec->queue = swfdec_buffer_queue_new ();
+
+ return &dec->decoder;
+}
+
+/*** PUBLIC API ***/
+
+static SwfdecAudioDecoder *
+swfdec_audio_decoder_builtin_new (guint codec, SwfdecAudioFormat format)
+{
+ SwfdecAudioDecoder *ret;
+
+ ret = swfdec_audio_decoder_uncompressed_new (codec, format);
+ if (ret == NULL)
+ ret = swfdec_audio_decoder_adpcm_new (codec, format);
+
+ return ret;
+}
+
+struct {
+ const char * name;
+ SwfdecAudioDecoder * (* func) (guint, SwfdecAudioFormat);
+} audio_codecs[] = {
+ { "builtin", swfdec_audio_decoder_builtin_new },
+#ifdef HAVE_GST
+ { "gst", swfdec_audio_decoder_gst_new },
+#endif
+#ifdef HAVE_MAD
+ { "mad", swfdec_audio_decoder_mad_new },
+#endif
+#ifdef HAVE_FFMPEG
+ { "ffmpeg", swfdec_audio_decoder_ffmpeg_new },
+#endif
+ { NULL, }
+};
+
+/**
+ * swfdec_audio_decoder_new:
+ * @format: #SwfdecAudioCodec to decode
+ *
+ * Creates a decoder suitable for decoding @format. If no decoder is available
+ * for the given for mat, %NULL is returned.
+ *
+ * Returns: a new decoder or %NULL
+ **/
+SwfdecAudioDecoder *
+swfdec_audio_decoder_new (guint codec, SwfdecAudioFormat format)
+{
+ SwfdecAudioDecoder *ret;
+ const char *list;
+
+ g_return_val_if_fail (SWFDEC_IS_AUDIO_FORMAT (format), NULL);
+
+ list = g_getenv ("SWFDEC_CODEC_AUDIO");
+ if (list == NULL)
+ list = g_getenv ("SWFDEC_CODEC");
+ if (list == NULL) {
+ guint i;
+ ret = NULL;
+ for (i = 0; audio_codecs[i].name != NULL; i++) {
+ ret = audio_codecs[i].func (codec, format);
+ if (ret)
+ break;
+ }
+ } else {
+ char **split = g_strsplit (list, ",", -1);
+ guint i, j;
+ ret = NULL;
+ SWFDEC_LOG ("codecs limited to \"%s\"", list);
+ for (i = 0; split[i] != NULL && ret == NULL; i++) {
+ for (j = 0; audio_codecs[j].name != NULL; j++) {
+ if (g_ascii_strcasecmp (audio_codecs[j].name, split[i]) != 0)
+ continue;
+ ret = audio_codecs[j].func (codec, format);
+ if (ret)
+ break;
+ }
+ }
+ g_strfreev (split);
+ }
+
+ if (ret) {
+ ret->codec = codec;
+ g_return_val_if_fail (ret->push, NULL);
+ g_return_val_if_fail (ret->pull, NULL);
+ g_return_val_if_fail (ret->free, NULL);
+ } else {
+ SWFDEC_ERROR ("no suitable decoder for audio codec %u", codec);
+ return NULL;
+ }
+ return ret;
+}
+
+/**
+ * swfdec_audio_decoder_free:
+ * @decoder: a #SwfdecAudioDecoder
+ *
+ * Frees the given decoder. When finishing decoding, be sure to pass a %NULL
+ * buffer to swfdec_audio_decoder_push() first to flush the decoder. See that
+ * function for details.
+ **/
+void
+swfdec_audio_decoder_free (SwfdecAudioDecoder *decoder)
+{
+ g_return_if_fail (decoder != NULL);
+
+ decoder->free (decoder);
+}
+
+/**
+ * swfdec_audio_decoder_get_format:
+ * @decoder: a #SwfdecAudioDecoder
+ *
+ * Queries the format that is used by the decoder for its produced output.
+ * The format will only be valid after swfdec_audio_decoder_pull () has been
+ * called at least once.
+ *
+ * Returns: the format of the decoded data
+ **/
+SwfdecAudioFormat
+swfdec_audio_decoder_get_format (SwfdecAudioDecoder *decoder)
+{
+ g_return_val_if_fail (decoder != NULL, 0);
+ g_return_val_if_fail (SWFDEC_IS_AUDIO_FORMAT (decoder->format), 0);
+
+ return decoder->format;
+}
+
+/**
+ * swfdec_audio_decoder_push:
+ * @decoder: a #SwfdecAudioDecoder
+ * @buffer: a #SwfdecBuffer to process or %NULL to flush
+ *
+ * Pushes a new buffer into the decoding pipeline. After this the results can
+ * be queried using swfdec_audio_decoder_pull(). Some decoders may not decode
+ * all available data immediately. So when you are done decoding, you may want
+ * to flush the decoder. Flushing can be achieved by passing %NULL as the
+ * @buffer argument. Do this when you are finished decoding.
+ **/
+void
+swfdec_audio_decoder_push (SwfdecAudioDecoder *decoder, SwfdecBuffer *buffer)
+{
+ g_return_if_fail (decoder != NULL);
+
+ decoder->push (decoder, buffer);
+}
+
+/**
+ * swfdec_audio_decoder_pull:
+ * @decoder: a #SwfdecAudioDecoder
+ *
+ * Gets the next buffer of decoded audio data. Since some decoders do not
+ * produce one output buffer per input buffer, any number of buffers may be
+ * available after calling swfdec_audio_decoder_push(), even none. When no more
+ * buffers are available, this function returns %NULL. You need to provide more
+ * input in then. A simple decoding pipeline would look like this:
+ * <informalexample><programlisting>do {
+ * input = next_input_buffer ();
+ * swfdec_audio_decoder_push (decoder, input);
+ * while ((output = swfdec_audio_decoder_pull (decoder))) {
+ * ... process output ...
+ * }
+ * } while (input != NULL); </programlisting></informalexample>
+ *
+ * Returns: the next buffer or %NULL if no more buffers are available.
+ **/
+SwfdecBuffer *
+swfdec_audio_decoder_pull (SwfdecAudioDecoder *decoder)
+{
+ SwfdecBuffer *ret;
+
+ g_return_val_if_fail (decoder != NULL, NULL);
+
+ ret = decoder->pull (decoder);
+ if (ret == NULL)
+ return NULL;
+ g_return_val_if_fail (SWFDEC_IS_AUDIO_FORMAT (decoder->format), ret);
+ return ret;
+}
+
diff --git a/swfdec/swfdec_codec_audio.h b/swfdec/swfdec_codec_audio.h
new file mode 100644
index 0000000..48eb139
--- /dev/null
+++ b/swfdec/swfdec_codec_audio.h
@@ -0,0 +1,57 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_CODEC_H_
+#define _SWFDEC_CODEC_H_
+
+#include <glib.h>
+#include <libswfdec/swfdec_audio_internal.h>
+#include <libswfdec/swfdec_buffer.h>
+
+typedef struct _SwfdecAudioDecoder SwfdecAudioDecoder;
+
+#define SWFDEC_AUDIO_CODEC_UNDEFINED 0
+#define SWFDEC_AUDIO_CODEC_ADPCM 1
+#define SWFDEC_AUDIO_CODEC_MP3 2
+#define SWFDEC_AUDIO_CODEC_UNCOMPRESSED 3
+#define SWFDEC_AUDIO_CODEC_NELLYMOSER_8KHZ 5
+#define SWFDEC_AUDIO_CODEC_NELLYMOSER 6
+
+typedef SwfdecAudioDecoder * (SwfdecAudioDecoderNewFunc) (guint type, gboolean width,
+ SwfdecAudioFormat format);
+struct _SwfdecAudioDecoder {
+ guint codec;
+ SwfdecAudioFormat format;
+ void (* push) (SwfdecAudioDecoder * decoder,
+ SwfdecBuffer * buffer);
+ SwfdecBuffer * (* pull) (SwfdecAudioDecoder * decoder);
+ void (* free) (SwfdecAudioDecoder * decoder);
+};
+
+SwfdecAudioDecoder * swfdec_audio_decoder_new (guint codec,
+ SwfdecAudioFormat format);
+void swfdec_audio_decoder_free (SwfdecAudioDecoder * decoder);
+SwfdecAudioFormat swfdec_audio_decoder_get_format (SwfdecAudioDecoder * decoder);
+void swfdec_audio_decoder_push (SwfdecAudioDecoder * decoder,
+ SwfdecBuffer * buffer);
+SwfdecBuffer * swfdec_audio_decoder_pull (SwfdecAudioDecoder * decoder);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_codec_ffmpeg.c b/swfdec/swfdec_codec_ffmpeg.c
new file mode 100644
index 0000000..9e159d3
--- /dev/null
+++ b/swfdec/swfdec_codec_ffmpeg.c
@@ -0,0 +1,317 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <string.h>
+#include <avcodec.h>
+#include <swscale.h>
+
+#include "swfdec_codec_audio.h"
+#include "swfdec_codec_video.h"
+#include "swfdec_debug.h"
+#include "swfdec_internal.h"
+
+/*** GENERAL ***/
+
+static AVCodecContext *
+swfdec_codec_ffmpeg_init (enum CodecID id)
+{
+ AVCodec *codec;
+ AVCodecContext *ctx;
+ static gboolean initialized = FALSE;
+
+ if (!initialized) {
+ avcodec_init();
+ avcodec_register_all ();
+ initialized = TRUE;
+ }
+
+ codec = avcodec_find_decoder (id);
+ if (!codec)
+ return NULL;
+
+ ctx = avcodec_alloc_context ();
+ if (avcodec_open (ctx, codec) < 0)
+ goto fail;
+
+ return ctx;
+fail:
+ SWFDEC_ERROR ("failed to initialize playback via ffmpeg");
+ avcodec_close (ctx);
+ av_free (ctx);
+ return NULL;
+}
+
+/*** AUDIO ***/
+
+typedef struct {
+ SwfdecAudioDecoder decoder;
+ AVCodecContext * ctx;
+ SwfdecBufferQueue * queue;
+} SwfdecAudioDecoderFFMpeg;
+
+static SwfdecBuffer *
+swfdec_codec_ffmpeg_convert (AVCodecContext *ctx, SwfdecBuffer *buffer)
+{
+ SwfdecBuffer *ret;
+ guint count, i, j, rate;
+ gint16 *out, *in;
+
+ /* do the common case fast */
+ if (ctx->channels == 2 && ctx->sample_rate == 44100) {
+ ret = swfdec_buffer_new_and_alloc (buffer->length);
+ memcpy (ret->data, buffer->data, buffer->length);
+ return ret;
+ }
+
+ switch (ctx->sample_rate) {
+ case 44100:
+ rate = 1;
+ break;
+ case 22050:
+ rate = 2;
+ break;
+ case 11025:
+ rate = 4;
+ break;
+ default:
+ SWFDEC_ERROR ("unsupported sample rate %u", ctx->sample_rate);
+ return NULL;
+ }
+ if (ctx->channels == 1)
+ rate *= 2;
+ ret = swfdec_buffer_new_and_alloc (buffer->length * rate);
+ out = (gint16 *) ret->data;
+ in = (gint16 *) buffer->data;
+ count = buffer->length / 2;
+
+ for (i = 0; i < count; i++) {
+ for (j = 0; j < rate; j++) {
+ *out++ = *in;
+ }
+ in++;
+ }
+ return ret;
+}
+
+static void
+swfdec_audio_decoder_ffmpeg_push (SwfdecAudioDecoder *dec, SwfdecBuffer *buffer)
+{
+ SwfdecAudioDecoderFFMpeg *ffmpeg = (SwfdecAudioDecoderFFMpeg *) dec;
+ int out_size;
+ int len;
+ guint amount;
+ SwfdecBuffer *outbuf = NULL;
+
+ if (buffer == NULL)
+ return;
+ outbuf = swfdec_buffer_new_and_alloc (AVCODEC_MAX_AUDIO_FRAME_SIZE);
+ for (amount = 0; amount < buffer->length; amount += len) {
+
+ out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+ len = avcodec_decode_audio2 (ffmpeg->ctx, (short *) outbuf->data, &out_size, buffer->data + amount, buffer->length - amount);
+
+ if (len < 0) {
+ SWFDEC_ERROR ("Error %d while decoding", len);
+ swfdec_buffer_unref (outbuf);
+ return;
+ }
+ if (out_size > 0) {
+ SwfdecBuffer *convert;
+ outbuf->length = out_size;
+ convert = swfdec_codec_ffmpeg_convert (ffmpeg->ctx, outbuf);
+ if (convert == NULL) {
+ swfdec_buffer_unref (outbuf);
+ return;
+ }
+ swfdec_buffer_queue_push (ffmpeg->queue, convert);
+ outbuf->length = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+ }
+ }
+ swfdec_buffer_unref (outbuf);
+}
+
+static SwfdecBuffer *
+swfdec_audio_decoder_ffmpeg_pull (SwfdecAudioDecoder *dec)
+{
+ SwfdecAudioDecoderFFMpeg *ffmpeg = (SwfdecAudioDecoderFFMpeg *) dec;
+
+ return swfdec_buffer_queue_pull_buffer (ffmpeg->queue);
+}
+
+static void
+swfdec_audio_decoder_ffmpeg_free (SwfdecAudioDecoder *dec)
+{
+ SwfdecAudioDecoderFFMpeg *ffmpeg = (SwfdecAudioDecoderFFMpeg *) dec;
+
+ avcodec_close (ffmpeg->ctx);
+ av_free (ffmpeg->ctx);
+ swfdec_buffer_queue_unref (ffmpeg->queue);
+
+ g_slice_free (SwfdecAudioDecoderFFMpeg, ffmpeg);
+}
+
+SwfdecAudioDecoder *
+swfdec_audio_decoder_ffmpeg_new (guint type, SwfdecAudioFormat format)
+{
+ SwfdecAudioDecoderFFMpeg *ffmpeg;
+ AVCodecContext *ctx;
+ enum CodecID id;
+
+ switch (type) {
+ case SWFDEC_AUDIO_CODEC_ADPCM:
+ id = CODEC_ID_ADPCM_SWF;
+ break;
+ case SWFDEC_AUDIO_CODEC_MP3:
+ id = CODEC_ID_MP3;
+ break;
+ default:
+ return NULL;
+ }
+ ctx = swfdec_codec_ffmpeg_init (id);
+ if (ctx == NULL)
+ return NULL;
+ ffmpeg = g_slice_new (SwfdecAudioDecoderFFMpeg);
+ ffmpeg->ctx = ctx;
+ ffmpeg->queue = swfdec_buffer_queue_new ();
+ ffmpeg->decoder.format = swfdec_audio_format_new (44100, 2, TRUE);
+ ffmpeg->decoder.pull = swfdec_audio_decoder_ffmpeg_pull;
+ ffmpeg->decoder.push = swfdec_audio_decoder_ffmpeg_push;
+ ffmpeg->decoder.free = swfdec_audio_decoder_ffmpeg_free;
+ ctx->sample_rate = swfdec_audio_format_get_rate (format);
+ ctx->channels = swfdec_audio_format_get_channels (format);
+
+ return &ffmpeg->decoder;
+}
+
+/*** VIDEO ***/
+
+typedef struct {
+ SwfdecVideoDecoder decoder;
+ AVCodecContext * ctx; /* out context (d'oh) */
+ AVFrame * frame; /* the frame we use for decoding */
+ enum PixelFormat format; /* format we must output */
+} SwfdecVideoDecoderFFMpeg;
+
+static enum PixelFormat
+swfdec_video_decoder_ffmpeg_get_format (guint codec)
+{
+ switch (swfdec_video_codec_get_format (codec)) {
+ case SWFDEC_VIDEO_FORMAT_RGBA:
+ return PIX_FMT_RGB32;
+ case SWFDEC_VIDEO_FORMAT_I420:
+ return PIX_FMT_YUV420P;
+ default:
+ g_return_val_if_reached (PIX_FMT_RGB32);
+ }
+}
+
+#define ALIGNMENT 31
+static gboolean
+swfdec_video_decoder_ffmpeg_decode (SwfdecVideoDecoder *dec, SwfdecBuffer *buffer,
+ SwfdecVideoImage *image)
+{
+ SwfdecVideoDecoderFFMpeg *codec = (SwfdecVideoDecoderFFMpeg *) dec;
+ int got_image = 0;
+ guchar *tmp, *aligned;
+
+ /* fullfill alignment and padding requirements */
+ tmp = g_try_malloc (buffer->length + ALIGNMENT + FF_INPUT_BUFFER_PADDING_SIZE);
+ if (tmp == NULL) {
+ SWFDEC_WARNING ("Could not allocate temporary memory");
+ return FALSE;
+ }
+ aligned = (guchar *) (((uintptr_t) tmp + ALIGNMENT) & ~ALIGNMENT);
+ memcpy (aligned, buffer->data, buffer->length);
+ memset (aligned + buffer->length, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+ if (avcodec_decode_video (codec->ctx, codec->frame, &got_image,
+ aligned, buffer->length) < 0) {
+ g_free (tmp);
+ SWFDEC_WARNING ("error decoding frame");
+ return FALSE;
+ }
+ g_free (tmp);
+ if (got_image == 0) {
+ SWFDEC_WARNING ("did not get an image from decoding");
+ return FALSE;
+ }
+ if (codec->ctx->pix_fmt != codec->format) {
+ SWFDEC_WARNING ("decoded to wrong format, expected %u, but got %u",
+ codec->format, codec->ctx->pix_fmt);
+ return FALSE;
+ }
+ image->width = codec->ctx->width;
+ image->height = codec->ctx->height;
+ image->mask = NULL;
+ image->plane[0] = codec->frame->data[0];
+ image->plane[1] = codec->frame->data[1];
+ image->plane[2] = codec->frame->data[2];
+ image->rowstride[0] = codec->frame->linesize[0];
+ image->rowstride[1] = codec->frame->linesize[1];
+ image->rowstride[2] = codec->frame->linesize[2];
+ return TRUE;
+}
+
+static void
+swfdec_video_decoder_ffmpeg_free (SwfdecVideoDecoder *dec)
+{
+ SwfdecVideoDecoderFFMpeg *codec = (SwfdecVideoDecoderFFMpeg *) dec;
+
+ avcodec_close (codec->ctx);
+ av_free (codec->ctx);
+ av_free (codec->frame);
+ g_free (codec);
+}
+
+SwfdecVideoDecoder *
+swfdec_video_decoder_ffmpeg_new (guint type)
+{
+ SwfdecVideoDecoderFFMpeg *codec;
+ AVCodecContext *ctx;
+ enum CodecID id;
+
+ switch (type) {
+ case SWFDEC_VIDEO_CODEC_H263:
+ id = CODEC_ID_FLV1;
+ break;
+ case SWFDEC_VIDEO_CODEC_SCREEN:
+ id = CODEC_ID_FLASHSV;
+ break;
+ case SWFDEC_VIDEO_CODEC_VP6:
+ id = CODEC_ID_VP6F;
+ break;
+ default:
+ return NULL;
+ }
+ ctx = swfdec_codec_ffmpeg_init (id);
+
+ if (ctx == NULL)
+ return NULL;
+ codec = g_new0 (SwfdecVideoDecoderFFMpeg, 1);
+ codec->decoder.decode = swfdec_video_decoder_ffmpeg_decode;
+ codec->decoder.free = swfdec_video_decoder_ffmpeg_free;
+ codec->ctx = ctx;
+ codec->frame = avcodec_alloc_frame ();
+ codec->format = swfdec_video_decoder_ffmpeg_get_format (type);
+
+ return &codec->decoder;
+}
+
diff --git a/swfdec/swfdec_codec_gst.c b/swfdec/swfdec_codec_gst.c
new file mode 100644
index 0000000..2167050
--- /dev/null
+++ b/swfdec/swfdec_codec_gst.c
@@ -0,0 +1,615 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <string.h>
+#include <gst/gst.h>
+
+#include "swfdec_codec_audio.h"
+#include "swfdec_codec_video.h"
+#include "swfdec_debug.h"
+#include "swfdec_internal.h"
+
+/*** BUFFER ***/
+
+static void
+swfdec_gst_buffer_free (unsigned char *data, gpointer priv)
+{
+ gst_buffer_unref (priv);
+}
+
+static SwfdecBuffer *
+swfdec_buffer_new_from_gst (GstBuffer *buffer)
+{
+ SwfdecBuffer *ret;
+
+ g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
+
+ ret = swfdec_buffer_new ();
+ ret->data = GST_BUFFER_DATA (buffer);
+ ret->length = GST_BUFFER_SIZE (buffer);
+ ret->free = swfdec_gst_buffer_free;
+ ret->priv = buffer;
+
+ return ret;
+}
+
+static GstBuffer *
+swfdec_gst_buffer_new (SwfdecBuffer *buffer)
+{
+ /* FIXME: make this a zero-copy operation */
+ GstBuffer *ret;
+
+ g_return_val_if_fail (buffer != NULL , NULL);
+
+ ret = gst_buffer_new_and_alloc (buffer->length);
+ memcpy (GST_BUFFER_DATA (ret), buffer->data, buffer->length);
+ swfdec_buffer_unref (buffer);
+
+ return ret;
+}
+
+/*** TYPEFINDING ***/
+
+/* NB: try to mirror decodebin behavior */
+static gboolean
+swfdec_gst_feature_filter (GstPluginFeature *feature, gpointer caps)
+{
+ const GList *walk;
+ const gchar *klass;
+
+ /* we only care about element factories */
+ if (!GST_IS_ELEMENT_FACTORY (feature))
+ return FALSE;
+
+ /* only decoders are interesting */
+ klass = gst_element_factory_get_klass (GST_ELEMENT_FACTORY (feature));
+ if (strstr (klass, "Decoder") == NULL)
+ return FALSE;
+
+ /* only select elements with autoplugging rank */
+ if (gst_plugin_feature_get_rank (feature) < GST_RANK_MARGINAL)
+ return FALSE;
+
+ /* only care about the right sink caps */
+ for (walk = gst_element_factory_get_static_pad_templates (GST_ELEMENT_FACTORY (feature));
+ walk; walk = walk->next) {
+ GstStaticPadTemplate *template = walk->data;
+ GstCaps *intersect;
+ GstCaps *template_caps;
+
+ if (template->direction != GST_PAD_SINK)
+ continue;
+
+ template_caps = gst_static_caps_get (&template->static_caps);
+ intersect = gst_caps_intersect (caps, template_caps);
+
+ gst_caps_unref (template_caps);
+ if (gst_caps_is_empty (intersect)) {
+ gst_caps_unref (intersect);
+ } else {
+ gst_caps_unref (intersect);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+static int
+swfdec_gst_compare_features (gconstpointer a_, gconstpointer b_)
+{
+ int diff;
+ GstPluginFeature *a = GST_PLUGIN_FEATURE (a_);
+ GstPluginFeature *b = GST_PLUGIN_FEATURE (b_);
+
+ diff = gst_plugin_feature_get_rank (b) - gst_plugin_feature_get_rank (a);
+ if (diff != 0)
+ return diff;
+
+ return strcmp (gst_plugin_feature_get_name (a), gst_plugin_feature_get_name (b));
+}
+
+static GstElement *
+swfdec_gst_get_element (GstCaps *caps)
+{
+ GstElement *element;
+ GList *list;
+
+ list = gst_registry_feature_filter (gst_registry_get_default (),
+ swfdec_gst_feature_filter, FALSE, caps);
+ if (list == NULL)
+ return NULL;
+
+ list = g_list_sort (list, swfdec_gst_compare_features);
+ element = gst_element_factory_create (list->data, "decoder");
+ gst_plugin_feature_list_free (list);
+ return element;
+}
+
+/*** PADS ***/
+
+static GstPad *
+swfdec_gst_connect_srcpad (GstElement *element, GstCaps *caps)
+{
+ GstPadTemplate *tmpl;
+ GstPad *srcpad, *sinkpad;
+
+ sinkpad = gst_element_get_pad (element, "sink");
+ if (sinkpad == NULL)
+ return NULL;
+ gst_caps_ref (caps);
+ tmpl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
+ srcpad = gst_pad_new_from_template (tmpl, "src");
+ g_object_unref (tmpl);
+ if (gst_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK)
+ goto error;
+
+ gst_object_unref (sinkpad);
+ gst_pad_set_active (srcpad, TRUE);
+ return srcpad;
+
+error:
+ SWFDEC_ERROR ("failed to create or link srcpad");
+ gst_object_unref (sinkpad);
+ gst_object_unref (srcpad);
+ return NULL;
+}
+
+static GstPad *
+swfdec_gst_connect_sinkpad (GstElement *element, GstCaps *caps)
+{
+ GstPadTemplate *tmpl;
+ GstPad *srcpad, *sinkpad;
+
+ srcpad = gst_element_get_pad (element, "src");
+ if (srcpad == NULL)
+ return NULL;
+ gst_caps_ref (caps);
+ tmpl = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, caps);
+ sinkpad = gst_pad_new_from_template (tmpl, "sink");
+ g_object_unref (tmpl);
+ if (gst_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK)
+ goto error;
+
+ gst_object_unref (srcpad);
+ gst_pad_set_active (sinkpad, TRUE);
+ return sinkpad;
+
+error:
+ SWFDEC_ERROR ("failed to create or link sinkpad");
+ gst_object_unref (srcpad);
+ gst_object_unref (sinkpad);
+ return NULL;
+}
+
+/*** DECODER ***/
+
+typedef struct {
+ GstElement * decoder;
+ GstPad * src;
+ GstPad * sink;
+ GQueue * queue; /* all the stored output GstBuffers */
+} SwfdecGstDecoder;
+
+static GstFlowReturn
+swfdec_gst_chain_func (GstPad *pad, GstBuffer *buffer)
+{
+ GQueue *queue = g_object_get_data (G_OBJECT (pad), "swfdec-queue");
+
+ g_queue_push_tail (queue, buffer);
+
+ return GST_FLOW_OK;
+}
+
+static gboolean
+swfdec_gst_decoder_init (SwfdecGstDecoder *dec, const char *name, GstCaps *srccaps, GstCaps *sinkcaps)
+{
+ if (name) {
+ dec->decoder = gst_element_factory_make (name, "decoder");
+ } else {
+ dec->decoder = swfdec_gst_get_element (srccaps);
+ }
+ if (dec->decoder == NULL) {
+ SWFDEC_ERROR ("failed to create decoder");
+ return FALSE;
+ }
+ dec->src = swfdec_gst_connect_srcpad (dec->decoder, srccaps);
+ if (dec->src == NULL)
+ return FALSE;
+ dec->sink = swfdec_gst_connect_sinkpad (dec->decoder, sinkcaps);
+ if (dec->sink == NULL)
+ return FALSE;
+ gst_pad_set_chain_function (dec->sink, swfdec_gst_chain_func);
+ dec->queue = g_queue_new ();
+ g_object_set_data (G_OBJECT (dec->sink), "swfdec-queue", dec->queue);
+ if (!gst_element_set_state (dec->decoder, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS) {
+ SWFDEC_ERROR ("could not change element state");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static void
+swfdec_gst_decoder_finish (SwfdecGstDecoder *dec)
+{
+ if (dec->decoder) {
+ gst_element_set_state (dec->decoder, GST_STATE_NULL);
+ g_object_unref (dec->decoder);
+ dec->decoder = NULL;
+ }
+ if (dec->src) {
+ g_object_unref (dec->src);
+ dec->src = NULL;
+ }
+ if (dec->sink) {
+ g_object_unref (dec->sink);
+ dec->sink = NULL;
+ }
+ if (dec->queue) {
+ GstBuffer *buffer;
+ while ((buffer = g_queue_pop_head (dec->queue)) != NULL) {
+ gst_buffer_unref (buffer);
+ }
+ g_queue_free (dec->queue);
+ dec->queue = NULL;
+ }
+}
+
+static gboolean
+swfdec_gst_decoder_push (SwfdecGstDecoder *dec, GstBuffer *buffer)
+{
+ GstFlowReturn ret;
+ GstCaps *caps;
+
+ /* set caps if none set yet */
+ caps = gst_buffer_get_caps (buffer);
+ if (caps) {
+ gst_caps_unref (caps);
+ } else {
+ caps = GST_PAD_CAPS (dec->src);
+ if (caps == NULL) {
+ caps = (GstCaps *) gst_pad_get_pad_template_caps (dec->src);
+ g_assert (gst_caps_is_fixed (caps));
+ gst_pad_set_caps (dec->src, caps);
+ }
+ gst_buffer_set_caps (buffer, GST_PAD_CAPS (dec->src));
+ }
+
+ ret = gst_pad_push (dec->src, buffer);
+ if (GST_FLOW_IS_SUCCESS (ret))
+ return TRUE;
+ SWFDEC_ERROR ("error %d pushing data", (int) ret);
+ return FALSE;
+}
+
+static void
+swfdec_gst_decoder_push_eos (SwfdecGstDecoder *dec)
+{
+ gst_pad_push_event (dec->src, gst_event_new_eos ());
+}
+
+static GstBuffer *
+swfdec_gst_decoder_pull (SwfdecGstDecoder *dec)
+{
+ return g_queue_pop_head (dec->queue);
+}
+
+/*** AUDIO ***/
+
+typedef struct _SwfdecGstAudio SwfdecGstAudio;
+struct _SwfdecGstAudio {
+ SwfdecAudioDecoder decoder;
+
+ gboolean error;
+ SwfdecGstDecoder dec;
+ SwfdecGstDecoder convert;
+ SwfdecGstDecoder resample;
+};
+
+static void
+swfdec_audio_decoder_gst_free (SwfdecAudioDecoder *dec)
+{
+ SwfdecGstAudio *player = (SwfdecGstAudio *) dec;
+
+ swfdec_gst_decoder_finish (&player->dec);
+ swfdec_gst_decoder_finish (&player->convert);
+ swfdec_gst_decoder_finish (&player->resample);
+
+ g_slice_free (SwfdecGstAudio, player);
+}
+
+static void
+swfdec_audio_decoder_gst_push (SwfdecAudioDecoder *dec, SwfdecBuffer *buffer)
+{
+ SwfdecGstAudio *player = (SwfdecGstAudio *) dec;
+ GstBuffer *buf;
+
+ if (player->error)
+ return;
+ if (buffer == NULL) {
+ swfdec_gst_decoder_push_eos (&player->dec);
+ } else {
+ swfdec_buffer_ref (buffer);
+ buf = swfdec_gst_buffer_new (buffer);
+ if (!swfdec_gst_decoder_push (&player->dec, buf))
+ goto error;
+ }
+ while ((buf = swfdec_gst_decoder_pull (&player->dec))) {
+ if (!swfdec_gst_decoder_push (&player->convert, buf))
+ goto error;
+ }
+ while ((buf = swfdec_gst_decoder_pull (&player->convert))) {
+ if (!swfdec_gst_decoder_push (&player->resample, buf))
+ goto error;
+ }
+ return;
+
+error:
+ SWFDEC_ERROR ("error pushing");
+ player->error = TRUE;
+}
+
+static SwfdecBuffer *
+swfdec_audio_decoder_gst_pull (SwfdecAudioDecoder *dec)
+{
+ SwfdecGstAudio *player = (SwfdecGstAudio *) dec;
+ GstBuffer *buf;
+
+ if (player->error)
+ return NULL;
+ buf = swfdec_gst_decoder_pull (&player->resample);
+ if (buf == NULL)
+ return NULL;
+ return swfdec_buffer_new_from_gst (buf);
+}
+
+static gboolean
+swfdec_audio_decoder_set_caps (GstPad *pad, GstCaps *caps)
+{
+ SwfdecGstAudio *player = g_object_get_data (G_OBJECT (pad), "swfdec-player");
+ GstStructure *structure = gst_caps_get_structure (caps, 0);
+ int depth, channels, rate;
+
+ if (SWFDEC_IS_AUDIO_FORMAT (player->decoder.format)) {
+ SWFDEC_ERROR ("resetting format not allowed");
+ player->error = TRUE;
+ return FALSE;
+ }
+ if (!gst_structure_get_int (structure, "depth", &depth) ||
+ !gst_structure_get_int (structure, "rate", &rate) ||
+ !gst_structure_get_int (structure, "channels", &channels)) {
+ SWFDEC_ERROR ("invalid caps");
+ player->error = TRUE;
+ return FALSE;
+ }
+
+ player->decoder.format = swfdec_audio_format_new (rate, channels, depth == 16 ? TRUE : FALSE);
+ return TRUE;
+}
+
+SwfdecAudioDecoder *
+swfdec_audio_decoder_gst_new (guint type, SwfdecAudioFormat format)
+{
+ SwfdecGstAudio *player;
+ GstCaps *srccaps, *sinkcaps;
+
+ if (!gst_init_check (NULL, NULL, NULL))
+ return NULL;
+
+ switch (type) {
+ case SWFDEC_AUDIO_CODEC_MP3:
+ srccaps = gst_caps_from_string ("audio/mpeg, mpegversion=(int)1, layer=(int)3");
+ break;
+ default:
+ return NULL;
+ }
+ g_assert (srccaps);
+
+ player = g_slice_new0 (SwfdecGstAudio);
+ player->decoder.format = SWFDEC_AUDIO_FORMAT_INVALID;
+ player->decoder.pull = swfdec_audio_decoder_gst_pull;
+ player->decoder.push = swfdec_audio_decoder_gst_push;
+ player->decoder.free = swfdec_audio_decoder_gst_free;
+
+ /* create decoder */
+ sinkcaps = gst_caps_from_string ("audio/x-raw-int");
+ g_assert (sinkcaps);
+ if (!swfdec_gst_decoder_init (&player->dec, NULL, srccaps, sinkcaps))
+ goto error;
+ /* create audioconvert */
+ gst_caps_unref (srccaps);
+ srccaps = sinkcaps;
+ sinkcaps = gst_caps_from_string ("audio/x-raw-int, endianness=byte_order, signed=(boolean)true, width=16, depth=16, channels={2,1}");
+ g_assert (sinkcaps);
+ if (!swfdec_gst_decoder_init (&player->convert, "audioconvert", srccaps, sinkcaps))
+ goto error;
+ /* create audiorate */
+ gst_caps_unref (srccaps);
+ srccaps = sinkcaps;
+ sinkcaps = gst_caps_from_string ("audio/x-raw-int, endianness=byte_order, signed=(boolean)true, width=16, depth=16, rate={44100, 22050, 11025, 5512}, channels={2,1}");
+ g_assert (sinkcaps);
+ if (!swfdec_gst_decoder_init (&player->resample, "audioresample", srccaps, sinkcaps))
+ goto error;
+ g_object_set_data (G_OBJECT (player->resample.sink), "swfdec-player", player);
+ gst_pad_set_setcaps_function (player->resample.sink, swfdec_audio_decoder_set_caps);
+
+ gst_caps_unref (srccaps);
+ gst_caps_unref (sinkcaps);
+ return &player->decoder;
+
+error:
+ swfdec_audio_decoder_gst_free (&player->decoder);
+ gst_caps_unref (srccaps);
+ gst_caps_unref (sinkcaps);
+ return NULL;
+}
+
+/*** VIDEO ***/
+
+/* NB: We don't put a colorspace tansform here, we just assume that the codecs
+ * in GStreamer decode to the native format that we enforce. */
+typedef struct _SwfdecGstVideo SwfdecGstVideo;
+struct _SwfdecGstVideo {
+ SwfdecVideoDecoder decoder;
+
+ gboolean error;
+ SwfdecGstDecoder dec; /* the decoder element */
+ GstBuffer * last; /* last decoded buffer */
+};
+
+static void
+swfdec_video_decoder_gst_free (SwfdecVideoDecoder *dec)
+{
+ SwfdecGstVideo *player = (SwfdecGstVideo *) dec;
+
+ swfdec_gst_decoder_finish (&player->dec);
+ if (player->last)
+ gst_buffer_unref (player->last);
+
+ g_slice_free (SwfdecGstVideo, player);
+}
+
+static gboolean
+swfdec_video_decoder_gst_decode (SwfdecVideoDecoder *dec, SwfdecBuffer *buffer,
+ SwfdecVideoImage *image)
+{
+ SwfdecGstVideo *player = (SwfdecGstVideo *) dec;
+#define SWFDEC_ALIGN(x, n) (((x) + (n) - 1) & (~((n) - 1)))
+ GstBuffer *buf;
+ GstCaps *caps;
+ GstStructure *structure;
+
+ if (player->error)
+ return FALSE;
+ if (player->last) {
+ gst_buffer_unref (player->last);
+ player->last = NULL;
+ }
+
+ buf = swfdec_gst_buffer_new (swfdec_buffer_ref (buffer));
+ if (!swfdec_gst_decoder_push (&player->dec, buf)) {
+ SWFDEC_ERROR ("failed to push buffer");
+ player->error = TRUE;
+ return FALSE;
+ }
+
+ player->last = swfdec_gst_decoder_pull (&player->dec);
+ if (player->last == NULL) {
+ SWFDEC_ERROR ("failed to pull decoded buffer");
+ player->error = TRUE;
+ return FALSE;
+ }
+ while ((buf = swfdec_gst_decoder_pull (&player->dec))) {
+ SWFDEC_WARNING ("too many output buffers!");
+ }
+ caps = gst_buffer_get_caps (player->last);
+ if (caps == NULL) {
+ SWFDEC_ERROR ("no caps on decoded buffer");
+ player->error = TRUE;
+ return FALSE;
+ }
+ structure = gst_caps_get_structure (caps, 0);
+ if (!gst_structure_get_int (structure, "width", (int *) &image->width) ||
+ !gst_structure_get_int (structure, "height", (int *) &image->height)) {
+ SWFDEC_ERROR ("invalid caps on decoded buffer");
+ player->error = TRUE;
+ return FALSE;
+ }
+ image->mask = NULL;
+ buf = player->last;
+ switch (swfdec_video_codec_get_format (dec->codec)) {
+ case SWFDEC_VIDEO_FORMAT_RGBA:
+ image->plane[0] = buf->data;
+ image->rowstride[0] = image->width * 4;
+ break;
+ case SWFDEC_VIDEO_FORMAT_I420:
+ image->plane[0] = buf->data;
+ image->rowstride[0] = SWFDEC_ALIGN (image->width, 4);
+ image->plane[1] = image->plane[0] + image->rowstride[0] * SWFDEC_ALIGN (image->height, 2);
+ image->rowstride[1] = SWFDEC_ALIGN (image->width, 8) / 2;
+ image->plane[2] = image->plane[1] + image->rowstride[1] * SWFDEC_ALIGN (image->height, 2) / 2;
+ image->rowstride[2] = image->rowstride[1];
+ g_assert (image->plane[2] + image->rowstride[2] * SWFDEC_ALIGN (image->height, 2) / 2 == image->plane[0] + buf->size);
+ break;
+ default:
+ g_return_val_if_reached (FALSE);
+ }
+ return TRUE;
+#undef SWFDEC_ALIGN
+}
+
+static GstCaps *
+swfdec_video_decoder_get_sink_caps (guint codec)
+{
+ switch (swfdec_video_codec_get_format (codec)) {
+ case SWFDEC_VIDEO_FORMAT_RGBA:
+#if G_BYTE_ORDER == G_BIG_ENDIAN
+ return gst_caps_from_string ("video/x-raw-rgb, bpp=32, endianness=4321, depth=24, "
+ "red_mask=16711680, green_mask=65280, blue_mask=255");
+#else
+ return gst_caps_from_string ("video/x-raw-rgb, bpp=32, endianness=4321, depth=24, "
+ "red_mask=65280, green_mask=16711680, blue_mask=-16777216");
+#endif
+ case SWFDEC_VIDEO_FORMAT_I420:
+ return gst_caps_from_string ("video/x-raw-yuv, format=(fourcc)I420");
+ default:
+ g_return_val_if_reached (NULL);
+ }
+}
+
+SwfdecVideoDecoder *
+swfdec_video_decoder_gst_new (guint codec)
+{
+ SwfdecGstVideo *player;
+ GstCaps *srccaps, *sinkcaps;
+
+ if (!gst_init_check (NULL, NULL, NULL))
+ return NULL;
+
+ switch (codec) {
+ case SWFDEC_VIDEO_CODEC_H263:
+ srccaps = gst_caps_from_string ("video/x-flash-video");
+ break;
+ case SWFDEC_VIDEO_CODEC_VP6:
+ srccaps = gst_caps_from_string ("video/x-vp6-flash");
+ break;
+ default:
+ return NULL;
+ }
+ g_assert (srccaps);
+ sinkcaps = swfdec_video_decoder_get_sink_caps (codec);
+
+ player = g_slice_new0 (SwfdecGstVideo);
+ player->decoder.decode = swfdec_video_decoder_gst_decode;
+ player->decoder.free = swfdec_video_decoder_gst_free;
+
+ if (!swfdec_gst_decoder_init (&player->dec, NULL, srccaps, sinkcaps)) {
+ swfdec_video_decoder_gst_free (&player->decoder);
+ gst_caps_unref (srccaps);
+ gst_caps_unref (sinkcaps);
+ return NULL;
+ }
+
+ gst_caps_unref (srccaps);
+ gst_caps_unref (sinkcaps);
+ return &player->decoder;
+}
+
diff --git a/swfdec/swfdec_codec_mad.c b/swfdec/swfdec_codec_mad.c
new file mode 100644
index 0000000..ec15231
--- /dev/null
+++ b/swfdec/swfdec_codec_mad.c
@@ -0,0 +1,235 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <string.h>
+#include <config.h>
+#include <liboil/liboil.h>
+#include <mad.h>
+
+#include "swfdec_codec_audio.h"
+#include "swfdec_debug.h"
+#include "swfdec_internal.h"
+
+typedef struct {
+ SwfdecAudioDecoder decoder;
+
+ struct mad_stream stream;
+ struct mad_frame frame;
+ struct mad_synth synth;
+ guint8 data[MAD_BUFFER_MDLEN * 3];
+ guint data_len;
+ SwfdecBufferQueue * queue;
+} MadData;
+
+static SwfdecBuffer *
+convert_synth_to_buffer (MadData *mdata)
+{
+ SwfdecBuffer *buffer;
+ int n_samples;
+ short *data;
+ int i;
+ short c0,c1;
+#define MAD_F_TO_S16(x) (CLAMP (x, -MAD_F_ONE, MAD_F_ONE) >> (MAD_F_FRACBITS - 14))
+
+ n_samples = mdata->synth.pcm.length;
+ if (n_samples == 0) {
+ return NULL;
+ }
+
+ switch (mdata->synth.pcm.samplerate) {
+ case 11025:
+ n_samples *= 4;
+ break;
+ case 22050:
+ n_samples *= 2;
+ break;
+ case 44100:
+ break;
+ default:
+ SWFDEC_ERROR ("sample rate not handled (%d)",
+ mdata->synth.pcm.samplerate);
+ return NULL;
+ }
+
+ buffer = swfdec_buffer_new_and_alloc (n_samples * 2 * 2);
+ data = (gint16 *) buffer->data;
+
+ if (mdata->synth.pcm.samplerate == 11025) {
+ if (mdata->synth.pcm.channels == 2) {
+ for (i = 0; i < mdata->synth.pcm.length; i++) {
+ c0 = MAD_F_TO_S16 (mdata->synth.pcm.samples[0][i]);
+ c1 = MAD_F_TO_S16 (mdata->synth.pcm.samples[1][i]);
+ *data++ = c0;
+ *data++ = c1;
+ *data++ = c0;
+ *data++ = c1;
+ *data++ = c0;
+ *data++ = c1;
+ *data++ = c0;
+ *data++ = c1;
+ }
+ } else {
+ for (i = 0; i < mdata->synth.pcm.length; i++) {
+ c0 = MAD_F_TO_S16( mdata->synth.pcm.samples[0][i]);
+ *data++ = c0;
+ *data++ = c0;
+ *data++ = c0;
+ *data++ = c0;
+ *data++ = c0;
+ *data++ = c0;
+ *data++ = c0;
+ *data++ = c0;
+ }
+ }
+ } else if (mdata->synth.pcm.samplerate == 22050) {
+ if (mdata->synth.pcm.channels == 2) {
+ for (i = 0; i < mdata->synth.pcm.length; i++) {
+ c0 = MAD_F_TO_S16 (mdata->synth.pcm.samples[0][i]);
+ c1 = MAD_F_TO_S16 (mdata->synth.pcm.samples[1][i]);
+ *data++ = c0;
+ *data++ = c1;
+ *data++ = c0;
+ *data++ = c1;
+ }
+ } else {
+ for (i = 0; i < mdata->synth.pcm.length; i++) {
+ c0 = MAD_F_TO_S16 (mdata->synth.pcm.samples[0][i]);
+ *data++ = c0;
+ *data++ = c0;
+ *data++ = c0;
+ *data++ = c0;
+ }
+ }
+ } else if (mdata->synth.pcm.samplerate == 44100) {
+ if (mdata->synth.pcm.channels == 2) {
+ for (i = 0; i < mdata->synth.pcm.length; i++) {
+ c0 = MAD_F_TO_S16 (mdata->synth.pcm.samples[0][i]);
+ c1 = MAD_F_TO_S16 (mdata->synth.pcm.samples[1][i]);
+ *data++ = c0;
+ *data++ = c1;
+ }
+ } else {
+ for (i = 0; i < mdata->synth.pcm.length; i++) {
+ c0 = MAD_F_TO_S16 (mdata->synth.pcm.samples[0][i]);
+ *data++ = c0;
+ *data++ = c0;
+ }
+ }
+ } else {
+ SWFDEC_ERROR ("sample rate not handled (%d)",
+ mdata->synth.pcm.samplerate);
+ }
+ return buffer;
+}
+
+static void
+swfdec_audio_decoder_mad_push (SwfdecAudioDecoder *dec, SwfdecBuffer *buffer)
+{
+ MadData *data = (MadData *) dec;
+ SwfdecBuffer *out, *empty = NULL;
+ guint amount = 0, size;
+
+ if (buffer == NULL) {
+ buffer = empty = swfdec_buffer_new ();
+ empty->data = g_malloc0 (MAD_BUFFER_GUARD * 3);
+ empty->length = MAD_BUFFER_GUARD * 3;
+ }
+
+ //write (1, buffer->data, buffer->length);
+ //g_print ("buffer %p gave us %u bytes\n", buffer, buffer->length);
+ while (amount < buffer->length) {
+ size = MIN (buffer->length - amount, MAD_BUFFER_MDLEN * 3 - data->data_len);
+ memcpy (&data->data[data->data_len], buffer->data + amount, size);
+ //write (1, buffer->data + amount, size);
+ amount += size;
+ data->data_len += size;
+ mad_stream_buffer (&data->stream, data->data, data->data_len);
+ while (1) {
+ if (mad_frame_decode (&data->frame, &data->stream)) {
+ if (data->stream.error == MAD_ERROR_BUFLEN)
+ break;
+ if (MAD_RECOVERABLE (data->stream.error)) {
+ SWFDEC_LOG ("recoverable error 0x%04x", data->stream.error);
+ continue;
+ }
+ SWFDEC_ERROR ("stream error 0x%04x", data->stream.error);
+ break;
+ }
+
+ mad_synth_frame (&data->synth, &data->frame);
+ out = convert_synth_to_buffer (data);
+ if (out)
+ swfdec_buffer_queue_push (data->queue, out);
+ }
+ if (data->stream.next_frame == NULL) {
+ data->data_len = 0;
+ } else {
+ data->data_len = data->stream.bufend - data->stream.next_frame;
+ memmove (data->data, data->stream.next_frame, data->data_len);
+ }
+ }
+ //g_print ("%u bytes left\n", data->data_len);
+
+ if (empty)
+ swfdec_buffer_unref (empty);
+}
+
+static void
+swfdec_audio_decoder_mad_free (SwfdecAudioDecoder *dec)
+{
+ MadData *data = (MadData *) dec;
+
+ mad_synth_finish (&data->synth);
+ mad_frame_finish (&data->frame);
+ mad_stream_finish (&data->stream);
+ swfdec_buffer_queue_unref (data->queue);
+ g_slice_free (MadData, data);
+}
+
+static SwfdecBuffer *
+swfdec_audio_decoder_mad_pull (SwfdecAudioDecoder *dec)
+{
+ return swfdec_buffer_queue_pull_buffer (((MadData *) dec)->queue);
+}
+
+SwfdecAudioDecoder *
+swfdec_audio_decoder_mad_new (guint type, SwfdecAudioFormat format)
+{
+ MadData *data;
+
+ if (type != SWFDEC_AUDIO_CODEC_MP3)
+ return NULL;
+
+ data = g_slice_new (MadData);
+ data->decoder.format = swfdec_audio_format_new (44100, 2, TRUE);
+ data->decoder.push = swfdec_audio_decoder_mad_push;
+ data->decoder.pull = swfdec_audio_decoder_mad_pull;
+ data->decoder.free = swfdec_audio_decoder_mad_free;
+ mad_stream_init (&data->stream);
+ mad_frame_init (&data->frame);
+ mad_synth_init (&data->synth);
+ data->data_len = 0;
+ data->queue = swfdec_buffer_queue_new ();
+
+ return &data->decoder;
+}
+
diff --git a/swfdec/swfdec_codec_screen.c b/swfdec/swfdec_codec_screen.c
new file mode 100644
index 0000000..5dbdfce
--- /dev/null
+++ b/swfdec/swfdec_codec_screen.c
@@ -0,0 +1,134 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include <zlib.h>
+#include <liboil/liboil.h>
+
+#include "swfdec_codec_video.h"
+#include "swfdec_bits.h"
+#include "swfdec_debug.h"
+#include "swfdec_internal.h"
+
+typedef struct _SwfdecCodecScreen SwfdecCodecScreen;
+
+struct _SwfdecCodecScreen {
+ SwfdecVideoDecoder decoder; /* the decoder */
+ gulong width; /* width of last image */
+ gulong height; /* height of last image */
+ guint8 * data; /* contains decoded image */
+};
+
+static gboolean
+swfdec_video_decoder_screen_decode (SwfdecVideoDecoder *dec, SwfdecBuffer *buffer,
+ SwfdecVideoImage *image)
+{
+ SwfdecCodecScreen *screen = (SwfdecCodecScreen *) dec;
+ SwfdecBits bits;
+ gulong i, j, w, h, bw, bh, stride;
+
+ swfdec_bits_init (&bits, buffer);
+ bw = (swfdec_bits_getbits (&bits, 4) + 1) * 16;
+ w = swfdec_bits_getbits (&bits, 12);
+ bh = (swfdec_bits_getbits (&bits, 4) + 1) * 16;
+ h = swfdec_bits_getbits (&bits, 12);
+ if (screen->width == 0 || screen->height == 0) {
+ if (w == 0 || h == 0) {
+ SWFDEC_ERROR ("width or height is 0: %lux%lu", w, h);
+ return FALSE;
+ }
+ screen->data = g_try_malloc (w * h * 4);
+ if (screen->data == NULL) {
+ SWFDEC_ERROR ("could not allocate %lu bytes", w * h * 4);
+ return FALSE;
+ }
+ screen->width = w;
+ screen->height = h;
+ } else if (screen->width != w || screen->height != h) {
+ SWFDEC_ERROR ("width or height differ from original: was %lux%lu, is %lux%lu",
+ screen->width, screen->height, w, h);
+ /* FIXME: this is what ffmpeg does, should we be more forgiving? */
+ return FALSE;
+ }
+ stride = w * 4;
+ SWFDEC_LOG ("size: %lu x %lu - block size %lu x %lu\n", w, h, bw, bh);
+ for (j = 0; j < h; j += bh) {
+ for (i = 0; i < w; i += bw) {
+ guint x, y, size;
+ SwfdecBuffer *buf;
+ guint8 *in, *out;
+ size = swfdec_bits_get_bu16 (&bits);
+ if (size == 0)
+ continue;
+ buf = swfdec_bits_decompress (&bits, size, bw * bh * 4);
+ if (buf == NULL) {
+ SWFDEC_WARNING ("error decoding block");
+ continue;
+ }
+ /* convert format and write out data */
+ out = screen->data + stride * (h - j - 1) + i * 4;
+ in = buf->data;
+ for (y = 0; y < MIN (bh, h - j); y++) {
+ for (x = 0; x < MIN (bw, w - i); x++) {
+ out[x * 4 - y * stride + SWFDEC_COLOR_INDEX_BLUE] = *in++;
+ out[x * 4 - y * stride + SWFDEC_COLOR_INDEX_GREEN] = *in++;
+ out[x * 4 - y * stride + SWFDEC_COLOR_INDEX_RED] = *in++;
+ out[x * 4 - y * stride + SWFDEC_COLOR_INDEX_ALPHA] = 0xFF;
+ }
+ }
+ swfdec_buffer_unref (buf);
+ }
+ }
+ image->width = screen->width;
+ image->height = screen->height;
+ image->plane[0] = screen->data;
+ image->rowstride[0] = stride;
+ image->mask = NULL;
+ return TRUE;
+}
+
+static void
+swfdec_video_decoder_screen_free (SwfdecVideoDecoder *dec)
+{
+ SwfdecCodecScreen *screen = (SwfdecCodecScreen *) dec;
+
+ if (screen->data)
+ g_free (screen->data);
+ g_free (screen);
+}
+
+SwfdecVideoDecoder *
+swfdec_video_decoder_screen_new (guint type)
+{
+ SwfdecCodecScreen *screen;
+
+ if (type != SWFDEC_VIDEO_CODEC_SCREEN)
+ return NULL;
+
+ screen = g_new0 (SwfdecCodecScreen, 1);
+ screen->decoder.decode = swfdec_video_decoder_screen_decode;
+ screen->decoder.free = swfdec_video_decoder_screen_free;
+
+ return &screen->decoder;
+}
+
diff --git a/swfdec/swfdec_codec_video.c b/swfdec/swfdec_codec_video.c
new file mode 100644
index 0000000..dcd03ce
--- /dev/null
+++ b/swfdec/swfdec_codec_video.c
@@ -0,0 +1,320 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <liboil/liboil.h>
+#include "swfdec_codec_video.h"
+#include "swfdec_color.h"
+#include "swfdec_debug.h"
+#include "swfdec_internal.h"
+
+static SwfdecVideoDecoder *
+swfdec_video_decoder_builtin_new (guint codec)
+{
+ SwfdecVideoDecoder *ret;
+
+ ret = swfdec_video_decoder_screen_new (codec);
+ if (ret == NULL)
+ ret = swfdec_video_decoder_vp6_alpha_new (codec);
+
+ return ret;
+}
+
+struct {
+ const char * name;
+ SwfdecVideoDecoder * (* func) (guint);
+} video_codecs[] = {
+ { "builtin", swfdec_video_decoder_builtin_new },
+#ifdef HAVE_GST
+ { "gst", swfdec_video_decoder_gst_new },
+#endif
+#ifdef HAVE_FFMPEG
+ { "ffmpeg", swfdec_video_decoder_ffmpeg_new },
+#endif
+ { NULL, }
+};
+
+/**
+ * swfdec_video_decoder_new:
+ * @codec: #SwfdecVideoCodec to create the #SwfdecVideoDecoder for
+ *
+ * Creates a new decoder to decode videos of type @codec. If no suitable
+ * decoder could be created, %NULL is returned.
+ *
+ * Returns:
+ **/
+SwfdecVideoDecoder *
+swfdec_video_decoder_new (guint codec)
+{
+ SwfdecVideoDecoder *ret;
+ const char *list;
+
+ list = g_getenv ("SWFDEC_CODEC_VIDEO");
+ if (list == NULL)
+ list = g_getenv ("SWFDEC_CODEC");
+ if (list == NULL) {
+ guint i;
+ ret = NULL;
+ for (i = 0; video_codecs[i].name != NULL; i++) {
+ ret = video_codecs[i].func (codec);
+ if (ret)
+ break;
+ }
+ } else {
+ char **split = g_strsplit (list, ",", -1);
+ guint i, j;
+ ret = NULL;
+ SWFDEC_LOG ("codecs limited to \"%s\"", list);
+ for (i = 0; split[i] != NULL && ret == NULL; i++) {
+ for (j = 0; video_codecs[j].name != NULL; j++) {
+ if (g_ascii_strcasecmp (video_codecs[j].name, split[i]) != 0)
+ continue;
+ ret = video_codecs[j].func (codec);
+ if (ret)
+ break;
+ }
+ }
+ g_strfreev (split);
+ }
+
+ if (ret != NULL) {
+ ret->codec = codec;
+ g_return_val_if_fail (ret->decode, ret);
+ g_return_val_if_fail (ret->free, ret);
+ } else {
+ SWFDEC_WARNING ("no decoder found for codec %u", (guint) codec);
+ }
+ return ret;
+}
+
+/**
+ * swfdec_video_decoder_free:
+ * @decoder: a #SwfdecVideoDecoder
+ *
+ * Frees the given @decoder and all associated ressources.
+ **/
+void
+swfdec_video_decoder_free (SwfdecVideoDecoder *decoder)
+{
+ g_return_if_fail (decoder);
+
+ decoder->free (decoder);
+}
+
+#define oil_argb(a,r,g,b) (((a) << 24) | ((r) << 16) | ((g) << 8) | b)
+static gint16 jfif_matrix[24] = {
+ 0, 0, -8192, -8192,
+ 16384, 0, 0, 0,
+ 0, 16384, 16384, 16384,
+ 0, 0, -5638, 29032,
+ 0, 22970, -11700, 0,
+ 0, 0, 0, 0
+};
+
+static void
+yuv_mux (guint32 *dest, const guint8 *src_y, const guint8 *src_u, const guint8 *src_v,
+ int n)
+{
+ int i;
+ for (i = 0; i < n; i++) {
+ dest[i] = oil_argb(255, src_y[i], src_u[i], src_v[i]);
+ }
+}
+
+static void
+upsample (guint8 *d, guint8 *s, int n)
+{
+ int i;
+
+ d[0] = s[0];
+
+ for (i = 0; i < n-3; i+=2) {
+ d[i + 1] = (3*s[i/2] + s[i/2+1] + 2)>>2;
+ d[i + 2] = (s[i/2] + 3*s[i/2+1] + 2)>>2;
+ }
+
+ if (n&1) {
+ i = n-3;
+ d[n-2] = s[n/2];
+ d[n-1] = s[n/2];
+ } else {
+ d[n-1] = s[n/2-1];
+ }
+}
+
+static guint8 *
+swfdec_video_i420_to_rgb (SwfdecVideoImage *image)
+{
+ guint32 *tmp;
+ guint8 *tmp_u;
+ guint8 *tmp_v;
+ guint8 *tmp1;
+ guint32 *argb_image;
+ const guint8 *yp, *up, *vp;
+ guint32 *argbp;
+ int j;
+ guint halfwidth;
+ int halfheight;
+
+ halfwidth = (image->width + 1)>>1;
+ tmp = g_malloc (4 * image->width * image->height);
+ tmp_u = g_malloc (image->width);
+ tmp_v = g_malloc (image->width);
+ tmp1 = g_malloc (halfwidth);
+ argb_image = g_malloc (4 * image->width * image->height);
+
+ yp = image->plane[0];
+ up = image->plane[1];
+ vp = image->plane[2];
+ argbp = argb_image;
+ halfheight = (image->height+1)>>1;
+ for(j=0;(guint)j<image->height;j++){
+ guint32 weight = 192 - 128*(j&1);
+
+ oil_merge_linear_u8(tmp1,
+ up + image->rowstride[1] * CLAMP((j-1)/2,0,halfheight-1),
+ up + image->rowstride[1] * CLAMP((j+1)/2,0,halfheight-1),
+ &weight, halfwidth);
+ upsample (tmp_u, tmp1, image->width);
+ oil_merge_linear_u8(tmp1,
+ vp + image->rowstride[2] * CLAMP((j-1)/2,0,halfheight-1),
+ vp + image->rowstride[2] * CLAMP((j+1)/2,0,halfheight-1),
+ &weight, halfwidth);
+ upsample (tmp_v, tmp1, image->width);
+
+ yuv_mux (tmp, yp, tmp_u, tmp_v, image->width);
+ oil_colorspace_argb(argbp, tmp, jfif_matrix, image->width);
+ yp += image->rowstride[0];
+ argbp += image->width;
+ }
+ g_free(tmp);
+ g_free(tmp_u);
+ g_free(tmp_v);
+ g_free(tmp1);
+ return (unsigned char *)argb_image;
+}
+
+/* FIXME: use liboil for this */
+static void
+swfdec_video_codec_apply_mask (guint8 *data, guint rowstride, const guint8 *mask,
+ guint mask_rowstride, guint width, guint height)
+{
+ const guint8 *in;
+ guint8 *out;
+ guint x, y;
+
+ data += SWFDEC_COLOR_INDEX_ALPHA;
+ for (y = 0; y < height; y++) {
+ in = mask;
+ out = data;
+ for (x = 0; x < width; x++) {
+ *out = *in;
+ out += 4;
+ in++;
+ }
+ mask += mask_rowstride;
+ data += rowstride;
+ }
+}
+
+/**
+ * swfdec_video_decoder_decode:
+ * @decoder: a #SwfdecVideoDecoder
+ * @buffer: buffer to decode
+ *
+ * Decodes the given buffer into an image surface.
+ *
+ * Returns: a new cairo image surface or %NULL on error.
+ **/
+cairo_surface_t *
+swfdec_video_decoder_decode (SwfdecVideoDecoder *decoder, SwfdecBuffer *buffer)
+{
+ SwfdecVideoImage image;
+ static const cairo_user_data_key_t key;
+ cairo_surface_t *surface;
+ guint8 *data;
+ guint rowstride;
+
+ g_return_val_if_fail (decoder != NULL, NULL);
+ g_return_val_if_fail (buffer != NULL, NULL);
+
+ if (!decoder->decode (decoder, buffer, &image)) {
+ SWFDEC_ERROR ("failed to decode video");
+ return NULL;
+ }
+ g_assert (image.width != 0 && image.height != 0);
+ /* FIXME: use cairo for all of this when cairo accelerates it */
+ if (swfdec_video_codec_get_format (decoder->codec) == SWFDEC_VIDEO_FORMAT_I420) {
+ data = swfdec_video_i420_to_rgb (&image);
+ if (data == NULL) {
+ SWFDEC_ERROR ("I420 => RGB conversion failed");
+ return NULL;
+ }
+ rowstride = image.width * 4;
+ } else {
+ rowstride = image.rowstride[0];
+ data = g_memdup (image.plane[0], rowstride * image.height);
+ }
+ if (image.mask) {
+ swfdec_video_codec_apply_mask (data, image.width * 4, image.mask,
+ image.mask_rowstride, image.width, image.height);
+ }
+ surface = cairo_image_surface_create_for_data (data,
+ image.mask ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24,
+ image.width, image.height, rowstride);
+ if (cairo_surface_status (surface)) {
+ SWFDEC_ERROR ("failed to create surface: %s",
+ cairo_status_to_string (cairo_surface_status (surface)));
+ cairo_surface_destroy (surface);
+ return NULL;
+ }
+ cairo_surface_set_user_data (surface, &key, data,
+ (cairo_destroy_func_t) g_free);
+ return surface;
+}
+
+/**
+ * swfdec_video_codec_get_format:
+ * @codec: codec to check
+ *
+ * Returns the output format used for this codec. Video codecs must use these
+ * codecs when decoding video.
+ *
+ * Returns: the output format to use for this format
+ **/
+SwfdecVideoFormat
+swfdec_video_codec_get_format (guint codec)
+{
+ switch (codec) {
+ case SWFDEC_VIDEO_CODEC_H263:
+ case SWFDEC_VIDEO_CODEC_VP6:
+ case SWFDEC_VIDEO_CODEC_VP6_ALPHA:
+ return SWFDEC_VIDEO_FORMAT_I420;
+ case SWFDEC_VIDEO_CODEC_UNDEFINED:
+ case SWFDEC_VIDEO_CODEC_SCREEN:
+ case SWFDEC_VIDEO_CODEC_SCREEN2:
+ return SWFDEC_VIDEO_FORMAT_RGBA;
+ default:
+ g_return_val_if_reached (SWFDEC_VIDEO_FORMAT_RGBA);
+ }
+}
+
diff --git a/swfdec/swfdec_codec_video.h b/swfdec/swfdec_codec_video.h
new file mode 100644
index 0000000..a7c968a
--- /dev/null
+++ b/swfdec/swfdec_codec_video.h
@@ -0,0 +1,75 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_CODEC_VIDEO_H_
+#define _SWFDEC_CODEC_VIDEO_H_
+
+#include <glib.h>
+#include <cairo.h>
+#include <libswfdec/swfdec_buffer.h>
+
+#define SWFDEC_VIDEO_CODEC_UNDEFINED 0
+#define SWFDEC_VIDEO_CODEC_H263 2
+#define SWFDEC_VIDEO_CODEC_SCREEN 3
+#define SWFDEC_VIDEO_CODEC_VP6 4
+#define SWFDEC_VIDEO_CODEC_VP6_ALPHA 5
+#define SWFDEC_VIDEO_CODEC_SCREEN2 6
+
+typedef enum {
+ SWFDEC_VIDEO_FORMAT_RGBA,
+ SWFDEC_VIDEO_FORMAT_I420
+} SwfdecVideoFormat;
+
+typedef struct {
+ guint width; /* width of image in pixels */
+ guint height; /* height of image in pixels */
+ const guint8 * plane[3]; /* planes of the image, not all might be used */
+ const guint8 * mask; /* A8 mask or NULL if none */
+ guint rowstride[3]; /* rowstrides of the planes */
+ guint mask_rowstride; /* rowstride of mask plane */
+} SwfdecVideoImage;
+
+typedef struct _SwfdecVideoDecoder SwfdecVideoDecoder;
+typedef SwfdecVideoDecoder * (SwfdecVideoDecoderNewFunc) (guint format);
+
+/* notes about the decode function:
+ * - the data must be in the format specified by swfdec_video_codec_get_format()
+ * - the data returned in the image belongs to the decoder and must be valid
+ * until the next function is called on the decoder.
+ * - you need to explicitly set mask to %NULL.
+ */
+struct _SwfdecVideoDecoder {
+ guint codec;
+ gboolean (* decode) (SwfdecVideoDecoder * decoder,
+ SwfdecBuffer * buffer,
+ SwfdecVideoImage * result);
+ void (* free) (SwfdecVideoDecoder * decoder);
+};
+
+SwfdecVideoFormat swfdec_video_codec_get_format (guint codec);
+
+SwfdecVideoDecoder * swfdec_video_decoder_new (guint codec);
+void swfdec_video_decoder_free (SwfdecVideoDecoder * decoder);
+
+cairo_surface_t * swfdec_video_decoder_decode (SwfdecVideoDecoder * decoder,
+ SwfdecBuffer * buffer);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_codec_vp6_alpha.c b/swfdec/swfdec_codec_vp6_alpha.c
new file mode 100644
index 0000000..672d3d7
--- /dev/null
+++ b/swfdec/swfdec_codec_vp6_alpha.c
@@ -0,0 +1,111 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include <zlib.h>
+#include <liboil/liboil.h>
+
+#include "swfdec_codec_video.h"
+#include "swfdec_bits.h"
+#include "swfdec_debug.h"
+#include "swfdec_internal.h"
+
+typedef struct _SwfdecCodecVp6Alpha SwfdecCodecVp6Alpha;
+
+struct _SwfdecCodecVp6Alpha {
+ SwfdecVideoDecoder decoder; /* the decoder */
+ SwfdecVideoDecoder * image; /* the image decoder */
+ SwfdecVideoDecoder * alpha; /* the alpha decoder */
+};
+
+static gboolean
+swfdec_video_decoder_vp6_alpha_decode (SwfdecVideoDecoder *dec, SwfdecBuffer *buffer,
+ SwfdecVideoImage *image)
+{
+ SwfdecCodecVp6Alpha *vp6 = (SwfdecCodecVp6Alpha *) dec;
+ SwfdecBuffer *tmp;
+ SwfdecVideoImage alpha;
+ SwfdecBits bits;
+ guint size;
+
+ swfdec_bits_init (&bits, buffer);
+ size = swfdec_bits_get_bu24 (&bits);
+ tmp = swfdec_bits_get_buffer (&bits, size);
+ if (tmp == NULL)
+ return FALSE;
+ if (!vp6->image->decode (vp6->image, tmp, image)) {
+ swfdec_buffer_unref (tmp);
+ return FALSE;
+ }
+ swfdec_buffer_unref (tmp);
+ tmp = swfdec_bits_get_buffer (&bits, -1);
+ if (tmp == NULL)
+ return FALSE;
+ if (!vp6->alpha->decode (vp6->alpha, tmp, &alpha)) {
+ swfdec_buffer_unref (tmp);
+ return FALSE;
+ }
+ swfdec_buffer_unref (tmp);
+ if (alpha.width != image->width || alpha.height != image->height) {
+ SWFDEC_ERROR ("size of mask doesn't match image: %ux%u vs %ux%u",
+ alpha.width, alpha.height, image->width, image->height);
+ return FALSE;
+ }
+ image->mask = alpha.plane[0];
+ image->mask_rowstride = alpha.rowstride[0];
+ return TRUE;
+}
+
+static void
+swfdec_video_decoder_vp6_alpha_free (SwfdecVideoDecoder *dec)
+{
+ SwfdecCodecVp6Alpha *vp6 = (SwfdecCodecVp6Alpha *) dec;
+
+ if (vp6->image)
+ swfdec_video_decoder_free (vp6->image);
+ if (vp6->alpha)
+ swfdec_video_decoder_free (vp6->alpha);
+ g_free (vp6);
+}
+
+SwfdecVideoDecoder *
+swfdec_video_decoder_vp6_alpha_new (guint type)
+{
+ SwfdecCodecVp6Alpha *vp6;
+
+ if (type != SWFDEC_VIDEO_CODEC_VP6_ALPHA)
+ return NULL;
+
+ vp6 = g_new0 (SwfdecCodecVp6Alpha, 1);
+ vp6->decoder.decode = swfdec_video_decoder_vp6_alpha_decode;
+ vp6->decoder.free = swfdec_video_decoder_vp6_alpha_free;
+ vp6->image = swfdec_video_decoder_new (SWFDEC_VIDEO_CODEC_VP6);
+ vp6->alpha = swfdec_video_decoder_new (SWFDEC_VIDEO_CODEC_VP6);
+ if (vp6->alpha == NULL || vp6->image == NULL) {
+ swfdec_video_decoder_vp6_alpha_free (&vp6->decoder);
+ return NULL;
+ }
+
+ return &vp6->decoder;
+}
+
diff --git a/swfdec/swfdec_color.c b/swfdec/swfdec_color.c
new file mode 100644
index 0000000..9ef554a
--- /dev/null
+++ b/swfdec/swfdec_color.c
@@ -0,0 +1,299 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+#include "swfdec_color.h"
+#include "swfdec_debug.h"
+
+SwfdecColor
+swfdec_color_apply_morph (SwfdecColor start, SwfdecColor end, guint ratio)
+{
+ guint r, g, b, a;
+ guint start_ratio, end_ratio;
+
+ g_assert (ratio < 65536);
+ if (ratio == 0)
+ return start;
+ if (ratio == 65535)
+ return end;
+ start_ratio = 65535 - ratio;
+ end_ratio = ratio;
+ r = (SWFDEC_COLOR_R (start) * start_ratio + SWFDEC_COLOR_R (end) * end_ratio) / 65535;
+ g = (SWFDEC_COLOR_G (start) * start_ratio + SWFDEC_COLOR_G (end) * end_ratio) / 65535;
+ b = (SWFDEC_COLOR_B (start) * start_ratio + SWFDEC_COLOR_B (end) * end_ratio) / 65535;
+ a = (SWFDEC_COLOR_A (start) * start_ratio + SWFDEC_COLOR_A (end) * end_ratio) / 65535;
+
+ return SWFDEC_COLOR_COMBINE (r, g, b, a);
+}
+
+void
+swfdec_color_set_source (cairo_t *cr, SwfdecColor color)
+{
+ cairo_set_source_rgba (cr,
+ SWFDEC_COLOR_R (color) / 255.0, SWFDEC_COLOR_G (color) / 255.0,
+ SWFDEC_COLOR_B (color) / 255.0, SWFDEC_COLOR_A (color) / 255.0);
+}
+
+SwfdecColor
+swfdec_color_apply_transform_premultiplied (SwfdecColor in,
+ const SwfdecColorTransform * trans)
+{
+ int r, g, b, a, aold;
+
+ if (trans->mask)
+ return SWFDEC_COLOR_COMBINE (0, 0, 0, 255);
+
+ aold = SWFDEC_COLOR_A (in);
+ if (aold == 0)
+ return 0;
+
+ a = (aold * trans->aa >> 8) + trans->ab;
+ a = CLAMP (a, 0, 255);
+
+ r = SWFDEC_COLOR_R (in);
+ g = SWFDEC_COLOR_G (in);
+ b = SWFDEC_COLOR_B (in);
+ r = (r * trans->ra * a / aold >> 8) + trans->rb * a / 255;
+ r = CLAMP (r, 0, a);
+ g = (g * trans->ga * a / aold >> 8) + trans->gb * a / 255;
+ g = CLAMP (g, 0, a);
+ b = (b * trans->ba * a / aold >> 8) + trans->bb * a / 255;
+ b = CLAMP (b, 0, a);
+
+ return SWFDEC_COLOR_COMBINE (r, g, b, a);
+}
+
+SwfdecColor
+swfdec_color_apply_transform (SwfdecColor in, const SwfdecColorTransform * trans)
+{
+ int r, g, b, a;
+
+ if (trans->mask)
+ return SWFDEC_COLOR_COMBINE (0, 0, 0, 255);
+
+ r = SWFDEC_COLOR_R (in);
+ g = SWFDEC_COLOR_G (in);
+ b = SWFDEC_COLOR_B (in);
+ a = SWFDEC_COLOR_A (in);
+
+ SWFDEC_LOG ("in rgba %d,%d,%d,%d", r, g, b, a);
+
+ r = (r * trans->ra >> 8) + trans->rb;
+ g = (g * trans->ga >> 8) + trans->gb;
+ b = (b * trans->ba >> 8) + trans->bb;
+ a = (a * trans->aa >> 8) + trans->ab;
+
+ r = CLAMP (r, 0, 255);
+ g = CLAMP (g, 0, 255);
+ b = CLAMP (b, 0, 255);
+ a = CLAMP (a, 0, 255);
+
+ SWFDEC_LOG ("out rgba %d,%d,%d,%d", r, g, b, a);
+
+ return SWFDEC_COLOR_COMBINE (r, g, b, a);
+}
+
+/**
+ * swfdec_color_transform_init_identity:
+ * @trans: a #SwfdecColorTransform
+ *
+ * Initializes the color transform so it doesn't transform any colors.
+ **/
+void
+swfdec_color_transform_init_identity (SwfdecColorTransform * trans)
+{
+ g_return_if_fail (trans != NULL);
+
+ trans->mask = FALSE;
+ trans->ra = 256;
+ trans->ga = 256;
+ trans->ba = 256;
+ trans->aa = 256;
+ trans->rb = 0;
+ trans->gb = 0;
+ trans->bb = 0;
+ trans->ab = 0;
+}
+
+void
+swfdec_color_transform_init_mask (SwfdecColorTransform *trans)
+{
+ g_return_if_fail (trans != NULL);
+
+ trans->mask = TRUE;
+ /* don't init the other values so valgrind complains when they get accessed */
+}
+
+/**
+ * swfdec_color_transform_init_color:
+ * @trans: a #SwfdecColorTransform
+ * @color: a #SwfdecColor to transform to
+ *
+ * Initializes this color transform so it results in exactly @color no matter
+ * the input.
+ **/
+void
+swfdec_color_transform_init_color (SwfdecColorTransform *trans, SwfdecColor color)
+{
+ trans->mask = FALSE;
+ trans->ra = 0;
+ trans->rb = SWFDEC_COLOR_R (color);
+ trans->ga = 0;
+ trans->gb = SWFDEC_COLOR_G (color);
+ trans->ba = 0;
+ trans->bb = SWFDEC_COLOR_B (color);
+ trans->aa = 0;
+ trans->ab = SWFDEC_COLOR_A (color);
+}
+
+gboolean
+swfdec_color_transform_is_identity (const SwfdecColorTransform * trans)
+{
+ return trans->mask == FALSE &&
+ trans->ra == 256 && trans->ga == 256 && trans->ba == 256 && trans->aa == 256 &&
+ trans->rb == 0 && trans->gb == 0 && trans->bb == 0 && trans->ab == 0;
+}
+
+/**
+ * swfdec_color_transform_chain:
+ * @dest: #SwfdecColorTransform to take the result
+ * @last: a #SwfdecColorTransform
+ * @first: a #SwfdecColorTransform
+ *
+ * Computes a color transform that has the same effect as if the color
+ * transforms @first and @last would have been applied one after another.
+ **/
+void
+swfdec_color_transform_chain (SwfdecColorTransform *dest,
+ const SwfdecColorTransform *last, const SwfdecColorTransform *first)
+{
+ g_return_if_fail (dest != NULL);
+ g_return_if_fail (last != NULL);
+ g_return_if_fail (first != NULL);
+ g_return_if_fail (!last->mask);
+
+ if (first->mask) {
+ swfdec_color_transform_init_mask (dest);
+ return;
+ }
+ dest->mask = FALSE;
+ dest->ra = last->ra * first->ra >> 8;
+ dest->rb = (last->ra * first->rb >> 8) + last->rb;
+ dest->ga = last->ga * first->ga >> 8;
+ dest->gb = (last->ga * first->gb >> 8) + last->gb;
+ dest->ba = last->ba * first->ba >> 8;
+ dest->bb = (last->ba * first->bb >> 8) + last->bb;
+ dest->aa = last->aa * first->aa >> 8;
+ dest->ab = (last->aa * first->ab >> 8) + last->ab;
+}
+
+void
+swfdec_matrix_ensure_invertible (cairo_matrix_t *matrix, cairo_matrix_t *inverse)
+{
+ cairo_matrix_t tmp;
+
+ g_return_if_fail (matrix != NULL);
+
+ if (inverse == NULL)
+ inverse = &tmp;
+
+ g_assert (isfinite (matrix->xx) && isfinite (matrix->yx) && isfinite (matrix->xy) && isfinite (matrix->yy));
+ *inverse = *matrix;
+ while (cairo_matrix_invert (inverse)) {
+ SWFDEC_INFO ("matrix not invertible, adding epsilon to smallest member");
+ /* add epsilon at point closest to zero */
+#define EPSILON (1.0 / SWFDEC_FIXED_SCALE_FACTOR)
+ if (ABS (matrix->xx) <= ABS (matrix->xy) &&
+ ABS (matrix->xx) <= ABS (matrix->yx) &&
+ ABS (matrix->xx) <= ABS (matrix->yy))
+ matrix->xx += (matrix->xx >= 0) ? EPSILON : -EPSILON;
+ else if (ABS (matrix->yy) <= ABS (matrix->xy) &&
+ ABS (matrix->yy) <= ABS (matrix->yx))
+ matrix->yy += (matrix->yy >= 0) ? EPSILON : -EPSILON;
+ else if (ABS (matrix->xy) <= ABS (matrix->yx))
+ matrix->xy += (matrix->xy >= 0) ? EPSILON : -EPSILON;
+ else
+ matrix->yx += (matrix->yx >= 0) ? EPSILON : -EPSILON;
+ *inverse = *matrix;
+ }
+}
+
+double
+swfdec_matrix_get_xscale (const cairo_matrix_t *matrix)
+{
+ double alpha;
+
+ if (matrix->xx) {
+ alpha = atan2 (matrix->yx, matrix->xx);
+ alpha = cos (alpha);
+ return matrix->xx / alpha * 100;
+ } else {
+ return matrix->yx * 100;
+ }
+}
+
+double
+swfdec_matrix_get_yscale (const cairo_matrix_t *matrix)
+{
+ double alpha;
+
+ if (matrix->yy) {
+ alpha = atan2 (matrix->xy, matrix->yy);
+ alpha = cos (alpha);
+ return matrix->yy / alpha * 100;
+ } else {
+ return matrix->xy * 100;
+ }
+}
+
+double
+swfdec_matrix_get_rotation (const cairo_matrix_t *matrix)
+{
+ return atan2 (matrix->yx, matrix->xx) * 180 / G_PI;
+}
+
+void
+swfdec_matrix_morph (cairo_matrix_t *dest, const cairo_matrix_t *start,
+ const cairo_matrix_t *end, guint ratio)
+{
+ guint inv_ratio = 65535 - ratio;
+ g_assert (ratio < 65536);
+
+ if (ratio == 0) {
+ *dest = *start;
+ return;
+ }
+ if (ratio == 65535) {
+ *dest = *end;
+ return;
+ }
+ dest->xx = (start->xx * inv_ratio + end->xx * ratio) / 65535;
+ dest->xy = (start->xy * inv_ratio + end->xy * ratio) / 65535;
+ dest->yy = (start->yy * inv_ratio + end->yy * ratio) / 65535;
+ dest->yx = (start->yx * inv_ratio + end->yx * ratio) / 65535;
+ dest->x0 = (start->x0 * inv_ratio + end->x0 * ratio) / 65535;
+ dest->y0 = (start->y0 * inv_ratio + end->y0 * ratio) / 65535;
+}
+
diff --git a/swfdec/swfdec_color.h b/swfdec/swfdec_color.h
new file mode 100644
index 0000000..d2ba7a1
--- /dev/null
+++ b/swfdec/swfdec_color.h
@@ -0,0 +1,75 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SWFDEC_COLOR_H__
+#define __SWFDEC_COLOR_H__
+
+#include <libswfdec/swfdec_types.h>
+
+struct _SwfdecColorTransform {
+ gboolean mask; /* TRUE if this is a mask - masks are always black */
+ /* naming here is taken from ActionScript, where ?a is the multiplier and ?b the offset */
+ int ra, rb, ga, gb, ba, bb, aa, ab;
+};
+
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define SWFDEC_COLOR_INDEX_ALPHA (3)
+#define SWFDEC_COLOR_INDEX_RED (2)
+#define SWFDEC_COLOR_INDEX_GREEN (1)
+#define SWFDEC_COLOR_INDEX_BLUE (0)
+#elif G_BYTE_ORDER == G_BIG_ENDIAN
+#define SWFDEC_COLOR_INDEX_ALPHA (0)
+#define SWFDEC_COLOR_INDEX_RED (1)
+#define SWFDEC_COLOR_INDEX_GREEN (2)
+#define SWFDEC_COLOR_INDEX_BLUE (3)
+#else
+#error "Unknown byte order"
+#endif
+
+#define SWFDEC_COLOR_COMBINE(r,g,b,a) (((a)<<24) | ((r)<<16) | ((g)<<8) | (b))
+#define SWFDEC_COLOR_A(x) (((x)>>24)&0xff)
+#define SWFDEC_COLOR_R(x) (((x)>>16)&0xff)
+#define SWFDEC_COLOR_G(x) (((x)>>8)&0xff)
+#define SWFDEC_COLOR_B(x) ((x)&0xff)
+
+SwfdecColor swfdec_color_apply_morph (SwfdecColor start, SwfdecColor end, guint ratio);
+void swfdec_color_set_source (cairo_t *cr, SwfdecColor color);
+void swfdec_color_transform_init_identity (SwfdecColorTransform * trans);
+void swfdec_color_transform_init_mask (SwfdecColorTransform * trans);
+void swfdec_color_transform_init_color (SwfdecColorTransform *trans, SwfdecColor color);
+gboolean swfdec_color_transform_is_identity (const SwfdecColorTransform * trans);
+#define swfdec_color_transform_is_mask(trans) ((trans)->mask)
+void swfdec_color_transform_chain (SwfdecColorTransform *dest,
+ const SwfdecColorTransform *last, const SwfdecColorTransform *first);
+SwfdecColor swfdec_color_apply_transform (SwfdecColor in,
+ const SwfdecColorTransform * trans);
+SwfdecColor swfdec_color_apply_transform_premultiplied (SwfdecColor in,
+ const SwfdecColorTransform * trans);
+
+void swfdec_matrix_ensure_invertible (cairo_matrix_t *matrix, cairo_matrix_t *inverse);
+double swfdec_matrix_get_xscale (const cairo_matrix_t *matrix);
+double swfdec_matrix_get_yscale (const cairo_matrix_t *matrix);
+double swfdec_matrix_get_rotation (const cairo_matrix_t *matrix);
+void swfdec_matrix_morph (cairo_matrix_t *dest, const cairo_matrix_t *start,
+ const cairo_matrix_t *end, guint ratio);
+
+
+#endif
diff --git a/swfdec/swfdec_color_as.c b/swfdec/swfdec_color_as.c
new file mode 100644
index 0000000..35a8304
--- /dev/null
+++ b/swfdec/swfdec_color_as.c
@@ -0,0 +1,181 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_context.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_internal.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_movie.h"
+
+/*** AS CODE ***/
+
+static SwfdecMovie *
+swfdec_movie_color_get_movie (SwfdecAsObject *object)
+{
+ SwfdecAsValue val;
+ SwfdecAsObject *target;
+
+ if (object == NULL)
+ return NULL;
+
+ swfdec_as_object_get_variable (object, SWFDEC_AS_STR_target, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return NULL;
+
+ target = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+ if (!SWFDEC_IS_MOVIE (target))
+ return NULL;
+
+ return SWFDEC_MOVIE (target);
+}
+
+SWFDEC_AS_NATIVE (700, 2, swfdec_movie_color_getRGB)
+void
+swfdec_movie_color_getRGB (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ int result;
+ SwfdecMovie *movie;
+
+ movie = swfdec_movie_color_get_movie (obj);
+
+ if (movie == NULL)
+ return;
+
+ result = (movie->color_transform.rb << 16) |
+ ((movie->color_transform.gb % 256) << 8) |
+ (movie->color_transform.bb % 256);
+ SWFDEC_AS_VALUE_SET_INT (ret, result);
+}
+
+static inline void
+add_variable (SwfdecAsObject *obj, const char *name, double value)
+{
+ SwfdecAsValue val;
+
+ SWFDEC_AS_VALUE_SET_NUMBER (&val, value);
+ swfdec_as_object_set_variable (obj, name, &val);
+}
+
+SWFDEC_AS_NATIVE (700, 3, swfdec_movie_color_getTransform)
+void
+swfdec_movie_color_getTransform (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecAsObject *ret;
+ SwfdecMovie *movie;
+
+ movie = swfdec_movie_color_get_movie (obj);
+
+ if (movie == NULL)
+ return;
+
+ ret = swfdec_as_object_new (cx);
+ if (ret == NULL)
+ return;
+
+ add_variable (ret, SWFDEC_AS_STR_ra, movie->color_transform.ra * 100.0 / 256.0);
+ add_variable (ret, SWFDEC_AS_STR_ga, movie->color_transform.ga * 100.0 / 256.0);
+ add_variable (ret, SWFDEC_AS_STR_ba, movie->color_transform.ba * 100.0 / 256.0);
+ add_variable (ret, SWFDEC_AS_STR_aa, movie->color_transform.aa * 100.0 / 256.0);
+ add_variable (ret, SWFDEC_AS_STR_rb, movie->color_transform.rb);
+ add_variable (ret, SWFDEC_AS_STR_gb, movie->color_transform.gb);
+ add_variable (ret, SWFDEC_AS_STR_bb, movie->color_transform.bb);
+ add_variable (ret, SWFDEC_AS_STR_ab, movie->color_transform.ab);
+ SWFDEC_AS_VALUE_SET_OBJECT (rval, ret);
+}
+
+SWFDEC_AS_NATIVE (700, 0, swfdec_movie_color_setRGB)
+void
+swfdec_movie_color_setRGB (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ guint color;
+ SwfdecMovie *movie;
+
+ if (argc < 1)
+ return;
+
+ movie = swfdec_movie_color_get_movie (obj);
+
+ if (movie == NULL)
+ return;
+
+ color = swfdec_as_value_to_integer (cx, &argv[0]);
+
+ movie->color_transform.ra = 0;
+ movie->color_transform.rb = (color & 0xFF0000) >> 16;
+ movie->color_transform.ga = 0;
+ movie->color_transform.gb = (color & 0xFF00) >> 8;
+ movie->color_transform.ba = 0;
+ movie->color_transform.bb = color & 0xFF;
+ swfdec_movie_invalidate_last (movie);
+}
+
+static inline void
+parse_property (SwfdecAsObject *obj, const char *name, int *target, gboolean scale)
+{
+ SwfdecAsValue val;
+ double d;
+
+ if (!swfdec_as_object_get_variable (obj, name, &val))
+ return;
+ d = swfdec_as_value_to_number (obj->context, &val);
+ if (scale) {
+ *target = d * 256.0 / 100.0;
+ } else {
+ *target = d;
+ }
+}
+
+SWFDEC_AS_NATIVE (700, 1, swfdec_movie_color_setTransform)
+void
+swfdec_movie_color_setTransform (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecAsObject *parse;
+ SwfdecMovie *movie;
+
+ if (argc < 1)
+ return;
+
+ movie = swfdec_movie_color_get_movie (obj);
+
+ if (movie == NULL)
+ return;
+
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]))
+ return;
+ parse = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
+ parse_property (parse, SWFDEC_AS_STR_ra, &movie->color_transform.ra, TRUE);
+ parse_property (parse, SWFDEC_AS_STR_ga, &movie->color_transform.ga, TRUE);
+ parse_property (parse, SWFDEC_AS_STR_ba, &movie->color_transform.ba, TRUE);
+ parse_property (parse, SWFDEC_AS_STR_aa, &movie->color_transform.aa, TRUE);
+ parse_property (parse, SWFDEC_AS_STR_rb, &movie->color_transform.rb, FALSE);
+ parse_property (parse, SWFDEC_AS_STR_gb, &movie->color_transform.gb, FALSE);
+ parse_property (parse, SWFDEC_AS_STR_bb, &movie->color_transform.bb, FALSE);
+ parse_property (parse, SWFDEC_AS_STR_ab, &movie->color_transform.ab, FALSE);
+ swfdec_movie_invalidate_last (movie);
+}
diff --git a/swfdec/swfdec_color_matrix_filter.c b/swfdec/swfdec_color_matrix_filter.c
new file mode 100644
index 0000000..95959af
--- /dev/null
+++ b/swfdec/swfdec_color_matrix_filter.c
@@ -0,0 +1,53 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (1110, 1, swfdec_color_matrix_filter_get_matrix)
+void
+swfdec_color_matrix_filter_get_matrix (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorMatrixFilter.matrix (get)");
+}
+
+SWFDEC_AS_NATIVE (1110, 2, swfdec_color_matrix_filter_set_matrix)
+void
+swfdec_color_matrix_filter_set_matrix (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorMatrixFilter.matrix (set)");
+}
+
+// constructor
+SWFDEC_AS_NATIVE (1110, 0, swfdec_color_matrix_filter_contruct)
+void
+swfdec_color_matrix_filter_contruct (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorMatrixFilter");
+}
diff --git a/swfdec/swfdec_color_transform.c b/swfdec/swfdec_color_transform.c
new file mode 100644
index 0000000..a06a370
--- /dev/null
+++ b/swfdec/swfdec_color_transform.c
@@ -0,0 +1,206 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+// properties
+SWFDEC_AS_NATIVE (1105, 101, swfdec_color_transform_get_alphaMultiplier)
+void
+swfdec_color_transform_get_alphaMultiplier (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform.alphaMultiplier (get)");
+}
+
+SWFDEC_AS_NATIVE (1105, 102, swfdec_color_transform_set_alphaMultiplier)
+void
+swfdec_color_transform_set_alphaMultiplier (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform.alphaMultiplier (set)");
+}
+
+SWFDEC_AS_NATIVE (1105, 103, swfdec_color_transform_get_redMultiplier)
+void
+swfdec_color_transform_get_redMultiplier (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform.redMultiplier (get)");
+}
+
+SWFDEC_AS_NATIVE (1105, 104, swfdec_color_transform_set_redMultiplier)
+void
+swfdec_color_transform_set_redMultiplier (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform.redMultiplier (set)");
+}
+
+SWFDEC_AS_NATIVE (1105, 105, swfdec_color_transform_get_greenMultiplier)
+void
+swfdec_color_transform_get_greenMultiplier (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform.greenMultiplier (get)");
+}
+
+SWFDEC_AS_NATIVE (1105, 106, swfdec_color_transform_set_greenMultiplier)
+void
+swfdec_color_transform_set_greenMultiplier (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform.greenMultiplier (set)");
+}
+
+SWFDEC_AS_NATIVE (1105, 107, swfdec_color_transform_get_blueMultiplier)
+void
+swfdec_color_transform_get_blueMultiplier (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform.blueMultiplier (get)");
+}
+
+SWFDEC_AS_NATIVE (1105, 108, swfdec_color_transform_set_blueMultiplier)
+void
+swfdec_color_transform_set_blueMultiplier (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform.blueMultiplier (set)");
+}
+
+SWFDEC_AS_NATIVE (1105, 109, swfdec_color_transform_get_alphaOffset)
+void
+swfdec_color_transform_get_alphaOffset (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform.alphaOffset (get)");
+}
+
+SWFDEC_AS_NATIVE (1105, 110, swfdec_color_transform_set_alphaOffset)
+void
+swfdec_color_transform_set_alphaOffset (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform.alphaOffset (set)");
+}
+
+SWFDEC_AS_NATIVE (1105, 111, swfdec_color_transform_get_redOffset)
+void
+swfdec_color_transform_get_redOffset (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform.redOffset (get)");
+}
+
+SWFDEC_AS_NATIVE (1105, 112, swfdec_color_transform_set_redOffset)
+void
+swfdec_color_transform_set_redOffset (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform.redOffset (set)");
+}
+
+SWFDEC_AS_NATIVE (1105, 113, swfdec_color_transform_get_greenOffset)
+void
+swfdec_color_transform_get_greenOffset (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform.greenOffset (get)");
+}
+
+SWFDEC_AS_NATIVE (1105, 114, swfdec_color_transform_set_greenOffset)
+void
+swfdec_color_transform_set_greenOffset (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform.greenOffset (set)");
+}
+
+SWFDEC_AS_NATIVE (1105, 115, swfdec_color_transform_get_blueOffset)
+void
+swfdec_color_transform_get_blueOffset (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform.blueOffset (get)");
+}
+
+SWFDEC_AS_NATIVE (1105, 116, swfdec_color_transform_set_blueOffset)
+void
+swfdec_color_transform_set_blueOffset (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform.blueOffset (set)");
+}
+
+SWFDEC_AS_NATIVE (1105, 117, swfdec_color_transform_get_rgb)
+void
+swfdec_color_transform_get_rgb (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform.rgb (get)");
+}
+
+SWFDEC_AS_NATIVE (1105, 118, swfdec_color_transform_set_rgb)
+void
+swfdec_color_transform_set_rgb (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform.rgb (set)");
+}
+
+// normal
+SWFDEC_AS_NATIVE (1105, 1, swfdec_color_transform_concat)
+void
+swfdec_color_transform_concat (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform.concat");
+}
+
+// constructor
+SWFDEC_AS_NATIVE (1105, 0, swfdec_color_transform_construct)
+void
+swfdec_color_transform_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ColorTransform");
+}
diff --git a/swfdec/swfdec_convolution_filter.c b/swfdec/swfdec_convolution_filter.c
new file mode 100644
index 0000000..bcb6309
--- /dev/null
+++ b/swfdec/swfdec_convolution_filter.c
@@ -0,0 +1,197 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (1109, 1, swfdec_convolution_filter_get_matrixX)
+void
+swfdec_convolution_filter_get_matrixX (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ConvolutionFilter.matrixX (get)");
+}
+
+SWFDEC_AS_NATIVE (1109, 2, swfdec_convolution_filter_set_matrixX)
+void
+swfdec_convolution_filter_set_matrixX (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ConvolutionFilter.matrixX (set)");
+}
+
+SWFDEC_AS_NATIVE (1109, 3, swfdec_convolution_filter_get_matrixY)
+void
+swfdec_convolution_filter_get_matrixY (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ConvolutionFilter.matrixY (get)");
+}
+
+SWFDEC_AS_NATIVE (1109, 4, swfdec_convolution_filter_set_matrixY)
+void
+swfdec_convolution_filter_set_matrixY (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ConvolutionFilter.matrixY (set)");
+}
+
+SWFDEC_AS_NATIVE (1109, 5, swfdec_convolution_filter_get_matrix)
+void
+swfdec_convolution_filter_get_matrix (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ConvolutionFilter.matrix (get)");
+}
+
+SWFDEC_AS_NATIVE (1109, 6, swfdec_convolution_filter_set_matrix)
+void
+swfdec_convolution_filter_set_matrix (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ConvolutionFilter.matrix (set)");
+}
+
+SWFDEC_AS_NATIVE (1109, 7, swfdec_convolution_filter_get_divisor)
+void
+swfdec_convolution_filter_get_divisor (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ConvolutionFilter.divisor (get)");
+}
+
+SWFDEC_AS_NATIVE (1109, 8, swfdec_convolution_filter_set_divisor)
+void
+swfdec_convolution_filter_set_divisor (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ConvolutionFilter.divisor (set)");
+}
+
+SWFDEC_AS_NATIVE (1109, 9, swfdec_convolution_filter_get_bias)
+void
+swfdec_convolution_filter_get_bias (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ConvolutionFilter.bias (get)");
+}
+
+SWFDEC_AS_NATIVE (1109, 10, swfdec_convolution_filter_set_bias)
+void
+swfdec_convolution_filter_set_bias (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ConvolutionFilter.bias (set)");
+}
+
+SWFDEC_AS_NATIVE (1109, 11, swfdec_convolution_filter_get_preserveAlpha)
+void
+swfdec_convolution_filter_get_preserveAlpha (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ConvolutionFilter.preserveAlpha (get)");
+}
+
+SWFDEC_AS_NATIVE (1109, 12, swfdec_convolution_filter_set_preserveAlpha)
+void
+swfdec_convolution_filter_set_preserveAlpha (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ConvolutionFilter.preserveAlpha (set)");
+}
+
+SWFDEC_AS_NATIVE (1109, 13, swfdec_convolution_filter_get_clamp)
+void
+swfdec_convolution_filter_get_clamp (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ConvolutionFilter.clamp (get)");
+}
+
+SWFDEC_AS_NATIVE (1109, 14, swfdec_convolution_filter_set_clamp)
+void
+swfdec_convolution_filter_set_clamp (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ConvolutionFilter.clamp (set)");
+}
+
+SWFDEC_AS_NATIVE (1109, 15, swfdec_convolution_filter_get_color)
+void
+swfdec_convolution_filter_get_color (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ConvolutionFilter.color (get)");
+}
+
+SWFDEC_AS_NATIVE (1109, 16, swfdec_convolution_filter_set_color)
+void
+swfdec_convolution_filter_set_color (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ConvolutionFilter.color (set)");
+}
+
+SWFDEC_AS_NATIVE (1109, 17, swfdec_convolution_filter_get_alpha)
+void
+swfdec_convolution_filter_get_alpha (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ConvolutionFilter.alpha (get)");
+}
+
+SWFDEC_AS_NATIVE (1109, 18, swfdec_convolution_filter_set_alpha)
+void
+swfdec_convolution_filter_set_alpha (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ConvolutionFilter.alpha (set)");
+}
+
+// constructor
+SWFDEC_AS_NATIVE (1109, 0, swfdec_convolution_filter_contruct)
+void
+swfdec_convolution_filter_contruct (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("ConvolutionFilter");
+}
diff --git a/swfdec/swfdec_debug.c b/swfdec/swfdec_debug.c
new file mode 100644
index 0000000..54eee5c
--- /dev/null
+++ b/swfdec/swfdec_debug.c
@@ -0,0 +1,78 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib.h>
+#include "swfdec_debug.h"
+
+static const char *swfdec_debug_level_names[] = {
+ "NONE ",
+ "ERROR",
+ "FIXME",
+ "WARN ",
+ "INFO ",
+ "DEBUG",
+ "LOG "
+};
+
+#ifndef SWFDEC_LEVEL_DEFAULT
+# define SWFDEC_LEVEL_DEFAULT SWFDEC_LEVEL_FIXME
+#endif
+
+static guint swfdec_debug_level = SWFDEC_LEVEL_DEFAULT;
+
+void
+swfdec_debug_log (guint level, const char *file, const char *function,
+ int line, const char *format, ...)
+{
+ va_list varargs;
+ char *s;
+
+ if (level > swfdec_debug_level)
+ return;
+
+ va_start (varargs, format);
+ s = g_strdup_vprintf (format, varargs);
+ va_end (varargs);
+
+ g_printerr ("SWFDEC: %s: %s(%d): %s: %s\n",
+ swfdec_debug_level_names[level], file, line, function, s);
+ g_free (s);
+}
+
+void
+swfdec_debug_set_level (guint level)
+{
+ if (swfdec_debug_level >= G_N_ELEMENTS (swfdec_debug_level_names))
+ swfdec_debug_level = G_N_ELEMENTS (swfdec_debug_level_names) - 1;
+ else
+ swfdec_debug_level = level;
+}
+
+int
+swfdec_debug_get_level (void)
+{
+ return swfdec_debug_level;
+}
+
diff --git a/swfdec/swfdec_debug.h b/swfdec/swfdec_debug.h
new file mode 100644
index 0000000..e6821e9
--- /dev/null
+++ b/swfdec/swfdec_debug.h
@@ -0,0 +1,65 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SWFDEC_DEBUG_H__
+#define __SWFDEC_DEBUG_H__
+
+#include <glib.h>
+
+enum {
+ SWFDEC_LEVEL_NONE = 0,
+ SWFDEC_LEVEL_ERROR,
+ SWFDEC_LEVEL_FIXME,
+ SWFDEC_LEVEL_WARNING,
+ SWFDEC_LEVEL_INFO,
+ SWFDEC_LEVEL_DEBUG,
+ SWFDEC_LEVEL_LOG
+};
+
+#define SWFDEC_ERROR(...) \
+ SWFDEC_DEBUG_LEVEL(SWFDEC_LEVEL_ERROR, __VA_ARGS__)
+#define SWFDEC_FIXME(...) \
+ SWFDEC_DEBUG_LEVEL(SWFDEC_LEVEL_FIXME, __VA_ARGS__)
+#define SWFDEC_WARNING(...) \
+ SWFDEC_DEBUG_LEVEL(SWFDEC_LEVEL_WARNING, __VA_ARGS__)
+#define SWFDEC_INFO(...) \
+ SWFDEC_DEBUG_LEVEL(SWFDEC_LEVEL_INFO, __VA_ARGS__)
+#define SWFDEC_DEBUG(...) \
+ SWFDEC_DEBUG_LEVEL(SWFDEC_LEVEL_DEBUG, __VA_ARGS__)
+#define SWFDEC_LOG(...) \
+ SWFDEC_DEBUG_LEVEL(SWFDEC_LEVEL_LOG, __VA_ARGS__)
+
+#define SWFDEC_STUB(fun) \
+ SWFDEC_DEBUG_LEVEL (SWFDEC_LEVEL_FIXME, "%s %s", fun, "is not implemented yet")
+
+#ifdef SWFDEC_DISABLE_DEBUG
+#define SWFDEC_DEBUG_LEVEL(level,...) (void) 0
+#else
+#define SWFDEC_DEBUG_LEVEL(level,...) \
+ swfdec_debug_log ((level), __FILE__, G_STRFUNC, __LINE__, __VA_ARGS__)
+#endif
+
+void swfdec_debug_log (guint level, const char *file, const char *function,
+ int line, const char *format, ...) G_GNUC_PRINTF (5, 6);
+void swfdec_debug_set_level (guint level);
+int swfdec_debug_get_level (void);
+
+#endif
diff --git a/swfdec/swfdec_debugger.c b/swfdec/swfdec_debugger.c
new file mode 100644
index 0000000..2dca1df
--- /dev/null
+++ b/swfdec/swfdec_debugger.c
@@ -0,0 +1,617 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include "swfdec_debugger.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_frame_internal.h"
+#include "swfdec_as_interpret.h"
+#include "swfdec_debug.h"
+#include "swfdec_decoder.h"
+#include "swfdec_movie.h"
+#include "swfdec_player_internal.h"
+
+enum {
+ SCRIPT_ADDED,
+ SCRIPT_REMOVED,
+ BREAKPOINT,
+ BREAKPOINT_ADDED,
+ BREAKPOINT_REMOVED,
+ MOVIE_ADDED,
+ MOVIE_REMOVED,
+ LAST_SIGNAL
+};
+
+G_DEFINE_TYPE (SwfdecDebugger, swfdec_debugger, SWFDEC_TYPE_PLAYER)
+static guint signals[LAST_SIGNAL] = { 0, };
+
+/*** SwfdecDebuggerScript ***/
+
+typedef struct {
+ guint version; /* version of parsed file */
+ SwfdecConstantPool * constant_pool; /* current constant pool */
+ GArray * commands; /* SwfdecDebuggerCommands parsed so far */
+} ScriptParser;
+
+static char *
+swfdec_debugger_print_push (ScriptParser *parser, const guint8 *data, guint len)
+{
+ gboolean first = TRUE;
+ SwfdecBits bits;
+ GString *string = g_string_new ("Push");
+
+ swfdec_bits_init_data (&bits, data, len);
+ while (swfdec_bits_left (&bits)) {
+ guint type = swfdec_bits_get_u8 (&bits);
+ if (first)
+ g_string_append (string, " ");
+ else
+ g_string_append (string, ", ");
+ first = FALSE;
+ switch (type) {
+ case 0: /* string */
+ {
+ char *s = swfdec_bits_get_string (&bits, parser->version);
+ if (!s)
+ goto error;
+ g_string_append_c (string, '"');
+ g_string_append (string, s);
+ g_string_append_c (string, '"');
+ g_free (s);
+ break;
+ }
+ case 1: /* float */
+ g_string_append_printf (string, "%g", swfdec_bits_get_float (&bits));
+ break;
+ case 2: /* null */
+ g_string_append (string, "null");
+ break;
+ case 3: /* undefined */
+ g_string_append (string, "undefined");
+ break;
+ case 4: /* register */
+ g_string_append_printf (string, "Register %u", swfdec_bits_get_u8 (&bits));
+ break;
+ case 5: /* boolean */
+ g_string_append (string, swfdec_bits_get_u8 (&bits) ? "True" : "False");
+ break;
+ case 6: /* double */
+ g_string_append_printf (string, "%g", swfdec_bits_get_double (&bits));
+ break;
+ case 7: /* 32bit int */
+ g_string_append_printf (string, "%d", swfdec_bits_get_u32 (&bits));
+ break;
+ case 8: /* 8bit ConstantPool address */
+ case 9: /* 16bit ConstantPool address */
+ {
+ guint id;
+ const char *s;
+
+ if (!parser->constant_pool) {
+ SWFDEC_ERROR ("no constant pool");
+ goto error;
+ }
+ id = type == 8 ? swfdec_bits_get_u8 (&bits) : swfdec_bits_get_u16 (&bits);
+ if (id >= swfdec_constant_pool_size (parser->constant_pool)) {
+ SWFDEC_ERROR ("constant pool size too small");
+ goto error;
+ }
+ s = swfdec_constant_pool_get (parser->constant_pool, id);
+ g_string_append_c (string, '"');
+ g_string_append (string, s);
+ g_string_append_c (string, '"');
+ }
+ break;
+ default:
+ SWFDEC_ERROR ("Push: type %u not implemented", type);
+ goto error;
+ }
+ }
+ return g_string_free (string, FALSE);
+
+error:
+ g_string_free (string, TRUE);
+ return g_strdup ("erroneous action Push");
+}
+
+/* NB: constant pool actions are special in that they are called at init time */
+static gboolean
+swfdec_debugger_add_command (gconstpointer bytecode, guint action,
+ const guint8 *data, guint len, gpointer parserp)
+{
+ ScriptParser *parser = parserp;
+ SwfdecDebuggerCommand command;
+
+ command.code = bytecode;
+ if (action == SWFDEC_AS_ACTION_PUSH) {
+ command.description = swfdec_debugger_print_push (parser, data, len);
+ } else {
+ command.description = swfdec_script_print_action (action, data, len);
+ }
+ g_assert (command.description != NULL);
+ g_array_append_val (parser->commands, command);
+ if (action == SWFDEC_AS_ACTION_CONSTANT_POOL) {
+ if (parser->constant_pool)
+ swfdec_constant_pool_free (parser->constant_pool);
+ parser->constant_pool = swfdec_constant_pool_new_from_action (data, len, parser->version);
+ }
+ return TRUE;
+}
+
+static SwfdecDebuggerScript *
+swfdec_debugger_script_new (SwfdecScript *script)
+{
+ ScriptParser parser;
+ SwfdecDebuggerScript *ret;
+
+ ret = g_new0 (SwfdecDebuggerScript, 1);
+ ret->script = script;
+ swfdec_script_ref (script);
+ parser.commands = g_array_new (TRUE, FALSE, sizeof (SwfdecDebuggerCommand));
+ parser.version = script->version;
+ if (script->constant_pool) {
+ parser.constant_pool = swfdec_constant_pool_new_from_action (
+ script->constant_pool->data, script->constant_pool->length, parser.version);
+ } else {
+ parser.constant_pool = NULL;
+ }
+ swfdec_script_foreach (script, swfdec_debugger_add_command, &parser);
+ ret->n_commands = parser.commands->len;
+ ret->commands = (SwfdecDebuggerCommand *) g_array_free (parser.commands, FALSE);
+ if (parser.constant_pool)
+ swfdec_constant_pool_free (parser.constant_pool);
+
+ return ret;
+}
+
+static void
+swfdec_debugger_script_free (SwfdecDebuggerScript *script)
+{
+ guint i;
+
+ g_assert (script);
+ swfdec_script_unref (script->script);
+ for (i = 0; i < script->n_commands; i++) {
+ g_free (script->commands[i].description);
+ }
+ g_free (script->commands);
+ g_free (script);
+}
+
+/*** BREAKPOINTS ***/
+
+typedef enum {
+ BREAKPOINT_NONE,
+ BREAKPOINT_PC
+} BreakpointType;
+
+typedef struct {
+ BreakpointType type;
+ const guint8 * pc;
+} Breakpoint;
+
+static void
+swfdec_debugger_update_interrupting (SwfdecDebugger *debugger)
+{
+ guint i;
+
+ debugger->has_breakpoints = debugger->stepping;
+
+ for (i = 0; i < debugger->breakpoints->len && !debugger->has_breakpoints; i++) {
+ Breakpoint *br = &g_array_index (debugger->breakpoints, Breakpoint, i);
+
+ if (br->type != BREAKPOINT_NONE)
+ debugger->has_breakpoints = TRUE;
+ }
+}
+
+guint
+swfdec_debugger_set_breakpoint (SwfdecDebugger *debugger,
+ SwfdecDebuggerScript *script, guint line)
+{
+ guint i;
+ Breakpoint *br = NULL;
+
+ g_return_val_if_fail (SWFDEC_IS_DEBUGGER (debugger), 0);
+ g_return_val_if_fail (script != NULL, 0);
+ g_return_val_if_fail (line < script->n_commands, 0);
+
+ for (i = 0; i < debugger->breakpoints->len; i++) {
+ br = &g_array_index (debugger->breakpoints, Breakpoint, i);
+ if (br->type == BREAKPOINT_NONE)
+ break;
+ br = NULL;
+ }
+
+ if (br == NULL) {
+ g_array_set_size (debugger->breakpoints, debugger->breakpoints->len + 1);
+ br = &g_array_index (debugger->breakpoints, Breakpoint,
+ debugger->breakpoints->len - 1);
+ }
+ br->type = BREAKPOINT_PC;
+ br->pc = script->commands[line].code;
+ swfdec_debugger_update_interrupting (debugger);
+ g_signal_emit (debugger, signals[BREAKPOINT_ADDED], 0, i + 1);
+ return i + 1;
+}
+
+void
+swfdec_debugger_unset_breakpoint (SwfdecDebugger *debugger, guint id)
+{
+ Breakpoint *br;
+
+ g_return_if_fail (SWFDEC_IS_DEBUGGER (debugger));
+ g_return_if_fail (id > 0);
+
+ if (debugger->breakpoints == NULL)
+ return;
+ if (id > debugger->breakpoints->len)
+ return;
+ br = &g_array_index (debugger->breakpoints, Breakpoint, id - 1);
+ if (br->type == BREAKPOINT_NONE)
+ return;
+
+ g_signal_emit (debugger, signals[BREAKPOINT_REMOVED], 0, id);
+ br->type = BREAKPOINT_NONE;
+ swfdec_debugger_update_interrupting (debugger);
+}
+
+static gboolean
+swfdec_debugger_get_from_as (SwfdecDebugger *debugger, SwfdecScript *script,
+ const guint8 *pc, SwfdecDebuggerScript **script_out, guint *line_out)
+{
+ guint line;
+ SwfdecDebuggerScript *dscript = swfdec_debugger_get_script (debugger, script);
+
+ if (dscript == NULL)
+ return FALSE;
+ for (line = 0; line < dscript->n_commands; line++) {
+ if (pc == dscript->commands[line].code) {
+ if (script_out)
+ *script_out = dscript;
+ if (line_out)
+ *line_out = line;
+ return TRUE;
+ }
+ if (pc < (guint8 *) dscript->commands[line].code)
+ return FALSE;
+ }
+ return FALSE;
+}
+
+gboolean
+swfdec_debugger_get_current (SwfdecDebugger *debugger,
+ SwfdecDebuggerScript **dscript, guint *line)
+{
+ SwfdecAsFrame *frame;
+
+ g_return_val_if_fail (SWFDEC_IS_DEBUGGER (debugger), FALSE);
+
+ frame = SWFDEC_AS_CONTEXT (debugger)->frame;
+ if (frame == NULL)
+ return FALSE;
+ if (frame->script == NULL) /* native function */
+ return FALSE;
+ return swfdec_debugger_get_from_as (debugger, frame->script, frame->pc, dscript, line);
+}
+
+typedef struct {
+ const guint8 *pc;
+ SwfdecScript *current;
+} BreakpointFinder;
+
+static void
+swfdec_debugger_find_script (gpointer key, gpointer value, gpointer data)
+{
+ BreakpointFinder *find = data;
+ SwfdecScript *script = key;
+
+ if (script->buffer->data > find->pc ||
+ find->pc >= (script->buffer->data + script->buffer->length))
+ return;
+ if (find->current == NULL ||
+ find->current->buffer->length > script->buffer->length)
+ find->current = script;
+}
+
+gboolean
+swfdec_debugger_get_breakpoint (SwfdecDebugger *debugger, guint id,
+ SwfdecDebuggerScript **script, guint *line)
+{
+ Breakpoint *br;
+ BreakpointFinder find = { NULL, NULL };
+
+ g_return_val_if_fail (SWFDEC_IS_DEBUGGER (debugger), FALSE);
+ g_return_val_if_fail (id > 0, FALSE);
+
+ if (debugger->breakpoints == NULL)
+ return FALSE;
+ if (id > debugger->breakpoints->len)
+ return FALSE;
+ br = &g_array_index (debugger->breakpoints, Breakpoint, id - 1);
+ if (br->type == BREAKPOINT_NONE)
+ return FALSE;
+
+ find.pc = br->pc;
+ g_hash_table_foreach (debugger->scripts, swfdec_debugger_find_script, &find);
+ if (find.current == NULL)
+ return FALSE;
+ return swfdec_debugger_get_from_as (debugger, find.current, find.pc, script, line);
+}
+
+guint
+swfdec_debugger_get_n_breakpoints (SwfdecDebugger *debugger)
+{
+ g_return_val_if_fail (SWFDEC_IS_DEBUGGER (debugger), 0);
+
+ if (debugger->breakpoints == NULL)
+ return 0;
+
+ return debugger->breakpoints->len;
+}
+
+/*** SwfdecDebugger ***/
+
+static void
+swfdec_debugger_dispose (GObject *object)
+{
+ SwfdecDebugger *debugger = SWFDEC_DEBUGGER (object);
+
+ swfdec_debugger_set_stepping (debugger, FALSE);
+ g_assert (g_hash_table_size (debugger->scripts) == 0);
+ g_hash_table_destroy (debugger->scripts);
+ if (debugger->breakpoints)
+ g_array_free (debugger->breakpoints, TRUE);
+
+ G_OBJECT_CLASS (swfdec_debugger_parent_class)->dispose (object);
+}
+
+#if 0
+static void
+swfdec_debugger_do_breakpoint (SwfdecDebugger *debugger, guint id)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (debugger);
+
+ GList *walk;
+ for (walk = player->roots; walk; walk = walk->next) {
+ swfdec_movie_update (walk->data);
+ }
+ g_object_thaw_notify (G_OBJECT (debugger));
+ if (!swfdec_rect_is_empty (&player->invalid)) {
+ double x, y, width, height;
+ x = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.x0);
+ y = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.y0);
+ width = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.x1 - player->invalid.x0);
+ height = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.y1 - player->invalid.y0);
+ g_signal_emit_by_name (player, "invalidate", x, y, width, height);
+ swfdec_rect_init_empty (&player->invalid);
+ }
+
+ g_signal_emit (debugger, signals[BREAKPOINT], 0, id);
+
+ g_object_freeze_notify (G_OBJECT (debugger));
+}
+
+static void
+swfdec_debugger_step (SwfdecAsContext *context)
+{
+ SwfdecDebugger *debugger = SWFDEC_DEBUGGER (context);
+
+ if (context->state != SWFDEC_AS_CONTEXT_RUNNING)
+ return;
+ if (!debugger->has_breakpoints)
+ return;
+
+ if (debugger->stepping) {
+ swfdec_debugger_do_breakpoint (debugger, 0);
+ } else {
+ guint i;
+ Breakpoint *br;
+ const guint8 *pc = context->frame->pc;
+
+ for (i = 0; i < debugger->breakpoints->len; i++) {
+ br = &g_array_index (debugger->breakpoints, Breakpoint, i);
+ if (br->type == BREAKPOINT_NONE)
+ continue;
+ if (br->pc == pc) {
+ swfdec_debugger_do_breakpoint (debugger, i + 1);
+ return;
+ }
+ }
+ }
+}
+#endif
+
+static void
+swfdec_debugger_class_init (SwfdecDebuggerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = swfdec_debugger_dispose;
+
+ signals[SCRIPT_ADDED] = g_signal_new ("script-added", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+ signals[SCRIPT_REMOVED] = g_signal_new ("script-removed", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+ signals[BREAKPOINT] = g_signal_new ("breakpoint",
+ G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+ g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
+ signals[BREAKPOINT_ADDED] = g_signal_new ("breakpoint-added",
+ G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+ g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
+ signals[BREAKPOINT_REMOVED] = g_signal_new ("breakpoint-removed",
+ G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+ g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
+ signals[MOVIE_ADDED] = g_signal_new ("movie-added",
+ G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT);
+ signals[MOVIE_REMOVED] = g_signal_new ("movie-removed",
+ G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT);
+}
+
+static void
+swfdec_debugger_init (SwfdecDebugger *debugger)
+{
+ debugger->scripts = g_hash_table_new_full (g_direct_hash, g_direct_equal,
+ NULL, (GDestroyNotify) swfdec_debugger_script_free);
+ debugger->breakpoints = g_array_new (FALSE, FALSE, sizeof (Breakpoint));
+}
+
+/**
+ * swfdec_debugger_new:
+ *
+ * Creates a #SwfdecPlayer that can be debugged.
+ *
+ * Returns: a new #SwfdecDebugger
+ **/
+SwfdecPlayer *
+swfdec_debugger_new (void)
+{
+ SwfdecPlayer *player;
+
+ swfdec_init ();
+ player = g_object_new (SWFDEC_TYPE_DEBUGGER, NULL);
+ return player;
+}
+
+void
+swfdec_debugger_add_script (SwfdecDebugger *debugger, SwfdecScript *script)
+{
+ SwfdecDebuggerScript *dscript = swfdec_debugger_script_new (script);
+
+ g_hash_table_insert (debugger->scripts, script, dscript);
+ g_signal_emit (debugger, signals[SCRIPT_ADDED], 0, dscript);
+}
+
+SwfdecDebuggerScript *
+swfdec_debugger_get_script (SwfdecDebugger *debugger, SwfdecScript *script)
+{
+ SwfdecDebuggerScript *dscript = g_hash_table_lookup (debugger->scripts, script);
+
+ return dscript;
+}
+
+void
+swfdec_debugger_remove_script (SwfdecDebugger *debugger, SwfdecScript *script)
+{
+ SwfdecDebuggerScript *dscript = g_hash_table_lookup (debugger->scripts, script);
+
+ g_assert (dscript);
+ g_signal_emit (debugger, signals[SCRIPT_REMOVED], 0, dscript);
+ g_hash_table_remove (debugger->scripts, script);
+}
+
+typedef struct {
+ GFunc func;
+ gpointer data;
+} ForeachData;
+
+static void
+do_foreach (gpointer key, gpointer value, gpointer data)
+{
+ ForeachData *fdata = data;
+
+ fdata->func (value, fdata->data);
+}
+
+void
+swfdec_debugger_foreach_script (SwfdecDebugger *debugger, GFunc func, gpointer data)
+{
+ ForeachData fdata = { func, data };
+ g_hash_table_foreach (debugger->scripts, do_foreach, &fdata);
+}
+
+void
+swfdec_debugger_set_stepping (SwfdecDebugger *debugger, gboolean stepping)
+{
+ g_return_if_fail (SWFDEC_IS_DEBUGGER (debugger));
+
+ if (debugger->stepping == stepping)
+ return;
+ debugger->stepping = stepping;
+}
+
+gboolean
+swfdec_debugger_get_stepping (SwfdecDebugger *debugger)
+{
+ g_return_val_if_fail (SWFDEC_IS_DEBUGGER (debugger), FALSE);
+
+ return debugger->stepping;
+}
+
+const char *
+swfdec_debugger_run (SwfdecDebugger *debugger, const char *command)
+{
+ SwfdecPlayer *player;
+ GList *walk;
+
+ g_return_val_if_fail (SWFDEC_IS_DEBUGGER (debugger), NULL);
+ g_return_val_if_fail (command != NULL, NULL);
+
+ player = SWFDEC_PLAYER (debugger);
+ g_object_freeze_notify (G_OBJECT (debugger));
+
+
+ SWFDEC_ERROR ("ooops");
+
+
+ for (walk = player->roots; walk; walk = walk->next) {
+ swfdec_movie_update (walk->data);
+ }
+ if (!swfdec_rect_is_empty (&player->invalid)) {
+ double x, y, width, height;
+ x = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.x0);
+ y = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.y0);
+ width = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.x1 - player->invalid.x0);
+ height = SWFDEC_TWIPS_TO_DOUBLE (player->invalid.y1 - player->invalid.y0);
+ g_signal_emit_by_name (player, "invalidate", x, y, width, height);
+ swfdec_rect_init_empty (&player->invalid);
+ }
+ g_object_thaw_notify (G_OBJECT (debugger));
+
+ return command;
+}
+
+guint
+swfdec_debugger_script_has_breakpoint (SwfdecDebugger *debugger,
+ SwfdecDebuggerScript *script, guint line)
+{
+ guint i;
+ const guint8 *pc;
+
+ g_return_val_if_fail (SWFDEC_IS_DEBUGGER (debugger), FALSE);
+ g_return_val_if_fail (script != NULL, FALSE);
+ g_return_val_if_fail (line < script->n_commands, FALSE);
+
+ pc = script->commands[line].code;
+ for (i = 0; i < debugger->breakpoints->len; i++) {
+ Breakpoint *br = &g_array_index (debugger->breakpoints, Breakpoint, i);
+
+ if (br->type == BREAKPOINT_PC && pc == br->pc)
+ return i + 1;
+ }
+ return 0;
+}
diff --git a/swfdec/swfdec_debugger.h b/swfdec/swfdec_debugger.h
new file mode 100644
index 0000000..139e93b
--- /dev/null
+++ b/swfdec/swfdec_debugger.h
@@ -0,0 +1,108 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_DEBUGGER_H_
+#define _SWFDEC_DEBUGGER_H_
+
+#include <glib-object.h>
+#include <libswfdec/swfdec.h>
+#include <libswfdec/swfdec_player_internal.h>
+#include <libswfdec/swfdec_script.h>
+#include <libswfdec/swfdec_types.h>
+
+G_BEGIN_DECLS
+
+//typedef struct _SwfdecDebugger SwfdecDebugger;
+typedef struct _SwfdecDebuggerClass SwfdecDebuggerClass;
+typedef struct _SwfdecDebuggerScript SwfdecDebuggerScript;
+typedef struct _SwfdecDebuggerCommand SwfdecDebuggerCommand;
+
+#define SWFDEC_TYPE_DEBUGGER (swfdec_debugger_get_type())
+#define SWFDEC_IS_DEBUGGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_DEBUGGER))
+#define SWFDEC_IS_DEBUGGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_DEBUGGER))
+#define SWFDEC_DEBUGGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_DEBUGGER, SwfdecDebugger))
+#define SWFDEC_DEBUGGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_DEBUGGER, SwfdecDebuggerClass))
+#define SWFDEC_DEBUGGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_DEBUGGER, SwfdecDebuggerClass))
+
+struct _SwfdecDebuggerCommand {
+ const guint8 * code; /* pointer to start bytecode in SwfdecScript */
+ char * description; /* string describing the action */
+};
+
+struct _SwfdecDebuggerScript {
+ SwfdecScript * script; /* the script */
+ SwfdecDebuggerCommand *commands; /* commands executed in the script (NULL-terminated) */
+ guint n_commands; /* number of commands */
+};
+
+struct _SwfdecDebugger {
+ SwfdecPlayer player;
+
+ GHashTable * scripts; /* JSScript => SwfdecDebuggerScript mapping */
+ GArray * breakpoints; /* all breakpoints */
+ gboolean stepping; /* TRUE if we're currently stepping through the code */
+ gboolean has_breakpoints; /* performance: track if there's breakpoints */
+};
+
+struct _SwfdecDebuggerClass {
+ SwfdecPlayerClass player_class;
+};
+
+GType swfdec_debugger_get_type (void);
+SwfdecPlayer * swfdec_debugger_new (void);
+
+gboolean swfdec_debugger_get_current (SwfdecDebugger * debugger,
+ SwfdecDebuggerScript **dscript,
+ guint * line);
+guint swfdec_debugger_set_breakpoint (SwfdecDebugger * debugger,
+ SwfdecDebuggerScript * script,
+ guint line);
+void swfdec_debugger_unset_breakpoint
+ (SwfdecDebugger * debugger,
+ guint id);
+gboolean swfdec_debugger_get_breakpoint (SwfdecDebugger * debugger,
+ guint id,
+ SwfdecDebuggerScript **script,
+ guint * line);
+guint swfdec_debugger_get_n_breakpoints
+ (SwfdecDebugger * debugger);
+void swfdec_debugger_set_stepping (SwfdecDebugger * debugger,
+ gboolean stepping);
+gboolean swfdec_debugger_get_stepping (SwfdecDebugger * debugger);
+
+void swfdec_debugger_add_script (SwfdecDebugger * debugger,
+ SwfdecScript * script);
+SwfdecDebuggerScript * swfdec_debugger_get_script (SwfdecDebugger * debugger,
+ SwfdecScript * script);
+void swfdec_debugger_remove_script (SwfdecDebugger * debugger,
+ SwfdecScript * script);
+void swfdec_debugger_foreach_script (SwfdecDebugger * debugger,
+ GFunc func,
+ gpointer data);
+guint swfdec_debugger_script_has_breakpoint
+ (SwfdecDebugger * debugger,
+ SwfdecDebuggerScript * script,
+ guint line);
+
+const char * swfdec_debugger_run (SwfdecDebugger * debugger,
+ const char * command);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_decoder.c b/swfdec/swfdec_decoder.c
new file mode 100644
index 0000000..24bbda0
--- /dev/null
+++ b/swfdec/swfdec_decoder.c
@@ -0,0 +1,103 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include "swfdec_decoder.h"
+#include "swfdec_debug.h"
+#include "swfdec_decoder.h"
+#include "swfdec_image.h"
+#include "swfdec_image_decoder.h"
+#include "swfdec_swf_decoder.h"
+
+
+G_DEFINE_ABSTRACT_TYPE (SwfdecDecoder, swfdec_decoder, G_TYPE_OBJECT)
+
+static void
+swfdec_decoder_class_init (SwfdecDecoderClass *klass)
+{
+}
+
+static void
+swfdec_decoder_init (SwfdecDecoder *decoder)
+{
+}
+
+SwfdecDecoder *
+swfdec_decoder_new (SwfdecPlayer *player, const SwfdecBuffer *buffer)
+{
+ guchar *data;
+ SwfdecDecoder *retval;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (buffer != NULL, NULL);
+
+ if (buffer->length < SWFDEC_DECODER_DETECT_LENGTH)
+ return NULL;
+
+ data = buffer->data;
+ if ((data[0] == 'C' || data[0] == 'F') &&
+ 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 if (swfdec_image_detect (data) != SWFDEC_IMAGE_TYPE_UNKNOWN) {
+ retval = g_object_new (SWFDEC_TYPE_IMAGE_DECODER, NULL);
+ } else {
+ retval = NULL;
+ }
+ if (retval) {
+ retval->player = player;
+ }
+ return retval;
+}
+
+SwfdecStatus
+swfdec_decoder_parse (SwfdecDecoder *decoder, SwfdecBuffer *buffer)
+{
+ SwfdecDecoderClass *klass;
+
+ g_return_val_if_fail (SWFDEC_IS_DECODER (decoder), SWFDEC_STATUS_ERROR);
+ g_return_val_if_fail (buffer != NULL, SWFDEC_STATUS_ERROR);
+
+ klass = SWFDEC_DECODER_GET_CLASS (decoder);
+ g_return_val_if_fail (klass->parse, SWFDEC_STATUS_ERROR);
+ return klass->parse (decoder, buffer);
+}
+
+SwfdecStatus
+swfdec_decoder_eof (SwfdecDecoder *decoder)
+{
+ SwfdecDecoderClass *klass;
+
+ g_return_val_if_fail (SWFDEC_IS_DECODER (decoder), SWFDEC_STATUS_ERROR);
+
+ klass = SWFDEC_DECODER_GET_CLASS (decoder);
+ g_return_val_if_fail (klass->eof, SWFDEC_STATUS_ERROR);
+ return klass->eof (decoder);
+}
+
diff --git a/swfdec/swfdec_decoder.h b/swfdec/swfdec_decoder.h
new file mode 100644
index 0000000..3a58015
--- /dev/null
+++ b/swfdec/swfdec_decoder.h
@@ -0,0 +1,93 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_DECODER_H_
+#define _SWFDEC_DECODER_H_
+
+#include <glib-object.h>
+#include <libswfdec/swfdec_buffer.h>
+#include <libswfdec/swfdec_loader.h>
+#include <libswfdec/swfdec_player.h>
+#include <libswfdec/swfdec_types.h>
+
+G_BEGIN_DECLS
+
+
+typedef enum {
+ /* processing continued as expected */
+ SWFDEC_STATUS_OK = 0,
+ /* An error occured during parsing */
+ SWFDEC_STATUS_ERROR = (1 << 0),
+ /* more data needs to be made available for processing */
+ SWFDEC_STATUS_NEEDBITS = (1 << 1),
+ /* parsing is finished */
+ SWFDEC_STATUS_EOF = (1 << 2),
+ /* header parsing is complete, framerate, image size etc are known */
+ SWFDEC_STATUS_INIT = (1 << 3),
+ /* at least one new image is available for display */
+ SWFDEC_STATUS_IMAGE = (1 << 4)
+} SwfdecStatus;
+
+//typedef struct _SwfdecDecoder SwfdecDecoder;
+typedef struct _SwfdecDecoderClass SwfdecDecoderClass;
+
+#define SWFDEC_TYPE_DECODER (swfdec_decoder_get_type())
+#define SWFDEC_IS_DECODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_DECODER))
+#define SWFDEC_IS_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_DECODER))
+#define SWFDEC_DECODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_DECODER, SwfdecDecoder))
+#define SWFDEC_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_DECODER, SwfdecDecoderClass))
+#define SWFDEC_DECODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_DECODER, SwfdecDecoderClass))
+
+struct _SwfdecDecoder
+{
+ GObject object;
+
+ SwfdecPlayer * player; /* FIXME: only needed to get the JS Context, I want it gone */
+ SwfdecLoaderDataType data_type; /* type of the data we provide or UNKNOWN if not known yet */
+ guint rate; /* rate per second in 256th */
+ guint width; /* width of stream */
+ guint height; /* guess */
+ guint bytes_loaded; /* bytes already loaded */
+ guint bytes_total; /* total bytes in the file or 0 if not known */
+ guint frames_loaded; /* frames already loaded */
+ guint frames_total; /* total frames */
+};
+
+struct _SwfdecDecoderClass
+{
+ GObjectClass object_class;
+
+ SwfdecStatus (* parse) (SwfdecDecoder * decoder,
+ SwfdecBuffer * buffer);
+ SwfdecStatus (* eof) (SwfdecDecoder * decoder);
+};
+
+GType swfdec_decoder_get_type (void);
+
+#define SWFDEC_DECODER_DETECT_LENGTH 4
+SwfdecDecoder * swfdec_decoder_new (SwfdecPlayer * player,
+ const SwfdecBuffer * buffer);
+
+SwfdecStatus swfdec_decoder_parse (SwfdecDecoder * decoder,
+ SwfdecBuffer * buffer);
+SwfdecStatus swfdec_decoder_eof (SwfdecDecoder * decoder);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_displacement_map_filter.c b/swfdec/swfdec_displacement_map_filter.c
new file mode 100644
index 0000000..55dea6e
--- /dev/null
+++ b/swfdec/swfdec_displacement_map_filter.c
@@ -0,0 +1,197 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (1111, 1, swfdec_displacement_map_filter_get_mapBitmap)
+void
+swfdec_displacement_map_filter_get_mapBitmap (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DisplacementMapFilter.mapBitmap (get)");
+}
+
+SWFDEC_AS_NATIVE (1111, 2, swfdec_displacement_map_filter_set_mapBitmap)
+void
+swfdec_displacement_map_filter_set_mapBitmap (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DisplacementMapFilter.mapBitmap (set)");
+}
+
+SWFDEC_AS_NATIVE (1111, 3, swfdec_displacement_map_filter_get_mapPoint)
+void
+swfdec_displacement_map_filter_get_mapPoint (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DisplacementMapFilter.mapPoint (get)");
+}
+
+SWFDEC_AS_NATIVE (1111, 4, swfdec_displacement_map_filter_set_mapPoint)
+void
+swfdec_displacement_map_filter_set_mapPoint (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DisplacementMapFilter.mapPoint (set)");
+}
+
+SWFDEC_AS_NATIVE (1111, 5, swfdec_displacement_map_filter_get_componentX)
+void
+swfdec_displacement_map_filter_get_componentX (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DisplacementMapFilter.componentX (get)");
+}
+
+SWFDEC_AS_NATIVE (1111, 6, swfdec_displacement_map_filter_set_componentX)
+void
+swfdec_displacement_map_filter_set_componentX (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DisplacementMapFilter.componentX (set)");
+}
+
+SWFDEC_AS_NATIVE (1111, 7, swfdec_displacement_map_filter_get_componentY)
+void
+swfdec_displacement_map_filter_get_componentY (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DisplacementMapFilter.componentY (get)");
+}
+
+SWFDEC_AS_NATIVE (1111, 8, swfdec_displacement_map_filter_set_componentY)
+void
+swfdec_displacement_map_filter_set_componentY (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DisplacementMapFilter.componentY (set)");
+}
+
+SWFDEC_AS_NATIVE (1111, 9, swfdec_displacement_map_filter_get_scaleX)
+void
+swfdec_displacement_map_filter_get_scaleX (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DisplacementMapFilter.scaleX (get)");
+}
+
+SWFDEC_AS_NATIVE (1111, 10, swfdec_displacement_map_filter_set_scaleX)
+void
+swfdec_displacement_map_filter_set_scaleX (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DisplacementMapFilter.scaleX (set)");
+}
+
+SWFDEC_AS_NATIVE (1111, 11, swfdec_displacement_map_filter_get_scaleY)
+void
+swfdec_displacement_map_filter_get_scaleY (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DisplacementMapFilter.scaleY (get)");
+}
+
+SWFDEC_AS_NATIVE (1111, 12, swfdec_displacement_map_filter_set_scaleY)
+void
+swfdec_displacement_map_filter_set_scaleY (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DisplacementMapFilter.scaleY (set)");
+}
+
+SWFDEC_AS_NATIVE (1111, 13, swfdec_displacement_map_filter_get_mode)
+void
+swfdec_displacement_map_filter_get_mode (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DisplacementMapFilter.mode (get)");
+}
+
+SWFDEC_AS_NATIVE (1111, 14, swfdec_displacement_map_filter_set_mode)
+void
+swfdec_displacement_map_filter_set_mode (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DisplacementMapFilter.mode (set)");
+}
+
+SWFDEC_AS_NATIVE (1111, 15, swfdec_displacement_map_filter_get_color)
+void
+swfdec_displacement_map_filter_get_color (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DisplacementMapFilter.color (get)");
+}
+
+SWFDEC_AS_NATIVE (1111, 16, swfdec_displacement_map_filter_set_color)
+void
+swfdec_displacement_map_filter_set_color (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DisplacementMapFilter.color (set)");
+}
+
+SWFDEC_AS_NATIVE (1111, 17, swfdec_displacement_map_filter_get_alpha)
+void
+swfdec_displacement_map_filter_get_alpha (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DisplacementMapFilter.alpha (get)");
+}
+
+SWFDEC_AS_NATIVE (1111, 18, swfdec_displacement_map_filter_set_alpha)
+void
+swfdec_displacement_map_filter_set_alpha (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DisplacementMapFilter.alpha (set)");
+}
+
+// constructor
+SWFDEC_AS_NATIVE (1111, 0, swfdec_displacement_map_filter_contruct)
+void
+swfdec_displacement_map_filter_contruct (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DisplacementMapFilter");
+}
diff --git a/swfdec/swfdec_draw.c b/swfdec/swfdec_draw.c
new file mode 100644
index 0000000..7da5374
--- /dev/null
+++ b/swfdec/swfdec_draw.c
@@ -0,0 +1,190 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+
+#include "swfdec_draw.h"
+#include "swfdec_color.h"
+#include "swfdec_debug.h"
+#include "swfdec_path.h"
+
+/*** DRAW ***/
+
+G_DEFINE_ABSTRACT_TYPE (SwfdecDraw, swfdec_draw, G_TYPE_OBJECT);
+
+static void
+swfdec_draw_do_morph (SwfdecDraw* dest, SwfdecDraw *source, guint ratio)
+{
+ swfdec_path_merge (&dest->path, &source->path, &source->end_path, ratio / 65535.);
+}
+
+static void
+swfdec_draw_dispose (GObject *object)
+{
+ SwfdecDraw *draw = SWFDEC_DRAW (object);
+
+ swfdec_path_reset (&draw->path);
+ swfdec_path_reset (&draw->end_path);
+
+ G_OBJECT_CLASS (swfdec_draw_parent_class)->dispose (object);
+}
+
+static void
+swfdec_draw_class_init (SwfdecDrawClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = swfdec_draw_dispose;
+
+ klass->morph = swfdec_draw_do_morph;
+}
+
+static void
+swfdec_draw_init (SwfdecDraw *draw)
+{
+ swfdec_path_init (&draw->path);
+ swfdec_path_init (&draw->end_path);
+}
+
+static gboolean
+swfdec_draw_can_morph (SwfdecDraw *draw)
+{
+ return draw->end_path.num_data > 0;
+}
+
+/**
+ * swfdec_draw_morph:
+ * @draw: a #SwfdecDraw
+ * @ratio: ratio of the morph from 0 to 65535
+ *
+ * Applies a morph to the given drawing operation. If the drawing operation
+ * can not be morphed, it is returned unchanged. Otherwise a new drawing
+ * operation is created.
+ *
+ * Returns: a new reference to a #SwfdecDraw corresponding to the given morph
+ * ratio
+ **/
+SwfdecDraw *
+swfdec_draw_morph (SwfdecDraw *draw, guint ratio)
+{
+ SwfdecDrawClass *klass;
+ SwfdecDraw *copy;
+
+ g_return_val_if_fail (SWFDEC_IS_DRAW (draw), NULL);
+ g_return_val_if_fail (ratio < 65536, NULL);
+
+ if (!swfdec_draw_can_morph (draw) || ratio == 0) {
+ /* not a morph */
+ g_object_ref (draw);
+ return draw;
+ }
+ klass = SWFDEC_DRAW_GET_CLASS (draw);
+ g_assert (klass->morph);
+ copy = g_object_new (G_OBJECT_CLASS_TYPE (klass), NULL);
+ klass->morph (copy, draw, ratio);
+ swfdec_draw_recompute (copy);
+ return copy;
+}
+
+/**
+ * swfdec_draw_paint:
+ * @draw: drawing operation to perform
+ * @cr: context to perform the operation on
+ * @trans: color transofrmation to apply
+ *
+ * Draws the given drawing operation on the given Cairo context.
+ **/
+void
+swfdec_draw_paint (SwfdecDraw *draw, cairo_t *cr, const SwfdecColorTransform *trans)
+{
+ SwfdecDrawClass *klass;
+
+ g_return_if_fail (SWFDEC_IS_DRAW (draw));
+ g_return_if_fail (draw->path.num_data > 0);
+ g_return_if_fail (cr != NULL);
+ g_return_if_fail (trans != NULL);
+
+ klass = SWFDEC_DRAW_GET_CLASS (draw);
+ g_assert (klass->paint);
+ klass->paint (draw, cr, trans);
+}
+
+static gpointer
+swfdec_draw_init_empty_surface (gpointer unused)
+{
+ return cairo_image_surface_create (CAIRO_FORMAT_A1, 1, 1);
+}
+
+/**
+ * swfdec_draw_contains:
+ * @draw: a #SwfdecDraw
+ * @x: x coordinate to check
+ * @y: y coordinate to check
+ *
+ * Checks if the given @x and @y coordinate is inside or outside the area drawn
+ * by the given drawing operation.
+ *
+ * Returns: %TRUE if the coordinates are inside the drawing operation.
+ **/
+gboolean
+swfdec_draw_contains (SwfdecDraw *draw, double x, double y)
+{
+ static GOnce empty_surface = G_ONCE_INIT;
+ SwfdecDrawClass *klass;
+ cairo_t *cr;
+ gboolean result;
+
+ g_return_val_if_fail (SWFDEC_IS_DRAW (draw), FALSE);
+
+ if (!swfdec_rect_contains (&draw->extents, x, y))
+ return FALSE;
+
+ g_once (&empty_surface, swfdec_draw_init_empty_surface, NULL);
+
+ klass = SWFDEC_DRAW_GET_CLASS (draw);
+ g_assert (klass->contains);
+ cr = cairo_create (empty_surface.retval);
+ result = klass->contains (draw, cr, x, y);
+ cairo_destroy (cr);
+ return result;
+}
+
+/**
+ * swfdec_draw_recompute:
+ * @draw: a #SwfdecDraw
+ *
+ * This function must be called after a call to swfdec_draw_append_path() but
+ * before using swfdec_draw_paint() again. It updates internal state and caches,
+ * in particular the extents of this drawing operation.
+ **/
+void
+swfdec_draw_recompute (SwfdecDraw *draw)
+{
+ SwfdecDrawClass *klass;
+
+ g_return_if_fail (SWFDEC_IS_DRAW (draw));
+
+ klass = SWFDEC_DRAW_GET_CLASS (draw);
+ g_assert (klass->compute_extents);
+ klass->compute_extents (draw);
+}
diff --git a/swfdec/swfdec_draw.h b/swfdec/swfdec_draw.h
new file mode 100644
index 0000000..e56a4ae
--- /dev/null
+++ b/swfdec/swfdec_draw.h
@@ -0,0 +1,85 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_DRAW_H_
+#define _SWFDEC_DRAW_H_
+
+#include <glib-object.h>
+#include <cairo.h>
+#include <libswfdec/swfdec_swf_decoder.h>
+#include <libswfdec/swfdec_color.h>
+
+G_BEGIN_DECLS
+
+//typedef struct _SwfdecDraw SwfdecDraw;
+typedef struct _SwfdecDrawClass SwfdecDrawClass;
+
+#define SWFDEC_TYPE_DRAW (swfdec_draw_get_type())
+#define SWFDEC_IS_DRAW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_DRAW))
+#define SWFDEC_IS_DRAW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_DRAW))
+#define SWFDEC_DRAW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_DRAW, SwfdecDraw))
+#define SWFDEC_DRAW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_DRAW, SwfdecDrawClass))
+#define SWFDEC_DRAW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_DRAW, SwfdecDrawClass))
+
+struct _SwfdecDraw
+{
+ GObject object;
+
+ /*< protected >*/
+ gboolean snap; /* this drawing op does pixel snapping on the device grid */
+ SwfdecRect extents; /* extents of path */
+ cairo_path_t path; /* path to draw with this operation - in twips */
+ cairo_path_t end_path; /* end path to draw with this operation if morph operation */
+};
+
+struct _SwfdecDrawClass
+{
+ GObjectClass object_class;
+
+ /* morph this drawing operation using the given ratio */
+ void (* morph) (SwfdecDraw * dest,
+ SwfdecDraw * source,
+ guint ratio);
+ /* paint the current drawing operation */
+ void (* paint) (SwfdecDraw * draw,
+ cairo_t * cr,
+ const SwfdecColorTransform * trans);
+ /* compute extents of this drawing op for the given movie */
+ void (* compute_extents) (SwfdecDraw * draw);
+ /* check if the given coordinate is part of the area rendered to */
+ gboolean (* contains) (SwfdecDraw * draw,
+ cairo_t * cr,
+ double x,
+ double y);
+};
+
+GType swfdec_draw_get_type (void);
+
+SwfdecDraw * swfdec_draw_morph (SwfdecDraw * draw,
+ guint ratio);
+void swfdec_draw_paint (SwfdecDraw * draw,
+ cairo_t * cr,
+ const SwfdecColorTransform * trans);
+gboolean swfdec_draw_contains (SwfdecDraw * draw,
+ double x,
+ double y);
+void swfdec_draw_recompute (SwfdecDraw * draw);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_drop_shadow_filter.c b/swfdec/swfdec_drop_shadow_filter.c
new file mode 100644
index 0000000..1ef97bf
--- /dev/null
+++ b/swfdec/swfdec_drop_shadow_filter.c
@@ -0,0 +1,233 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (1101, 1, swfdec_drop_shadow_filter_get_distance)
+void
+swfdec_drop_shadow_filter_get_distance (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.distance (get)");
+}
+
+SWFDEC_AS_NATIVE (1101, 2, swfdec_drop_shadow_filter_set_distance)
+void
+swfdec_drop_shadow_filter_set_distance (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.distance (set)");
+}
+
+SWFDEC_AS_NATIVE (1101, 3, swfdec_drop_shadow_filter_get_angle)
+void
+swfdec_drop_shadow_filter_get_angle (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.angle (get)");
+}
+
+SWFDEC_AS_NATIVE (1101, 4, swfdec_drop_shadow_filter_set_angle)
+void
+swfdec_drop_shadow_filter_set_angle (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.angle (set)");
+}
+
+SWFDEC_AS_NATIVE (1101, 5, swfdec_drop_shadow_filter_get_color)
+void
+swfdec_drop_shadow_filter_get_color (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.color (get)");
+}
+
+SWFDEC_AS_NATIVE (1101, 6, swfdec_drop_shadow_filter_set_color)
+void
+swfdec_drop_shadow_filter_set_color (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.color (set)");
+}
+
+SWFDEC_AS_NATIVE (1101, 7, swfdec_drop_shadow_filter_get_alpha)
+void
+swfdec_drop_shadow_filter_get_alpha (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.alpha (get)");
+}
+
+SWFDEC_AS_NATIVE (1101, 8, swfdec_drop_shadow_filter_set_alpha)
+void
+swfdec_drop_shadow_filter_set_alpha (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.alpha (set)");
+}
+
+SWFDEC_AS_NATIVE (1101, 9, swfdec_drop_shadow_filter_get_quality)
+void
+swfdec_drop_shadow_filter_get_quality (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.quality (get)");
+}
+
+SWFDEC_AS_NATIVE (1101, 10, swfdec_drop_shadow_filter_set_quality)
+void
+swfdec_drop_shadow_filter_set_quality (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.quality (set)");
+}
+
+SWFDEC_AS_NATIVE (1101, 11, swfdec_drop_shadow_filter_get_inner)
+void
+swfdec_drop_shadow_filter_get_inner (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.inner (get)");
+}
+
+SWFDEC_AS_NATIVE (1101, 12, swfdec_drop_shadow_filter_set_inner)
+void
+swfdec_drop_shadow_filter_set_inner (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.inner (set)");
+}
+
+SWFDEC_AS_NATIVE (1101, 13, swfdec_drop_shadow_filter_get_knockout)
+void
+swfdec_drop_shadow_filter_get_knockout (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.knockout (get)");
+}
+
+SWFDEC_AS_NATIVE (1101, 14, swfdec_drop_shadow_filter_set_knockout)
+void
+swfdec_drop_shadow_filter_set_knockout (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.knockout (set)");
+}
+
+SWFDEC_AS_NATIVE (1101, 15, swfdec_drop_shadow_filter_get_blurX)
+void
+swfdec_drop_shadow_filter_get_blurX (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.blurX (get)");
+}
+
+SWFDEC_AS_NATIVE (1101, 16, swfdec_drop_shadow_filter_set_blurX)
+void
+swfdec_drop_shadow_filter_set_blurX (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.blurX (set)");
+}
+
+SWFDEC_AS_NATIVE (1101, 17, swfdec_drop_shadow_filter_get_blurY)
+void
+swfdec_drop_shadow_filter_get_blurY (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.blurY (get)");
+}
+
+SWFDEC_AS_NATIVE (1101, 18, swfdec_drop_shadow_filter_set_blurY)
+void
+swfdec_drop_shadow_filter_set_blurY (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.blurY (set)");
+}
+
+SWFDEC_AS_NATIVE (1101, 19, swfdec_drop_shadow_filter_get_strength)
+void
+swfdec_drop_shadow_filter_get_strength (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.strength (get)");
+}
+
+SWFDEC_AS_NATIVE (1101, 20, swfdec_drop_shadow_filter_set_strength)
+void
+swfdec_drop_shadow_filter_set_strength (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.strength (set)");
+}
+
+SWFDEC_AS_NATIVE (1101, 21, swfdec_drop_shadow_filter_get_hideObject)
+void
+swfdec_drop_shadow_filter_get_hideObject (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.hideObject (get)");
+}
+
+SWFDEC_AS_NATIVE (1101, 22, swfdec_drop_shadow_filter_set_hideObject)
+void
+swfdec_drop_shadow_filter_set_hideObject (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter.hideObject (set)");
+}
+
+// constructor
+SWFDEC_AS_NATIVE (1101, 0, swfdec_drop_shadow_filter_construct)
+void
+swfdec_drop_shadow_filter_construct (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("DropShadowFilter");
+}
diff --git a/swfdec/swfdec_event.c b/swfdec/swfdec_event.c
new file mode 100644
index 0000000..6af665d
--- /dev/null
+++ b/swfdec/swfdec_event.c
@@ -0,0 +1,231 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include "swfdec_event.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_script_internal.h"
+
+typedef struct _SwfdecEvent SwfdecEvent;
+
+struct _SwfdecEvent {
+ guint conditions;
+ guint8 key;
+ SwfdecScript *script;
+};
+
+struct _SwfdecEventList {
+ SwfdecPlayer * player;
+ guint refcount;
+ GArray * events;
+};
+
+/**
+ * swfdec_event_type_get_name:
+ * @type: a #SwfdecEventType
+ *
+ * Gets the name for the event as a refcounted string or %NULL if the
+ * given clip event has no associated event.
+ *
+ * Returns: The name of the event or %NULL if none.
+ **/
+const char *
+swfdec_event_type_get_name (SwfdecEventType type)
+{
+ switch (type) {
+ case SWFDEC_EVENT_LOAD:
+ return SWFDEC_AS_STR_onLoad;
+ case SWFDEC_EVENT_ENTER:
+ return SWFDEC_AS_STR_onEnterFrame;
+ case SWFDEC_EVENT_UNLOAD:
+ return SWFDEC_AS_STR_onUnload;
+ case SWFDEC_EVENT_MOUSE_MOVE:
+ return SWFDEC_AS_STR_onMouseMove;
+ case SWFDEC_EVENT_MOUSE_DOWN:
+ return SWFDEC_AS_STR_onMouseDown;
+ case SWFDEC_EVENT_MOUSE_UP:
+ return SWFDEC_AS_STR_onMouseUp;
+ case SWFDEC_EVENT_KEY_UP:
+ return SWFDEC_AS_STR_onKeyUp;
+ case SWFDEC_EVENT_KEY_DOWN:
+ return SWFDEC_AS_STR_onKeyDown;
+ case SWFDEC_EVENT_DATA:
+ return SWFDEC_AS_STR_onData;
+ case SWFDEC_EVENT_INITIALIZE:
+ return NULL;
+ case SWFDEC_EVENT_PRESS:
+ return SWFDEC_AS_STR_onPress;
+ case SWFDEC_EVENT_RELEASE:
+ return SWFDEC_AS_STR_onRelease;
+ case SWFDEC_EVENT_RELEASE_OUTSIDE:
+ return SWFDEC_AS_STR_onReleaseOutside;
+ case SWFDEC_EVENT_ROLL_OVER:
+ return SWFDEC_AS_STR_onRollOver;
+ case SWFDEC_EVENT_ROLL_OUT:
+ return SWFDEC_AS_STR_onRollOut;
+ case SWFDEC_EVENT_DRAG_OVER:
+ return SWFDEC_AS_STR_onDragOver;
+ case SWFDEC_EVENT_DRAG_OUT:
+ return SWFDEC_AS_STR_onDragOut;
+ case SWFDEC_EVENT_KEY_PRESS:
+ return NULL;
+ case SWFDEC_EVENT_CONSTRUCT:
+ return SWFDEC_AS_STR_onConstruct;
+ default:
+ g_assert_not_reached ();
+ return NULL;
+ }
+}
+
+SwfdecEventList *
+swfdec_event_list_new (SwfdecPlayer *player)
+{
+ SwfdecEventList *list;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+
+ list = g_new0 (SwfdecEventList, 1);
+ list->player = player;
+ list->refcount = 1;
+ list->events = g_array_new (FALSE, FALSE, sizeof (SwfdecEvent));
+
+ return list;
+}
+
+/* FIXME: this is a bit nasty because of modifying */
+SwfdecEventList *
+swfdec_event_list_copy (SwfdecEventList *list)
+{
+ g_return_val_if_fail (list != NULL, NULL);
+ g_return_val_if_fail (list->refcount > 0, NULL);
+
+ list->refcount++;
+
+ return list;
+}
+
+void
+swfdec_event_list_free (SwfdecEventList *list)
+{
+ guint i;
+
+ g_return_if_fail (list != NULL);
+ g_return_if_fail (list->refcount > 0);
+
+ list->refcount--;
+ if (list->refcount > 0)
+ return;
+
+ for (i = 0; i < list->events->len; i++) {
+ SwfdecEvent *event = &g_array_index (list->events, SwfdecEvent, i);
+ swfdec_script_unref (event->script);
+ }
+ g_array_free (list->events, TRUE);
+ g_free (list);
+}
+
+#define N_CONDITIONS 19
+void
+swfdec_event_list_parse (SwfdecEventList *list, SwfdecBits *bits, int version,
+ guint conditions, guint8 key, const char *description)
+{
+ SwfdecEvent event;
+ char *name;
+ guint i;
+
+ g_return_if_fail (list != NULL);
+ g_return_if_fail (list->refcount == 1);
+ g_return_if_fail (description != NULL);
+
+ event.conditions = conditions;
+ event.key = key;
+ i = g_bit_nth_lsf (conditions, -1);
+ name = g_strconcat (description, ".", i < N_CONDITIONS ?
+ swfdec_event_type_get_name (i) : "???", NULL);
+ event.script = swfdec_script_new_from_bits (bits, name, version);
+ g_free (name);
+ if (event.script)
+ g_array_append_val (list->events, event);
+}
+
+void
+swfdec_event_list_execute (SwfdecEventList *list, SwfdecAsObject *object,
+ guint condition, guint8 key)
+{
+ guint i;
+
+ g_return_if_fail (list != NULL);
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+ g_return_if_fail (condition < N_CONDITIONS);
+
+ condition = (1 << condition);
+ /* FIXME: Do we execute all events if the event list is gone already? */
+ /* need to ref here because followup code could free all references to the list */
+ list = swfdec_event_list_copy (list);
+ for (i = 0; i < list->events->len; i++) {
+ SwfdecEvent *event = &g_array_index (list->events, SwfdecEvent, i);
+ if ((event->conditions & condition) &&
+ event->key == key) {
+ SWFDEC_LOG ("executing script for event %u on scriptable %p", condition, object);
+ swfdec_as_object_run (object, event->script);
+ }
+ }
+ swfdec_event_list_free (list);
+}
+
+gboolean
+swfdec_event_list_has_conditions (SwfdecEventList *list, SwfdecAsObject *object,
+ guint condition, guint8 key)
+{
+ guint i;
+
+ g_return_val_if_fail (list != NULL, FALSE);
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), FALSE);
+ g_return_val_if_fail (condition < N_CONDITIONS, FALSE);
+
+ condition = 1 << condition;
+ for (i = 0; i < list->events->len; i++) {
+ SwfdecEvent *event = &g_array_index (list->events, SwfdecEvent, i);
+ if ((event->conditions & condition) &&
+ event->key == key)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+#define MOUSE_EVENTS 0x1FC0
+gboolean
+swfdec_event_list_has_mouse_events (SwfdecEventList *list)
+{
+ guint i;
+
+ g_return_val_if_fail (list != NULL, FALSE);
+
+ for (i = 0; i < list->events->len; i++) {
+ SwfdecEvent *event = &g_array_index (list->events, SwfdecEvent, i);
+ if (event->conditions & MOUSE_EVENTS)
+ return TRUE;
+ }
+ return FALSE;
+}
diff --git a/swfdec/swfdec_event.h b/swfdec/swfdec_event.h
new file mode 100644
index 0000000..4b1ba40
--- /dev/null
+++ b/swfdec/swfdec_event.h
@@ -0,0 +1,77 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#include <libswfdec/swfdec_bits.h>
+#include <libswfdec/swfdec_as_types.h>
+#include <libswfdec/swfdec_player.h>
+#include <libswfdec/swfdec_types.h>
+
+#ifndef _SWFDEC_EVENT_H_
+#define _SWFDEC_EVENT_H_
+
+G_BEGIN_DECLS
+
+typedef enum _SwfdecEventType {
+ SWFDEC_EVENT_LOAD = 0,
+ SWFDEC_EVENT_ENTER = 1,
+ SWFDEC_EVENT_UNLOAD = 2,
+ SWFDEC_EVENT_MOUSE_MOVE = 3,
+ SWFDEC_EVENT_MOUSE_DOWN = 4,
+ SWFDEC_EVENT_MOUSE_UP = 5,
+ SWFDEC_EVENT_KEY_UP = 6,
+ SWFDEC_EVENT_KEY_DOWN = 7,
+ SWFDEC_EVENT_DATA = 8,
+ SWFDEC_EVENT_INITIALIZE = 9,
+ SWFDEC_EVENT_PRESS = 10,
+ SWFDEC_EVENT_RELEASE = 11,
+ SWFDEC_EVENT_RELEASE_OUTSIDE = 12,
+ SWFDEC_EVENT_ROLL_OVER = 13,
+ SWFDEC_EVENT_ROLL_OUT = 14,
+ SWFDEC_EVENT_DRAG_OVER = 15,
+ SWFDEC_EVENT_DRAG_OUT = 16,
+ SWFDEC_EVENT_KEY_PRESS = 17,
+ SWFDEC_EVENT_CONSTRUCT = 18
+} SwfdecEventType;
+
+const char * swfdec_event_type_get_name (SwfdecEventType type);
+
+SwfdecEventList * swfdec_event_list_new (SwfdecPlayer * player);
+SwfdecEventList * swfdec_event_list_copy (SwfdecEventList * list);
+void swfdec_event_list_free (SwfdecEventList * list);
+
+void swfdec_event_list_parse (SwfdecEventList * list,
+ SwfdecBits * bits,
+ int version,
+ guint conditions,
+ guint8 key,
+ const char * description);
+void swfdec_event_list_execute (SwfdecEventList * list,
+ SwfdecAsObject * object,
+ guint condition,
+ guint8 key);
+gboolean swfdec_event_list_has_conditions(SwfdecEventList * list,
+ SwfdecAsObject * object,
+ guint conditions,
+ guint8 key);
+gboolean swfdec_event_list_has_mouse_events(SwfdecEventList * list);
+
+
+G_END_DECLS
+
+#endif
diff --git a/swfdec/swfdec_external_interface.c b/swfdec/swfdec_external_interface.c
new file mode 100644
index 0000000..9574954
--- /dev/null
+++ b/swfdec/swfdec_external_interface.c
@@ -0,0 +1,228 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+
+#include "swfdec_as_internal.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_player_scripting.h"
+#include "swfdec_xml.h"
+
+SWFDEC_AS_NATIVE (14, 0, swfdec_external_interface__initJS)
+void
+swfdec_external_interface__initJS (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ /* FIXME: call an init vfunc here? */
+}
+
+SWFDEC_AS_NATIVE (14, 1, swfdec_external_interface__objectID)
+void
+swfdec_external_interface__objectID (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+ SwfdecPlayerScripting *scripting = player->priv->scripting;
+ SwfdecPlayerScriptingClass *klass;
+
+ if (scripting == NULL) {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ return;
+ }
+ klass = SWFDEC_PLAYER_SCRIPTING_GET_CLASS (scripting);
+ if (klass->js_get_id) {
+ char *s = klass->js_get_id (scripting, player);
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, s));
+ } else {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ }
+}
+
+SWFDEC_AS_NATIVE (14, 2, swfdec_external_interface__addCallback)
+void
+swfdec_external_interface__addCallback (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecPlayerPrivate *priv = SWFDEC_PLAYER (cx)->priv;
+ SwfdecAsObject *fun;
+ const char *name;
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
+ SWFDEC_AS_CHECK (0, NULL, "sO", &name, &fun);
+
+ /* FIXME: do we allow setting if scripting is unsupported? */
+ if (!SWFDEC_IS_AS_FUNCTION (fun))
+ return;
+
+ g_hash_table_insert (priv->scripting_callbacks, (gpointer) name, fun);
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, TRUE);
+}
+
+SWFDEC_AS_NATIVE (14, 3, swfdec_external_interface__evalJS)
+void
+swfdec_external_interface__evalJS (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+ SwfdecPlayerScripting *scripting = player->priv->scripting;
+ SwfdecPlayerScriptingClass *klass;
+ const char *s;
+
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ if (scripting == NULL || argc == 0)
+ return;
+ s = swfdec_as_value_to_string (cx, &argv[0]);
+ klass = SWFDEC_PLAYER_SCRIPTING_GET_CLASS (scripting);
+ if (klass->js_call) {
+ char *t = klass->js_call (scripting, player, s);
+ if (t != NULL) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, t));
+ }
+ }
+}
+
+SWFDEC_AS_NATIVE (14, 4, swfdec_external_interface__callOut)
+void
+swfdec_external_interface__callOut (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+ SwfdecPlayerScripting *scripting = player->priv->scripting;
+ SwfdecPlayerScriptingClass *klass;
+ const char *s;
+
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ if (scripting == NULL || argc == 0)
+ return;
+ s = swfdec_as_value_to_string (cx, &argv[0]);
+ klass = SWFDEC_PLAYER_SCRIPTING_GET_CLASS (scripting);
+ if (klass->xml_call) {
+ char *t = klass->xml_call (scripting, player, s);
+ if (t != NULL) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, t));
+ }
+ }
+}
+
+SWFDEC_AS_NATIVE (14, 5, swfdec_external_interface__escapeXML)
+void
+swfdec_external_interface__escapeXML (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ const char *s;
+
+ if (argc == 0 ||
+ (s = swfdec_as_value_to_string (cx, &argv[0])) == SWFDEC_AS_STR_EMPTY) {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ return;
+ }
+
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, swfdec_xml_escape (s)));
+}
+
+SWFDEC_AS_NATIVE (14, 6, swfdec_external_interface__unescapeXML)
+void
+swfdec_external_interface__unescapeXML (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ const char *s;
+
+ if (argc == 0 ||
+ (s = swfdec_as_value_to_string (cx, &argv[0])) == SWFDEC_AS_STR_EMPTY) {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ return;
+ }
+
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx,
+ swfdec_xml_unescape_len (cx, s, strlen (s), FALSE)));
+}
+
+SWFDEC_AS_NATIVE (14, 7, swfdec_external_interface__jsQuoteString)
+void
+swfdec_external_interface__jsQuoteString (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ const char *s;
+ GString *str;
+ size_t len;
+
+ if (argc == 0 ||
+ (s = swfdec_as_value_to_string (cx, &argv[0])) == SWFDEC_AS_STR_EMPTY) {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ return;
+ }
+
+ str = g_string_new ("");
+ do {
+ /* Yay, we don't escape backslashes! */
+ len = strcspn (s, "\n\r\"");
+ g_string_append_len (str, s, len);
+ s += len;
+ if (*s == '\0')
+ break;
+ g_string_append_c (str, '\\');
+ switch (*s) {
+ case '\n':
+ g_string_append_c (str, 'n');
+ break;
+ case '\r':
+ g_string_append_c (str, 'r');
+ break;
+ case '"':
+ g_string_append_c (str, '"');
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ };
+ s++;
+ } while (TRUE);
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, g_string_free (str, FALSE)));
+}
+
+SWFDEC_AS_NATIVE (14, 100, swfdec_external_interface_get_available)
+void
+swfdec_external_interface_get_available (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, SWFDEC_PLAYER (cx)->priv->scripting != NULL);
+}
+
+SWFDEC_AS_NATIVE (14, 101, swfdec_external_interface_set_available)
+void
+swfdec_external_interface_set_available (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ /* read-only property */
+}
diff --git a/swfdec/swfdec_file_loader.c b/swfdec/swfdec_file_loader.c
new file mode 100644
index 0000000..178601a
--- /dev/null
+++ b/swfdec/swfdec_file_loader.c
@@ -0,0 +1,98 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include "swfdec_loader_internal.h"
+#include "swfdec_buffer.h"
+#include "swfdec_debug.h"
+#include "swfdec_player_internal.h"
+
+/**
+ * SwfdecFileLoader:
+ *
+ * This is a #SwfdecLoader that can load content from files. This symbol is
+ * exported so you can subclass your own loaders from it and have automatic
+ * file access.
+ */
+
+G_DEFINE_TYPE (SwfdecFileLoader, swfdec_file_loader, SWFDEC_TYPE_LOADER)
+
+static void
+swfdec_file_loader_load (SwfdecLoader *loader, SwfdecPlayer *player,
+ const char *url_string, SwfdecLoaderRequest request, SwfdecBuffer *buffer)
+{
+ SwfdecStream *stream = SWFDEC_STREAM (loader);
+ GError *error = NULL;
+ char *real;
+ SwfdecURL *url;
+
+ if (swfdec_url_path_is_relative (url_string)) {
+ url = swfdec_url_new_relative (swfdec_player_get_base_url (player), url_string);
+ } else {
+ url = swfdec_url_new (url_string);
+ }
+ if (url == NULL) {
+ swfdec_stream_error (stream, "%s is an invalid URL", url_string);
+ return;
+ }
+ swfdec_loader_set_url (loader, swfdec_url_get_url (url));
+ if (!g_str_equal (swfdec_url_get_protocol (url), "file")) {
+ swfdec_stream_error (stream, "Don't know how to handle this protocol");
+ swfdec_url_free (url);
+ return;
+ }
+ if (swfdec_url_get_host (url)) {
+ swfdec_stream_error (stream, "filenames cannot have hostnames");
+ swfdec_url_free (url);
+ return;
+ }
+
+ /* FIXME: append query string here? */
+ real = g_strconcat ("/", swfdec_url_get_path (url), NULL);
+ buffer = swfdec_buffer_new_from_file (real, &error);
+ g_free (real);
+ if (buffer == NULL) {
+ swfdec_stream_error (stream, "%s", error->message);
+ g_error_free (error);
+ } else {
+ swfdec_loader_set_size (loader, buffer->length);
+ swfdec_stream_open (stream);
+ swfdec_stream_push (stream, buffer);
+ swfdec_stream_eof (stream);
+ }
+ swfdec_url_free (url);
+}
+
+static void
+swfdec_file_loader_class_init (SwfdecFileLoaderClass *klass)
+{
+ SwfdecLoaderClass *loader_class = SWFDEC_LOADER_CLASS (klass);
+
+ loader_class->load = swfdec_file_loader_load;
+}
+
+static void
+swfdec_file_loader_init (SwfdecFileLoader *loader)
+{
+}
+
diff --git a/swfdec/swfdec_file_loader.h b/swfdec/swfdec_file_loader.h
new file mode 100644
index 0000000..facd8c5
--- /dev/null
+++ b/swfdec/swfdec_file_loader.h
@@ -0,0 +1,52 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_FILE_LOADER_H_
+#define _SWFDEC_FILE_LOADER_H_
+
+#include <libswfdec/swfdec_loader.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecFileLoader SwfdecFileLoader;
+typedef struct _SwfdecFileLoaderClass SwfdecFileLoaderClass;
+
+#define SWFDEC_TYPE_FILE_LOADER (swfdec_file_loader_get_type())
+#define SWFDEC_IS_FILE_LOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_FILE_LOADER))
+#define SWFDEC_IS_FILE_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_FILE_LOADER))
+#define SWFDEC_FILE_LOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_FILE_LOADER, SwfdecFileLoader))
+#define SWFDEC_FILE_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_FILE_LOADER, SwfdecFileLoaderClass))
+#define SWFDEC_FILE_LOADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_FILE_LOADER, SwfdecFileLoaderClass))
+
+struct _SwfdecFileLoader
+{
+ SwfdecLoader loader;
+};
+
+struct _SwfdecFileLoaderClass
+{
+ SwfdecLoaderClass loader_class;
+};
+
+GType swfdec_file_loader_get_type (void);
+
+
+G_END_DECLS
+
+#endif /* _SWFDEC_FILE_LOADER_H_ */
diff --git a/swfdec/swfdec_file_reference.c b/swfdec/swfdec_file_reference.c
new file mode 100644
index 0000000..4bbcd32
--- /dev/null
+++ b/swfdec/swfdec_file_reference.c
@@ -0,0 +1,139 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (2204, 0, swfdec_file_reference_browse)
+void
+swfdec_file_reference_browse (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("FileReference.browse");
+}
+
+SWFDEC_AS_NATIVE (2204, 1, swfdec_file_reference_upload)
+void
+swfdec_file_reference_upload (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("FileReference.upload");
+}
+
+SWFDEC_AS_NATIVE (2204, 2, swfdec_file_reference_download)
+void
+swfdec_file_reference_download (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("FileReference.download");
+}
+
+SWFDEC_AS_NATIVE (2204, 3, swfdec_file_reference_cancel)
+void
+swfdec_file_reference_cancel (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("FileReference.cancel");
+}
+
+static void
+swfdec_file_reference_get_creationDate (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("FileReference.creationDate (get)");
+}
+
+static void
+swfdec_file_reference_get_creator (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("FileReference.creator (get)");
+}
+
+static void
+swfdec_file_reference_get_modificationDate (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("FileReference.modificationDate (get)");
+}
+
+static void
+swfdec_file_reference_get_name (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("FileReference.name (get)");
+}
+
+static void
+swfdec_file_reference_get_size (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("FileReference.size (get)");
+}
+
+static void
+swfdec_file_reference_get_type (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("FileReference.type (get)");
+}
+
+// Note: this is not actually the flash.net.FileReference function, but is
+// called from within that function
+SWFDEC_AS_NATIVE (2204, 200, swfdec_file_reference_construct)
+void
+swfdec_file_reference_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecAsObject *target;
+ SwfdecAsValue val;
+
+ SWFDEC_STUB ("FileReference");
+
+ if (argc > 0 && SWFDEC_AS_VALUE_IS_OBJECT (&argv[0])) {
+ target = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
+ } else {
+ target = object;
+ if (target == NULL)
+ return;
+ }
+
+ swfdec_as_object_add_native_variable (target, SWFDEC_AS_STR_creationDate,
+ swfdec_file_reference_get_creationDate, NULL);
+ swfdec_as_object_add_native_variable (target, SWFDEC_AS_STR_creator,
+ swfdec_file_reference_get_creator, NULL);
+ swfdec_as_object_add_native_variable (target, SWFDEC_AS_STR_modificationDate,
+ swfdec_file_reference_get_modificationDate, NULL);
+ swfdec_as_object_add_native_variable (target, SWFDEC_AS_STR_name,
+ swfdec_file_reference_get_name, NULL);
+ swfdec_as_object_add_native_variable (target, SWFDEC_AS_STR_size,
+ swfdec_file_reference_get_size, NULL);
+ swfdec_as_object_add_native_variable (target, SWFDEC_AS_STR_type,
+ swfdec_file_reference_get_type, NULL);
+
+ SWFDEC_AS_VALUE_SET_STRING (&val, SWFDEC_AS_STR_undefined);
+ swfdec_as_object_set_variable (target, SWFDEC_AS_STR_postData, &val);
+}
diff --git a/swfdec/swfdec_file_reference_list.c b/swfdec/swfdec_file_reference_list.c
new file mode 100644
index 0000000..52f4703
--- /dev/null
+++ b/swfdec/swfdec_file_reference_list.c
@@ -0,0 +1,33 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (2205, 0, swfdec_file_reference_list_browse)
+void
+swfdec_file_reference_list_browse (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("FileReferenceList.browse");
+}
diff --git a/swfdec/swfdec_filter.c b/swfdec/swfdec_filter.c
new file mode 100644
index 0000000..b51561b
--- /dev/null
+++ b/swfdec/swfdec_filter.c
@@ -0,0 +1,124 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_filter.h"
+#include "swfdec_debug.h"
+
+G_DEFINE_ABSTRACT_TYPE (SwfdecFilter, swfdec_filter, SWFDEC_TYPE_AS_OBJECT)
+
+static void
+swfdec_filter_class_init (SwfdecFilterClass *klass)
+{
+}
+
+static void
+swfdec_filter_init (SwfdecFilter *array)
+{
+}
+
+cairo_pattern_t *
+swfdec_filter_apply (SwfdecFilter *filter, cairo_pattern_t *pattern)
+{
+ SwfdecFilterClass *klass;
+ cairo_pattern_t *ret;
+
+ g_return_val_if_fail (SWFDEC_IS_FILTER (filter), NULL);
+ g_return_val_if_fail (pattern != NULL, NULL);
+
+ klass = SWFDEC_FILTER_GET_CLASS (filter);
+ g_assert (klass->apply);
+
+ ret = klass->apply (filter, pattern);
+ cairo_pattern_destroy (pattern);
+ return ret;
+}
+
+GSList *
+swfdec_filter_parse (SwfdecPlayer *player, SwfdecBits *bits)
+{
+ GSList *filters = NULL;
+ guint i, n_filters, filter_id;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (bits != NULL, NULL);
+
+ n_filters = swfdec_bits_get_u8 (bits);
+ SWFDEC_LOG (" filters: %u", n_filters);
+ for (i = 0; i < n_filters && swfdec_bits_left (bits); i++) {
+ filter_id = swfdec_bits_get_u8 (bits);
+ switch (filter_id) {
+ case 0:
+ SWFDEC_WARNING (" drop shadow");
+ swfdec_bits_skip_bytes (bits, 16);
+ break;
+ case 1:
+ SWFDEC_WARNING (" blur");
+ swfdec_bits_skip_bytes (bits, 9);
+ break;
+ case 2:
+ SWFDEC_WARNING (" glow");
+ swfdec_bits_skip_bytes (bits, 15);
+ break;
+ case 3:
+ SWFDEC_WARNING (" bevel");
+ swfdec_bits_skip_bytes (bits, 27);
+ break;
+ case 4:
+ {
+ guint n;
+ n = swfdec_bits_get_u8 (bits);
+ SWFDEC_WARNING (" gradient glow");
+ swfdec_bits_skip_bytes (bits, n * 5 + 19);
+ }
+ break;
+ case 5:
+ {
+ guint x, y;
+ x = swfdec_bits_get_u8 (bits);
+ y = swfdec_bits_get_u8 (bits);
+ SWFDEC_WARNING (" %u x %u convolution", x, y);
+ swfdec_bits_skip_bytes (bits, (x + y) * 4 + 13);
+ }
+ break;
+ case 6:
+ SWFDEC_WARNING (" color matrix");
+ swfdec_bits_skip_bytes (bits, 20 * 4);
+ break;
+ case 7:
+ {
+ guint n;
+ n = swfdec_bits_get_u8 (bits);
+ SWFDEC_WARNING (" gradient bevel");
+ swfdec_bits_skip_bytes (bits, n * 5 + 19);
+ }
+ break;
+ default:
+ SWFDEC_ERROR ("unknown filter id %u", filter_id);
+ break;
+ }
+ }
+
+ filters = g_slist_reverse (filters);
+ return filters;
+}
+
diff --git a/swfdec/swfdec_filter.h b/swfdec/swfdec_filter.h
new file mode 100644
index 0000000..2f39f15
--- /dev/null
+++ b/swfdec/swfdec_filter.h
@@ -0,0 +1,60 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_FILTER_H_
+#define _SWFDEC_FILTER_H_
+
+#include <libswfdec/swfdec.h>
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_bits.h>
+#include <libswfdec/swfdec_types.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecFilterClass SwfdecFilterClass;
+
+#define SWFDEC_TYPE_FILTER (swfdec_filter_get_type())
+#define SWFDEC_IS_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_FILTER))
+#define SWFDEC_IS_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_FILTER))
+#define SWFDEC_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_FILTER, SwfdecFilter))
+#define SWFDEC_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_FILTER, SwfdecFilterClass))
+#define SWFDEC_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_FILTER, SwfdecFilterClass))
+
+struct _SwfdecFilter {
+ SwfdecAsObject object;
+};
+
+struct _SwfdecFilterClass {
+ SwfdecAsObjectClass object_class;
+
+ SwfdecFilter * (* clone) (SwfdecFilter * filter);
+ cairo_pattern_t * (* apply) (SwfdecFilter * filter,
+ cairo_pattern_t * pattern);
+};
+
+GType swfdec_filter_get_type (void);
+
+cairo_pattern_t * swfdec_filter_apply (SwfdecFilter * filter,
+ cairo_pattern_t * pattern);
+GSList * swfdec_filter_parse (SwfdecPlayer * player,
+ SwfdecBits * bits);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_filter_as.c b/swfdec/swfdec_filter_as.c
new file mode 100644
index 0000000..0f00211
--- /dev/null
+++ b/swfdec/swfdec_filter_as.c
@@ -0,0 +1,47 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_filter.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (1112, 1, swfdec_filter_clone)
+void
+swfdec_filter_clone (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ SwfdecFilter *filter;
+ SwfdecFilterClass *klass;
+
+ if (!SWFDEC_IS_FILTER (object))
+ return;
+
+ filter = SWFDEC_FILTER (object);
+ klass = SWFDEC_FILTER_GET_CLASS (filter);
+ g_assert (klass->clone);
+
+ filter = klass->clone (filter);
+ if (filter)
+ SWFDEC_AS_VALUE_SET_OBJECT (retval, SWFDEC_AS_OBJECT (filter));
+}
+
diff --git a/swfdec/swfdec_flv_decoder.c b/swfdec/swfdec_flv_decoder.c
new file mode 100644
index 0000000..52f14e2
--- /dev/null
+++ b/swfdec/swfdec_flv_decoder.c
@@ -0,0 +1,595 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_flv_decoder.h"
+#include "swfdec_audio_internal.h"
+#include "swfdec_bits.h"
+#include "swfdec_debug.h"
+
+enum {
+ SWFDEC_STATE_HEADER, /* need to parse header */
+ SWFDEC_STATE_LAST_TAG, /* read size of last tag */
+ SWFDEC_STATE_TAG, /* read next tag */
+ SWFDEC_STATE_EOF /* file is complete */
+};
+
+typedef struct _SwfdecFlvVideoTag SwfdecFlvVideoTag;
+typedef struct _SwfdecFlvAudioTag SwfdecFlvAudioTag;
+typedef struct _SwfdecFlvDataTag SwfdecFlvDataTag;
+
+struct _SwfdecFlvVideoTag {
+ guint timestamp; /* milliseconds */
+ guint format; /* format in use */
+ int frame_type; /* 0: undefined, 1: keyframe, 2: iframe, 3: H263 disposable iframe */
+ SwfdecBuffer * buffer; /* buffer for this data */
+};
+
+struct _SwfdecFlvAudioTag {
+ guint timestamp; /* milliseconds */
+ guint format; /* format in use */
+ SwfdecAudioFormat original_format; /* channel/rate information */
+ SwfdecBuffer * buffer; /* buffer for this data */
+};
+
+struct _SwfdecFlvDataTag {
+ guint timestamp; /* milliseconds */
+ SwfdecBuffer * buffer; /* buffer containing raw AMF data */
+};
+
+G_DEFINE_TYPE (SwfdecFlvDecoder, swfdec_flv_decoder, SWFDEC_TYPE_DECODER)
+
+static void
+swfdec_flv_decoder_dispose (GObject *object)
+{
+ SwfdecFlvDecoder *flv = SWFDEC_FLV_DECODER (object);
+ guint i;
+
+ if (flv->audio) {
+ for (i = 0; i < flv->audio->len; i++) {
+ SwfdecFlvAudioTag *tag = &g_array_index (flv->audio, SwfdecFlvAudioTag, i);
+ swfdec_buffer_unref (tag->buffer);
+ }
+ g_array_free (flv->audio, TRUE);
+ flv->audio = NULL;
+ }
+ if (flv->video) {
+ for (i = 0; i < flv->video->len; i++) {
+ SwfdecFlvVideoTag *tag = &g_array_index (flv->video, SwfdecFlvVideoTag, i);
+ swfdec_buffer_unref (tag->buffer);
+ }
+ g_array_free (flv->video, TRUE);
+ flv->video = NULL;
+ }
+ if (flv->data) {
+ for (i = 0; i < flv->data->len; i++) {
+ SwfdecFlvDataTag *tag = &g_array_index (flv->data, SwfdecFlvDataTag, i);
+ swfdec_buffer_unref (tag->buffer);
+ }
+ g_array_free (flv->data, TRUE);
+ flv->data = NULL;
+ }
+ swfdec_buffer_queue_unref (flv->queue);
+ flv->queue = NULL;
+
+ G_OBJECT_CLASS (swfdec_flv_decoder_parent_class)->dispose (object);
+}
+
+static SwfdecStatus
+swfdec_flv_decoder_parse_header (SwfdecFlvDecoder *flv)
+{
+ SwfdecBuffer *buffer;
+ SwfdecBits bits;
+ guint version, header_length;
+ gboolean has_audio, has_video;
+
+ buffer = swfdec_buffer_queue_peek (flv->queue, 9);
+ if (buffer == NULL)
+ return SWFDEC_STATUS_NEEDBITS;
+
+ swfdec_bits_init (&bits, buffer);
+ /* Check if we're really an FLV file */
+ if (swfdec_bits_get_u8 (&bits) != 'F' ||
+ swfdec_bits_get_u8 (&bits) != 'L' ||
+ swfdec_bits_get_u8 (&bits) != 'V') {
+ swfdec_buffer_unref (buffer);
+ return SWFDEC_STATUS_ERROR;
+ }
+
+ version = swfdec_bits_get_u8 (&bits);
+ swfdec_bits_getbits (&bits, 5);
+ has_audio = swfdec_bits_getbit (&bits);
+ swfdec_bits_getbit (&bits);
+ has_video = swfdec_bits_getbit (&bits);
+ header_length = swfdec_bits_get_bu32 (&bits);
+ swfdec_buffer_unref (buffer);
+ if (header_length < 9) {
+ SWFDEC_ERROR ("invalid header length %u, must be 9 or greater", header_length);
+ /* FIXME: treat as error or ignore? */
+ return SWFDEC_STATUS_ERROR;
+ }
+ buffer = swfdec_buffer_queue_pull (flv->queue, header_length);
+ if (buffer == NULL)
+ return SWFDEC_STATUS_NEEDBITS;
+ swfdec_buffer_unref (buffer);
+ SWFDEC_LOG ("parsing flv stream");
+ SWFDEC_LOG (" version %u", version);
+ SWFDEC_LOG (" with%s audio", has_audio ? "" : "out");
+ SWFDEC_LOG (" with%s video", has_video ? "" : "out");
+ flv->version = version;
+ if (has_audio) {
+ flv->audio = g_array_new (FALSE, FALSE, sizeof (SwfdecFlvAudioTag));
+ }
+ if (has_video) {
+ flv->video = g_array_new (FALSE, FALSE, sizeof (SwfdecFlvVideoTag));
+ }
+ flv->state = SWFDEC_STATE_LAST_TAG;
+
+ return SWFDEC_STATUS_OK;
+}
+
+static SwfdecStatus
+swfdec_flv_decoder_parse_last_tag (SwfdecFlvDecoder *flv)
+{
+ SwfdecBuffer *buffer;
+ SwfdecBits bits;
+ guint last_tag;
+
+ buffer = swfdec_buffer_queue_pull (flv->queue, 4);
+ if (buffer == NULL)
+ return SWFDEC_STATUS_NEEDBITS;
+
+ swfdec_bits_init (&bits, buffer);
+ last_tag = swfdec_bits_get_bu32 (&bits);
+ SWFDEC_LOG ("last tag was %u bytes", last_tag);
+ swfdec_buffer_unref (buffer);
+ flv->state = SWFDEC_STATE_TAG;
+ return SWFDEC_STATUS_OK;
+}
+
+static guint
+swfdec_flv_decoder_find_video (SwfdecFlvDecoder *flv, guint timestamp)
+{
+ guint min, max;
+
+ g_assert (flv->video);
+
+ min = 0;
+ max = flv->video->len;
+ while (max - min > 1) {
+ guint cur = (max + min) / 2;
+ SwfdecFlvVideoTag *tag = &g_array_index (flv->video, SwfdecFlvVideoTag, cur);
+ if (tag->timestamp > timestamp) {
+ max = cur;
+ } else {
+ min = cur;
+ }
+ }
+ return min;
+}
+
+static guint
+swfdec_flv_decoder_find_audio (SwfdecFlvDecoder *flv, guint timestamp)
+{
+ guint min, max;
+
+ g_assert (flv->audio);
+
+ min = 0;
+ max = flv->audio->len;
+ while (max - min > 1) {
+ guint cur = (max + min) / 2;
+ SwfdecFlvAudioTag *tag = &g_array_index (flv->audio, SwfdecFlvAudioTag, cur);
+ if (tag->timestamp > timestamp) {
+ max = cur;
+ } else {
+ min = cur;
+ }
+ }
+ return min;
+}
+
+static guint
+swfdec_flv_decoder_find_data (SwfdecFlvDecoder *flv, guint timestamp)
+{
+ guint min, max;
+
+ g_assert (flv->data);
+
+ min = 0;
+ max = flv->data->len;
+ while (max - min > 1) {
+ guint cur = (max + min) / 2;
+ SwfdecFlvDataTag *tag = &g_array_index (flv->data, SwfdecFlvDataTag, cur);
+ if (tag->timestamp > timestamp) {
+ max = cur;
+ } else {
+ min = cur;
+ }
+ }
+ return min;
+}
+
+static SwfdecStatus
+swfdec_flv_decoder_parse_video_tag (SwfdecFlvDecoder *flv, SwfdecBits *bits, guint timestamp)
+{
+ SwfdecFlvVideoTag tag;
+
+ if (flv->video == NULL) {
+ SWFDEC_INFO ("video tags even though header didn't decalre them. Initializing...");
+ flv->video = g_array_new (FALSE, FALSE, sizeof (SwfdecFlvVideoTag));
+ return SWFDEC_STATUS_OK;
+ }
+
+ tag.timestamp = timestamp;
+ tag.frame_type = swfdec_bits_getbits (bits, 4);
+ tag.format = swfdec_bits_getbits (bits, 4);
+ tag.buffer = swfdec_bits_get_buffer (bits, -1);
+ SWFDEC_LOG (" format: %u", tag.format);
+ SWFDEC_LOG (" frame type: %u", tag.frame_type);
+ if (tag.buffer == NULL) {
+ SWFDEC_WARNING ("no buffer, ignoring");
+ return SWFDEC_STATUS_OK;
+ }
+ if (flv->video->len == 0) {
+ g_array_append_val (flv->video, tag);
+ } else if (g_array_index (flv->video, SwfdecFlvVideoTag,
+ flv->video->len - 1).timestamp < tag.timestamp) {
+ g_array_append_val (flv->video, tag);
+ } else {
+ guint idx;
+ SWFDEC_WARNING ("timestamps of video buffers not increasing (last was %u, now %u)",
+ g_array_index (flv->video, SwfdecFlvVideoTag, flv->video->len - 1).timestamp,
+ tag.timestamp);
+ idx = swfdec_flv_decoder_find_video (flv, tag.timestamp);
+ g_array_insert_val (flv->video, idx, tag);
+ }
+ return SWFDEC_STATUS_IMAGE;
+}
+
+static void
+swfdec_flv_decoder_parse_audio_tag (SwfdecFlvDecoder *flv, SwfdecBits *bits, guint timestamp)
+{
+ SwfdecFlvAudioTag tag;
+
+ if (flv->audio == NULL) {
+ SWFDEC_INFO ("audio tags even though header didn't decalre them. Initializing...");
+ flv->audio = g_array_new (FALSE, FALSE, sizeof (SwfdecFlvAudioTag));
+ return;
+ }
+
+ tag.timestamp = timestamp;
+ tag.format = swfdec_bits_getbits (bits, 4);
+ tag.original_format = swfdec_audio_format_parse (bits);
+ tag.buffer = swfdec_bits_get_buffer (bits, -1);
+ SWFDEC_LOG (" codec: %u", (guint) tag.format);
+ SWFDEC_LOG (" format: %s", swfdec_audio_format_to_string (tag.original_format));
+ if (tag.buffer == NULL) {
+ SWFDEC_WARNING ("no buffer, ignoring");
+ return;
+ }
+ if (flv->audio->len == 0) {
+ g_array_append_val (flv->audio, tag);
+ } else if (g_array_index (flv->audio, SwfdecFlvAudioTag,
+ flv->audio->len - 1).timestamp < tag.timestamp) {
+ g_array_append_val (flv->audio, tag);
+ } else {
+ guint idx;
+ SWFDEC_WARNING ("timestamps of audio buffers not increasing (last was %u, now %u)",
+ g_array_index (flv->audio, SwfdecFlvAudioTag, flv->audio->len - 1).timestamp,
+ tag.timestamp);
+ idx = swfdec_flv_decoder_find_audio (flv, tag.timestamp);
+ g_array_insert_val (flv->audio, idx, tag);
+ }
+}
+
+static void
+swfdec_flv_decoder_parse_data_tag (SwfdecFlvDecoder *flv, SwfdecBits *bits, guint timestamp)
+{
+ SwfdecFlvDataTag tag;
+
+ if (flv->data == NULL) {
+ flv->data = g_array_new (FALSE, FALSE, sizeof (SwfdecFlvDataTag));
+ }
+
+ tag.timestamp = timestamp;
+ tag.buffer = swfdec_bits_get_buffer (bits, -1);
+ if (tag.buffer == NULL) {
+ SWFDEC_WARNING ("no buffer, ignoring");
+ return;
+ }
+ if (flv->data->len == 0) {
+ g_array_append_val (flv->data, tag);
+ } else if (g_array_index (flv->data, SwfdecFlvDataTag,
+ flv->data->len - 1).timestamp < tag.timestamp) {
+ g_array_append_val (flv->data, tag);
+ } else {
+ guint idx;
+ SWFDEC_WARNING ("timestamps of data buffers not increasing (last was %u, now %u)",
+ g_array_index (flv->data, SwfdecFlvDataTag, flv->data->len - 1).timestamp,
+ tag.timestamp);
+ idx = swfdec_flv_decoder_find_data (flv, tag.timestamp);
+ g_array_insert_val (flv->data, idx, tag);
+ }
+}
+
+static SwfdecStatus
+swfdec_flv_decoder_parse_tag (SwfdecFlvDecoder *flv)
+{
+ SwfdecBuffer *buffer;
+ SwfdecBits bits;
+ guint size, type, timestamp;
+ SwfdecStatus ret = SWFDEC_STATUS_OK;
+
+ buffer = swfdec_buffer_queue_peek (flv->queue, 4);
+ if (buffer == NULL)
+ return SWFDEC_STATUS_NEEDBITS;
+ swfdec_bits_init (&bits, buffer);
+ swfdec_bits_get_u8 (&bits);
+ size = swfdec_bits_get_bu24 (&bits);
+ swfdec_buffer_unref (buffer);
+ buffer = swfdec_buffer_queue_pull (flv->queue, 11 + size);
+ if (buffer == NULL)
+ return SWFDEC_STATUS_NEEDBITS;
+ swfdec_bits_init (&bits, buffer);
+ type = swfdec_bits_get_u8 (&bits);
+ /* I think I'm paranoid and complicated. I think I'm paranoid, manipulated */
+ if (size != swfdec_bits_get_bu24 (&bits)) {
+ g_assert_not_reached ();
+ }
+ timestamp = swfdec_bits_get_bu24 (&bits);
+ swfdec_bits_get_bu32 (&bits);
+ SWFDEC_LOG ("new tag");
+ SWFDEC_LOG (" type %u", type);
+ SWFDEC_LOG (" size %u", size);
+ SWFDEC_LOG (" timestamp %u", timestamp);
+ switch (type) {
+ case 8:
+ swfdec_flv_decoder_parse_audio_tag (flv, &bits, timestamp);
+ break;
+ case 9:
+ ret = swfdec_flv_decoder_parse_video_tag (flv, &bits, timestamp);
+ break;
+ case 18:
+ swfdec_flv_decoder_parse_data_tag (flv, &bits, timestamp);
+ break;
+ default:
+ SWFDEC_WARNING ("unknown tag (type %u)", type);
+ break;
+ }
+ swfdec_buffer_unref (buffer);
+ flv->state = SWFDEC_STATE_LAST_TAG;
+ return ret;
+}
+
+static SwfdecStatus
+swfdec_flv_decoder_parse (SwfdecDecoder *dec, SwfdecBuffer *buffer)
+{
+ SwfdecFlvDecoder *flv = SWFDEC_FLV_DECODER (dec);
+ SwfdecStatus status = 0;
+
+ swfdec_buffer_queue_push (flv->queue, buffer);
+
+ do {
+ switch (flv->state) {
+ case SWFDEC_STATE_HEADER:
+ status |= swfdec_flv_decoder_parse_header (flv);
+ break;
+ case SWFDEC_STATE_LAST_TAG:
+ status |= swfdec_flv_decoder_parse_last_tag (flv);
+ break;
+ case SWFDEC_STATE_TAG:
+ status |= swfdec_flv_decoder_parse_tag (flv);
+ break;
+ case SWFDEC_STATE_EOF:
+ status |= SWFDEC_STATUS_EOF;
+ break;
+ default:
+ g_assert_not_reached ();
+ status |= SWFDEC_STATUS_ERROR;
+ break;
+ }
+ } while ((status & (SWFDEC_STATUS_EOF | SWFDEC_STATUS_NEEDBITS | SWFDEC_STATUS_ERROR)) == 0);
+
+ return status;
+}
+
+static SwfdecStatus
+swfdec_flv_decoder_eof (SwfdecDecoder *dec)
+{
+ SwfdecFlvDecoder *flv = SWFDEC_FLV_DECODER (dec);
+
+ flv->state = SWFDEC_STATE_EOF;
+
+ return 0;
+}
+
+static void
+swfdec_flv_decoder_class_init (SwfdecFlvDecoderClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ SwfdecDecoderClass *decoder_class = SWFDEC_DECODER_CLASS (class);
+
+ object_class->dispose = swfdec_flv_decoder_dispose;
+
+ decoder_class->parse = swfdec_flv_decoder_parse;
+ decoder_class->eof = swfdec_flv_decoder_eof;
+}
+
+static void
+swfdec_flv_decoder_init (SwfdecFlvDecoder *flv)
+{
+ flv->state = SWFDEC_STATE_HEADER;
+ flv->queue = swfdec_buffer_queue_new ();
+}
+
+SwfdecBuffer *
+swfdec_flv_decoder_get_video (SwfdecFlvDecoder *flv, guint timestamp,
+ gboolean keyframe, guint *format, guint *real_timestamp, guint *next_timestamp)
+{
+ guint id, offset;
+ SwfdecFlvVideoTag *tag;
+
+ g_return_val_if_fail (SWFDEC_IS_FLV_DECODER (flv), NULL);
+ g_return_val_if_fail (flv->video != NULL, NULL);
+
+ if (flv->video->len == 0) {
+ if (next_timestamp)
+ *next_timestamp = 0;
+ if (real_timestamp)
+ *real_timestamp = 0;
+ if (format)
+ *format = SWFDEC_VIDEO_CODEC_UNDEFINED;
+ return NULL;
+ }
+ offset = g_array_index (flv->video, SwfdecFlvVideoTag, 0).timestamp;
+ timestamp += offset;
+ id = swfdec_flv_decoder_find_video (flv, timestamp);
+ tag = &g_array_index (flv->video, SwfdecFlvVideoTag, id);
+ if (keyframe) {
+ while (id > 0 && tag->frame_type != 1) {
+ id--;
+ tag--;
+ }
+ }
+ if (next_timestamp) {
+ if (id + 1 >= flv->video->len)
+ *next_timestamp = 0;
+ else
+ *next_timestamp = g_array_index (flv->video, SwfdecFlvVideoTag, id + 1).timestamp - offset;
+ }
+ if (real_timestamp)
+ *real_timestamp = tag->timestamp - offset;
+ if (format)
+ *format = tag->format;
+ return tag->buffer;
+}
+
+gboolean
+swfdec_flv_decoder_get_video_info (SwfdecFlvDecoder *flv,
+ guint *first_timestamp, guint *last_timestamp)
+{
+ g_return_val_if_fail (SWFDEC_IS_FLV_DECODER (flv), FALSE);
+
+ if (flv->video == NULL)
+ return FALSE;
+
+ if (flv->video->len == 0) {
+ if (first_timestamp)
+ *first_timestamp = 0;
+ if (last_timestamp)
+ *last_timestamp = 0;
+ return TRUE;
+ }
+ if (first_timestamp)
+ *first_timestamp = g_array_index (flv->video, SwfdecFlvVideoTag, 0).timestamp;
+ if (last_timestamp)
+ *last_timestamp = g_array_index (flv->video, SwfdecFlvVideoTag, flv->video->len - 1).timestamp;
+ return TRUE;
+}
+
+SwfdecBuffer *
+swfdec_flv_decoder_get_audio (SwfdecFlvDecoder *flv, guint timestamp,
+ guint *codec, SwfdecAudioFormat *format,
+ guint *real_timestamp, guint *next_timestamp)
+{
+ guint id, offset;
+ SwfdecFlvAudioTag *tag;
+
+ g_return_val_if_fail (SWFDEC_IS_FLV_DECODER (flv), NULL);
+ g_return_val_if_fail (flv->audio != NULL, NULL);
+
+ if (flv->audio->len == 0) {
+ if (next_timestamp)
+ *next_timestamp = 0;
+ if (real_timestamp)
+ *real_timestamp = 0;
+ if (codec)
+ *codec = SWFDEC_AUDIO_CODEC_UNDEFINED;
+ if (format)
+ *format = swfdec_audio_format_new (44100, 2, TRUE);
+ return NULL;
+ }
+ offset = g_array_index (flv->audio, SwfdecFlvAudioTag, 0).timestamp;
+ timestamp += offset;
+ id = swfdec_flv_decoder_find_audio (flv, timestamp);
+ if (next_timestamp) {
+ if (id + 1 >= flv->audio->len)
+ *next_timestamp = 0;
+ else
+ *next_timestamp = g_array_index (flv->audio, SwfdecFlvAudioTag, id + 1).timestamp - offset;
+ }
+ tag = &g_array_index (flv->audio, SwfdecFlvAudioTag, id);
+ if (real_timestamp)
+ *real_timestamp = tag->timestamp - offset;
+ if (codec)
+ *codec = tag->format;
+ if (format)
+ *format = tag->original_format;
+ return tag->buffer;
+}
+
+/**
+ * swfdec_flv_decoder_get_data:
+ * @flv: a #SwfdecFlvDecoder
+ * @timestamp: timestamp to look for
+ * @real_timestamp: the timestamp of the returned buffer, if any
+ *
+ * Finds the next data event with a timestamp of at least @timestamp. If one
+ * exists, it is returned, and its real timestamp put into @real_timestamp.
+ * Otherwise, %NULL is returned.
+ *
+ * Returns: a #SwfdecBuffer containing the next data or NULL if none
+ **/
+SwfdecBuffer *
+swfdec_flv_decoder_get_data (SwfdecFlvDecoder *flv, guint timestamp, guint *real_timestamp)
+{
+ guint id;
+ SwfdecFlvDataTag *tag;
+
+ g_return_val_if_fail (SWFDEC_IS_FLV_DECODER (flv), NULL);
+
+ if (flv->data == NULL ||
+ flv->data->len == 0)
+ return NULL;
+
+ id = swfdec_flv_decoder_find_data (flv, timestamp);
+ tag = &g_array_index (flv->data, SwfdecFlvDataTag, id);
+ while (tag->timestamp < timestamp) {
+ id++;
+ if (id >= flv->data->len)
+ return NULL;
+ tag++;
+ }
+ if (real_timestamp)
+ *real_timestamp = tag->timestamp;
+ return tag->buffer;
+}
+
+gboolean
+swfdec_flv_decoder_is_eof (SwfdecFlvDecoder *flv)
+{
+ g_return_val_if_fail (SWFDEC_IS_FLV_DECODER (flv), TRUE);
+
+ return flv->state == SWFDEC_STATE_EOF;
+}
+
diff --git a/swfdec/swfdec_flv_decoder.h b/swfdec/swfdec_flv_decoder.h
new file mode 100644
index 0000000..635fea4
--- /dev/null
+++ b/swfdec/swfdec_flv_decoder.h
@@ -0,0 +1,83 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SWFDEC_FLV_DECODER_H__
+#define __SWFDEC_FLV_DECODER_H__
+
+#include <libswfdec/swfdec_codec_audio.h>
+#include <libswfdec/swfdec_codec_video.h>
+#include <libswfdec/swfdec_decoder.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _SwfdecFlvDecoder SwfdecFlvDecoder;
+typedef struct _SwfdecFlvDecoderClass SwfdecFlvDecoderClass;
+
+#define SWFDEC_TYPE_FLV_DECODER (swfdec_flv_decoder_get_type())
+#define SWFDEC_IS_FLV_DECODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_FLV_DECODER))
+#define SWFDEC_IS_FLV_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_FLV_DECODER))
+#define SWFDEC_FLV_DECODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_FLV_DECODER, SwfdecFlvDecoder))
+#define SWFDEC_FLV_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_FLV_DECODER, SwfdecFlvDecoderClass))
+#define SWFDEC_FLV_DECODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_FLV_DECODER, SwfdecFlvDecoderClass))
+
+struct _SwfdecFlvDecoder
+{
+ SwfdecDecoder decoder;
+
+ int version; /* only version 1 is known for now */
+ int state; /* parsing state we're in */
+ GArray * audio; /* audio tags */
+ GArray * video; /* video tags */
+ GArray * data; /* data tags (if any) */
+ SwfdecBufferQueue * queue; /* queue for parsing */
+};
+
+struct _SwfdecFlvDecoderClass {
+ SwfdecDecoderClass decoder_class;
+};
+
+GType swfdec_flv_decoder_get_type (void);
+
+gboolean swfdec_flv_decoder_is_eof (SwfdecFlvDecoder * flv);
+
+SwfdecBuffer * swfdec_flv_decoder_get_video (SwfdecFlvDecoder * flv,
+ guint timestamp,
+ gboolean keyframe,
+ guint * format,
+ guint * real_timestamp,
+ guint * next_timestamp);
+gboolean swfdec_flv_decoder_get_video_info (SwfdecFlvDecoder * flv,
+ guint * first_timestamp,
+ guint * last_timestamp);
+SwfdecBuffer * swfdec_flv_decoder_get_audio (SwfdecFlvDecoder * flv,
+ guint timestamp,
+ guint * codec,
+ SwfdecAudioFormat * format,
+ guint * real_timestamp,
+ guint * next_timestamp);
+SwfdecBuffer * swfdec_flv_decoder_get_data (SwfdecFlvDecoder * flv,
+ guint timestamp,
+ guint * real_timestamp);
+
+SwfdecMovie * swfdec_flv_decoder_add_movie (SwfdecFlvDecoder * flv,
+ SwfdecMovie * parent);
+G_END_DECLS
+
+#endif
diff --git a/swfdec/swfdec_font.c b/swfdec/swfdec_font.c
new file mode 100644
index 0000000..bce8792
--- /dev/null
+++ b/swfdec/swfdec_font.c
@@ -0,0 +1,457 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_font.h"
+#include "swfdec_bits.h"
+#include "swfdec_debug.h"
+#include "swfdec_shape_parser.h"
+#include "swfdec_swf_decoder.h"
+#include "swfdec_tag.h"
+
+G_DEFINE_TYPE (SwfdecFont, swfdec_font, SWFDEC_TYPE_CHARACTER)
+
+static void
+swfdec_font_dispose (GObject *object)
+{
+ SwfdecFont * font = SWFDEC_FONT (object);
+ guint i;
+
+ if (font->glyphs) {
+ for (i = 0; i < font->glyphs->len; i++) {
+ SwfdecDraw *draw = g_array_index (font->glyphs, SwfdecFontEntry, i).draw;
+ if (draw)
+ g_object_unref (draw);
+ }
+ g_array_free (font->glyphs, TRUE);
+ font->glyphs = NULL;
+ }
+ if (font->desc) {
+ pango_font_description_free (font->desc);
+ font->desc = NULL;
+ }
+ if (font->name) {
+ g_free (font->name);
+ font->name = NULL;
+ }
+
+ G_OBJECT_CLASS (swfdec_font_parent_class)->dispose (object);
+}
+
+static void
+swfdec_font_class_init (SwfdecFontClass * g_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+
+ object_class->dispose = swfdec_font_dispose;
+}
+
+static void
+swfdec_font_init (SwfdecFont * font)
+{
+ font->glyphs = g_array_new (FALSE, TRUE, sizeof (SwfdecFontEntry));
+}
+
+/**
+ * swfdec_font_get_glyph:
+ * @font: a #SwfdecFont
+ * @glyph: id of glyph to render
+ *
+ * Tries to get the shape associated with the given glyph id. It is valid to
+ * call this function with any glyph id. If no such glyph exists, this function
+ * returns %NULL.
+ *
+ * Returns: the shape of the requested glyph or %NULL if no such glyph exists.
+ **/
+SwfdecDraw *
+swfdec_font_get_glyph (SwfdecFont * font, guint glyph)
+{
+ g_return_val_if_fail (SWFDEC_IS_FONT (font), NULL);
+
+ if (glyph >= font->glyphs->len)
+ return NULL;
+
+ return g_array_index (font->glyphs, SwfdecFontEntry, glyph).draw;
+}
+
+#if 0
+static char *
+convert_from_language (const char *s, SwfdecLanguage language)
+{
+ char *ret;
+ const char *langcode;
+
+ switch (language) {
+ case SWFDEC_LANGUAGE_LATIN:
+ langcode = "LATIN1";
+ break;
+ case SWFDEC_LANGUAGE_JAPANESE:
+ langcode = "SHIFT_JIS";
+ break;
+ /* FIXME! */
+ case SWFDEC_LANGUAGE_KOREAN:
+ case SWFDEC_LANGUAGE_CHINESE:
+ case SWFDEC_LANGUAGE_CHINESE_TRADITIONAL:
+ default:
+ SWFDEC_ERROR ("can't convert given text from language %u", language);
+ return NULL;
+ }
+ SWFDEC_LOG ("converting text from %s", langcode);
+ ret = g_convert (s, -1, "UTF-8", langcode, NULL, NULL, NULL);
+ if (ret == NULL)
+ SWFDEC_ERROR ("given text is not in language %s", langcode);
+ return ret;
+}
+#endif
+
+int
+tag_func_define_font_info (SwfdecSwfDecoder *s, guint tag)
+{
+ SwfdecFont *font;
+ guint id, len, i;
+ int reserved, wide, ansi, jis;
+ char *name;
+ /* we just assume Latin1 (FIXME: option to change this?) */
+ SwfdecLanguage language = SWFDEC_LANGUAGE_LATIN;
+
+ id = swfdec_bits_get_u16 (&s->b);
+ font = swfdec_swf_decoder_get_character (s, id);
+ if (!SWFDEC_IS_FONT (font)) {
+ SWFDEC_WARNING ("didn't find a font with id %u", id);
+ return SWFDEC_STATUS_OK;
+ }
+ len = swfdec_bits_get_u8 (&s->b);
+ /* this string is locale specific */
+ name = swfdec_bits_get_string_length (&s->b, len, s->version);
+ reserved = swfdec_bits_getbits (&s->b, 2);
+ font->small = swfdec_bits_getbit (&s->b);
+ jis = swfdec_bits_getbit (&s->b);
+ ansi = swfdec_bits_getbit (&s->b);
+ if (jis != 0 || ansi != 0) {
+ SWFDEC_LOG ("ansi = %d, jis = %d", ansi, jis);
+ if (tag == SWFDEC_TAG_DEFINEFONTINFO2)
+ SWFDEC_INFO ("ANSI and JIS flags are supposed to be 0 in DefineFontInfo");
+ if (jis)
+ language = SWFDEC_LANGUAGE_JAPANESE;
+ }
+ font->italic = swfdec_bits_getbit (&s->b);
+ font->bold = swfdec_bits_getbit (&s->b);
+ wide = swfdec_bits_getbit (&s->b);
+ if (tag == SWFDEC_TAG_DEFINEFONTINFO2)
+ language = swfdec_bits_get_u8 (&s->b);
+ g_free (name);
+ if (font->name) {
+ SWFDEC_LOG ("Creating font description for font %d", id);
+ font->desc = pango_font_description_new ();
+ pango_font_description_set_family_static (font->desc, font->name);
+ if (font->bold)
+ pango_font_description_set_weight (font->desc, PANGO_WEIGHT_BOLD);
+ if (font->italic)
+ pango_font_description_set_style (font->desc, PANGO_STYLE_ITALIC);
+ }
+ for (i = 0; i < font->glyphs->len; i++) {
+ g_array_index (font->glyphs, SwfdecFontEntry, i).value =
+ wide ? swfdec_bits_get_u16 (&s->b) : swfdec_bits_get_u8 (&s->b);
+ }
+
+ return SWFDEC_STATUS_OK;
+}
+
+static void
+swfdec_font_parse_shape (SwfdecSwfDecoder *s, SwfdecFontEntry *entry, guint size)
+{
+ SwfdecBits bits;
+ SwfdecShapeParser *parser;
+ GSList *list;
+
+ swfdec_bits_init_bits (&bits, &s->b, size);
+ parser = swfdec_shape_parser_new (NULL, NULL, NULL);
+ swfdec_shape_parser_parse (parser, &bits);
+ list = swfdec_shape_parser_free (parser);
+ if (list) {
+ entry->draw = g_object_ref (list->data);
+ g_slist_foreach (list, (GFunc) g_object_unref, NULL);
+ g_slist_free (list);
+ } else {
+ entry->draw = NULL;
+ }
+
+ if (swfdec_bits_left (&bits)) {
+ SWFDEC_WARNING ("parsing shape didn't use %d bytes",
+ swfdec_bits_left (&bits) / 8);
+ }
+}
+
+int
+tag_func_define_font (SwfdecSwfDecoder * s, guint tag)
+{
+ guint i, id, n_glyphs, offset, next_offset;
+ SwfdecFont *font;
+ SwfdecBits offsets;
+
+ id = swfdec_bits_get_u16 (&s->b);
+ font = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_FONT);
+ if (!font)
+ return SWFDEC_STATUS_OK;
+ font->scale_factor = SWFDEC_TEXT_SCALE_FACTOR;
+
+ offset = swfdec_bits_get_u16 (&s->b);
+ if (offset % 2) {
+ SWFDEC_ERROR ("first offset is odd?!");
+ }
+ n_glyphs = offset / 2;
+ if (n_glyphs == 0)
+ return SWFDEC_STATUS_OK;
+ swfdec_bits_init_bits (&offsets, &s->b, offset - 2);
+
+ g_array_set_size (font->glyphs, n_glyphs);
+ for (i = 0; i < n_glyphs && swfdec_bits_left (&s->b); i++) {
+ SwfdecFontEntry *entry = &g_array_index (font->glyphs, SwfdecFontEntry, i);
+ if (i + 1 == n_glyphs)
+ next_offset = offset + swfdec_bits_left (&s->b) / 8;
+ else
+ next_offset = swfdec_bits_get_u16 (&offsets);
+ swfdec_font_parse_shape (s, entry, next_offset - offset);
+ offset = next_offset;
+ }
+ if (i < n_glyphs) {
+ SWFDEC_ERROR ("data was only enough for %u glyphs, not %u", i, n_glyphs);
+ g_array_set_size (font->glyphs, i);
+ }
+
+ return SWFDEC_STATUS_OK;
+}
+
+static void
+swfdec_font_parse_kerning_table (SwfdecSwfDecoder *s, SwfdecFont *font, gboolean wide_codes)
+{
+ SwfdecBits *bits = &s->b;
+ guint n_kernings, i;
+
+ n_kernings = swfdec_bits_get_u16 (bits);
+ for (i = 0; i < n_kernings; i++) {
+ if (wide_codes) {
+ swfdec_bits_get_u16 (bits);
+ swfdec_bits_get_u16 (bits);
+ } else {
+ swfdec_bits_get_u8 (bits);
+ swfdec_bits_get_u8 (bits);
+ }
+ swfdec_bits_get_s16 (bits);
+ }
+}
+
+int
+tag_func_define_font_2 (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecBits *bits = &s->b;
+ SwfdecBits offset_bits;
+ guint id;
+ SwfdecFont *font;
+ SwfdecRect rect;
+
+ int has_layout;
+ int shift_jis;
+ int reserved;
+ int ansi;
+ int wide_offsets;
+ int wide_codes;
+ int italic;
+ int bold;
+ int langcode;
+ int font_name_len;
+ int n_glyphs;
+ int font_ascent;
+ int font_descent;
+ int font_leading;
+ int i;
+ guint offset;
+
+ id = swfdec_bits_get_u16 (bits);
+ font = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_FONT);
+ if (!font)
+ return SWFDEC_STATUS_OK;
+ font->scale_factor = SWFDEC_TEXT_SCALE_FACTOR;
+
+ has_layout = swfdec_bits_getbit (bits);
+ shift_jis = swfdec_bits_getbit (bits);
+ reserved = swfdec_bits_getbit (bits);
+ ansi = swfdec_bits_getbit (bits);
+ wide_offsets = swfdec_bits_getbit (bits);
+ wide_codes = swfdec_bits_getbit (bits);
+ italic = swfdec_bits_getbit (bits);
+ bold = swfdec_bits_getbit (bits);
+
+ langcode = swfdec_bits_get_u8 (bits);
+ SWFDEC_DEBUG("langcode %d", langcode);
+
+ font_name_len = swfdec_bits_get_u8 (bits);
+ font->name = swfdec_bits_get_string_length (bits, font_name_len, s->version);
+ if (font->name == NULL) {
+ SWFDEC_ERROR ("error reading font name");
+ } else {
+ SWFDEC_LOG (" font name = %s", font->name);
+ }
+
+ n_glyphs = swfdec_bits_get_u16 (bits);
+ if (wide_offsets) {
+ swfdec_bits_init_bits (&offset_bits, bits, 4 * n_glyphs + 4);
+ offset = swfdec_bits_get_u32 (&offset_bits);
+ } else {
+ swfdec_bits_init_bits (&offset_bits, bits, 2 * n_glyphs + 2);
+ offset = swfdec_bits_get_u16 (&offset_bits);
+ }
+
+ g_array_set_size (font->glyphs, n_glyphs);
+
+ for (i = 0; i < n_glyphs && swfdec_bits_left (&s->b); i++) {
+ SwfdecFontEntry *entry = &g_array_index (font->glyphs, SwfdecFontEntry, i);
+ guint next_offset;
+
+ if (wide_offsets)
+ next_offset = swfdec_bits_get_u32 (&offset_bits);
+ else
+ next_offset = swfdec_bits_get_u16 (&offset_bits);
+ swfdec_font_parse_shape (s, entry, next_offset - offset);
+ offset = next_offset;
+ }
+ if (i < n_glyphs) {
+ SWFDEC_ERROR ("data was only enough for %u glyphs, not %u", i, n_glyphs);
+ g_array_set_size (font->glyphs, i);
+ n_glyphs = i;
+ }
+ if (wide_codes) {
+ swfdec_bits_skip_bytes (bits, 2 * n_glyphs);
+ } else {
+ swfdec_bits_skip_bytes (bits, 1 * n_glyphs);
+ }
+ if (has_layout) {
+ font_ascent = swfdec_bits_get_s16 (bits);
+ font_descent = swfdec_bits_get_s16 (bits);
+ font_leading = swfdec_bits_get_s16 (bits);
+ //font_advance_table = swfdec_bits_get_s16(bits);
+ swfdec_bits_skip_bytes (bits, 2 * n_glyphs);
+ for (i = 0; i < n_glyphs && swfdec_bits_left (bits); i++) {
+ swfdec_bits_get_rect (bits, &rect);
+ }
+ swfdec_font_parse_kerning_table (s, font, wide_codes);
+ }
+
+ return SWFDEC_STATUS_OK;
+}
+
+int
+tag_func_define_font_3 (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecBits offsets, *bits = &s->b;
+ SwfdecFont *font;
+ SwfdecLanguage language;
+ guint i, id, len, n_glyphs, offset, next_offset;
+ gboolean layout, shift_jis, ansi, wide_offsets, wide_codes;
+
+ id = swfdec_bits_get_u16 (bits);
+ font = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_FONT);
+ if (!font)
+ return SWFDEC_STATUS_OK;
+ SWFDEC_LOG (" id = %u", id);
+ font->scale_factor = 20 * SWFDEC_TEXT_SCALE_FACTOR;
+
+ layout = swfdec_bits_getbit (bits);
+ SWFDEC_LOG (" layout = %d", layout);
+ shift_jis = swfdec_bits_getbit (bits);
+ SWFDEC_LOG (" JIS = %d", shift_jis);
+ font->small = swfdec_bits_getbit (bits);
+ SWFDEC_LOG (" small = %d", font->small);
+ ansi = swfdec_bits_getbit (bits);
+ SWFDEC_LOG (" ansi = %d", ansi);
+ wide_offsets = swfdec_bits_getbit (bits);
+ SWFDEC_LOG (" wide offsets = %d", wide_offsets);
+ wide_codes = swfdec_bits_getbit (bits);
+ SWFDEC_LOG (" wide codes = %d", wide_codes);
+ if (wide_codes == 0) {
+ SWFDEC_ERROR (" wide codes should be set in DefineFont3");
+ }
+ font->italic = swfdec_bits_getbit (bits);
+ SWFDEC_LOG (" italic = %d", font->italic);
+ font->bold = swfdec_bits_getbit (bits);
+ SWFDEC_LOG (" bold = %d", font->bold);
+ language = swfdec_bits_get_u8 (&s->b);
+ SWFDEC_LOG (" language = %u", (guint) language);
+ len = swfdec_bits_get_u8 (&s->b);
+ font->name = swfdec_bits_get_string_length (&s->b, len, s->version);
+ if (font->name == NULL) {
+ SWFDEC_ERROR ("error reading font name");
+ } else {
+ SWFDEC_LOG (" font name = %s", font->name);
+ }
+ n_glyphs = swfdec_bits_get_u16 (&s->b);
+ SWFDEC_LOG (" n_glyphs = %u", n_glyphs);
+
+ if (wide_offsets) {
+ offset = swfdec_bits_get_u32 (bits);
+ swfdec_bits_init_bits (&offsets, bits, n_glyphs * 4);
+ } else {
+ offset = swfdec_bits_get_u16 (bits);
+ swfdec_bits_init_bits (&offsets, bits, n_glyphs * 2);
+ }
+ g_array_set_size (font->glyphs, n_glyphs);
+ for (i = 0; i < n_glyphs && swfdec_bits_left (bits); i++) {
+ SwfdecFontEntry *entry = &g_array_index (font->glyphs, SwfdecFontEntry, i);
+ if (wide_offsets)
+ next_offset = swfdec_bits_get_u32 (&offsets);
+ else
+ next_offset = swfdec_bits_get_u16 (&offsets);
+ swfdec_font_parse_shape (s, entry, next_offset - offset);
+ offset = next_offset;
+ }
+ if (i < n_glyphs) {
+ SWFDEC_ERROR ("data was only enough for %u glyphs, not %u", i, n_glyphs);
+ g_array_set_size (font->glyphs, i);
+ n_glyphs = i;
+ }
+ for (i = 0; i < n_glyphs && swfdec_bits_left (bits); i++) {
+ SwfdecFontEntry *entry = &g_array_index (font->glyphs, SwfdecFontEntry, i);
+ if (wide_codes)
+ entry->value = swfdec_bits_get_u16 (bits);
+ else
+ entry->value = swfdec_bits_get_u8 (bits);
+ }
+ if (layout) {
+ guint ascent, descent, leading;
+
+ ascent = swfdec_bits_get_u16 (bits);
+ descent = swfdec_bits_get_u16 (bits);
+ leading = swfdec_bits_get_u16 (bits);
+ for (i = 0; i < n_glyphs && swfdec_bits_left (bits); i++) {
+ /* guint advance = */ swfdec_bits_get_u16 (bits);
+ }
+ for (i = 0; i < n_glyphs && swfdec_bits_left (bits); i++) {
+ SwfdecRect rect;
+ swfdec_bits_get_rect (bits, &rect);
+ }
+ swfdec_font_parse_kerning_table (s, font, wide_codes);
+ }
+
+ return SWFDEC_STATUS_OK;
+}
diff --git a/swfdec/swfdec_font.h b/swfdec/swfdec_font.h
new file mode 100644
index 0000000..b9ff5d7
--- /dev/null
+++ b/swfdec/swfdec_font.h
@@ -0,0 +1,89 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_FONT_H_
+#define _SWFDEC_FONT_H_
+
+#include <pango/pangocairo.h>
+#include <libswfdec/swfdec_types.h>
+#include <libswfdec/swfdec_character.h>
+
+G_BEGIN_DECLS
+//typedef struct _SwfdecFont SwfdecFont;
+typedef struct _SwfdecFontEntry SwfdecFontEntry;
+typedef struct _SwfdecFontClass SwfdecFontClass;
+
+#define SWFDEC_TEXT_SCALE_FACTOR (1024)
+
+typedef enum {
+ SWFDEC_LANGUAGE_NONE = 0,
+ SWFDEC_LANGUAGE_LATIN = 1,
+ SWFDEC_LANGUAGE_JAPANESE = 2,
+ SWFDEC_LANGUAGE_KOREAN = 3,
+ SWFDEC_LANGUAGE_CHINESE = 4,
+ SWFDEC_LANGUAGE_CHINESE_TRADITIONAL = 5
+} SwfdecLanguage;
+
+#define SWFDEC_TYPE_FONT (swfdec_font_get_type())
+#define SWFDEC_IS_FONT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_FONT))
+#define SWFDEC_IS_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_FONT))
+#define SWFDEC_FONT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_FONT, SwfdecFont))
+#define SWFDEC_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_FONT, SwfdecFontClass))
+
+struct _SwfdecFontEntry {
+ SwfdecDraw * draw; /* drawing operation to do or %NULL if none (ie space character) */
+ gunichar value; /* UCS2 value of glyph */
+};
+
+struct _SwfdecFont
+{
+ SwfdecCharacter character;
+
+ char * name; /* name of the font (FIXME: what name?) */
+ PangoFontDescription *desc;
+ gboolean bold; /* font is bold */
+ gboolean italic; /* font is italic */
+ gboolean small; /* font is rendered at small sizes */
+ GArray * glyphs; /* SwfdecFontEntry */
+ guint scale_factor; /* size of a font in glyph entry */
+};
+
+struct _SwfdecFontClass
+{
+ SwfdecCharacterClass character_class;
+};
+
+GType swfdec_font_get_type (void);
+
+SwfdecDraw * swfdec_font_get_glyph (SwfdecFont * font,
+ guint glyph);
+
+int tag_func_define_font_info (SwfdecSwfDecoder * s,
+ guint tag);
+int tag_func_define_font (SwfdecSwfDecoder * s,
+ guint tag);
+int tag_func_define_font_2 (SwfdecSwfDecoder * s,
+ guint tag);
+int tag_func_define_font_3 (SwfdecSwfDecoder * s,
+ guint tag);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_function_list.c b/swfdec/swfdec_function_list.c
new file mode 100644
index 0000000..0b29b59
--- /dev/null
+++ b/swfdec/swfdec_function_list.c
@@ -0,0 +1,132 @@
+/* Swfdec
+ * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include "swfdec_function_list.h"
+
+typedef struct _SwfdecFunctionListEntry SwfdecFunctionListEntry;
+struct _SwfdecFunctionListEntry {
+ GFunc func;
+ gpointer data;
+ GDestroyNotify destroy;
+};
+
+void
+swfdec_function_list_clear (SwfdecFunctionList *list)
+{
+ GList *walk;
+
+ g_return_if_fail (list != NULL);
+
+ for (walk = list->list; walk; walk = walk->next) {
+ SwfdecFunctionListEntry *entry = walk->data;
+ if (entry->destroy)
+ entry->destroy (entry->data);
+ g_slice_free (SwfdecFunctionListEntry, entry);
+ }
+ g_list_free (list->list);
+ list->list = NULL;
+}
+
+void
+swfdec_function_list_add (SwfdecFunctionList *list, GFunc func,
+ gpointer data, GDestroyNotify destroy)
+{
+ SwfdecFunctionListEntry *entry;
+
+ g_return_if_fail (list != NULL);
+ g_return_if_fail (func);
+
+ entry = g_slice_new (SwfdecFunctionListEntry);
+ entry->func = func;
+ entry->data = data;
+ entry->destroy = destroy;
+
+ list->list = g_list_append (list->list, entry);
+}
+
+static int
+swfdec_function_list_entry_compare (gconstpointer a, gconstpointer b)
+{
+ a = ((const SwfdecFunctionListEntry *) a)->data;
+ b = ((const SwfdecFunctionListEntry *) b)->data;
+
+ if (a < b)
+ return -1;
+ if (a > b)
+ return 1;
+ return 0;
+}
+
+void
+swfdec_function_list_remove (SwfdecFunctionList *list, gpointer data)
+{
+ SwfdecFunctionListEntry entry = { NULL, data, NULL };
+ SwfdecFunctionListEntry *e;
+ GList *node;
+
+ g_return_if_fail (list != NULL);
+
+ node = g_list_find_custom (list->list, &entry,
+ swfdec_function_list_entry_compare);
+ e = node->data;
+ if (e->destroy)
+ e->destroy (data);
+ g_slice_free (SwfdecFunctionListEntry, e);
+ list->list = g_list_delete_link (list->list, node);
+}
+
+void
+swfdec_function_list_execute (SwfdecFunctionList *list, gpointer data)
+{
+ SwfdecFunctionListEntry *entry;
+ GList *walk;
+
+ g_return_if_fail (list != NULL);
+
+ for (walk = list->list; walk; walk = walk->next) {
+ entry = walk->data;
+ entry->func (entry->data, data);
+ }
+}
+
+void
+swfdec_function_list_execute_and_clear (SwfdecFunctionList *list, gpointer data)
+{
+ SwfdecFunctionListEntry *entry;
+ GList *old, *walk;
+
+ g_return_if_fail (list != NULL);
+
+ old = list->list;
+ list->list = NULL;
+ for (walk = old; walk; walk = walk->next) {
+ entry = walk->data;
+ entry->func (entry->data, data);
+ if (entry->destroy)
+ entry->destroy (entry->data);
+ g_slice_free (SwfdecFunctionListEntry, entry);
+ }
+ g_list_free (old);
+}
+
diff --git a/swfdec/swfdec_function_list.h b/swfdec/swfdec_function_list.h
new file mode 100644
index 0000000..f7e8691
--- /dev/null
+++ b/swfdec/swfdec_function_list.h
@@ -0,0 +1,50 @@
+/* Swfdec
+ * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SWFDEC_FUNCTION_LIST_H__
+#define __SWFDEC_FUNCTION_LIST_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _SwfdecFunctionList SwfdecFunctionList;
+struct _SwfdecFunctionList {
+ GList * list;
+};
+
+void swfdec_function_list_clear (SwfdecFunctionList * list);
+
+void swfdec_function_list_add (SwfdecFunctionList * list,
+ GFunc func,
+ gpointer data,
+ GDestroyNotify destroy);
+void swfdec_function_list_remove (SwfdecFunctionList * list,
+ gpointer data);
+
+void swfdec_function_list_execute (SwfdecFunctionList * list,
+ gpointer data);
+void swfdec_function_list_execute_and_clear
+ (SwfdecFunctionList * list,
+ gpointer data);
+
+G_END_DECLS
+
+#endif
diff --git a/swfdec/swfdec_glow_filter.c b/swfdec/swfdec_glow_filter.c
new file mode 100644
index 0000000..2bc0784
--- /dev/null
+++ b/swfdec/swfdec_glow_filter.c
@@ -0,0 +1,162 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (1103, 1, swfdec_glow_filter_get_distance)
+void
+swfdec_glow_filter_get_distance (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GlowFilter.distance (get)");
+}
+
+SWFDEC_AS_NATIVE (1103, 2, swfdec_glow_filter_set_distance)
+void
+swfdec_glow_filter_set_distance (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GlowFilter.distance (set)");
+}
+
+SWFDEC_AS_NATIVE (1103, 3, swfdec_glow_filter_get_alpha)
+void
+swfdec_glow_filter_get_alpha (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GlowFilter.alpha (get)");
+}
+
+SWFDEC_AS_NATIVE (1103, 4, swfdec_glow_filter_set_alpha)
+void
+swfdec_glow_filter_set_alpha (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GlowFilter.alpha (set)");
+}
+
+SWFDEC_AS_NATIVE (1103, 5, swfdec_glow_filter_get_quality)
+void
+swfdec_glow_filter_get_quality (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GlowFilter.quality (get)");
+}
+
+SWFDEC_AS_NATIVE (1103, 6, swfdec_glow_filter_set_quality)
+void
+swfdec_glow_filter_set_quality (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GlowFilter.quality (set)");
+}
+
+SWFDEC_AS_NATIVE (1103, 7, swfdec_glow_filter_get_inner)
+void
+swfdec_glow_filter_get_inner (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GlowFilter.inner (get)");
+}
+
+SWFDEC_AS_NATIVE (1103, 8, swfdec_glow_filter_set_inner)
+void
+swfdec_glow_filter_set_inner (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GlowFilter.inner (set)");
+}
+
+SWFDEC_AS_NATIVE (1103, 9, swfdec_glow_filter_get_knockout)
+void
+swfdec_glow_filter_get_knockout (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GlowFilter.knockout (get)");
+}
+
+SWFDEC_AS_NATIVE (1103, 10, swfdec_glow_filter_set_knockout)
+void
+swfdec_glow_filter_set_knockout (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GlowFilter.knockout (set)");
+}
+
+SWFDEC_AS_NATIVE (1103, 11, swfdec_glow_filter_get_blurX)
+void
+swfdec_glow_filter_get_blurX (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GlowFilter.blurX (get)");
+}
+
+SWFDEC_AS_NATIVE (1103, 12, swfdec_glow_filter_set_blurX)
+void
+swfdec_glow_filter_set_blurX (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GlowFilter.blurX (set)");
+}
+
+SWFDEC_AS_NATIVE (1103, 13, swfdec_glow_filter_get_blurY)
+void
+swfdec_glow_filter_get_blurY (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GlowFilter.blurY (get)");
+}
+
+SWFDEC_AS_NATIVE (1103, 14, swfdec_glow_filter_set_blurY)
+void
+swfdec_glow_filter_set_blurY (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GlowFilter.blurY (set)");
+}
+
+SWFDEC_AS_NATIVE (1103, 15, swfdec_glow_filter_get_strength)
+void
+swfdec_glow_filter_get_strength (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GlowFilter.strength (get)");
+}
+
+SWFDEC_AS_NATIVE (1103, 16, swfdec_glow_filter_set_strength)
+void
+swfdec_glow_filter_set_strength (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GlowFilter.strength (set)");
+}
+
+// constructor
+SWFDEC_AS_NATIVE (1103, 0, swfdec_glow_filter_construct)
+void
+swfdec_glow_filter_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GlowFilter");
+}
diff --git a/swfdec/swfdec_gradient_filter.c b/swfdec/swfdec_gradient_filter.c
new file mode 100644
index 0000000..d32b113
--- /dev/null
+++ b/swfdec/swfdec_gradient_filter.c
@@ -0,0 +1,243 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (1108, 1, swfdec_gradient_filter_get_distance)
+void
+swfdec_gradient_filter_get_distance (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter/GradientGlowFilter.distance (get)");
+}
+
+SWFDEC_AS_NATIVE (1108, 2, swfdec_gradient_filter_set_distance)
+void
+swfdec_gradient_filter_set_distance (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter/GradientGlowFilter.distance (set)");
+}
+
+SWFDEC_AS_NATIVE (1108, 3, swfdec_gradient_filter_get_angle)
+void
+swfdec_gradient_filter_get_angle (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.angle (get)");
+}
+
+SWFDEC_AS_NATIVE (1108, 4, swfdec_gradient_filter_set_angle)
+void
+swfdec_gradient_filter_set_angle (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.angle (set)");
+}
+
+SWFDEC_AS_NATIVE (1108, 5, swfdec_gradient_filter_get_colors)
+void
+swfdec_gradient_filter_get_colors (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.colors (get)");
+}
+
+SWFDEC_AS_NATIVE (1108, 6, swfdec_gradient_filter_set_colors)
+void
+swfdec_gradient_filter_set_colors (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.colors (set)");
+}
+
+SWFDEC_AS_NATIVE (1108, 7, swfdec_gradient_filter_get_alphas)
+void
+swfdec_gradient_filter_get_alphas (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.alphas (get)");
+}
+
+SWFDEC_AS_NATIVE (1108, 8, swfdec_gradient_filter_set_alphas)
+void
+swfdec_gradient_filter_set_alphas (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.alphas (set)");
+}
+
+SWFDEC_AS_NATIVE (1108, 9, swfdec_gradient_filter_get_ratios)
+void
+swfdec_gradient_filter_get_ratios (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.ratios (get)");
+}
+
+SWFDEC_AS_NATIVE (1108, 10, swfdec_gradient_filter_set_ratios)
+void
+swfdec_gradient_filter_set_ratios (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.ratios (set)");
+}
+
+SWFDEC_AS_NATIVE (1108, 11, swfdec_gradient_filter_get_blurX)
+void
+swfdec_gradient_filter_get_blurX (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.blurX (get)");
+}
+
+SWFDEC_AS_NATIVE (1108, 12, swfdec_gradient_filter_set_blurX)
+void
+swfdec_gradient_filter_set_blurX (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.blurX (set)");
+}
+
+SWFDEC_AS_NATIVE (1108, 13, swfdec_gradient_filter_get_blurY)
+void
+swfdec_gradient_filter_get_blurY (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.blurY (get)");
+}
+
+SWFDEC_AS_NATIVE (1108, 14, swfdec_gradient_filter_set_blurY)
+void
+swfdec_gradient_filter_set_blurY (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.blurY (set)");
+}
+
+SWFDEC_AS_NATIVE (1108, 15, swfdec_gradient_filter_get_quality)
+void
+swfdec_gradient_filter_get_quality (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.quality (get)");
+}
+
+SWFDEC_AS_NATIVE (1108, 16, swfdec_gradient_filter_set_quality)
+void
+swfdec_gradient_filter_set_quality (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.quality (set)");
+}
+
+SWFDEC_AS_NATIVE (1108, 17, swfdec_gradient_filter_get_strength)
+void
+swfdec_gradient_filter_get_strength (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.strength (get)");
+}
+
+SWFDEC_AS_NATIVE (1108, 18, swfdec_gradient_filter_set_strength)
+void
+swfdec_gradient_filter_set_strength (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.strength (set)");
+}
+
+SWFDEC_AS_NATIVE (1108, 19, swfdec_gradient_filter_get_knockout)
+void
+swfdec_gradient_filter_get_knockout (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.knockout (get)");
+}
+
+SWFDEC_AS_NATIVE (1108, 20, swfdec_gradient_filter_set_knockout)
+void
+swfdec_gradient_filter_set_knockout (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.knockout (set)");
+}
+
+SWFDEC_AS_NATIVE (1108, 21, swfdec_gradient_filter_get_type)
+void
+swfdec_gradient_filter_get_type (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.type (get)");
+}
+
+SWFDEC_AS_NATIVE (1108, 22, swfdec_gradient_filter_set_type)
+void
+swfdec_gradient_filter_set_type (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter/GradientGlowFilter.type (set)");
+}
+
+// constructors
+
+SWFDEC_AS_NATIVE (1108, 0, swfdec_gradient_glow_filter_construct)
+void
+swfdec_gradient_glow_filter_construct (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientGlowFilter");
+}
+
+SWFDEC_AS_NATIVE (1108, 1000, swfdec_gradient_bevel_filter_construct)
+void
+swfdec_gradient_bevel_filter_construct (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("GradientBevelFilter");
+}
diff --git a/swfdec/swfdec_gradient_pattern.c b/swfdec/swfdec_gradient_pattern.c
new file mode 100644
index 0000000..2f63634
--- /dev/null
+++ b/swfdec/swfdec_gradient_pattern.c
@@ -0,0 +1,129 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+
+#include "swfdec_gradient_pattern.h"
+#include "swfdec_color.h"
+#include "swfdec_debug.h"
+#include "swfdec_path.h"
+
+G_DEFINE_TYPE (SwfdecGradientPattern, swfdec_gradient_pattern, SWFDEC_TYPE_PATTERN);
+
+static void
+swfdec_gradient_pattern_morph (SwfdecDraw *dest, SwfdecDraw *source, guint ratio)
+{
+ guint i;
+
+ SwfdecGradientPattern *dpattern = SWFDEC_GRADIENT_PATTERN (dest);
+ SwfdecGradientPattern *spattern = SWFDEC_GRADIENT_PATTERN (source);
+
+ g_return_if_fail (spattern->end_gradient != NULL);
+ dpattern->radial = spattern->radial;
+ dpattern->focus = spattern->focus;
+ dpattern->extend = spattern->extend;
+ dpattern->n_gradients = spattern->n_gradients;
+ for (i = 0; i < spattern->n_gradients; i++) {
+ dpattern->gradient[i].color = swfdec_color_apply_morph (spattern->gradient[i].color,
+ spattern->end_gradient[i].color, ratio);
+ dpattern->gradient[i].ratio = (spattern->gradient[i].ratio * (65535 - ratio) +
+ spattern->end_gradient[i].ratio * ratio) / 65535;
+ }
+
+ SWFDEC_DRAW_CLASS (swfdec_gradient_pattern_parent_class)->morph (dest, source, ratio);
+}
+
+static cairo_pattern_t *
+swfdec_gradient_pattern_get_pattern (SwfdecPattern *pat, const SwfdecColorTransform *trans)
+{
+ guint i, ratio;
+ cairo_pattern_t *pattern;
+ SwfdecColor color;
+ double offset;
+ SwfdecGradientPattern *gradient = SWFDEC_GRADIENT_PATTERN (pat);
+
+ if (gradient->n_gradients == 0) {
+ /* cairo interprets an empty gradient as translucent, not as solid black */
+ return cairo_pattern_create_rgb (0, 0, 0);
+ }
+#if 0
+ /* use this when https://bugs.freedesktop.org/show_bug.cgi?id=8341 is fixed */
+ if (gradient->radial)
+ pattern = cairo_pattern_create_radial (0, 0, 0, 0, 0, 16384);
+ else
+ pattern = cairo_pattern_create_linear (-16384.0, 0, 16384.0, 0);
+ cairo_pattern_set_matrix (pattern, &pat->transform);
+#else
+ {
+ cairo_matrix_t mat = pat->transform;
+ if (gradient->radial) {
+ pattern = cairo_pattern_create_radial ((16384.0 / 256.0) * gradient->focus,
+ 0, 0, 0, 0, 16384 / 256.0);
+ } else {
+ pattern = cairo_pattern_create_linear (-16384.0 / 256.0, 0, 16384.0 / 256.0, 0);
+ }
+ cairo_matrix_scale (&mat, 1 / 256.0, 1 / 256.0);
+ mat.x0 /= 256.0;
+ mat.y0 /= 256.0;
+ cairo_pattern_set_matrix (pattern, &mat);
+ }
+#endif
+ cairo_pattern_set_extend (pattern, gradient->extend);
+ /* we check here that ratios increase linearly, because both gradients parsed
+ * from the SWF and gradients created with beginGradientFill have this
+ * behavior */
+ ratio = 0;
+ for (i = 0; i < gradient->n_gradients; i++){
+ color = swfdec_color_apply_transform (gradient->gradient[i].color,
+ trans);
+ ratio = MAX (ratio, gradient->gradient[i].ratio);
+ offset = ratio / 255.0;
+ cairo_pattern_add_color_stop_rgba (pattern, offset,
+ SWFDEC_COLOR_R(color) / 255.0, SWFDEC_COLOR_G(color) / 255.0,
+ SWFDEC_COLOR_B(color) / 255.0, SWFDEC_COLOR_A(color) / 255.0);
+ if (++ratio > 255)
+ break;
+ }
+ return pattern;
+}
+
+static void
+swfdec_gradient_pattern_class_init (SwfdecGradientPatternClass *klass)
+{
+ SWFDEC_DRAW_CLASS (klass)->morph = swfdec_gradient_pattern_morph;
+
+ SWFDEC_PATTERN_CLASS (klass)->get_pattern = swfdec_gradient_pattern_get_pattern;
+}
+
+static void
+swfdec_gradient_pattern_init (SwfdecGradientPattern *gradient)
+{
+ gradient->extend = CAIRO_EXTEND_PAD;
+}
+
+SwfdecDraw *
+swfdec_gradient_pattern_new (void)
+{
+ return g_object_new (SWFDEC_TYPE_GRADIENT_PATTERN, NULL);
+}
+
diff --git a/swfdec/swfdec_gradient_pattern.h b/swfdec/swfdec_gradient_pattern.h
new file mode 100644
index 0000000..6b85608
--- /dev/null
+++ b/swfdec/swfdec_gradient_pattern.h
@@ -0,0 +1,67 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_GRADIENT_PATTERN_H_
+#define _SWFDEC_GRADIENT_PATTERN_H_
+
+#include <libswfdec/swfdec_pattern.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecGradientPattern SwfdecGradientPattern;
+typedef struct _SwfdecGradientPatternClass SwfdecGradientPatternClass;
+
+typedef struct _SwfdecGradientEntry SwfdecGradientEntry;
+
+#define SWFDEC_TYPE_GRADIENT_PATTERN (swfdec_gradient_pattern_get_type())
+#define SWFDEC_IS_GRADIENT_PATTERN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_GRADIENT_PATTERN))
+#define SWFDEC_IS_GRADIENT_PATTERN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_GRADIENT_PATTERN))
+#define SWFDEC_GRADIENT_PATTERN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_GRADIENT_PATTERN, SwfdecGradientPattern))
+#define SWFDEC_GRADIENT_PATTERN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_GRADIENT_PATTERN, SwfdecGradientPatternClass))
+#define SWFDEC_GRADIENT_PATTERN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_GRADIENT_PATTERN, SwfdecGradientPatternClass))
+
+struct _SwfdecGradientEntry {
+ guint ratio;
+ SwfdecColor color;
+};
+
+struct _SwfdecGradientPattern
+{
+ SwfdecPattern pattern;
+
+ SwfdecGradientEntry gradient[16]; /* gradient to paint */
+ SwfdecGradientEntry end_gradient[16]; /* end gradient for morphs */
+ guint n_gradients; /* number of gradients */
+ cairo_extend_t extend; /* extend of gradient */
+ gboolean radial; /* TRUE for radial gradient, FALSE for linear gradient */
+ double focus; /* focus point */
+};
+
+struct _SwfdecGradientPatternClass
+{
+ SwfdecPatternClass pattern_class;
+};
+
+GType swfdec_gradient_pattern_get_type (void);
+
+SwfdecDraw * swfdec_gradient_pattern_new (void);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_graphic.c b/swfdec/swfdec_graphic.c
new file mode 100644
index 0000000..c316084
--- /dev/null
+++ b/swfdec/swfdec_graphic.c
@@ -0,0 +1,71 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_graphic.h"
+#include "swfdec_graphic_movie.h"
+
+
+G_DEFINE_ABSTRACT_TYPE (SwfdecGraphic, swfdec_graphic, SWFDEC_TYPE_CHARACTER)
+
+static SwfdecMovie *
+swfdec_graphic_create_movie (SwfdecGraphic *graphic, gsize *size)
+{
+ SwfdecGraphicMovie *movie = g_object_new (SWFDEC_TYPE_GRAPHIC_MOVIE, NULL);
+
+ *size = sizeof (SwfdecGraphicMovie);
+ return SWFDEC_MOVIE (movie);
+}
+
+static void
+swfdec_graphic_class_init (SwfdecGraphicClass *klass)
+{
+ klass->create_movie = swfdec_graphic_create_movie;
+}
+
+static void
+swfdec_graphic_init (SwfdecGraphic *graphic)
+{
+}
+
+void
+swfdec_graphic_render (SwfdecGraphic *graphic, cairo_t *cr,
+ const SwfdecColorTransform *trans, const SwfdecRect *inval)
+{
+ SwfdecGraphicClass *klass = SWFDEC_GRAPHIC_GET_CLASS (graphic);
+
+ if (klass->render)
+ klass->render (graphic, cr, trans, inval);
+}
+
+gboolean
+swfdec_graphic_mouse_in (SwfdecGraphic *graphic, double x, double y)
+{
+ SwfdecGraphicClass *klass = SWFDEC_GRAPHIC_GET_CLASS (graphic);
+
+ if (klass->mouse_in)
+ return klass->mouse_in (graphic, x, y);
+ else
+ return FALSE;
+}
diff --git a/swfdec/swfdec_graphic.h b/swfdec/swfdec_graphic.h
new file mode 100644
index 0000000..0b48d19
--- /dev/null
+++ b/swfdec/swfdec_graphic.h
@@ -0,0 +1,78 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_GRAPHIC_H_
+#define _SWFDEC_GRAPHIC_H_
+
+#include <glib-object.h>
+#include <libswfdec/swfdec_character.h>
+#include <libswfdec/swfdec_rect.h>
+#include <libswfdec/swfdec_types.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _SwfdecGraphicClass SwfdecGraphicClass;
+
+#define SWFDEC_TYPE_GRAPHIC (swfdec_graphic_get_type())
+#define SWFDEC_IS_GRAPHIC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_GRAPHIC))
+#define SWFDEC_IS_GRAPHIC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_GRAPHIC))
+#define SWFDEC_GRAPHIC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_GRAPHIC, SwfdecGraphic))
+#define SWFDEC_GRAPHIC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_GRAPHIC, SwfdecGraphicClass))
+#define SWFDEC_GRAPHIC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_GRAPHIC, SwfdecGraphicClass))
+
+struct _SwfdecGraphic
+{
+ SwfdecCharacter character;
+
+ SwfdecRect extents; /* bounding box that encloses this graphic */
+};
+
+struct _SwfdecGraphicClass
+{
+ SwfdecCharacterClass character_class;
+
+ /* when creating a movie for this graphic, calls this function */
+ SwfdecMovie * (*create_movie) (SwfdecGraphic * graphic,
+ gsize * size);
+ /* optional vfuncs */
+ void (* render) (SwfdecGraphic * graphic,
+ cairo_t * cr,
+ const SwfdecColorTransform * trans,
+ const SwfdecRect * inval);
+ gboolean (* mouse_in) (SwfdecGraphic * graphic,
+ double x,
+ double y);
+};
+
+GType swfdec_graphic_get_type (void);
+
+void swfdec_graphic_render (SwfdecGraphic * graphic,
+ cairo_t * cr,
+ const SwfdecColorTransform * trans,
+ const SwfdecRect * inval);
+gboolean swfdec_graphic_mouse_in (SwfdecGraphic * graphic,
+ double x,
+ double y);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_graphic_movie.c b/swfdec/swfdec_graphic_movie.c
new file mode 100644
index 0000000..24e8a77
--- /dev/null
+++ b/swfdec/swfdec_graphic_movie.c
@@ -0,0 +1,113 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_graphic_movie.h"
+#include "swfdec_button.h"
+#include "swfdec_debug.h"
+#include "swfdec_movie.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_shape.h"
+#include "swfdec_sprite.h"
+#include "swfdec_swf_decoder.h"
+#include "swfdec_resource.h"
+#include "swfdec_text.h"
+#include "swfdec_text_field.h"
+
+G_DEFINE_TYPE (SwfdecGraphicMovie, swfdec_graphic_movie, SWFDEC_TYPE_MOVIE)
+
+static void
+swfdec_graphic_movie_update_extents (SwfdecMovie *movie,
+ SwfdecRect *extents)
+{
+ swfdec_rect_union (extents, extents,
+ &movie->graphic->extents);
+}
+
+static void
+swfdec_graphic_movie_render (SwfdecMovie *movie, cairo_t *cr,
+ const SwfdecColorTransform *trans, const SwfdecRect *inval)
+{
+ swfdec_graphic_render (movie->graphic, cr, trans, inval);
+}
+
+static void
+swfdec_graphic_movie_invalidate (SwfdecMovie *movie, const cairo_matrix_t *matrix, gboolean last)
+{
+ SwfdecRect rect;
+
+ swfdec_rect_transform (&rect, &movie->graphic->extents, matrix);
+ swfdec_player_invalidate (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), &rect);
+}
+
+static SwfdecMovie *
+swfdec_graphic_movie_contains (SwfdecMovie *movie, double x, double y,
+ gboolean events)
+{
+ if (swfdec_graphic_mouse_in (movie->graphic, x, y))
+ return movie;
+ else
+ return NULL;
+}
+
+static void
+swfdec_graphic_movie_replace (SwfdecMovie *movie, SwfdecGraphic *graphic)
+{
+ if (SWFDEC_IS_SHAPE (graphic) ||
+ SWFDEC_IS_TEXT (graphic)) {
+ /* nothing to do here, please move along */
+ } else if (SWFDEC_IS_SPRITE (graphic) ||
+ SWFDEC_IS_BUTTON (graphic) ||
+ SWFDEC_IS_TEXT_FIELD (graphic)) {
+ SWFDEC_INFO ("can't replace with scriptable objects");
+ return;
+ } else {
+ SWFDEC_FIXME ("Can we replace with %s objects?", G_OBJECT_TYPE_NAME (graphic));
+ return;
+ }
+ if (movie->graphic == graphic)
+ return;
+ swfdec_movie_invalidate_next (movie);
+ SWFDEC_LOG ("replacing %u with %u", SWFDEC_CHARACTER (movie->graphic)->id,
+ SWFDEC_CHARACTER (graphic)->id);
+ swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_EXTENTS);
+ g_object_unref (movie->graphic);
+ movie->graphic = g_object_ref (graphic);
+}
+
+static void
+swfdec_graphic_movie_class_init (SwfdecGraphicMovieClass * g_class)
+{
+ SwfdecMovieClass *movie_class = SWFDEC_MOVIE_CLASS (g_class);
+
+ movie_class->update_extents = swfdec_graphic_movie_update_extents;
+ movie_class->replace = swfdec_graphic_movie_replace;
+ movie_class->render = swfdec_graphic_movie_render;
+ movie_class->invalidate = swfdec_graphic_movie_invalidate;
+ movie_class->contains = swfdec_graphic_movie_contains;
+}
+
+static void
+swfdec_graphic_movie_init (SwfdecGraphicMovie * graphic_movie)
+{
+}
+
diff --git a/swfdec/swfdec_graphic_movie.h b/swfdec/swfdec_graphic_movie.h
new file mode 100644
index 0000000..4d6e454
--- /dev/null
+++ b/swfdec/swfdec_graphic_movie.h
@@ -0,0 +1,51 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_GRAPHIC_MOVIE_H_
+#define _SWFDEC_GRAPHIC_MOVIE_H_
+
+#include <glib-object.h>
+#include <libswfdec/swfdec_movie.h>
+#include <libswfdec/swfdec_graphic.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _SwfdecGraphicMovie SwfdecGraphicMovie;
+typedef struct _SwfdecGraphicMovieClass SwfdecGraphicMovieClass;
+
+#define SWFDEC_TYPE_GRAPHIC_MOVIE (swfdec_graphic_movie_get_type())
+#define SWFDEC_IS_GRAPHIC_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_GRAPHIC_MOVIE))
+#define SWFDEC_IS_GRAPHIC_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_GRAPHIC_MOVIE))
+#define SWFDEC_GRAPHIC_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_GRAPHIC_MOVIE, SwfdecGraphicMovie))
+#define SWFDEC_GRAPHIC_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_GRAPHIC_MOVIE, SwfdecGraphicMovieClass))
+
+struct _SwfdecGraphicMovie {
+ SwfdecMovie movie;
+};
+
+struct _SwfdecGraphicMovieClass {
+ SwfdecMovieClass movie_class;
+};
+
+GType swfdec_graphic_movie_get_type (void);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_image.c b/swfdec/swfdec_image.c
new file mode 100644
index 0000000..54e84ca
--- /dev/null
+++ b/swfdec/swfdec_image.c
@@ -0,0 +1,710 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <zlib.h>
+#include <string.h>
+
+#include "jpeg.h"
+#include "swfdec_image.h"
+#include "swfdec_cache.h"
+#include "swfdec_debug.h"
+#include "swfdec_swf_decoder.h"
+
+static const cairo_user_data_key_t key;
+
+static void merge_alpha (SwfdecImage * image, unsigned char *image_data,
+ unsigned char *alpha);
+static void swfdec_image_colormap_decode (SwfdecImage * image,
+ unsigned char *dest,
+ unsigned char *src, unsigned char *colormap, int colormap_len);
+
+G_DEFINE_TYPE (SwfdecImage, swfdec_image, SWFDEC_TYPE_CACHED)
+
+static void
+swfdec_image_unload (SwfdecCached *cached)
+{
+ SwfdecImage *image = SWFDEC_IMAGE (cached);
+
+ if (image->surface) {
+ cairo_surface_destroy (image->surface);
+ image->surface = NULL;
+ }
+}
+
+static void
+swfdec_image_dispose (GObject *object)
+{
+ SwfdecImage * image = SWFDEC_IMAGE (object);
+
+ if (image->jpegtables) {
+ swfdec_buffer_unref (image->jpegtables);
+ image->jpegtables = NULL;
+ }
+ if (image->raw_data) {
+ swfdec_buffer_unref (image->raw_data);
+ image->raw_data = NULL;
+ }
+
+ G_OBJECT_CLASS (swfdec_image_parent_class)->dispose (object);
+
+ g_assert (image->surface == NULL);
+}
+
+static void
+swfdec_image_class_init (SwfdecImageClass * g_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+ SwfdecCachedClass *cached_class = SWFDEC_CACHED_CLASS (g_class);
+
+ object_class->dispose = swfdec_image_dispose;
+
+ cached_class->unload = swfdec_image_unload;
+}
+
+static void
+swfdec_image_init (SwfdecImage * image)
+{
+}
+
+int
+swfdec_image_jpegtables (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecBits *bits = &s->b;
+
+ SWFDEC_DEBUG ("swfdec_image_jpegtables");
+
+ if (s->jpegtables) {
+ SWFDEC_FIXME ("duplicate DefineJPEGTables tag. Deleting first one");
+ swfdec_buffer_unref (s->jpegtables);
+ }
+ s->jpegtables = swfdec_bits_get_buffer (bits, -1);
+
+ return SWFDEC_STATUS_OK;
+}
+
+int
+tag_func_define_bits_jpeg (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecBits *bits = &s->b;
+ int id;
+ SwfdecImage *image;
+
+ SWFDEC_LOG ("tag_func_define_bits_jpeg");
+ id = swfdec_bits_get_u16 (bits);
+ SWFDEC_LOG (" id = %d", id);
+
+ image = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_IMAGE);
+ if (!image)
+ return SWFDEC_STATUS_OK;
+
+ image->type = SWFDEC_IMAGE_TYPE_JPEG;
+ if (!s->jpegtables) {
+ SWFDEC_ERROR("No global JPEG tables available");
+ } else {
+ image->jpegtables = swfdec_buffer_ref (s->jpegtables);
+ }
+ image->raw_data = swfdec_bits_get_buffer (bits, -1);
+
+ return SWFDEC_STATUS_OK;
+}
+
+/**
+ * swfdec_jpeg_decode_argb:
+ *
+ * This is a wrapper around jpeg_decode_argb() that takes two segments,
+ * strips off (sometimes bogus) start-of-image and end-of-image codes,
+ * concatenates them, and puts new SOI and EOI codes on the resulting
+ * buffer. This makes a real JPEG image out of the crap in SWF files.
+ */
+static gboolean
+swfdec_jpeg_decode_argb (unsigned char *data1, int length1,
+ unsigned char *data2, int length2,
+ void *outdata, int *width, int *height)
+{
+ gboolean ret;
+
+ if (data2) {
+ unsigned char *tmpdata;
+ int tmplength;
+
+ tmplength = length1 + length2;
+ tmpdata = g_malloc (tmplength);
+
+ memcpy (tmpdata, data1, length1);
+ memcpy (tmpdata + length1, data2, length2);
+ ret = jpeg_decode_argb (tmpdata, tmplength, outdata, width, height);
+
+ g_free (tmpdata);
+ } else {
+ ret = jpeg_decode_argb (data1, length1, outdata, width, height);
+ }
+
+ return ret;
+}
+
+static void
+swfdec_image_jpeg_load (SwfdecImage *image)
+{
+ gboolean ret;
+ guint8 *data;
+
+ if (image->jpegtables) {
+ ret = swfdec_jpeg_decode_argb (
+ image->jpegtables->data, image->jpegtables->length,
+ image->raw_data->data, image->raw_data->length,
+ (void *) &data, &image->width, &image->height);
+ } else {
+ ret = swfdec_jpeg_decode_argb (
+ image->raw_data->data, image->raw_data->length,
+ NULL, 0,
+ (void *)&data, &image->width, &image->height);
+ }
+
+ if (!ret)
+ return;
+
+ swfdec_cached_load (SWFDEC_CACHED (image), 4 * image->width * image->height);
+ image->surface = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_RGB24,
+ image->width, image->height, image->width * 4);
+ cairo_surface_set_user_data (image->surface, &key, data, g_free);
+
+ SWFDEC_LOG (" width = %d", image->width);
+ SWFDEC_LOG (" height = %d", image->height);
+}
+
+int
+tag_func_define_bits_jpeg_2 (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecBits *bits = &s->b;
+ int id;
+ SwfdecImage *image;
+
+ id = swfdec_bits_get_u16 (bits);
+ SWFDEC_LOG (" id = %d", id);
+
+ image = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_IMAGE);
+ if (!image)
+ return SWFDEC_STATUS_OK;
+
+ image->type = SWFDEC_IMAGE_TYPE_JPEG2;
+ image->raw_data = swfdec_bits_get_buffer (bits, -1);
+
+ return SWFDEC_STATUS_OK;
+}
+
+static void
+swfdec_image_jpeg2_load (SwfdecImage *image)
+{
+ gboolean ret;
+ guint8 *data;
+
+ ret = swfdec_jpeg_decode_argb (image->raw_data->data, image->raw_data->length,
+ NULL, 0,
+ (void *)&data, &image->width, &image->height);
+ if (!ret)
+ return;
+
+ swfdec_cached_load (SWFDEC_CACHED (image), 4 * image->width * image->height);
+ image->surface = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_RGB24,
+ image->width, image->height, image->width * 4);
+ cairo_surface_set_user_data (image->surface, &key, data, g_free);
+
+ SWFDEC_LOG (" width = %d", image->width);
+ SWFDEC_LOG (" height = %d", image->height);
+}
+
+int
+tag_func_define_bits_jpeg_3 (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecBits *bits = &s->b;
+ guint id;
+ SwfdecImage *image;
+
+ id = swfdec_bits_get_u16 (bits);
+ SWFDEC_LOG (" id = %d", id);
+
+ image = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_IMAGE);
+ if (!image)
+ return SWFDEC_STATUS_OK;
+
+ image->type = SWFDEC_IMAGE_TYPE_JPEG3;
+ image->raw_data = swfdec_bits_get_buffer (bits, -1);
+
+ return SWFDEC_STATUS_OK;
+}
+
+static void
+swfdec_image_jpeg3_load (SwfdecImage *image)
+{
+ SwfdecBits bits;
+ SwfdecBuffer *buffer;
+ int jpeg_length;
+ gboolean ret;
+ guint8 *data;
+
+ swfdec_bits_init (&bits, image->raw_data);
+
+ jpeg_length = swfdec_bits_get_u32 (&bits);
+ buffer = swfdec_bits_get_buffer (&bits, jpeg_length);
+ if (buffer == NULL)
+ return;
+
+ ret = swfdec_jpeg_decode_argb (buffer->data, buffer->length,
+ NULL, 0,
+ (void *)&data, &image->width, &image->height);
+ swfdec_buffer_unref (buffer);
+
+ if (!ret)
+ return;
+
+ swfdec_cached_load (SWFDEC_CACHED (image), 4 * image->width * image->height);
+
+ buffer = swfdec_bits_decompress (&bits, -1, image->width * image->height);
+ if (buffer) {
+ merge_alpha (image, data, buffer->data);
+ swfdec_buffer_unref (buffer);
+ } else {
+ SWFDEC_WARNING ("cannot set alpha channel information, decompression failed");
+ }
+
+ SWFDEC_LOG (" width = %d", image->width);
+ SWFDEC_LOG (" height = %d", image->height);
+
+ image->surface = cairo_image_surface_create_for_data (data,
+ CAIRO_FORMAT_ARGB32, image->width, image->height, image->width * 4);
+ cairo_surface_set_user_data (image->surface, &key, data, g_free);
+}
+
+static void
+merge_alpha (SwfdecImage * image, unsigned char *image_data,
+ unsigned char *alpha)
+{
+ int x, y;
+ unsigned char *p;
+
+ for (y = 0; y < image->height; y++) {
+ p = image_data + y * image->width * 4;
+ for (x = 0; x < image->width; x++) {
+ p[SWFDEC_COLOR_INDEX_ALPHA] = *alpha;
+ p += 4;
+ alpha++;
+ }
+ }
+}
+
+static void
+swfdec_image_lossless_load (SwfdecImage *image)
+{
+ int format;
+ guint color_table_size;
+ unsigned char *ptr;
+ SwfdecBits bits;
+ guint8 *data;
+ int have_alpha = (image->type == SWFDEC_IMAGE_TYPE_LOSSLESS2);
+
+ swfdec_bits_init (&bits, image->raw_data);
+
+ format = swfdec_bits_get_u8 (&bits);
+ SWFDEC_LOG (" format = %d", format);
+ image->width = swfdec_bits_get_u16 (&bits);
+ SWFDEC_LOG (" width = %d", image->width);
+ image->height = swfdec_bits_get_u16 (&bits);
+ SWFDEC_LOG (" height = %d", image->height);
+ if (format == 3) {
+ color_table_size = swfdec_bits_get_u8 (&bits) + 1;
+ } else {
+ color_table_size = 0;
+ }
+
+ SWFDEC_LOG ("format = %d", format);
+ SWFDEC_LOG ("width = %d", image->width);
+ SWFDEC_LOG ("height = %d", image->height);
+ SWFDEC_LOG ("color_table_size = %d", color_table_size);
+
+ if (image->width == 0 || image->height == 0)
+ return;
+ swfdec_cached_load (SWFDEC_CACHED (image), 4 * image->width * image->height);
+
+ if (format == 3) {
+ SwfdecBuffer *buffer;
+ unsigned char *indexed_data;
+ guint i;
+ guint rowstride = (image->width + 3) & ~3;
+
+ data = g_malloc (4 * image->width * image->height);
+
+ if (have_alpha) {
+ buffer = swfdec_bits_decompress (&bits, -1, color_table_size * 4 + rowstride * image->height);
+ if (buffer == NULL) {
+ SWFDEC_ERROR ("failed to decompress data");
+ memset (data, 0, 4 * image->width * image->height);
+ goto out;
+ }
+ ptr = buffer->data;
+ for (i = 0; i < color_table_size; i++) {
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+ guint8 tmp = ptr[i * 4 + 0];
+ ptr[i * 4 + 0] = ptr[i * 4 + 2];
+ ptr[i * 4 + 2] = tmp;
+#else
+ guint8 tmp = ptr[i * 4 + 3];
+ ptr[i * 4 + 3] = ptr[i * 4 + 2];
+ ptr[i * 4 + 2] = ptr[i * 4 + 1];
+ ptr[i * 4 + 1] = ptr[i * 4 + 0];
+ ptr[i * 4 + 0] = tmp;
+#endif
+ }
+ indexed_data = ptr + color_table_size * 4;
+ } else {
+ buffer = swfdec_bits_decompress (&bits, -1, color_table_size * 3 + rowstride * image->height);
+ if (buffer == NULL) {
+ SWFDEC_ERROR ("failed to decompress data");
+ memset (data, 0, 4 * image->width * image->height);
+ goto out;
+ }
+ ptr = buffer->data;
+ for (i = color_table_size - 1; i < color_table_size; i--) {
+ guint8 color[3];
+ color[0] = ptr[i * 3 + 0];
+ color[1] = ptr[i * 3 + 1];
+ color[2] = ptr[i * 3 + 2];
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+ ptr[i * 4 + 0] = color[2];
+ ptr[i * 4 + 1] = color[1];
+ ptr[i * 4 + 2] = color[0];
+ ptr[i * 4 + 3] = 255;
+#else
+ ptr[i * 4 + 0] = 255;
+ ptr[i * 4 + 1] = color[0];
+ ptr[i * 4 + 2] = color[1];
+ ptr[i * 4 + 3] = color[2];
+#endif
+ }
+ indexed_data = ptr + color_table_size * 3;
+ }
+ swfdec_image_colormap_decode (image, data, indexed_data,
+ ptr, color_table_size);
+
+ swfdec_buffer_unref (buffer);
+ } else if (format == 4) {
+ int i, j;
+ guint c;
+ unsigned char *idata;
+ SwfdecBuffer *buffer;
+
+ if (have_alpha) {
+ SWFDEC_INFO("16bit images aren't allowed to have alpha, ignoring");
+ have_alpha = FALSE;
+ }
+
+ buffer = swfdec_bits_decompress (&bits, -1, 2 * ((image->width + 1) & ~1) * image->height);
+ data = g_malloc (4 * image->width * image->height);
+ idata = data;
+ if (buffer == NULL) {
+ SWFDEC_ERROR ("failed to decompress data");
+ memset (data, 0, 4 * image->width * image->height);
+ goto out;
+ }
+ ptr = buffer->data;
+
+ /* 15 bit packed */
+ for (j = 0; j < image->height; j++) {
+ for (i = 0; i < image->width; i++) {
+ c = ptr[1] | (ptr[0] << 8);
+ idata[SWFDEC_COLOR_INDEX_BLUE] = (c << 3) | ((c >> 2) & 0x7);
+ idata[SWFDEC_COLOR_INDEX_GREEN] = ((c >> 2) & 0xf8) | ((c >> 7) & 0x7);
+ idata[SWFDEC_COLOR_INDEX_RED] = ((c >> 7) & 0xf8) | ((c >> 12) & 0x7);
+ idata[SWFDEC_COLOR_INDEX_ALPHA] = 0xff;
+ ptr += 2;
+ idata += 4;
+ }
+ if (image->width & 1)
+ ptr += 2;
+ }
+ swfdec_buffer_unref (buffer);
+ } else if (format == 5) {
+ SwfdecBuffer *buffer;
+ int i, j;
+ guint32 *p;
+
+ buffer = swfdec_bits_decompress (&bits, -1, 4 * image->width * image->height);
+ if (buffer == NULL) {
+ SWFDEC_ERROR ("failed to decompress data");
+ data = g_malloc0 (4 * image->width * image->height);
+ goto out;
+ }
+ data = buffer->data;
+ p = (void *) data;
+ /* image is stored in 0RGB format. We use ARGB/BGRA. */
+ for (j = 0; j < image->height; j++) {
+ for (i = 0; i < image->width; i++) {
+ *p = GUINT32_FROM_BE (*p);
+ p++;
+ }
+ }
+ /* FIXME: this can fail if the returned buffer does not contain malloc'd
+ * data at some point in the future */
+ buffer->data = NULL;
+ buffer->length = 0;
+ swfdec_buffer_unref (buffer);
+ } else {
+ SWFDEC_ERROR ("unknown lossless image format %u", format);
+ return;
+ }
+
+out:
+ image->surface = cairo_image_surface_create_for_data (data,
+ have_alpha ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24,
+ image->width, image->height, image->width * 4);
+ cairo_surface_set_user_data (image->surface, &key, data, g_free);
+}
+
+int
+tag_func_define_bits_lossless (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecImage *image;
+ int id;
+ SwfdecBits *bits = &s->b;
+
+ id = swfdec_bits_get_u16 (bits);
+ SWFDEC_LOG (" id = %d", id);
+
+ image = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_IMAGE);
+ if (!image)
+ return SWFDEC_STATUS_OK;
+
+ image->type = SWFDEC_IMAGE_TYPE_LOSSLESS;
+ image->raw_data = swfdec_bits_get_buffer (bits, -1);
+
+ return SWFDEC_STATUS_OK;
+}
+
+int
+tag_func_define_bits_lossless_2 (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecImage *image;
+ int id;
+ SwfdecBits *bits = &s->b;
+
+ id = swfdec_bits_get_u16 (bits);
+ SWFDEC_LOG (" id = %d", id);
+
+ image = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_IMAGE);
+ if (!image)
+ return SWFDEC_STATUS_OK;
+
+ image->type = SWFDEC_IMAGE_TYPE_LOSSLESS2;
+ image->raw_data = swfdec_bits_get_buffer (bits, -1);
+
+ return SWFDEC_STATUS_OK;
+}
+
+static void
+swfdec_image_colormap_decode (SwfdecImage * image,
+ unsigned char *dest,
+ unsigned char *src, unsigned char *colormap, int colormap_len)
+{
+ int c;
+ int i;
+ int j;
+ int rowstride;
+
+ rowstride = (image->width + 3) & ~0x3;
+ SWFDEC_DEBUG ("rowstride %d", rowstride);
+
+ for (j = 0; j < image->height; j++) {
+ for (i = 0; i < image->width; i++) {
+ c = src[i];
+ if (colormap_len < 256 && c == 255) {
+ dest[0] = 0;
+ dest[1] = 0;
+ dest[2] = 0;
+ dest[3] = 0;
+ } else if (c >= colormap_len) {
+ SWFDEC_ERROR ("colormap index out of range (%d>=%d) (%d,%d)",
+ c, colormap_len, i, j);
+ dest[0] = 0;
+ dest[1] = 0;
+ dest[2] = 0;
+ dest[3] = 0;
+ } else {
+ memmove (dest, &colormap[c*4], 4);
+ }
+ dest += 4;
+ }
+ src += rowstride;
+ }
+}
+
+static cairo_status_t
+swfdec_image_png_read (void *bitsp, unsigned char *data, unsigned int length)
+{
+ SwfdecBits *bits = bitsp;
+ const guint8 *ptr;
+
+ ptr = bits->ptr;
+ if (swfdec_bits_skip_bytes (bits, length) != length)
+ return CAIRO_STATUS_READ_ERROR;
+
+ memcpy (data, ptr, length);
+ return CAIRO_STATUS_SUCCESS;
+}
+
+static void
+swfdec_image_png_load (SwfdecImage *image)
+{
+ SwfdecBits bits;
+
+ swfdec_bits_init (&bits, image->raw_data);
+ image->surface = cairo_image_surface_create_from_png_stream (
+ swfdec_image_png_read, &bits);
+ image->width = cairo_image_surface_get_width (image->surface);
+ image->height = cairo_image_surface_get_height (image->surface);
+ swfdec_cached_load (SWFDEC_CACHED (image), image->height *
+ cairo_image_surface_get_stride (image->surface));
+}
+
+cairo_surface_t *
+swfdec_image_create_surface (SwfdecImage *image)
+{
+ if (image->raw_data == NULL)
+ return NULL;
+
+ if (image->surface == NULL) {
+ switch (image->type) {
+ case SWFDEC_IMAGE_TYPE_JPEG:
+ swfdec_image_jpeg_load (image);
+ break;
+ case SWFDEC_IMAGE_TYPE_JPEG2:
+ swfdec_image_jpeg2_load (image);
+ break;
+ case SWFDEC_IMAGE_TYPE_JPEG3:
+ swfdec_image_jpeg3_load (image);
+ break;
+ case SWFDEC_IMAGE_TYPE_LOSSLESS:
+ swfdec_image_lossless_load (image);
+ break;
+ case SWFDEC_IMAGE_TYPE_LOSSLESS2:
+ swfdec_image_lossless_load (image);
+ break;
+ case SWFDEC_IMAGE_TYPE_PNG:
+ swfdec_image_png_load (image);
+ break;
+ case SWFDEC_IMAGE_TYPE_UNKNOWN:
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+ if (image->surface == NULL) {
+ SWFDEC_WARNING ("failed to decode image");
+ return NULL;
+ }
+ } else {
+ swfdec_cached_use (SWFDEC_CACHED (image));
+ }
+ return cairo_surface_reference (image->surface);
+}
+
+cairo_surface_t *
+swfdec_image_create_surface_transformed (SwfdecImage *image, const SwfdecColorTransform *trans)
+{
+ cairo_surface_t *surface, *source;
+ guint32 *tdata;
+ const guint32 *sdata;
+ guint i, n;
+ gboolean has_alpha = FALSE;
+
+ g_return_val_if_fail (SWFDEC_IS_IMAGE (image), NULL);
+ g_return_val_if_fail (trans != NULL, NULL);
+
+ /* obvious optimization */
+ if (swfdec_color_transform_is_identity (trans))
+ return swfdec_image_create_surface (image);
+
+ source = swfdec_image_create_surface (image);
+ tdata = g_try_malloc (image->width * image->height * 4);
+ if (!tdata) {
+ SWFDEC_ERROR ("failed to allocate memory for transformed image");
+ cairo_surface_destroy (source);
+ return NULL;
+ }
+ /* FIXME: This code assumes a rowstride of 4 * width */
+ /* FIXME: This code assumes an alignment of 4 */
+ sdata = (void *) cairo_image_surface_get_data (source);
+ n = image->width * image->height;
+ for (i = 0; i < n; i++) {
+ tdata[i] = swfdec_color_apply_transform_premultiplied (sdata[i], trans);
+ /* optimization: check for alpha channel to speed up compositing */
+ has_alpha |= SWFDEC_COLOR_A (tdata[i]) != 0xFF;
+ }
+ cairo_surface_destroy (source);
+ surface = cairo_image_surface_create_for_data ((unsigned char *) tdata,
+ has_alpha ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24,
+ image->width, image->height, image->width * 4);
+ cairo_surface_set_user_data (surface, &key, tdata, g_free);
+ return surface;
+}
+
+/* NB: must be at least SWFDEC_DECODER_DETECT_LENGTH bytes */
+SwfdecImageType
+swfdec_image_detect (const guint8 *data)
+{
+ g_return_val_if_fail (data != NULL, SWFDEC_IMAGE_TYPE_UNKNOWN);
+
+ if (data[0] == 0xFF && data[1] == 0xD8)
+ return SWFDEC_IMAGE_TYPE_JPEG2;
+ else if (data[0] == 0x89 && data[1] == 'P' &&
+ data[2] == 'N' && data[3] == 'G')
+ return SWFDEC_IMAGE_TYPE_PNG;
+ else
+ return SWFDEC_IMAGE_TYPE_UNKNOWN;
+}
+
+SwfdecImage *
+swfdec_image_new (SwfdecBuffer *buffer)
+{
+ SwfdecImage *image;
+ SwfdecImageType type;
+
+ g_return_val_if_fail (buffer != NULL, NULL);
+
+ /* check type of the image */
+ if (buffer->length < 4)
+ goto fail;
+ type = swfdec_image_detect (buffer->data);
+ if (type == SWFDEC_IMAGE_TYPE_UNKNOWN)
+ goto fail;
+
+ image = g_object_new (SWFDEC_TYPE_IMAGE, NULL);
+ image->type = type;
+ image->raw_data = buffer;
+
+ return image;
+
+fail:
+ swfdec_buffer_unref (buffer);
+ return NULL;
+}
diff --git a/swfdec/swfdec_image.h b/swfdec/swfdec_image.h
new file mode 100644
index 0000000..e648e08
--- /dev/null
+++ b/swfdec/swfdec_image.h
@@ -0,0 +1,84 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_IMAGE_H_
+#define _SWFDEC_IMAGE_H_
+
+#include <cairo.h>
+#include <libswfdec/swfdec_cached.h>
+#include <libswfdec/swfdec_decoder.h>
+
+G_BEGIN_DECLS
+//typedef struct _SwfdecImage SwfdecImage;
+typedef struct _SwfdecImageClass SwfdecImageClass;
+
+#define SWFDEC_TYPE_IMAGE (swfdec_image_get_type())
+#define SWFDEC_IS_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_IMAGE))
+#define SWFDEC_IS_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_IMAGE))
+#define SWFDEC_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_IMAGE, SwfdecImage))
+#define SWFDEC_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_IMAGE, SwfdecImageClass))
+
+typedef enum {
+ SWFDEC_IMAGE_TYPE_UNKNOWN = 0,
+ SWFDEC_IMAGE_TYPE_JPEG,
+ SWFDEC_IMAGE_TYPE_JPEG2,
+ SWFDEC_IMAGE_TYPE_JPEG3,
+ SWFDEC_IMAGE_TYPE_LOSSLESS,
+ SWFDEC_IMAGE_TYPE_LOSSLESS2,
+ /* those can only be created by loading from files */
+ SWFDEC_IMAGE_TYPE_PNG
+} SwfdecImageType;
+
+struct _SwfdecImage {
+ SwfdecCached cached;
+
+ int width; /* width of image or 0 if not known yet */
+ int height; /* height of image or 0 if not known yet */
+ cairo_surface_t * surface; /* surface when cache loaded or NULL */
+
+ SwfdecImageType type;
+ SwfdecBuffer * jpegtables;
+ SwfdecBuffer * raw_data;
+};
+
+struct _SwfdecImageClass {
+ SwfdecCachedClass cached_class;
+
+};
+
+GType swfdec_image_get_type (void);
+
+SwfdecImageType swfdec_image_detect (const guint8 * data);
+SwfdecImage * swfdec_image_new (SwfdecBuffer * buffer);
+cairo_surface_t * swfdec_image_create_surface (SwfdecImage * image);
+cairo_surface_t * swfdec_image_create_surface_transformed
+ (SwfdecImage * image,
+ const SwfdecColorTransform *trans);
+
+int swfdec_image_jpegtables (SwfdecSwfDecoder * s, guint tag);
+int tag_func_define_bits_jpeg (SwfdecSwfDecoder * s, guint tag);
+int tag_func_define_bits_jpeg_2 (SwfdecSwfDecoder * s, guint tag);
+int tag_func_define_bits_jpeg_3 (SwfdecSwfDecoder * s, guint tag);
+int tag_func_define_bits_lossless (SwfdecSwfDecoder * s, guint tag);
+int tag_func_define_bits_lossless_2 (SwfdecSwfDecoder * s, guint tag);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_image_decoder.c b/swfdec/swfdec_image_decoder.c
new file mode 100644
index 0000000..17edf90
--- /dev/null
+++ b/swfdec/swfdec_image_decoder.c
@@ -0,0 +1,131 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_image_decoder.h"
+#include "swfdec_debug.h"
+#include "swfdec_image.h"
+
+G_DEFINE_TYPE (SwfdecImageDecoder, swfdec_image_decoder, SWFDEC_TYPE_DECODER)
+
+static void
+swfdec_image_decoder_dispose (GObject *object)
+{
+ SwfdecImageDecoder *image = SWFDEC_IMAGE_DECODER (object);
+
+ if (image->queue) {
+ swfdec_buffer_queue_unref (image->queue);
+ image->queue = NULL;
+ }
+
+ if (image->image) {
+ g_object_unref (image->image);
+ image->image = NULL;
+ }
+
+ G_OBJECT_CLASS (swfdec_image_decoder_parent_class)->dispose (object);
+}
+
+static SwfdecStatus
+swfdec_image_decoder_parse (SwfdecDecoder *dec, SwfdecBuffer *buffer)
+{
+ SwfdecImageDecoder *image = SWFDEC_IMAGE_DECODER (dec);
+
+ if (image->queue == NULL)
+ image->queue = swfdec_buffer_queue_new ();
+ swfdec_buffer_queue_push (image->queue, buffer);
+ dec->bytes_loaded += buffer->length;
+ if (dec->bytes_loaded < dec->bytes_total)
+ dec->bytes_total = dec->bytes_loaded;
+ return 0;
+}
+
+/* FIXME: move this to swfdec_image API? */
+static gboolean
+swfdec_image_get_size (SwfdecImage *image, guint *w, guint *h)
+{
+ cairo_surface_t *surface;
+
+ surface = swfdec_image_create_surface (image);
+ if (surface == NULL)
+ return FALSE;
+
+ if (w)
+ *w = cairo_image_surface_get_width (surface);
+ if (h)
+ *h = cairo_image_surface_get_width (surface);
+
+ cairo_surface_destroy (surface);
+
+ return TRUE;
+}
+
+static SwfdecStatus
+swfdec_image_decoder_eof (SwfdecDecoder *dec)
+{
+ SwfdecImageDecoder *image = SWFDEC_IMAGE_DECODER (dec);
+ SwfdecBuffer *buffer;
+ guint depth;
+
+ if (image->queue == NULL)
+ return 0;
+ depth = swfdec_buffer_queue_get_depth (image->queue);
+ if (depth == 0) {
+ swfdec_buffer_queue_unref (image->queue);
+ image->queue = NULL;
+ return SWFDEC_STATUS_ERROR;
+ }
+ buffer = swfdec_buffer_queue_pull (image->queue,
+ swfdec_buffer_queue_get_depth (image->queue));
+ swfdec_buffer_queue_unref (image->queue);
+ image->queue = NULL;
+ image->image = swfdec_image_new (buffer);
+ if (!swfdec_image_get_size (image->image, &dec->width, &dec->height))
+ return SWFDEC_STATUS_ERROR;
+ dec->frames_loaded = 1;
+ dec->frames_total = 1;
+ if (image->image->type == SWFDEC_IMAGE_TYPE_JPEG)
+ dec->data_type = SWFDEC_LOADER_DATA_JPEG;
+ else if (image->image->type == SWFDEC_IMAGE_TYPE_PNG)
+ dec->data_type = SWFDEC_LOADER_DATA_PNG;
+
+
+ return SWFDEC_STATUS_INIT | SWFDEC_STATUS_IMAGE;
+}
+
+static void
+swfdec_image_decoder_class_init (SwfdecImageDecoderClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ SwfdecDecoderClass *decoder_class = SWFDEC_DECODER_CLASS (class);
+
+ object_class->dispose = swfdec_image_decoder_dispose;
+
+ decoder_class->parse = swfdec_image_decoder_parse;
+ decoder_class->eof = swfdec_image_decoder_eof;
+}
+
+static void
+swfdec_image_decoder_init (SwfdecImageDecoder *s)
+{
+}
+
diff --git a/swfdec/swfdec_image_decoder.h b/swfdec/swfdec_image_decoder.h
new file mode 100644
index 0000000..b5f3a84
--- /dev/null
+++ b/swfdec/swfdec_image_decoder.h
@@ -0,0 +1,59 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SWFDEC_IMAGE_DECODER_H__
+#define __SWFDEC_IMAGE_DECODER_H__
+
+#include <glib.h>
+
+#include <libswfdec/swfdec_decoder.h>
+#include <libswfdec/swfdec_bits.h>
+#include <libswfdec/swfdec_types.h>
+#include <libswfdec/swfdec_rect.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecImageDecoder SwfdecImageDecoder;
+typedef struct _SwfdecImageDecoderClass SwfdecImageDecoderClass;
+
+#define SWFDEC_TYPE_IMAGE_DECODER (swfdec_image_decoder_get_type())
+#define SWFDEC_IS_IMAGE_DECODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_IMAGE_DECODER))
+#define SWFDEC_IS_IMAGE_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_IMAGE_DECODER))
+#define SWFDEC_IMAGE_DECODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_IMAGE_DECODER, SwfdecImageDecoder))
+#define SWFDEC_IMAGE_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_IMAGE_DECODER, SwfdecImageDecoderClass))
+#define SWFDEC_IMAGE_DECODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_IMAGE_DECODER, SwfdecImageDecoderClass))
+
+struct _SwfdecImageDecoder
+{
+ SwfdecDecoder decoder;
+
+ SwfdecBufferQueue * queue; /* keeps the data while decoding */
+ SwfdecImage * image; /* the image we display */
+};
+
+struct _SwfdecImageDecoderClass {
+ SwfdecDecoderClass decoder_class;
+};
+
+GType swfdec_image_decoder_get_type (void);
+
+
+G_END_DECLS
+
+#endif
diff --git a/swfdec/swfdec_initialize.as b/swfdec/swfdec_initialize.as
new file mode 100644
index 0000000..ed643b9
--- /dev/null
+++ b/swfdec/swfdec_initialize.as
@@ -0,0 +1,1521 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+/*** GENERAL ***/
+
+ASSetPropFlags = ASnative (1, 0);
+ASSetNative = ASnative (4, 0);
+ASSetNativeAccessor = ASnative (4, 1);
+
+flash = {};
+
+/*** Object ***/
+/* Only Flash extensions here, rest to swfdec_as_initialize.as */
+
+Object.registerClass = ASnative(101, 8);
+ASSetPropFlags (Object, null, 7);
+
+// so we can use it in this script
+ASSetPropFlags (Object, "addProperty", 0, 128);
+
+/*** Error ***/
+
+function Error (msg) {
+ if (typeof (msg) != "undefined")
+ this.message = msg;
+}
+Error.prototype.name = Error.prototype.message = "Error";
+Error.prototype.toString = function () {
+ return this.message;
+};
+
+/*** ASBROADCASTER ***/
+
+function AsBroadcaster () { };
+
+AsBroadcaster.broadcastMessage = ASnative(101, 12);
+
+AsBroadcaster.addListener = function (x) {
+ this.removeListener (x);
+ this._listeners.push (x);
+ return true;
+};
+
+AsBroadcaster.removeListener = function (x) {
+ var l = this._listeners;
+ var i;
+
+ for (var i = 0; i < l.length; i++) {
+ if (l[i] == x) {
+ l.splice (i, 1);
+ return true;
+ }
+ }
+ return false;
+};
+
+AsBroadcaster.initialize = function (o) {
+ o.broadcastMessage = ASnative(101, 12);
+ o.addListener = AsBroadcaster.addListener;
+ o.removeListener = AsBroadcaster.removeListener;
+ o._listeners = [];
+ ASSetPropFlags(o, "broadcastMessage,addListener,removeListener,_listeners", 131);
+};
+
+Key = { ALT: 18, BACKSPACE: 8, CAPSLOCK: 20, CONTROL: 17, DELETEKEY: 46,
+ DOWN: 40, END: 35, ENTER: 13, ESCAPE: 27, HOME: 36, INSERT: 45, LEFT: 37,
+ PGDN: 34, PGUP: 33, RIGHT: 39, SHIFT: 16, SPACE: 32, TAB: 9, UP: 38 };
+ASSetNative(Key, 800, "getAscii,getCode,isDown,isToggled,isAccessible");
+AsBroadcaster.initialize(Key);
+ASSetPropFlags(Key, null, 7);
+
+/*** MOUSE ***/
+
+Mouse = { };
+Mouse.show = ASnative (5, 0);
+Mouse.hide = ASnative (5, 1);
+AsBroadcaster.initialize (Mouse);
+ASSetPropFlags(Mouse, null, 7);
+
+/*** STAGE ***/
+
+Stage = { };
+AsBroadcaster.initialize (Stage);
+ASSetNativeAccessor (Stage, 666, "scaleMode,align,width,height,showMenu,displayState", 1);
+ASSetNativeAccessor (Stage, 666, "9fullScreenSourceRect,9fullScreenHeight,9fullScreenWidth", 100);
+
+/*** NetConnection ***/
+
+// FIXME: this should actually be a non-native function that calls the ASnative
+// function
+NetConnection = ASconstructor (2100, 200);
+
+ASSetNative (NetConnection.prototype, 2100, "6connect,6close,6call,6addHeader");
+NetConnection.prototype.addProperty ("connectedProxyType", ASnative (2100, 4), null);
+NetConnection.prototype.proxyType = "none";
+NetConnection.prototype.addProperty ("usingTLS", ASnative (2100, 5), null);
+ASSetPropFlags (NetConnection.prototype, null, 3);
+
+/*** NetStream ***/
+
+NetStream.prototype.publish = function () {
+ var o = {}; o["Implement NetStream.publish"] ();
+};
+
+NetStream.prototype.receiveAudio = function (flag) {
+ var o = {}; o["Implement NetStream.receiveAudio"] ();
+};
+
+NetStream.prototype.receiveVideo = function (flag) {
+ var o = {}; o["Implement NetStream.receiveVideo"] ();
+};
+
+ASSetNative (NetStream.prototype, 2101, "6close,6attachAudio,6attachVideo,6send,6setBufferTime");
+ASSetNativeAccessor (NetStream.prototype, 2101, "checkPolicyFile", 5);
+ASSetPropFlags (NetStream.prototype, null, 3);
+
+/*** LOADVARS ***/
+
+function LoadVars () { };
+
+LoadVars.prototype.contentType = "application/x-www-form-urlencoded";
+
+LoadVars.prototype.load = ASnative (301, 0);
+LoadVars.prototype.send = ASnative (301, 1);
+LoadVars.prototype.sendAndLoad = ASnative (301, 2);
+LoadVars.prototype.decode = ASnative (301, 3);
+
+LoadVars.prototype.onLoad = function () {
+};
+
+LoadVars.prototype.onData = function (src) {
+ this.loaded = true;
+ if (src != null) {
+ this.decode (src);
+ this.onLoad (true);
+ } else {
+ this.onLoad (false);
+ }
+};
+
+LoadVars.prototype.toString = function () {
+ var str = null;
+ for (var x in this) {
+ if (str == null) {
+ str = escape(x) + "=" + escape(this[x]);
+ } else {
+ str += "&" + escape(x) + "=" + escape(this[x]);
+ }
+ }
+ return str;
+};
+
+LoadVars.prototype.getBytesLoaded = function () {
+ return this._bytesLoaded;
+};
+
+LoadVars.prototype.getBytesTotal = function () {
+ return this._bytesTotal;
+};
+
+LoadVars.prototype.addRequestHeader = function () {
+ // Same as XML?
+ var o = {}; o["Implement LoadVars.addRequestHeader"] ();
+};
+
+ASSetPropFlags(LoadVars.prototype, null, 131);
+
+/*** Sound ***/
+
+Sound = ASconstructor (500, 16);
+ASSetNative (Sound.prototype, 500, "getPan,getTransform,getVolume,setPan,setTransform,setVolume,stop,attachSound,start,6getDuration,6setDuration,6getPosition,6setPosition,6loadSound,6getBytesLoaded,6getBytesTotal,9areSoundsInaccessible");
+ASSetNativeAccessor (Sound.prototype, 500, "checkPolicyFile", 18);
+ASSetPropFlags (Sound.prototype, null, 7);
+
+/*** XMLNode ***/
+
+XMLNode = ASconstructor (253, 0);
+
+XMLNode.prototype.cloneNode = ASnative (253, 1);
+XMLNode.prototype.removeNode = ASnative (253, 2);
+XMLNode.prototype.insertBefore = ASnative (253, 3);
+XMLNode.prototype.appendChild = ASnative (253, 4);
+XMLNode.prototype.hasChildNodes = ASnative (253, 5);
+XMLNode.prototype.toString = ASnative (253, 6);
+XMLNode.prototype.getNamespaceForPrefix = ASnative (253, 7);
+XMLNode.prototype.getPrefixForNamespace = ASnative (253, 8);
+
+/*** XML ***/
+
+XML = ASconstructor (253, 9);
+
+XML.prototype = new XMLNode (1, "");
+delete XML.prototype.constructor;
+ASSetPropFlags (XML, "prototype", 3);
+
+XML.prototype.load = ASnative (301, 0);
+XML.prototype.send = ASnative (301, 1);
+XML.prototype.sendAndLoad = ASnative (301, 2);
+XML.prototype.createElement = ASnative (253, 10);
+XML.prototype.createTextNode = ASnative (253, 11);
+XML.prototype.parseXML = ASnative (253, 12);
+
+XML.prototype.onLoad = function () {
+};
+
+// Note: handling of loaded is different here than in LoadVars
+XML.prototype.onData = function (src) {
+ if (src != null) {
+ this.loaded = true;
+ this.parseXML (src);
+ this.onLoad (true);
+ } else {
+ this.loaded = false;
+ this.onLoad (false);
+ }
+};
+
+XML.prototype.getBytesLoaded = function () {
+ return this._bytesLoaded;
+};
+
+XML.prototype.getBytesTotal = function () {
+ return this._bytesTotal;
+};
+
+XML.prototype.addRequestHeader = function () {
+ // Same as LoadVars?
+ var o = {}; o["Implement XML.addRequestHeader"] ();
+};
+
+/*** System ***/
+
+System = {};
+
+System.capabilities = {};
+System.capabilities.Query = ASnative (11, 0);
+System.capabilities.Query ();
+delete System.capabilities.Query;
+
+System.setClipboard = ASnative (1066, 0);
+System.showSettings = ASnative (2107, 0);
+ASSetNativeAccessor (System, 2107, "exactSettings,useCodepage", 1);
+ASSetPropFlags (System, "exactSettings,useCodePage", 128);
+
+/*** System.security */
+
+System.security = new Object();
+delete System.security.constructor;
+ASSetNative (System.security, 12, "allowDomain,7allowInsecureDomain,loadPolicyFile,chooseLocalSwfPath,escapeDomain");
+ASSetNativeAccessor (System.security, 12, "sandboxType", 5);
+
+/*** System.security.PolicyFileResolver */
+
+System.security.PolicyFileResolver = function () {
+ var o = {}; o["Implement System.security.PolicyFileResolver"] ();
+};
+System.security.PolicyFileResolver.prototype.resolve = ASnative (15, 0);
+AsBroadcaster.initialize (System.security.PolicyFileResolver.prototype);
+
+/*** System.Product ***/
+
+System.Product = function () {
+ var o = {}; o["Implement System.Product"] ();
+};
+
+System.Product.prototype.isRunning = function () {
+ var o = {}; o["Implement System.Product.isRunning"] ();
+};
+
+System.Product.prototype.isInstalled = function () {
+ var o = {}; o["Implement System.Product.isInstalled"] ();
+};
+
+System.Product.prototype.launch = function () {
+ var o = {}; o["Implement System.Product.launch"] ();
+};
+
+System.Product.prototype.download = function () {
+ var o = {}; o["Implement System.Product.download"] ();
+};
+
+System.Product.prototype.installedVersion = function () {
+ var o = {}; o["Implement System.Product.installedVersion"] ();
+};
+
+System.Product.prototype.validate = function () {
+ var o = {}; o["Implement System.Product.validate"] ();
+};
+
+ASSetPropFlags (System.Product.prototype, null, 3);
+
+/*** System.IME ***/
+
+System.IME = {
+ ALPHANUMERIC_FULL: "ALPHANUMERIC_FULL",
+ ALPHANUMERIC_HALF: "ALPHANUMERIC_HALF",
+ CHINESE: "CHINESE",
+ JAPANESE_HIRAGANA: "JAPANESE_HIRAGANA",
+ JAPANESE_KATAKANA_FULL: "JAPANESE_KATAKANA_FULL",
+ JAPANESE_KATAKANA_HALF: "JAPANESE_KATAKANA_HALF",
+ KOREAN: "KOREAN",
+ UNKNOWN: "UNKNOWN"
+};
+
+AsBroadcaster.initialize (System.IME);
+
+ASSetNative (System.IME, 13, "8getEnabled,8setEnabled,8getConversionMode,8setConversionMode,8setCompositionString,8doConversion");
+ASSetPropFlags (System.IME, null, 7);
+
+/*** Color ***/
+
+Color = function (target) {
+ this.target = target;
+ ASSetPropFlags (this, null, 7);
+};
+ASSetNative (Color.prototype, 700, "setRGB,setTransform,getRGB,getTransform");
+ASSetPropFlags (Color.prototype, null, 7);
+
+/* TextSnapshot */
+
+TextSnapshot = ASconstructor (1067, 0);
+ASSetNative (TextSnapshot.prototype, 1067, "6getCount,6setSelected,6getSelected,6getText,6getSelectedText,6hitTestTextNearPos,6findText,6setSelectColor,6getTextRunInfo", 1);
+
+/* MovieClip */
+
+MovieClip.prototype.useHandCursor = true;
+MovieClip.prototype.enabled = true;
+
+MovieClip.prototype.meth = function (method) {
+ var lower = method.toLowerCase ();
+ if (lower == "post") {
+ return 2;
+ } else if (lower == "get") {
+ return 1;
+ } else {
+ return 0;
+ }
+};
+
+MovieClip.prototype.getURL = function (url, target, method) {
+ if (typeof (target) == "undefined")
+ target = ""; // undefined to empty string, even in version >= 7
+
+ var type = this.meth (method);
+ if (type == 0) {
+ getURL (url, target);
+ } else if (type == 1) {
+ getURL (url, target, "GET");
+ } else {
+ getURL (url, target, "POST");
+ }
+};
+
+// work around ming bug, causing loadVariables to be lower cased
+MovieClip.prototype["loadVariables"] = function (url, method) {
+ var type = this.meth (method);
+ setTarget (this);
+ if (type == 0) {
+ loadVariables (url, this._target);
+ } else if (type == 1) {
+ loadVariables (url, this._target, "GET");
+ } else {
+ loadVariables (url, this._target, "POST");
+ }
+ setTarget ("");
+};
+
+// work around ming bug, causing loadMovie to be lower cased
+MovieClip.prototype["loadMovie"] = function (url, method) {
+ var type = this.meth (method);
+ setTarget (this);
+ if (type == 0) {
+ loadMovie (url, this._target);
+ } else if (type == 1) {
+ loadMovie (url, this._target, "GET");
+ } else {
+ loadMovie (url, this._target, "POST");
+ }
+ setTarget ("");
+};
+
+MovieClip.prototype.unloadMovie = function () {
+ setTarget (this);
+ loadMovie ("", this._target);
+ setTarget ("");
+};
+
+MovieClip.prototype.getTextSnapshot = function () {
+ return new TextSnapshot(this);
+};
+ASSetPropFlags (MovieClip.prototype, "getTextSnapshot", 128);
+
+
+ASSetNative (MovieClip.prototype, 900, "attachMovie,swapDepths,localToGlobal,globalToLocal,hitTest,getBounds,getBytesTotal,getBytesLoaded,6attachAudio,6attachVideo,6getDepth,6setMask,play,stop,nextFrame,prevFrame,gotoAndPlay,gotoAndStop,duplicateMovieClip,removeMovieClip,startDrag,stopDrag,7getNextHighestDepth,7getInstanceAtDepth,getSWFVersion,8attachBitmap,8getRect");
+ASSetNativeAccessor (MovieClip.prototype, 900, "tabIndex", 200);
+ASSetNativeAccessor (MovieClip.prototype, 900, "_lockroot", 300);
+ASSetNativeAccessor (MovieClip.prototype, 900, "8cacheAsBitmap,8opaqueBackground,8scrollRect", 401);
+ASSetNativeAccessor (MovieClip.prototype, 900, "8filters,8transform", 417);
+ASSetNativeAccessor (MovieClip.prototype, 900, "8blendMode", 500);
+
+ASSetNative (MovieClip.prototype, 901, "6createEmptyMovieClip,6beginFill,6beginGradientFill,6moveTo,6lineTo,6curveTo,6lineStyle,6endFill,6clear,8lineGradientStyle,8beginMeshFill,8beginBitmapFill");
+ASSetNativeAccessor (MovieClip.prototype, 901, "8scale9Grid", 12);
+
+MovieClip.prototype.createTextField = ASnative (104, 200);
+
+ASSetPropFlags (MovieClip.prototype, null, 3);
+
+/* MovieClipLoader */
+
+MovieClipLoader = ASconstructor (112, 0);
+ASSetNative(MovieClipLoader.prototype, 112, "7loadClip,7getProgress,7unloadClip", 100);
+AsBroadcaster.initialize(MovieClipLoader.prototype);
+ASSetPropFlags(MovieClipLoader.prototype, null, 1027);
+
+/* TextField */
+
+TextField = ASconstructor (104, 0);
+TextField.getFontList = ASnative (104, 201);
+
+ASSetNative (TextField.prototype, 104, "6replaceSel,6getTextFormat,6setTextFormat,6removeTextField,6getNewTextFormat,6setNewTextFormat,6getDepth,7replaceText", 100);
+AsBroadcaster.initialize (TextField.prototype);
+
+ASSetPropFlags (TextField.prototype, null, 131);
+
+ASSetNativeAccessor (TextField.prototype, 104, "8gridFitType,8antiAliasType,8thickness,8sharpness,8filters", 300);
+// FIXME: this should be done inside the TextField constructor
+ASSetNativeAccessor (TextField.prototype, 900, "8tabIndex", 200);
+
+ASSetPropFlags (TextField, null, 131);
+
+/* TextFormat */
+
+TextFormat = ASconstructor (110, 0);
+
+/* TextField.Stylesheet */
+
+TextField.StyleSheet = ASconstructor (113, 0);
+
+TextField.StyleSheet.prototype._copy = function (o) {
+ if (typeof (o) != "object")
+ return null;
+
+ var o_new = {};
+ for (var prop in o) {
+ o_new[prop] = o[prop];
+ }
+ return o_new;
+};
+
+TextField.StyleSheet.prototype.clear = function () {
+ this._css = {};
+ this._styles = {};
+ this.update ();
+};
+
+TextField.StyleSheet.prototype.getStyle = function (name) {
+ return (this._copy (this._css[name]));
+};
+
+TextField.StyleSheet.prototype.setStyle = function (name, style) {
+ if (!this._css)
+ this._css = {};
+
+ this._css[name] = this._copy (style);
+ this.doTransform (name);
+ this.update ();
+};
+
+TextField.StyleSheet.prototype.getStyleNames = function () {
+ var tmp = this._css; /* ming bug? */
+ var names = [];
+ for (var prop in tmp) {
+ names.push (prop);
+ }
+ return names;
+};
+
+TextField.StyleSheet.prototype.doTransform = function (name) {
+ if (!this._styles) {
+ this._styles = {};
+ }
+ this._styles[name] = this.transform (this._css[name]);
+};
+
+TextField.StyleSheet.prototype.transform = function (style) {
+ if (style == null)
+ return null;
+
+ var format = new TextFormat ();
+
+ if (style.textAlign)
+ format.align = style.textAlign;
+
+ if (style.fontWeight == "bold") {
+ format.bold = true;
+ } else if (style.fontWeight == "normal") {
+ format.bold = false;
+ }
+
+ if (style.color) {
+ var tmp = this.parseColor (style.color);
+ if (tmp != null)
+ format.color = tmp;
+ }
+
+ format.display = style.display;
+
+ if (style.fontFamily)
+ format.font = this.parseCSSFontFamily (style.fontFamily);
+
+ if (style.textIndent)
+ format.indent = parseInt (style.textIndent);
+
+ if (style.fontStyle == "italic") {
+ format.italic = true;
+ } else if (style.fontStyle == "normal") {
+ format.italic = false;
+ }
+
+ if (style.kerning == "true") {
+ format.kerning = true;
+ } else if (style.kerning == "false") {
+ format.kerning = false;
+ } else {
+ format.kerning = parseInt (style.kerning);
+ }
+
+ if (style.leading)
+ format.leading = parseInt (style.leading);
+
+ if (style.marginLeft)
+ format.leftMargin = parseInt (style.marginLeft);
+
+ if (style.letterSpacing)
+ format.letterSpacing = parseInt (style.letterSpacing);
+
+ if (style.marginRight)
+ format.rightMargin = parseInt (style.marginRight);
+
+ if (style.fontSize) {
+ var tmp = parseInt (style.fontSize);
+ if (tmp > 0)
+ format.size = tmp;
+ }
+
+ if (style.textDecoration == "underline") {
+ format.underline = true;
+ } else if (style.textDecoration == "none") {
+ format.underline = false;
+ }
+
+ return format;
+};
+
+TextField.StyleSheet.prototype.parseCSS = function (css) {
+ var result = this.parseCSSInternal (css);
+ if (typeof (result) == "null")
+ return false;
+
+ if (!this._css)
+ this._css = {};
+
+ for (var prop in result) {
+ this._css[prop] = this._copy (result[prop]);
+ this.doTransform (prop);
+ }
+ this.update ();
+
+ return true;
+};
+
+TextField.StyleSheet.prototype.parse = TextField.StyleSheet.prototype.parseCSS;
+
+TextField.StyleSheet.prototype.load = ASnative (301, 0);
+
+TextField.StyleSheet.prototype.onLoad = function () {
+};
+
+TextField.StyleSheet.prototype.onData = function (src) {
+ if (src != null) {
+ var result = this.parse (src);
+ this.loaded = result;
+ this.onLoad (result);
+ } else {
+ this.onLoad (false);
+ }
+};
+
+ASSetNative (TextField.StyleSheet.prototype, 113, "7update,7parseCSSInternal,7parseCSSFontFamily,7parseColor", 100);
+ASSetPropFlags (TextField.StyleSheet.prototype, null, 1027);
+ASSetPropFlags (TextField, "StyleSheet", 1027);
+
+/* Video */
+
+ASSetNative(Video.prototype, 667, "6attachVideo,6clear", 1);
+ASSetPropFlags(Video.prototype, null, 3);
+
+/* Accessibility */
+
+Accessibility = {};
+ASSetNative (Accessibility, 1999, "6isActive,6sendEvent,6updateProperties");
+ASSetPropFlags (Accessibility, null, 6);
+
+/* Camera */
+
+function Camera () {
+}
+
+Camera.get = function (index) {
+ var get_func = ASnative (2102, 200);
+ return get_func (index);
+};
+Camera.addProperty ("names", ASnative (2102, 201), null);
+ASSetNative (Camera.prototype, 2102, "6setMode,6setQuality,6setKeyFrameInterval,6setMotionLevel,6setLoopback,6setCursor");
+ASSetPropFlags (Camera.prototype, null, 3);
+
+/* ContextMenu */
+
+function ContextMenu (callback) {
+ this.onSelect = callback;
+ this.customItems = new Array ();
+ this.builtInItems = {
+ forward_back: true,
+ loop: true,
+ play: true,
+ print: true,
+ quality: true,
+ rewind: true,
+ save: true,
+ zoom: true
+ };
+}
+
+ContextMenu.prototype.copy = function () {
+ var o = new ContextMenu ();
+
+ o.onSelect = this.onSelect;
+
+ o.customItems = new Array ();
+ for (var i = 0; i < this.customItems.length; i++) {
+ o.customItems.push (this.customItems[i].copy ());
+ }
+
+ o.builtInItems = this.builtInItems;
+
+ return o;
+};
+
+ContextMenu.prototype.hideBuiltInItems = function () {
+ this.builtInItems = {
+ forward_back: false,
+ loop: false,
+ play: false,
+ print: false,
+ quality: false,
+ rewind: false,
+ save: false,
+ zoom: false
+ };
+};
+
+ASSetPropFlags (ContextMenu.prototype, null, 1027);
+
+/* ContextMenuItem */
+
+function ContextMenuItem (caption, callback, separatorBefore, enabled, visible)
+{
+ this.caption = caption;
+ this.onSelect = callback;
+ if (separatorBefore == undefined) {
+ this.separatorBefore = false;
+ } else {
+ this.separatorBefore = separatorBefore;
+ }
+ if (enabled == undefined) {
+ this.enabled = true;
+ } else {
+ this.enabled = enabled;
+ }
+ if (visible == undefined) {
+ this.visible = true;
+ } else {
+ this.visible = visible;
+ }
+}
+
+ContextMenuItem.prototype.copy = function () {
+ var o = new ContextMenuItem ();
+
+ o.caption = this.caption;
+ o.onSelect = this.onSelect;
+ o.separatorBefore = this.separatorBefore;
+ o.enabled = this.enabled;
+ o.visible = this.visible;
+
+ return o;
+};
+
+ASSetPropFlags (ContextMenuItem.prototype, null, 1027);
+
+/* FileReference */
+
+flash.net = {};
+flash.net.FileReference = function () {
+ var c = ASnative (2204, 200);
+ c (this);
+ this._listeners = [];
+};
+
+AsBroadcaster.initialize(flash.net.FileReference.prototype);
+ASSetNative(flash.net.FileReference.prototype, 2204, "8browse,8upload,8download,8cancel");
+ASSetPropFlags(flash.net.FileReference.prototype, null, 3);
+
+/* FileReferenceList */
+
+flash.net.FileReferenceList = function () {
+ this.fileList = new Array();
+ this._listeners = [];
+};
+
+AsBroadcaster.initialize (flash.net.FileReferenceList.prototype);
+ASSetNative (flash.net.FileReferenceList.prototype, 2205, "8browse");
+ASSetPropFlags (flash.net.FileReferenceList.prototype, null, 3);
+
+/* LocalConnection */
+
+function LocalConnection () {
+}
+
+ASSetNative (LocalConnection.prototype, 2200, "6connect,6send,6close,6domain");
+ASSetPropFlags (LocalConnection.prototype, null, 3);
+
+/* Microphone */
+
+function Microphone () {
+}
+
+Microphone.get = function (index) {
+ var get_func = ASnative (2104, 200);
+ return get_func (index);
+};
+Microphone.addProperty ("names", ASnative (2104, 201), null);
+ASSetNative (Microphone.prototype, 2104, "6setSilenceLevel,6setRate,6setGain,6setUseEchoSuppression");
+ASSetPropFlags (Microphone.prototype, null, 3);
+
+/* PrintJob */
+
+PrintJob = ASconstructor(111, 0);
+ASSetNative (PrintJob.prototype, 111, "7start,7addPage,7send", 100);
+ASSetPropFlags (PrintJob.prototype, null, 1027);
+
+/* Selection */
+
+Selection = {};
+ASSetNative (Selection, 600, "getBeginIndex,getEndIndex,getCaretIndex,getFocus,setFocus,setSelection");
+AsBroadcaster.initialize (Selection);
+ASSetPropFlags (Selection, null, 7);
+
+/* TextRenderer */
+
+flash.text = {};
+flash.text.TextRenderer = ASconstructor (2150, 0);
+
+ASSetNative (flash.text.TextRenderer, 2150, "8setAdvancedAntialiasingTable", 1);
+ASSetNativeAccessor (flash.text.TextRenderer, 2150, "8maxLevel", 4);
+ASSetNativeAccessor (flash.text.TextRenderer, 2150, "8displayMode", 10);
+
+textRenderer = flash.text.TextRenderer; // awesome
+
+/* XMLSocket */
+
+function XMLSocket () {
+}
+
+XMLSocket.prototype.onData = function (src) {
+ this.onXML (new XML (src));
+};
+
+ASSetNative (XMLSocket.prototype, 400, "connect,send,close");
+ASSetPropFlags (XMLSocket.prototype, null, 3);
+
+/* Point */
+
+flash.geom = {};
+
+flash.geom.Point = function () {
+ if (arguments.length == 0) {
+ this.x = 0;
+ this.y = 0;
+ } else {
+ // Note: we don't check for length == 1
+ this.x = arguments[0];
+ this.y = arguments[1];
+ }
+};
+
+flash.geom.Point.distance = function (a, b) {
+ return a.subtract (b).length;
+};
+
+flash.geom.Point.interpolate = function (a, b, value) {
+ return new flash.geom.Point (b.x + value * (a.x - b.x),
+ b.y + value * (a.y - b.y));
+};
+
+flash.geom.Point.polar = function (length, angle) {
+ return new flash.geom.Point (length * Math.cos (angle),
+ length * Math.sin (angle));
+};
+
+flash.geom.Point.prototype.addProperty ("length",
+ function () { return Math.sqrt (this.x * this.x + this.y * this.y); },
+ null);
+
+flash.geom.Point.prototype.add = function (other) {
+ return new flash.geom.Point (this.x + other.x, this.y + other.y);
+};
+
+flash.geom.Point.prototype.clone = function () {
+ return new flash.geom.Point (this.x, this.y);
+};
+
+flash.geom.Point.prototype.equals = function (other) {
+ if (!other instanceOf flash.geom.Point)
+ return false;
+
+ return (other.x == this.x && other.y == this.y);
+};
+
+flash.geom.Point.prototype.normalize = function (length) {
+ if (this.length <= 0)
+ return undefined;
+
+ var factor = length / this.length;
+ this.x = this.x * factor;
+ this.y = this.y * factor;
+};
+
+flash.geom.Point.prototype.subtract = function (other) {
+ return new flash.geom.Point (this.x - other.x, this.y - other.y);
+};
+
+flash.geom.Point.prototype.offset = function (x, y) {
+ this.x += x;
+ this.y += y;
+};
+
+flash.geom.Point.prototype.toString = function () {
+ return "(x=" + this.x + ", y=" + this.y + ")";
+};
+
+/* Rectangle */
+
+flash.geom.Rectangle = function (x, y, width, height) {
+ if (arguments.length == 0) {
+ this.setEmpty ();
+ } else {
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+};
+
+flash.geom.Rectangle.prototype.clone = function () {
+ return new flash.geom.Rectangle (this.x, this.y, this.width, this.height);
+};
+
+flash.geom.Rectangle.prototype.toString = function () {
+ return "(x=" + this.x + ", y=" + this.y + ", w=" + this.width + ", h=" + this.height + ")";
+};
+
+flash.geom.Rectangle.prototype.equals = function (rect) {
+ return (rect instanceof flash.geom.Rectangle &&
+ this.x == rect.x && this.y == rect.y &&
+ this.width == rect.width && this.height == rect.height);
+};
+
+flash.geom.Rectangle.prototype.contains = function (x, y) {
+ return (this.x <= x && this.y <= y &&
+ this.x + this.width > x && this.y + this.height > y);
+};
+
+flash.geom.Rectangle.prototype.containsPoint = function (point) {
+ return (this.x <= point.x && this.y <= point.y &&
+ this.x + this.width > point.x && this.y + this.height > point.y);
+};
+
+flash.geom.Rectangle.prototype.containsRectangle = function (rect) {
+ var tr = this.x + this.width;
+ var tb = this.y + this.height;
+ var rr = rect.x + rect.width;
+ var rb = rect.y + rect.height;
+ return (rect.x >= this.x && rect.x < tr && rect.y >= this.y && rect.y < tb &&
+ rr > this.x && rr <= tr && rb > this.y && rb <= tb);
+};
+
+flash.geom.Rectangle.prototype.isEmpty = function () {
+ return (this.width <= 0 || this.height <= 0);
+};
+
+flash.geom.Rectangle.prototype.setEmpty = function () {
+ this.x = 0;
+ this.y = 0;
+ this.width = 0;
+ this.height = 0;
+};
+
+flash.geom.Rectangle.prototype.intersection = function (rect) {
+ var ints = new flash.geom.Rectangle ();
+
+ if (this.isEmpty () || rect.isEmpty ()) {
+ ints.setEmpty ();
+ return ints;
+ }
+
+ ints.x = Math.max (this.x, rect.x);
+ ints.y = Math.max (this.y, rect.y);
+ ints.width = Math.min (this.x + this.width, rect.x + rect.width) - ints.x;
+ ints.height = Math.min (this.y + this.height, rect.y + rect.height) - ints.y;
+
+ if (ints.width <= 0 || ints.height <= 0)
+ ints.setEmpty ();
+
+ return ints;
+};
+
+flash.geom.Rectangle.prototype.intersects = function (rect) {
+ return !this.intersection (rect).isEmpty ();
+};
+
+flash.geom.Rectangle.prototype.union = function (rect) {
+ if (this.isEmpty ())
+ return rect.clone ();
+
+ if (rect.isEmpty ())
+ return this.clone ();
+
+ var union = new flash.geom.Rectangle ();
+ union.x = Math.min (this.x, rect.x);
+ union.y = Math.min (this.y, rect.y);
+ union.width = Math.max (this.x + this.width, rect.x + rect.width) - union.x;
+ union.height =
+ Math.max (this.y + this.height, rect.y + rect.height) - union.y;
+
+ return union;
+};
+
+flash.geom.Rectangle.prototype.offset = function (dx, dy) {
+ this.x += dx;
+ this.y += dy;
+};
+
+flash.geom.Rectangle.prototype.offsetPoint = function (d) {
+ this.x += d.x;
+ this.y += d.y;
+};
+
+flash.geom.Rectangle.prototype.inflate = function (dx, dy) {
+ this.x -= dx;
+ this.width += 2 * dx;
+
+ this.y -= dy;
+ this.height += 2 * dy;
+};
+
+flash.geom.Rectangle.prototype.inflatePoint = function (d) {
+ this.x -= d.x;
+ this.width += 2 * d.x;
+
+ this.y -= d.y;
+ this.height += 2 * d.y;
+};
+
+flash.geom.Rectangle.prototype.addProperty ("left",
+ function () {
+ return this.x;
+ },
+ function (left) {
+ this.width += this.x - left;
+ this.x = left;
+ }
+);
+
+flash.geom.Rectangle.prototype.addProperty ("right",
+ function () {
+ return this.x + this.width;
+ },
+ function (right) {
+ this.width = right - this.x;
+ }
+);
+
+flash.geom.Rectangle.prototype.addProperty ("top",
+ function () {
+ return this.y;
+ },
+ function (top) {
+ this.height += this.y - top;
+ this.y = top;
+ }
+);
+
+flash.geom.Rectangle.prototype.addProperty ("bottom",
+ function () {
+ return this.y + this.height;
+ },
+ function (bottom) {
+ this.height = bottom - this.y;
+ }
+);
+
+flash.geom.Rectangle.prototype.addProperty ("topLeft",
+ function () {
+ return new flash.geom.Point (this.x, this.y);
+ },
+ function (topLeft) {
+ this.width += this.x - topLeft.x;
+ this.height += this.y - topLeft.y;
+ this.x = topLeft.x;
+ this.y = topLeft.y;
+ }
+);
+
+flash.geom.Rectangle.prototype.addProperty ("bottomRight",
+ function () {
+ return new flash.geom.Point (this.x + this.width, this.y + this.height);
+ },
+ function (bottomRight) {
+ this.width = bottomRight.x - this.x;
+ this.height = bottomRight.y - this.y;
+ }
+);
+
+flash.geom.Rectangle.prototype.addProperty ("size",
+ function () {
+ return new flash.geom.Point (this.width, this.height);
+ },
+ function (size) {
+ this.width = size.x;
+ this.height = size.y;
+ }
+);
+
+/* Matrix */
+
+flash.geom.Matrix = function () {
+ var o = {}; o["Implement Matrix"] ();
+};
+
+flash.geom.Matrix.prototype.clone = function () {
+ var o = {}; o["Implement Matrix.clone"] ();
+};
+
+flash.geom.Matrix.prototype.concat = function () {
+ var o = {}; o["Implement Matrix.concat"] ();
+};
+
+flash.geom.Matrix.prototype.createBox = function () {
+ var o = {}; o["Implement Matrix.createBox"] ();
+};
+
+flash.geom.Matrix.prototype.createGradientBox = function () {
+ var o = {}; o["Implement Matrix.createGradientBox"] ();
+};
+
+flash.geom.Matrix.prototype.deltaTransformPoint = function () {
+ var o = {}; o["Implement Matrix.deltaTransformPoint"] ();
+};
+
+flash.geom.Matrix.prototype.identity = function () {
+ var o = {}; o["Implement Matrix.identity"] ();
+};
+
+flash.geom.Matrix.prototype.invert = function () {
+ var o = {}; o["Implement Matrix.invert"] ();
+};
+
+flash.geom.Matrix.prototype.rotate = function () {
+ var o = {}; o["Implement Matrix.rotate"] ();
+};
+
+flash.geom.Matrix.prototype.scale = function () {
+ var o = {}; o["Implement Matrix.scale"] ();
+};
+
+flash.geom.Matrix.prototype.transformPoint = function () {
+ var o = {}; o["Implement Matrix.transformPoint"] ();
+};
+
+flash.geom.Matrix.prototype.translate = function () {
+ var o = {}; o["Implement Matrix.translate"] ();
+};
+
+flash.geom.Matrix.prototype.toString = function () {
+ var o = {}; o["Implement Matrix.toString"] ();
+};
+
+/* ColorTransform */
+
+flash.geom.ColorTransform = ASconstructor (1105, 0);
+
+flash.geom.ColorTransform.prototype.toString = function () {
+ var o = {}; o["Implement ColorTransform.toString"] ();
+};
+
+ASSetNative (flash.geom.ColorTransform.prototype, 1105, "8concat", 1);
+ASSetNativeAccessor (flash.geom.ColorTransform.prototype, 1105, "8alphaMultiplier,8redMultiplier,8greenMultiplier,8blueMultiplier,8alphaOffset,8redOffset,8greenOffset,8blueOffset,8rgb", 101);
+
+/* Transform */
+
+flash.geom.Transform = ASconstructor (1106, 0);
+
+ASSetNativeAccessor (flash.geom.Transform.prototype, 1106, "8matrix,8concatenatedMatrix,8colorTransform,8concatenatedColorTransform,8pixelBounds", 101);
+
+/* BitmapData */
+
+flash.display = {};
+flash.display.BitmapData = ASconstructor (1100, 0);
+
+flash.display.BitmapData.RED_CHANNEL = 1;
+flash.display.BitmapData.GREEN_CHANNEL = 2;
+flash.display.BitmapData.BLUE_CHANNEL = 4;
+flash.display.BitmapData.ALPHA_CHANNEL = 8;
+
+ASSetNative (flash.display.BitmapData, 1100, "8loadBitmap", 40);
+
+ASSetNative (flash.display.BitmapData.prototype, 1100, "8getPixel,8setPixel,8fillRect,8copyPixels,8applyFilter,8scroll,8threshold,8draw,8pixelDissolve,8getPixel32,8setPixel32,8floodFill,8getColorBoundsRect,8perlinNoise,8colorTransform,8hitTest,8paletteMap,8merge,8noise,8copyChannel,8clone,8dispose,8generateFilterRect,8compare", 1);
+ASSetNativeAccessor(flash.display.BitmapData.prototype, 1100, "8width,8height,8rectangle,8transparent", 100);
+
+/* ExternalInterface */
+
+flash.external = {};
+
+flash.external.ExternalInterface = function () {
+};
+
+flash.external.ExternalInterface.addCallback = function (name, instance, method) {
+ if (!method || !flash.external.ExternalInterface.available)
+ return false;
+
+ flash.external.ExternalInterface._initJS ();
+ return flash.external.ExternalInterface._addCallback (name, function (request) {
+ return flash.external.ExternalInterface._callIn (instance, method, request);
+ });
+};
+
+flash.external.ExternalInterface.call = function (name) {
+ if (!flash.external.ExternalInterface.available)
+ return null;
+
+ flash.external.ExternalInterface._initJS ();
+ var request = "try { ";
+ var id = flash.external.ExternalInterface._objectID ();
+ if (id != null)
+ request += id + ".SetReturnValue(";
+ request += "__flash__toXML (" + name + "(";
+ for (var i = 1; i < arguments.length; i++) {
+ if (i > 1)
+ request += ",";
+ request += flash.external.ExternalInterface._toJS (arguments[i]);
+ }
+ request += ")) ";
+ if (id != null)
+ request += ")";
+ request += "; } catch (e) { ";
+ if (id != null) {
+ request += id + ".SetReturnValue(\"<undefined/>\"); }";
+ } else {
+ request += "\"<undefined/>\"; }";
+ }
+ var result = flash.external.ExternalInterface._evalJS (request);
+ if (result == null) {
+ request = "<invoke name=\"" + name + "\" returntype=\"xml\">" + flash.external.ExternalInterface._argumentsToXML (arguments) + "</invoke>";
+ result = flash.external.ExternalInterface._callOut (request);
+ }
+ if (result == null)
+ return null;
+
+ var xml = new XML ();
+ xml.ignoreWhite = true;
+ xml.parseXML (result);
+ return flash.external.ExternalInterface._toAS (xml.firstChild);
+};
+
+flash.external.ExternalInterface._callIn = function (instance, method, request) {
+ var xml = new XML();
+ xml.ignoreWhite = true;
+ xml.parseXML (request);
+ var args = null;
+ for (var i = 0; i < xml.firstChild.childNodes.length; i++) {
+ if (xml.firstChild.childNodes[i].nodeName == "arguments") {
+ args = xml.firstChild.childNodes[i];
+ break;
+ }
+ }
+ var result = method.apply (instance, flash.external.ExternalInterface._argumentsToAS (args));
+ if (xml.firstChild.attributes.returntype == "javascript")
+ return flash.external.ExternalInterface._toJS (result);
+ else
+ return flash.external.ExternalInterface._toXML (result);
+};
+
+flash.external.ExternalInterface._arrayToXML = function (array) {
+ var s = "<array>";
+ for (var i = 0; i < array.length; i++) {
+ s += "<property id=\"" + i + "\">" + flash.external.ExternalInterface._toXML (array[i]) + "</property>";
+ }
+ return s + "</array>";
+};
+
+flash.external.ExternalInterface._argumentsToXML = function (args) {
+ var s = "<arguments>";
+ for (var i = 0; i < args.length; i++) {
+ s += flash.external.ExternalInterface._toXML (args[i]);
+ }
+ return s + "</arguments>";
+};
+
+flash.external.ExternalInterface._objectToXML = function (obj) {
+ var s = "<object>";
+ for (var prop in obj) {
+ s += "<property id=\"" + prop + "\">" + flash.external.ExternalInterface._toXML (obj[prop]) + "</property>";
+ }
+ return s + "</object>";
+};
+
+flash.external.ExternalInterface._toXML = function (value) {
+ var type = typeof(value);
+ if (type == "string") {
+ return "<string>" + flash.external.ExternalInterface._escapeXML(value) + "</string>";
+ } else if (type == "undefined") {
+ return "<undefined/>";
+ } else if (type == "number") {
+ return "<number>" + value + "</number>";
+ } else if (value == null) {
+ return "<null/>";
+ } else if (type == "boolean") {
+ return value ? "<true/>" : "<false/>";
+ } else if (value.hasOwnProperty ("length")) {
+ return flash.external.ExternalInterface._arrayToXML (value);
+ } else if (type == "object") {
+ return flash.external.ExternalInterface._objectToXML (value);
+ } else {
+ return "<null/>";
+ }
+};
+
+flash.external.ExternalInterface._objectToAS = function (xml) {
+ var o = {};
+ for (i = 0; i < xml.childNodes.length; i++) {
+ if (xml.childNodes[i].nodeName == "property")
+ o[xml.childNodes[i].attributes.id] = flash.external.ExternalInterface._toAS (xml.childNodes[i].firstChild);
+ }
+ return o;
+};
+
+flash.external.ExternalInterface._arrayToAS = function (xml) {
+ var a = [];
+ for (i = 0; i < xml.childNodes.length; i++) {
+ if (xml.childNodes[i].nodeName == "property")
+ a[xml.childNodes[i].attributes.id] = flash.external.ExternalInterface._toAS (xml.childNodes[i].firstChild);
+ }
+ return a;
+};
+
+flash.external.ExternalInterface._toAS = function (xml) {
+ var type = xml.nodeName;
+ if (type == "number") {
+ return Number (xml.firstChild.toString());
+ } else if (type == "string") {
+ return flash.external.ExternalInterface._unescapeXML (String (xml.firstChild));
+ } else if (type == "false") {
+ return false;
+ } else if (type == "true") {
+ return true;
+ } else if (type == "null") {
+ return null;
+ } else if (type == "undefined") {
+ return undefined;
+ } else if (type == "object") {
+ return flash.external.ExternalInterface._objectToAS (xml);
+ } else if (type == "array") {
+ return flash.external.ExternalInterface._arrayToAS (xml);
+ } else if (type == "class") {
+ return String (xml.firstChild);
+ } else {
+ return undefined;
+ }
+};
+
+flash.external.ExternalInterface._argumentsToAS = function (xml) {
+ var args = [];
+ for (var i = 0; i < xml.childNodes.length; i++) {
+ args.push (flash.external.ExternalInterface._toAS (xml.childNodes [i]));
+ }
+ return args;
+};
+
+flash.external.ExternalInterface._arrayToJS = function (array) {
+ var s = "[";
+ for (var i = 0; i < array.length; i++) {
+ if (i != 0)
+ s += ",";
+ s += flash.external.ExternalInterface._toJS (array[_l1]);
+ }
+ return s + "]";
+};
+
+flash.external.ExternalInterface._objectToJS = function (obj) {
+ var s = "({";
+ var needs_comma = false;
+ for (var prop in obj) {
+ if (needs_comma) {
+ s += ",";
+ }
+ needs_comma = true;
+ s += prop + ":" + flash.external.ExternalInterface._toJS (obj[prop]);
+ }
+ return s + "})";
+};
+
+flash.external.ExternalInterface._toJS = function (value) {
+ var type = typeof (value);
+ if (type == "string") {
+ return "\"" + flash.external.ExternalInterface._jsQuoteString (flash.external.ExternalInterface._unescapeXML (value)) + "\"";
+ } else if (type == "object") {
+ if (value instanceof Array) {
+ return flash.external.ExternalInterface._arrayToJS (value);
+ } else {
+ return flash.external.ExternalInterface._objectToJS (value);
+ }
+ } else {
+ return String (value);
+ }
+};
+
+ASSetNative (flash.external.ExternalInterface, 14, "8_initJS,8_objectID,8_addCallback,8_evalJS,8_callOut,8_escapeXML,8_unescapeXML,8_jsQuoteString");
+ASSetNativeAccessor (flash.external.ExternalInterface, 14, "8available", 100);
+
+ASSetPropFlags (flash.external.ExternalInterface, null, 4103);
+
+/* SharedObject */
+
+function SharedObject () {
+};
+
+SharedObject.deleteAll = function () {
+ var o = {}; o["Implement SharedObject.deleteAll (static)"] ();
+};
+
+SharedObject.getDiskUsage = function () {
+ var o = {}; o["Implement SharedObject.getDiskUsage (static)"] ();
+};
+
+SharedObject.getLocal = function () {
+ var o = {}; o["Implement SharedObject.getLocal (static)"] ();
+};
+
+SharedObject.getRemote = function () {
+ var o = {}; o["Implement SharedObject.getRemote (static)"] ();
+};
+
+ASSetPropFlags (SharedObject, "deleteAll,getDiskUsage", 1);
+
+ASSetNative (SharedObject.prototype, 2106, "6connect,6send,6flush,6close,6getSize,6setFps,6clear");
+ASSetPropFlags (SharedObject.prototype, null, 3);
+
+/* AsSetupError */
+
+/* This function added new Error classes in Flash player 7, in Flash player 9
+ * it seems to be just broken, we just call new Error based on the number of
+ * ,-characters in the given string */
+function AsSetupError (names) {
+ var count = names.split (",").length;
+ for (var i = 0; i < count; i++) {
+ var tmp = new Error ();
+ }
+}
+
+/* RemoteLSOUsage */
+
+function RemoteLSOUsage () {
+};
+
+RemoteLSOUsage.getURLPageSupport = function () {
+ var o = {}; o["Implement RemoteLSOUsage.getURLPageSupport (static)"] ();
+};
+ASSetPropFlags (RemoteLSOUsage, "getURLPageSupport", 1);
+
+/* Button */
+
+Button = ASconstructor (105, 0);
+
+Button.prototype.useHandCursor = true;
+Button.prototype.enabled = true;
+
+Button.prototype.getDepth = ASnative (105, 3);
+ASSetNativeAccessor (Button.prototype, 105, "8scale9Grid,8filters,8cacheAsBitmap,8blendMode", 4);
+// FIXME: this should be done inside the Button constructor
+ASSetNativeAccessor (Button.prototype, 900, "8tabIndex", 200);
+
+/* BitmapFilter */
+
+flash.filters = {};
+
+flash.filters.BitmapFilter = ASconstructor(1112, 0);
+
+ASSetNative(flash.filters.BitmapFilter.prototype, 1112, "8clone", 1);
+
+/* BevelFilter */
+
+flash.filters.BevelFilter = ASconstructor (1107, 0);
+flash.filters.BevelFilter.prototype = new flash.filters.BitmapFilter ();
+delete flash.filters.BevelFilter.prototype.constructor;
+
+ASSetNativeAccessor (flash.filters.BevelFilter.prototype, 1107, "8distance,8angle,8highlightColor,8highlightAlpha,8shadowColor,8shadowAlpha,8quality,8strength,8knockout,8blurX,8blurY,8type", 1);
+
+/* BlurFilter */
+
+flash.filters.BlurFilter = ASconstructor (1102, 0);
+flash.filters.BlurFilter.prototype = new flash.filters.BitmapFilter ();
+delete flash.filters.BlurFilter.prototype.constructor;
+
+ASSetNativeAccessor (flash.filters.BlurFilter.prototype, 1102, "8blurX,8blurY,8quality", 1);
+
+/* ColorMatrixFilter */
+
+flash.filters.ColorMatrixFilter = ASconstructor (1110, 0);
+flash.filters.ColorMatrixFilter.prototype = new flash.filters.BitmapFilter ();
+delete flash.filters.ColorMatrixFilter.prototype.constructor;
+
+ASSetNativeAccessor (flash.filters.ColorMatrixFilter.prototype, 1110, "8matrix", 1);
+
+/* ConvolutionFilter */
+
+flash.filters.ConvolutionFilter = ASconstructor (1109, 0);
+flash.filters.ConvolutionFilter.prototype = new flash.filters.BitmapFilter ();
+delete flash.filters.ConvolutionFilter.prototype.constructor;
+
+ASSetNativeAccessor (flash.filters.ConvolutionFilter.prototype, 1109, "8matrixX,8matrixY,8matrix,8divisor,8bias,8preserveAlpha,8clamp,8color,8alpha", 1);
+
+/* DisplacementMapFilter */
+
+flash.filters.DisplacementMapFilter = ASconstructor (1111, 0);
+flash.filters.DisplacementMapFilter.prototype = new flash.filters.BitmapFilter ();
+delete flash.filters.DisplacementMapFilter.prototype.constructor;
+
+ASSetNativeAccessor (flash.filters.DisplacementMapFilter.prototype, 1111, "8mapBitmap,8mapPoint,8componentX,8componentY,8scaleX,8scaleY,8mode,8color,8alpha", 1);
+
+/* DropShadowFilter */
+
+flash.filters.DropShadowFilter = ASconstructor (1101, 0);
+flash.filters.DropShadowFilter.prototype = new flash.filters.BitmapFilter();
+delete flash.filters.DropShadowFilter.prototype.constructor;
+
+ASSetNativeAccessor (flash.filters.DropShadowFilter.prototype, 1101, "8distance,8angle,8color,8alpha,8quality,8inner,8knockout,8blurX,8blurY,8strength,8hideObject", 1);
+
+/* GlowFilter */
+
+flash.filters.GlowFilter = ASconstructor (1103, 0);
+flash.filters.GlowFilter.prototype = new flash.filters.BitmapFilter ();
+delete flash.filters.GlowFilter.prototype.constructor;
+
+ASSetNativeAccessor (flash.filters.GlowFilter.prototype, 1103, "8color,8alpha,8quality,8inner,8knockout,8blurX,8blurY,8strength", 1);
+
+/* GradientBevelFilter */
+
+flash.filters.GradientBevelFilter = ASconstructor (1108, 1000);
+flash.filters.GradientBevelFilter.prototype = new flash.filters.BitmapFilter ();
+delete flash.filters.GradientBevelFilter.prototype.constructor;
+
+ASSetNativeAccessor (flash.filters.GradientBevelFilter.prototype, 1108, "8distance,8angle,8colors,8alphas,8ratios,8blurX,8blurY,8quality,8strength,8knockout,8type", 1);
+
+/* GradientGlowFilter */
+
+flash.filters.GradientGlowFilter = ASconstructor (1108, 0);
+flash.filters.GradientGlowFilter.prototype = o = new flash.filters.BitmapFilter ();
+delete flash.filters.GradientGlowFilter.prototype.constructor;
+ASSetNativeAccessor (flash.filters.GradientGlowFilter.prototype, 1108, "8distance,8angle,8colors,8alphas,8ratios,8blurX,8blurY,8quality,8strength,8knockout,8type", 1);
+
+/* Global Functions */
+
+setInterval = ASnative (250, 0);
+clearInterval = ASnative (250, 1);
+setTimeout = ASnative(250, 2);
+clearTimeout = clearInterval;
+showRedrawRegions = ASnative (1021, 1);
+trace = ASnative (100, 4);
+updateAfterEvent = ASnative (9, 0);
+
+/*** OH THE HUMANITY ***/
+
+o = null;
+
+/*** Set propflags that would have interfered with running this script */
+
+ASSetPropFlags (this, "flash", 4096);
+ASSetPropFlags (Object, "addProperty", 128);
+ASSetPropFlags (AsBroadcaster, null, 131);
+
+/*** GLOBAL PROPFLAGS */
+
+ASSetPropFlags (this, null, 1, 6);
diff --git a/swfdec/swfdec_initialize.h b/swfdec/swfdec_initialize.h
new file mode 100644
index 0000000..cc9af3c
--- /dev/null
+++ b/swfdec/swfdec_initialize.h
@@ -0,0 +1,2196 @@
+/* This file is autogenerated, do not edit! */
+
+/* compiled from swfdec_initialize.as */
+static const unsigned char swfdec_initialize[] = {
+ 0x88, 0xB3, 0x21, 0x0D, 0x02, 0x41, 0x53, 0x53, 0x65, 0x74, 0x50, 0x72, 0x6F, 0x70, 0x46, 0x6C,
+ 0x61, 0x67, 0x73, 0x00, 0x41, 0x53, 0x6E, 0x61, 0x74, 0x69, 0x76, 0x65, 0x00, 0x41, 0x53, 0x53,
+ 0x65, 0x74, 0x4E, 0x61, 0x74, 0x69, 0x76, 0x65, 0x00, 0x41, 0x53, 0x53, 0x65, 0x74, 0x4E, 0x61,
+ 0x74, 0x69, 0x76, 0x65, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x6F, 0x72, 0x00, 0x66, 0x6C, 0x61,
+ 0x73, 0x68, 0x00, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74,
+ 0x65, 0x72, 0x43, 0x6C, 0x61, 0x73, 0x73, 0x00, 0x61, 0x64, 0x64, 0x50, 0x72, 0x6F, 0x70, 0x65,
+ 0x72, 0x74, 0x79, 0x00, 0x6D, 0x73, 0x67, 0x00, 0x75, 0x6E, 0x64, 0x65, 0x66, 0x69, 0x6E, 0x65,
+ 0x64, 0x00, 0x74, 0x68, 0x69, 0x73, 0x00, 0x6D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x00, 0x45,
+ 0x72, 0x72, 0x6F, 0x72, 0x00, 0x70, 0x72, 0x6F, 0x74, 0x6F, 0x74, 0x79, 0x70, 0x65, 0x00, 0x6E,
+ 0x61, 0x6D, 0x65, 0x00, 0x74, 0x6F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x41, 0x73, 0x42,
+ 0x72, 0x6F, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x65, 0x72, 0x00, 0x62, 0x72, 0x6F, 0x61, 0x64,
+ 0x63, 0x61, 0x73, 0x74, 0x4D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x00, 0x61, 0x64, 0x64, 0x4C,
+ 0x69, 0x73, 0x74, 0x65, 0x6E, 0x65, 0x72, 0x00, 0x78, 0x00, 0x72, 0x65, 0x6D, 0x6F, 0x76, 0x65,
+ 0x4C, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x65, 0x72, 0x00, 0x5F, 0x6C, 0x69, 0x73, 0x74, 0x65, 0x6E,
+ 0x65, 0x72, 0x73, 0x00, 0x70, 0x75, 0x73, 0x68, 0x00, 0x6C, 0x00, 0x69, 0x00, 0x6C, 0x65, 0x6E,
+ 0x67, 0x74, 0x68, 0x00, 0x73, 0x70, 0x6C, 0x69, 0x63, 0x65, 0x00, 0x69, 0x6E, 0x69, 0x74, 0x69,
+ 0x61, 0x6C, 0x69, 0x7A, 0x65, 0x00, 0x6F, 0x00, 0x62, 0x72, 0x6F, 0x61, 0x64, 0x63, 0x61, 0x73,
+ 0x74, 0x4D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2C, 0x61, 0x64, 0x64, 0x4C, 0x69, 0x73, 0x74,
+ 0x65, 0x6E, 0x65, 0x72, 0x2C, 0x72, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x4C, 0x69, 0x73, 0x74, 0x65,
+ 0x6E, 0x65, 0x72, 0x2C, 0x5F, 0x6C, 0x69, 0x73, 0x74, 0x65, 0x6E, 0x65, 0x72, 0x73, 0x00, 0x4B,
+ 0x65, 0x79, 0x00, 0x41, 0x4C, 0x54, 0x00, 0x42, 0x41, 0x43, 0x4B, 0x53, 0x50, 0x41, 0x43, 0x45,
+ 0x00, 0x43, 0x41, 0x50, 0x53, 0x4C, 0x4F, 0x43, 0x4B, 0x00, 0x43, 0x4F, 0x4E, 0x54, 0x52, 0x4F,
+ 0x4C, 0x00, 0x44, 0x45, 0x4C, 0x45, 0x54, 0x45, 0x4B, 0x45, 0x59, 0x00, 0x44, 0x4F, 0x57, 0x4E,
+ 0x00, 0x45, 0x4E, 0x44, 0x00, 0x45, 0x4E, 0x54, 0x45, 0x52, 0x00, 0x45, 0x53, 0x43, 0x41, 0x50,
+ 0x45, 0x00, 0x48, 0x4F, 0x4D, 0x45, 0x00, 0x49, 0x4E, 0x53, 0x45, 0x52, 0x54, 0x00, 0x4C, 0x45,
+ 0x46, 0x54, 0x00, 0x50, 0x47, 0x44, 0x4E, 0x00, 0x50, 0x47, 0x55, 0x50, 0x00, 0x52, 0x49, 0x47,
+ 0x48, 0x54, 0x00, 0x53, 0x48, 0x49, 0x46, 0x54, 0x00, 0x53, 0x50, 0x41, 0x43, 0x45, 0x00, 0x54,
+ 0x41, 0x42, 0x00, 0x55, 0x50, 0x00, 0x67, 0x65, 0x74, 0x41, 0x73, 0x63, 0x69, 0x69, 0x2C, 0x67,
+ 0x65, 0x74, 0x43, 0x6F, 0x64, 0x65, 0x2C, 0x69, 0x73, 0x44, 0x6F, 0x77, 0x6E, 0x2C, 0x69, 0x73,
+ 0x54, 0x6F, 0x67, 0x67, 0x6C, 0x65, 0x64, 0x2C, 0x69, 0x73, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73,
+ 0x69, 0x62, 0x6C, 0x65, 0x00, 0x4D, 0x6F, 0x75, 0x73, 0x65, 0x00, 0x73, 0x68, 0x6F, 0x77, 0x00,
+ 0x68, 0x69, 0x64, 0x65, 0x00, 0x53, 0x74, 0x61, 0x67, 0x65, 0x00, 0x73, 0x63, 0x61, 0x6C, 0x65,
+ 0x4D, 0x6F, 0x64, 0x65, 0x2C, 0x61, 0x6C, 0x69, 0x67, 0x6E, 0x2C, 0x77, 0x69, 0x64, 0x74, 0x68,
+ 0x2C, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x2C, 0x73, 0x68, 0x6F, 0x77, 0x4D, 0x65, 0x6E, 0x75,
+ 0x2C, 0x64, 0x69, 0x73, 0x70, 0x6C, 0x61, 0x79, 0x53, 0x74, 0x61, 0x74, 0x65, 0x00, 0x39, 0x66,
+ 0x75, 0x6C, 0x6C, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6E, 0x53, 0x6F, 0x75, 0x72, 0x63, 0x65, 0x52,
+ 0x65, 0x63, 0x74, 0x2C, 0x39, 0x66, 0x75, 0x6C, 0x6C, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6E, 0x48,
+ 0x65, 0x69, 0x67, 0x68, 0x74, 0x2C, 0x39, 0x66, 0x75, 0x6C, 0x6C, 0x53, 0x63, 0x72, 0x65, 0x65,
+ 0x6E, 0x57, 0x69, 0x64, 0x74, 0x68, 0x00, 0x4E, 0x65, 0x74, 0x43, 0x6F, 0x6E, 0x6E, 0x65, 0x63,
+ 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x41, 0x53, 0x63, 0x6F, 0x6E, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74,
+ 0x6F, 0x72, 0x00, 0x36, 0x63, 0x6F, 0x6E, 0x6E, 0x65, 0x63, 0x74, 0x2C, 0x36, 0x63, 0x6C, 0x6F,
+ 0x73, 0x65, 0x2C, 0x36, 0x63, 0x61, 0x6C, 0x6C, 0x2C, 0x36, 0x61, 0x64, 0x64, 0x48, 0x65, 0x61,
+ 0x64, 0x65, 0x72, 0x00, 0x63, 0x6F, 0x6E, 0x6E, 0x65, 0x63, 0x74, 0x65, 0x64, 0x50, 0x72, 0x6F,
+ 0x78, 0x79, 0x54, 0x79, 0x70, 0x65, 0x00, 0x70, 0x72, 0x6F, 0x78, 0x79, 0x54, 0x79, 0x70, 0x65,
+ 0x00, 0x6E, 0x6F, 0x6E, 0x65, 0x00, 0x75, 0x73, 0x69, 0x6E, 0x67, 0x54, 0x4C, 0x53, 0x00, 0x4E,
+ 0x65, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6D, 0x00, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x73, 0x68,
+ 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x4E, 0x65, 0x74, 0x53, 0x74,
+ 0x72, 0x65, 0x61, 0x6D, 0x2E, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x73, 0x68, 0x00, 0x72, 0x65, 0x63,
+ 0x65, 0x69, 0x76, 0x65, 0x41, 0x75, 0x64, 0x69, 0x6F, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D,
+ 0x65, 0x6E, 0x74, 0x20, 0x4E, 0x65, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6D, 0x2E, 0x72, 0x65,
+ 0x63, 0x65, 0x69, 0x76, 0x65, 0x41, 0x75, 0x64, 0x69, 0x6F, 0x00, 0x72, 0x65, 0x63, 0x65, 0x69,
+ 0x76, 0x65, 0x56, 0x69, 0x64, 0x65, 0x6F, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E,
+ 0x74, 0x20, 0x4E, 0x65, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6D, 0x2E, 0x72, 0x65, 0x63, 0x65,
+ 0x69, 0x76, 0x65, 0x56, 0x69, 0x64, 0x65, 0x6F, 0x00, 0x36, 0x63, 0x6C, 0x6F, 0x73, 0x65, 0x2C,
+ 0x36, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x41, 0x75, 0x64, 0x69, 0x6F, 0x2C, 0x36, 0x61, 0x74,
+ 0x74, 0x61, 0x63, 0x68, 0x56, 0x69, 0x64, 0x65, 0x6F, 0x2C, 0x36, 0x73, 0x65, 0x6E, 0x64, 0x2C,
+ 0x36, 0x73, 0x65, 0x74, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x54, 0x69, 0x6D, 0x65, 0x00, 0x63,
+ 0x68, 0x65, 0x63, 0x6B, 0x50, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x46, 0x69, 0x6C, 0x65, 0x00, 0x4C,
+ 0x6F, 0x61, 0x64, 0x56, 0x61, 0x72, 0x73, 0x00, 0x63, 0x6F, 0x6E, 0x74, 0x65, 0x6E, 0x74, 0x54,
+ 0x79, 0x70, 0x65, 0x00, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2F,
+ 0x78, 0x2D, 0x77, 0x77, 0x77, 0x2D, 0x66, 0x6F, 0x72, 0x6D, 0x2D, 0x75, 0x72, 0x6C, 0x65, 0x6E,
+ 0x63, 0x6F, 0x64, 0x65, 0x64, 0x00, 0x6C, 0x6F, 0x61, 0x64, 0x00, 0x73, 0x65, 0x6E, 0x64, 0x00,
+ 0x73, 0x65, 0x6E, 0x64, 0x41, 0x6E, 0x64, 0x4C, 0x6F, 0x61, 0x64, 0x00, 0x64, 0x65, 0x63, 0x6F,
+ 0x64, 0x65, 0x00, 0x6F, 0x6E, 0x4C, 0x6F, 0x61, 0x64, 0x00, 0x6F, 0x6E, 0x44, 0x61, 0x74, 0x61,
+ 0x00, 0x6C, 0x6F, 0x61, 0x64, 0x65, 0x64, 0x00, 0x73, 0x72, 0x63, 0x00, 0x73, 0x74, 0x72, 0x00,
+ 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x00, 0x3D, 0x00, 0x26, 0x00, 0x67, 0x65, 0x74, 0x42, 0x79,
+ 0x74, 0x65, 0x73, 0x4C, 0x6F, 0x61, 0x64, 0x65, 0x64, 0x00, 0x5F, 0x62, 0x79, 0x74, 0x65, 0x73,
+ 0x4C, 0x6F, 0x61, 0x64, 0x65, 0x64, 0x00, 0x67, 0x65, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x54,
+ 0x6F, 0x74, 0x61, 0x6C, 0x00, 0x5F, 0x62, 0x79, 0x74, 0x65, 0x73, 0x54, 0x6F, 0x74, 0x61, 0x6C,
+ 0x00, 0x61, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65,
+ 0x72, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x4C, 0x6F, 0x61, 0x64,
+ 0x56, 0x61, 0x72, 0x73, 0x2E, 0x61, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48,
+ 0x65, 0x61, 0x64, 0x65, 0x72, 0x00, 0x53, 0x6F, 0x75, 0x6E, 0x64, 0x00, 0x67, 0x65, 0x74, 0x50,
+ 0x61, 0x6E, 0x2C, 0x67, 0x65, 0x74, 0x54, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x2C,
+ 0x67, 0x65, 0x74, 0x56, 0x6F, 0x6C, 0x75, 0x6D, 0x65, 0x2C, 0x73, 0x65, 0x74, 0x50, 0x61, 0x6E,
+ 0x2C, 0x73, 0x65, 0x74, 0x54, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x2C, 0x73, 0x65,
+ 0x74, 0x56, 0x6F, 0x6C, 0x75, 0x6D, 0x65, 0x2C, 0x73, 0x74, 0x6F, 0x70, 0x2C, 0x61, 0x74, 0x74,
+ 0x61, 0x63, 0x68, 0x53, 0x6F, 0x75, 0x6E, 0x64, 0x2C, 0x73, 0x74, 0x61, 0x72, 0x74, 0x2C, 0x36,
+ 0x67, 0x65, 0x74, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2C, 0x36, 0x73, 0x65, 0x74,
+ 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2C, 0x36, 0x67, 0x65, 0x74, 0x50, 0x6F, 0x73,
+ 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x50, 0x6F, 0x73, 0x69, 0x74, 0x69,
+ 0x6F, 0x6E, 0x2C, 0x36, 0x6C, 0x6F, 0x61, 0x64, 0x53, 0x6F, 0x75, 0x6E, 0x64, 0x2C, 0x36, 0x67,
+ 0x65, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x4C, 0x6F, 0x61, 0x64, 0x65, 0x64, 0x2C, 0x36, 0x67,
+ 0x65, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x54, 0x6F, 0x74, 0x61, 0x6C, 0x2C, 0x39, 0x61, 0x72,
+ 0x65, 0x53, 0x6F, 0x75, 0x6E, 0x64, 0x73, 0x49, 0x6E, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69,
+ 0x62, 0x6C, 0x65, 0x00, 0x58, 0x4D, 0x4C, 0x4E, 0x6F, 0x64, 0x65, 0x00, 0x63, 0x6C, 0x6F, 0x6E,
+ 0x65, 0x4E, 0x6F, 0x64, 0x65, 0x00, 0x72, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x4E, 0x6F, 0x64, 0x65,
+ 0x00, 0x69, 0x6E, 0x73, 0x65, 0x72, 0x74, 0x42, 0x65, 0x66, 0x6F, 0x72, 0x65, 0x00, 0x61, 0x70,
+ 0x70, 0x65, 0x6E, 0x64, 0x43, 0x68, 0x69, 0x6C, 0x64, 0x00, 0x68, 0x61, 0x73, 0x43, 0x68, 0x69,
+ 0x6C, 0x64, 0x4E, 0x6F, 0x64, 0x65, 0x73, 0x00, 0x67, 0x65, 0x74, 0x4E, 0x61, 0x6D, 0x65, 0x73,
+ 0x70, 0x61, 0x63, 0x65, 0x46, 0x6F, 0x72, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x00, 0x67, 0x65,
+ 0x74, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x46, 0x6F, 0x72, 0x4E, 0x61, 0x6D, 0x65, 0x73, 0x70,
+ 0x61, 0x63, 0x65, 0x00, 0x58, 0x4D, 0x4C, 0x00, 0x00, 0x63, 0x6F, 0x6E, 0x73, 0x74, 0x72, 0x75,
+ 0x63, 0x74, 0x6F, 0x72, 0x00, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x6C, 0x65, 0x6D, 0x65,
+ 0x6E, 0x74, 0x00, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, 0x78, 0x74, 0x4E, 0x6F, 0x64,
+ 0x65, 0x00, 0x70, 0x61, 0x72, 0x73, 0x65, 0x58, 0x4D, 0x4C, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65,
+ 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x58, 0x4D, 0x4C, 0x2E, 0x61, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75,
+ 0x65, 0x73, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x00, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D,
+ 0x00, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6C, 0x69, 0x74, 0x69, 0x65, 0x73, 0x00, 0x51, 0x75,
+ 0x65, 0x72, 0x79, 0x00, 0x73, 0x65, 0x74, 0x43, 0x6C, 0x69, 0x70, 0x62, 0x6F, 0x61, 0x72, 0x64,
+ 0x00, 0x73, 0x68, 0x6F, 0x77, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6E, 0x67, 0x73, 0x00, 0x65, 0x78,
+ 0x61, 0x63, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6E, 0x67, 0x73, 0x2C, 0x75, 0x73, 0x65, 0x43,
+ 0x6F, 0x64, 0x65, 0x70, 0x61, 0x67, 0x65, 0x00, 0x65, 0x78, 0x61, 0x63, 0x74, 0x53, 0x65, 0x74,
+ 0x74, 0x69, 0x6E, 0x67, 0x73, 0x2C, 0x75, 0x73, 0x65, 0x43, 0x6F, 0x64, 0x65, 0x50, 0x61, 0x67,
+ 0x65, 0x00, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x00, 0x61, 0x6C, 0x6C, 0x6F, 0x77,
+ 0x44, 0x6F, 0x6D, 0x61, 0x69, 0x6E, 0x2C, 0x37, 0x61, 0x6C, 0x6C, 0x6F, 0x77, 0x49, 0x6E, 0x73,
+ 0x65, 0x63, 0x75, 0x72, 0x65, 0x44, 0x6F, 0x6D, 0x61, 0x69, 0x6E, 0x2C, 0x6C, 0x6F, 0x61, 0x64,
+ 0x50, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x46, 0x69, 0x6C, 0x65, 0x2C, 0x63, 0x68, 0x6F, 0x6F, 0x73,
+ 0x65, 0x4C, 0x6F, 0x63, 0x61, 0x6C, 0x53, 0x77, 0x66, 0x50, 0x61, 0x74, 0x68, 0x2C, 0x65, 0x73,
+ 0x63, 0x61, 0x70, 0x65, 0x44, 0x6F, 0x6D, 0x61, 0x69, 0x6E, 0x00, 0x73, 0x61, 0x6E, 0x64, 0x62,
+ 0x6F, 0x78, 0x54, 0x79, 0x70, 0x65, 0x00, 0x50, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x46, 0x69, 0x6C,
+ 0x65, 0x52, 0x65, 0x73, 0x6F, 0x6C, 0x76, 0x65, 0x72, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D,
+ 0x65, 0x6E, 0x74, 0x20, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x73, 0x65, 0x63, 0x75, 0x72,
+ 0x69, 0x74, 0x79, 0x2E, 0x50, 0x6F, 0x6C, 0x69, 0x63, 0x79, 0x46, 0x69, 0x6C, 0x65, 0x52, 0x65,
+ 0x73, 0x6F, 0x6C, 0x76, 0x65, 0x72, 0x00, 0x72, 0x65, 0x73, 0x6F, 0x6C, 0x76, 0x65, 0x00, 0x50,
+ 0x72, 0x6F, 0x64, 0x75, 0x63, 0x74, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74,
+ 0x20, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x50, 0x72, 0x6F, 0x64, 0x75, 0x63, 0x74, 0x00,
+ 0x69, 0x73, 0x52, 0x75, 0x6E, 0x6E, 0x69, 0x6E, 0x67, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D,
+ 0x65, 0x6E, 0x74, 0x20, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x50, 0x72, 0x6F, 0x64, 0x75,
+ 0x63, 0x74, 0x2E, 0x69, 0x73, 0x52, 0x75, 0x6E, 0x6E, 0x69, 0x6E, 0x67, 0x00, 0x69, 0x73, 0x49,
+ 0x6E, 0x73, 0x74, 0x61, 0x6C, 0x6C, 0x65, 0x64, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65,
+ 0x6E, 0x74, 0x20, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x50, 0x72, 0x6F, 0x64, 0x75, 0x63,
+ 0x74, 0x2E, 0x69, 0x73, 0x49, 0x6E, 0x73, 0x74, 0x61, 0x6C, 0x6C, 0x65, 0x64, 0x00, 0x6C, 0x61,
+ 0x75, 0x6E, 0x63, 0x68, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53,
+ 0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x50, 0x72, 0x6F, 0x64, 0x75, 0x63, 0x74, 0x2E, 0x6C, 0x61,
+ 0x75, 0x6E, 0x63, 0x68, 0x00, 0x64, 0x6F, 0x77, 0x6E, 0x6C, 0x6F, 0x61, 0x64, 0x00, 0x49, 0x6D,
+ 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x50,
+ 0x72, 0x6F, 0x64, 0x75, 0x63, 0x74, 0x2E, 0x64, 0x6F, 0x77, 0x6E, 0x6C, 0x6F, 0x61, 0x64, 0x00,
+ 0x69, 0x6E, 0x73, 0x74, 0x61, 0x6C, 0x6C, 0x65, 0x64, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E,
+ 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53, 0x79, 0x73, 0x74, 0x65,
+ 0x6D, 0x2E, 0x50, 0x72, 0x6F, 0x64, 0x75, 0x63, 0x74, 0x2E, 0x69, 0x6E, 0x73, 0x74, 0x61, 0x6C,
+ 0x6C, 0x65, 0x64, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x00, 0x76, 0x61, 0x6C, 0x69, 0x64,
+ 0x61, 0x74, 0x65, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53, 0x79,
+ 0x73, 0x74, 0x65, 0x6D, 0x2E, 0x50, 0x72, 0x6F, 0x64, 0x75, 0x63, 0x74, 0x2E, 0x76, 0x61, 0x6C,
+ 0x69, 0x64, 0x61, 0x74, 0x65, 0x00, 0x49, 0x4D, 0x45, 0x00, 0x41, 0x4C, 0x50, 0x48, 0x41, 0x4E,
+ 0x55, 0x4D, 0x45, 0x52, 0x49, 0x43, 0x5F, 0x46, 0x55, 0x4C, 0x4C, 0x00, 0x41, 0x4C, 0x50, 0x48,
+ 0x41, 0x4E, 0x55, 0x4D, 0x45, 0x52, 0x49, 0x43, 0x5F, 0x48, 0x41, 0x4C, 0x46, 0x00, 0x43, 0x48,
+ 0x49, 0x4E, 0x45, 0x53, 0x45, 0x00, 0x4A, 0x41, 0x50, 0x41, 0x4E, 0x45, 0x53, 0x45, 0x5F, 0x48,
+ 0x49, 0x52, 0x41, 0x47, 0x41, 0x4E, 0x41, 0x00, 0x4A, 0x41, 0x50, 0x41, 0x4E, 0x45, 0x53, 0x45,
+ 0x5F, 0x4B, 0x41, 0x54, 0x41, 0x4B, 0x41, 0x4E, 0x41, 0x5F, 0x46, 0x55, 0x4C, 0x4C, 0x00, 0x4A,
+ 0x41, 0x50, 0x41, 0x4E, 0x45, 0x53, 0x45, 0x5F, 0x4B, 0x41, 0x54, 0x41, 0x4B, 0x41, 0x4E, 0x41,
+ 0x5F, 0x48, 0x41, 0x4C, 0x46, 0x00, 0x4B, 0x4F, 0x52, 0x45, 0x41, 0x4E, 0x00, 0x55, 0x4E, 0x4B,
+ 0x4E, 0x4F, 0x57, 0x4E, 0x00, 0x38, 0x67, 0x65, 0x74, 0x45, 0x6E, 0x61, 0x62, 0x6C, 0x65, 0x64,
+ 0x2C, 0x38, 0x73, 0x65, 0x74, 0x45, 0x6E, 0x61, 0x62, 0x6C, 0x65, 0x64, 0x2C, 0x38, 0x67, 0x65,
+ 0x74, 0x43, 0x6F, 0x6E, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x4D, 0x6F, 0x64, 0x65, 0x2C,
+ 0x38, 0x73, 0x65, 0x74, 0x43, 0x6F, 0x6E, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x4D, 0x6F,
+ 0x64, 0x65, 0x2C, 0x38, 0x73, 0x65, 0x74, 0x43, 0x6F, 0x6D, 0x70, 0x6F, 0x73, 0x69, 0x74, 0x69,
+ 0x6F, 0x6E, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x2C, 0x38, 0x64, 0x6F, 0x43, 0x6F, 0x6E, 0x76,
+ 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x00, 0x43, 0x6F, 0x6C, 0x6F, 0x72, 0x00, 0x74, 0x61, 0x72,
+ 0x67, 0x65, 0x74, 0x00, 0x73, 0x65, 0x74, 0x52, 0x47, 0x42, 0x2C, 0x73, 0x65, 0x74, 0x54, 0x72,
+ 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x2C, 0x67, 0x65, 0x74, 0x52, 0x47, 0x42, 0x2C, 0x67,
+ 0x65, 0x74, 0x54, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x00, 0x54, 0x65, 0x78, 0x74,
+ 0x53, 0x6E, 0x61, 0x70, 0x73, 0x68, 0x6F, 0x74, 0x00, 0x36, 0x67, 0x65, 0x74, 0x43, 0x6F, 0x75,
+ 0x6E, 0x74, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x53, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x65, 0x64, 0x2C,
+ 0x36, 0x67, 0x65, 0x74, 0x53, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x65, 0x64, 0x2C, 0x36, 0x67, 0x65,
+ 0x74, 0x54, 0x65, 0x78, 0x74, 0x2C, 0x36, 0x67, 0x65, 0x74, 0x53, 0x65, 0x6C, 0x65, 0x63, 0x74,
+ 0x65, 0x64, 0x54, 0x65, 0x78, 0x74, 0x2C, 0x36, 0x68, 0x69, 0x74, 0x54, 0x65, 0x73, 0x74, 0x54,
+ 0x65, 0x78, 0x74, 0x4E, 0x65, 0x61, 0x72, 0x50, 0x6F, 0x73, 0x2C, 0x36, 0x66, 0x69, 0x6E, 0x64,
+ 0x54, 0x65, 0x78, 0x74, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x53, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x43,
+ 0x6F, 0x6C, 0x6F, 0x72, 0x2C, 0x36, 0x67, 0x65, 0x74, 0x54, 0x65, 0x78, 0x74, 0x52, 0x75, 0x6E,
+ 0x49, 0x6E, 0x66, 0x6F, 0x00, 0x4D, 0x6F, 0x76, 0x69, 0x65, 0x43, 0x6C, 0x69, 0x70, 0x00, 0x75,
+ 0x73, 0x65, 0x48, 0x61, 0x6E, 0x64, 0x43, 0x75, 0x72, 0x73, 0x6F, 0x72, 0x00, 0x65, 0x6E, 0x61,
+ 0x62, 0x6C, 0x65, 0x64, 0x00, 0x6D, 0x65, 0x74, 0x68, 0x00, 0x6D, 0x65, 0x74, 0x68, 0x6F, 0x64,
+ 0x00, 0x74, 0x6F, 0x4C, 0x6F, 0x77, 0x65, 0x72, 0x43, 0x61, 0x73, 0x65, 0x00, 0x6C, 0x6F, 0x77,
+ 0x65, 0x72, 0x00, 0x70, 0x6F, 0x73, 0x74, 0x00, 0x67, 0x65, 0x74, 0x00, 0x67, 0x65, 0x74, 0x55,
+ 0x52, 0x4C, 0x00, 0x74, 0x79, 0x70, 0x65, 0x00, 0x75, 0x72, 0x6C, 0x00, 0x6C, 0x6F, 0x61, 0x64,
+ 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6C, 0x65, 0x73, 0x00, 0x5F, 0x74, 0x61, 0x72, 0x67, 0x65,
+ 0x74, 0x00, 0x6C, 0x6F, 0x61, 0x64, 0x4D, 0x6F, 0x76, 0x69, 0x65, 0x00, 0x75, 0x6E, 0x6C, 0x6F,
+ 0x61, 0x64, 0x4D, 0x6F, 0x76, 0x69, 0x65, 0x00, 0x67, 0x65, 0x74, 0x54, 0x65, 0x78, 0x74, 0x53,
+ 0x6E, 0x61, 0x70, 0x73, 0x68, 0x6F, 0x74, 0x00, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x4D, 0x6F,
+ 0x76, 0x69, 0x65, 0x2C, 0x73, 0x77, 0x61, 0x70, 0x44, 0x65, 0x70, 0x74, 0x68, 0x73, 0x2C, 0x6C,
+ 0x6F, 0x63, 0x61, 0x6C, 0x54, 0x6F, 0x47, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x2C, 0x67, 0x6C, 0x6F,
+ 0x62, 0x61, 0x6C, 0x54, 0x6F, 0x4C, 0x6F, 0x63, 0x61, 0x6C, 0x2C, 0x68, 0x69, 0x74, 0x54, 0x65,
+ 0x73, 0x74, 0x2C, 0x67, 0x65, 0x74, 0x42, 0x6F, 0x75, 0x6E, 0x64, 0x73, 0x2C, 0x67, 0x65, 0x74,
+ 0x42, 0x79, 0x74, 0x65, 0x73, 0x54, 0x6F, 0x74, 0x61, 0x6C, 0x2C, 0x67, 0x65, 0x74, 0x42, 0x79,
+ 0x74, 0x65, 0x73, 0x4C, 0x6F, 0x61, 0x64, 0x65, 0x64, 0x2C, 0x36, 0x61, 0x74, 0x74, 0x61, 0x63,
+ 0x68, 0x41, 0x75, 0x64, 0x69, 0x6F, 0x2C, 0x36, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x56, 0x69,
+ 0x64, 0x65, 0x6F, 0x2C, 0x36, 0x67, 0x65, 0x74, 0x44, 0x65, 0x70, 0x74, 0x68, 0x2C, 0x36, 0x73,
+ 0x65, 0x74, 0x4D, 0x61, 0x73, 0x6B, 0x2C, 0x70, 0x6C, 0x61, 0x79, 0x2C, 0x73, 0x74, 0x6F, 0x70,
+ 0x2C, 0x6E, 0x65, 0x78, 0x74, 0x46, 0x72, 0x61, 0x6D, 0x65, 0x2C, 0x70, 0x72, 0x65, 0x76, 0x46,
+ 0x72, 0x61, 0x6D, 0x65, 0x2C, 0x67, 0x6F, 0x74, 0x6F, 0x41, 0x6E, 0x64, 0x50, 0x6C, 0x61, 0x79,
+ 0x2C, 0x67, 0x6F, 0x74, 0x6F, 0x41, 0x6E, 0x64, 0x53, 0x74, 0x6F, 0x70, 0x2C, 0x64, 0x75, 0x70,
+ 0x6C, 0x69, 0x63, 0x61, 0x74, 0x65, 0x4D, 0x6F, 0x76, 0x69, 0x65, 0x43, 0x6C, 0x69, 0x70, 0x2C,
+ 0x72, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x4D, 0x6F, 0x76, 0x69, 0x65, 0x43, 0x6C, 0x69, 0x70, 0x2C,
+ 0x73, 0x74, 0x61, 0x72, 0x74, 0x44, 0x72, 0x61, 0x67, 0x2C, 0x73, 0x74, 0x6F, 0x70, 0x44, 0x72,
+ 0x61, 0x67, 0x2C, 0x37, 0x67, 0x65, 0x74, 0x4E, 0x65, 0x78, 0x74, 0x48, 0x69, 0x67, 0x68, 0x65,
+ 0x73, 0x74, 0x44, 0x65, 0x70, 0x74, 0x68, 0x2C, 0x37, 0x67, 0x65, 0x74, 0x49, 0x6E, 0x73, 0x74,
+ 0x61, 0x6E, 0x63, 0x65, 0x41, 0x74, 0x44, 0x65, 0x70, 0x74, 0x68, 0x2C, 0x67, 0x65, 0x74, 0x53,
+ 0x57, 0x46, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x2C, 0x38, 0x61, 0x74, 0x74, 0x61, 0x63,
+ 0x68, 0x42, 0x69, 0x74, 0x6D, 0x61, 0x70, 0x2C, 0x38, 0x67, 0x65, 0x74, 0x52, 0x65, 0x63, 0x74,
+ 0x00, 0x74, 0x61, 0x62, 0x49, 0x6E, 0x64, 0x65, 0x78, 0x00, 0x5F, 0x6C, 0x6F, 0x63, 0x6B, 0x72,
+ 0x6F, 0x6F, 0x74, 0x00, 0x38, 0x63, 0x61, 0x63, 0x68, 0x65, 0x41, 0x73, 0x42, 0x69, 0x74, 0x6D,
+ 0x61, 0x70, 0x2C, 0x38, 0x6F, 0x70, 0x61, 0x71, 0x75, 0x65, 0x42, 0x61, 0x63, 0x6B, 0x67, 0x72,
+ 0x6F, 0x75, 0x6E, 0x64, 0x2C, 0x38, 0x73, 0x63, 0x72, 0x6F, 0x6C, 0x6C, 0x52, 0x65, 0x63, 0x74,
+ 0x00, 0x38, 0x66, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x73, 0x2C, 0x38, 0x74, 0x72, 0x61, 0x6E, 0x73,
+ 0x66, 0x6F, 0x72, 0x6D, 0x00, 0x38, 0x62, 0x6C, 0x65, 0x6E, 0x64, 0x4D, 0x6F, 0x64, 0x65, 0x00,
+ 0x36, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x6D, 0x70, 0x74, 0x79, 0x4D, 0x6F, 0x76, 0x69,
+ 0x65, 0x43, 0x6C, 0x69, 0x70, 0x2C, 0x36, 0x62, 0x65, 0x67, 0x69, 0x6E, 0x46, 0x69, 0x6C, 0x6C,
+ 0x2C, 0x36, 0x62, 0x65, 0x67, 0x69, 0x6E, 0x47, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6E, 0x74, 0x46,
+ 0x69, 0x6C, 0x6C, 0x2C, 0x36, 0x6D, 0x6F, 0x76, 0x65, 0x54, 0x6F, 0x2C, 0x36, 0x6C, 0x69, 0x6E,
+ 0x65, 0x54, 0x6F, 0x2C, 0x36, 0x63, 0x75, 0x72, 0x76, 0x65, 0x54, 0x6F, 0x2C, 0x36, 0x6C, 0x69,
+ 0x6E, 0x65, 0x53, 0x74, 0x79, 0x6C, 0x65, 0x2C, 0x36, 0x65, 0x6E, 0x64, 0x46, 0x69, 0x6C, 0x6C,
+ 0x2C, 0x36, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x2C, 0x38, 0x6C, 0x69, 0x6E, 0x65, 0x47, 0x72, 0x61,
+ 0x64, 0x69, 0x65, 0x6E, 0x74, 0x53, 0x74, 0x79, 0x6C, 0x65, 0x2C, 0x38, 0x62, 0x65, 0x67, 0x69,
+ 0x6E, 0x4D, 0x65, 0x73, 0x68, 0x46, 0x69, 0x6C, 0x6C, 0x2C, 0x38, 0x62, 0x65, 0x67, 0x69, 0x6E,
+ 0x42, 0x69, 0x74, 0x6D, 0x61, 0x70, 0x46, 0x69, 0x6C, 0x6C, 0x00, 0x38, 0x73, 0x63, 0x61, 0x6C,
+ 0x65, 0x39, 0x47, 0x72, 0x69, 0x64, 0x00, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x65, 0x78,
+ 0x74, 0x46, 0x69, 0x65, 0x6C, 0x64, 0x00, 0x4D, 0x6F, 0x76, 0x69, 0x65, 0x43, 0x6C, 0x69, 0x70,
+ 0x4C, 0x6F, 0x61, 0x64, 0x65, 0x72, 0x00, 0x37, 0x6C, 0x6F, 0x61, 0x64, 0x43, 0x6C, 0x69, 0x70,
+ 0x2C, 0x37, 0x67, 0x65, 0x74, 0x50, 0x72, 0x6F, 0x67, 0x72, 0x65, 0x73, 0x73, 0x2C, 0x37, 0x75,
+ 0x6E, 0x6C, 0x6F, 0x61, 0x64, 0x43, 0x6C, 0x69, 0x70, 0x00, 0x54, 0x65, 0x78, 0x74, 0x46, 0x69,
+ 0x65, 0x6C, 0x64, 0x00, 0x67, 0x65, 0x74, 0x46, 0x6F, 0x6E, 0x74, 0x4C, 0x69, 0x73, 0x74, 0x00,
+ 0x36, 0x72, 0x65, 0x70, 0x6C, 0x61, 0x63, 0x65, 0x53, 0x65, 0x6C, 0x2C, 0x36, 0x67, 0x65, 0x74,
+ 0x54, 0x65, 0x78, 0x74, 0x46, 0x6F, 0x72, 0x6D, 0x61, 0x74, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x54,
+ 0x65, 0x78, 0x74, 0x46, 0x6F, 0x72, 0x6D, 0x61, 0x74, 0x2C, 0x36, 0x72, 0x65, 0x6D, 0x6F, 0x76,
+ 0x65, 0x54, 0x65, 0x78, 0x74, 0x46, 0x69, 0x65, 0x6C, 0x64, 0x2C, 0x36, 0x67, 0x65, 0x74, 0x4E,
+ 0x65, 0x77, 0x54, 0x65, 0x78, 0x74, 0x46, 0x6F, 0x72, 0x6D, 0x61, 0x74, 0x2C, 0x36, 0x73, 0x65,
+ 0x74, 0x4E, 0x65, 0x77, 0x54, 0x65, 0x78, 0x74, 0x46, 0x6F, 0x72, 0x6D, 0x61, 0x74, 0x2C, 0x36,
+ 0x67, 0x65, 0x74, 0x44, 0x65, 0x70, 0x74, 0x68, 0x2C, 0x37, 0x72, 0x65, 0x70, 0x6C, 0x61, 0x63,
+ 0x65, 0x54, 0x65, 0x78, 0x74, 0x00, 0x38, 0x67, 0x72, 0x69, 0x64, 0x46, 0x69, 0x74, 0x54, 0x79,
+ 0x70, 0x65, 0x2C, 0x38, 0x61, 0x6E, 0x74, 0x69, 0x41, 0x6C, 0x69, 0x61, 0x73, 0x54, 0x79, 0x70,
+ 0x65, 0x2C, 0x38, 0x74, 0x68, 0x69, 0x63, 0x6B, 0x6E, 0x65, 0x73, 0x73, 0x2C, 0x38, 0x73, 0x68,
+ 0x61, 0x72, 0x70, 0x6E, 0x65, 0x73, 0x73, 0x2C, 0x38, 0x66, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x73,
+ 0x00, 0x38, 0x74, 0x61, 0x62, 0x49, 0x6E, 0x64, 0x65, 0x78, 0x00, 0x54, 0x65, 0x78, 0x74, 0x46,
+ 0x6F, 0x72, 0x6D, 0x61, 0x74, 0x00, 0x53, 0x74, 0x79, 0x6C, 0x65, 0x53, 0x68, 0x65, 0x65, 0x74,
+ 0x00, 0x5F, 0x63, 0x6F, 0x70, 0x79, 0x00, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x6F, 0x5F,
+ 0x6E, 0x65, 0x77, 0x00, 0x70, 0x72, 0x6F, 0x70, 0x00, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x00, 0x5F,
+ 0x63, 0x73, 0x73, 0x00, 0x5F, 0x73, 0x74, 0x79, 0x6C, 0x65, 0x73, 0x00, 0x75, 0x70, 0x64, 0x61,
+ 0x74, 0x65, 0x00, 0x67, 0x65, 0x74, 0x53, 0x74, 0x79, 0x6C, 0x65, 0x00, 0x73, 0x65, 0x74, 0x53,
+ 0x74, 0x79, 0x6C, 0x65, 0x00, 0x73, 0x74, 0x79, 0x6C, 0x65, 0x00, 0x64, 0x6F, 0x54, 0x72, 0x61,
+ 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x00, 0x67, 0x65, 0x74, 0x53, 0x74, 0x79, 0x6C, 0x65, 0x4E,
+ 0x61, 0x6D, 0x65, 0x73, 0x00, 0x74, 0x6D, 0x70, 0x00, 0x6E, 0x61, 0x6D, 0x65, 0x73, 0x00, 0x74,
+ 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x00, 0x66, 0x6F, 0x72, 0x6D, 0x61, 0x74, 0x00,
+ 0x74, 0x65, 0x78, 0x74, 0x41, 0x6C, 0x69, 0x67, 0x6E, 0x00, 0x61, 0x6C, 0x69, 0x67, 0x6E, 0x00,
+ 0x66, 0x6F, 0x6E, 0x74, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x00, 0x62, 0x6F, 0x6C, 0x64, 0x00,
+ 0x6E, 0x6F, 0x72, 0x6D, 0x61, 0x6C, 0x00, 0x63, 0x6F, 0x6C, 0x6F, 0x72, 0x00, 0x70, 0x61, 0x72,
+ 0x73, 0x65, 0x43, 0x6F, 0x6C, 0x6F, 0x72, 0x00, 0x64, 0x69, 0x73, 0x70, 0x6C, 0x61, 0x79, 0x00,
+ 0x66, 0x6F, 0x6E, 0x74, 0x46, 0x61, 0x6D, 0x69, 0x6C, 0x79, 0x00, 0x66, 0x6F, 0x6E, 0x74, 0x00,
+ 0x70, 0x61, 0x72, 0x73, 0x65, 0x43, 0x53, 0x53, 0x46, 0x6F, 0x6E, 0x74, 0x46, 0x61, 0x6D, 0x69,
+ 0x6C, 0x79, 0x00, 0x74, 0x65, 0x78, 0x74, 0x49, 0x6E, 0x64, 0x65, 0x6E, 0x74, 0x00, 0x69, 0x6E,
+ 0x64, 0x65, 0x6E, 0x74, 0x00, 0x70, 0x61, 0x72, 0x73, 0x65, 0x49, 0x6E, 0x74, 0x00, 0x66, 0x6F,
+ 0x6E, 0x74, 0x53, 0x74, 0x79, 0x6C, 0x65, 0x00, 0x69, 0x74, 0x61, 0x6C, 0x69, 0x63, 0x00, 0x6B,
+ 0x65, 0x72, 0x6E, 0x69, 0x6E, 0x67, 0x00, 0x74, 0x72, 0x75, 0x65, 0x00, 0x66, 0x61, 0x6C, 0x73,
+ 0x65, 0x00, 0x6C, 0x65, 0x61, 0x64, 0x69, 0x6E, 0x67, 0x00, 0x6D, 0x61, 0x72, 0x67, 0x69, 0x6E,
+ 0x4C, 0x65, 0x66, 0x74, 0x00, 0x6C, 0x65, 0x66, 0x74, 0x4D, 0x61, 0x72, 0x67, 0x69, 0x6E, 0x00,
+ 0x6C, 0x65, 0x74, 0x74, 0x65, 0x72, 0x53, 0x70, 0x61, 0x63, 0x69, 0x6E, 0x67, 0x00, 0x6D, 0x61,
+ 0x72, 0x67, 0x69, 0x6E, 0x52, 0x69, 0x67, 0x68, 0x74, 0x00, 0x72, 0x69, 0x67, 0x68, 0x74, 0x4D,
+ 0x61, 0x72, 0x67, 0x69, 0x6E, 0x00, 0x66, 0x6F, 0x6E, 0x74, 0x53, 0x69, 0x7A, 0x65, 0x00, 0x73,
+ 0x69, 0x7A, 0x65, 0x00, 0x74, 0x65, 0x78, 0x74, 0x44, 0x65, 0x63, 0x6F, 0x72, 0x61, 0x74, 0x69,
+ 0x6F, 0x6E, 0x00, 0x75, 0x6E, 0x64, 0x65, 0x72, 0x6C, 0x69, 0x6E, 0x65, 0x00, 0x70, 0x61, 0x72,
+ 0x73, 0x65, 0x43, 0x53, 0x53, 0x00, 0x63, 0x73, 0x73, 0x00, 0x70, 0x61, 0x72, 0x73, 0x65, 0x43,
+ 0x53, 0x53, 0x49, 0x6E, 0x74, 0x65, 0x72, 0x6E, 0x61, 0x6C, 0x00, 0x72, 0x65, 0x73, 0x75, 0x6C,
+ 0x74, 0x00, 0x6E, 0x75, 0x6C, 0x6C, 0x00, 0x70, 0x61, 0x72, 0x73, 0x65, 0x00, 0x37, 0x75, 0x70,
+ 0x64, 0x61, 0x74, 0x65, 0x2C, 0x37, 0x70, 0x61, 0x72, 0x73, 0x65, 0x43, 0x53, 0x53, 0x49, 0x6E,
+ 0x74, 0x65, 0x72, 0x6E, 0x61, 0x6C, 0x2C, 0x37, 0x70, 0x61, 0x72, 0x73, 0x65, 0x43, 0x53, 0x53,
+ 0x46, 0x6F, 0x6E, 0x74, 0x46, 0x61, 0x6D, 0x69, 0x6C, 0x79, 0x2C, 0x37, 0x70, 0x61, 0x72, 0x73,
+ 0x65, 0x43, 0x6F, 0x6C, 0x6F, 0x72, 0x00, 0x56, 0x69, 0x64, 0x65, 0x6F, 0x00, 0x36, 0x61, 0x74,
+ 0x74, 0x61, 0x63, 0x68, 0x56, 0x69, 0x64, 0x65, 0x6F, 0x2C, 0x36, 0x63, 0x6C, 0x65, 0x61, 0x72,
+ 0x00, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x69, 0x62, 0x69, 0x6C, 0x69, 0x74, 0x79, 0x00, 0x36,
+ 0x69, 0x73, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x2C, 0x36, 0x73, 0x65, 0x6E, 0x64, 0x45, 0x76,
+ 0x65, 0x6E, 0x74, 0x2C, 0x36, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6F, 0x70, 0x65,
+ 0x72, 0x74, 0x69, 0x65, 0x73, 0x00, 0x43, 0x61, 0x6D, 0x65, 0x72, 0x61, 0x00, 0x67, 0x65, 0x74,
+ 0x5F, 0x66, 0x75, 0x6E, 0x63, 0x00, 0x69, 0x6E, 0x64, 0x65, 0x78, 0x00, 0x36, 0x73, 0x65, 0x74,
+ 0x4D, 0x6F, 0x64, 0x65, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x51, 0x75, 0x61, 0x6C, 0x69, 0x74, 0x79,
+ 0x2C, 0x36, 0x73, 0x65, 0x74, 0x4B, 0x65, 0x79, 0x46, 0x72, 0x61, 0x6D, 0x65, 0x49, 0x6E, 0x74,
+ 0x65, 0x72, 0x76, 0x61, 0x6C, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x4D, 0x6F, 0x74, 0x69, 0x6F, 0x6E,
+ 0x4C, 0x65, 0x76, 0x65, 0x6C, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x4C, 0x6F, 0x6F, 0x70, 0x62, 0x61,
+ 0x63, 0x6B, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x43, 0x75, 0x72, 0x73, 0x6F, 0x72, 0x00, 0x6F, 0x6E,
+ 0x53, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x00, 0x63, 0x61, 0x6C, 0x6C, 0x62, 0x61, 0x63, 0x6B, 0x00,
+ 0x63, 0x75, 0x73, 0x74, 0x6F, 0x6D, 0x49, 0x74, 0x65, 0x6D, 0x73, 0x00, 0x41, 0x72, 0x72, 0x61,
+ 0x79, 0x00, 0x62, 0x75, 0x69, 0x6C, 0x74, 0x49, 0x6E, 0x49, 0x74, 0x65, 0x6D, 0x73, 0x00, 0x66,
+ 0x6F, 0x72, 0x77, 0x61, 0x72, 0x64, 0x5F, 0x62, 0x61, 0x63, 0x6B, 0x00, 0x6C, 0x6F, 0x6F, 0x70,
+ 0x00, 0x70, 0x6C, 0x61, 0x79, 0x00, 0x70, 0x72, 0x69, 0x6E, 0x74, 0x00, 0x71, 0x75, 0x61, 0x6C,
+ 0x69, 0x74, 0x79, 0x00, 0x72, 0x65, 0x77, 0x69, 0x6E, 0x64, 0x00, 0x73, 0x61, 0x76, 0x65, 0x00,
+ 0x7A, 0x6F, 0x6F, 0x6D, 0x00, 0x43, 0x6F, 0x6E, 0x74, 0x65, 0x78, 0x74, 0x4D, 0x65, 0x6E, 0x75,
+ 0x00, 0x63, 0x6F, 0x70, 0x79, 0x00, 0x68, 0x69, 0x64, 0x65, 0x42, 0x75, 0x69, 0x6C, 0x74, 0x49,
+ 0x6E, 0x49, 0x74, 0x65, 0x6D, 0x73, 0x00, 0x63, 0x61, 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x73,
+ 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x6F, 0x72, 0x42, 0x65, 0x66, 0x6F, 0x72, 0x65, 0x00, 0x76,
+ 0x69, 0x73, 0x69, 0x62, 0x6C, 0x65, 0x00, 0x43, 0x6F, 0x6E, 0x74, 0x65, 0x78, 0x74, 0x4D, 0x65,
+ 0x6E, 0x75, 0x49, 0x74, 0x65, 0x6D, 0x00, 0x6E, 0x65, 0x74, 0x00, 0x46, 0x69, 0x6C, 0x65, 0x52,
+ 0x65, 0x66, 0x65, 0x72, 0x65, 0x6E, 0x63, 0x65, 0x00, 0x63, 0x00, 0x38, 0x62, 0x72, 0x6F, 0x77,
+ 0x73, 0x65, 0x2C, 0x38, 0x75, 0x70, 0x6C, 0x6F, 0x61, 0x64, 0x2C, 0x38, 0x64, 0x6F, 0x77, 0x6E,
+ 0x6C, 0x6F, 0x61, 0x64, 0x2C, 0x38, 0x63, 0x61, 0x6E, 0x63, 0x65, 0x6C, 0x00, 0x46, 0x69, 0x6C,
+ 0x65, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6E, 0x63, 0x65, 0x4C, 0x69, 0x73, 0x74, 0x00, 0x66,
+ 0x69, 0x6C, 0x65, 0x4C, 0x69, 0x73, 0x74, 0x00, 0x38, 0x62, 0x72, 0x6F, 0x77, 0x73, 0x65, 0x00,
+ 0x4C, 0x6F, 0x63, 0x61, 0x6C, 0x43, 0x6F, 0x6E, 0x6E, 0x65, 0x63, 0x74, 0x69, 0x6F, 0x6E, 0x00,
+ 0x36, 0x63, 0x6F, 0x6E, 0x6E, 0x65, 0x63, 0x74, 0x2C, 0x36, 0x73, 0x65, 0x6E, 0x64, 0x2C, 0x36,
+ 0x63, 0x6C, 0x6F, 0x73, 0x65, 0x2C, 0x36, 0x64, 0x6F, 0x6D, 0x61, 0x69, 0x6E, 0x00, 0x4D, 0x69,
+ 0x63, 0x72, 0x6F, 0x70, 0x68, 0x6F, 0x6E, 0x65, 0x00, 0x36, 0x73, 0x65, 0x74, 0x53, 0x69, 0x6C,
+ 0x65, 0x6E, 0x63, 0x65, 0x4C, 0x65, 0x76, 0x65, 0x6C, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x52, 0x61,
+ 0x74, 0x65, 0x2C, 0x36, 0x73, 0x65, 0x74, 0x47, 0x61, 0x69, 0x6E, 0x2C, 0x36, 0x73, 0x65, 0x74,
+ 0x55, 0x73, 0x65, 0x45, 0x63, 0x68, 0x6F, 0x53, 0x75, 0x70, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69,
+ 0x6F, 0x6E, 0x00, 0x50, 0x72, 0x69, 0x6E, 0x74, 0x4A, 0x6F, 0x62, 0x00, 0x37, 0x73, 0x74, 0x61,
+ 0x72, 0x74, 0x2C, 0x37, 0x61, 0x64, 0x64, 0x50, 0x61, 0x67, 0x65, 0x2C, 0x37, 0x73, 0x65, 0x6E,
+ 0x64, 0x00, 0x53, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x67, 0x65, 0x74, 0x42,
+ 0x65, 0x67, 0x69, 0x6E, 0x49, 0x6E, 0x64, 0x65, 0x78, 0x2C, 0x67, 0x65, 0x74, 0x45, 0x6E, 0x64,
+ 0x49, 0x6E, 0x64, 0x65, 0x78, 0x2C, 0x67, 0x65, 0x74, 0x43, 0x61, 0x72, 0x65, 0x74, 0x49, 0x6E,
+ 0x64, 0x65, 0x78, 0x2C, 0x67, 0x65, 0x74, 0x46, 0x6F, 0x63, 0x75, 0x73, 0x2C, 0x73, 0x65, 0x74,
+ 0x46, 0x6F, 0x63, 0x75, 0x73, 0x2C, 0x73, 0x65, 0x74, 0x53, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x69,
+ 0x6F, 0x6E, 0x00, 0x74, 0x65, 0x78, 0x74, 0x00, 0x54, 0x65, 0x78, 0x74, 0x52, 0x65, 0x6E, 0x64,
+ 0x65, 0x72, 0x65, 0x72, 0x00, 0x38, 0x73, 0x65, 0x74, 0x41, 0x64, 0x76, 0x61, 0x6E, 0x63, 0x65,
+ 0x64, 0x41, 0x6E, 0x74, 0x69, 0x61, 0x6C, 0x69, 0x61, 0x73, 0x69, 0x6E, 0x67, 0x54, 0x61, 0x62,
+ 0x6C, 0x65, 0x00, 0x38, 0x6D, 0x61, 0x78, 0x4C, 0x65, 0x76, 0x65, 0x6C, 0x00, 0x38, 0x64, 0x69,
+ 0x73, 0x70, 0x6C, 0x61, 0x79, 0x4D, 0x6F, 0x64, 0x65, 0x00, 0x74, 0x65, 0x78, 0x74, 0x52, 0x65,
+ 0x6E, 0x64, 0x65, 0x72, 0x65, 0x72, 0x00, 0x58, 0x4D, 0x4C, 0x53, 0x6F, 0x63, 0x6B, 0x65, 0x74,
+ 0x00, 0x6F, 0x6E, 0x58, 0x4D, 0x4C, 0x00, 0x63, 0x6F, 0x6E, 0x6E, 0x65, 0x63, 0x74, 0x2C, 0x73,
+ 0x65, 0x6E, 0x64, 0x2C, 0x63, 0x6C, 0x6F, 0x73, 0x65, 0x00, 0x67, 0x65, 0x6F, 0x6D, 0x00, 0x50,
+ 0x6F, 0x69, 0x6E, 0x74, 0x00, 0x61, 0x72, 0x67, 0x75, 0x6D, 0x65, 0x6E, 0x74, 0x73, 0x00, 0x79,
+ 0x00, 0x64, 0x69, 0x73, 0x74, 0x61, 0x6E, 0x63, 0x65, 0x00, 0x61, 0x00, 0x62, 0x00, 0x73, 0x75,
+ 0x62, 0x74, 0x72, 0x61, 0x63, 0x74, 0x00, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x70, 0x6F, 0x6C, 0x61,
+ 0x74, 0x65, 0x00, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x00, 0x70, 0x6F, 0x6C, 0x61, 0x72, 0x00, 0x4D,
+ 0x61, 0x74, 0x68, 0x00, 0x61, 0x6E, 0x67, 0x6C, 0x65, 0x00, 0x63, 0x6F, 0x73, 0x00, 0x73, 0x69,
+ 0x6E, 0x00, 0x73, 0x71, 0x72, 0x74, 0x00, 0x61, 0x64, 0x64, 0x00, 0x6F, 0x74, 0x68, 0x65, 0x72,
+ 0x00, 0x63, 0x6C, 0x6F, 0x6E, 0x65, 0x00, 0x65, 0x71, 0x75, 0x61, 0x6C, 0x73, 0x00, 0x6E, 0x6F,
+ 0x72, 0x6D, 0x61, 0x6C, 0x69, 0x7A, 0x65, 0x00, 0x66, 0x61, 0x63, 0x74, 0x6F, 0x72, 0x00, 0x6F,
+ 0x66, 0x66, 0x73, 0x65, 0x74, 0x00, 0x28, 0x78, 0x3D, 0x00, 0x2C, 0x20, 0x79, 0x3D, 0x00, 0x29,
+ 0x00, 0x52, 0x65, 0x63, 0x74, 0x61, 0x6E, 0x67, 0x6C, 0x65, 0x00, 0x73, 0x65, 0x74, 0x45, 0x6D,
+ 0x70, 0x74, 0x79, 0x00, 0x77, 0x69, 0x64, 0x74, 0x68, 0x00, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74,
+ 0x00, 0x2C, 0x20, 0x77, 0x3D, 0x00, 0x2C, 0x20, 0x68, 0x3D, 0x00, 0x72, 0x65, 0x63, 0x74, 0x00,
+ 0x63, 0x6F, 0x6E, 0x74, 0x61, 0x69, 0x6E, 0x73, 0x00, 0x63, 0x6F, 0x6E, 0x74, 0x61, 0x69, 0x6E,
+ 0x73, 0x50, 0x6F, 0x69, 0x6E, 0x74, 0x00, 0x70, 0x6F, 0x69, 0x6E, 0x74, 0x00, 0x63, 0x6F, 0x6E,
+ 0x74, 0x61, 0x69, 0x6E, 0x73, 0x52, 0x65, 0x63, 0x74, 0x61, 0x6E, 0x67, 0x6C, 0x65, 0x00, 0x74,
+ 0x72, 0x00, 0x74, 0x62, 0x00, 0x72, 0x72, 0x00, 0x72, 0x62, 0x00, 0x69, 0x73, 0x45, 0x6D, 0x70,
+ 0x74, 0x79, 0x00, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x73, 0x65, 0x63, 0x74, 0x69, 0x6F, 0x6E, 0x00,
+ 0x69, 0x6E, 0x74, 0x73, 0x00, 0x6D, 0x61, 0x78, 0x00, 0x6D, 0x69, 0x6E, 0x00, 0x69, 0x6E, 0x74,
+ 0x65, 0x72, 0x73, 0x65, 0x63, 0x74, 0x73, 0x00, 0x75, 0x6E, 0x69, 0x6F, 0x6E, 0x00, 0x64, 0x78,
+ 0x00, 0x64, 0x79, 0x00, 0x6F, 0x66, 0x66, 0x73, 0x65, 0x74, 0x50, 0x6F, 0x69, 0x6E, 0x74, 0x00,
+ 0x64, 0x00, 0x69, 0x6E, 0x66, 0x6C, 0x61, 0x74, 0x65, 0x00, 0x69, 0x6E, 0x66, 0x6C, 0x61, 0x74,
+ 0x65, 0x50, 0x6F, 0x69, 0x6E, 0x74, 0x00, 0x6C, 0x65, 0x66, 0x74, 0x00, 0x72, 0x69, 0x67, 0x68,
+ 0x74, 0x00, 0x74, 0x6F, 0x70, 0x00, 0x62, 0x6F, 0x74, 0x74, 0x6F, 0x6D, 0x00, 0x74, 0x6F, 0x70,
+ 0x4C, 0x65, 0x66, 0x74, 0x00, 0x62, 0x6F, 0x74, 0x74, 0x6F, 0x6D, 0x52, 0x69, 0x67, 0x68, 0x74,
+ 0x00, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E,
+ 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65,
+ 0x6E, 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x63, 0x6C, 0x6F, 0x6E, 0x65, 0x00,
+ 0x63, 0x6F, 0x6E, 0x63, 0x61, 0x74, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74,
+ 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x63, 0x6F, 0x6E, 0x63, 0x61, 0x74, 0x00, 0x63,
+ 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6F, 0x78, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65,
+ 0x6E, 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65,
+ 0x42, 0x6F, 0x78, 0x00, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x61, 0x64, 0x69, 0x65,
+ 0x6E, 0x74, 0x42, 0x6F, 0x78, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20,
+ 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x61,
+ 0x64, 0x69, 0x65, 0x6E, 0x74, 0x42, 0x6F, 0x78, 0x00, 0x64, 0x65, 0x6C, 0x74, 0x61, 0x54, 0x72,
+ 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x50, 0x6F, 0x69, 0x6E, 0x74, 0x00, 0x49, 0x6D, 0x70,
+ 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x64, 0x65,
+ 0x6C, 0x74, 0x61, 0x54, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x50, 0x6F, 0x69, 0x6E,
+ 0x74, 0x00, 0x69, 0x64, 0x65, 0x6E, 0x74, 0x69, 0x74, 0x79, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65,
+ 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x69, 0x64, 0x65, 0x6E,
+ 0x74, 0x69, 0x74, 0x79, 0x00, 0x69, 0x6E, 0x76, 0x65, 0x72, 0x74, 0x00, 0x49, 0x6D, 0x70, 0x6C,
+ 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x69, 0x6E, 0x76,
+ 0x65, 0x72, 0x74, 0x00, 0x72, 0x6F, 0x74, 0x61, 0x74, 0x65, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65,
+ 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x72, 0x6F, 0x74, 0x61,
+ 0x74, 0x65, 0x00, 0x73, 0x63, 0x61, 0x6C, 0x65, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65,
+ 0x6E, 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x73, 0x63, 0x61, 0x6C, 0x65, 0x00,
+ 0x74, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x50, 0x6F, 0x69, 0x6E, 0x74, 0x00, 0x49,
+ 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E,
+ 0x74, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x50, 0x6F, 0x69, 0x6E, 0x74, 0x00, 0x74,
+ 0x72, 0x61, 0x6E, 0x73, 0x6C, 0x61, 0x74, 0x65, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65,
+ 0x6E, 0x74, 0x20, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2E, 0x74, 0x72, 0x61, 0x6E, 0x73, 0x6C,
+ 0x61, 0x74, 0x65, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x4D, 0x61,
+ 0x74, 0x72, 0x69, 0x78, 0x2E, 0x74, 0x6F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x43, 0x6F,
+ 0x6C, 0x6F, 0x72, 0x54, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x00, 0x49, 0x6D, 0x70,
+ 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x43, 0x6F, 0x6C, 0x6F, 0x72, 0x54, 0x72, 0x61, 0x6E,
+ 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x2E, 0x74, 0x6F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x38,
+ 0x63, 0x6F, 0x6E, 0x63, 0x61, 0x74, 0x00, 0x38, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x4D, 0x75, 0x6C,
+ 0x74, 0x69, 0x70, 0x6C, 0x69, 0x65, 0x72, 0x2C, 0x38, 0x72, 0x65, 0x64, 0x4D, 0x75, 0x6C, 0x74,
+ 0x69, 0x70, 0x6C, 0x69, 0x65, 0x72, 0x2C, 0x38, 0x67, 0x72, 0x65, 0x65, 0x6E, 0x4D, 0x75, 0x6C,
+ 0x74, 0x69, 0x70, 0x6C, 0x69, 0x65, 0x72, 0x2C, 0x38, 0x62, 0x6C, 0x75, 0x65, 0x4D, 0x75, 0x6C,
+ 0x74, 0x69, 0x70, 0x6C, 0x69, 0x65, 0x72, 0x2C, 0x38, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x4F, 0x66,
+ 0x66, 0x73, 0x65, 0x74, 0x2C, 0x38, 0x72, 0x65, 0x64, 0x4F, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2C,
+ 0x38, 0x67, 0x72, 0x65, 0x65, 0x6E, 0x4F, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2C, 0x38, 0x62, 0x6C,
+ 0x75, 0x65, 0x4F, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2C, 0x38, 0x72, 0x67, 0x62, 0x00, 0x54, 0x72,
+ 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x00, 0x38, 0x6D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2C,
+ 0x38, 0x63, 0x6F, 0x6E, 0x63, 0x61, 0x74, 0x65, 0x6E, 0x61, 0x74, 0x65, 0x64, 0x4D, 0x61, 0x74,
+ 0x72, 0x69, 0x78, 0x2C, 0x38, 0x63, 0x6F, 0x6C, 0x6F, 0x72, 0x54, 0x72, 0x61, 0x6E, 0x73, 0x66,
+ 0x6F, 0x72, 0x6D, 0x2C, 0x38, 0x63, 0x6F, 0x6E, 0x63, 0x61, 0x74, 0x65, 0x6E, 0x61, 0x74, 0x65,
+ 0x64, 0x43, 0x6F, 0x6C, 0x6F, 0x72, 0x54, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x2C,
+ 0x38, 0x70, 0x69, 0x78, 0x65, 0x6C, 0x42, 0x6F, 0x75, 0x6E, 0x64, 0x73, 0x00, 0x42, 0x69, 0x74,
+ 0x6D, 0x61, 0x70, 0x44, 0x61, 0x74, 0x61, 0x00, 0x52, 0x45, 0x44, 0x5F, 0x43, 0x48, 0x41, 0x4E,
+ 0x4E, 0x45, 0x4C, 0x00, 0x47, 0x52, 0x45, 0x45, 0x4E, 0x5F, 0x43, 0x48, 0x41, 0x4E, 0x4E, 0x45,
+ 0x4C, 0x00, 0x42, 0x4C, 0x55, 0x45, 0x5F, 0x43, 0x48, 0x41, 0x4E, 0x4E, 0x45, 0x4C, 0x00, 0x41,
+ 0x4C, 0x50, 0x48, 0x41, 0x5F, 0x43, 0x48, 0x41, 0x4E, 0x4E, 0x45, 0x4C, 0x00, 0x38, 0x6C, 0x6F,
+ 0x61, 0x64, 0x42, 0x69, 0x74, 0x6D, 0x61, 0x70, 0x00, 0x38, 0x67, 0x65, 0x74, 0x50, 0x69, 0x78,
+ 0x65, 0x6C, 0x2C, 0x38, 0x73, 0x65, 0x74, 0x50, 0x69, 0x78, 0x65, 0x6C, 0x2C, 0x38, 0x66, 0x69,
+ 0x6C, 0x6C, 0x52, 0x65, 0x63, 0x74, 0x2C, 0x38, 0x63, 0x6F, 0x70, 0x79, 0x50, 0x69, 0x78, 0x65,
+ 0x6C, 0x73, 0x2C, 0x38, 0x61, 0x70, 0x70, 0x6C, 0x79, 0x46, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x2C,
+ 0x38, 0x73, 0x63, 0x72, 0x6F, 0x6C, 0x6C, 0x2C, 0x38, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6F,
+ 0x6C, 0x64, 0x2C, 0x38, 0x64, 0x72, 0x61, 0x77, 0x2C, 0x38, 0x70, 0x69, 0x78, 0x65, 0x6C, 0x44,
+ 0x69, 0x73, 0x73, 0x6F, 0x6C, 0x76, 0x65, 0x2C, 0x38, 0x67, 0x65, 0x74, 0x50, 0x69, 0x78, 0x65,
+ 0x6C, 0x33, 0x32, 0x2C, 0x38, 0x73, 0x65, 0x74, 0x50, 0x69, 0x78, 0x65, 0x6C, 0x33, 0x32, 0x2C,
+ 0x38, 0x66, 0x6C, 0x6F, 0x6F, 0x64, 0x46, 0x69, 0x6C, 0x6C, 0x2C, 0x38, 0x67, 0x65, 0x74, 0x43,
+ 0x6F, 0x6C, 0x6F, 0x72, 0x42, 0x6F, 0x75, 0x6E, 0x64, 0x73, 0x52, 0x65, 0x63, 0x74, 0x2C, 0x38,
+ 0x70, 0x65, 0x72, 0x6C, 0x69, 0x6E, 0x4E, 0x6F, 0x69, 0x73, 0x65, 0x2C, 0x38, 0x63, 0x6F, 0x6C,
+ 0x6F, 0x72, 0x54, 0x72, 0x61, 0x6E, 0x73, 0x66, 0x6F, 0x72, 0x6D, 0x2C, 0x38, 0x68, 0x69, 0x74,
+ 0x54, 0x65, 0x73, 0x74, 0x2C, 0x38, 0x70, 0x61, 0x6C, 0x65, 0x74, 0x74, 0x65, 0x4D, 0x61, 0x70,
+ 0x2C, 0x38, 0x6D, 0x65, 0x72, 0x67, 0x65, 0x2C, 0x38, 0x6E, 0x6F, 0x69, 0x73, 0x65, 0x2C, 0x38,
+ 0x63, 0x6F, 0x70, 0x79, 0x43, 0x68, 0x61, 0x6E, 0x6E, 0x65, 0x6C, 0x2C, 0x38, 0x63, 0x6C, 0x6F,
+ 0x6E, 0x65, 0x2C, 0x38, 0x64, 0x69, 0x73, 0x70, 0x6F, 0x73, 0x65, 0x2C, 0x38, 0x67, 0x65, 0x6E,
+ 0x65, 0x72, 0x61, 0x74, 0x65, 0x46, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x52, 0x65, 0x63, 0x74, 0x2C,
+ 0x38, 0x63, 0x6F, 0x6D, 0x70, 0x61, 0x72, 0x65, 0x00, 0x38, 0x77, 0x69, 0x64, 0x74, 0x68, 0x2C,
+ 0x38, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x2C, 0x38, 0x72, 0x65, 0x63, 0x74, 0x61, 0x6E, 0x67,
+ 0x6C, 0x65, 0x2C, 0x38, 0x74, 0x72, 0x61, 0x6E, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6E, 0x74, 0x00,
+ 0x65, 0x78, 0x74, 0x65, 0x72, 0x6E, 0x61, 0x6C, 0x00, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6E, 0x61,
+ 0x6C, 0x49, 0x6E, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x00, 0x61, 0x64, 0x64, 0x43, 0x61,
+ 0x6C, 0x6C, 0x62, 0x61, 0x63, 0x6B, 0x00, 0x61, 0x76, 0x61, 0x69, 0x6C, 0x61, 0x62, 0x6C, 0x65,
+ 0x00, 0x5F, 0x69, 0x6E, 0x69, 0x74, 0x4A, 0x53, 0x00, 0x69, 0x6E, 0x73, 0x74, 0x61, 0x6E, 0x63,
+ 0x65, 0x00, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x00, 0x5F, 0x63, 0x61, 0x6C, 0x6C, 0x49,
+ 0x6E, 0x00, 0x5F, 0x61, 0x64, 0x64, 0x43, 0x61, 0x6C, 0x6C, 0x62, 0x61, 0x63, 0x6B, 0x00, 0x63,
+ 0x61, 0x6C, 0x6C, 0x00, 0x74, 0x72, 0x79, 0x20, 0x7B, 0x20, 0x00, 0x5F, 0x6F, 0x62, 0x6A, 0x65,
+ 0x63, 0x74, 0x49, 0x44, 0x00, 0x69, 0x64, 0x00, 0x2E, 0x53, 0x65, 0x74, 0x52, 0x65, 0x74, 0x75,
+ 0x72, 0x6E, 0x56, 0x61, 0x6C, 0x75, 0x65, 0x28, 0x00, 0x5F, 0x5F, 0x66, 0x6C, 0x61, 0x73, 0x68,
+ 0x5F, 0x5F, 0x74, 0x6F, 0x58, 0x4D, 0x4C, 0x20, 0x28, 0x00, 0x28, 0x00, 0x2C, 0x00, 0x5F, 0x74,
+ 0x6F, 0x4A, 0x53, 0x00, 0x29, 0x29, 0x20, 0x00, 0x3B, 0x20, 0x7D, 0x20, 0x63, 0x61, 0x74, 0x63,
+ 0x68, 0x20, 0x28, 0x65, 0x29, 0x20, 0x7B, 0x20, 0x00, 0x2E, 0x53, 0x65, 0x74, 0x52, 0x65, 0x74,
+ 0x75, 0x72, 0x6E, 0x56, 0x61, 0x6C, 0x75, 0x65, 0x28, 0x22, 0x3C, 0x75, 0x6E, 0x64, 0x65, 0x66,
+ 0x69, 0x6E, 0x65, 0x64, 0x2F, 0x3E, 0x22, 0x29, 0x3B, 0x20, 0x7D, 0x00, 0x22, 0x3C, 0x75, 0x6E,
+ 0x64, 0x65, 0x66, 0x69, 0x6E, 0x65, 0x64, 0x2F, 0x3E, 0x22, 0x3B, 0x20, 0x7D, 0x00, 0x5F, 0x65,
+ 0x76, 0x61, 0x6C, 0x4A, 0x53, 0x00, 0x3C, 0x69, 0x6E, 0x76, 0x6F, 0x6B, 0x65, 0x20, 0x6E, 0x61,
+ 0x6D, 0x65, 0x3D, 0x22, 0x00, 0x22, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6E, 0x74, 0x79, 0x70,
+ 0x65, 0x3D, 0x22, 0x78, 0x6D, 0x6C, 0x22, 0x3E, 0x00, 0x5F, 0x61, 0x72, 0x67, 0x75, 0x6D, 0x65,
+ 0x6E, 0x74, 0x73, 0x54, 0x6F, 0x58, 0x4D, 0x4C, 0x00, 0x3C, 0x2F, 0x69, 0x6E, 0x76, 0x6F, 0x6B,
+ 0x65, 0x3E, 0x00, 0x5F, 0x63, 0x61, 0x6C, 0x6C, 0x4F, 0x75, 0x74, 0x00, 0x78, 0x6D, 0x6C, 0x00,
+ 0x69, 0x67, 0x6E, 0x6F, 0x72, 0x65, 0x57, 0x68, 0x69, 0x74, 0x65, 0x00, 0x66, 0x69, 0x72, 0x73,
+ 0x74, 0x43, 0x68, 0x69, 0x6C, 0x64, 0x00, 0x5F, 0x74, 0x6F, 0x41, 0x53, 0x00, 0x61, 0x72, 0x67,
+ 0x73, 0x00, 0x63, 0x68, 0x69, 0x6C, 0x64, 0x4E, 0x6F, 0x64, 0x65, 0x73, 0x00, 0x6E, 0x6F, 0x64,
+ 0x65, 0x4E, 0x61, 0x6D, 0x65, 0x00, 0x5F, 0x61, 0x72, 0x67, 0x75, 0x6D, 0x65, 0x6E, 0x74, 0x73,
+ 0x54, 0x6F, 0x41, 0x53, 0x00, 0x61, 0x70, 0x70, 0x6C, 0x79, 0x00, 0x61, 0x74, 0x74, 0x72, 0x69,
+ 0x62, 0x75, 0x74, 0x65, 0x73, 0x00, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6E, 0x74, 0x79, 0x70, 0x65,
+ 0x00, 0x6A, 0x61, 0x76, 0x61, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x00, 0x5F, 0x74, 0x6F, 0x58,
+ 0x4D, 0x4C, 0x00, 0x5F, 0x61, 0x72, 0x72, 0x61, 0x79, 0x54, 0x6F, 0x58, 0x4D, 0x4C, 0x00, 0x3C,
+ 0x61, 0x72, 0x72, 0x61, 0x79, 0x3E, 0x00, 0x73, 0x00, 0x61, 0x72, 0x72, 0x61, 0x79, 0x00, 0x3C,
+ 0x70, 0x72, 0x6F, 0x70, 0x65, 0x72, 0x74, 0x79, 0x20, 0x69, 0x64, 0x3D, 0x22, 0x00, 0x22, 0x3E,
+ 0x00, 0x3C, 0x2F, 0x70, 0x72, 0x6F, 0x70, 0x65, 0x72, 0x74, 0x79, 0x3E, 0x00, 0x3C, 0x2F, 0x61,
+ 0x72, 0x72, 0x61, 0x79, 0x3E, 0x00, 0x3C, 0x61, 0x72, 0x67, 0x75, 0x6D, 0x65, 0x6E, 0x74, 0x73,
+ 0x3E, 0x00, 0x3C, 0x2F, 0x61, 0x72, 0x67, 0x75, 0x6D, 0x65, 0x6E, 0x74, 0x73, 0x3E, 0x00, 0x5F,
+ 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x54, 0x6F, 0x58, 0x4D, 0x4C, 0x00, 0x3C, 0x6F, 0x62, 0x6A,
+ 0x65, 0x63, 0x74, 0x3E, 0x00, 0x6F, 0x62, 0x6A, 0x00, 0x3C, 0x2F, 0x6F, 0x62, 0x6A, 0x65, 0x63,
+ 0x74, 0x3E, 0x00, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x3C, 0x73, 0x74, 0x72, 0x69, 0x6E,
+ 0x67, 0x3E, 0x00, 0x5F, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x58, 0x4D, 0x4C, 0x00, 0x3C, 0x2F,
+ 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x3E, 0x00, 0x3C, 0x75, 0x6E, 0x64, 0x65, 0x66, 0x69, 0x6E,
+ 0x65, 0x64, 0x2F, 0x3E, 0x00, 0x6E, 0x75, 0x6D, 0x62, 0x65, 0x72, 0x00, 0x3C, 0x6E, 0x75, 0x6D,
+ 0x62, 0x65, 0x72, 0x3E, 0x00, 0x3C, 0x2F, 0x6E, 0x75, 0x6D, 0x62, 0x65, 0x72, 0x3E, 0x00, 0x3C,
+ 0x6E, 0x75, 0x6C, 0x6C, 0x2F, 0x3E, 0x00, 0x62, 0x6F, 0x6F, 0x6C, 0x65, 0x61, 0x6E, 0x00, 0x3C,
+ 0x74, 0x72, 0x75, 0x65, 0x2F, 0x3E, 0x00, 0x3C, 0x66, 0x61, 0x6C, 0x73, 0x65, 0x2F, 0x3E, 0x00,
+ 0x68, 0x61, 0x73, 0x4F, 0x77, 0x6E, 0x50, 0x72, 0x6F, 0x70, 0x65, 0x72, 0x74, 0x79, 0x00, 0x5F,
+ 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x54, 0x6F, 0x41, 0x53, 0x00, 0x70, 0x72, 0x6F, 0x70, 0x65,
+ 0x72, 0x74, 0x79, 0x00, 0x5F, 0x61, 0x72, 0x72, 0x61, 0x79, 0x54, 0x6F, 0x41, 0x53, 0x00, 0x4E,
+ 0x75, 0x6D, 0x62, 0x65, 0x72, 0x00, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, 0x5F, 0x75, 0x6E,
+ 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x58, 0x4D, 0x4C, 0x00, 0x63, 0x6C, 0x61, 0x73, 0x73, 0x00,
+ 0x5F, 0x61, 0x72, 0x72, 0x61, 0x79, 0x54, 0x6F, 0x4A, 0x53, 0x00, 0x5B, 0x00, 0x5F, 0x6C, 0x31,
+ 0x00, 0x5D, 0x00, 0x5F, 0x6F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x54, 0x6F, 0x4A, 0x53, 0x00, 0x28,
+ 0x7B, 0x00, 0x6E, 0x65, 0x65, 0x64, 0x73, 0x5F, 0x63, 0x6F, 0x6D, 0x6D, 0x61, 0x00, 0x3A, 0x00,
+ 0x7D, 0x29, 0x00, 0x22, 0x00, 0x5F, 0x6A, 0x73, 0x51, 0x75, 0x6F, 0x74, 0x65, 0x53, 0x74, 0x72,
+ 0x69, 0x6E, 0x67, 0x00, 0x38, 0x5F, 0x69, 0x6E, 0x69, 0x74, 0x4A, 0x53, 0x2C, 0x38, 0x5F, 0x6F,
+ 0x62, 0x6A, 0x65, 0x63, 0x74, 0x49, 0x44, 0x2C, 0x38, 0x5F, 0x61, 0x64, 0x64, 0x43, 0x61, 0x6C,
+ 0x6C, 0x62, 0x61, 0x63, 0x6B, 0x2C, 0x38, 0x5F, 0x65, 0x76, 0x61, 0x6C, 0x4A, 0x53, 0x2C, 0x38,
+ 0x5F, 0x63, 0x61, 0x6C, 0x6C, 0x4F, 0x75, 0x74, 0x2C, 0x38, 0x5F, 0x65, 0x73, 0x63, 0x61, 0x70,
+ 0x65, 0x58, 0x4D, 0x4C, 0x2C, 0x38, 0x5F, 0x75, 0x6E, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x58,
+ 0x4D, 0x4C, 0x2C, 0x38, 0x5F, 0x6A, 0x73, 0x51, 0x75, 0x6F, 0x74, 0x65, 0x53, 0x74, 0x72, 0x69,
+ 0x6E, 0x67, 0x00, 0x38, 0x61, 0x76, 0x61, 0x69, 0x6C, 0x61, 0x62, 0x6C, 0x65, 0x00, 0x53, 0x68,
+ 0x61, 0x72, 0x65, 0x64, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x64, 0x65, 0x6C, 0x65, 0x74,
+ 0x65, 0x41, 0x6C, 0x6C, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53,
+ 0x68, 0x61, 0x72, 0x65, 0x64, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x2E, 0x64, 0x65, 0x6C, 0x65,
+ 0x74, 0x65, 0x41, 0x6C, 0x6C, 0x20, 0x28, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x29, 0x00, 0x67,
+ 0x65, 0x74, 0x44, 0x69, 0x73, 0x6B, 0x55, 0x73, 0x61, 0x67, 0x65, 0x00, 0x49, 0x6D, 0x70, 0x6C,
+ 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x4F, 0x62, 0x6A, 0x65,
+ 0x63, 0x74, 0x2E, 0x67, 0x65, 0x74, 0x44, 0x69, 0x73, 0x6B, 0x55, 0x73, 0x61, 0x67, 0x65, 0x20,
+ 0x28, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x29, 0x00, 0x67, 0x65, 0x74, 0x4C, 0x6F, 0x63, 0x61,
+ 0x6C, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53, 0x68, 0x61, 0x72,
+ 0x65, 0x64, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x2E, 0x67, 0x65, 0x74, 0x4C, 0x6F, 0x63, 0x61,
+ 0x6C, 0x20, 0x28, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x29, 0x00, 0x67, 0x65, 0x74, 0x52, 0x65,
+ 0x6D, 0x6F, 0x74, 0x65, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x53,
+ 0x68, 0x61, 0x72, 0x65, 0x64, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x2E, 0x67, 0x65, 0x74, 0x52,
+ 0x65, 0x6D, 0x6F, 0x74, 0x65, 0x20, 0x28, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x29, 0x00, 0x64,
+ 0x65, 0x6C, 0x65, 0x74, 0x65, 0x41, 0x6C, 0x6C, 0x2C, 0x67, 0x65, 0x74, 0x44, 0x69, 0x73, 0x6B,
+ 0x55, 0x73, 0x61, 0x67, 0x65, 0x00, 0x36, 0x63, 0x6F, 0x6E, 0x6E, 0x65, 0x63, 0x74, 0x2C, 0x36,
+ 0x73, 0x65, 0x6E, 0x64, 0x2C, 0x36, 0x66, 0x6C, 0x75, 0x73, 0x68, 0x2C, 0x36, 0x63, 0x6C, 0x6F,
+ 0x73, 0x65, 0x2C, 0x36, 0x67, 0x65, 0x74, 0x53, 0x69, 0x7A, 0x65, 0x2C, 0x36, 0x73, 0x65, 0x74,
+ 0x46, 0x70, 0x73, 0x2C, 0x36, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x00, 0x73, 0x70, 0x6C, 0x69, 0x74,
+ 0x00, 0x63, 0x6F, 0x75, 0x6E, 0x74, 0x00, 0x52, 0x65, 0x6D, 0x6F, 0x74, 0x65, 0x4C, 0x53, 0x4F,
+ 0x55, 0x73, 0x61, 0x67, 0x65, 0x00, 0x67, 0x65, 0x74, 0x55, 0x52, 0x4C, 0x50, 0x61, 0x67, 0x65,
+ 0x53, 0x75, 0x70, 0x70, 0x6F, 0x72, 0x74, 0x00, 0x49, 0x6D, 0x70, 0x6C, 0x65, 0x6D, 0x65, 0x6E,
+ 0x74, 0x20, 0x52, 0x65, 0x6D, 0x6F, 0x74, 0x65, 0x4C, 0x53, 0x4F, 0x55, 0x73, 0x61, 0x67, 0x65,
+ 0x2E, 0x67, 0x65, 0x74, 0x55, 0x52, 0x4C, 0x50, 0x61, 0x67, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6F,
+ 0x72, 0x74, 0x20, 0x28, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x29, 0x00, 0x42, 0x75, 0x74, 0x74,
+ 0x6F, 0x6E, 0x00, 0x67, 0x65, 0x74, 0x44, 0x65, 0x70, 0x74, 0x68, 0x00, 0x38, 0x73, 0x63, 0x61,
+ 0x6C, 0x65, 0x39, 0x47, 0x72, 0x69, 0x64, 0x2C, 0x38, 0x66, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x73,
+ 0x2C, 0x38, 0x63, 0x61, 0x63, 0x68, 0x65, 0x41, 0x73, 0x42, 0x69, 0x74, 0x6D, 0x61, 0x70, 0x2C,
+ 0x38, 0x62, 0x6C, 0x65, 0x6E, 0x64, 0x4D, 0x6F, 0x64, 0x65, 0x00, 0x66, 0x69, 0x6C, 0x74, 0x65,
+ 0x72, 0x73, 0x00, 0x42, 0x69, 0x74, 0x6D, 0x61, 0x70, 0x46, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x00,
+ 0x38, 0x63, 0x6C, 0x6F, 0x6E, 0x65, 0x00, 0x42, 0x65, 0x76, 0x65, 0x6C, 0x46, 0x69, 0x6C, 0x74,
+ 0x65, 0x72, 0x00, 0x38, 0x64, 0x69, 0x73, 0x74, 0x61, 0x6E, 0x63, 0x65, 0x2C, 0x38, 0x61, 0x6E,
+ 0x67, 0x6C, 0x65, 0x2C, 0x38, 0x68, 0x69, 0x67, 0x68, 0x6C, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6F,
+ 0x6C, 0x6F, 0x72, 0x2C, 0x38, 0x68, 0x69, 0x67, 0x68, 0x6C, 0x69, 0x67, 0x68, 0x74, 0x41, 0x6C,
+ 0x70, 0x68, 0x61, 0x2C, 0x38, 0x73, 0x68, 0x61, 0x64, 0x6F, 0x77, 0x43, 0x6F, 0x6C, 0x6F, 0x72,
+ 0x2C, 0x38, 0x73, 0x68, 0x61, 0x64, 0x6F, 0x77, 0x41, 0x6C, 0x70, 0x68, 0x61, 0x2C, 0x38, 0x71,
+ 0x75, 0x61, 0x6C, 0x69, 0x74, 0x79, 0x2C, 0x38, 0x73, 0x74, 0x72, 0x65, 0x6E, 0x67, 0x74, 0x68,
+ 0x2C, 0x38, 0x6B, 0x6E, 0x6F, 0x63, 0x6B, 0x6F, 0x75, 0x74, 0x2C, 0x38, 0x62, 0x6C, 0x75, 0x72,
+ 0x58, 0x2C, 0x38, 0x62, 0x6C, 0x75, 0x72, 0x59, 0x2C, 0x38, 0x74, 0x79, 0x70, 0x65, 0x00, 0x42,
+ 0x6C, 0x75, 0x72, 0x46, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x00, 0x38, 0x62, 0x6C, 0x75, 0x72, 0x58,
+ 0x2C, 0x38, 0x62, 0x6C, 0x75, 0x72, 0x59, 0x2C, 0x38, 0x71, 0x75, 0x61, 0x6C, 0x69, 0x74, 0x79,
+ 0x00, 0x43, 0x6F, 0x6C, 0x6F, 0x72, 0x4D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x46, 0x69, 0x6C, 0x74,
+ 0x65, 0x72, 0x00, 0x38, 0x6D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x00, 0x43, 0x6F, 0x6E, 0x76, 0x6F,
+ 0x6C, 0x75, 0x74, 0x69, 0x6F, 0x6E, 0x46, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x00, 0x38, 0x6D, 0x61,
+ 0x74, 0x72, 0x69, 0x78, 0x58, 0x2C, 0x38, 0x6D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x59, 0x2C, 0x38,
+ 0x6D, 0x61, 0x74, 0x72, 0x69, 0x78, 0x2C, 0x38, 0x64, 0x69, 0x76, 0x69, 0x73, 0x6F, 0x72, 0x2C,
+ 0x38, 0x62, 0x69, 0x61, 0x73, 0x2C, 0x38, 0x70, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x41,
+ 0x6C, 0x70, 0x68, 0x61, 0x2C, 0x38, 0x63, 0x6C, 0x61, 0x6D, 0x70, 0x2C, 0x38, 0x63, 0x6F, 0x6C,
+ 0x6F, 0x72, 0x2C, 0x38, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x00, 0x44, 0x69, 0x73, 0x70, 0x6C, 0x61,
+ 0x63, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x4D, 0x61, 0x70, 0x46, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x00,
+ 0x38, 0x6D, 0x61, 0x70, 0x42, 0x69, 0x74, 0x6D, 0x61, 0x70, 0x2C, 0x38, 0x6D, 0x61, 0x70, 0x50,
+ 0x6F, 0x69, 0x6E, 0x74, 0x2C, 0x38, 0x63, 0x6F, 0x6D, 0x70, 0x6F, 0x6E, 0x65, 0x6E, 0x74, 0x58,
+ 0x2C, 0x38, 0x63, 0x6F, 0x6D, 0x70, 0x6F, 0x6E, 0x65, 0x6E, 0x74, 0x59, 0x2C, 0x38, 0x73, 0x63,
+ 0x61, 0x6C, 0x65, 0x58, 0x2C, 0x38, 0x73, 0x63, 0x61, 0x6C, 0x65, 0x59, 0x2C, 0x38, 0x6D, 0x6F,
+ 0x64, 0x65, 0x2C, 0x38, 0x63, 0x6F, 0x6C, 0x6F, 0x72, 0x2C, 0x38, 0x61, 0x6C, 0x70, 0x68, 0x61,
+ 0x00, 0x44, 0x72, 0x6F, 0x70, 0x53, 0x68, 0x61, 0x64, 0x6F, 0x77, 0x46, 0x69, 0x6C, 0x74, 0x65,
+ 0x72, 0x00, 0x38, 0x64, 0x69, 0x73, 0x74, 0x61, 0x6E, 0x63, 0x65, 0x2C, 0x38, 0x61, 0x6E, 0x67,
+ 0x6C, 0x65, 0x2C, 0x38, 0x63, 0x6F, 0x6C, 0x6F, 0x72, 0x2C, 0x38, 0x61, 0x6C, 0x70, 0x68, 0x61,
+ 0x2C, 0x38, 0x71, 0x75, 0x61, 0x6C, 0x69, 0x74, 0x79, 0x2C, 0x38, 0x69, 0x6E, 0x6E, 0x65, 0x72,
+ 0x2C, 0x38, 0x6B, 0x6E, 0x6F, 0x63, 0x6B, 0x6F, 0x75, 0x74, 0x2C, 0x38, 0x62, 0x6C, 0x75, 0x72,
+ 0x58, 0x2C, 0x38, 0x62, 0x6C, 0x75, 0x72, 0x59, 0x2C, 0x38, 0x73, 0x74, 0x72, 0x65, 0x6E, 0x67,
+ 0x74, 0x68, 0x2C, 0x38, 0x68, 0x69, 0x64, 0x65, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x47,
+ 0x6C, 0x6F, 0x77, 0x46, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x00, 0x38, 0x63, 0x6F, 0x6C, 0x6F, 0x72,
+ 0x2C, 0x38, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x2C, 0x38, 0x71, 0x75, 0x61, 0x6C, 0x69, 0x74, 0x79,
+ 0x2C, 0x38, 0x69, 0x6E, 0x6E, 0x65, 0x72, 0x2C, 0x38, 0x6B, 0x6E, 0x6F, 0x63, 0x6B, 0x6F, 0x75,
+ 0x74, 0x2C, 0x38, 0x62, 0x6C, 0x75, 0x72, 0x58, 0x2C, 0x38, 0x62, 0x6C, 0x75, 0x72, 0x59, 0x2C,
+ 0x38, 0x73, 0x74, 0x72, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x00, 0x47, 0x72, 0x61, 0x64, 0x69, 0x65,
+ 0x6E, 0x74, 0x42, 0x65, 0x76, 0x65, 0x6C, 0x46, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x00, 0x38, 0x64,
+ 0x69, 0x73, 0x74, 0x61, 0x6E, 0x63, 0x65, 0x2C, 0x38, 0x61, 0x6E, 0x67, 0x6C, 0x65, 0x2C, 0x38,
+ 0x63, 0x6F, 0x6C, 0x6F, 0x72, 0x73, 0x2C, 0x38, 0x61, 0x6C, 0x70, 0x68, 0x61, 0x73, 0x2C, 0x38,
+ 0x72, 0x61, 0x74, 0x69, 0x6F, 0x73, 0x2C, 0x38, 0x62, 0x6C, 0x75, 0x72, 0x58, 0x2C, 0x38, 0x62,
+ 0x6C, 0x75, 0x72, 0x59, 0x2C, 0x38, 0x71, 0x75, 0x61, 0x6C, 0x69, 0x74, 0x79, 0x2C, 0x38, 0x73,
+ 0x74, 0x72, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x2C, 0x38, 0x6B, 0x6E, 0x6F, 0x63, 0x6B, 0x6F, 0x75,
+ 0x74, 0x2C, 0x38, 0x74, 0x79, 0x70, 0x65, 0x00, 0x47, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6E, 0x74,
+ 0x47, 0x6C, 0x6F, 0x77, 0x46, 0x69, 0x6C, 0x74, 0x65, 0x72, 0x00, 0x73, 0x65, 0x74, 0x49, 0x6E,
+ 0x74, 0x65, 0x72, 0x76, 0x61, 0x6C, 0x00, 0x63, 0x6C, 0x65, 0x61, 0x72, 0x49, 0x6E, 0x74, 0x65,
+ 0x72, 0x76, 0x61, 0x6C, 0x00, 0x73, 0x65, 0x74, 0x54, 0x69, 0x6D, 0x65, 0x6F, 0x75, 0x74, 0x00,
+ 0x63, 0x6C, 0x65, 0x61, 0x72, 0x54, 0x69, 0x6D, 0x65, 0x6F, 0x75, 0x74, 0x00, 0x73, 0x68, 0x6F,
+ 0x77, 0x52, 0x65, 0x64, 0x72, 0x61, 0x77, 0x52, 0x65, 0x67, 0x69, 0x6F, 0x6E, 0x73, 0x00, 0x74,
+ 0x72, 0x61, 0x63, 0x65, 0x00, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x66, 0x74, 0x65, 0x72,
+ 0x45, 0x76, 0x65, 0x6E, 0x74, 0x00, 0x8E, 0x12, 0x00, 0x45, 0x72, 0x72, 0x6F, 0x72, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x6D, 0x73, 0x67, 0x00, 0x23, 0x00, 0x96, 0x02, 0x00, 0x08, 0x08,
+ 0x1C, 0x44, 0x96, 0x02, 0x00, 0x08, 0x09, 0x49, 0x12, 0x12, 0x9D, 0x02, 0x00, 0x0F, 0x00, 0x96,
+ 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x0B, 0x08, 0x08, 0x1C, 0x4F, 0x8E, 0x15,
+ 0x00, 0x41, 0x73, 0x42, 0x72, 0x6F, 0x61, 0x64, 0x63, 0x61, 0x73, 0x74, 0x65, 0x72, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8E, 0x10, 0x00, 0x4C, 0x6F, 0x61, 0x64, 0x56, 0x61, 0x72,
+ 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8E, 0x0E, 0x00, 0x43, 0x61, 0x6D, 0x65,
+ 0x72, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8E, 0x1D, 0x00, 0x43, 0x6F, 0x6E,
+ 0x74, 0x65, 0x78, 0x74, 0x4D, 0x65, 0x6E, 0x75, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63,
+ 0x61, 0x6C, 0x6C, 0x62, 0x61, 0x63, 0x6B, 0x00, 0x5B, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C,
+ 0x96, 0x04, 0x00, 0x08, 0xF9, 0x08, 0xFA, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96,
+ 0x09, 0x00, 0x08, 0xFB, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFC, 0x40, 0x4F, 0x96, 0x02, 0x00,
+ 0x08, 0x0A, 0x1C, 0x96, 0x2D, 0x00, 0x08, 0xFD, 0x08, 0xFE, 0x05, 0x01, 0x08, 0xFF, 0x05, 0x01,
+ 0x09, 0x00, 0x01, 0x05, 0x01, 0x09, 0x01, 0x01, 0x05, 0x01, 0x09, 0x02, 0x01, 0x05, 0x01, 0x09,
+ 0x03, 0x01, 0x05, 0x01, 0x09, 0x04, 0x01, 0x05, 0x01, 0x09, 0x05, 0x01, 0x05, 0x01, 0x07, 0x08,
+ 0x00, 0x00, 0x00, 0x43, 0x4F, 0x8E, 0x4D, 0x00, 0x43, 0x6F, 0x6E, 0x74, 0x65, 0x78, 0x74, 0x4D,
+ 0x65, 0x6E, 0x75, 0x49, 0x74, 0x65, 0x6D, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x61,
+ 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x00, 0x63, 0x61, 0x6C, 0x6C, 0x62, 0x61, 0x63, 0x6B, 0x00,
+ 0x00, 0x73, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x6F, 0x72, 0x42, 0x65, 0x66, 0x6F, 0x72, 0x65,
+ 0x00, 0x00, 0x65, 0x6E, 0x61, 0x62, 0x6C, 0x65, 0x64, 0x00, 0x00, 0x76, 0x69, 0x73, 0x69, 0x62,
+ 0x6C, 0x65, 0x00, 0xBE, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x09,
+ 0x01, 0x09, 0x09, 0x01, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08,
+ 0xF9, 0x08, 0xFA, 0x1C, 0x4F, 0x96, 0x03, 0x00, 0x09, 0x0A, 0x01, 0x1C, 0x96, 0x01, 0x00, 0x03,
+ 0x49, 0x9D, 0x02, 0x00, 0x16, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09,
+ 0x0A, 0x01, 0x09, 0x0A, 0x01, 0x1C, 0x4F, 0x99, 0x02, 0x00, 0x0F, 0x00, 0x96, 0x02, 0x00, 0x08,
+ 0x0A, 0x1C, 0x96, 0x05, 0x00, 0x09, 0x0A, 0x01, 0x05, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x9B,
+ 0x1C, 0x96, 0x01, 0x00, 0x03, 0x49, 0x9D, 0x02, 0x00, 0x14, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A,
+ 0x1C, 0x96, 0x04, 0x00, 0x08, 0x9B, 0x08, 0x9B, 0x1C, 0x4F, 0x99, 0x02, 0x00, 0x0E, 0x00, 0x96,
+ 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x9B, 0x05, 0x01, 0x4F, 0x96, 0x03, 0x00,
+ 0x09, 0x0B, 0x01, 0x1C, 0x96, 0x01, 0x00, 0x03, 0x49, 0x9D, 0x02, 0x00, 0x16, 0x00, 0x96, 0x02,
+ 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x0B, 0x01, 0x09, 0x0B, 0x01, 0x1C, 0x4F, 0x99,
+ 0x02, 0x00, 0x0F, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x05, 0x00, 0x09, 0x0B, 0x01,
+ 0x05, 0x01, 0x4F, 0x8E, 0x17, 0x00, 0x4C, 0x6F, 0x63, 0x61, 0x6C, 0x43, 0x6F, 0x6E, 0x6E, 0x65,
+ 0x63, 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8E, 0x12, 0x00,
+ 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x70, 0x68, 0x6F, 0x6E, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x8E, 0x11, 0x00, 0x58, 0x4D, 0x4C, 0x53, 0x6F, 0x63, 0x6B, 0x65, 0x74, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8E, 0x14, 0x00, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x4F,
+ 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8E, 0x1B, 0x00,
+ 0x41, 0x73, 0x53, 0x65, 0x74, 0x75, 0x70, 0x45, 0x72, 0x72, 0x6F, 0x72, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x6E, 0x61, 0x6D, 0x65, 0x73, 0x00, 0x5F, 0x00, 0x96, 0x0D, 0x00, 0x09, 0xEB,
+ 0x01, 0x09, 0x97, 0x01, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0xCA, 0x1C, 0x96, 0x03, 0x00, 0x09,
+ 0xEA, 0x01, 0x52, 0x96, 0x02, 0x00, 0x08, 0x19, 0x4E, 0x3C, 0x96, 0x07, 0x00, 0x08, 0x18, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x3C, 0x99, 0x02, 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C,
+ 0x1C, 0x50, 0x1D, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xEB, 0x01, 0x1C,
+ 0x48, 0x12, 0x9D, 0x02, 0x00, 0x13, 0x00, 0x96, 0x09, 0x00, 0x08, 0xC9, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x08, 0x0C, 0x40, 0x3C, 0x99, 0x02, 0x00, 0xD0, 0xFF, 0x8E, 0x16, 0x00, 0x52, 0x65, 0x6D,
+ 0x6F, 0x74, 0x65, 0x4C, 0x53, 0x4F, 0x55, 0x73, 0x61, 0x67, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x96, 0x13, 0x00, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0x00,
+ 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x13, 0x00, 0x08, 0x02,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08,
+ 0x01, 0x3D, 0x1D, 0x96, 0x13, 0x00, 0x08, 0x03, 0x07, 0x01, 0x00, 0x00, 0x00, 0x07, 0x04, 0x00,
+ 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x07, 0x00, 0x08, 0x04,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x1D, 0x96, 0x02, 0x00, 0x08, 0x05, 0x1C, 0x96, 0x13, 0x00,
+ 0x08, 0x06, 0x07, 0x08, 0x00, 0x00, 0x00, 0x07, 0x65, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00,
+ 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x08, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x05,
+ 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x0E, 0x00,
+ 0x07, 0x80, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x07, 0x08, 0x05, 0x1C, 0x96,
+ 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x0C,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x04, 0x00, 0x08, 0x0E, 0x08, 0x0C, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x04, 0x00, 0x08, 0x0B, 0x08, 0x0C, 0x87, 0x01, 0x00, 0x00,
+ 0x4F, 0x96, 0x02, 0x00, 0x04, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0C, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x0D, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0B, 0x4E, 0x3E,
+ 0x4F, 0x96, 0x02, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x13, 0x00, 0x08, 0x11, 0x07, 0x0C, 0x00, 0x00,
+ 0x00, 0x07, 0x65, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96,
+ 0x02, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x12, 0x8E, 0x0B, 0x00, 0x00, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x3C, 0x00, 0x96, 0x02, 0x00, 0x08, 0x13, 0x1C, 0x96, 0x07,
+ 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x14, 0x52, 0x17,
+ 0x96, 0x02, 0x00, 0x08, 0x13, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x15, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x16, 0x52, 0x17, 0x96, 0x02,
+ 0x00, 0x05, 0x01, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x14,
+ 0x8E, 0x0B, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x8F, 0x00, 0x96, 0x04,
+ 0x00, 0x08, 0x17, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x15, 0x4E, 0x3C, 0x96, 0x02, 0x00,
+ 0x08, 0x18, 0x41, 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x99, 0x02,
+ 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C, 0x50, 0x1D, 0x96, 0x02, 0x00, 0x08,
+ 0x18, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x17, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x19, 0x4E, 0x48, 0x12,
+ 0x9D, 0x02, 0x00, 0x42, 0x00, 0x96, 0x02, 0x00, 0x08, 0x17, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x18,
+ 0x1C, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x13, 0x1C, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x23, 0x00, 0x96,
+ 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x18, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x02, 0x00,
+ 0x00, 0x00, 0x08, 0x17, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1A, 0x52, 0x17, 0x96, 0x02, 0x00, 0x05,
+ 0x01, 0x3E, 0x99, 0x02, 0x00, 0x9C, 0xFF, 0x96, 0x02, 0x00, 0x05, 0x00, 0x3E, 0x4F, 0x96, 0x02,
+ 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1B, 0x8E, 0x0B, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x6F, 0x00, 0x73, 0x00, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x13, 0x00,
+ 0x08, 0x11, 0x07, 0x0C, 0x00, 0x00, 0x00, 0x07, 0x65, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00,
+ 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x12,
+ 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x12, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C,
+ 0x96, 0x04, 0x00, 0x08, 0x14, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x14, 0x4E, 0x4F, 0x96,
+ 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x15, 0x07, 0x00, 0x00, 0x00, 0x00, 0x42,
+ 0x4F, 0x96, 0x09, 0x00, 0x07, 0x83, 0x00, 0x00, 0x00, 0x08, 0x1D, 0x08, 0x1C, 0x1C, 0x96, 0x07,
+ 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x4F, 0x96, 0x8C, 0x00, 0x08, 0x1E,
+ 0x08, 0x1F, 0x07, 0x12, 0x00, 0x00, 0x00, 0x08, 0x20, 0x07, 0x08, 0x00, 0x00, 0x00, 0x08, 0x21,
+ 0x07, 0x14, 0x00, 0x00, 0x00, 0x08, 0x22, 0x07, 0x11, 0x00, 0x00, 0x00, 0x08, 0x23, 0x07, 0x2E,
+ 0x00, 0x00, 0x00, 0x08, 0x24, 0x07, 0x28, 0x00, 0x00, 0x00, 0x08, 0x25, 0x07, 0x23, 0x00, 0x00,
+ 0x00, 0x08, 0x26, 0x07, 0x0D, 0x00, 0x00, 0x00, 0x08, 0x27, 0x07, 0x1B, 0x00, 0x00, 0x00, 0x08,
+ 0x28, 0x07, 0x24, 0x00, 0x00, 0x00, 0x08, 0x29, 0x07, 0x2D, 0x00, 0x00, 0x00, 0x08, 0x2A, 0x07,
+ 0x25, 0x00, 0x00, 0x00, 0x08, 0x2B, 0x07, 0x22, 0x00, 0x00, 0x00, 0x08, 0x2C, 0x07, 0x21, 0x00,
+ 0x00, 0x00, 0x08, 0x2D, 0x07, 0x27, 0x00, 0x00, 0x00, 0x08, 0x2E, 0x07, 0x10, 0x00, 0x00, 0x00,
+ 0x08, 0x2F, 0x07, 0x20, 0x00, 0x00, 0x00, 0x08, 0x30, 0x07, 0x09, 0x00, 0x00, 0x00, 0x08, 0x31,
+ 0x07, 0x26, 0x00, 0x00, 0x00, 0x07, 0x13, 0x00, 0x00, 0x00, 0x43, 0x1D, 0x96, 0x09, 0x00, 0x08,
+ 0x32, 0x07, 0x20, 0x03, 0x00, 0x00, 0x08, 0x1E, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00,
+ 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x1E, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01,
+ 0x00, 0x00, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1B, 0x52, 0x17, 0x96, 0x08, 0x00,
+ 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x1E, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00,
+ 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x07, 0x00, 0x08, 0x33, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43,
+ 0x1D, 0x96, 0x02, 0x00, 0x08, 0x33, 0x1C, 0x96, 0x13, 0x00, 0x08, 0x34, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x07, 0x05, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96,
+ 0x02, 0x00, 0x08, 0x33, 0x1C, 0x96, 0x13, 0x00, 0x08, 0x35, 0x07, 0x01, 0x00, 0x00, 0x00, 0x07,
+ 0x05, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00,
+ 0x08, 0x33, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0x1B, 0x52, 0x17, 0x96, 0x08, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x33,
+ 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x07, 0x00,
+ 0x08, 0x36, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x1D, 0x96, 0x02, 0x00, 0x08, 0x36, 0x1C, 0x96,
+ 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1B, 0x52,
+ 0x17, 0x96, 0x0E, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x37, 0x07, 0x9A, 0x02, 0x00, 0x00,
+ 0x08, 0x36, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96,
+ 0x0E, 0x00, 0x07, 0x64, 0x00, 0x00, 0x00, 0x08, 0x38, 0x07, 0x9A, 0x02, 0x00, 0x00, 0x08, 0x36,
+ 0x1C, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x13, 0x00,
+ 0x08, 0x39, 0x07, 0xC8, 0x00, 0x00, 0x00, 0x07, 0x34, 0x08, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00,
+ 0x00, 0x08, 0x3A, 0x3D, 0x1D, 0x96, 0x09, 0x00, 0x08, 0x3B, 0x07, 0x34, 0x08, 0x00, 0x00, 0x08,
+ 0x39, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00,
+ 0x08, 0x02, 0x3D, 0x17, 0x96, 0x12, 0x00, 0x02, 0x07, 0x04, 0x00, 0x00, 0x00, 0x07, 0x34, 0x08,
+ 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x96, 0x09, 0x00, 0x08, 0x3C, 0x07,
+ 0x03, 0x00, 0x00, 0x00, 0x08, 0x39, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00,
+ 0x08, 0x07, 0x52, 0x17, 0x96, 0x02, 0x00, 0x08, 0x39, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
+ 0x96, 0x04, 0x00, 0x08, 0x3D, 0x08, 0x3E, 0x4F, 0x96, 0x12, 0x00, 0x02, 0x07, 0x05, 0x00, 0x00,
+ 0x00, 0x07, 0x34, 0x08, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x96, 0x09,
+ 0x00, 0x08, 0x3F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x39, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52, 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00,
+ 0x02, 0x08, 0x39, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00,
+ 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x40, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x41, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07,
+ 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x42, 0x52, 0x17,
+ 0x4F, 0x96, 0x02, 0x00, 0x08, 0x40, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00,
+ 0x08, 0x43, 0x8E, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x6C, 0x61, 0x67,
+ 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96,
+ 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x44, 0x52,
+ 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x40, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02,
+ 0x00, 0x08, 0x45, 0x8E, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x6C, 0x61,
+ 0x67, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C,
+ 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x46,
+ 0x52, 0x17, 0x4F, 0x96, 0x09, 0x00, 0x08, 0x47, 0x07, 0x35, 0x08, 0x00, 0x00, 0x08, 0x40, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02,
+ 0x3D, 0x17, 0x96, 0x0E, 0x00, 0x07, 0x05, 0x00, 0x00, 0x00, 0x08, 0x48, 0x07, 0x35, 0x08, 0x00,
+ 0x00, 0x08, 0x40, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00,
+ 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08,
+ 0x40, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x49, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
+ 0x96, 0x04, 0x00, 0x08, 0x4A, 0x08, 0x4B, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x49, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x4C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x2D,
+ 0x01, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0x49, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x4D, 0x07, 0x01, 0x00,
+ 0x00, 0x00, 0x07, 0x2D, 0x01, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F,
+ 0x96, 0x02, 0x00, 0x08, 0x49, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08,
+ 0x4E, 0x07, 0x02, 0x00, 0x00, 0x00, 0x07, 0x2D, 0x01, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00,
+ 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x49, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
+ 0x96, 0x13, 0x00, 0x08, 0x4F, 0x07, 0x03, 0x00, 0x00, 0x00, 0x07, 0x2D, 0x01, 0x00, 0x00, 0x07,
+ 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x49, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x50, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x49, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x51, 0x8E, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x73, 0x72, 0x63, 0x00, 0x64, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08,
+ 0x52, 0x05, 0x01, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x53, 0x1C, 0x96, 0x01, 0x00, 0x02, 0x49, 0x12,
+ 0x9D, 0x02, 0x00, 0x19, 0x00, 0x96, 0x09, 0x00, 0x05, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08,
+ 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x50, 0x52, 0x17, 0x99, 0x02, 0x00, 0x2C, 0x00, 0x96, 0x02,
+ 0x00, 0x08, 0x53, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x4F, 0x52, 0x17, 0x96, 0x09, 0x00, 0x05, 0x01, 0x07, 0x01, 0x00, 0x00, 0x00,
+ 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x50, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x49,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x8E, 0x08, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xB3, 0x00, 0x96, 0x03, 0x00, 0x08, 0x54, 0x02, 0x3C, 0x96, 0x02,
+ 0x00, 0x08, 0x0A, 0x46, 0x87, 0x01, 0x00, 0x00, 0x96, 0x01, 0x00, 0x02, 0x49, 0x9D, 0x02, 0x00,
+ 0x91, 0x00, 0x96, 0x04, 0x00, 0x08, 0x13, 0x04, 0x00, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x54, 0x1C,
+ 0x96, 0x01, 0x00, 0x02, 0x49, 0x9D, 0x02, 0x00, 0x41, 0x00, 0x96, 0x02, 0x00, 0x08, 0x54, 0x4C,
+ 0x1C, 0x96, 0x04, 0x00, 0x08, 0x57, 0x08, 0x13, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00,
+ 0x00, 0x08, 0x55, 0x3D, 0x47, 0x96, 0x02, 0x00, 0x08, 0x56, 0x47, 0x96, 0x02, 0x00, 0x08, 0x0A,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x1C, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00,
+ 0x08, 0x55, 0x3D, 0x47, 0x47, 0x1D, 0x99, 0x02, 0x00, 0x33, 0x00, 0x96, 0x04, 0x00, 0x08, 0x54,
+ 0x08, 0x13, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x55, 0x3D, 0x96, 0x02,
+ 0x00, 0x08, 0x56, 0x47, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x1C,
+ 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x55, 0x3D, 0x47, 0x1D, 0x99, 0x02,
+ 0x00, 0x61, 0xFF, 0x96, 0x02, 0x00, 0x08, 0x54, 0x1C, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x49,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x58, 0x8E, 0x08, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0x59, 0x4E, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x49, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x5A, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D,
+ 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x5B, 0x4E, 0x3E, 0x4F, 0x96,
+ 0x02, 0x00, 0x08, 0x49, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x5C,
+ 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08,
+ 0x1C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x5D, 0x52, 0x17, 0x4F, 0x96, 0x08, 0x00, 0x07, 0x83, 0x00,
+ 0x00, 0x00, 0x02, 0x08, 0x49, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07,
+ 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x13, 0x00, 0x08, 0x5E, 0x07, 0x10, 0x00,
+ 0x00, 0x00, 0x07, 0xF4, 0x01, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x1D,
+ 0x96, 0x09, 0x00, 0x08, 0x5F, 0x07, 0xF4, 0x01, 0x00, 0x00, 0x08, 0x5E, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96,
+ 0x0E, 0x00, 0x07, 0x12, 0x00, 0x00, 0x00, 0x08, 0x48, 0x07, 0xF4, 0x01, 0x00, 0x00, 0x08, 0x5E,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08,
+ 0x03, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x5E, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D,
+ 0x17, 0x96, 0x13, 0x00, 0x08, 0x60, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00,
+ 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x1D, 0x96, 0x02, 0x00, 0x08, 0x60, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x61, 0x07, 0x01, 0x00, 0x00, 0x00, 0x07,
+ 0xFD, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00,
+ 0x08, 0x60, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x62, 0x07, 0x02,
+ 0x00, 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D,
+ 0x4F, 0x96, 0x02, 0x00, 0x08, 0x60, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00,
+ 0x08, 0x63, 0x07, 0x03, 0x00, 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00,
+ 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x60, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
+ 0x4E, 0x96, 0x13, 0x00, 0x08, 0x64, 0x07, 0x04, 0x00, 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00,
+ 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x60, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x65, 0x07, 0x05, 0x00, 0x00, 0x00, 0x07,
+ 0xFD, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00,
+ 0x08, 0x60, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x0F, 0x07, 0x06,
+ 0x00, 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D,
+ 0x4F, 0x96, 0x02, 0x00, 0x08, 0x60, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00,
+ 0x08, 0x66, 0x07, 0x07, 0x00, 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00,
+ 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x60, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
+ 0x4E, 0x96, 0x13, 0x00, 0x08, 0x67, 0x07, 0x08, 0x00, 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00,
+ 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x13, 0x00, 0x08, 0x68, 0x07, 0x09,
+ 0x00, 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D,
+ 0x1D, 0x96, 0x02, 0x00, 0x08, 0x68, 0x1C, 0x96, 0x10, 0x00, 0x08, 0x0D, 0x08, 0x69, 0x07, 0x01,
+ 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x60, 0x40, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0x68, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x6A, 0x3A, 0x17, 0x96,
+ 0x09, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x0D, 0x08, 0x68, 0x1C, 0x96, 0x07, 0x00, 0x07,
+ 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x68, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x4C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x2D,
+ 0x01, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0x68, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x4D, 0x07, 0x01, 0x00,
+ 0x00, 0x00, 0x07, 0x2D, 0x01, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F,
+ 0x96, 0x02, 0x00, 0x08, 0x68, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08,
+ 0x4E, 0x07, 0x02, 0x00, 0x00, 0x00, 0x07, 0x2D, 0x01, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00,
+ 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x68, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
+ 0x96, 0x13, 0x00, 0x08, 0x6B, 0x07, 0x0A, 0x00, 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00, 0x07,
+ 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x68, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x6C, 0x07, 0x0B, 0x00, 0x00, 0x00, 0x07, 0xFD,
+ 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0x68, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x6D, 0x07, 0x0C, 0x00,
+ 0x00, 0x00, 0x07, 0xFD, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F,
+ 0x96, 0x02, 0x00, 0x08, 0x68, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08,
+ 0x50, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00,
+ 0x08, 0x68, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x51, 0x8E, 0x0D,
+ 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x72, 0x63, 0x00, 0x72, 0x00, 0x96, 0x02,
+ 0x00, 0x08, 0x53, 0x1C, 0x96, 0x01, 0x00, 0x02, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x27, 0x00, 0x96,
+ 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x52, 0x05, 0x00, 0x4F, 0x96, 0x09, 0x00,
+ 0x05, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x50, 0x52,
+ 0x17, 0x99, 0x02, 0x00, 0x3A, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08,
+ 0x52, 0x05, 0x01, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x53, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00,
+ 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x6D, 0x52, 0x17, 0x96, 0x09, 0x00, 0x05,
+ 0x01, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x50, 0x52, 0x17,
+ 0x4F, 0x96, 0x02, 0x00, 0x08, 0x68, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00,
+ 0x08, 0x58, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x96, 0x02, 0x00,
+ 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x59, 0x4E, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x68,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x5A, 0x8E, 0x08, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0x5B, 0x4E, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x68, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x5C, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E,
+ 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x6E, 0x52, 0x17, 0x4F,
+ 0x96, 0x07, 0x00, 0x08, 0x6F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x1D, 0x96, 0x02, 0x00, 0x08,
+ 0x6F, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x70, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02,
+ 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x70, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x71, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x07, 0x0B, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01,
+ 0x3D, 0x4F, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0x70, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x71, 0x52, 0x17, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0x70, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x71, 0x3A, 0x17, 0x96, 0x02, 0x00,
+ 0x08, 0x6F, 0x1C, 0x96, 0x13, 0x00, 0x08, 0x72, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x2A, 0x04,
+ 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F,
+ 0x1C, 0x96, 0x13, 0x00, 0x08, 0x73, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x3B, 0x08, 0x00, 0x00,
+ 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x0E, 0x00, 0x07, 0x01, 0x00, 0x00,
+ 0x00, 0x08, 0x74, 0x07, 0x3B, 0x08, 0x00, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x04,
+ 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x09, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x08,
+ 0x75, 0x08, 0x6F, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17,
+ 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x09, 0x00, 0x08, 0x76, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x08, 0x05, 0x40, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x76, 0x4E,
+ 0x96, 0x02, 0x00, 0x08, 0x6A, 0x3A, 0x17, 0x96, 0x09, 0x00, 0x08, 0x77, 0x07, 0x0C, 0x00, 0x00,
+ 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x76, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00,
+ 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x0E, 0x00, 0x07, 0x05, 0x00, 0x00, 0x00, 0x08, 0x78,
+ 0x07, 0x0C, 0x00, 0x00, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x76, 0x4E, 0x96, 0x07,
+ 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0x76, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x79, 0x8E, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0x7A, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x76,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x79, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00,
+ 0x08, 0x7B, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0F, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00,
+ 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x76,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x79, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00,
+ 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1B, 0x52, 0x17, 0x96,
+ 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x7C, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43,
+ 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0x7D, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x7C, 0x4E,
+ 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x7E, 0x8E, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0x7F, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x7C,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x80, 0x8E, 0x08, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0x81, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0x7C, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x82, 0x8E, 0x08, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00,
+ 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x83, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0x7C, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x84, 0x8E, 0x08,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0x85, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0x7C, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x86, 0x8E,
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x87, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x7C, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x88,
+ 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08,
+ 0x1C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x89, 0x52, 0x17, 0x4F, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00,
+ 0x00, 0x00, 0x02, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x7C, 0x4E, 0x96, 0x02, 0x00, 0x08,
+ 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02,
+ 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x27, 0x00, 0x08, 0x8A, 0x08, 0x8B, 0x08, 0x8B, 0x08, 0x8C, 0x08,
+ 0x8C, 0x08, 0x8D, 0x08, 0x8D, 0x08, 0x8E, 0x08, 0x8E, 0x08, 0x8F, 0x08, 0x8F, 0x08, 0x90, 0x08,
+ 0x90, 0x08, 0x91, 0x08, 0x91, 0x08, 0x92, 0x08, 0x92, 0x07, 0x08, 0x00, 0x00, 0x00, 0x43, 0x4F,
+ 0x96, 0x02, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x8A, 0x4E, 0x96, 0x07, 0x00, 0x07,
+ 0x01, 0x00, 0x00, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1B, 0x52, 0x17, 0x96, 0x09,
+ 0x00, 0x08, 0x93, 0x07, 0x0D, 0x00, 0x00, 0x00, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x8A,
+ 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x08, 0x00,
+ 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x6F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x8A, 0x4E, 0x96,
+ 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x94,
+ 0x8E, 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74,
+ 0x00, 0x27, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x95, 0x08, 0x95,
+ 0x1C, 0x4F, 0x96, 0x08, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x08, 0x0A, 0x1C, 0x96, 0x07,
+ 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x1D, 0x96, 0x09, 0x00, 0x08, 0x96,
+ 0x07, 0xBC, 0x02, 0x00, 0x00, 0x08, 0x94, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07,
+ 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x07, 0x00,
+ 0x00, 0x00, 0x02, 0x08, 0x94, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07,
+ 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x13, 0x00, 0x08, 0x97, 0x07, 0x00, 0x00,
+ 0x00, 0x00, 0x07, 0x2B, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x1D,
+ 0x96, 0x0E, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x98, 0x07, 0x2B, 0x04, 0x00, 0x00, 0x08,
+ 0x97, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00,
+ 0x08, 0x02, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
+ 0x96, 0x04, 0x00, 0x08, 0x9A, 0x05, 0x01, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x04, 0x00, 0x08, 0x9B, 0x05, 0x01, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x9C, 0x8E, 0x10, 0x00,
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6D, 0x65, 0x74, 0x68, 0x6F, 0x64, 0x00, 0x5B, 0x00,
+ 0x96, 0x09, 0x00, 0x08, 0x9F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x9D, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0x9E, 0x52, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x9F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xA0, 0x49,
+ 0x9D, 0x02, 0x00, 0x2D, 0x00, 0x96, 0x02, 0x00, 0x08, 0x9F, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xA1,
+ 0x49, 0x9D, 0x02, 0x00, 0x0E, 0x00, 0x96, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x99,
+ 0x02, 0x00, 0x09, 0x00, 0x96, 0x05, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x3E, 0x99, 0x02, 0x00,
+ 0x09, 0x00, 0x96, 0x05, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xA2, 0x8E, 0x1D, 0x00,
+ 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x72, 0x6C, 0x00, 0x00, 0x74, 0x61, 0x72, 0x67,
+ 0x65, 0x74, 0x00, 0x00, 0x6D, 0x65, 0x74, 0x68, 0x6F, 0x64, 0x00, 0x97, 0x00, 0x96, 0x02, 0x00,
+ 0x08, 0x95, 0x1C, 0x44, 0x96, 0x02, 0x00, 0x08, 0x09, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x08, 0x00,
+ 0x96, 0x04, 0x00, 0x08, 0x95, 0x08, 0x69, 0x1D, 0x96, 0x04, 0x00, 0x08, 0xA3, 0x08, 0x9D, 0x1C,
+ 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x9C,
+ 0x52, 0x3C, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x49, 0x9D, 0x02, 0x00, 0x3E, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x05, 0x00, 0x07,
+ 0x01, 0x00, 0x00, 0x00, 0x49, 0x9D, 0x02, 0x00, 0x15, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA4, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0x95, 0x1C, 0x9A, 0x01, 0x00, 0x02, 0x99, 0x02, 0x00, 0x10, 0x00, 0x96,
+ 0x02, 0x00, 0x08, 0xA4, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x95, 0x1C, 0x9A, 0x01, 0x00, 0x01, 0x99,
+ 0x02, 0x00, 0x10, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA4, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x95, 0x1C,
+ 0x9A, 0x01, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0xA5, 0x8E, 0x15, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x75, 0x72, 0x6C, 0x00, 0x00, 0x6D, 0x65, 0x74, 0x68, 0x6F, 0x64, 0x00, 0x99, 0x00, 0x96, 0x04,
+ 0x00, 0x08, 0xA3, 0x08, 0x9D, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x9C, 0x52, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x20, 0x96,
+ 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x49, 0x9D, 0x02,
+ 0x00, 0x4A, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x05, 0x00, 0x07, 0x01, 0x00, 0x00,
+ 0x00, 0x49, 0x9D, 0x02, 0x00, 0x1B, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA4, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xA6, 0x4E, 0x9A, 0x01, 0x00, 0xC2, 0x99, 0x02, 0x00,
+ 0x16, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA4, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0xA6, 0x4E, 0x9A, 0x01, 0x00, 0xC1, 0x99, 0x02, 0x00, 0x16, 0x00, 0x96, 0x02, 0x00,
+ 0x08, 0xA4, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xA6, 0x4E, 0x9A,
+ 0x01, 0x00, 0xC0, 0x8B, 0x01, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xA7, 0x8E, 0x15, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x75, 0x72, 0x6C, 0x00, 0x00, 0x6D, 0x65, 0x74, 0x68, 0x6F, 0x64, 0x00, 0x99,
+ 0x00, 0x96, 0x04, 0x00, 0x08, 0xA3, 0x08, 0x9D, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00,
+ 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x9C, 0x52, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x0A,
+ 0x1C, 0x20, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x49, 0x9D, 0x02, 0x00, 0x4A, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x05, 0x00, 0x07,
+ 0x01, 0x00, 0x00, 0x00, 0x49, 0x9D, 0x02, 0x00, 0x1B, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA4, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xA6, 0x4E, 0x9A, 0x01, 0x00, 0x42,
+ 0x99, 0x02, 0x00, 0x16, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA4, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0xA6, 0x4E, 0x9A, 0x01, 0x00, 0x41, 0x99, 0x02, 0x00, 0x16, 0x00,
+ 0x96, 0x02, 0x00, 0x08, 0xA4, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0xA6, 0x4E, 0x9A, 0x01, 0x00, 0x40, 0x8B, 0x01, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x99,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xA8, 0x8E, 0x08, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x20, 0x96, 0x04,
+ 0x00, 0x08, 0x69, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xA6, 0x4E, 0x9A, 0x01, 0x00, 0x40,
+ 0x8B, 0x01, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0xA9, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12,
+ 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08,
+ 0x97, 0x40, 0x3E, 0x4F, 0x96, 0x09, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x08, 0xA9, 0x08, 0x99,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08,
+ 0x00, 0x3D, 0x17, 0x96, 0x09, 0x00, 0x08, 0xAA, 0x07, 0x84, 0x03, 0x00, 0x00, 0x08, 0x99, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02,
+ 0x3D, 0x17, 0x96, 0x0E, 0x00, 0x07, 0xC8, 0x00, 0x00, 0x00, 0x08, 0xAB, 0x07, 0x84, 0x03, 0x00,
+ 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00,
+ 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x0E, 0x00, 0x07, 0x2C, 0x01, 0x00, 0x00, 0x08, 0xAC,
+ 0x07, 0x84, 0x03, 0x00, 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07,
+ 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x0E, 0x00, 0x07, 0x91, 0x01,
+ 0x00, 0x00, 0x08, 0xAD, 0x07, 0x84, 0x03, 0x00, 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x0E,
+ 0x00, 0x07, 0xA1, 0x01, 0x00, 0x00, 0x08, 0xAE, 0x07, 0x84, 0x03, 0x00, 0x00, 0x08, 0x99, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03,
+ 0x3D, 0x17, 0x96, 0x0E, 0x00, 0x07, 0xF4, 0x01, 0x00, 0x00, 0x08, 0xAF, 0x07, 0x84, 0x03, 0x00,
+ 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00,
+ 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x09, 0x00, 0x08, 0xB0, 0x07, 0x85, 0x03, 0x00, 0x00,
+ 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00,
+ 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x0E, 0x00, 0x07, 0x0C, 0x00, 0x00, 0x00, 0x08, 0xB1, 0x07,
+ 0x85, 0x03, 0x00, 0x00, 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00,
+ 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x99, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0xB2, 0x07, 0xC8, 0x00, 0x00, 0x00, 0x07,
+ 0x68, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x08, 0x00,
+ 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0x99, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96,
+ 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x13, 0x00, 0x08, 0xB3,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x70, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08,
+ 0x3A, 0x3D, 0x1D, 0x96, 0x0E, 0x00, 0x07, 0x64, 0x00, 0x00, 0x00, 0x08, 0xB4, 0x07, 0x70, 0x00,
+ 0x00, 0x00, 0x08, 0xB3, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04,
+ 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0xB3, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0x1B, 0x52, 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x04, 0x00, 0x00, 0x02, 0x08, 0xB3,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08,
+ 0x00, 0x3D, 0x17, 0x96, 0x13, 0x00, 0x08, 0xB5, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x68, 0x00,
+ 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x1D, 0x96, 0x02, 0x00, 0x08, 0xB5,
+ 0x1C, 0x96, 0x13, 0x00, 0x08, 0xB6, 0x07, 0xC9, 0x00, 0x00, 0x00, 0x07, 0x68, 0x00, 0x00, 0x00,
+ 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x0E, 0x00, 0x07, 0x64, 0x00, 0x00,
+ 0x00, 0x08, 0xB7, 0x07, 0x68, 0x00, 0x00, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
+ 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x02, 0x00,
+ 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00,
+ 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1B, 0x52, 0x17, 0x96, 0x08, 0x00, 0x07, 0x83,
+ 0x00, 0x00, 0x00, 0x02, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00,
+ 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x0E, 0x00, 0x07, 0x2C, 0x01, 0x00,
+ 0x00, 0x08, 0xB8, 0x07, 0x68, 0x00, 0x00, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
+ 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x0E, 0x00,
+ 0x07, 0xC8, 0x00, 0x00, 0x00, 0x08, 0xB9, 0x07, 0x84, 0x03, 0x00, 0x00, 0x08, 0xB5, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D,
+ 0x17, 0x96, 0x08, 0x00, 0x07, 0x83, 0x00, 0x00, 0x00, 0x02, 0x08, 0xB5, 0x1C, 0x96, 0x07, 0x00,
+ 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x13, 0x00, 0x08, 0xBA, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x07, 0x6E, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D,
+ 0x1D, 0x96, 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x13, 0x00, 0x08, 0xBB, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x07, 0x71, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96,
+ 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0xBC, 0x8E, 0x0B, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x6F, 0x00, 0x67, 0x00, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x44, 0x96, 0x02, 0x00, 0x08, 0xBD,
+ 0x49, 0x12, 0x12, 0x9D, 0x02, 0x00, 0x05, 0x00, 0x96, 0x01, 0x00, 0x02, 0x3E, 0x96, 0x07, 0x00,
+ 0x08, 0xBE, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x46, 0x87,
+ 0x01, 0x00, 0x00, 0x96, 0x01, 0x00, 0x02, 0x49, 0x9D, 0x02, 0x00, 0x27, 0x00, 0x96, 0x04, 0x00,
+ 0x08, 0xBF, 0x04, 0x00, 0x3C, 0x96, 0x02, 0x00, 0x08, 0xBE, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBF,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBF, 0x1C, 0x4E, 0x4F, 0x99,
+ 0x02, 0x00, 0xCB, 0xFF, 0x96, 0x02, 0x00, 0x08, 0xBE, 0x1C, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02,
+ 0x00, 0x08, 0xC0, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x96, 0x02,
+ 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x08, 0xC1, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F,
+ 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x08, 0xC2, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x43, 0x4F, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0xC3, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xC4, 0x8E, 0x0E, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6E, 0x61, 0x6D, 0x65, 0x00, 0x25, 0x00, 0x96, 0x02, 0x00,
+ 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC1, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C, 0x4E,
+ 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBC,
+ 0x52, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96,
+ 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xC5, 0x8E, 0x15, 0x00, 0x00, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x6E, 0x61, 0x6D, 0x65, 0x00, 0x00, 0x73, 0x74, 0x79, 0x6C, 0x65, 0x00,
+ 0x79, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC1, 0x4E, 0x12, 0x12,
+ 0x9D, 0x02, 0x00, 0x12, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x08, 0xC1,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0xC1, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96,
+ 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBC, 0x52,
+ 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08,
+ 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC7, 0x52, 0x17, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC3, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02,
+ 0x00, 0x08, 0xC8, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5B, 0x00, 0x96, 0x04,
+ 0x00, 0x08, 0xC9, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC1, 0x4E, 0x3C, 0x96, 0x07, 0x00,
+ 0x08, 0xCA, 0x07, 0x00, 0x00, 0x00, 0x00, 0x42, 0x3C, 0x96, 0x02, 0x00, 0x08, 0xC9, 0x46, 0x87,
+ 0x01, 0x00, 0x00, 0x96, 0x01, 0x00, 0x02, 0x49, 0x9D, 0x02, 0x00, 0x25, 0x00, 0x96, 0x04, 0x00,
+ 0x08, 0xBF, 0x04, 0x00, 0x3C, 0x96, 0x02, 0x00, 0x08, 0xBF, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01,
+ 0x00, 0x00, 0x00, 0x08, 0xCA, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x16, 0x52, 0x17, 0x99, 0x02, 0x00,
+ 0xCD, 0xFF, 0x96, 0x02, 0x00, 0x08, 0xCA, 0x1C, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xB5, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08,
+ 0xC7, 0x8E, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6E, 0x61, 0x6D, 0x65, 0x00,
+ 0x5C, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC2, 0x4E, 0x12, 0x12,
+ 0x9D, 0x02, 0x00, 0x12, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x08, 0xC2,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0xC2, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0xC1, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C, 0x4E, 0x96, 0x07, 0x00, 0x07,
+ 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xCB, 0x52, 0x4F, 0x4F, 0x96,
+ 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0xCB, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x73, 0x74, 0x79, 0x6C, 0x65, 0x00, 0x9D, 0x03, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x01,
+ 0x00, 0x02, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x05, 0x00, 0x96, 0x01, 0x00, 0x02, 0x3E, 0x96, 0x09,
+ 0x00, 0x08, 0xCC, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0xBA, 0x40, 0x3C, 0x96, 0x02, 0x00, 0x08,
+ 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xCD, 0x4E, 0x12, 0x9D, 0x02, 0x00, 0x15, 0x00, 0x96, 0x02,
+ 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xCE, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0xCD, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xCF, 0x4E, 0x96,
+ 0x02, 0x00, 0x08, 0xD0, 0x49, 0x9D, 0x02, 0x00, 0x2B, 0x00, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0xCF, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xD1, 0x49, 0x12, 0x9D, 0x02, 0x00,
+ 0x0E, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xD0, 0x05, 0x00, 0x4F,
+ 0x99, 0x02, 0x00, 0x0E, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xD0,
+ 0x05, 0x01, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD2, 0x4E, 0x12,
+ 0x9D, 0x02, 0x00, 0x41, 0x00, 0x96, 0x04, 0x00, 0x08, 0xC9, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0xD2, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0xD3, 0x52, 0x3C, 0x96, 0x02, 0x00, 0x08, 0xC9, 0x1C, 0x96, 0x01, 0x00, 0x02, 0x49,
+ 0x12, 0x12, 0x9D, 0x02, 0x00, 0x0F, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00,
+ 0x08, 0xD2, 0x08, 0xC9, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08,
+ 0xD4, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD4, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xC6,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD5, 0x4E, 0x12, 0x9D, 0x02, 0x00, 0x26, 0x00, 0x96, 0x02, 0x00,
+ 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xD6, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD5,
+ 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0xD7, 0x52, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD8, 0x4E, 0x12,
+ 0x9D, 0x02, 0x00, 0x20, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xD9,
+ 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD8, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00,
+ 0x00, 0x08, 0xDA, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xDB,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0xDC, 0x49, 0x9D, 0x02, 0x00, 0x2B, 0x00, 0x96, 0x02, 0x00, 0x08,
+ 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xDB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xD1, 0x49, 0x12, 0x9D,
+ 0x02, 0x00, 0x0E, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xDC, 0x05,
+ 0x00, 0x4F, 0x99, 0x02, 0x00, 0x0E, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00,
+ 0x08, 0xDC, 0x05, 0x01, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xDD,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0xDE, 0x49, 0x9D, 0x02, 0x00, 0x4F, 0x00, 0x96, 0x02, 0x00, 0x08,
+ 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xDD, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xDF, 0x49, 0x9D, 0x02,
+ 0x00, 0x25, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xDD, 0x08, 0xC6,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0xDD, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08,
+ 0xDA, 0x3D, 0x4F, 0x99, 0x02, 0x00, 0x0E, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04,
+ 0x00, 0x08, 0xDD, 0x05, 0x00, 0x4F, 0x99, 0x02, 0x00, 0x0E, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC,
+ 0x1C, 0x96, 0x04, 0x00, 0x08, 0xDD, 0x05, 0x01, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0xE0, 0x4E, 0x12, 0x9D, 0x02, 0x00, 0x20, 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC,
+ 0x1C, 0x96, 0x04, 0x00, 0x08, 0xE0, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xE0, 0x4E, 0x96,
+ 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0xDA, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xC6,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0xE1, 0x4E, 0x12, 0x9D, 0x02, 0x00, 0x20, 0x00, 0x96, 0x02, 0x00,
+ 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xE2, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xE1,
+ 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0xDA, 0x3D, 0x4F, 0x96, 0x02, 0x00,
+ 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xE3, 0x4E, 0x12, 0x9D, 0x02, 0x00, 0x20, 0x00, 0x96,
+ 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xE3, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0xE3, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0xDA, 0x3D, 0x4F, 0x96,
+ 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xE4, 0x4E, 0x12, 0x9D, 0x02, 0x00, 0x20,
+ 0x00, 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xE5, 0x08, 0xC6, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0xE4, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0xDA, 0x3D,
+ 0x4F, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xE6, 0x4E, 0x12, 0x9D, 0x02,
+ 0x00, 0x3B, 0x00, 0x96, 0x04, 0x00, 0x08, 0xC9, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xE6,
+ 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0xDA, 0x3D, 0x3C, 0x96, 0x07, 0x00,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0xC9, 0x1C, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x0F, 0x00, 0x96,
+ 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xE7, 0x08, 0xC9, 0x1C, 0x4F, 0x96, 0x02,
+ 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xE8, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xE9, 0x49,
+ 0x9D, 0x02, 0x00, 0x2B, 0x00, 0x96, 0x02, 0x00, 0x08, 0xC6, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xE8,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x3E, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x0E, 0x00, 0x96, 0x02, 0x00,
+ 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xE9, 0x05, 0x00, 0x4F, 0x99, 0x02, 0x00, 0x0E, 0x00,
+ 0x96, 0x02, 0x00, 0x08, 0xCC, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xE9, 0x05, 0x01, 0x4F, 0x96, 0x02,
+ 0x00, 0x08, 0xCC, 0x1C, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0xBB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0xEA, 0x8E, 0x0D, 0x00,
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x73, 0x73, 0x00, 0xDA, 0x00, 0x96, 0x04, 0x00,
+ 0x08, 0xED, 0x08, 0xEB, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0xEC, 0x52, 0x3C, 0x96, 0x02, 0x00, 0x08, 0xED, 0x1C, 0x44, 0x96, 0x02,
+ 0x00, 0x08, 0xEE, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x06, 0x00, 0x96, 0x02, 0x00, 0x05, 0x00, 0x3E,
+ 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC1, 0x4E, 0x12, 0x12, 0x9D, 0x02,
+ 0x00, 0x12, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x08, 0xC1, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xED, 0x46, 0x87, 0x01, 0x00, 0x00, 0x96,
+ 0x01, 0x00, 0x02, 0x49, 0x9D, 0x02, 0x00, 0x56, 0x00, 0x96, 0x04, 0x00, 0x08, 0xBF, 0x04, 0x00,
+ 0x3C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC1, 0x4E, 0x96, 0x02, 0x00,
+ 0x08, 0xBF, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xED, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBF, 0x1C, 0x4E,
+ 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBC,
+ 0x52, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xBF, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00,
+ 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC7, 0x52, 0x17, 0x99, 0x02, 0x00, 0x9C, 0xFF, 0x96,
+ 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xC3, 0x52,
+ 0x17, 0x96, 0x02, 0x00, 0x05, 0x01, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x04, 0x00, 0x08, 0xEF, 0x08,
+ 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02,
+ 0x00, 0x08, 0xEA, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x13, 0x00, 0x08, 0x4C, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x07, 0x2D, 0x01, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96,
+ 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x50, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02,
+ 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x51, 0x8E, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x73, 0x72, 0x63, 0x00, 0x6B, 0x00, 0x96, 0x02, 0x00, 0x08, 0x53, 0x1C, 0x96,
+ 0x01, 0x00, 0x02, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x19, 0x00, 0x96, 0x09, 0x00, 0x05, 0x00, 0x07,
+ 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x50, 0x52, 0x17, 0x99, 0x02,
+ 0x00, 0x41, 0x00, 0x96, 0x04, 0x00, 0x08, 0xED, 0x08, 0x53, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01,
+ 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xEF, 0x52, 0x3C, 0x96, 0x02, 0x00,
+ 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x52, 0x08, 0xED, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0xED, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0x50, 0x52, 0x17, 0x4F, 0x96, 0x0E, 0x00, 0x07, 0x64, 0x00, 0x00, 0x00, 0x08, 0xF0, 0x07,
+ 0x71, 0x00, 0x00, 0x00, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB, 0x4E, 0x96, 0x02, 0x00,
+ 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96,
+ 0x08, 0x00, 0x07, 0x03, 0x04, 0x00, 0x00, 0x02, 0x08, 0xB5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBB,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08,
+ 0x00, 0x3D, 0x17, 0x96, 0x09, 0x00, 0x07, 0x03, 0x04, 0x00, 0x00, 0x08, 0xBB, 0x08, 0xB5, 0x1C,
+ 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x0E, 0x00, 0x07,
+ 0x01, 0x00, 0x00, 0x00, 0x08, 0xF2, 0x07, 0x9B, 0x02, 0x00, 0x00, 0x08, 0xF1, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17,
+ 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0xF1, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x07,
+ 0x00, 0x08, 0xF3, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x1D, 0x96, 0x09, 0x00, 0x08, 0xF4, 0x07,
+ 0xCF, 0x07, 0x00, 0x00, 0x08, 0xF3, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08,
+ 0x02, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x06, 0x00, 0x00, 0x00, 0x02, 0x08, 0xF3, 0x1C, 0x96,
+ 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0xF5,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0xA1, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x69, 0x6E, 0x64, 0x65, 0x78, 0x00, 0x2A, 0x00, 0x96, 0x13, 0x00, 0x08, 0xF6, 0x07, 0xC8, 0x00,
+ 0x00, 0x00, 0x07, 0x36, 0x08, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x3C,
+ 0x96, 0x02, 0x00, 0x08, 0xF7, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0xF6,
+ 0x3D, 0x3E, 0x4F, 0x96, 0x12, 0x00, 0x02, 0x07, 0xC9, 0x00, 0x00, 0x00, 0x07, 0x36, 0x08, 0x00,
+ 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x96, 0x09, 0x00, 0x08, 0xCA, 0x07, 0x03,
+ 0x00, 0x00, 0x00, 0x08, 0xF5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52, 0x17, 0x96, 0x09, 0x00,
+ 0x08, 0xF8, 0x07, 0x36, 0x08, 0x00, 0x00, 0x08, 0xF5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
+ 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07,
+ 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0xF5, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07,
+ 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x03, 0x00, 0x09, 0x06, 0x01,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x07, 0x01, 0x8E, 0x08, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC8, 0x00, 0x96, 0x0A, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00,
+ 0x00, 0x00, 0x09, 0x06, 0x01, 0x40, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x04, 0x00,
+ 0x08, 0xF9, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xF9, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0x1C, 0x1C, 0x96, 0x09, 0x00, 0x08, 0xFB, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0xFC, 0x40, 0x4F,
+ 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x99, 0x02, 0x00, 0x09, 0x00,
+ 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C, 0x50, 0x1D, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xFB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x19,
+ 0x4E, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x3C, 0x00, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xFB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x4E,
+ 0x96, 0x03, 0x00, 0x09, 0x07, 0x01, 0x52, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08,
+ 0x1C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xFB, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x16, 0x52, 0x17, 0x99,
+ 0x02, 0x00, 0x9C, 0xFF, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x04, 0x00, 0x08, 0xFD, 0x08,
+ 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xFD, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x3E,
+ 0x4F, 0x96, 0x03, 0x00, 0x09, 0x06, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0x08, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x96,
+ 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x2D, 0x00, 0x08, 0xFD, 0x08, 0xFE, 0x05, 0x00, 0x08, 0xFF,
+ 0x05, 0x00, 0x09, 0x00, 0x01, 0x05, 0x00, 0x09, 0x01, 0x01, 0x05, 0x00, 0x09, 0x02, 0x01, 0x05,
+ 0x00, 0x09, 0x03, 0x01, 0x05, 0x00, 0x09, 0x04, 0x01, 0x05, 0x00, 0x09, 0x05, 0x01, 0x05, 0x00,
+ 0x07, 0x08, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x4F, 0x96, 0x09, 0x00, 0x07, 0x03, 0x04, 0x00, 0x00,
+ 0x02, 0x09, 0x06, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03,
+ 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x03, 0x00, 0x09, 0x0C, 0x01, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x07, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x85, 0x00, 0x96, 0x0A, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x09,
+ 0x0C, 0x01, 0x40, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x05, 0x00, 0x09, 0x09, 0x01,
+ 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x09, 0x01, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x1C,
+ 0x1C, 0x96, 0x04, 0x00, 0x08, 0xF9, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xF9, 0x4E, 0x4F,
+ 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x05, 0x00, 0x09, 0x0A, 0x01, 0x08, 0x0A, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x0A, 0x01, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x04, 0x00,
+ 0x08, 0x9B, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x9B, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0x1C, 0x1C, 0x96, 0x05, 0x00, 0x09, 0x0B, 0x01, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x0B,
+ 0x01, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x3E, 0x4F, 0x96, 0x09, 0x00, 0x07, 0x03,
+ 0x04, 0x00, 0x00, 0x02, 0x09, 0x0C, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07,
+ 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C,
+ 0x96, 0x08, 0x00, 0x09, 0x0D, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02, 0x00,
+ 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x0D, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x0E, 0x01,
+ 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x96, 0x14, 0x00, 0x09, 0x0F,
+ 0x01, 0x07, 0xC8, 0x00, 0x00, 0x00, 0x07, 0x9C, 0x08, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00,
+ 0x08, 0x01, 0x3D, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x08, 0x00, 0x07, 0x01, 0x00,
+ 0x00, 0x00, 0x09, 0x0F, 0x01, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00,
+ 0x08, 0x15, 0x07, 0x00, 0x00, 0x00, 0x00, 0x42, 0x4F, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0x0D, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x0E, 0x01, 0x4E, 0x96, 0x02,
+ 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x10, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x1B, 0x52, 0x17, 0x96, 0x0A, 0x00, 0x09, 0x10, 0x01, 0x07, 0x9C, 0x08, 0x00,
+ 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x0D, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x0E,
+ 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00,
+ 0x08, 0x02, 0x3D, 0x17, 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0x04, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0x0D, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x0E, 0x01, 0x4E, 0x96, 0x02,
+ 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17,
+ 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x0D, 0x01, 0x4E, 0x96, 0x03, 0x00,
+ 0x09, 0x11, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27, 0x00, 0x96, 0x02,
+ 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x0A, 0x00, 0x09, 0x12, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08,
+ 0xFC, 0x40, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x15, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x42, 0x4F, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09,
+ 0x0D, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x11, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
+ 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1B,
+ 0x52, 0x17, 0x96, 0x0A, 0x00, 0x09, 0x13, 0x01, 0x07, 0x9D, 0x08, 0x00, 0x00, 0x08, 0x04, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0x0D, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x11, 0x01, 0x4E, 0x96, 0x02,
+ 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17,
+ 0x96, 0x08, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09,
+ 0x0D, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x11, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
+ 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x0B, 0x00, 0x09,
+ 0x15, 0x01, 0x07, 0x98, 0x08, 0x00, 0x00, 0x09, 0x14, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D,
+ 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x09, 0x00,
+ 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x09, 0x14, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
+ 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x03, 0x00, 0x09,
+ 0x16, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xA1, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x69, 0x6E, 0x64, 0x65, 0x78, 0x00, 0x2A, 0x00, 0x96, 0x13, 0x00, 0x08, 0xF6, 0x07,
+ 0xC8, 0x00, 0x00, 0x00, 0x07, 0x38, 0x08, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01,
+ 0x3D, 0x3C, 0x96, 0x02, 0x00, 0x08, 0xF7, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00,
+ 0x08, 0xF6, 0x3D, 0x3E, 0x4F, 0x96, 0x12, 0x00, 0x02, 0x07, 0xC9, 0x00, 0x00, 0x00, 0x07, 0x38,
+ 0x08, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x96, 0x0A, 0x00, 0x08, 0xCA,
+ 0x07, 0x03, 0x00, 0x00, 0x00, 0x09, 0x16, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52, 0x17,
+ 0x96, 0x0B, 0x00, 0x09, 0x17, 0x01, 0x07, 0x38, 0x08, 0x00, 0x00, 0x09, 0x16, 0x01, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D,
+ 0x17, 0x96, 0x09, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x09, 0x16, 0x01, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17,
+ 0x96, 0x14, 0x00, 0x09, 0x18, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x6F, 0x00, 0x00, 0x00,
+ 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x1D, 0x96, 0x10, 0x00, 0x07, 0x64, 0x00, 0x00,
+ 0x00, 0x09, 0x19, 0x01, 0x07, 0x6F, 0x00, 0x00, 0x00, 0x09, 0x18, 0x01, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96,
+ 0x09, 0x00, 0x07, 0x03, 0x04, 0x00, 0x00, 0x02, 0x09, 0x18, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x08,
+ 0x00, 0x09, 0x1A, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x1D, 0x96, 0x0B, 0x00, 0x09, 0x1B,
+ 0x01, 0x07, 0x58, 0x02, 0x00, 0x00, 0x09, 0x1A, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00,
+ 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x03, 0x00, 0x09, 0x1A, 0x01, 0x1C, 0x96, 0x07, 0x00,
+ 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x10, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x1B, 0x52, 0x17, 0x96,
+ 0x09, 0x00, 0x07, 0x07, 0x00, 0x00, 0x00, 0x02, 0x09, 0x1A, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07,
+ 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x08,
+ 0x00, 0x09, 0x1C, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0x1C, 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09, 0x1D, 0x01, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x07, 0x66, 0x08, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D,
+ 0x4F, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0x1E, 0x01, 0x07, 0x66, 0x08, 0x00,
+ 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x1C, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x1D,
+ 0x01, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x0F,
+ 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x09, 0x1F, 0x01, 0x07, 0x66, 0x08, 0x00, 0x00, 0x08, 0x04,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0x1C, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x1D, 0x01, 0x4E, 0x96,
+ 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x0A,
+ 0x00, 0x00, 0x00, 0x09, 0x20, 0x01, 0x07, 0x66, 0x08, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x1C, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x1D, 0x01, 0x4E, 0x96, 0x07, 0x00, 0x07,
+ 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x05, 0x00, 0x09, 0x21, 0x01, 0x08, 0x04,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0x1C, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x1D, 0x01, 0x4E, 0x1D,
+ 0x96, 0x03, 0x00, 0x09, 0x22, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00,
+ 0x08, 0x51, 0x8E, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x72, 0x63, 0x00,
+ 0x24, 0x00, 0x96, 0x02, 0x00, 0x08, 0x53, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00,
+ 0x08, 0x68, 0x40, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x23, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x0B, 0x00, 0x09, 0x24, 0x01, 0x07, 0x90, 0x01,
+ 0x00, 0x00, 0x09, 0x22, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07,
+ 0x03, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x09, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00,
+ 0x02, 0x09, 0x22, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03,
+ 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x08, 0x00,
+ 0x09, 0x25, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x8E, 0x08, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x00, 0x96, 0x03, 0x00, 0x09, 0x27, 0x01, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x19, 0x4E, 0x96, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x49, 0x9D, 0x02,
+ 0x00, 0x38, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x05, 0x00, 0x08, 0x13, 0x09, 0x27,
+ 0x01, 0x1C, 0x96, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x28, 0x01, 0x09, 0x27, 0x01, 0x1C, 0x96, 0x05, 0x00, 0x07,
+ 0x01, 0x00, 0x00, 0x00, 0x4E, 0x4F, 0x99, 0x02, 0x00, 0x23, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A,
+ 0x1C, 0x96, 0x07, 0x00, 0x08, 0x13, 0x07, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0x0A, 0x1C, 0x96, 0x08, 0x00, 0x09, 0x28, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x4F, 0x96,
+ 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0x26, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x29, 0x01, 0x8E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x62, 0x00, 0x21, 0x00, 0x96, 0x03, 0x00, 0x09, 0x2B, 0x01,
+ 0x1C, 0x96, 0x08, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0x2A, 0x01, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x2C, 0x01, 0x52, 0x96, 0x02, 0x00, 0x08, 0x19, 0x4E, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x4E,
+ 0x96, 0x03, 0x00, 0x09, 0x2D, 0x01, 0x8E, 0x15, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x61, 0x00, 0x00, 0x62, 0x00, 0x00, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x00, 0x7F, 0x00, 0x96, 0x03,
+ 0x00, 0x09, 0x2B, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0x2E, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x2A, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0x2B, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x0B,
+ 0x0C, 0x47, 0x96, 0x03, 0x00, 0x09, 0x2B, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96,
+ 0x03, 0x00, 0x09, 0x2E, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x2A, 0x01, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x2B, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E,
+ 0x0B, 0x0C, 0x47, 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x53, 0x3E, 0x4F, 0x96, 0x02,
+ 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26,
+ 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x2F, 0x01, 0x8E, 0x17, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x6C, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x00, 0x00, 0x61, 0x6E, 0x67, 0x6C, 0x65, 0x00,
+ 0x5C, 0x00, 0x96, 0x02, 0x00, 0x08, 0x19, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x31, 0x01, 0x1C, 0x96,
+ 0x08, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x33,
+ 0x01, 0x52, 0x0C, 0x96, 0x02, 0x00, 0x08, 0x19, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x31, 0x01, 0x1C,
+ 0x96, 0x08, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09,
+ 0x32, 0x01, 0x52, 0x0C, 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x53, 0x3E, 0x4F, 0x96,
+ 0x01, 0x00, 0x02, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x96, 0x02,
+ 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x0C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01,
+ 0x4E, 0x0C, 0x47, 0x96, 0x08, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x34, 0x01, 0x52, 0x3E, 0x96, 0x09, 0x00, 0x08, 0x19, 0x07, 0x03, 0x00, 0x00,
+ 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26,
+ 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52, 0x17, 0x96,
+ 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0x26, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x35, 0x01, 0x8E,
+ 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0x74, 0x68, 0x65, 0x72, 0x00, 0x50,
+ 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0x36, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x47, 0x96, 0x02, 0x00,
+ 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x36, 0x01, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x47, 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08,
+ 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x53,
+ 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96,
+ 0x03, 0x00, 0x09, 0x26, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0x37, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x96, 0x02, 0x00,
+ 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x04,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x53, 0x3E,
+ 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0x26, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x38,
+ 0x01, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0x74, 0x68, 0x65, 0x72,
+ 0x00, 0x68, 0x00, 0x96, 0x03, 0x00, 0x09, 0x36, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x4E, 0x54, 0x12,
+ 0x12, 0x9D, 0x02, 0x00, 0x06, 0x00, 0x96, 0x02, 0x00, 0x05, 0x00, 0x3E, 0x96, 0x03, 0x00, 0x09,
+ 0x36, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x13, 0x4E, 0x49, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x1D, 0x00, 0x17, 0x96, 0x03,
+ 0x00, 0x09, 0x36, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08,
+ 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x49, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x4E,
+ 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x39, 0x01, 0x8E, 0x10, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0x65, 0x6E, 0x67, 0x74, 0x68, 0x00, 0x71, 0x00, 0x96,
+ 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x19, 0x4E,
+ 0x48, 0x12, 0x12, 0x9D, 0x02, 0x00, 0x05, 0x00, 0x96, 0x01, 0x00, 0x03, 0x3E, 0x96, 0x05, 0x00,
+ 0x09, 0x3A, 0x01, 0x08, 0x19, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0x19, 0x4E, 0x0D, 0x3C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x13, 0x08,
+ 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3A, 0x01, 0x1C, 0x0C,
+ 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x05, 0x00, 0x09, 0x28, 0x01, 0x08, 0x0A, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3A, 0x01, 0x1C, 0x0C, 0x4F,
+ 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0x26, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x2C,
+ 0x01, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0x74, 0x68, 0x65, 0x72,
+ 0x00, 0x50, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E,
+ 0x96, 0x03, 0x00, 0x09, 0x36, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x0B, 0x96,
+ 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x36,
+ 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x0B, 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00,
+ 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26,
+ 0x01, 0x53, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0x3B, 0x01, 0x8E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00,
+ 0x00, 0x79, 0x00, 0x39, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x02, 0x00, 0x08,
+ 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x13, 0x1C, 0x47, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4D, 0x4F,
+ 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0x28, 0x01, 0x1C, 0x47, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4D, 0x4F, 0x4F, 0x96,
+ 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0x26, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x8E, 0x08,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2D, 0x00, 0x96, 0x05, 0x00, 0x09, 0x3C, 0x01, 0x08,
+ 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x47, 0x96, 0x03, 0x00, 0x09, 0x3D, 0x01, 0x47,
+ 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x47, 0x96, 0x03,
+ 0x00, 0x09, 0x3E, 0x01, 0x47, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x8E, 0x1D, 0x00, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x79, 0x00, 0x00, 0x77, 0x69, 0x64, 0x74, 0x68, 0x00,
+ 0x00, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x00, 0x75, 0x00, 0x96, 0x03, 0x00, 0x09, 0x27, 0x01,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x19, 0x4E, 0x96, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x49,
+ 0x9D, 0x02, 0x00, 0x47, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x04, 0x00, 0x08, 0x13,
+ 0x08, 0x13, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x28, 0x01,
+ 0x09, 0x28, 0x01, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x41,
+ 0x01, 0x09, 0x41, 0x01, 0x1C, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09,
+ 0x42, 0x01, 0x09, 0x42, 0x01, 0x1C, 0x4F, 0x99, 0x02, 0x00, 0x13, 0x00, 0x96, 0x07, 0x00, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x40, 0x01, 0x52, 0x17, 0x4F,
+ 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00,
+ 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x37, 0x01,
+ 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x41, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28,
+ 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x07,
+ 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E,
+ 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x53, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00,
+ 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x57, 0x00, 0x96, 0x05, 0x00, 0x09, 0x3C, 0x01, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0x13, 0x4E, 0x47, 0x96, 0x03, 0x00, 0x09, 0x3D, 0x01, 0x47, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x47, 0x96, 0x03, 0x00, 0x09, 0x43, 0x01, 0x47, 0x96,
+ 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01, 0x4E, 0x47, 0x96, 0x03, 0x00,
+ 0x09, 0x44, 0x01, 0x47, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01,
+ 0x4E, 0x47, 0x96, 0x03, 0x00, 0x09, 0x3E, 0x01, 0x47, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96,
+ 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x38, 0x01, 0x8E, 0x0E, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x65, 0x63, 0x74, 0x00, 0xAB, 0x00, 0x96, 0x03, 0x00, 0x09,
+ 0x45, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E,
+ 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x54, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x1B, 0x00, 0x17,
+ 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0x45, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x49, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x1D,
+ 0x00, 0x17, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96,
+ 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x49, 0x4C, 0x12,
+ 0x9D, 0x02, 0x00, 0x1D, 0x00, 0x17, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09,
+ 0x41, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01,
+ 0x4E, 0x49, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x1D, 0x00, 0x17, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x42, 0x01, 0x4E, 0x49, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08,
+ 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x46, 0x01, 0x8E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x78, 0x00, 0x00, 0x79, 0x00, 0x87, 0x00, 0x96, 0x02, 0x00, 0x08, 0x13, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x48, 0x12, 0x4C, 0x12, 0x9D,
+ 0x02, 0x00, 0x17, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x48, 0x12, 0x4C, 0x12, 0x9D, 0x02, 0x00,
+ 0x22, 0x00, 0x17, 0x96, 0x02, 0x00, 0x08, 0x13, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x41,
+ 0x01, 0x4E, 0x47, 0x48, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x24, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09,
+ 0x28, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E,
+ 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x47, 0x48, 0x3E,
+ 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x47,
+ 0x01, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x6F, 0x69, 0x6E, 0x74,
+ 0x00, 0xA3, 0x00, 0x96, 0x03, 0x00, 0x09, 0x48, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E,
+ 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x48, 0x12, 0x4C, 0x12,
+ 0x9D, 0x02, 0x00, 0x1E, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09, 0x48, 0x01, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01,
+ 0x4E, 0x48, 0x12, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x29, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09, 0x48,
+ 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01,
+ 0x4E, 0x47, 0x48, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x2B, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09, 0x48,
+ 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09,
+ 0x42, 0x01, 0x4E, 0x47, 0x48, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0x49, 0x01, 0x8E, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x72, 0x65, 0x63, 0x74, 0x00, 0x63, 0x01, 0x96, 0x05, 0x00, 0x09, 0x4A, 0x01, 0x08, 0x0A,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x41, 0x01, 0x4E, 0x47, 0x3C, 0x96, 0x05, 0x00, 0x09, 0x4B, 0x01, 0x08, 0x0A, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09,
+ 0x42, 0x01, 0x4E, 0x47, 0x3C, 0x96, 0x06, 0x00, 0x09, 0x4C, 0x01, 0x09, 0x45, 0x01, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09,
+ 0x41, 0x01, 0x4E, 0x47, 0x3C, 0x96, 0x06, 0x00, 0x09, 0x4D, 0x01, 0x09, 0x45, 0x01, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x42, 0x01, 0x4E, 0x47, 0x3C, 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x48,
+ 0x12, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x16, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x4A, 0x01, 0x1C, 0x48, 0x4C, 0x12,
+ 0x9D, 0x02, 0x00, 0x1E, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01,
+ 0x4E, 0x48, 0x12, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x17, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09, 0x45,
+ 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x4B, 0x01, 0x1C,
+ 0x48, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x15, 0x00, 0x17, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x4C, 0x01, 0x1C, 0x48, 0x4C, 0x12, 0x9D,
+ 0x02, 0x00, 0x11, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09, 0x4A, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09,
+ 0x4C, 0x01, 0x1C, 0x48, 0x12, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x16, 0x00, 0x17, 0x96, 0x02, 0x00,
+ 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x4D, 0x01,
+ 0x1C, 0x48, 0x4C, 0x12, 0x9D, 0x02, 0x00, 0x11, 0x00, 0x17, 0x96, 0x03, 0x00, 0x09, 0x4B, 0x01,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0x4D, 0x01, 0x1C, 0x48, 0x12, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E,
+ 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x4E, 0x01, 0x8E, 0x08, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08,
+ 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01, 0x4E, 0x48, 0x12, 0x4C, 0x9D, 0x02, 0x00, 0x15,
+ 0x00, 0x17, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x42, 0x01, 0x4E, 0x48, 0x12, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08,
+ 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x40, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x47, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x08, 0x13, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x08, 0x00, 0x09, 0x28, 0x01,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x08, 0x00, 0x09,
+ 0x41, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x08,
+ 0x00, 0x09, 0x42, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96,
+ 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x4F, 0x01, 0x8E, 0x0E, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x65, 0x63, 0x74, 0x00, 0xF4, 0x01, 0x96, 0x0A, 0x00, 0x09,
+ 0x50, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x53, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x4E, 0x01, 0x52, 0x4C, 0x9D, 0x02, 0x00, 0x14,
+ 0x00, 0x17, 0x96, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x4E, 0x01, 0x52, 0x12, 0x9D, 0x02, 0x00, 0x1C, 0x00, 0x96, 0x08, 0x00, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x09, 0x50, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x40, 0x01, 0x52, 0x17, 0x96,
+ 0x03, 0x00, 0x09, 0x50, 0x01, 0x1C, 0x3E, 0x96, 0x03, 0x00, 0x09, 0x50, 0x01, 0x1C, 0x96, 0x05,
+ 0x00, 0x08, 0x13, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00,
+ 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x08, 0x00, 0x07, 0x02, 0x00, 0x00,
+ 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x51, 0x01, 0x52, 0x4F, 0x96, 0x03, 0x00,
+ 0x09, 0x50, 0x01, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x28, 0x01, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28,
+ 0x01, 0x4E, 0x96, 0x08, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x51, 0x01, 0x52, 0x4F, 0x96, 0x03, 0x00, 0x09, 0x50, 0x01, 0x1C, 0x96, 0x06, 0x00,
+ 0x09, 0x41, 0x01, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00,
+ 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01, 0x4E, 0x47, 0x96, 0x02, 0x00, 0x08,
+ 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x41, 0x01, 0x4E, 0x47, 0x96, 0x08, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x09, 0x30,
+ 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x52, 0x01, 0x52, 0x96, 0x03, 0x00, 0x09, 0x50, 0x01, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x0B, 0x4F, 0x96, 0x03, 0x00, 0x09, 0x50, 0x01, 0x1C, 0x96,
+ 0x06, 0x00, 0x09, 0x42, 0x01, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E,
+ 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x47, 0x96,
+ 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08,
+ 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x47, 0x96, 0x08, 0x00, 0x07, 0x02, 0x00,
+ 0x00, 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x52, 0x01, 0x52, 0x96, 0x03, 0x00,
+ 0x09, 0x50, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x0B, 0x4F, 0x96, 0x08, 0x00,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x09, 0x50, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01, 0x4E,
+ 0x48, 0x12, 0x4C, 0x9D, 0x02, 0x00, 0x16, 0x00, 0x17, 0x96, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x09, 0x50, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x48, 0x12, 0x12, 0x9D,
+ 0x02, 0x00, 0x14, 0x00, 0x96, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x09, 0x50, 0x01, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0x40, 0x01, 0x52, 0x17, 0x96, 0x03, 0x00, 0x09, 0x50, 0x01, 0x1C, 0x3E,
+ 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x53,
+ 0x01, 0x8E, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x65, 0x63, 0x74, 0x00,
+ 0x27, 0x00, 0x96, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x07,
+ 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x4F, 0x01, 0x52,
+ 0x96, 0x03, 0x00, 0x09, 0x4E, 0x01, 0x52, 0x12, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02,
+ 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x54, 0x01, 0x8E, 0x0E, 0x00, 0x00, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x72, 0x65, 0x63, 0x74, 0x00, 0xB3, 0x01, 0x96, 0x07, 0x00, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x4E, 0x01, 0x52, 0x12, 0x9D, 0x02,
+ 0x00, 0x14, 0x00, 0x96, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x37, 0x01, 0x52, 0x3E, 0x96, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x09,
+ 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x4E, 0x01, 0x52, 0x12, 0x9D, 0x02, 0x00, 0x13, 0x00,
+ 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x37,
+ 0x01, 0x52, 0x3E, 0x96, 0x0A, 0x00, 0x09, 0x54, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x53, 0x3C,
+ 0x96, 0x03, 0x00, 0x09, 0x54, 0x01, 0x1C, 0x96, 0x05, 0x00, 0x08, 0x13, 0x09, 0x45, 0x01, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0x13, 0x4E, 0x96, 0x08, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x52, 0x01, 0x52, 0x4F, 0x96, 0x03, 0x00, 0x09, 0x54, 0x01, 0x1C, 0x96, 0x06, 0x00,
+ 0x09, 0x28, 0x01, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02,
+ 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x08, 0x00, 0x07, 0x02,
+ 0x00, 0x00, 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x52, 0x01, 0x52, 0x4F, 0x96,
+ 0x03, 0x00, 0x09, 0x54, 0x01, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x41, 0x01, 0x09, 0x45, 0x01, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x41, 0x01, 0x4E, 0x47, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01, 0x4E, 0x47, 0x96,
+ 0x08, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x51,
+ 0x01, 0x52, 0x96, 0x03, 0x00, 0x09, 0x54, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x0B,
+ 0x4F, 0x96, 0x03, 0x00, 0x09, 0x54, 0x01, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x42, 0x01, 0x09, 0x45,
+ 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x45, 0x01, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x47, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x42,
+ 0x01, 0x4E, 0x47, 0x96, 0x08, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x09, 0x30, 0x01, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x51, 0x01, 0x52, 0x96, 0x03, 0x00, 0x09, 0x54, 0x01, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x28, 0x01, 0x4E, 0x0B, 0x4F, 0x96, 0x03, 0x00, 0x09, 0x54, 0x01, 0x1C, 0x3E, 0x4F, 0x96,
+ 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3B, 0x01, 0x8E,
+ 0x10, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x78, 0x00, 0x00, 0x64, 0x79, 0x00,
+ 0x3A, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96,
+ 0x03, 0x00, 0x09, 0x55, 0x01, 0x1C, 0x47, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4D, 0x4F, 0x96, 0x02,
+ 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0x56, 0x01, 0x1C, 0x47, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4D, 0x4F, 0x4F, 0x96, 0x02, 0x00,
+ 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x57, 0x01, 0x8E, 0x0B, 0x00,
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x47, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A,
+ 0x1C, 0x4C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x58, 0x01, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x13, 0x4E, 0x47, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4D, 0x4F, 0x96, 0x02, 0x00,
+ 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x58,
+ 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x47, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01,
+ 0x4D, 0x4F, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E,
+ 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00,
+ 0x09, 0x59, 0x01, 0x8E, 0x10, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x78, 0x00,
+ 0x00, 0x64, 0x79, 0x00, 0x82, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x02, 0x00,
+ 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x55, 0x01, 0x1C, 0x0B, 0x96, 0x02, 0x00, 0x08, 0x13,
+ 0x4D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01, 0x4E,
+ 0x96, 0x08, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x09, 0x55, 0x01, 0x1C, 0x0C, 0x47, 0x96, 0x03,
+ 0x00, 0x09, 0x41, 0x01, 0x4D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00,
+ 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x56, 0x01, 0x1C, 0x0B, 0x96, 0x03, 0x00, 0x09,
+ 0x28, 0x01, 0x4D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00, 0x09, 0x42,
+ 0x01, 0x4E, 0x96, 0x08, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x09, 0x56, 0x01, 0x1C, 0x0C, 0x47,
+ 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4D, 0x4F, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00,
+ 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x5A, 0x01, 0x8E, 0x0B, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x64, 0x00, 0x9C, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x02,
+ 0x00, 0x08, 0x13, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x58, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13,
+ 0x4E, 0x0B, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C,
+ 0x96, 0x03, 0x00, 0x09, 0x41, 0x01, 0x4E, 0x96, 0x08, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x09,
+ 0x58, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x0C, 0x47, 0x96, 0x03, 0x00, 0x09, 0x41,
+ 0x01, 0x4D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0x58, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x0B,
+ 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96,
+ 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x96, 0x08, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x09, 0x58,
+ 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x0C, 0x47, 0x96, 0x03, 0x00, 0x09, 0x42,
+ 0x01, 0x4D, 0x4F, 0x4F, 0x8E, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0x65,
+ 0x66, 0x74, 0x00, 0x3B, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00, 0x09,
+ 0x41, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96,
+ 0x03, 0x00, 0x09, 0x5B, 0x01, 0x1C, 0x0B, 0x47, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01, 0x4D, 0x4F,
+ 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x05, 0x00, 0x08, 0x13, 0x09, 0x5B, 0x01, 0x1C, 0x4F,
+ 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x3E, 0x96, 0x0A, 0x00, 0x09, 0x5B, 0x01, 0x07, 0x03,
+ 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00,
+ 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52,
+ 0x17, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x69, 0x67, 0x68, 0x74,
+ 0x00, 0x1E, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x41, 0x01, 0x09,
+ 0x5C, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x0B,
+ 0x4F, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x96, 0x02, 0x00, 0x08,
+ 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x41, 0x01, 0x4E, 0x47, 0x3E, 0x96, 0x0A, 0x00, 0x09, 0x5C, 0x01, 0x07, 0x03, 0x00,
+ 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52, 0x17,
+ 0x8E, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x6F, 0x70, 0x00, 0x3D, 0x00,
+ 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x96, 0x02,
+ 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x5D,
+ 0x01, 0x1C, 0x0B, 0x47, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4D, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x28, 0x01, 0x09, 0x5D, 0x01, 0x1C, 0x4F, 0x8E, 0x08, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x28, 0x01, 0x4E, 0x3E, 0x96, 0x0A, 0x00, 0x09, 0x5D, 0x01, 0x07, 0x03, 0x00, 0x00,
+ 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F,
+ 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52, 0x17, 0x8E,
+ 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x6F, 0x74, 0x74, 0x6F, 0x6D, 0x00,
+ 0x1F, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x42, 0x01, 0x09, 0x5E,
+ 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x0B,
+ 0x4F, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x96, 0x02, 0x00, 0x08,
+ 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x47, 0x3E, 0x96, 0x0A, 0x00, 0x09, 0x5E, 0x01, 0x07, 0x03,
+ 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00,
+ 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52,
+ 0x17, 0x8E, 0x11, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x6F, 0x70, 0x4C, 0x65,
+ 0x66, 0x74, 0x00, 0x92, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00, 0x09,
+ 0x41, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96,
+ 0x03, 0x00, 0x09, 0x5F, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x0B, 0x47, 0x96, 0x03,
+ 0x00, 0x09, 0x41, 0x01, 0x4D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x4C, 0x96, 0x03, 0x00,
+ 0x09, 0x42, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0x5F, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x0B,
+ 0x47, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96,
+ 0x05, 0x00, 0x08, 0x13, 0x09, 0x5F, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x4F, 0x96,
+ 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09, 0x28, 0x01, 0x09, 0x5F, 0x01, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x4F, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x33, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96,
+ 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x02,
+ 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00,
+ 0x09, 0x26, 0x01, 0x53, 0x3E, 0x96, 0x0A, 0x00, 0x09, 0x5F, 0x01, 0x07, 0x03, 0x00, 0x00, 0x00,
+ 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52, 0x17, 0x8E, 0x15,
+ 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x6F, 0x74, 0x74, 0x6F, 0x6D, 0x52, 0x69,
+ 0x67, 0x68, 0x74, 0x00, 0x4A, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x06, 0x00, 0x09,
+ 0x41, 0x01, 0x09, 0x60, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08,
+ 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x0B, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C,
+ 0x96, 0x06, 0x00, 0x09, 0x42, 0x01, 0x09, 0x60, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x0B, 0x4F,
+ 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x42, 0x01, 0x4E, 0x47, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0x13, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x41, 0x01, 0x4E, 0x47,
+ 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25,
+ 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x53, 0x3E, 0x96, 0x0A, 0x00, 0x09, 0x60, 0x01,
+ 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96,
+ 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08,
+ 0x07, 0x52, 0x17, 0x8E, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x69, 0x7A,
+ 0x65, 0x00, 0x2D, 0x00, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96, 0x05, 0x00, 0x09, 0x41, 0x01,
+ 0x08, 0xE7, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x13, 0x4E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C,
+ 0x96, 0x05, 0x00, 0x09, 0x42, 0x01, 0x08, 0xE7, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x28, 0x01, 0x4E,
+ 0x4F, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x96, 0x02, 0x00, 0x08,
+ 0x0A, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x42, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0A, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x41, 0x01, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x04,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x26, 0x01, 0x53, 0x3E,
+ 0x96, 0x09, 0x00, 0x08, 0xE7, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x3F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x07, 0x52, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x61, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x62, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09,
+ 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x61, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
+ 0x96, 0x03, 0x00, 0x09, 0x37, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F,
+ 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x63, 0x01, 0x52, 0x17,
+ 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0x61, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x64,
+ 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08,
+ 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x65, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x61, 0x01, 0x4E,
+ 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x66, 0x01, 0x8E, 0x08, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x67, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x61, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0x68, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07,
+ 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x69, 0x01, 0x52,
+ 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96,
+ 0x03, 0x00, 0x09, 0x61, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0x6A, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00,
+ 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x6B, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00,
+ 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x61, 0x01,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x6C, 0x01, 0x8E, 0x08, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00,
+ 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x6D, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x61, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08,
+ 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x6E, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96,
+ 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x6F, 0x01,
+ 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E,
+ 0x96, 0x03, 0x00, 0x09, 0x61, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00,
+ 0x09, 0x70, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07,
+ 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00,
+ 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x71, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x02,
+ 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x61,
+ 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x72, 0x01, 0x8E, 0x08,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0x73, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x61, 0x01, 0x4E, 0x96, 0x02, 0x00,
+ 0x08, 0x0D, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x74, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C,
+ 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x75,
+ 0x01, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0x61, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0x76, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96,
+ 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x77, 0x01, 0x52, 0x17, 0x4F, 0x96,
+ 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0x61, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x8E, 0x08,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0x78, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09, 0x79, 0x01, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x07, 0x51, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96,
+ 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0x79, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x8E, 0x08,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0x7A, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00,
+ 0x00, 0x09, 0x7B, 0x01, 0x07, 0x51, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09,
+ 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x79, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
+ 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x0F, 0x00, 0x07,
+ 0x65, 0x00, 0x00, 0x00, 0x09, 0x7C, 0x01, 0x07, 0x51, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x79, 0x01, 0x4E, 0x96, 0x02, 0x00,
+ 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96,
+ 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09,
+ 0x7D, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x52, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00,
+ 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96, 0x0F, 0x00, 0x07, 0x65, 0x00, 0x00, 0x00, 0x09, 0x7E, 0x01,
+ 0x07, 0x52, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x25, 0x01, 0x4E, 0x96,
+ 0x03, 0x00, 0x09, 0x7D, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07,
+ 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x07,
+ 0x00, 0x08, 0xD4, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0xD4, 0x4E, 0x96, 0x14, 0x00, 0x09, 0x7F, 0x01, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x07, 0x4C, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96,
+ 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD4, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x7F,
+ 0x01, 0x4E, 0x96, 0x08, 0x00, 0x09, 0x80, 0x01, 0x07, 0x01, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02,
+ 0x00, 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD4, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x7F, 0x01,
+ 0x4E, 0x96, 0x08, 0x00, 0x09, 0x81, 0x01, 0x07, 0x02, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00,
+ 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD4, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x7F, 0x01, 0x4E,
+ 0x96, 0x08, 0x00, 0x09, 0x82, 0x01, 0x07, 0x04, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD4, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x7F, 0x01, 0x4E, 0x96,
+ 0x08, 0x00, 0x09, 0x83, 0x01, 0x07, 0x08, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x0F, 0x00, 0x07, 0x28,
+ 0x00, 0x00, 0x00, 0x09, 0x84, 0x01, 0x07, 0x4C, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x02,
+ 0x00, 0x08, 0xD4, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x7F, 0x01, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04,
+ 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09,
+ 0x85, 0x01, 0x07, 0x4C, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xD4, 0x4E,
+ 0x96, 0x03, 0x00, 0x09, 0x7F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00,
+ 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x64, 0x00, 0x00,
+ 0x00, 0x09, 0x86, 0x01, 0x07, 0x4C, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0xD4, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x7F, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96,
+ 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04,
+ 0x1C, 0x96, 0x08, 0x00, 0x09, 0x87, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02,
+ 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88,
+ 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x96, 0x02, 0x00,
+ 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0x89, 0x01, 0x8E, 0x20, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x6E, 0x61, 0x6D, 0x65, 0x00, 0x00, 0x69, 0x6E, 0x73, 0x74, 0x61, 0x6E, 0x63, 0x65, 0x00,
+ 0x00, 0x6D, 0x65, 0x74, 0x68, 0x6F, 0x64, 0x00, 0xC7, 0x00, 0x96, 0x02, 0x00, 0x08, 0x9D, 0x1C,
+ 0x12, 0x4C, 0x9D, 0x02, 0x00, 0x1D, 0x00, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0x8A, 0x01, 0x4E, 0x12, 0x12, 0x9D, 0x02, 0x00, 0x06, 0x00, 0x96, 0x02, 0x00, 0x05, 0x00, 0x3E,
+ 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87,
+ 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x8B, 0x01, 0x52,
+ 0x17, 0x8E, 0x11, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x65, 0x71, 0x75, 0x65,
+ 0x73, 0x74, 0x00, 0x35, 0x00, 0x96, 0x03, 0x00, 0x09, 0x8D, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0x9D, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x8C, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00,
+ 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88,
+ 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x8E, 0x01, 0x52, 0x3E, 0x96, 0x02, 0x00, 0x08, 0x0E, 0x1C,
+ 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87,
+ 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x8F, 0x01, 0x52,
+ 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96,
+ 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x90, 0x01, 0x8E, 0x0E, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6E, 0x61, 0x6D, 0x65, 0x00, 0xF6, 0x02, 0x96, 0x02, 0x00,
+ 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0x8A, 0x01, 0x4E, 0x12, 0x12, 0x9D, 0x02, 0x00, 0x05, 0x00, 0x96,
+ 0x01, 0x00, 0x02, 0x3E, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00,
+ 0x09, 0x8B, 0x01, 0x52, 0x17, 0x96, 0x06, 0x00, 0x09, 0x8D, 0x01, 0x09, 0x91, 0x01, 0x3C, 0x96,
+ 0x0A, 0x00, 0x09, 0x93, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x92,
+ 0x01, 0x52, 0x3C, 0x96, 0x03, 0x00, 0x09, 0x93, 0x01, 0x1C, 0x96, 0x01, 0x00, 0x02, 0x49, 0x12,
+ 0x12, 0x9D, 0x02, 0x00, 0x18, 0x00, 0x96, 0x03, 0x00, 0x09, 0x8D, 0x01, 0x4C, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x93, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x94, 0x01, 0x47, 0x47, 0x1D, 0x96, 0x03,
+ 0x00, 0x09, 0x8D, 0x01, 0x4C, 0x1C, 0x96, 0x05, 0x00, 0x09, 0x95, 0x01, 0x08, 0x0E, 0x1C, 0x47,
+ 0x96, 0x03, 0x00, 0x09, 0x96, 0x01, 0x47, 0x47, 0x1D, 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x01,
+ 0x00, 0x00, 0x00, 0x3C, 0x99, 0x02, 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C,
+ 0x50, 0x1D, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x27, 0x01, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x19, 0x4E, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x5F, 0x00, 0x96, 0x07, 0x00, 0x07,
+ 0x01, 0x00, 0x00, 0x00, 0x08, 0x18, 0x1C, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x10, 0x00, 0x96, 0x03,
+ 0x00, 0x09, 0x8D, 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x97, 0x01, 0x47, 0x1D, 0x96, 0x03,
+ 0x00, 0x09, 0x8D, 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x27, 0x01, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0x18, 0x1C, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00,
+ 0x09, 0x98, 0x01, 0x52, 0x47, 0x1D, 0x99, 0x02, 0x00, 0x7E, 0xFF, 0x96, 0x03, 0x00, 0x09, 0x8D,
+ 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x99, 0x01, 0x47, 0x1D, 0x96, 0x03, 0x00, 0x09, 0x93,
+ 0x01, 0x1C, 0x96, 0x01, 0x00, 0x02, 0x49, 0x12, 0x12, 0x9D, 0x02, 0x00, 0x10, 0x00, 0x96, 0x03,
+ 0x00, 0x09, 0x8D, 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x3E, 0x01, 0x47, 0x1D, 0x96, 0x03,
+ 0x00, 0x09, 0x8D, 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x9A, 0x01, 0x47, 0x1D, 0x96, 0x03,
+ 0x00, 0x09, 0x93, 0x01, 0x1C, 0x96, 0x01, 0x00, 0x02, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x15, 0x00,
+ 0x96, 0x03, 0x00, 0x09, 0x8D, 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x9C, 0x01, 0x47, 0x1D,
+ 0x99, 0x02, 0x00, 0x18, 0x00, 0x96, 0x03, 0x00, 0x09, 0x8D, 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x93, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x9B, 0x01, 0x47, 0x47, 0x1D, 0x96, 0x05, 0x00,
+ 0x08, 0xED, 0x09, 0x8D, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96,
+ 0x03, 0x00, 0x09, 0x9D, 0x01, 0x52, 0x3C, 0x96, 0x02, 0x00, 0x08, 0xED, 0x1C, 0x96, 0x01, 0x00,
+ 0x02, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x6E, 0x00, 0x96, 0x08, 0x00, 0x09, 0x8D, 0x01, 0x09, 0x9E,
+ 0x01, 0x08, 0x0E, 0x1C, 0x47, 0x96, 0x03, 0x00, 0x09, 0x9F, 0x01, 0x47, 0x96, 0x03, 0x00, 0x09,
+ 0x27, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0xA0, 0x01, 0x52, 0x47, 0x96, 0x03, 0x00, 0x09, 0xA1, 0x01, 0x47, 0x1D, 0x96, 0x05, 0x00, 0x08,
+ 0xED, 0x09, 0x8D, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0xA2, 0x01, 0x52, 0x1D, 0x96, 0x02, 0x00, 0x08, 0xED, 0x1C, 0x96, 0x01, 0x00, 0x02,
+ 0x49, 0x12, 0x9D, 0x02, 0x00, 0x05, 0x00, 0x96, 0x01, 0x00, 0x02, 0x3E, 0x96, 0x0A, 0x00, 0x09,
+ 0xA3, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x68, 0x40, 0x3C, 0x96, 0x03, 0x00, 0x09, 0xA3,
+ 0x01, 0x1C, 0x96, 0x05, 0x00, 0x09, 0xA4, 0x01, 0x05, 0x01, 0x4F, 0x96, 0x02, 0x00, 0x08, 0xED,
+ 0x1C, 0x96, 0x08, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x02, 0x00,
+ 0x08, 0x6D, 0x52, 0x17, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA5,
+ 0x01, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA6,
+ 0x01, 0x52, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x8E, 0x01, 0x8E, 0x23,
+ 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x69, 0x6E, 0x73, 0x74, 0x61, 0x6E, 0x63, 0x65,
+ 0x00, 0x00, 0x6D, 0x65, 0x74, 0x68, 0x6F, 0x64, 0x00, 0x00, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73,
+ 0x74, 0x00, 0x9A, 0x01, 0x96, 0x0A, 0x00, 0x09, 0xA3, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08,
+ 0x68, 0x40, 0x3C, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x05, 0x00, 0x09, 0xA4, 0x01,
+ 0x05, 0x01, 0x4F, 0x96, 0x03, 0x00, 0x09, 0x8D, 0x01, 0x1C, 0x96, 0x08, 0x00, 0x07, 0x01, 0x00,
+ 0x00, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x6D, 0x52, 0x17, 0x96, 0x04, 0x00,
+ 0x09, 0xA7, 0x01, 0x02, 0x3C, 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3C,
+ 0x99, 0x02, 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C, 0x50, 0x1D, 0x96, 0x02,
+ 0x00, 0x08, 0x18, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA5,
+ 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x19, 0x4E, 0x48,
+ 0x12, 0x9D, 0x02, 0x00, 0x5A, 0x00, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0xA5, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x18,
+ 0x1C, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA9, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x27, 0x01, 0x49,
+ 0x12, 0x9D, 0x02, 0x00, 0x25, 0x00, 0x96, 0x06, 0x00, 0x09, 0xA7, 0x01, 0x09, 0xA3, 0x01, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0xA5, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96, 0x02,
+ 0x00, 0x08, 0x18, 0x1C, 0x4E, 0x1D, 0x99, 0x02, 0x00, 0x05, 0x00, 0x99, 0x02, 0x00, 0x75, 0xFF,
+ 0x96, 0x05, 0x00, 0x08, 0xED, 0x09, 0xA7, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00,
+ 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88,
+ 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xAA, 0x01, 0x52, 0x96, 0x03, 0x00, 0x09, 0x8C, 0x01, 0x1C,
+ 0x96, 0x07, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x9D, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xAB,
+ 0x01, 0x52, 0x3C, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA5, 0x01,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0xAC, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xAD, 0x01, 0x4E, 0x96,
+ 0x03, 0x00, 0x09, 0xAE, 0x01, 0x49, 0x9D, 0x02, 0x00, 0x2C, 0x00, 0x96, 0x02, 0x00, 0x08, 0xED,
+ 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09,
+ 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xAF, 0x01,
+ 0x52, 0x3E, 0x99, 0x02, 0x00, 0x27, 0x00, 0x96, 0x02, 0x00, 0x08, 0xED, 0x1C, 0x96, 0x07, 0x00,
+ 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96,
+ 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x98, 0x01, 0x52, 0x3E, 0x4F, 0x96,
+ 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xB0, 0x01, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x61, 0x72, 0x72, 0x61, 0x79, 0x00, 0xA2, 0x00, 0x96, 0x06, 0x00, 0x09, 0xB2,
+ 0x01, 0x09, 0xB1, 0x01, 0x3C, 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3C,
+ 0x99, 0x02, 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C, 0x50, 0x1D, 0x96, 0x02,
+ 0x00, 0x08, 0x18, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xB3, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x19,
+ 0x4E, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x56, 0x00, 0x96, 0x03, 0x00, 0x09, 0xB2, 0x01, 0x4C, 0x1C,
+ 0x96, 0x05, 0x00, 0x09, 0xB4, 0x01, 0x08, 0x18, 0x1C, 0x47, 0x96, 0x03, 0x00, 0x09, 0xB5, 0x01,
+ 0x47, 0x96, 0x03, 0x00, 0x09, 0xB3, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x4E, 0x96,
+ 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xAF, 0x01, 0x52, 0x47,
+ 0x96, 0x03, 0x00, 0x09, 0xB6, 0x01, 0x47, 0x47, 0x1D, 0x99, 0x02, 0x00, 0x87, 0xFF, 0x96, 0x03,
+ 0x00, 0x09, 0xB2, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xB7, 0x01, 0x47, 0x3E, 0x4F, 0x96, 0x02,
+ 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88,
+ 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA0, 0x01, 0x8E, 0x0E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x61, 0x72, 0x67, 0x73, 0x00, 0x89, 0x00, 0x96, 0x06, 0x00, 0x09, 0xB2, 0x01, 0x09,
+ 0xB8, 0x01, 0x3C, 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x99, 0x02,
+ 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C, 0x50, 0x1D, 0x96, 0x02, 0x00, 0x08,
+ 0x18, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA7, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x19, 0x4E, 0x48,
+ 0x12, 0x9D, 0x02, 0x00, 0x3D, 0x00, 0x96, 0x03, 0x00, 0x09, 0xB2, 0x01, 0x4C, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0xA7, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x4E, 0x96, 0x07, 0x00, 0x07,
+ 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xAF, 0x01, 0x52, 0x47, 0x1D, 0x99, 0x02,
+ 0x00, 0xA0, 0xFF, 0x96, 0x03, 0x00, 0x09, 0xB2, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xB9, 0x01,
+ 0x47, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E,
+ 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xBA, 0x01, 0x8E, 0x0D, 0x00,
+ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6F, 0x62, 0x6A, 0x00, 0x8C, 0x00, 0x96, 0x06, 0x00,
+ 0x09, 0xB2, 0x01, 0x09, 0xBB, 0x01, 0x3C, 0x96, 0x03, 0x00, 0x09, 0xBC, 0x01, 0x46, 0x87, 0x01,
+ 0x00, 0x00, 0x96, 0x01, 0x00, 0x02, 0x49, 0x9D, 0x02, 0x00, 0x5E, 0x00, 0x96, 0x04, 0x00, 0x08,
+ 0xBF, 0x04, 0x00, 0x3C, 0x96, 0x03, 0x00, 0x09, 0xB2, 0x01, 0x4C, 0x1C, 0x96, 0x05, 0x00, 0x09,
+ 0xB4, 0x01, 0x08, 0xBF, 0x1C, 0x47, 0x96, 0x03, 0x00, 0x09, 0xB5, 0x01, 0x47, 0x96, 0x03, 0x00,
+ 0x09, 0xBC, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBF, 0x1C, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01,
+ 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00,
+ 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xAF, 0x01, 0x52, 0x47, 0x96, 0x03, 0x00, 0x09,
+ 0xB6, 0x01, 0x47, 0x47, 0x1D, 0x99, 0x02, 0x00, 0x94, 0xFF, 0x96, 0x03, 0x00, 0x09, 0xB2, 0x01,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0xBD, 0x01, 0x47, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0xAF, 0x01, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x61,
+ 0x6C, 0x75, 0x65, 0x00, 0x7A, 0x01, 0x96, 0x05, 0x00, 0x08, 0xA3, 0x09, 0x2E, 0x01, 0x1C, 0x44,
+ 0x3C, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xBE, 0x01, 0x49, 0x9D, 0x02,
+ 0x00, 0x2A, 0x01, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x09, 0x49, 0x9D,
+ 0x02, 0x00, 0x0D, 0x01, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xC3, 0x01,
+ 0x49, 0x9D, 0x02, 0x00, 0xE3, 0x00, 0x96, 0x03, 0x00, 0x09, 0x2E, 0x01, 0x1C, 0x96, 0x01, 0x00,
+ 0x02, 0x49, 0x9D, 0x02, 0x00, 0xC6, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0xC7, 0x01, 0x49, 0x9D, 0x02, 0x00, 0x91, 0x00, 0x96, 0x0A, 0x00, 0x08, 0x19, 0x07, 0x01,
+ 0x00, 0x00, 0x00, 0x09, 0x2E, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xCA, 0x01, 0x52, 0x9D, 0x02,
+ 0x00, 0x4A, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBD, 0x49, 0x9D,
+ 0x02, 0x00, 0x0C, 0x00, 0x96, 0x03, 0x00, 0x09, 0xC6, 0x01, 0x3E, 0x99, 0x02, 0x00, 0x28, 0x00,
+ 0x96, 0x03, 0x00, 0x09, 0x2E, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08,
+ 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E,
+ 0x96, 0x03, 0x00, 0x09, 0xBA, 0x01, 0x52, 0x3E, 0x99, 0x02, 0x00, 0x28, 0x00, 0x96, 0x03, 0x00,
+ 0x09, 0x2E, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00,
+ 0x09, 0xB0, 0x01, 0x52, 0x3E, 0x99, 0x02, 0x00, 0x1E, 0x00, 0x96, 0x03, 0x00, 0x09, 0x2E, 0x01,
+ 0x1C, 0x9D, 0x02, 0x00, 0x0B, 0x00, 0x96, 0x03, 0x00, 0x09, 0xC9, 0x01, 0x99, 0x02, 0x00, 0x06,
+ 0x00, 0x96, 0x03, 0x00, 0x09, 0xC8, 0x01, 0x3E, 0x99, 0x02, 0x00, 0x07, 0x00, 0x96, 0x03, 0x00,
+ 0x09, 0xC6, 0x01, 0x3E, 0x99, 0x02, 0x00, 0x13, 0x00, 0x96, 0x06, 0x00, 0x09, 0xC4, 0x01, 0x09,
+ 0x2E, 0x01, 0x1C, 0x47, 0x96, 0x03, 0x00, 0x09, 0xC5, 0x01, 0x47, 0x3E, 0x99, 0x02, 0x00, 0x07,
+ 0x00, 0x96, 0x03, 0x00, 0x09, 0xC2, 0x01, 0x3E, 0x99, 0x02, 0x00, 0x33, 0x00, 0x96, 0x06, 0x00,
+ 0x09, 0xBF, 0x01, 0x09, 0x2E, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08,
+ 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E,
+ 0x96, 0x03, 0x00, 0x09, 0xC0, 0x01, 0x52, 0x47, 0x96, 0x03, 0x00, 0x09, 0xC1, 0x01, 0x47, 0x3E,
+ 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xCB, 0x01, 0x8E, 0x0D, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x6D, 0x6C, 0x00, 0xE1, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x1D, 0x99, 0x02, 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C, 0x50, 0x1D,
+ 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0xA8, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x19, 0x4E, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x94,
+ 0x00, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96,
+ 0x02, 0x00, 0x08, 0x18, 0x1C, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA9, 0x01, 0x4E, 0x96, 0x03, 0x00,
+ 0x09, 0xCC, 0x01, 0x49, 0x12, 0x9D, 0x02, 0x00, 0x66, 0x00, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96, 0x02,
+ 0x00, 0x08, 0x18, 0x1C, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xAC, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0x93, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA5, 0x01, 0x4E, 0x96,
+ 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA6, 0x01, 0x52, 0x4F,
+ 0x99, 0x02, 0x00, 0x42, 0xFF, 0x96, 0x02, 0x00, 0x08, 0x1C, 0x1C, 0x3E, 0x4F, 0x96, 0x02, 0x00,
+ 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0xCD, 0x01, 0x8E, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x78, 0x6D, 0x6C, 0x00, 0xE4, 0x00, 0x96, 0x08, 0x00, 0x09, 0x2A, 0x01, 0x07, 0x00, 0x00,
+ 0x00, 0x00, 0x42, 0x3C, 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x1D, 0x99,
+ 0x02, 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C, 0x50, 0x1D, 0x96, 0x02, 0x00,
+ 0x08, 0x18, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x19, 0x4E, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x95, 0x00, 0x96, 0x03,
+ 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08,
+ 0x18, 0x1C, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA9, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xCC, 0x01,
+ 0x49, 0x12, 0x9D, 0x02, 0x00, 0x67, 0x00, 0x96, 0x03, 0x00, 0x09, 0x2A, 0x01, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08,
+ 0x18, 0x1C, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xAC, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x93, 0x01,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96,
+ 0x02, 0x00, 0x08, 0x18, 0x1C, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA5, 0x01, 0x4E, 0x96, 0x07, 0x00,
+ 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96,
+ 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA6, 0x01, 0x52, 0x4F, 0x99, 0x02,
+ 0x00, 0x41, 0xFF, 0x96, 0x03, 0x00, 0x09, 0x2A, 0x01, 0x1C, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E,
+ 0x96, 0x03, 0x00, 0x09, 0xA6, 0x01, 0x8E, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x78, 0x6D, 0x6C, 0x00, 0xC2, 0x01, 0x96, 0x05, 0x00, 0x08, 0xA3, 0x09, 0xA3, 0x01, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0xA9, 0x01, 0x4E, 0x3C, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0xC3, 0x01, 0x49, 0x9D, 0x02, 0x00, 0x79, 0x01, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0xBE, 0x01, 0x49, 0x9D, 0x02, 0x00, 0x27, 0x01, 0x96, 0x02, 0x00, 0x08, 0xA3,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0xDF, 0x49, 0x9D, 0x02, 0x00, 0x0B, 0x01, 0x96, 0x02, 0x00, 0x08,
+ 0xA3, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xDE, 0x49, 0x9D, 0x02, 0x00, 0xEF, 0x00, 0x96, 0x02, 0x00,
+ 0x08, 0xA3, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xEE, 0x49, 0x9D, 0x02, 0x00, 0xD4, 0x00, 0x96, 0x02,
+ 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x09, 0x49, 0x9D, 0x02, 0x00, 0xB9, 0x00, 0x96,
+ 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBD, 0x49, 0x9D, 0x02, 0x00, 0x7B, 0x00,
+ 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xB3, 0x01, 0x49, 0x9D, 0x02, 0x00,
+ 0x3C, 0x00, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xD1, 0x01, 0x49, 0x9D,
+ 0x02, 0x00, 0x0A, 0x00, 0x96, 0x01, 0x00, 0x03, 0x3E, 0x99, 0x02, 0x00, 0x1B, 0x00, 0x96, 0x03,
+ 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA5, 0x01, 0x4E, 0x96, 0x08, 0x00, 0x07,
+ 0x01, 0x00, 0x00, 0x00, 0x09, 0xCF, 0x01, 0x3D, 0x3E, 0x99, 0x02, 0x00, 0x28, 0x00, 0x96, 0x03,
+ 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0xCD, 0x01, 0x52, 0x3E, 0x99, 0x02, 0x00, 0x28, 0x00, 0x96, 0x03, 0x00, 0x09, 0xA3,
+ 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xCB,
+ 0x01, 0x52, 0x3E, 0x99, 0x02, 0x00, 0x05, 0x00, 0x96, 0x01, 0x00, 0x03, 0x3E, 0x99, 0x02, 0x00,
+ 0x05, 0x00, 0x96, 0x01, 0x00, 0x02, 0x3E, 0x99, 0x02, 0x00, 0x06, 0x00, 0x96, 0x02, 0x00, 0x05,
+ 0x01, 0x3E, 0x99, 0x02, 0x00, 0x06, 0x00, 0x96, 0x02, 0x00, 0x05, 0x00, 0x3E, 0x99, 0x02, 0x00,
+ 0x3B, 0x00, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA5, 0x01, 0x4E,
+ 0x96, 0x08, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0xCF, 0x01, 0x3D, 0x96, 0x07, 0x00, 0x07,
+ 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xD0, 0x01, 0x52, 0x3E, 0x99, 0x02, 0x00,
+ 0x26, 0x00, 0x96, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0xA5, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0F, 0x52, 0x96, 0x08, 0x00, 0x07, 0x01,
+ 0x00, 0x00, 0x00, 0x09, 0xCE, 0x01, 0x3D, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00,
+ 0x09, 0xAA, 0x01, 0x8E, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x6D, 0x6C,
+ 0x00, 0x9C, 0x00, 0x96, 0x08, 0x00, 0x09, 0xA7, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x42, 0x3C,
+ 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x99, 0x02, 0x00, 0x09, 0x00,
+ 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C, 0x50, 0x1D, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0xA3, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96, 0x02, 0x00,
+ 0x08, 0x19, 0x4E, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x4D, 0x00, 0x96, 0x03, 0x00, 0x09, 0xA3, 0x01,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0xA8, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x4E, 0x96,
+ 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xA6, 0x01, 0x52, 0x96,
+ 0x08, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0xA7, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x16,
+ 0x52, 0x17, 0x99, 0x02, 0x00, 0x89, 0xFF, 0x96, 0x03, 0x00, 0x09, 0xA7, 0x01, 0x1C, 0x3E, 0x4F,
+ 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00,
+ 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xD2, 0x01, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x61, 0x72, 0x72, 0x61, 0x79, 0x00, 0xB0, 0x00, 0x96, 0x06, 0x00, 0x09,
+ 0xB2, 0x01, 0x09, 0xD3, 0x01, 0x3C, 0x96, 0x07, 0x00, 0x08, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x3C, 0x99, 0x02, 0x00, 0x09, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x4C, 0x1C, 0x50, 0x1D, 0x96,
+ 0x02, 0x00, 0x08, 0x18, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xB3, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08,
+ 0x19, 0x4E, 0x48, 0x12, 0x9D, 0x02, 0x00, 0x64, 0x00, 0x96, 0x02, 0x00, 0x08, 0x18, 0x1C, 0x96,
+ 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x49, 0x12, 0x12, 0x9D, 0x02, 0x00, 0x10, 0x00, 0x96,
+ 0x03, 0x00, 0x09, 0xB2, 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x97, 0x01, 0x47, 0x1D, 0x96,
+ 0x03, 0x00, 0x09, 0xB2, 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xB3, 0x01, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0xD4, 0x01, 0x1C, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96,
+ 0x03, 0x00, 0x09, 0x98, 0x01, 0x52, 0x47, 0x1D, 0x99, 0x02, 0x00, 0x79, 0xFF, 0x96, 0x03, 0x00,
+ 0x09, 0xB2, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xD5, 0x01, 0x47, 0x3E, 0x4F, 0x96, 0x02, 0x00,
+ 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0xD6, 0x01, 0x8E, 0x0D, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x6F, 0x62, 0x6A, 0x00, 0xB0, 0x00, 0x96, 0x06, 0x00, 0x09, 0xB2, 0x01, 0x09, 0xD7, 0x01,
+ 0x3C, 0x96, 0x05, 0x00, 0x09, 0xD8, 0x01, 0x05, 0x00, 0x3C, 0x96, 0x03, 0x00, 0x09, 0xBC, 0x01,
+ 0x46, 0x87, 0x01, 0x00, 0x00, 0x96, 0x01, 0x00, 0x02, 0x49, 0x9D, 0x02, 0x00, 0x79, 0x00, 0x96,
+ 0x04, 0x00, 0x08, 0xBF, 0x04, 0x00, 0x3C, 0x96, 0x03, 0x00, 0x09, 0xD8, 0x01, 0x1C, 0x12, 0x9D,
+ 0x02, 0x00, 0x10, 0x00, 0x96, 0x03, 0x00, 0x09, 0xB2, 0x01, 0x4C, 0x1C, 0x96, 0x03, 0x00, 0x09,
+ 0x97, 0x01, 0x47, 0x1D, 0x96, 0x05, 0x00, 0x09, 0xD8, 0x01, 0x05, 0x01, 0x1D, 0x96, 0x03, 0x00,
+ 0x09, 0xB2, 0x01, 0x4C, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBF, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xD9,
+ 0x01, 0x47, 0x96, 0x03, 0x00, 0x09, 0xBC, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBF, 0x1C, 0x4E,
+ 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87,
+ 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x98, 0x01, 0x52,
+ 0x47, 0x47, 0x1D, 0x99, 0x02, 0x00, 0x79, 0xFF, 0x96, 0x03, 0x00, 0x09, 0xB2, 0x01, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0xDA, 0x01, 0x47, 0x3E, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0x98, 0x01, 0x8E, 0x0F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x61, 0x6C, 0x75,
+ 0x65, 0x00, 0x07, 0x01, 0x96, 0x05, 0x00, 0x08, 0xA3, 0x09, 0x2E, 0x01, 0x1C, 0x44, 0x3C, 0x96,
+ 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xBE, 0x01, 0x49, 0x9D, 0x02, 0x00, 0x97,
+ 0x00, 0x96, 0x02, 0x00, 0x08, 0xA3, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xBD, 0x49, 0x9D, 0x02, 0x00,
+ 0x19, 0x00, 0x96, 0x03, 0x00, 0x09, 0x2E, 0x01, 0x1C, 0x96, 0x08, 0x00, 0x07, 0x01, 0x00, 0x00,
+ 0x00, 0x09, 0xCF, 0x01, 0x3D, 0x3E, 0x99, 0x02, 0x00, 0x68, 0x00, 0x96, 0x03, 0x00, 0x09, 0x2E,
+ 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0xFC, 0x1C, 0x54, 0x9D, 0x02, 0x00, 0x2D, 0x00, 0x96, 0x03,
+ 0x00, 0x09, 0x2E, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0xD6, 0x01, 0x52, 0x3E, 0x99, 0x02, 0x00, 0x28, 0x00, 0x96, 0x03, 0x00, 0x09, 0x2E,
+ 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xD2,
+ 0x01, 0x52, 0x3E, 0x99, 0x02, 0x00, 0x53, 0x00, 0x96, 0x06, 0x00, 0x09, 0xDB, 0x01, 0x09, 0x2E,
+ 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xD0,
+ 0x01, 0x52, 0x96, 0x07, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xDC,
+ 0x01, 0x52, 0x47, 0x96, 0x03, 0x00, 0x09, 0xDB, 0x01, 0x47, 0x3E, 0x4F, 0x96, 0x0A, 0x00, 0x09,
+ 0xDD, 0x01, 0x07, 0x0E, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00,
+ 0x08, 0x02, 0x3D, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x64, 0x00, 0x00, 0x00, 0x09, 0xDE, 0x01, 0x07,
+ 0x0E, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D,
+ 0x17, 0x96, 0x08, 0x00, 0x07, 0x07, 0x10, 0x00, 0x00, 0x02, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0x87, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x88, 0x01, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03,
+ 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x03, 0x00, 0x09, 0xDF, 0x01, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0xE0, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96,
+ 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xE1, 0x01, 0x52, 0x17, 0x4F, 0x96,
+ 0x03, 0x00, 0x09, 0xDF, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xE2, 0x01, 0x8E, 0x08, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0xE3, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x03, 0x00, 0x09, 0xDF, 0x01, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0xE4, 0x01, 0x8E, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96,
+ 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xE5, 0x01, 0x52, 0x17, 0x4F, 0x96,
+ 0x03, 0x00, 0x09, 0xDF, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xE6, 0x01, 0x8E, 0x08, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0xE7, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x0B, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09,
+ 0xE8, 0x01, 0x09, 0xDF, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00,
+ 0x3D, 0x17, 0x96, 0x0B, 0x00, 0x09, 0xE9, 0x01, 0x07, 0x3A, 0x08, 0x00, 0x00, 0x09, 0xDF, 0x01,
+ 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08,
+ 0x02, 0x3D, 0x17, 0x96, 0x09, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x02, 0x09, 0xDF, 0x01, 0x1C,
+ 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00,
+ 0x3D, 0x17, 0x96, 0x03, 0x00, 0x09, 0xEC, 0x01, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xED, 0x01, 0x8E,
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x96, 0x07, 0x00, 0x08, 0x1C, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x43, 0x3C, 0x96, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1C,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0xEE, 0x01, 0x52, 0x17, 0x4F, 0x96, 0x0B, 0x00, 0x07, 0x01, 0x00,
+ 0x00, 0x00, 0x09, 0xED, 0x01, 0x09, 0xEC, 0x01, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00,
+ 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x14, 0x00, 0x09, 0xEF, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00,
+ 0x07, 0x69, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x1D, 0x96, 0x03,
+ 0x00, 0x09, 0xEF, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x04, 0x00, 0x08, 0x9A,
+ 0x05, 0x01, 0x4F, 0x96, 0x03, 0x00, 0x09, 0xEF, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E,
+ 0x96, 0x04, 0x00, 0x08, 0x9B, 0x05, 0x01, 0x4F, 0x96, 0x03, 0x00, 0x09, 0xEF, 0x01, 0x1C, 0x96,
+ 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x14, 0x00, 0x09, 0xF0, 0x01, 0x07, 0x03, 0x00, 0x00, 0x00,
+ 0x07, 0x69, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x4F, 0x96, 0x10,
+ 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x09, 0xF1, 0x01, 0x07, 0x69, 0x00, 0x00, 0x00, 0x09, 0xEF,
+ 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00,
+ 0x08, 0x03, 0x3D, 0x17, 0x96, 0x0F, 0x00, 0x07, 0xC8, 0x00, 0x00, 0x00, 0x08, 0xB9, 0x07, 0x84,
+ 0x03, 0x00, 0x00, 0x09, 0xEF, 0x01, 0x1C, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00,
+ 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96,
+ 0x08, 0x00, 0x09, 0xF2, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x43, 0x4F, 0x96, 0x02, 0x00, 0x08,
+ 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09, 0xF3, 0x01, 0x07,
+ 0x00, 0x00, 0x00, 0x00, 0x07, 0x58, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A,
+ 0x3D, 0x4F, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0xF4, 0x01, 0x07, 0x58, 0x04,
+ 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0xF3, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00,
+ 0x00, 0x08, 0x02, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2,
+ 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09, 0xF5, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x53, 0x04,
+ 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF5, 0x01, 0x4E, 0x96,
+ 0x09, 0x00, 0x08, 0x0D, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09,
+ 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF3, 0x01, 0x53, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF5, 0x01, 0x4E, 0x96,
+ 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x6A, 0x3A, 0x17, 0x96, 0x0F, 0x00, 0x07,
+ 0x01, 0x00, 0x00, 0x00, 0x09, 0xF6, 0x01, 0x07, 0x53, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF5, 0x01, 0x4E, 0x96, 0x02, 0x00,
+ 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96,
+ 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09,
+ 0xF7, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x4E, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00,
+ 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2,
+ 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF7, 0x01, 0x4E, 0x96, 0x09, 0x00, 0x08, 0x0D, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00,
+ 0x09, 0xF3, 0x01, 0x53, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2,
+ 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF7, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96,
+ 0x02, 0x00, 0x08, 0x6A, 0x3A, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0xF8,
+ 0x01, 0x07, 0x4E, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E,
+ 0x96, 0x03, 0x00, 0x09, 0xF7, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00,
+ 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09, 0xF9, 0x01, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x07, 0x56, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96,
+ 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0xF9, 0x01, 0x4E, 0x96, 0x09, 0x00, 0x08, 0x0D, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C,
+ 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF3, 0x01, 0x53, 0x4F, 0x96,
+ 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0xF9, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x6A, 0x3A, 0x17,
+ 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0xFA, 0x01, 0x07, 0x56, 0x04, 0x00, 0x00,
+ 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF9, 0x01,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08,
+ 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E,
+ 0x96, 0x14, 0x00, 0x09, 0xFB, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x55, 0x04, 0x00, 0x00,
+ 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xFB, 0x01, 0x4E, 0x96, 0x09, 0x00,
+ 0x08, 0x0D, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01,
+ 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF3, 0x01, 0x53, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96,
+ 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xFB, 0x01, 0x4E, 0x96, 0x02, 0x00,
+ 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x6A, 0x3A, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00,
+ 0x00, 0x00, 0x09, 0xFC, 0x01, 0x07, 0x55, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xFB, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D,
+ 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00,
+ 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09, 0xFD, 0x01,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x57, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08,
+ 0x3A, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E,
+ 0x96, 0x03, 0x00, 0x09, 0xFD, 0x01, 0x4E, 0x96, 0x09, 0x00, 0x08, 0x0D, 0x07, 0x00, 0x00, 0x00,
+ 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF3,
+ 0x01, 0x53, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E,
+ 0x96, 0x03, 0x00, 0x09, 0xFD, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00,
+ 0x08, 0x6A, 0x3A, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0xFE, 0x01, 0x07,
+ 0x57, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0xFD, 0x01, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04,
+ 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09, 0xFF, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07,
+ 0x4D, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96, 0x02, 0x00,
+ 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xFF, 0x01,
+ 0x4E, 0x96, 0x09, 0x00, 0x08, 0x0D, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03,
+ 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF3, 0x01, 0x53, 0x4F, 0x96, 0x02, 0x00,
+ 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xFF, 0x01,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x6A, 0x3A, 0x17, 0x96, 0x0F,
+ 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x02, 0x07, 0x4D, 0x04, 0x00, 0x00, 0x08, 0x04,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xFF, 0x01, 0x4E, 0x96,
+ 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D,
+ 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x14,
+ 0x00, 0x09, 0x01, 0x02, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x4F, 0x04, 0x00, 0x00, 0x07, 0x02,
+ 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x01, 0x02, 0x4E, 0x96, 0x09, 0x00, 0x08, 0x0D,
+ 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96,
+ 0x03, 0x00, 0x09, 0xF3, 0x01, 0x53, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00,
+ 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x01, 0x02, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D,
+ 0x4E, 0x96, 0x02, 0x00, 0x08, 0x6A, 0x3A, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00,
+ 0x09, 0x02, 0x02, 0x07, 0x4F, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2,
+ 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x01, 0x02, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96,
+ 0x07, 0x00, 0x07, 0x04, 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09, 0x03, 0x02, 0x07, 0xE8,
+ 0x03, 0x00, 0x00, 0x07, 0x54, 0x04, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D,
+ 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0x03, 0x02, 0x4E, 0x96, 0x09, 0x00, 0x08, 0x0D, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08,
+ 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF3, 0x01, 0x53,
+ 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0x03, 0x02, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x6A,
+ 0x3A, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0x04, 0x02, 0x07, 0x54, 0x04,
+ 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09,
+ 0x03, 0x02, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00, 0x00,
+ 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2,
+ 0x01, 0x4E, 0x96, 0x14, 0x00, 0x09, 0x05, 0x02, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x54, 0x04,
+ 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3A, 0x3D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04,
+ 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0x05, 0x02, 0x4E, 0x96,
+ 0x09, 0x00, 0x08, 0x0D, 0x07, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09,
+ 0xF2, 0x01, 0x4E, 0x96, 0x03, 0x00, 0x09, 0xF3, 0x01, 0x53, 0x4C, 0x96, 0x02, 0x00, 0x08, 0x1C,
+ 0x4D, 0x1D, 0x4F, 0x96, 0x02, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E,
+ 0x96, 0x03, 0x00, 0x09, 0x05, 0x02, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x02, 0x00,
+ 0x08, 0x6A, 0x3A, 0x17, 0x96, 0x0F, 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x09, 0x04, 0x02, 0x07,
+ 0x54, 0x04, 0x00, 0x00, 0x08, 0x04, 0x1C, 0x96, 0x03, 0x00, 0x09, 0xF2, 0x01, 0x4E, 0x96, 0x03,
+ 0x00, 0x09, 0x05, 0x02, 0x4E, 0x96, 0x02, 0x00, 0x08, 0x0D, 0x4E, 0x96, 0x07, 0x00, 0x07, 0x04,
+ 0x00, 0x00, 0x00, 0x08, 0x03, 0x3D, 0x17, 0x96, 0x14, 0x00, 0x09, 0x06, 0x02, 0x07, 0x00, 0x00,
+ 0x00, 0x00, 0x07, 0xFA, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D,
+ 0x96, 0x14, 0x00, 0x09, 0x07, 0x02, 0x07, 0x01, 0x00, 0x00, 0x00, 0x07, 0xFA, 0x00, 0x00, 0x00,
+ 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x14, 0x00, 0x09, 0x08, 0x02, 0x07,
+ 0x02, 0x00, 0x00, 0x00, 0x07, 0xFA, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01,
+ 0x3D, 0x1D, 0x96, 0x06, 0x00, 0x09, 0x09, 0x02, 0x09, 0x07, 0x02, 0x1C, 0x1D, 0x96, 0x14, 0x00,
+ 0x09, 0x0A, 0x02, 0x07, 0x01, 0x00, 0x00, 0x00, 0x07, 0xFD, 0x03, 0x00, 0x00, 0x07, 0x02, 0x00,
+ 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x14, 0x00, 0x09, 0x0B, 0x02, 0x07, 0x04, 0x00, 0x00,
+ 0x00, 0x07, 0x64, 0x00, 0x00, 0x00, 0x07, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96,
+ 0x14, 0x00, 0x09, 0x0C, 0x02, 0x07, 0x00, 0x00, 0x00, 0x00, 0x07, 0x09, 0x00, 0x00, 0x00, 0x07,
+ 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, 0x3D, 0x1D, 0x96, 0x03, 0x00, 0x08, 0x1C, 0x02, 0x1D, 0x96,
+ 0x09, 0x00, 0x07, 0x00, 0x10, 0x00, 0x00, 0x08, 0x04, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x07,
+ 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x09, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00,
+ 0x08, 0x07, 0x08, 0x05, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D,
+ 0x17, 0x96, 0x08, 0x00, 0x07, 0x83, 0x00, 0x00, 0x00, 0x02, 0x08, 0x10, 0x1C, 0x96, 0x07, 0x00,
+ 0x07, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x96, 0x0D, 0x00, 0x07, 0x06, 0x00, 0x00,
+ 0x00, 0x07, 0x01, 0x00, 0x00, 0x00, 0x02, 0x08, 0x0A, 0x1C, 0x96, 0x07, 0x00, 0x07, 0x04, 0x00,
+ 0x00, 0x00, 0x08, 0x00, 0x3D, 0x17, 0x00
+};
+
diff --git a/swfdec/swfdec_internal.h b/swfdec/swfdec_internal.h
new file mode 100644
index 0000000..79d49c1
--- /dev/null
+++ b/swfdec/swfdec_internal.h
@@ -0,0 +1,68 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_INTERNAL_H_
+#define _SWFDEC_INTERNAL_H_
+
+#include <libswfdec/swfdec_types.h>
+#include <libswfdec/swfdec_codec_audio.h>
+#include <libswfdec/swfdec_codec_video.h>
+
+G_BEGIN_DECLS
+
+
+/* audio codecs */
+
+SwfdecAudioDecoder * swfdec_audio_decoder_adpcm_new (guint type,
+ SwfdecAudioFormat format);
+#ifdef HAVE_MAD
+SwfdecAudioDecoder * swfdec_audio_decoder_mad_new (guint type,
+ SwfdecAudioFormat format);
+#endif
+#ifdef HAVE_FFMPEG
+SwfdecAudioDecoder * swfdec_audio_decoder_ffmpeg_new (guint type,
+ SwfdecAudioFormat format);
+#endif
+#ifdef HAVE_GST
+SwfdecAudioDecoder * swfdec_audio_decoder_gst_new (guint type,
+ SwfdecAudioFormat format);
+#endif
+
+/* video codecs */
+
+SwfdecVideoDecoder * swfdec_video_decoder_screen_new (guint format);
+SwfdecVideoDecoder * swfdec_video_decoder_vp6_alpha_new (guint format);
+#ifdef HAVE_FFMPEG
+SwfdecVideoDecoder * swfdec_video_decoder_ffmpeg_new (guint format);
+#endif
+#ifdef HAVE_GST
+SwfdecVideoDecoder * swfdec_video_decoder_gst_new (guint format);
+#endif
+
+/* AS engine setup code */
+
+void swfdec_player_preinit_global (SwfdecAsContext * context);
+void swfdec_net_stream_init_context (SwfdecPlayer * player);
+void swfdec_sprite_movie_init_context (SwfdecPlayer * player);
+void swfdec_video_movie_init_context (SwfdecPlayer * player);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_interval.c b/swfdec/swfdec_interval.c
new file mode 100644
index 0000000..88a2ca4
--- /dev/null
+++ b/swfdec/swfdec_interval.c
@@ -0,0 +1,193 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "swfdec_interval.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_frame_internal.h"
+#include "swfdec_as_function.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_resource.h"
+
+G_DEFINE_TYPE (SwfdecInterval, swfdec_interval, SWFDEC_TYPE_AS_OBJECT)
+
+static void
+swfdec_interval_mark (SwfdecAsObject *object)
+{
+ guint i;
+ SwfdecInterval *interval = SWFDEC_INTERVAL (object);
+
+ swfdec_as_object_mark (interval->object);
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (interval->sandbox));
+ if (interval->fun_name)
+ swfdec_as_string_mark (interval->fun_name);
+ for (i = 0; i < interval->n_args; i++) {
+ swfdec_as_value_mark (&interval->args[i]);
+ }
+
+ SWFDEC_AS_OBJECT_CLASS (swfdec_interval_parent_class)->mark (object);
+}
+
+static void
+swfdec_interval_dispose (GObject *object)
+{
+ SwfdecInterval *interval = SWFDEC_INTERVAL (object);
+
+ g_free (interval->args);
+ interval->args = NULL;
+ /* needed here when GC'ed by closing the player */
+ if (interval->timeout.callback != NULL) {
+ swfdec_player_remove_timeout (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (object)->context), &interval->timeout);
+ interval->timeout.callback = NULL;
+ }
+
+ G_OBJECT_CLASS (swfdec_interval_parent_class)->dispose (object);
+}
+
+static void
+swfdec_interval_class_init (SwfdecIntervalClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
+
+ object_class->dispose = swfdec_interval_dispose;
+
+ asobject_class->mark = swfdec_interval_mark;
+}
+
+static void
+swfdec_interval_init (SwfdecInterval *array)
+{
+}
+
+static void
+swfdec_interval_trigger (SwfdecTimeout *timeout)
+{
+ SwfdecAsValue ret;
+ SwfdecInterval *interval = SWFDEC_INTERVAL ((void *) (((guchar *) timeout)
+ - G_STRUCT_OFFSET (SwfdecInterval, timeout)));
+ SwfdecAsContext *context = SWFDEC_AS_OBJECT (interval)->context;
+ SwfdecPlayer *player = SWFDEC_PLAYER (context);
+
+ if (interval->repeat) {
+ timeout->timestamp += SWFDEC_MSECS_TO_TICKS (interval->msecs);
+ swfdec_player_add_timeout (SWFDEC_PLAYER (context), timeout);
+ } else {
+ player->priv->intervals = g_list_remove (player->priv->intervals, interval);
+ interval->timeout.callback = NULL;
+ }
+ swfdec_sandbox_use (interval->sandbox);
+ if (interval->fun_name) {
+ swfdec_as_object_call (interval->object,
+ interval->fun_name, interval->n_args, interval->args, &ret);
+ } else {
+ swfdec_as_function_call (SWFDEC_AS_FUNCTION (interval->object), NULL,
+ interval->n_args, interval->args, &ret);
+ swfdec_as_context_run (context);
+ }
+ swfdec_sandbox_unuse (interval->sandbox);
+}
+
+static guint
+swfdec_interval_new (SwfdecPlayer *player, guint msecs, gboolean repeat,
+ SwfdecAsObject *object, const char *fun_name,
+ guint n_args, const SwfdecAsValue *args)
+{
+ SwfdecAsContext *context;
+ SwfdecInterval *interval;
+ guint size;
+
+ context = SWFDEC_AS_CONTEXT (player);
+ size = sizeof (SwfdecInterval) + n_args * sizeof (SwfdecAsValue);
+ if (!swfdec_as_context_use_mem (context, size))
+ return 0;
+ interval = g_object_new (SWFDEC_TYPE_INTERVAL, NULL);
+ swfdec_as_object_add (SWFDEC_AS_OBJECT (interval), context, size);
+
+ interval->id = ++player->priv->interval_id;
+ interval->sandbox = SWFDEC_SANDBOX (context->global);
+ interval->msecs = msecs;
+ interval->repeat = repeat;
+ interval->object = object;
+ interval->fun_name = fun_name;
+ interval->n_args = n_args;
+ interval->args = g_memdup (args, n_args * sizeof (SwfdecAsValue));
+ interval->timeout.timestamp = player->priv->time + SWFDEC_MSECS_TO_TICKS (interval->msecs);
+ interval->timeout.callback = swfdec_interval_trigger;
+ swfdec_player_add_timeout (player, &interval->timeout);
+
+ player->priv->intervals =
+ g_list_prepend (player->priv->intervals, interval);
+
+ return interval->id;
+}
+
+guint
+swfdec_interval_new_function (SwfdecPlayer *player, guint msecs, gboolean repeat,
+ SwfdecAsFunction *fun, guint n_args, const SwfdecAsValue *args)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), 0);
+ g_return_val_if_fail (msecs > 0, 0);
+ g_return_val_if_fail (SWFDEC_IS_AS_FUNCTION (fun), 0);
+ g_return_val_if_fail (n_args == 0 || args != NULL, 0);
+
+ return swfdec_interval_new (player, msecs, repeat, SWFDEC_AS_OBJECT (fun), NULL, n_args, args);
+}
+
+guint
+swfdec_interval_new_object (SwfdecPlayer *player, guint msecs, gboolean repeat,
+ SwfdecAsObject *thisp, const char *fun_name,
+ guint n_args, const SwfdecAsValue *args)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), 0);
+ g_return_val_if_fail (msecs > 0, 0);
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (thisp), 0);
+ g_return_val_if_fail (fun_name != NULL, 0);
+ g_return_val_if_fail (n_args == 0 || args != NULL, 0);
+
+ return swfdec_interval_new (player, msecs, repeat, thisp, fun_name, n_args, args);
+}
+
+void
+swfdec_interval_remove (SwfdecPlayer *player, guint id)
+{
+ GList *walk;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+ for (walk = player->priv->intervals; walk; walk = walk->next) {
+ SwfdecInterval *interval = walk->data;
+ if (interval->id != id)
+ continue;
+
+ player->priv->intervals = g_list_delete_link (player->priv->intervals, walk);
+ swfdec_player_remove_timeout (player, &interval->timeout);
+ interval->timeout.callback = NULL;
+ return;
+ }
+}
+
diff --git a/swfdec/swfdec_interval.h b/swfdec/swfdec_interval.h
new file mode 100644
index 0000000..48941bf
--- /dev/null
+++ b/swfdec/swfdec_interval.h
@@ -0,0 +1,80 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_INTERVAL_H_
+#define _SWFDEC_INTERVAL_H_
+
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_as_types.h>
+#include <libswfdec/swfdec_player_internal.h>
+#include <libswfdec/swfdec_sandbox.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecInterval SwfdecInterval;
+typedef struct _SwfdecIntervalClass SwfdecIntervalClass;
+
+#define SWFDEC_TYPE_INTERVAL (swfdec_interval_get_type())
+#define SWFDEC_IS_INTERVAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_INTERVAL))
+#define SWFDEC_IS_INTERVAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_INTERVAL))
+#define SWFDEC_INTERVAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_INTERVAL, SwfdecInterval))
+#define SWFDEC_INTERVAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_INTERVAL, SwfdecIntervalClass))
+#define SWFDEC_INTERVAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_INTERVAL, SwfdecIntervalClass))
+
+struct _SwfdecInterval {
+ SwfdecAsObject asobject;
+
+ SwfdecTimeout timeout;
+ SwfdecSandbox * sandbox; /* sandbox we run the script in */
+ guint id; /* id this interval is identified with */
+ guint msecs; /* interval in milliseconds */
+ gboolean repeat; /* TRUE for calling in intervals, FALSE for single-shot */
+ /* if calling named function */
+ SwfdecAsObject * object; /* this object or function to call (depending on fun_name) */
+ const char * fun_name; /* name of function or NULL if object is function */
+
+ guint n_args; /* number of arguments to call function with */
+ SwfdecAsValue * args; /* arguments for function */
+};
+
+struct _SwfdecIntervalClass {
+ SwfdecAsObjectClass asobject_class;
+};
+
+GType swfdec_interval_get_type (void);
+
+guint swfdec_interval_new_function (SwfdecPlayer * player,
+ guint msecs,
+ gboolean repeat,
+ SwfdecAsFunction * fun,
+ guint n_args,
+ const SwfdecAsValue * args);
+guint swfdec_interval_new_object (SwfdecPlayer * player,
+ guint msecs,
+ gboolean repeat,
+ SwfdecAsObject * thisp,
+ const char * fun_name,
+ guint n_args,
+ const SwfdecAsValue * args);
+void swfdec_interval_remove (SwfdecPlayer * player,
+ guint id);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_key_as.c b/swfdec/swfdec_key_as.c
new file mode 100644
index 0000000..ca7a949
--- /dev/null
+++ b/swfdec/swfdec_key_as.c
@@ -0,0 +1,83 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_as_object.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_player_internal.h"
+
+SWFDEC_AS_NATIVE (800, 0, swfdec_key_getAscii)
+void
+swfdec_key_getAscii (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+
+ SWFDEC_AS_VALUE_SET_INT (retval, player->priv->last_character);
+}
+
+SWFDEC_AS_NATIVE (800, 1, swfdec_key_getCode)
+void
+swfdec_key_getCode (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+
+ SWFDEC_AS_VALUE_SET_INT (retval, player->priv->last_keycode);
+}
+
+SWFDEC_AS_NATIVE (800, 2, swfdec_key_isDown)
+void
+swfdec_key_isDown (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ guint id;
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+
+ if (argc < 1)
+ return;
+
+ id = swfdec_as_value_to_integer (cx, &argv[0]);
+ if (id >= 256) {
+ SWFDEC_FIXME ("id %u too big for a keycode", id);
+ id %= 256;
+ }
+ SWFDEC_AS_VALUE_SET_BOOLEAN (retval, (player->priv->key_pressed[id / 8] & (1 << (id % 8))) ? TRUE : FALSE);
+}
+
+SWFDEC_AS_NATIVE (800, 3, swfdec_key_isToggled)
+void
+swfdec_key_isToggled (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+ SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ SWFDEC_STUB ("Key.isToggled (static)");
+}
+
+SWFDEC_AS_NATIVE (800, 4, swfdec_key_isAccessible)
+void
+swfdec_key_isAccessible (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ SWFDEC_STUB ("Key.isAccessible (static)");
+}
diff --git a/swfdec/swfdec_keys.h b/swfdec/swfdec_keys.h
new file mode 100644
index 0000000..a32e546
--- /dev/null
+++ b/swfdec/swfdec_keys.h
@@ -0,0 +1,126 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_KEYS_H_
+#define _SWFDEC_KEYS_H_
+
+G_BEGIN_DECLS
+
+typedef enum {
+ SWFDEC_KEY_BACKSPACE = 8,
+ SWFDEC_KEY_TAB = 9,
+ SWFDEC_KEY_CLEAR = 12,
+ SWFDEC_KEY_ENTER = 13,
+ SWFDEC_KEY_SHIFT = 16,
+ SWFDEC_KEY_CONTROL = 17,
+ SWFDEC_KEY_ALT = 18,
+ SWFDEC_KEY_CAPS_LOCK = 20,
+ SWFDEC_KEY_ESCAPE = 27,
+ SWFDEC_KEY_SPACE = 32,
+ SWFDEC_KEY_PAGE_UP = 33,
+ SWFDEC_KEY_PAGE_DOWN = 34,
+ SWFDEC_KEY_END = 35,
+ SWFDEC_KEY_HOME = 36,
+ SWFDEC_KEY_LEFT = 37,
+ SWFDEC_KEY_UP = 38,
+ SWFDEC_KEY_RIGHT = 39,
+ SWFDEC_KEY_DOWN = 40,
+ SWFDEC_KEY_INSERT = 45,
+ SWFDEC_KEY_DELETE = 46,
+ SWFDEC_KEY_HELP = 47,
+ SWFDEC_KEY_0 = 48,
+ SWFDEC_KEY_1 = 49,
+ SWFDEC_KEY_2 = 50,
+ SWFDEC_KEY_3 = 51,
+ SWFDEC_KEY_4 = 52,
+ SWFDEC_KEY_5 = 53,
+ SWFDEC_KEY_6 = 54,
+ SWFDEC_KEY_7 = 55,
+ SWFDEC_KEY_8 = 56,
+ SWFDEC_KEY_9 = 57,
+ SWFDEC_KEY_A = 65,
+ SWFDEC_KEY_B = 66,
+ SWFDEC_KEY_C = 67,
+ SWFDEC_KEY_D = 68,
+ SWFDEC_KEY_E = 69,
+ SWFDEC_KEY_F = 70,
+ SWFDEC_KEY_G = 71,
+ SWFDEC_KEY_H = 72,
+ SWFDEC_KEY_I = 73,
+ SWFDEC_KEY_J = 74,
+ SWFDEC_KEY_K = 75,
+ SWFDEC_KEY_L = 76,
+ SWFDEC_KEY_M = 77,
+ SWFDEC_KEY_N = 78,
+ SWFDEC_KEY_O = 79,
+ SWFDEC_KEY_P = 80,
+ SWFDEC_KEY_Q = 81,
+ SWFDEC_KEY_R = 82,
+ SWFDEC_KEY_S = 83,
+ SWFDEC_KEY_T = 84,
+ SWFDEC_KEY_U = 85,
+ SWFDEC_KEY_V = 86,
+ SWFDEC_KEY_W = 87,
+ SWFDEC_KEY_X = 88,
+ SWFDEC_KEY_Y = 89,
+ SWFDEC_KEY_Z = 90,
+ SWFDEC_KEY_NUMPAD_0 = 96,
+ SWFDEC_KEY_NUMPAD_1 = 97,
+ SWFDEC_KEY_NUMPAD_2 = 98,
+ SWFDEC_KEY_NUMPAD_3 = 99,
+ SWFDEC_KEY_NUMPAD_4 = 100,
+ SWFDEC_KEY_NUMPAD_5 = 101,
+ SWFDEC_KEY_NUMPAD_6 = 102,
+ SWFDEC_KEY_NUMPAD_7 = 103,
+ SWFDEC_KEY_NUMPAD_8 = 104,
+ SWFDEC_KEY_NUMPAD_9 = 105,
+ SWFDEC_KEY_NUMPAD_MULTIPLY = 106,
+ SWFDEC_KEY_NUMPAD_ADD = 107,
+ SWFDEC_KEY_NUMPAD_SUBTRACT = 109,
+ SWFDEC_KEY_NUMPAD_DECIMAL = 110,
+ SWFDEC_KEY_NUMPAD_DIVIDE = 111,
+ SWFDEC_KEY_F1 = 112,
+ SWFDEC_KEY_F2 = 113,
+ SWFDEC_KEY_F3 = 114,
+ SWFDEC_KEY_F4 = 115,
+ SWFDEC_KEY_F5 = 116,
+ SWFDEC_KEY_F6 = 117,
+ SWFDEC_KEY_F7 = 118,
+ SWFDEC_KEY_F8 = 119,
+ SWFDEC_KEY_F9 = 120,
+ SWFDEC_KEY_F10 = 121,
+ SWFDEC_KEY_F11 = 122,
+ SWFDEC_KEY_F12 = 123,
+ SWFDEC_KEY_F13 = 124,
+ SWFDEC_KEY_F14 = 125,
+ SWFDEC_KEY_F15 = 126,
+ SWFDEC_KEY_NUM_LOCK = 144,
+ SWFDEC_KEY_SEMICOLON = 186,
+ SWFDEC_KEY_EQUAL = 187,
+ SWFDEC_KEY_MINUS = 189,
+ SWFDEC_KEY_SLASH = 191,
+ SWFDEC_KEY_GRAVE = 192,
+ SWFDEC_KEY_LEFT_BRACKET = 219,
+ SWFDEC_KEY_BACKSLASH = 220,
+ SWFDEC_KEY_RIGHT_BRACKET = 221,
+ SWFDEC_KEY_APOSTROPHE = 222,
+} SwfdecKey;
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_load_object.c b/swfdec/swfdec_load_object.c
new file mode 100644
index 0000000..0e6e58d
--- /dev/null
+++ b/swfdec/swfdec_load_object.c
@@ -0,0 +1,259 @@
+/* Swfdec
+ * Copyright (C) 2007-2008 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include "swfdec_load_object.h"
+#include "swfdec_as_frame_internal.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_loader_internal.h"
+#include "swfdec_stream_target.h"
+#include "swfdec_player_internal.h"
+
+/*** SWFDEC_STREAM_TARGET ***/
+
+static SwfdecPlayer *
+swfdec_load_object_stream_target_get_player (SwfdecStreamTarget *target)
+{
+ return SWFDEC_PLAYER (SWFDEC_LOAD_OBJECT (target)->target->context);
+}
+
+static void
+swfdec_load_object_stream_target_parse (SwfdecStreamTarget *target,
+ SwfdecStream *stream)
+{
+ SwfdecLoader *loader = SWFDEC_LOADER (stream);
+ SwfdecLoadObject *load_object = SWFDEC_LOAD_OBJECT (target);
+
+ if (load_object->progress != NULL) {
+ swfdec_sandbox_use (load_object->sandbox);
+ load_object->progress (load_object->target,
+ swfdec_loader_get_loaded (loader), swfdec_loader_get_size (loader));
+ swfdec_sandbox_unuse (load_object->sandbox);
+ }
+}
+
+static void
+swfdec_load_object_stream_target_error (SwfdecStreamTarget *target,
+ SwfdecStream *stream)
+{
+ SwfdecLoader *loader = SWFDEC_LOADER (stream);
+ SwfdecLoadObject *load_object = SWFDEC_LOAD_OBJECT (target);
+
+ /* break reference to the loader */
+ swfdec_stream_set_target (SWFDEC_STREAM (loader), NULL);
+ load_object->loader = NULL;
+ g_object_unref (loader);
+
+ /* call finish */
+ swfdec_sandbox_use (load_object->sandbox);
+ load_object->finish (load_object->target, NULL);
+ swfdec_sandbox_unuse (load_object->sandbox);
+
+ /* unroot */
+ swfdec_player_unroot (SWFDEC_PLAYER (
+ SWFDEC_AS_OBJECT (load_object->sandbox)->context), load_object);
+}
+
+static void
+swfdec_load_object_stream_target_close (SwfdecStreamTarget *target,
+ SwfdecStream *stream)
+{
+ SwfdecLoader *loader = SWFDEC_LOADER (stream);
+ SwfdecLoadObject *load_object = SWFDEC_LOAD_OBJECT (target);
+ char *text;
+
+ // get text
+ text =
+ swfdec_loader_get_text (loader, load_object->version);
+
+ /* break reference to the loader */
+ swfdec_stream_set_target (stream, NULL);
+ load_object->loader = NULL;
+ g_object_unref (loader);
+
+ /* call finish */
+ swfdec_sandbox_use (load_object->sandbox);
+ if (text != NULL) {
+ load_object->finish (load_object->target,
+ swfdec_as_context_give_string (load_object->target->context, text));
+ } else {
+ load_object->finish (load_object->target, SWFDEC_AS_STR_EMPTY);
+ }
+ swfdec_sandbox_unuse (load_object->sandbox);
+
+ /* unroot */
+ swfdec_player_unroot (SWFDEC_PLAYER (
+ SWFDEC_AS_OBJECT (load_object->sandbox)->context), load_object);
+}
+
+static void
+swfdec_load_object_stream_target_init (SwfdecStreamTargetInterface *iface)
+{
+ iface->get_player = swfdec_load_object_stream_target_get_player;
+ iface->parse = swfdec_load_object_stream_target_parse;
+ iface->close = swfdec_load_object_stream_target_close;
+ iface->error = swfdec_load_object_stream_target_error;
+}
+
+/*** SWFDEC_LOAD_OBJECT ***/
+
+G_DEFINE_TYPE_WITH_CODE (SwfdecLoadObject, swfdec_load_object, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (SWFDEC_TYPE_STREAM_TARGET, swfdec_load_object_stream_target_init))
+
+static void
+swfdec_load_object_dispose (GObject *object)
+{
+ SwfdecLoadObject *load = SWFDEC_LOAD_OBJECT (object);
+
+ if (load->loader) {
+ swfdec_stream_set_target (SWFDEC_STREAM (load->loader), NULL);
+ g_object_unref (load->loader);
+ load->loader = NULL;
+ }
+ if (load->buffer) {
+ swfdec_buffer_unref (load->buffer);
+ load->buffer = NULL;
+ }
+
+ G_OBJECT_CLASS (swfdec_load_object_parent_class)->dispose (object);
+}
+
+static void
+swfdec_load_object_class_init (SwfdecLoadObjectClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = swfdec_load_object_dispose;
+}
+
+static void
+swfdec_load_object_init (SwfdecLoadObject *load_object)
+{
+}
+
+static void
+swfdec_load_object_load (SwfdecPlayer *player, gboolean allow, gpointer obj)
+{
+ SwfdecLoadObject *load = SWFDEC_LOAD_OBJECT (obj);
+
+ if (!allow) {
+ SWFDEC_WARNING ("SECURITY: no access to %s from %s",
+ load->url, swfdec_url_get_url (load->sandbox->url));
+
+ /* unroot */
+ swfdec_player_unroot (player, load);
+ return;
+ }
+
+ load->loader = swfdec_player_load (player, load->url, load->request, load->buffer);
+
+ swfdec_stream_set_target (SWFDEC_STREAM (load->loader), SWFDEC_STREAM_TARGET (load));
+ swfdec_loader_set_data_type (load->loader, SWFDEC_LOADER_DATA_TEXT);
+}
+
+/* perform security checks */
+static void
+swfdec_load_object_request (gpointer objectp, gpointer playerp)
+{
+ SwfdecLoadObject *load = SWFDEC_LOAD_OBJECT (objectp);
+ SwfdecPlayer *player = SWFDEC_PLAYER (playerp);
+ SwfdecURL *url;
+
+ if (swfdec_url_path_is_relative (load->url)) {
+ swfdec_load_object_load (player, TRUE, load);
+ return;
+ }
+ /* FIXME: or is this relative to the player? */
+ url = swfdec_player_create_url (player, load->url);
+ if (url == NULL) {
+ swfdec_load_object_load (player, FALSE, load);
+ return;
+ }
+ switch (load->sandbox->type) {
+ case SWFDEC_SANDBOX_REMOTE:
+ case SWFDEC_SANDBOX_LOCAL_NETWORK:
+ case SWFDEC_SANDBOX_LOCAL_TRUSTED:
+ if (swfdec_url_is_local (url)) {
+ swfdec_load_object_load (player, swfdec_url_is_local (url), load);
+ } else {
+ SwfdecURL *load_url = swfdec_url_new_components (
+ swfdec_url_get_protocol (url), swfdec_url_get_host (url),
+ swfdec_url_get_port (url), "crossdomain.xml", NULL);
+ swfdec_player_allow_or_load (player, url, load_url,
+ swfdec_load_object_load, load);
+ swfdec_url_free (load_url);
+ }
+ break;
+ case SWFDEC_SANDBOX_LOCAL_FILE:
+ swfdec_load_object_load (player, swfdec_url_is_local (url), load);
+ break;
+ case SWFDEC_SANDBOX_NONE:
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ swfdec_url_free (url);
+}
+
+static void
+swfdec_load_object_mark (gpointer object, gpointer player)
+{
+ SwfdecLoadObject *load = object;
+
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (load->sandbox));
+ if (load->url)
+ swfdec_as_string_mark (load->url);
+ swfdec_as_object_mark (load->target);
+}
+
+void
+swfdec_load_object_create (SwfdecAsObject *target, const char *url,
+ SwfdecLoaderRequest request, SwfdecBuffer *data,
+ SwfdecLoadObjectProgress progress, SwfdecLoadObjectFinish finish)
+{
+ SwfdecPlayer *player;
+ SwfdecLoadObject *load;
+
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (target));
+ g_return_if_fail (url != NULL);
+ g_return_if_fail (finish != NULL);
+
+ player = SWFDEC_PLAYER (target->context);
+ load = g_object_new (SWFDEC_TYPE_LOAD_OBJECT, NULL);
+ swfdec_player_root_full (player, load, swfdec_load_object_mark, g_object_unref);
+
+ load->target = target;
+ load->url = url;
+ load->request = request;
+ load->buffer = data;
+ load->progress = progress;
+ load->finish = finish;
+ /* get the current security */
+ g_assert (SWFDEC_AS_CONTEXT (player)->frame);
+ load->sandbox = SWFDEC_SANDBOX (SWFDEC_AS_CONTEXT (player)->global);
+ load->version = SWFDEC_AS_CONTEXT (player)->version;
+ swfdec_player_request_resource (player, swfdec_load_object_request, load, NULL);
+}
diff --git a/swfdec/swfdec_load_object.h b/swfdec/swfdec_load_object.h
new file mode 100644
index 0000000..51b3baa
--- /dev/null
+++ b/swfdec/swfdec_load_object.h
@@ -0,0 +1,76 @@
+/* Swfdec
+ * Copyright (C) 2007-2008 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_LOAD_OBJECT_H_
+#define _SWFDEC_LOAD_OBJECT_H_
+
+#include <libswfdec/swfdec.h>
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_resource.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _SwfdecLoadObject SwfdecLoadObject;
+typedef struct _SwfdecLoadObjectClass SwfdecLoadObjectClass;
+
+typedef void (* SwfdecLoadObjectProgress) (SwfdecAsObject *target,
+ glong loaded, glong size);
+typedef void (* SwfdecLoadObjectFinish) (SwfdecAsObject *target,
+ const char *text);
+
+#define SWFDEC_TYPE_LOAD_OBJECT (swfdec_load_object_get_type())
+#define SWFDEC_IS_LOAD_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_LOAD_OBJECT))
+#define SWFDEC_IS_LOAD_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_LOAD_OBJECT))
+#define SWFDEC_LOAD_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_LOAD_OBJECT, SwfdecLoadObject))
+#define SWFDEC_LOAD_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_LOAD_OBJECT, SwfdecLoadObjectClass))
+#define SWFDEC_LOAD_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_LOAD_OBJECT, SwfdecLoadObjectClass))
+
+struct _SwfdecLoadObject {
+ GObject object;
+
+ const char * url; /* GC'ed url to request */
+ SwfdecLoaderRequest request; /* type of request */
+ SwfdecBuffer * buffer; /* data to send */
+ SwfdecLoader * loader; /* loader when loading or NULL */
+
+ SwfdecSandbox * sandbox; /* sandbox that inited the loading */
+ guint version; /* version used when initiating the load - for parsing the data */
+ SwfdecAsObject * target; /* target object */
+ SwfdecLoadObjectProgress progress; /* progress callback */
+ SwfdecLoadObjectFinish finish; /* finish callback */
+};
+
+struct _SwfdecLoadObjectClass {
+ GObjectClass object_class;
+};
+
+GType swfdec_load_object_get_type (void);
+
+void swfdec_load_object_create (SwfdecAsObject * target,
+ const char * url,
+ SwfdecLoaderRequest request,
+ SwfdecBuffer * data,
+ SwfdecLoadObjectProgress progress,
+ SwfdecLoadObjectFinish finish);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_load_object_as.c b/swfdec/swfdec_load_object_as.c
new file mode 100644
index 0000000..012249e
--- /dev/null
+++ b/swfdec/swfdec_load_object_as.c
@@ -0,0 +1,141 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include "swfdec_load_object.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_loader_internal.h"
+#include "swfdec_player_internal.h"
+
+static void
+swfdec_load_object_on_finish (SwfdecAsObject *target, const char *text)
+{
+ SwfdecAsValue val;
+
+ if (text != NULL) {
+ SWFDEC_AS_VALUE_SET_STRING (&val, text);
+ } else {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (&val);
+ }
+
+ swfdec_as_object_call (target, SWFDEC_AS_STR_onData, 1, &val, NULL);
+}
+
+static void
+swfdec_load_object_on_progress (SwfdecAsObject *target, glong size,
+ glong loaded)
+{
+ SwfdecAsValue val;
+
+ SWFDEC_AS_VALUE_SET_NUMBER (&val, loaded);
+ swfdec_as_object_set_variable_and_flags (target, SWFDEC_AS_STR__bytesLoaded,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN);
+
+ if (size >= 0) {
+ SWFDEC_AS_VALUE_SET_NUMBER (&val, size);
+ } else {
+ SWFDEC_AS_VALUE_SET_NUMBER (&val, loaded);
+ }
+ swfdec_as_object_set_variable_and_flags (target, SWFDEC_AS_STR__bytesTotal,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN);
+}
+
+SWFDEC_AS_NATIVE (301, 0, swfdec_load_object_as_load)
+void
+swfdec_load_object_as_load (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+ SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecAsValue val;
+ const char *url;
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (rval, FALSE);
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_OBJECT, &object, "s", &url);
+
+ swfdec_load_object_create (object, url, SWFDEC_LOADER_REQUEST_DEFAULT, NULL,
+ swfdec_load_object_on_progress, swfdec_load_object_on_finish);
+
+ SWFDEC_AS_VALUE_SET_INT (&val, 0);
+ swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR__bytesLoaded,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN);
+ SWFDEC_AS_VALUE_SET_UNDEFINED (&val);
+ swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR__bytesTotal,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN);
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (&val, FALSE);
+ swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR_loaded, &val,
+ SWFDEC_AS_VARIABLE_HIDDEN);
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (rval, TRUE);
+}
+
+SWFDEC_AS_NATIVE (301, 1, swfdec_load_object_as_send)
+void
+swfdec_load_object_as_send (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("LoadVars/XML.send");
+}
+
+SWFDEC_AS_NATIVE (301, 2, swfdec_load_object_as_sendAndLoad)
+void
+swfdec_load_object_as_sendAndLoad (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ const char *url, *data, *method_string;
+ SwfdecAsObject *target;
+ SwfdecAsValue val;
+ SwfdecBuffer *buffer;
+ SwfdecLoaderRequest method;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_OBJECT, &object, "sO|s", &url, &target, &method_string);
+
+ SWFDEC_FIXME ("support for contentType is missing");
+
+ if (method_string == NULL || g_ascii_strcasecmp (method_string, "get") == 0) {
+ method = SWFDEC_LOADER_REQUEST_GET;
+ } else {
+ method = SWFDEC_LOADER_REQUEST_POST;
+ }
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, object);
+ data = swfdec_as_value_to_string (cx, &val);
+ buffer = swfdec_buffer_new_for_data (g_memdup (data, strlen (data) + 1),
+ strlen (data) + 1);
+ swfdec_load_object_create (target, url, method, buffer,
+ swfdec_load_object_on_progress, swfdec_load_object_on_finish);
+
+ SWFDEC_AS_VALUE_SET_INT (&val, 0);
+ swfdec_as_object_set_variable_and_flags (target, SWFDEC_AS_STR__bytesLoaded,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN);
+ SWFDEC_AS_VALUE_SET_UNDEFINED (&val);
+ swfdec_as_object_set_variable_and_flags (target, SWFDEC_AS_STR__bytesTotal,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN);
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (&val, FALSE);
+ swfdec_as_object_set_variable_and_flags (target, SWFDEC_AS_STR_loaded, &val,
+ SWFDEC_AS_VARIABLE_HIDDEN);
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (rval, TRUE);
+}
diff --git a/swfdec/swfdec_loader.c b/swfdec/swfdec_loader.c
new file mode 100644
index 0000000..9868eac
--- /dev/null
+++ b/swfdec/swfdec_loader.c
@@ -0,0 +1,443 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include "swfdec_loader_internal.h"
+#include "swfdec_buffer.h"
+#include "swfdec_debug.h"
+#include "swfdec_player_internal.h"
+
+/*** gtk-doc ***/
+
+/**
+ * SECTION:SwfdecLoader
+ * @title: SwfdecLoader
+ * @short_description: object used for input
+ *
+ * SwfdecLoader is the base class used for reading input. Since developers
+ * normally need to adapt input to the needs of their application, this class
+ * is provided to be adapted to their needs. It is used both for HTTP and
+ * RTMP access.
+ *
+ * Since Flash files can load new resources while operating, a #SwfdecLoader
+ * can be instructed to load another resource.
+ *
+ * For convenience, a #SwfdecLoader for file access is provided by Swfdec.
+ */
+
+/**
+ * SwfdecLoader:
+ *
+ * This is the base object used for providing input. It is abstract, use a
+ * subclass to provide your input.
+ */
+
+/**
+ * SwfdecLoaderClass:
+ * @load: initialize a new loader based on a parent loader object. The new
+ * loader will already have its URL set.
+ *
+ * This is the base class used for input. If you create a subclass, you are
+ * supposed to set the function pointers listed above.
+ */
+
+/**
+ * SwfdecLoaderDataType:
+ * @SWFDEC_LOADER_DATA_UNKNOWN: Unidentified data or data that cannot be
+ * identified.
+ * @SWFDEC_LOADER_DATA_SWF: Data describing a normal Flash file.
+ * @SWFDEC_LOADER_DATA_FLV: Data describing a Flash video stream.
+ * @SWFDEC_LOADER_DATA_XML: Data in XML format.
+ * @SWFDEC_LOADER_DATA_TEXT: Textual data.
+ * @SWFDEC_LOADER_DATA_JPEG: a JPEG image
+ * @SWFDEC_LOADER_DATA_PNG: a PNG image
+ *
+ * This type describes the different types of data that can be loaded inside
+ * Swfdec. Swfdec identifies its data streams and you can use the
+ * swfdec_loader_get_data_type() to acquire more information about the data
+ * inside a #SwfdecLoader.
+ */
+
+/**
+ * SwfdecLoaderRequest:
+ * @SWFDEC_LOADER_REQUEST_DEFAULT: Use the default method (this most likely is
+ * equal to HTTPget)
+ * @SWFDEC_LOADER_REQUEST_GET: Use HTTP get
+ * @SWFDEC_LOADER_REQUEST_POST: Use HTTP post
+ *
+ * Describes the moethod to use for requesting a given URL. These methods map
+ * naturally to HTTP methods, since HTTP is the common method for requesting
+ * Flash content.
+ */
+
+/*** SwfdecLoader ***/
+
+enum {
+ PROP_0,
+ PROP_DATA_TYPE,
+ PROP_SIZE,
+ PROP_LOADED,
+ PROP_URL
+};
+
+G_DEFINE_ABSTRACT_TYPE (SwfdecLoader, swfdec_loader, SWFDEC_TYPE_STREAM)
+
+static const char *
+swfdec_loader_describe (SwfdecStream *stream)
+{
+ const SwfdecURL *url = SWFDEC_LOADER (stream)->url;
+
+ if (url) {
+ return swfdec_url_get_url (url);
+ } else {
+ return "unknown url";
+ }
+}
+
+static void
+swfdec_loader_get_property (GObject *object, guint param_id, GValue *value,
+ GParamSpec * pspec)
+{
+ SwfdecLoader *loader = SWFDEC_LOADER (object);
+
+ switch (param_id) {
+ case PROP_DATA_TYPE:
+ g_value_set_enum (value, loader->data_type);
+ break;
+ case PROP_SIZE:
+ g_value_set_long (value, loader->size);
+ break;
+ case PROP_LOADED:
+ g_value_set_ulong (value, swfdec_loader_get_loaded (loader));
+ break;
+ case PROP_URL:
+ g_value_set_boxed (value, loader->url);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+swfdec_loader_set_property (GObject *object, guint param_id, const GValue *value,
+ GParamSpec *pspec)
+{
+ SwfdecLoader *loader = SWFDEC_LOADER (object);
+
+ switch (param_id) {
+ case PROP_SIZE:
+ if (loader->size == -1 && g_value_get_long (value) >= 0)
+ swfdec_loader_set_size (loader, g_value_get_long (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+swfdec_loader_dispose (GObject *object)
+{
+ SwfdecLoader *loader = SWFDEC_LOADER (object);
+
+ if (loader->url) {
+ swfdec_url_free (loader->url);
+ loader->url = NULL;
+ }
+
+ G_OBJECT_CLASS (swfdec_loader_parent_class)->dispose (object);
+}
+
+static void
+swfdec_loader_class_init (SwfdecLoaderClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ SwfdecStreamClass *stream_class = SWFDEC_STREAM_CLASS (klass);
+
+ object_class->dispose = swfdec_loader_dispose;
+ object_class->get_property = swfdec_loader_get_property;
+ object_class->set_property = swfdec_loader_set_property;
+
+ 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_long ("size", "size", "amount of bytes in loader",
+ -1, G_MAXLONG, -1, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_LOADED,
+ g_param_spec_ulong ("loaded", "loaded", "bytes already loaded",
+ 0, G_MAXULONG, 0, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_URL,
+ g_param_spec_boxed ("url", "url", "URL for this file",
+ SWFDEC_TYPE_URL, G_PARAM_READABLE));
+
+ stream_class->describe = swfdec_loader_describe;
+}
+
+static void
+swfdec_loader_init (SwfdecLoader *loader)
+{
+ loader->data_type = SWFDEC_LOADER_DATA_UNKNOWN;
+
+ loader->size = -1;
+}
+
+/** PUBLIC API ***/
+
+/**
+ * swfdec_loader_set_url:
+ * @loader: the loader to update
+ * @url: string specifying the new URL. The url must be a valid absolute URL.
+ *
+ * Updates the url of the given @loader to point to the new @url. This is useful
+ * whe encountering HTTP redirects, as the loader is supposed to reference the
+ * final URL after all rdirections.
+ * This function may only be called once and must have been called before
+ * calling swfdec_stream_open() on @loader.
+ **/
+void
+swfdec_loader_set_url (SwfdecLoader *loader, const char *url)
+{
+ SwfdecURL *real;
+
+ g_return_if_fail (SWFDEC_IS_LOADER (loader));
+ g_return_if_fail (loader->url == NULL);
+ g_return_if_fail (url != NULL);
+
+ real = swfdec_url_new (url);
+ g_return_if_fail (real != NULL);
+ loader->url = real;
+}
+
+/**
+ * swfdec_loader_get_url:
+ * @loader: a #SwfdecLoader
+ *
+ * Gets the url this loader is handling. This is mostly useful for writing
+ * subclasses of #SwfdecLoader.
+ *
+ * Returns: a #SwfdecURL describing @loader or %NULL if the @url is not known
+ * yet.
+ **/
+const SwfdecURL *
+swfdec_loader_get_url (SwfdecLoader *loader)
+{
+ g_return_val_if_fail (SWFDEC_IS_LOADER (loader), NULL);
+
+ return loader->url;
+}
+
+/**
+ * swfdec_loader_get_data_type:
+ * @loader: a #SwfdecLoader
+ *
+ * Queries the type of data this loader provides. The type is determined
+ * automatically by Swfdec.
+ *
+ * Returns: the type this data was identified to be in or
+ * #SWFDEC_LOADER_DATA_UNKNOWN if not identified
+ **/
+SwfdecLoaderDataType
+swfdec_loader_get_data_type (SwfdecLoader *loader)
+{
+ g_return_val_if_fail (SWFDEC_IS_LOADER (loader), SWFDEC_LOADER_DATA_UNKNOWN);
+
+ return loader->data_type;
+}
+
+void
+swfdec_loader_set_data_type (SwfdecLoader *loader, SwfdecLoaderDataType type)
+{
+ g_return_if_fail (SWFDEC_IS_LOADER (loader));
+ g_return_if_fail (loader->data_type == SWFDEC_LOADER_DATA_UNKNOWN);
+ g_return_if_fail (type != SWFDEC_LOADER_DATA_UNKNOWN);
+
+ loader->data_type = type;
+ g_object_notify (G_OBJECT (loader), "data-type");
+}
+
+/**
+ * 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 == -1);
+ g_return_if_fail (size <= G_MAXLONG);
+
+ 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, -1 is
+ * returned. Otherwise the number is greater or equal to 0.
+ *
+ * Returns: the total number of bytes for this loader or -1 if unknown
+ **/
+glong
+swfdec_loader_get_size (SwfdecLoader *loader)
+{
+ g_return_val_if_fail (SWFDEC_IS_LOADER (loader), -1);
+
+ return loader->size;
+}
+
+/**
+ * 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)
+{
+ SwfdecBufferQueue *queue;
+
+ g_return_val_if_fail (SWFDEC_IS_LOADER (loader), 0);
+
+ queue = swfdec_stream_get_queue (SWFDEC_STREAM (loader));
+ return swfdec_buffer_queue_get_depth (queue) +
+ swfdec_buffer_queue_get_offset (queue);
+}
+
+/**
+ * swfdec_loader_data_type_get_extension:
+ * @type: a #SwfdecLoaderDataType
+ *
+ * Queries the extension to be used for data of the given @type.
+ *
+ * Returns: the typical extension for this data type or the empty string
+ * if the type has no extension
+ **/
+const char *
+swfdec_loader_data_type_get_extension (SwfdecLoaderDataType type)
+{
+ switch (type) {
+ case SWFDEC_LOADER_DATA_UNKNOWN:
+ return "";
+ case SWFDEC_LOADER_DATA_SWF:
+ return "swf";
+ case SWFDEC_LOADER_DATA_FLV:
+ return "flv";
+ case SWFDEC_LOADER_DATA_XML:
+ return "xml";
+ case SWFDEC_LOADER_DATA_TEXT:
+ return "txt";
+ case SWFDEC_LOADER_DATA_JPEG:
+ return "jpg";
+ case SWFDEC_LOADER_DATA_PNG:
+ return "png";
+ default:
+ g_warning ("unknown data type %u", type);
+ return "";
+ }
+}
+
+typedef struct {
+ const char *name;
+ guint length;
+ guchar data[4];
+} ByteOrderMark;
+
+static ByteOrderMark boms[] = {
+ { "UTF-8", 3, {0xEF, 0xBB, 0xBF, 0} },
+ { "UTF-16BE", 2, {0xFE, 0xFF, 0, 0} },
+ { "UTF-16LE", 2, {0xFF, 0xFE, 0, 0} },
+ { "UTF-8", 0, {0, 0, 0, 0} }
+};
+
+char *
+swfdec_loader_get_text (SwfdecLoader *loader, guint version)
+{
+ SwfdecBufferQueue *queue;
+ SwfdecBuffer *buffer;
+ char *text;
+ guint size, i, j;
+
+ /* get the text from the loader */
+ queue = swfdec_stream_get_queue (SWFDEC_STREAM (loader));
+ size = swfdec_buffer_queue_get_depth (queue);
+ if (size == 0) {
+ SWFDEC_LOG ("empty loader, returning empty string");
+ return g_strdup ("");
+ }
+
+ buffer = swfdec_buffer_queue_peek (queue, size);
+ if (!buffer)
+ return NULL;
+
+ if (version > 5) {
+ for (i = 0; boms[i].length > 0; i++) {
+ // FIXME: test what happens if we have BOM and nothing else
+ if (size < boms[i].length)
+ continue;
+
+ for (j = 0; j < boms[i].length; j++) {
+ if (buffer->data[j] != boms[i].data[j])
+ break;
+ }
+ if (j == boms[i].length)
+ break;
+ }
+
+ if (!strcmp (boms[i].name, "UTF-8")) {
+ if (!g_utf8_validate ((char *)buffer->data + boms[i].length,
+ size - boms[i].length, NULL)) {
+ SWFDEC_ERROR ("downloaded data is not valid UTF-8");
+ text = NULL;
+ } else {
+ text =
+ g_strndup ((char *)buffer->data + boms[i].length,
+ size - boms[i].length);
+ }
+ } else {
+ text = g_convert ((char *)buffer->data + boms[i].length,
+ size - boms[i].length, "UTF-8", boms[i].name, NULL, NULL, NULL);
+ if (text == NULL)
+ SWFDEC_ERROR ("downloaded data is not valid %s", boms[i].name);
+ }
+ } else {
+ text = g_convert ((char *)buffer->data, size, "UTF-8", "LATIN1", NULL,
+ NULL, NULL);
+ if (text == NULL)
+ SWFDEC_ERROR ("downloaded data is not valid LATIN1");
+ }
+
+ swfdec_buffer_unref (buffer);
+
+ return text;
+}
+
diff --git a/swfdec/swfdec_loader.h b/swfdec/swfdec_loader.h
new file mode 100644
index 0000000..3d0ebff
--- /dev/null
+++ b/swfdec/swfdec_loader.h
@@ -0,0 +1,97 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_LOADER_H_
+#define _SWFDEC_LOADER_H_
+
+#include <glib-object.h>
+#include <libswfdec/swfdec_buffer.h>
+#include <libswfdec/swfdec_player.h>
+#include <libswfdec/swfdec_stream.h>
+#include <libswfdec/swfdec_url.h>
+
+G_BEGIN_DECLS
+
+typedef enum {
+ SWFDEC_LOADER_DATA_UNKNOWN,
+ SWFDEC_LOADER_DATA_SWF,
+ SWFDEC_LOADER_DATA_FLV,
+ SWFDEC_LOADER_DATA_XML,
+ SWFDEC_LOADER_DATA_TEXT,
+ SWFDEC_LOADER_DATA_JPEG,
+ SWFDEC_LOADER_DATA_PNG
+} SwfdecLoaderDataType;
+
+/* NB: actal numbers in SwfdecLoaderRequest are important for GetURL2 action */
+typedef enum {
+ SWFDEC_LOADER_REQUEST_DEFAULT = 0,
+ SWFDEC_LOADER_REQUEST_GET = 1,
+ SWFDEC_LOADER_REQUEST_POST = 2
+} SwfdecLoaderRequest;
+
+typedef struct _SwfdecLoader SwfdecLoader;
+typedef struct _SwfdecLoaderClass SwfdecLoaderClass;
+
+#define SWFDEC_TYPE_LOADER (swfdec_loader_get_type())
+#define SWFDEC_IS_LOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_LOADER))
+#define SWFDEC_IS_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_LOADER))
+#define SWFDEC_LOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_LOADER, SwfdecLoader))
+#define SWFDEC_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_LOADER, SwfdecLoaderClass))
+#define SWFDEC_LOADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_LOADER, SwfdecLoaderClass))
+
+struct _SwfdecLoader
+{
+ SwfdecStream stream;
+
+ /*< protected >*/
+ SwfdecURL * url; /* the URL for this loader in UTF-8 - must be set on creation */
+ glong size; /* number of bytes in stream or -1 if unknown */
+ SwfdecLoaderDataType data_type; /* type this stream is in (identified by swfdec) */
+};
+
+struct _SwfdecLoaderClass
+{
+ SwfdecStreamClass stream_class;
+
+ void (* load) (SwfdecLoader * loader,
+ SwfdecPlayer * player,
+ const char * url,
+ SwfdecLoaderRequest request,
+ SwfdecBuffer * buffer);
+};
+
+GType swfdec_loader_get_type (void);
+
+void swfdec_loader_set_url (SwfdecLoader * loader,
+ const char * url);
+const SwfdecURL *
+ swfdec_loader_get_url (SwfdecLoader * loader);
+void swfdec_loader_set_size (SwfdecLoader * loader,
+ gulong size);
+glong swfdec_loader_get_size (SwfdecLoader * loader);
+gulong swfdec_loader_get_loaded (SwfdecLoader * loader);
+SwfdecLoaderDataType
+ swfdec_loader_get_data_type (SwfdecLoader * loader);
+
+const char * swfdec_loader_data_type_get_extension
+ (SwfdecLoaderDataType type);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_loader_internal.h b/swfdec/swfdec_loader_internal.h
new file mode 100644
index 0000000..c19ba9f
--- /dev/null
+++ b/swfdec/swfdec_loader_internal.h
@@ -0,0 +1,47 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_LOADER_INTERNAL_H_
+#define _SWFDEC_LOADER_INTERNAL_H_
+
+#include "swfdec_loader.h"
+#include "swfdec_stream_target.h"
+
+G_BEGIN_DECLS
+
+/* swfdec_stream.c */
+SwfdecBufferQueue * swfdec_stream_get_queue (SwfdecStream * stream);
+const char * swfdec_stream_describe (SwfdecStream * stream);
+void swfdec_stream_close (SwfdecStream * stream);
+void swfdec_stream_set_target (SwfdecStream * stream,
+ SwfdecStreamTarget * target);
+
+/* swfdec_loader.c */
+void swfdec_loader_set_data_type (SwfdecLoader * loader,
+ SwfdecLoaderDataType type);
+char * swfdec_loader_get_text (SwfdecLoader * loader,
+ guint version);
+
+/* swfdec_socket.c */
+void swfdec_socket_send (SwfdecSocket * sock,
+ SwfdecBuffer * buffer);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_loadvars_as.c b/swfdec/swfdec_loadvars_as.c
new file mode 100644
index 0000000..600dcb0
--- /dev/null
+++ b/swfdec/swfdec_loadvars_as.c
@@ -0,0 +1,46 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+
+#include "swfdec_debug.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_object.h"
+#include "swfdec_as_string.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_as_types.h"
+
+/*** AS CODE ***/
+
+SWFDEC_AS_NATIVE (301, 3, swfdec_loadvars_decode)
+void
+swfdec_loadvars_decode (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ if (argc < 1 || obj == NULL)
+ return;
+
+ swfdec_as_object_decode (obj, swfdec_as_value_to_string (cx, &argv[0]));
+}
diff --git a/swfdec/swfdec_local_connection.c b/swfdec/swfdec_local_connection.c
new file mode 100644
index 0000000..99d9d1d
--- /dev/null
+++ b/swfdec/swfdec_local_connection.c
@@ -0,0 +1,57 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (2200, 0, swfdec_local_connection_connect)
+void
+swfdec_local_connection_connect (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("LocalConnection.connect");
+}
+
+SWFDEC_AS_NATIVE (2200, 1, swfdec_local_connection_send)
+void
+swfdec_local_connection_send (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("LocalConnection.send");
+}
+
+SWFDEC_AS_NATIVE (2200, 2, swfdec_local_connection_close)
+void
+swfdec_local_connection_close (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("LocalConnection.close");
+}
+
+SWFDEC_AS_NATIVE (2200, 3, swfdec_local_connection_domain)
+void
+swfdec_local_connection_domain (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("LocalConnection.domain");
+}
diff --git a/swfdec/swfdec_marshal.list b/swfdec/swfdec_marshal.list
new file mode 100644
index 0000000..5aeeb44
--- /dev/null
+++ b/swfdec/swfdec_marshal.list
@@ -0,0 +1,6 @@
+BOOLEAN:DOUBLE,DOUBLE,INT
+BOOLEAN:UINT,UINT,BOOLEAN
+VOID:BOXED,POINTER,UINT
+VOID:ENUM,STRING,STRING,BOXED
+VOID:STRING,STRING
+VOID:ULONG,UINT
diff --git a/swfdec/swfdec_microphone.c b/swfdec/swfdec_microphone.c
new file mode 100644
index 0000000..fe31a2c
--- /dev/null
+++ b/swfdec/swfdec_microphone.c
@@ -0,0 +1,74 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (2104, 200, swfdec_microphone_get)
+void
+swfdec_microphone_get (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+ SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Microphone.get (static)");
+}
+
+SWFDEC_AS_NATIVE (2104, 201, swfdec_microphone_names_get)
+void
+swfdec_microphone_names_get (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Microphone.names (static, get)");
+}
+
+SWFDEC_AS_NATIVE (2104, 0, swfdec_microphone_setSilenceLevel)
+void
+swfdec_microphone_setSilenceLevel (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Microphone.setSilenceLevel");
+}
+
+SWFDEC_AS_NATIVE (2104, 1, swfdec_microphone_setRate)
+void
+swfdec_microphone_setRate (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Microphone.setRate");
+}
+
+SWFDEC_AS_NATIVE (2104, 2, swfdec_microphone_setGain)
+void
+swfdec_microphone_setGain (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Microphone.setGain");
+}
+
+SWFDEC_AS_NATIVE (2104, 3, swfdec_microphone_setUseEchoSuppression)
+void
+swfdec_microphone_setUseEchoSuppression (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Microphone.setUseEchoSuppression");
+}
diff --git a/swfdec/swfdec_morph_movie.c b/swfdec/swfdec_morph_movie.c
new file mode 100644
index 0000000..e53f881
--- /dev/null
+++ b/swfdec/swfdec_morph_movie.c
@@ -0,0 +1,133 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_morph_movie.h"
+#include "swfdec_debug.h"
+#include "swfdec_draw.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_stroke.h"
+
+G_DEFINE_TYPE (SwfdecMorphMovie, swfdec_morph_movie, SWFDEC_TYPE_MOVIE)
+
+static void
+swfdec_morph_movie_update_extents (SwfdecMovie *movie,
+ SwfdecRect *extents)
+{
+ guint ratio = movie->original_ratio;
+ SwfdecMorphMovie *mmovie = SWFDEC_MORPH_MOVIE (movie);
+ SwfdecMorphShape *morph = mmovie->morph;
+ SwfdecGraphic *graphic = SWFDEC_GRAPHIC (morph);
+ extents->x0 = ((65535 - ratio) * graphic->extents.x0 + ratio * morph->end_extents.x0) / 65535;
+ extents->x1 = ((65535 - ratio) * graphic->extents.x1 + ratio * morph->end_extents.x1) / 65535;
+ extents->y0 = ((65535 - ratio) * graphic->extents.y0 + ratio * morph->end_extents.y0) / 65535;
+ extents->y1 = ((65535 - ratio) * graphic->extents.y1 + ratio * morph->end_extents.y1) / 65535;
+}
+
+static void
+swfdec_morph_movie_set_ratio (SwfdecMovie *movie)
+{
+ SwfdecMorphMovie *mmovie = SWFDEC_MORPH_MOVIE (movie);
+
+ swfdec_movie_invalidate_next (movie);
+ g_slist_foreach (mmovie->draws, (GFunc) g_object_unref, NULL);
+ g_slist_free (mmovie->draws);
+ mmovie->draws = NULL;
+ swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_EXTENTS);
+}
+
+static void
+swfdec_morph_movie_create_morphs (SwfdecMorphMovie *mmovie)
+{
+ SwfdecShape *shape = SWFDEC_SHAPE (mmovie->morph);
+ guint ratio = SWFDEC_MOVIE (mmovie)->original_ratio;
+ GSList *walk;
+
+ for (walk = shape->draws; walk; walk = walk->next) {
+ mmovie->draws = g_slist_prepend (mmovie->draws, swfdec_draw_morph (walk->data, ratio));
+ }
+ mmovie->draws = g_slist_reverse (mmovie->draws);
+}
+
+static void
+swfdec_morph_movie_render (SwfdecMovie *movie, cairo_t *cr,
+ const SwfdecColorTransform *trans, const SwfdecRect *inval)
+{
+ SwfdecMorphMovie *morph = SWFDEC_MORPH_MOVIE (movie);
+ GSList *walk;
+
+ if (morph->draws == NULL)
+ swfdec_morph_movie_create_morphs (morph);
+
+ for (walk = morph->draws; walk; walk = walk->next) {
+ SwfdecDraw *draw = walk->data;
+
+ if (!swfdec_rect_intersect (NULL, &draw->extents, inval))
+ continue;
+
+ swfdec_draw_paint (draw, cr, trans);
+ }
+}
+
+static void
+swfdec_morph_movie_invalidate (SwfdecMovie *movie, const cairo_matrix_t *matrix, gboolean last)
+{
+ SwfdecRect rect;
+
+ swfdec_rect_transform (&rect, &movie->original_extents, matrix);
+ swfdec_player_invalidate (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), &rect);
+}
+
+static void
+swfdec_morph_movie_dispose (GObject *object)
+{
+ SwfdecMorphMovie *morph = SWFDEC_MORPH_MOVIE (object);
+
+ g_slist_foreach (morph->draws, (GFunc) g_object_unref, NULL);
+ g_slist_free (morph->draws);
+ morph->draws = NULL;
+ g_object_unref (morph->morph);
+
+ G_OBJECT_CLASS (swfdec_morph_movie_parent_class)->dispose (object);
+}
+
+static void
+swfdec_morph_movie_class_init (SwfdecMorphMovieClass * g_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+ SwfdecMovieClass *movie_class = SWFDEC_MOVIE_CLASS (g_class);
+
+ object_class->dispose = swfdec_morph_movie_dispose;
+
+ movie_class->update_extents = swfdec_morph_movie_update_extents;
+ movie_class->render = swfdec_morph_movie_render;
+ movie_class->invalidate = swfdec_morph_movie_invalidate;
+ movie_class->set_ratio = swfdec_morph_movie_set_ratio;
+ /* FIXME */
+ //movie_class->handle_mouse = swfdec_morph_movie_handle_mouse;
+}
+
+static void
+swfdec_morph_movie_init (SwfdecMorphMovie *morph)
+{
+}
+
diff --git a/swfdec/swfdec_morph_movie.h b/swfdec/swfdec_morph_movie.h
new file mode 100644
index 0000000..c8dd6cc
--- /dev/null
+++ b/swfdec/swfdec_morph_movie.h
@@ -0,0 +1,54 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_MORPH_MOVIE_H_
+#define _SWFDEC_MORPH_MOVIE_H_
+
+#include <glib-object.h>
+#include <libswfdec/swfdec_movie.h>
+#include <libswfdec/swfdec_morphshape.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _SwfdecMorphMovie SwfdecMorphMovie;
+typedef struct _SwfdecMorphMovieClass SwfdecMorphMovieClass;
+
+#define SWFDEC_TYPE_MORPH_MOVIE (swfdec_morph_movie_get_type())
+#define SWFDEC_IS_MORPH_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_MORPH_MOVIE))
+#define SWFDEC_IS_MORPH_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_MORPH_MOVIE))
+#define SWFDEC_MORPH_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_MORPH_MOVIE, SwfdecMorphMovie))
+#define SWFDEC_MORPH_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_MORPH_MOVIE, SwfdecMorphMovieClass))
+
+struct _SwfdecMorphMovie {
+ SwfdecMovie movie;
+
+ SwfdecMorphShape * morph;
+ GSList * draws; /* drawing operations to use or NULL if not yet created */
+};
+
+struct _SwfdecMorphMovieClass {
+ SwfdecMovieClass movie_class;
+};
+
+GType swfdec_morph_movie_get_type (void);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_morphshape.c b/swfdec/swfdec_morphshape.c
new file mode 100644
index 0000000..5252804
--- /dev/null
+++ b/swfdec/swfdec_morphshape.c
@@ -0,0 +1,96 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_morphshape.h"
+#include "swfdec_debug.h"
+#include "swfdec_image.h"
+#include "swfdec_morph_movie.h"
+#include "swfdec_shape_parser.h"
+
+G_DEFINE_TYPE (SwfdecMorphShape, swfdec_morph_shape, SWFDEC_TYPE_SHAPE)
+
+static SwfdecMovie *
+swfdec_graphic_create_movie (SwfdecGraphic *graphic, gsize *size)
+{
+ SwfdecMorphShape *morph = SWFDEC_MORPH_SHAPE (graphic);
+ SwfdecMorphMovie *movie = g_object_new (SWFDEC_TYPE_MORPH_MOVIE, NULL);
+
+ movie->morph = morph;
+ g_object_ref (morph);
+
+ *size = sizeof (SwfdecMorphMovie);
+
+ return SWFDEC_MOVIE (movie);
+}
+
+static void
+swfdec_morph_shape_class_init (SwfdecMorphShapeClass * g_class)
+{
+ SwfdecGraphicClass *graphic_class = SWFDEC_GRAPHIC_CLASS (g_class);
+
+ graphic_class->create_movie = swfdec_graphic_create_movie;
+}
+
+static void
+swfdec_morph_shape_init (SwfdecMorphShape * morph)
+{
+}
+
+
+int
+tag_define_morph_shape (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecShapeParser *parser;
+ SwfdecBits bits2;
+ SwfdecBits *bits = &s->b;
+ SwfdecMorphShape *morph;
+ guint offset;
+ int id;
+
+ id = swfdec_bits_get_u16 (bits);
+
+ morph = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_MORPH_SHAPE);
+ if (!morph)
+ return SWFDEC_STATUS_OK;
+
+ SWFDEC_INFO ("id=%d", id);
+
+ swfdec_bits_get_rect (bits, &SWFDEC_GRAPHIC (morph)->extents);
+ swfdec_bits_get_rect (bits, &morph->end_extents);
+ offset = swfdec_bits_get_u32 (bits);
+ swfdec_bits_init_bits (&bits2, bits, offset);
+
+ parser = swfdec_shape_parser_new ((SwfdecParseDrawFunc) swfdec_pattern_parse_morph,
+ (SwfdecParseDrawFunc) swfdec_stroke_parse_morph, s);
+ swfdec_shape_parser_parse_morph (parser, &bits2, bits);
+ SWFDEC_SHAPE (morph)->draws = swfdec_shape_parser_free (parser);
+
+ if (swfdec_bits_left (&bits2)) {
+ SWFDEC_WARNING ("early finish when parsing start shapes: %u bytes",
+ swfdec_bits_left (&bits2));
+ }
+
+ return SWFDEC_STATUS_OK;
+}
diff --git a/swfdec/swfdec_morphshape.h b/swfdec/swfdec_morphshape.h
new file mode 100644
index 0000000..e460109
--- /dev/null
+++ b/swfdec/swfdec_morphshape.h
@@ -0,0 +1,53 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_MORPH_SHAPE_H_
+#define _SWFDEC_MORPH_SHAPE_H_
+
+#include <libswfdec/swfdec_shape.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecMorphShape SwfdecMorphShape;
+typedef struct _SwfdecMorphShapeClass SwfdecMorphShapeClass;
+
+#define SWFDEC_TYPE_MORPH_SHAPE (swfdec_morph_shape_get_type())
+#define SWFDEC_IS_MORPH_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_MORPH_SHAPE))
+#define SWFDEC_IS_MORPH_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_MORPH_SHAPE))
+#define SWFDEC_MORPH_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_MORPH_SHAPE, SwfdecMorphShape))
+#define SWFDEC_MORPH_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_MORPH_SHAPE, SwfdecMorphShapeClass))
+
+struct _SwfdecMorphShape {
+ SwfdecShape shape;
+
+ SwfdecRect end_extents; /* extents at end of morph (compare with graphic->extents for start) */
+};
+
+struct _SwfdecMorphShapeClass {
+ SwfdecShapeClass shape_class;
+};
+
+GType swfdec_morph_shape_get_type (void);
+
+int tag_define_morph_shape (SwfdecSwfDecoder * s,
+ guint tag);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_mouse_as.c b/swfdec/swfdec_mouse_as.c
new file mode 100644
index 0000000..88ee046
--- /dev/null
+++ b/swfdec/swfdec_mouse_as.c
@@ -0,0 +1,51 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_as_object.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_player_internal.h"
+
+SWFDEC_AS_NATIVE (5, 0, swfdec_mouse_show)
+void
+swfdec_mouse_show (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+
+ SWFDEC_AS_VALUE_SET_INT (retval, player->priv->mouse_visible ? 1 : 0);
+ player->priv->mouse_visible = TRUE;
+}
+
+SWFDEC_AS_NATIVE (5, 1, swfdec_mouse_hide)
+void
+swfdec_mouse_hide (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+
+ SWFDEC_AS_VALUE_SET_INT (retval, player->priv->mouse_visible ? 1 : 0);
+ player->priv->mouse_visible = FALSE;
+}
+
diff --git a/swfdec/swfdec_movie.c b/swfdec/swfdec_movie.c
new file mode 100644
index 0000000..278a067
--- /dev/null
+++ b/swfdec/swfdec_movie.c
@@ -0,0 +1,1815 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <errno.h>
+
+#include "swfdec_movie.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_button_movie.h"
+#include "swfdec_debug.h"
+#include "swfdec_draw.h"
+#include "swfdec_event.h"
+#include "swfdec_graphic.h"
+#include "swfdec_image.h"
+#include "swfdec_loader_internal.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_sprite.h"
+#include "swfdec_sprite_movie.h"
+#include "swfdec_resource.h"
+#include "swfdec_system.h"
+#include "swfdec_utils.h"
+#include "swfdec_as_internal.h"
+
+/*** MOVIE ***/
+
+enum {
+ PROP_0,
+ PROP_DEPTH
+};
+
+G_DEFINE_ABSTRACT_TYPE (SwfdecMovie, swfdec_movie, SWFDEC_TYPE_AS_OBJECT)
+
+static void
+swfdec_movie_init (SwfdecMovie * movie)
+{
+ movie->blend_mode = 1;
+
+ movie->xscale = 100;
+ movie->yscale = 100;
+ cairo_matrix_init_identity (&movie->original_transform);
+ cairo_matrix_init_identity (&movie->matrix);
+ cairo_matrix_init_identity (&movie->inverse_matrix);
+
+ swfdec_color_transform_init_identity (&movie->color_transform);
+ swfdec_color_transform_init_identity (&movie->original_ctrans);
+
+ movie->visible = TRUE;
+ movie->cache_state = SWFDEC_MOVIE_INVALID_EXTENTS;
+ movie->invalidate_last = TRUE;
+ movie->invalidate_next = TRUE;
+
+ swfdec_rect_init_empty (&movie->extents);
+}
+
+/**
+ * swfdec_movie_invalidate:
+ * @movie: a #SwfdecMovie
+ * @parent_to_global: This is the matrix from the parent to the global matrix.
+ * It is only used for caching reasons
+ * @new_contents: %TRUE if this is the invalidation of the new contents, %FALSE
+ * if the old contents are invalidated.
+ *
+ * Performs an instant invalidation on @movie. You most likely don't want to
+ * call this function directly, but use swfdec_movie_invalidate_last_last() or
+ * swfdec_movie_invalidate_next() instead.
+ **/
+void
+swfdec_movie_invalidate (SwfdecMovie *movie, const cairo_matrix_t *parent_to_global,
+ gboolean new_contents)
+{
+ SwfdecMovieClass *klass;
+ cairo_matrix_t matrix;
+
+ if (new_contents) {
+ movie->invalidate_next = FALSE;
+ } else {
+ if (movie->invalidate_last)
+ return;
+ movie->invalidate_last = TRUE;
+ }
+ g_assert (movie->cache_state <= SWFDEC_MOVIE_INVALID_CHILDREN);
+ SWFDEC_LOG ("invalidating %s %s at %s", G_OBJECT_TYPE_NAME (movie),
+ movie->name, new_contents ? "end" : "start");
+ cairo_matrix_multiply (&matrix, &movie->matrix, parent_to_global);
+ klass = SWFDEC_MOVIE_GET_CLASS (movie);
+ klass->invalidate (movie, &matrix, new_contents);
+}
+
+/**
+ * swfdec_movie_invalidate_last:
+ * @movie: a #SwfdecMovie
+ *
+ * Ensures the movie's contents are invalidated. This function must be called
+ * before changing the movie or the output will have artifacts.
+ **/
+void
+swfdec_movie_invalidate_last (SwfdecMovie *movie)
+{
+ cairo_matrix_t matrix;
+
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+
+ if (movie->invalidate_last)
+ return;
+
+ if (movie->parent)
+ swfdec_movie_local_to_global_matrix (movie->parent, &matrix);
+ else
+ cairo_matrix_init_identity (&matrix);
+ swfdec_movie_invalidate (movie, &matrix, FALSE);
+ g_assert (movie->invalidate_last);
+}
+
+/**
+ * swfdec_movie_invalidate_last_next:
+ * @movie: a #SwfdecMovie
+ *
+ * Ensures the movie will be invalidated after script execution is done. So
+ * after calling this function you can modify position and contents of the
+ * @movie in any way.
+ **/
+void
+swfdec_movie_invalidate_next (SwfdecMovie *movie)
+{
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+
+ swfdec_movie_invalidate_last (movie);
+ movie->invalidate_next = TRUE;
+}
+
+/**
+ * swfdec_movie_queue_update:
+ * @movie: a #SwfdecMovie
+ * @state: how much needs to be updated
+ *
+ * Queues an update of all cached values inside @movie and invalidates it.
+ **/
+void
+swfdec_movie_queue_update (SwfdecMovie *movie, SwfdecMovieCacheState state)
+{
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+
+ if (state > SWFDEC_MOVIE_INVALID_EXTENTS) {
+ swfdec_movie_invalidate_next (movie);
+ }
+ while (movie && movie->cache_state < state) {
+ movie->cache_state = state;
+ movie = movie->parent;
+ state = SWFDEC_MOVIE_INVALID_CHILDREN;
+ }
+}
+
+static void
+swfdec_movie_update_extents (SwfdecMovie *movie)
+{
+ SwfdecMovieClass *klass;
+ GList *walk;
+ SwfdecRect *rect = &movie->original_extents;
+ SwfdecRect *extents = &movie->extents;
+
+ *rect = movie->draw_extents;
+ if (movie->image) {
+ SwfdecRect image_extents = { 0, 0,
+ movie->image->width * SWFDEC_TWIPS_SCALE_FACTOR,
+ movie->image->height * SWFDEC_TWIPS_SCALE_FACTOR };
+ swfdec_rect_union (rect, rect, &image_extents);
+ }
+ for (walk = movie->list; walk; walk = walk->next) {
+ swfdec_rect_union (rect, rect, &SWFDEC_MOVIE (walk->data)->extents);
+ }
+ klass = SWFDEC_MOVIE_GET_CLASS (movie);
+ if (klass->update_extents)
+ klass->update_extents (movie, rect);
+ if (swfdec_rect_is_empty (rect)) {
+ *extents = *rect;
+ return;
+ }
+ swfdec_rect_transform (extents, rect, &movie->matrix);
+ if (movie->parent && movie->parent->cache_state < SWFDEC_MOVIE_INVALID_EXTENTS) {
+ /* no need to invalidate here */
+ movie->parent->cache_state = SWFDEC_MOVIE_INVALID_EXTENTS;
+ }
+}
+
+static void
+swfdec_movie_update_matrix (SwfdecMovie *movie)
+{
+ double d, e;
+
+ /* we operate on x0 and y0 when setting movie._x and movie._y */
+ if (movie->modified) {
+ movie->matrix.xx = movie->original_transform.xx;
+ movie->matrix.yx = movie->original_transform.yx;
+ movie->matrix.xy = movie->original_transform.xy;
+ movie->matrix.yy = movie->original_transform.yy;
+ } else {
+ movie->matrix = movie->original_transform;
+ }
+
+ d = movie->xscale / swfdec_matrix_get_xscale (&movie->original_transform);
+ e = movie->yscale / swfdec_matrix_get_yscale (&movie->original_transform);
+ cairo_matrix_scale (&movie->matrix, d, e);
+ if (isfinite (movie->rotation)) {
+ d = movie->rotation - swfdec_matrix_get_rotation (&movie->original_transform);
+ cairo_matrix_rotate (&movie->matrix, d * G_PI / 180);
+ }
+ swfdec_matrix_ensure_invertible (&movie->matrix, &movie->inverse_matrix);
+}
+
+static void
+swfdec_movie_do_update (SwfdecMovie *movie)
+{
+ GList *walk;
+
+ for (walk = movie->list; walk; walk = walk->next) {
+ SwfdecMovie *child = walk->data;
+
+ if (child->cache_state != SWFDEC_MOVIE_UP_TO_DATE)
+ swfdec_movie_do_update (child);
+ }
+
+ switch (movie->cache_state) {
+ case SWFDEC_MOVIE_INVALID_MATRIX:
+ swfdec_movie_update_matrix (movie);
+ /* fall through */
+ case SWFDEC_MOVIE_INVALID_EXTENTS:
+ swfdec_movie_update_extents (movie);
+ /* fall through */
+ case SWFDEC_MOVIE_INVALID_CHILDREN:
+ break;
+ case SWFDEC_MOVIE_UP_TO_DATE:
+ default:
+ g_assert_not_reached ();
+ }
+ movie->cache_state = SWFDEC_MOVIE_UP_TO_DATE;
+}
+
+/**
+ * swfdec_movie_update:
+ * @movie: a #SwfdecMovie
+ *
+ * Brings the cached values of @movie up-to-date if they are not. This includes
+ * transformation matrices and extents. It needs to be called before accessing
+ * the relevant values.
+ **/
+void
+swfdec_movie_update (SwfdecMovie *movie)
+{
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+
+ if (movie->cache_state == SWFDEC_MOVIE_UP_TO_DATE)
+ return;
+
+ if (movie->parent && movie->parent->cache_state != SWFDEC_MOVIE_UP_TO_DATE) {
+ swfdec_movie_update (movie->parent);
+ } else {
+ swfdec_movie_do_update (movie);
+ }
+}
+
+SwfdecMovie *
+swfdec_movie_find (SwfdecMovie *movie, int depth)
+{
+ GList *walk;
+
+ g_return_val_if_fail (SWFDEC_IS_MOVIE (movie), NULL);
+
+ for (walk = movie->list; walk; walk = walk->next) {
+ SwfdecMovie *cur= walk->data;
+
+ if (cur->depth < depth)
+ continue;
+ if (cur->depth == depth)
+ return cur;
+ break;
+ }
+ return NULL;
+}
+
+static gboolean
+swfdec_movie_do_remove (SwfdecMovie *movie, gboolean destroy)
+{
+ SwfdecPlayerPrivate *priv;
+ SwfdecPlayer *player;
+
+ SWFDEC_LOG ("removing %s %s", G_OBJECT_TYPE_NAME (movie), movie->name);
+
+ player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
+ while (movie->list) {
+ GList *walk = movie->list;
+ while (walk && SWFDEC_MOVIE (walk->data)->state >= SWFDEC_MOVIE_STATE_REMOVED)
+ walk = walk->next;
+ if (walk == NULL)
+ break;
+ destroy &= swfdec_movie_do_remove (walk->data, destroy);
+ }
+ /* FIXME: all of this here or in destroy callback? */
+ priv = player->priv;
+ if (priv->mouse_grab == movie)
+ priv->mouse_grab = NULL;
+ if (priv->mouse_drag == movie)
+ priv->mouse_drag = NULL;
+ swfdec_movie_invalidate_last (movie);
+ movie->state = SWFDEC_MOVIE_STATE_REMOVED;
+
+ if ((movie->events &&
+ swfdec_event_list_has_conditions (movie->events, SWFDEC_AS_OBJECT (movie), SWFDEC_EVENT_UNLOAD, 0)) ||
+ swfdec_as_object_has_variable (SWFDEC_AS_OBJECT (movie), SWFDEC_AS_STR_onUnload)) {
+ swfdec_movie_queue_script (movie, SWFDEC_EVENT_UNLOAD);
+ destroy = FALSE;
+ }
+ if (destroy)
+ swfdec_movie_destroy (movie);
+ return destroy;
+}
+
+/**
+ * swfdec_movie_remove:
+ * @movie: #SwfdecMovie to remove
+ *
+ * Removes this movie from its parent. In contrast to swfdec_movie_destroy (),
+ * it will definitely cause a removal from the display list, but depending on
+ * movie, it might still be possible to reference it from Actionscript.
+ **/
+void
+swfdec_movie_remove (SwfdecMovie *movie)
+{
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+
+ if (movie->state > SWFDEC_MOVIE_STATE_RUNNING)
+ return;
+ if (swfdec_movie_do_remove (movie, TRUE))
+ return;
+
+ swfdec_movie_set_depth (movie, -32769 - movie->depth); /* don't ask me why... */
+}
+
+/**
+ * swfdec_movie_destroy:
+ * @movie: #SwfdecMovie to destroy
+ *
+ * Removes this movie from its parent. After this it will no longer be present,
+ * neither visually nor via ActionScript. This function will not cause an
+ * unload event. Compare with swfdec_movie_remove ().
+ **/
+void
+swfdec_movie_destroy (SwfdecMovie *movie)
+{
+ SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (movie);
+ SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
+
+ g_assert (movie->state < SWFDEC_MOVIE_STATE_DESTROYED);
+ SWFDEC_LOG ("destroying movie %s", movie->name);
+ while (movie->list) {
+ swfdec_movie_destroy (movie->list->data);
+ }
+ if (movie->parent) {
+ movie->parent->list = g_list_remove (movie->parent->list, movie);
+ } else {
+ player->priv->roots = g_list_remove (player->priv->roots, movie);
+ }
+ /* unset masks */
+ if (movie->masked_by)
+ movie->masked_by->mask_of = NULL;
+ if (movie->mask_of)
+ movie->mask_of->masked_by = NULL;
+ movie->masked_by = NULL;
+ movie->mask_of = NULL;
+ /* FIXME: figure out how to handle destruction pre-init/construct.
+ * This is just a stop-gap measure to avoid dead movies in those queues */
+ swfdec_player_remove_all_actions (player, movie);
+ if (klass->finish_movie)
+ klass->finish_movie (movie);
+ player->priv->movies = g_list_remove (player->priv->movies, movie);
+ movie->state = SWFDEC_MOVIE_STATE_DESTROYED;
+ /* unset prototype here, so we don't work in AS anymore */
+ SWFDEC_AS_OBJECT (movie)->prototype = NULL;
+ g_object_unref (movie);
+}
+
+static void
+swfdec_movie_set_constructor (SwfdecSpriteMovie *movie)
+{
+ SwfdecMovie *mov = SWFDEC_MOVIE (movie);
+ SwfdecAsContext *context = SWFDEC_AS_OBJECT (movie)->context;
+ SwfdecAsObject *constructor = NULL;
+
+ g_assert (mov->resource != NULL);
+
+ if (movie->sprite) {
+ const char *name;
+
+ name = swfdec_resource_get_export_name (mov->resource,
+ SWFDEC_CHARACTER (movie->sprite));
+ if (name != NULL) {
+ name = swfdec_as_context_get_string (context, name);
+ constructor = swfdec_player_get_export_class (SWFDEC_PLAYER (context),
+ name);
+ }
+ }
+ if (constructor == NULL)
+ constructor = mov->resource->sandbox->MovieClip;
+
+ swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (movie), constructor);
+}
+
+/**
+ * swfdec_movie_resolve:
+ * @movie: movie to resolve
+ *
+ * Resolves a movie clip to its real version. Since movie clips can be
+ * explicitly destroyed, they have problems with references to them. In the
+ * case of destruction, these references will remain as "dangling pointers".
+ * However, if a movie with the same name is later created again, the reference
+ * will point to that movie. This function does this resolving.
+ *
+ * Returns: The movie clip @movie resolves to or %NULL if none.
+ **/
+SwfdecMovie *
+swfdec_movie_resolve (SwfdecMovie *movie)
+{
+ g_return_val_if_fail (SWFDEC_IS_MOVIE (movie), NULL);
+
+ if (movie->state != SWFDEC_MOVIE_STATE_DESTROYED)
+ return movie;
+ if (movie->parent == NULL) {
+ SWFDEC_FIXME ("figure out how to resolve root movies");
+ return NULL;
+ }
+ /* FIXME: include unnamed ones? */
+ return swfdec_movie_get_by_name (movie->parent, movie->original_name, FALSE);
+}
+
+guint
+swfdec_movie_get_version (SwfdecMovie *movie)
+{
+ return movie->resource->version;
+}
+
+void
+swfdec_movie_execute (SwfdecMovie *movie, SwfdecEventType condition)
+{
+ SwfdecAsObject *thisp;
+ const char *name;
+
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+
+ if (SWFDEC_IS_BUTTON_MOVIE (movie)) {
+ /* these conditions don't exist for buttons */
+ if (condition == SWFDEC_EVENT_CONSTRUCT || condition < SWFDEC_EVENT_PRESS)
+ return;
+ thisp = SWFDEC_AS_OBJECT (movie->parent);
+ if (swfdec_movie_get_version (movie) <= 5) {
+ while (!SWFDEC_IS_SPRITE_MOVIE (thisp))
+ thisp = SWFDEC_AS_OBJECT (SWFDEC_MOVIE (thisp)->parent);
+ }
+ g_assert (thisp);
+ } else {
+ thisp = SWFDEC_AS_OBJECT (movie);
+ }
+
+ /* special cases */
+ if (condition == SWFDEC_EVENT_CONSTRUCT) {
+ if (swfdec_movie_get_version (movie) <= 5)
+ return;
+ swfdec_movie_set_constructor (SWFDEC_SPRITE_MOVIE (movie));
+ } else if (condition == SWFDEC_EVENT_ENTER) {
+ if (movie->state >= SWFDEC_MOVIE_STATE_REMOVED)
+ return;
+ }
+
+ swfdec_sandbox_use (movie->resource->sandbox);
+ if (movie->events) {
+ swfdec_event_list_execute (movie->events, thisp, condition, 0);
+ }
+ /* FIXME: how do we compute the version correctly here? */
+ if (swfdec_movie_get_version (movie) > 5) {
+ name = swfdec_event_type_get_name (condition);
+ if (name != NULL) {
+ swfdec_as_object_call (SWFDEC_AS_OBJECT (movie), name, 0, NULL, NULL);
+ }
+ if (condition == SWFDEC_EVENT_CONSTRUCT)
+ swfdec_as_object_call (thisp, SWFDEC_AS_STR_constructor, 0, NULL, NULL);
+ }
+ swfdec_sandbox_unuse (movie->resource->sandbox);
+}
+
+/**
+ * swfdec_movie_queue_script:
+ * @movie: a #SwfdecMovie
+ * @condition: the event that should happen
+ *
+ * Queues execution of all scripts associated with the given event.
+ **/
+void
+swfdec_movie_queue_script (SwfdecMovie *movie, SwfdecEventType condition)
+{
+ SwfdecPlayer *player;
+ guint importance;
+
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+
+ if (!SWFDEC_IS_SPRITE_MOVIE (movie) && !SWFDEC_IS_BUTTON_MOVIE (movie))
+ return;
+
+ switch (condition) {
+ case SWFDEC_EVENT_INITIALIZE:
+ importance = 0;
+ break;
+ case SWFDEC_EVENT_CONSTRUCT:
+ importance = 1;
+ break;
+ case SWFDEC_EVENT_LOAD:
+ case SWFDEC_EVENT_ENTER:
+ case SWFDEC_EVENT_UNLOAD:
+ case SWFDEC_EVENT_MOUSE_MOVE:
+ case SWFDEC_EVENT_MOUSE_DOWN:
+ case SWFDEC_EVENT_MOUSE_UP:
+ case SWFDEC_EVENT_KEY_UP:
+ case SWFDEC_EVENT_KEY_DOWN:
+ case SWFDEC_EVENT_DATA:
+ case SWFDEC_EVENT_PRESS:
+ case SWFDEC_EVENT_RELEASE:
+ case SWFDEC_EVENT_RELEASE_OUTSIDE:
+ case SWFDEC_EVENT_ROLL_OVER:
+ case SWFDEC_EVENT_ROLL_OUT:
+ case SWFDEC_EVENT_DRAG_OVER:
+ case SWFDEC_EVENT_DRAG_OUT:
+ case SWFDEC_EVENT_KEY_PRESS:
+ importance = 2;
+ break;
+ default:
+ g_return_if_reached ();
+ }
+
+ player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
+ swfdec_player_add_action (player, movie, condition, importance);
+}
+
+void
+swfdec_movie_local_to_global (SwfdecMovie *movie, double *x, double *y)
+{
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+ g_return_if_fail (x != NULL);
+ g_return_if_fail (y != NULL);
+
+ do {
+ cairo_matrix_transform_point (&movie->matrix, x, y);
+ } while ((movie = movie->parent));
+}
+
+void
+swfdec_movie_rect_local_to_global (SwfdecMovie *movie, SwfdecRect *rect)
+{
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+ g_return_if_fail (rect != NULL);
+
+ swfdec_movie_local_to_global (movie, &rect->x0, &rect->y0);
+ swfdec_movie_local_to_global (movie, &rect->x1, &rect->y1);
+ if (rect->x0 > rect->x1) {
+ double tmp = rect->x1;
+ rect->x1 = rect->x0;
+ rect->x0 = tmp;
+ }
+ if (rect->y0 > rect->y1) {
+ double tmp = rect->y1;
+ rect->y1 = rect->y0;
+ rect->y0 = tmp;
+ }
+}
+
+void
+swfdec_movie_global_to_local_matrix (SwfdecMovie *movie, cairo_matrix_t *matrix)
+{
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+ g_return_if_fail (matrix != NULL);
+
+ cairo_matrix_init_identity (matrix);
+ while (movie) {
+ if (movie->cache_state >= SWFDEC_MOVIE_INVALID_MATRIX)
+ swfdec_movie_update (movie);
+ cairo_matrix_multiply (matrix, &movie->inverse_matrix, matrix);
+ movie = movie->parent;
+ }
+}
+
+void
+swfdec_movie_local_to_global_matrix (SwfdecMovie *movie, cairo_matrix_t *matrix)
+{
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+ g_return_if_fail (matrix != NULL);
+
+ cairo_matrix_init_identity (matrix);
+ while (movie) {
+ if (movie->cache_state >= SWFDEC_MOVIE_INVALID_MATRIX)
+ swfdec_movie_update (movie);
+ cairo_matrix_multiply (matrix, matrix, &movie->matrix);
+ movie = movie->parent;
+ }
+}
+
+void
+swfdec_movie_global_to_local (SwfdecMovie *movie, double *x, double *y)
+{
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+ g_return_if_fail (x != NULL);
+ g_return_if_fail (y != NULL);
+
+ if (movie->parent) {
+ swfdec_movie_global_to_local (movie->parent, x, y);
+ }
+ if (movie->cache_state >= SWFDEC_MOVIE_INVALID_MATRIX)
+ swfdec_movie_update (movie);
+ cairo_matrix_transform_point (&movie->inverse_matrix, x, y);
+}
+
+void
+swfdec_movie_rect_global_to_local (SwfdecMovie *movie, SwfdecRect *rect)
+{
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+ g_return_if_fail (rect != NULL);
+
+ swfdec_movie_global_to_local (movie, &rect->x0, &rect->y0);
+ swfdec_movie_global_to_local (movie, &rect->x1, &rect->y1);
+ if (rect->x0 > rect->x1) {
+ double tmp = rect->x1;
+ rect->x1 = rect->x0;
+ rect->x0 = tmp;
+ }
+ if (rect->y0 > rect->y1) {
+ double tmp = rect->y1;
+ rect->y1 = rect->y0;
+ rect->y0 = tmp;
+ }
+}
+
+/**
+ * swfdec_movie_get_mouse:
+ * @movie: a #SwfdecMovie
+ * @x: pointer to hold result of X coordinate
+ * @y: pointer to hold result of y coordinate
+ *
+ * Gets the mouse coordinates in the coordinate space of @movie.
+ **/
+void
+swfdec_movie_get_mouse (SwfdecMovie *movie, double *x, double *y)
+{
+ SwfdecPlayer *player;
+
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+ g_return_if_fail (x != NULL);
+ g_return_if_fail (y != NULL);
+
+ player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
+ *x = player->priv->mouse_x;
+ *y = player->priv->mouse_y;
+ swfdec_player_stage_to_global (player, x, y);
+ swfdec_movie_global_to_local (movie, x, y);
+}
+
+/**
+ * swfdec_movie_get_mouse_events:
+ * @movie: a #SwfdecMovie
+ *
+ * Checks if this movie should respond to mouse events.
+ *
+ * Returns: %TRUE if this movie can receive mouse events
+ **/
+gboolean
+swfdec_movie_get_mouse_events (SwfdecMovie *movie)
+{
+ SwfdecMovieClass *klass;
+
+ g_return_val_if_fail (SWFDEC_IS_MOVIE (movie), FALSE);
+
+ klass = SWFDEC_MOVIE_GET_CLASS (movie);
+ if (klass->mouse_events)
+ return klass->mouse_events (movie);
+ else
+ return FALSE;
+}
+
+/**
+ * swfdec_movie_get_movie_at:
+ * @movie: a #SwfdecMovie
+ * @x: x coordinate in parent's coordinate space
+ * @y: y coordinate in the parent's coordinate space
+ * @events: %TRUE to only prefer movies that receive events
+ *
+ * Gets the child at the given coordinates. The coordinates are in the
+ * coordinate system of @movie's parent (or the global coordinate system for
+ * root movies). The @events parameter determines if movies that don't receive
+ * events should be respected.
+ *
+ * Returns: the child of @movie at the given coordinates or %NULL if none
+ **/
+SwfdecMovie *
+swfdec_movie_get_movie_at (SwfdecMovie *movie, double x, double y, gboolean events)
+{
+ SwfdecMovie *ret;
+ SwfdecMovieClass *klass;
+
+ g_return_val_if_fail (SWFDEC_IS_MOVIE (movie), NULL);
+
+ SWFDEC_LOG ("%s %p getting mouse at: %g %g", G_OBJECT_TYPE_NAME (movie), movie, x, y);
+ if (!swfdec_rect_contains (&movie->extents, x, y)) {
+ return NULL;
+ }
+ cairo_matrix_transform_point (&movie->inverse_matrix, &x, &y);
+
+ klass = SWFDEC_MOVIE_GET_CLASS (movie);
+ g_return_val_if_fail (klass->contains, NULL);
+ ret = klass->contains (movie, x, y, events);
+
+ return ret;
+}
+
+static SwfdecMovie *
+swfdec_movie_do_contains (SwfdecMovie *movie, double x, double y, gboolean events)
+{
+ GList *walk;
+ GSList *walk2;
+ SwfdecMovie *ret, *got;
+
+ ret = NULL;
+ for (walk = movie->list; walk; walk = walk->next) {
+ SwfdecMovie *child = walk->data;
+
+ if (!child->visible) {
+ SWFDEC_LOG ("%s %s (depth %d) is invisible, ignoring", G_OBJECT_TYPE_NAME (movie), movie->name, movie->depth);
+ continue;
+ }
+ got = swfdec_movie_get_movie_at (child, x, y, events);
+ if (got != NULL) {
+ if (events) {
+ /* set the return value to the topmost movie */
+ if (swfdec_movie_get_mouse_events (got)) {
+ ret = got;
+ } else if (ret == NULL) {
+ ret = movie;
+ }
+ } else {
+ /* if thie is not a clipped movie, we've found something */
+ if (child->clip_depth == 0)
+ return movie;
+ }
+ } else {
+ if (child->clip_depth) {
+ /* skip obscured movies */
+ SwfdecMovie *tmp = walk->next ? walk->next->data : NULL;
+ while (tmp && tmp->depth <= child->clip_depth) {
+ walk = walk->next;
+ tmp = walk->next ? walk->next->data : NULL;
+ }
+ }
+ }
+ }
+ if (ret)
+ return ret;
+
+ for (walk2 = movie->draws; walk2; walk2 = walk2->next) {
+ SwfdecDraw *draw = walk2->data;
+
+ if (swfdec_draw_contains (draw, x, y))
+ return movie;
+ }
+
+ return NULL;
+}
+
+static gboolean
+swfdec_movie_needs_group (SwfdecMovie *movie)
+{
+ return (movie->blend_mode > 1);
+}
+
+static cairo_operator_t
+swfdec_movie_get_operator_for_blend_mode (guint blend_mode)
+{
+ switch (blend_mode) {
+ case SWFDEC_BLEND_MODE_NORMAL:
+ SWFDEC_ERROR ("shouldn't need to get operator without blend mode?!");
+ case SWFDEC_BLEND_MODE_LAYER:
+ return CAIRO_OPERATOR_OVER;
+ case SWFDEC_BLEND_MODE_ADD:
+ return CAIRO_OPERATOR_ADD;
+ case SWFDEC_BLEND_MODE_ALPHA:
+ return CAIRO_OPERATOR_DEST_IN;
+ case SWFDEC_BLEND_MODE_ERASE:
+ return CAIRO_OPERATOR_DEST_OUT;
+ case SWFDEC_BLEND_MODE_MULTIPLY:
+ case SWFDEC_BLEND_MODE_SCREEN:
+ case SWFDEC_BLEND_MODE_LIGHTEN:
+ case SWFDEC_BLEND_MODE_DARKEN:
+ case SWFDEC_BLEND_MODE_DIFFERENCE:
+ case SWFDEC_BLEND_MODE_SUBTRACT:
+ case SWFDEC_BLEND_MODE_INVERT:
+ case SWFDEC_BLEND_MODE_OVERLAY:
+ case SWFDEC_BLEND_MODE_HARDLIGHT:
+ SWFDEC_WARNING ("blend mode %u unimplemented in cairo", blend_mode);
+ return CAIRO_OPERATOR_OVER;
+ default:
+ SWFDEC_WARNING ("invalid blend mode %u", blend_mode);
+ return CAIRO_OPERATOR_OVER;
+ }
+}
+
+/**
+ * swfdec_movie_mask:
+ * @movie: The movie to act as the mask
+ * @cr: a cairo context which should be used for masking. The cairo context's
+ * matrix is assumed to be in the coordinate system of the movie's parent.
+ * @inval: The region that is relevant for masking
+ *
+ * Creates a pattern suitable for masking. To do rendering using the returned
+ * mask, you want to use code like this:
+ * <informalexample><programlisting>
+ * mask = swfdec_movie_mask (cr, movie, inval);
+ * cairo_push_group (cr);
+ * // do rendering here
+ * cairo_pop_group_to_source (cr);
+ * cairo_mask (cr, mask);
+ * cairo_pattern_destroy (mask);
+ * </programlisting></informalexample>
+ *
+ * Returns: A new cairo_patten_t to be used as the mask.
+ **/
+cairo_pattern_t *
+swfdec_movie_mask (cairo_t *cr, SwfdecMovie *movie, const SwfdecRect *inval)
+{
+ SwfdecColorTransform black;
+
+ swfdec_color_transform_init_mask (&black);
+ cairo_push_group_with_content (cr, CAIRO_CONTENT_ALPHA);
+ swfdec_movie_render (movie, cr, &black, inval);
+ return cairo_pop_group (cr);
+}
+
+void
+swfdec_movie_render (SwfdecMovie *movie, cairo_t *cr,
+ const SwfdecColorTransform *color_transform, const SwfdecRect *inval)
+{
+ SwfdecMovieClass *klass;
+ SwfdecColorTransform trans;
+ SwfdecRect rect;
+ gboolean group;
+
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+ g_return_if_fail (cr != NULL);
+ if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
+ g_warning ("%s", cairo_status_to_string (cairo_status (cr)));
+ }
+ g_return_if_fail (color_transform != NULL);
+ g_return_if_fail (inval != NULL);
+
+ if (movie->mask_of != NULL && !swfdec_color_transform_is_mask (color_transform)) {
+ SWFDEC_LOG ("not rendering %s %p, movie is a mask",
+ G_OBJECT_TYPE_NAME (movie), movie->name);
+ return;
+ }
+ if (!swfdec_rect_intersect (NULL, &movie->extents, inval)) {
+ SWFDEC_LOG ("not rendering %s %s, extents %g %g %g %g are not in invalid area %g %g %g %g",
+ G_OBJECT_TYPE_NAME (movie), movie->name,
+ movie->extents.x0, movie->extents.y0, movie->extents.x1, movie->extents.y1,
+ inval->x0, inval->y0, inval->x1, inval->y1);
+ return;
+ }
+ if (!movie->visible) {
+ SWFDEC_LOG ("not rendering %s %p, movie is invisible",
+ G_OBJECT_TYPE_NAME (movie), movie->name);
+ return;
+ }
+
+ cairo_save (cr);
+ if (movie->masked_by != NULL) {
+ cairo_push_group (cr);
+ }
+ group = swfdec_movie_needs_group (movie);
+ if (group) {
+ SWFDEC_DEBUG ("pushing group for blend mode %u", movie->blend_mode);
+ cairo_push_group (cr);
+ }
+
+ SWFDEC_LOG ("transforming movie, transform: %g %g %g %g %g %g",
+ movie->matrix.xx, movie->matrix.yy,
+ movie->matrix.xy, movie->matrix.yx,
+ movie->matrix.x0, movie->matrix.y0);
+ cairo_transform (cr, &movie->matrix);
+ swfdec_rect_transform (&rect, inval, &movie->inverse_matrix);
+ SWFDEC_LOG ("%sinvalid area is now: %g %g %g %g", movie->parent ? " " : "",
+ rect.x0, rect.y0, rect.x1, rect.y1);
+ swfdec_color_transform_chain (&trans, &movie->original_ctrans, color_transform);
+ swfdec_color_transform_chain (&trans, &movie->color_transform, &trans);
+
+ klass = SWFDEC_MOVIE_GET_CLASS (movie);
+ g_return_if_fail (klass->render);
+ klass->render (movie, cr, &trans, &rect);
+#if 0
+ /* code to draw a red rectangle around the area occupied by this movie clip */
+ {
+ double x = 1.0, y = 0.0;
+ cairo_transform (cr, &movie->inverse_transform);
+ cairo_user_to_device_distance (cr, &x, &y);
+ cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
+ cairo_set_line_width (cr, 1 / sqrt (x * x + y * y));
+ cairo_rectangle (cr, object->extents.x0 + 10, object->extents.y0 + 10,
+ object->extents.x1 - object->extents.x0 - 20,
+ object->extents.y1 - object->extents.y0 - 20);
+ cairo_stroke (cr);
+ }
+#endif
+ if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
+ g_warning ("error rendering with cairo: %s", cairo_status_to_string (cairo_status (cr)));
+ }
+ if (group) {
+ cairo_pattern_t *pattern;
+
+ pattern = cairo_pop_group (cr);
+ cairo_set_source (cr, pattern);
+ cairo_set_operator (cr, swfdec_movie_get_operator_for_blend_mode (movie->blend_mode));
+ cairo_paint (cr);
+ cairo_pattern_destroy (pattern);
+ }
+ if (movie->masked_by) {
+ cairo_pattern_t *mask;
+ if (movie->parent == movie->masked_by->parent) {
+ cairo_transform (cr, &movie->inverse_matrix);
+ rect = *inval;
+ } else {
+ cairo_matrix_t mat, mat2;
+ swfdec_movie_local_to_global_matrix (movie, &mat);
+ swfdec_movie_global_to_local_matrix (movie->masked_by, &mat2);
+ cairo_matrix_multiply (&mat, &mat2, &mat);
+ cairo_transform (cr, &mat);
+ if (cairo_matrix_invert (&mat) == CAIRO_STATUS_SUCCESS && FALSE) {
+ swfdec_rect_transform (&rect, &rect, &mat);
+ } else {
+ SWFDEC_INFO ("non-invertible matrix when computing invalid area");
+ rect.x0 = rect.y0 = -G_MAXDOUBLE;
+ rect.x1 = rect.y1 = G_MAXDOUBLE;
+ }
+ }
+ mask = swfdec_movie_mask (cr, movie->masked_by, &rect);
+ cairo_pop_group_to_source (cr);
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_mask (cr, mask);
+ cairo_pattern_destroy (mask);
+ }
+ cairo_restore (cr);
+}
+
+static void
+swfdec_movie_get_property (GObject *object, guint param_id, GValue *value,
+ GParamSpec * pspec)
+{
+ SwfdecMovie *movie = SWFDEC_MOVIE (object);
+
+ switch (param_id) {
+ case PROP_DEPTH:
+ g_value_set_int (value, movie->depth);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+swfdec_movie_set_property (GObject *object, guint param_id, const GValue *value,
+ GParamSpec * pspec)
+{
+ SwfdecMovie *movie = SWFDEC_MOVIE (object);
+
+ switch (param_id) {
+ case PROP_DEPTH:
+ movie->depth = g_value_get_int (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+swfdec_movie_dispose (GObject *object)
+{
+ SwfdecMovie * movie = SWFDEC_MOVIE (object);
+ GSList *iter;
+
+ g_assert (movie->list == NULL);
+
+ SWFDEC_LOG ("disposing movie %s (depth %d)", movie->name, movie->depth);
+ if (movie->events) {
+ swfdec_event_list_free (movie->events);
+ movie->events = NULL;
+ }
+ if (movie->graphic) {
+ g_object_unref (movie->graphic);
+ movie->graphic = NULL;
+ }
+ for (iter = movie->variable_listeners; iter != NULL; iter = iter->next) {
+ g_free (iter->data);
+ }
+ g_slist_free (movie->variable_listeners);
+ movie->variable_listeners = NULL;
+
+ if (movie->image) {
+ g_object_unref (movie->image);
+ movie->image = NULL;
+ }
+ g_slist_foreach (movie->draws, (GFunc) g_object_unref, NULL);
+ g_slist_free (movie->draws);
+ movie->draws = NULL;
+
+ G_OBJECT_CLASS (swfdec_movie_parent_class)->dispose (G_OBJECT (movie));
+}
+
+static void
+swfdec_movie_mark (SwfdecAsObject *object)
+{
+ SwfdecMovie *movie = SWFDEC_MOVIE (object);
+ GList *walk;
+ GSList *iter;
+
+ if (movie->parent)
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (movie->parent));
+ swfdec_as_string_mark (movie->original_name);
+ swfdec_as_string_mark (movie->name);
+ for (walk = movie->list; walk; walk = walk->next) {
+ swfdec_as_object_mark (walk->data);
+ }
+ for (iter = movie->variable_listeners; iter != NULL; iter = iter->next) {
+ SwfdecMovieVariableListener *listener = iter->data;
+ swfdec_as_object_mark (listener->object);
+ swfdec_as_string_mark (listener->name);
+ }
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (movie->resource));
+
+ SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->mark (object);
+}
+
+/* FIXME: This function can definitely be implemented easier */
+SwfdecMovie *
+swfdec_movie_get_by_name (SwfdecMovie *movie, const char *name, gboolean unnamed)
+{
+ GList *walk;
+ int i;
+ gulong l;
+ guint version = SWFDEC_AS_OBJECT (movie)->context->version;
+ char *end;
+ SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
+
+ if ((version >= 7 && g_str_has_prefix (name, "_level")) ||
+ (version < 7 && strncasecmp (name, "_level", 6) == 0)) {
+ errno = 0;
+ l = strtoul (name + 6, &end, 10);
+ if (errno != 0 || *end != 0 || l > G_MAXINT)
+ return NULL;
+ i = l - 16384;
+ for (walk = player->priv->roots; walk; walk = walk->next) {
+ SwfdecMovie *cur = walk->data;
+ if (cur->depth < i)
+ continue;
+ if (cur->depth == i)
+ return cur;
+ break;
+ }
+ }
+
+ for (walk = movie->list; walk; walk = walk->next) {
+ SwfdecMovie *cur = walk->data;
+ if (cur->original_name == SWFDEC_AS_STR_EMPTY && !unnamed)
+ continue;
+ if (swfdec_strcmp (version, cur->name, name) == 0)
+ return cur;
+ }
+ return NULL;
+}
+
+SwfdecMovie *
+swfdec_movie_get_root (SwfdecMovie *movie)
+{
+ g_return_val_if_fail (SWFDEC_IS_MOVIE (movie), NULL);
+
+ while (movie->parent)
+ movie = movie->parent;
+
+ return movie;
+}
+
+static gboolean
+swfdec_movie_get_variable (SwfdecAsObject *object, SwfdecAsObject *orig,
+ const char *variable, SwfdecAsValue *val, guint *flags)
+{
+ SwfdecMovie *movie = SWFDEC_MOVIE (object);
+
+ movie = swfdec_movie_resolve (movie);
+ if (movie == NULL)
+ return FALSE;
+
+ if (SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->get (object, orig, variable, val, flags))
+ return TRUE;
+
+ if (swfdec_movie_get_asprop (movie, variable, val)) {
+ *flags = 0;
+ return TRUE;
+ }
+
+ /* FIXME: check that this is correct */
+ if (object->context->version > 5 && variable == SWFDEC_AS_STR__global) {
+ SWFDEC_AS_VALUE_SET_OBJECT (val, object->context->global);
+ *flags = 0;
+ return TRUE;
+ }
+
+ movie = swfdec_movie_get_by_name (movie, variable, FALSE);
+ if (movie) {
+ SWFDEC_AS_VALUE_SET_OBJECT (val, SWFDEC_AS_OBJECT (movie));
+ *flags = 0;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void
+swfdec_movie_add_variable_listener (SwfdecMovie *movie, SwfdecAsObject *object,
+ const char *name, const SwfdecMovieVariableListenerFunction function)
+{
+ SwfdecMovieVariableListener *listener;
+ GSList *iter;
+
+ for (iter = movie->variable_listeners; iter != NULL; iter = iter->next) {
+ listener = iter->data;
+
+ if (listener->object == object && listener->name == name &&
+ listener->function == function)
+ break;
+ }
+ if (iter != NULL)
+ return;
+
+ listener = g_new0 (SwfdecMovieVariableListener, 1);
+ listener->object = object;
+ listener->name = name;
+ listener->function = function;
+
+ movie->variable_listeners = g_slist_prepend (movie->variable_listeners,
+ listener);
+}
+
+void
+swfdec_movie_remove_variable_listener (SwfdecMovie *movie,
+ SwfdecAsObject *object, const char *name,
+ const SwfdecMovieVariableListenerFunction function)
+{
+ GSList *iter;
+
+ for (iter = movie->variable_listeners; iter != NULL; iter = iter->next) {
+ SwfdecMovieVariableListener *listener = iter->data;
+
+ if (listener->object == object && listener->name == name &&
+ listener->function == function)
+ break;
+ }
+ if (iter == NULL)
+ return;
+
+ g_free (iter->data);
+ movie->variable_listeners =
+ g_slist_remove (movie->variable_listeners, iter->data);
+}
+
+static void
+swfdec_movie_call_variable_listeners (SwfdecMovie *movie, const char *name,
+ const SwfdecAsValue *val)
+{
+ GSList *iter;
+
+ for (iter = movie->variable_listeners; iter != NULL; iter = iter->next) {
+ SwfdecMovieVariableListener *listener = iter->data;
+
+ if (listener->name != name &&
+ (SWFDEC_AS_OBJECT (movie)->context->version >= 7 ||
+ !swfdec_str_case_equal (listener->name, name)))
+ continue;
+
+ listener->function (listener->object, name, val);
+ }
+}
+
+static void
+swfdec_movie_set_variable (SwfdecAsObject *object, const char *variable,
+ const SwfdecAsValue *val, guint flags)
+{
+ SwfdecMovie *movie = SWFDEC_MOVIE (object);
+
+ movie = swfdec_movie_resolve (movie);
+ if (movie == NULL)
+ return;
+
+ if (swfdec_movie_set_asprop (movie, variable, val))
+ return;
+
+ swfdec_movie_call_variable_listeners (movie, variable, val);
+
+ SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->set (object, variable, val, flags);
+}
+
+static gboolean
+swfdec_movie_foreach_variable (SwfdecAsObject *object, SwfdecAsVariableForeach func, gpointer data)
+{
+ SwfdecMovie *movie = SWFDEC_MOVIE (object);
+ SwfdecAsValue val;
+ GList *walk;
+ gboolean ret;
+
+ ret = SWFDEC_AS_OBJECT_CLASS (swfdec_movie_parent_class)->foreach (object, func, data);
+
+ for (walk = movie->list; walk && ret; walk = walk->next) {
+ SwfdecMovie *cur = walk->data;
+ if (cur->original_name == SWFDEC_AS_STR_EMPTY)
+ continue;
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, walk->data);
+ ret &= func (object, cur->name, &val, 0, data);
+ }
+
+ return ret;
+}
+
+static char *
+swfdec_movie_get_debug (SwfdecAsObject *object)
+{
+ SwfdecMovie *movie = SWFDEC_MOVIE (object);
+
+ return swfdec_movie_get_path (movie, TRUE);
+}
+
+static gboolean
+swfdec_movie_iterate_end (SwfdecMovie *movie)
+{
+ return movie->parent == NULL ||
+ movie->state < SWFDEC_MOVIE_STATE_REMOVED;
+}
+
+typedef struct {
+ SwfdecMovie * movie;
+ int depth;
+} ClipEntry;
+
+static void
+swfdec_movie_do_render (SwfdecMovie *movie, cairo_t *cr,
+ const SwfdecColorTransform *ctrans, const SwfdecRect *inval)
+{
+ GList *g;
+ GSList *walk;
+ GSList *clips = NULL;
+ ClipEntry *clip = NULL;
+
+ /* exeute the movie's drawing commands */
+ for (walk = movie->draws; walk; walk = walk->next) {
+ SwfdecDraw *draw = walk->data;
+
+ if (!swfdec_rect_intersect (NULL, &draw->extents, inval))
+ continue;
+
+ swfdec_draw_paint (draw, cr, ctrans);
+ }
+
+ /* if the movie loaded an image, draw it here now */
+ if (movie->image) {
+ cairo_surface_t *surface = swfdec_image_create_surface_transformed (movie->image,
+ ctrans);
+ if (surface) {
+ static const cairo_matrix_t matrix = { 1.0 / SWFDEC_TWIPS_SCALE_FACTOR, 0, 0, 1.0 / SWFDEC_TWIPS_SCALE_FACTOR, 0, 0 };
+ cairo_pattern_t *pattern = cairo_pattern_create_for_surface (surface);
+ SWFDEC_LOG ("rendering loaded image");
+ cairo_pattern_set_matrix (pattern, &matrix);
+ cairo_set_source (cr, pattern);
+ cairo_paint (cr);
+ cairo_pattern_destroy (pattern);
+ cairo_surface_destroy (surface);
+ }
+ }
+
+ /* draw the children movies */
+ for (g = movie->list; g; g = g_list_next (g)) {
+ SwfdecMovie *child = g->data;
+
+ while (clip && clip->depth < child->depth) {
+ cairo_pattern_t *mask;
+ SWFDEC_INFO ("unsetting clip depth %d for depth %d", clip->depth, child->depth);
+ mask = swfdec_movie_mask (cr, clip->movie, inval);
+ cairo_pop_group_to_source (cr);
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_mask (cr, mask);
+ cairo_pattern_destroy (mask);
+ g_slice_free (ClipEntry, clip);
+ clips = g_slist_delete_link (clips, clips);
+ clip = clips ? clips->data : NULL;
+ }
+
+ if (child->clip_depth) {
+ clip = g_slice_new (ClipEntry);
+ clips = g_slist_prepend (clips, clip);
+ clip->movie = child;
+ clip->depth = child->clip_depth;
+ SWFDEC_INFO ("clipping up to depth %d by using %s with depth %d", child->clip_depth,
+ child->name, child->depth);
+ cairo_push_group (cr);
+ continue;
+ }
+
+ SWFDEC_LOG ("rendering %p with depth %d", child, child->depth);
+ swfdec_movie_render (child, cr, ctrans, inval);
+ }
+ while (clip) {
+ cairo_pattern_t *mask;
+ SWFDEC_INFO ("unsetting clip depth %d", clip->depth);
+ mask = swfdec_movie_mask (cr, clip->movie, inval);
+ cairo_pop_group_to_source (cr);
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_mask (cr, mask);
+ cairo_pattern_destroy (mask);
+ g_slice_free (ClipEntry, clip);
+ clips = g_slist_delete_link (clips, clips);
+ clip = clips ? clips->data : NULL;
+ }
+ g_assert (clips == NULL);
+}
+
+static gboolean
+swfdec_movie_mouse_events (SwfdecMovie *movie)
+{
+ SwfdecAsObject *object;
+
+ /* root movies don't get event */
+ if (movie->parent == NULL)
+ return FALSE;
+ /* look if we have a script that gets events */
+ if (movie->events && swfdec_event_list_has_mouse_events (movie->events))
+ return TRUE;
+ /* otherwise, require at least one of the custom script handlers */
+ object = SWFDEC_AS_OBJECT (movie);
+ if (swfdec_as_object_has_variable (object, SWFDEC_AS_STR_onRollOver) ||
+ swfdec_as_object_has_variable (object, SWFDEC_AS_STR_onRollOut) ||
+ swfdec_as_object_has_variable (object, SWFDEC_AS_STR_onDragOver) ||
+ swfdec_as_object_has_variable (object, SWFDEC_AS_STR_onDragOut) ||
+ swfdec_as_object_has_variable (object, SWFDEC_AS_STR_onPress) ||
+ swfdec_as_object_has_variable (object, SWFDEC_AS_STR_onRelease) ||
+ swfdec_as_object_has_variable (object, SWFDEC_AS_STR_onReleaseOutside))
+ return TRUE;
+ return FALSE;
+}
+
+static void
+swfdec_movie_mouse_in (SwfdecMovie *movie)
+{
+ if (swfdec_player_is_mouse_pressed (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context)))
+ swfdec_movie_queue_script (movie, SWFDEC_EVENT_DRAG_OVER);
+ else
+ swfdec_movie_queue_script (movie, SWFDEC_EVENT_ROLL_OVER);
+}
+
+static void
+swfdec_movie_mouse_out (SwfdecMovie *movie)
+{
+ if (swfdec_player_is_mouse_pressed (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context)))
+ swfdec_movie_queue_script (movie, SWFDEC_EVENT_DRAG_OUT);
+ else
+ swfdec_movie_queue_script (movie, SWFDEC_EVENT_ROLL_OUT);
+}
+
+static void
+swfdec_movie_mouse_press (SwfdecMovie *movie, guint button)
+{
+ if (button != 0)
+ return;
+ swfdec_movie_queue_script (movie, SWFDEC_EVENT_PRESS);
+}
+
+static void
+swfdec_movie_mouse_release (SwfdecMovie *movie, guint button)
+{
+ SwfdecPlayer *player;
+
+ if (button != 0)
+ return;
+
+ player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
+ if (player->priv->mouse_below == movie)
+ swfdec_movie_queue_script (movie, SWFDEC_EVENT_RELEASE);
+ else
+ swfdec_movie_queue_script (movie, SWFDEC_EVENT_RELEASE_OUTSIDE);
+}
+
+static void
+swfdec_movie_mouse_move (SwfdecMovie *movie, double x, double y)
+{
+ /* nothing to do here, it's just there so we don't need to check for NULL */
+}
+
+static void
+swfdec_movie_do_invalidate (SwfdecMovie *movie, const cairo_matrix_t *matrix, gboolean last)
+{
+ GList *walk;
+ SwfdecRect rect;
+
+ if (movie->image) {
+ rect.x0 = rect.y0 = 0;
+ rect.x1 = movie->image->width * SWFDEC_TWIPS_SCALE_FACTOR;
+ rect.y1 = movie->image->height * SWFDEC_TWIPS_SCALE_FACTOR;
+ } else {
+ swfdec_rect_init_empty (&rect);
+ }
+ swfdec_rect_union (&rect, &rect, &movie->draw_extents);
+ swfdec_rect_transform (&rect, &rect, matrix);
+ swfdec_player_invalidate (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), &rect);
+
+ for (walk = movie->list; walk; walk = walk->next) {
+ swfdec_movie_invalidate (walk->data, matrix, last);
+ }
+}
+
+static void
+swfdec_movie_class_init (SwfdecMovieClass * movie_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (movie_class);
+ SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (movie_class);
+
+ object_class->dispose = swfdec_movie_dispose;
+ object_class->get_property = swfdec_movie_get_property;
+ object_class->set_property = swfdec_movie_set_property;
+
+ asobject_class->mark = swfdec_movie_mark;
+ asobject_class->get = swfdec_movie_get_variable;
+ asobject_class->set = swfdec_movie_set_variable;
+ asobject_class->foreach = swfdec_movie_foreach_variable;
+ asobject_class->debug = swfdec_movie_get_debug;
+
+ g_object_class_install_property (object_class, PROP_DEPTH,
+ g_param_spec_int ("depth", "depth", "z order inside the parent",
+ G_MININT, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ movie_class->render = swfdec_movie_do_render;
+ movie_class->invalidate = swfdec_movie_do_invalidate;
+ movie_class->contains = swfdec_movie_do_contains;
+ movie_class->iterate_end = swfdec_movie_iterate_end;
+ movie_class->mouse_events = swfdec_movie_mouse_events;
+ movie_class->mouse_in = swfdec_movie_mouse_in;
+ movie_class->mouse_out = swfdec_movie_mouse_out;
+ movie_class->mouse_press = swfdec_movie_mouse_press;
+ movie_class->mouse_release = swfdec_movie_mouse_release;
+ movie_class->mouse_move = swfdec_movie_mouse_move;
+}
+
+void
+swfdec_movie_initialize (SwfdecMovie *movie)
+{
+ SwfdecMovieClass *klass;
+
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+
+ klass = SWFDEC_MOVIE_GET_CLASS (movie);
+ if (klass->init_movie)
+ klass->init_movie (movie);
+}
+
+void
+swfdec_movie_set_depth (SwfdecMovie *movie, int depth)
+{
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+
+ if (movie->depth == depth)
+ return;
+
+ swfdec_movie_invalidate_last (movie);
+ movie->depth = depth;
+ if (movie->parent) {
+ movie->parent->list = g_list_sort (movie->parent->list, swfdec_movie_compare_depths);
+ } else {
+ SwfdecPlayerPrivate *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context)->priv;
+ player->roots = g_list_sort (player->roots, swfdec_movie_compare_depths);
+ }
+ g_object_notify (G_OBJECT (movie), "depth");
+}
+
+static void
+swfdec_movie_set_version (SwfdecMovie *movie)
+{
+ SwfdecAsObject *o;
+ SwfdecAsContext *cx;
+ SwfdecAsValue val;
+
+ if (movie->parent != NULL)
+ return;
+
+ o = SWFDEC_AS_OBJECT (movie);
+ cx = o->context;
+ SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_get_string (cx, SWFDEC_PLAYER (cx)->priv->system->version));
+ swfdec_as_object_set_variable (o, SWFDEC_AS_STR_$version, &val);
+}
+
+/**
+ * swfdec_movie_new:
+ * @player: a #SwfdecPlayer
+ * @depth: depth of movie
+ * @parent: the parent movie or %NULL to make this a root movie
+ * @resource: the resource that is responsible for this movie
+ * @graphic: the graphic that is displayed by this movie or %NULL to create an
+ * empty movieclip
+ * @name: a garbage-collected string to be used as the name for this movie or
+ * %NULL for a default one.
+ *
+ * Creates a new movie #SwfdecMovie for the given properties. No movie may exist
+ * at the given @depth. The actual type of
+ * this movie depends on the @graphic parameter. The movie will be initialized
+ * with default properties. No script execution will be scheduled. After all
+ * properties are set, the new-movie signal will be emitted if @player is a
+ * debugger.
+ *
+ * Returns: a new #SwfdecMovie
+ **/
+SwfdecMovie *
+swfdec_movie_new (SwfdecPlayer *player, int depth, SwfdecMovie *parent, SwfdecResource *resource,
+ SwfdecGraphic *graphic, const char *name)
+{
+ SwfdecMovie *movie;
+ gsize size;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (parent == NULL || SWFDEC_IS_MOVIE (parent), NULL);
+ g_return_val_if_fail (SWFDEC_IS_RESOURCE (resource), NULL);
+ g_return_val_if_fail (graphic == NULL || SWFDEC_IS_GRAPHIC (graphic), NULL);
+
+ /* create the right movie */
+ if (graphic == NULL) {
+ movie = g_object_new (SWFDEC_TYPE_SPRITE_MOVIE, "depth", depth, NULL);
+ size = sizeof (SwfdecSpriteMovie);
+ } else {
+ SwfdecGraphicClass *klass = SWFDEC_GRAPHIC_GET_CLASS (graphic);
+ g_return_val_if_fail (klass->create_movie != NULL, NULL);
+ movie = klass->create_movie (graphic, &size);
+ movie->graphic = g_object_ref (graphic);
+ movie->depth = depth;
+ }
+ /* register it to the VM */
+ /* FIXME: It'd be nice if we'd not overuse memory here when calling this function from a script */
+ if (!swfdec_as_context_use_mem (SWFDEC_AS_CONTEXT (player), size)) {
+ size = 0;
+ }
+ g_object_ref (movie);
+ /* set essential properties */
+ movie->parent = parent;
+ movie->resource = resource;
+ if (parent) {
+ parent->list = g_list_insert_sorted (parent->list, movie, swfdec_movie_compare_depths);
+ SWFDEC_DEBUG ("inserting %s %s (depth %d) into %s %p", G_OBJECT_TYPE_NAME (movie), movie->name,
+ movie->depth, G_OBJECT_TYPE_NAME (parent), parent);
+ /* invalidate the parent, so it gets visible */
+ swfdec_movie_queue_update (parent, SWFDEC_MOVIE_INVALID_CHILDREN);
+ } else {
+ player->priv->roots = g_list_insert_sorted (player->priv->roots, movie, swfdec_movie_compare_depths);
+ }
+ /* set its name */
+ if (name) {
+ movie->original_name = name;
+ movie->name = name;
+ } else {
+ movie->original_name = SWFDEC_AS_STR_EMPTY;
+ if (SWFDEC_IS_SPRITE_MOVIE (movie) || SWFDEC_IS_BUTTON_MOVIE (movie)) {
+ movie->name = swfdec_as_context_give_string (SWFDEC_AS_CONTEXT (player),
+ g_strdup_printf ("instance%u", ++player->priv->unnamed_count));
+ } else {
+ movie->name = SWFDEC_AS_STR_EMPTY;
+ }
+ }
+ /* add the movie to the global movies list */
+ /* NB: adding to the movies list happens before setting the parent.
+ * Setting the parent does a gotoAndPlay(0) for Sprites which can cause
+ * new movies to be created (and added to this list)
+ */
+ player->priv->movies = g_list_prepend (player->priv->movies, movie);
+ /* only add the movie here, because it needs to be setup for the debugger */
+ swfdec_as_object_add (SWFDEC_AS_OBJECT (movie), SWFDEC_AS_CONTEXT (player), size);
+ swfdec_movie_set_version (movie);
+ /* only setup here, the resource assumes it can access the player via the movie */
+ if (resource->movie == NULL) {
+ g_assert (SWFDEC_IS_SPRITE_MOVIE (movie));
+ resource->movie = SWFDEC_SPRITE_MOVIE (movie);
+ }
+
+ return movie;
+}
+
+/* FIXME: since this is only used in PlaceObject, wouldn't it be easier to just have
+ * swfdec_movie_update_static_properties (movie); that's notified when any of these change
+ * and let PlaceObject modify the movie directly?
+ */
+void
+swfdec_movie_set_static_properties (SwfdecMovie *movie, const cairo_matrix_t *transform,
+ const SwfdecColorTransform *ctrans, int ratio, int clip_depth, guint blend_mode,
+ SwfdecEventList *events)
+{
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+ g_return_if_fail (clip_depth >= -16384 || clip_depth <= 0);
+ g_return_if_fail (ratio >= -1);
+
+ if (movie->modified) {
+ SWFDEC_LOG ("%s has already been modified by scripts, ignoring updates", movie->name);
+ return;
+ }
+ if (transform) {
+ swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
+ movie->original_transform = *transform;
+ movie->matrix.x0 = movie->original_transform.x0;
+ movie->matrix.y0 = movie->original_transform.y0;
+ movie->xscale = swfdec_matrix_get_xscale (&movie->original_transform);
+ movie->yscale = swfdec_matrix_get_yscale (&movie->original_transform);
+ movie->rotation = swfdec_matrix_get_rotation (&movie->original_transform);
+ }
+ if (ctrans) {
+ swfdec_movie_invalidate_last (movie);
+ movie->original_ctrans = *ctrans;
+ }
+ if (ratio >= 0 && (guint) ratio != movie->original_ratio) {
+ SwfdecMovieClass *klass;
+ movie->original_ratio = ratio;
+ klass = SWFDEC_MOVIE_GET_CLASS (movie);
+ if (klass->set_ratio)
+ klass->set_ratio (movie);
+ }
+ if (clip_depth && clip_depth != movie->clip_depth) {
+ movie->clip_depth = clip_depth;
+ /* FIXME: is this correct? */
+ swfdec_movie_invalidate_last (movie->parent ? movie->parent : movie);
+ }
+ if (blend_mode != movie->blend_mode) {
+ movie->blend_mode = blend_mode;
+ swfdec_movie_invalidate_last (movie);
+ }
+ if (events) {
+ if (SWFDEC_IS_SPRITE_MOVIE (movie)) {
+ if (movie->events)
+ swfdec_event_list_free (movie->events);
+ movie->events = swfdec_event_list_copy (events);
+ } else {
+ SWFDEC_WARNING ("trying to set events on a %s, not allowed", G_OBJECT_TYPE_NAME (movie));
+ }
+ }
+}
+
+/**
+ * swfdec_movie_duplicate:
+ * @movie: #SwfdecMovie to copy
+ * @name: garbage-collected name for the new copy
+ * @depth: depth to put this movie in
+ *
+ * Creates a duplicate of @movie. The duplicate will not be initialized or
+ * queued up for any events. You have to do this manually. In particular calling
+ * swfdec_movie_initialize() on the returned movie must be done.
+ * This function must be called from within a script.
+ *
+ * Returns: a newly created movie or %NULL on error
+ **/
+SwfdecMovie *
+swfdec_movie_duplicate (SwfdecMovie *movie, const char *name, int depth)
+{
+ SwfdecMovie *parent, *copy;
+ SwfdecSandbox *sandbox;
+
+ g_return_val_if_fail (SWFDEC_IS_MOVIE (movie), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+
+ parent = movie->parent;
+ if (movie->parent == NULL) {
+ SWFDEC_FIXME ("don't know how to duplicate root movies");
+ return NULL;
+ }
+ copy = swfdec_movie_find (movie->parent, depth);
+ if (copy) {
+ SWFDEC_LOG ("depth %d already occupied while duplicating, removing old movie", depth);
+ swfdec_movie_remove (copy);
+ }
+ copy = swfdec_movie_new (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), depth,
+ parent, movie->resource, movie->graphic, name);
+ if (copy == NULL)
+ return NULL;
+ swfdec_movie_set_static_properties (copy, &movie->original_transform,
+ &movie->original_ctrans, movie->original_ratio, movie->clip_depth,
+ movie->blend_mode, movie->events);
+ sandbox = SWFDEC_SANDBOX (SWFDEC_AS_OBJECT (movie)->context->global);
+ swfdec_sandbox_unuse (sandbox);
+ if (SWFDEC_IS_SPRITE_MOVIE (copy)) {
+ swfdec_movie_queue_script (copy, SWFDEC_EVENT_INITIALIZE);
+ swfdec_movie_queue_script (copy, SWFDEC_EVENT_LOAD);
+ swfdec_movie_execute (copy, SWFDEC_EVENT_CONSTRUCT);
+ }
+ swfdec_movie_initialize (copy);
+ swfdec_sandbox_use (sandbox);
+ return copy;
+}
+
+char *
+swfdec_movie_get_path (SwfdecMovie *movie, gboolean dot)
+{
+ GString *s;
+
+ g_return_val_if_fail (SWFDEC_IS_MOVIE (movie), NULL);
+
+ s = g_string_new ("");
+ do {
+ if (movie->parent) {
+ g_string_prepend (s, movie->name);
+ g_string_prepend_c (s, (dot ? '.' : '/'));
+ } else {
+ char *ret;
+ if (dot) {
+ ret = g_strdup_printf ("_level%u%s", movie->depth + 16384, s->str);
+ g_string_free (s, TRUE);
+ } else {
+ if (s->str[0] != '/')
+ g_string_prepend_c (s, '/');
+ ret = g_string_free (s, FALSE);
+ }
+ return ret;
+ }
+ movie = movie->parent;
+ } while (TRUE);
+
+ g_assert_not_reached ();
+
+ return NULL;
+}
+
+int
+swfdec_movie_compare_depths (gconstpointer a, gconstpointer b)
+{
+ if (SWFDEC_MOVIE (a)->depth < SWFDEC_MOVIE (b)->depth)
+ return -1;
+ if (SWFDEC_MOVIE (a)->depth > SWFDEC_MOVIE (b)->depth)
+ return 1;
+ return 0;
+}
+
+/**
+ * swfdec_depth_classify:
+ * @depth: the depth to classify
+ *
+ * Classifies a depth. This classification is mostly used when deciding if
+ * certain operations are valid in ActionScript.
+ *
+ * Returns: the classification of the depth.
+ **/
+SwfdecDepthClass
+swfdec_depth_classify (int depth)
+{
+ if (depth < -16384)
+ return SWFDEC_DEPTH_CLASS_EMPTY;
+ if (depth < 0)
+ return SWFDEC_DEPTH_CLASS_TIMELINE;
+ if (depth < 1048576)
+ return SWFDEC_DEPTH_CLASS_DYNAMIC;
+ if (depth < 2130690046)
+ return SWFDEC_DEPTH_CLASS_RESERVED;
+ return SWFDEC_DEPTH_CLASS_EMPTY;
+}
+
+/**
+ * swfdec_movie_get_own_resource:
+ * @movie: movie to query
+ *
+ * Queries the movie for his own resource. A movie only has its own resource if
+ * it contains data loaded with the loadMovie() function, or if it is the root
+ * movie.
+ *
+ * Returns: The own resource of @movie or %NULL
+ **/
+SwfdecResource *
+swfdec_movie_get_own_resource (SwfdecMovie *movie)
+{
+ g_return_val_if_fail (SWFDEC_IS_MOVIE (movie), NULL);
+
+ if (!SWFDEC_IS_SPRITE_MOVIE (movie))
+ return NULL;
+
+ if (SWFDEC_MOVIE (movie->resource->movie) != movie)
+ return NULL;
+
+ return movie->resource;
+}
+
diff --git a/swfdec/swfdec_movie.h b/swfdec/swfdec_movie.h
new file mode 100644
index 0000000..623707f
--- /dev/null
+++ b/swfdec/swfdec_movie.h
@@ -0,0 +1,306 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_MOVIE_H_
+#define _SWFDEC_MOVIE_H_
+
+#include <glib-object.h>
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_color.h>
+#include <libswfdec/swfdec.h>
+#include <libswfdec/swfdec_event.h>
+#include <libswfdec/swfdec_rect.h>
+#include <libswfdec/swfdec_types.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _SwfdecMovieClass SwfdecMovieClass;
+
+/* descriptions taken from http://www.kirupa.com/developer/actionscript/depths2.htm */
+typedef enum {
+ SWFDEC_DEPTH_CLASS_EMPTY,
+ SWFDEC_DEPTH_CLASS_TIMELINE,
+ SWFDEC_DEPTH_CLASS_DYNAMIC,
+ SWFDEC_DEPTH_CLASS_RESERVED
+} SwfdecDepthClass;
+
+typedef enum {
+ SWFDEC_MOVIE_STATE_RUNNING = 0, /* the movie has been created */
+ SWFDEC_MOVIE_STATE_REMOVED, /* swfdec_movie_remove has been called */
+ SWFDEC_MOVIE_STATE_DESTROYED /* swfdec_movie_destroy has been called */
+} SwfdecMovieState;
+
+#define SWFDEC_BLEND_MODE_NORMAL 1
+#define SWFDEC_BLEND_MODE_LAYER 2
+#define SWFDEC_BLEND_MODE_MULTIPLY 3
+#define SWFDEC_BLEND_MODE_SCREEN 4
+#define SWFDEC_BLEND_MODE_LIGHTEN 5
+#define SWFDEC_BLEND_MODE_DARKEN 6
+#define SWFDEC_BLEND_MODE_DIFFERENCE 7
+#define SWFDEC_BLEND_MODE_ADD 8
+#define SWFDEC_BLEND_MODE_SUBTRACT 9
+#define SWFDEC_BLEND_MODE_INVERT 10
+#define SWFDEC_BLEND_MODE_ALPHA 11
+#define SWFDEC_BLEND_MODE_ERASE 12
+#define SWFDEC_BLEND_MODE_OVERLAY 13
+#define SWFDEC_BLEND_MODE_HARDLIGHT 14
+
+#define SWFDEC_TYPE_MOVIE (swfdec_movie_get_type())
+#define SWFDEC_IS_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_MOVIE))
+#define SWFDEC_IS_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_MOVIE))
+#define SWFDEC_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_MOVIE, SwfdecMovie))
+#define SWFDEC_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_MOVIE, SwfdecMovieClass))
+#define SWFDEC_MOVIE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_MOVIE, SwfdecMovieClass))
+
+/* NB: each following state includes the previous */
+typedef enum {
+ SWFDEC_MOVIE_UP_TO_DATE = 0, /* everything OK */
+ SWFDEC_MOVIE_INVALID_CHILDREN, /* call update on children */
+ SWFDEC_MOVIE_INVALID_EXTENTS, /* recalculate extents */
+ SWFDEC_MOVIE_INVALID_MATRIX /* matrix is invalid, recalculate */
+} SwfdecMovieCacheState;
+
+typedef void (*SwfdecMovieVariableListenerFunction) (SwfdecAsObject *object,
+ const char *name, const SwfdecAsValue *val);
+
+typedef struct {
+ SwfdecAsObject * object;
+ const char * name;
+ SwfdecMovieVariableListenerFunction function;
+} SwfdecMovieVariableListener;
+
+struct _SwfdecMovie {
+ SwfdecAsObject object;
+
+ SwfdecGraphic * graphic; /* graphic represented by this movie or NULL if script-created */
+ const char * name; /* name of movie - GC'd */
+ GList * list; /* our contained movie clips (ordered by depth) */
+ int depth; /* depth of movie (equals content->depth unless explicitly set) */
+ SwfdecMovieCacheState cache_state; /* whether we are up to date */
+ SwfdecMovieState state; /* state the movie is in */
+ GSList *variable_listeners; /* textfield's listening to changes in variables - SwfdecMovieVariableListener */
+
+ /* static properties (set by PlaceObject tags) */
+ const char * original_name; /* the original name - GC'd and static */
+ SwfdecColorTransform original_ctrans; /* color transform set on this movie */
+ cairo_matrix_t original_transform; /* initial transform used */
+ guint original_ratio; /* ratio used in this movie */
+ int clip_depth; /* up to which movie this movie clips */
+ SwfdecEventList * events; /* events queued on this movie */
+
+ /* parenting information */
+ SwfdecMovie * parent; /* movie that contains us or NULL for root movies */
+ SwfdecResource * resource; /* the resource that created us */
+
+ /* positioning - the values are applied in this order */
+ SwfdecRect extents; /* the extents occupied after transform is applied */
+ SwfdecRect original_extents; /* the extents from all children - unmodified */
+ gboolean modified; /* TRUE if the transform has been modified by scripts */
+ double xscale; /* x scale in percent */
+ double yscale; /* y scale in percent */
+ double rotation; /* rotation in degrees [-180, 180] */
+ cairo_matrix_t matrix; /* cairo matrix computed from above and content->transform */
+ cairo_matrix_t inverse_matrix; /* the inverse of the cairo matrix */
+ SwfdecColorTransform color_transform; /* scripted color transformation */
+ guint blend_mode; /* blend mode to use - see to-cairo conversion code for what they mean */
+
+ /* iteration state */
+ gboolean visible; /* whether we currently can be seen or iterate */
+
+ /* drawing state */
+ SwfdecMovie * mask_of; /* movie this movie is a mask of or NULL if none */
+ SwfdecMovie * masked_by; /* movie we are masked by or NULL if none */
+ /* FIXME: could it be that shape drawing (SwfdecGraphicMovie etc) uses these same objects? */
+ SwfdecImage * image; /* image loaded via loadMovie */
+ SwfdecRect draw_extents; /* extents of the items in the following list */
+ GSList * draws; /* all the items to draw */
+ SwfdecDraw * draw_fill; /* current fill style or NULL */
+ SwfdecDraw * draw_line; /* current line style or NULL */
+ int draw_x; /* current x position for drawing */
+ int draw_y; /* current y position for drawing */
+
+ /* invalidatation state */
+ gboolean invalidate_last; /* TRUE if this movie's previous contents are already invalidated */
+ gboolean invalidate_next; /* TRUE if this movie should be invalidated before unlocking */
+
+ /* leftover unimplemented variables from the Actionscript spec */
+#if 0
+ int droptarget;
+#endif
+};
+
+struct _SwfdecMovieClass {
+ SwfdecAsObjectClass object_class;
+
+ /* general vfuncs */
+ void (* init_movie) (SwfdecMovie * movie);
+ void (* finish_movie) (SwfdecMovie * movie);
+ void (* replace) (SwfdecMovie * movie,
+ SwfdecGraphic * graphic);
+ void (* set_ratio) (SwfdecMovie * movie);
+ void (* update_extents) (SwfdecMovie * movie,
+ SwfdecRect * extents);
+ void (* render) (SwfdecMovie * movie,
+ cairo_t * cr,
+ const SwfdecColorTransform *trans,
+ const SwfdecRect * inval);
+ void (* invalidate) (SwfdecMovie * movie,
+ const cairo_matrix_t * movie_to_global,
+ gboolean new_contents);
+
+ SwfdecMovie * (* contains) (SwfdecMovie * movie,
+ double x,
+ double y,
+ gboolean events);
+ /* mouse handling */
+ gboolean (* mouse_events) (SwfdecMovie * movie);
+ SwfdecMouseCursor (* mouse_cursor) (SwfdecMovie * movie);
+ void (* mouse_in) (SwfdecMovie * movie);
+ void (* mouse_out) (SwfdecMovie * movie);
+ void (* mouse_press) (SwfdecMovie * movie,
+ guint button);
+ void (* mouse_release) (SwfdecMovie * movie,
+ guint button);
+ void (* mouse_move) (SwfdecMovie * movie,
+ double x,
+ double y);
+ /* keyboard handling */
+ void (* focus_in) (SwfdecMovie * movie,
+ SwfdecMovie * previous);
+ void (* focus_out) (SwfdecMovie * movie,
+ SwfdecMovie * next);
+ void (* key_pressed) (SwfdecMovie * movie,
+ guint keycode,
+ guint character);
+ void (* key_released) (SwfdecMovie * movie,
+ guint keycode,
+ guint character);
+
+ /* iterating */
+ void (* iterate_start) (SwfdecMovie * movie);
+ gboolean (* iterate_end) (SwfdecMovie * movie);
+};
+
+GType swfdec_movie_get_type (void);
+
+SwfdecMovie * swfdec_movie_new (SwfdecPlayer * player,
+ int depth,
+ SwfdecMovie * parent,
+ SwfdecResource * resource,
+ SwfdecGraphic * graphic,
+ const char * name);
+SwfdecMovie * swfdec_movie_duplicate (SwfdecMovie * movie,
+ const char * name,
+ int depth);
+void swfdec_movie_initialize (SwfdecMovie * movie);
+SwfdecMovie * swfdec_movie_find (SwfdecMovie * movie,
+ int depth);
+SwfdecMovie * swfdec_movie_get_by_name (SwfdecMovie * movie,
+ const char * name,
+ gboolean unnamed);
+SwfdecMovie * swfdec_movie_get_root (SwfdecMovie * movie);
+void swfdec_movie_remove (SwfdecMovie * movie);
+void swfdec_movie_destroy (SwfdecMovie * movie);
+void swfdec_movie_set_static_properties
+ (SwfdecMovie * movie,
+ const cairo_matrix_t * transform,
+ const SwfdecColorTransform *ctrans,
+ int ratio,
+ int clip_depth,
+ guint blend_mode,
+ SwfdecEventList * events);
+void swfdec_movie_invalidate_last (SwfdecMovie * movie);
+void swfdec_movie_invalidate_next (SwfdecMovie * movie);
+void swfdec_movie_invalidate (SwfdecMovie * movie,
+ const cairo_matrix_t * parent_to_global,
+ gboolean last);
+void swfdec_movie_queue_update (SwfdecMovie * movie,
+ SwfdecMovieCacheState state);
+void swfdec_movie_update (SwfdecMovie * movie);
+void swfdec_movie_local_to_global (SwfdecMovie * movie,
+ double * x,
+ double * y);
+void swfdec_movie_global_to_local (SwfdecMovie * movie,
+ double * x,
+ double * y);
+void swfdec_movie_global_to_local_matrix
+ (SwfdecMovie * movie,
+ cairo_matrix_t * matrix);
+void swfdec_movie_local_to_global_matrix
+ (SwfdecMovie * movie,
+ cairo_matrix_t * matrix);
+void swfdec_movie_rect_local_to_global (SwfdecMovie * movie,
+ SwfdecRect * rect);
+void swfdec_movie_rect_global_to_local (SwfdecMovie * movie,
+ SwfdecRect * rect);
+void swfdec_movie_set_depth (SwfdecMovie * movie,
+ int depth);
+
+void swfdec_movie_get_mouse (SwfdecMovie * movie,
+ double * x,
+ double * y);
+gboolean swfdec_movie_get_mouse_events (SwfdecMovie * movie);
+#define swfdec_movie_contains(movie, x, y) \
+ (swfdec_movie_get_movie_at ((movie), (x), (y), FALSE) != NULL)
+SwfdecMovie * swfdec_movie_get_movie_at (SwfdecMovie * movie,
+ double x,
+ double y,
+ gboolean events);
+char * swfdec_movie_get_path (SwfdecMovie * movie,
+ gboolean dot);
+void swfdec_movie_render (SwfdecMovie * movie,
+ cairo_t * cr,
+ const SwfdecColorTransform *trans,
+ const SwfdecRect * inval);
+cairo_pattern_t *swfdec_movie_mask (cairo_t * cr,
+ SwfdecMovie * movie,
+ const SwfdecRect * inval);
+SwfdecMovie * swfdec_movie_resolve (SwfdecMovie * movie);
+guint swfdec_movie_get_version (SwfdecMovie * movie);
+void swfdec_movie_execute (SwfdecMovie * movie,
+ SwfdecEventType condition);
+void swfdec_movie_queue_script (SwfdecMovie * movie,
+ SwfdecEventType condition);
+
+int swfdec_movie_compare_depths (gconstpointer a,
+ gconstpointer b);
+SwfdecDepthClass
+ swfdec_depth_classify (int depth);
+
+/* in swfdec_movie_asprops.c */
+gboolean swfdec_movie_set_asprop (SwfdecMovie * movie,
+ const char * name,
+ const SwfdecAsValue * val);
+gboolean swfdec_movie_get_asprop (SwfdecMovie * movie,
+ const char * name,
+ SwfdecAsValue * val);
+
+void swfdec_movie_add_variable_listener (SwfdecMovie * movie,
+ SwfdecAsObject * object,
+ const char * name,
+ const SwfdecMovieVariableListenerFunction function);
+void swfdec_movie_remove_variable_listener (SwfdecMovie * movie,
+ SwfdecAsObject * object,
+ const char * name,
+ const SwfdecMovieVariableListenerFunction function);
+SwfdecResource *swfdec_movie_get_own_resource (SwfdecMovie * movie);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_movie_as_drawing.c b/swfdec/swfdec_movie_as_drawing.c
new file mode 100644
index 0000000..bcedce6
--- /dev/null
+++ b/swfdec/swfdec_movie_as_drawing.c
@@ -0,0 +1,456 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_movie.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_color.h"
+#include "swfdec_debug.h"
+#include "swfdec_gradient_pattern.h"
+#include "swfdec_path.h"
+#include "swfdec_pattern.h"
+#include "swfdec_stroke.h"
+
+/* FIXME: This whole code assumes it works for MovieClip, Button and TextField
+ * objects. If it only works for MovieClip objects, fix this. */
+
+static SwfdecDraw *
+swfdec_stroke_copy (SwfdecDraw *draw)
+{
+ SwfdecStroke *sstroke = SWFDEC_STROKE (draw);
+ SwfdecStroke *dstroke = g_object_new (SWFDEC_TYPE_STROKE, NULL);
+
+ dstroke->start_width = sstroke->start_width;
+ dstroke->start_color = sstroke->start_color;
+ if (sstroke->pattern)
+ dstroke->pattern = g_object_ref (sstroke->pattern);
+ dstroke->start_cap = sstroke->start_cap;
+ dstroke->end_cap = sstroke->end_cap;
+ dstroke->join = sstroke->join;
+ dstroke->miter_limit = sstroke->miter_limit;
+ dstroke->no_vscale = sstroke->no_vscale;
+ dstroke->no_hscale = sstroke->no_hscale;
+
+ return SWFDEC_DRAW (dstroke);
+}
+
+static void
+swfdec_sprite_movie_end_fill (SwfdecMovie *movie, SwfdecDraw *new)
+{
+ /* FIXME: need to cairo_close_path()? */
+ movie->draw_fill = new;
+ if (new == NULL)
+ return;
+
+ movie->draws = g_slist_append (movie->draws, new);
+
+ /* need to begin a new line segment to ensure proper stacking order */
+ if (movie->draw_line) {
+ movie->draw_line = swfdec_stroke_copy (movie->draw_line);
+ movie->draws = g_slist_append (movie->draws, movie->draw_line);
+ }
+}
+
+#define SWFDEC_COLOR_FROM_COLOR_ALPHA(color, alpha) \
+ (((color) & 0xFFFFFF) | SWFDEC_COLOR_COMBINE (0, 0, 0, CLAMP ((alpha), 0, 100) * 255 / 100))
+
+SWFDEC_AS_NATIVE (901, 1, swfdec_sprite_movie_beginFill)
+void
+swfdec_sprite_movie_beginFill (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+ SwfdecDraw *draw;
+ int color, alpha;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "|ii", &color, &alpha);
+ movie->draw_fill = NULL;
+
+ if (argc == 0)
+ return;
+ color = color & 0xFFFFFF;
+ if (argc <= 1) {
+ alpha = 255;
+ }
+ color = SWFDEC_COLOR_FROM_COLOR_ALPHA (color, alpha);
+ draw = SWFDEC_DRAW (swfdec_pattern_new_color (color));
+ swfdec_path_move_to (&draw->path, movie->draw_x, movie->draw_y);
+ swfdec_sprite_movie_end_fill (movie, draw);
+}
+
+static inline guint
+swfdec_sprite_movie_gradient_fill_get_length (SwfdecAsObject *o)
+{
+ int length;
+ SwfdecAsValue val;
+
+ swfdec_as_object_get_variable (o, SWFDEC_AS_STR_length, &val);
+ length = swfdec_as_value_to_integer (o->context, &val);
+ return MAX (length, 0);
+}
+
+static int
+swfdec_sprite_movie_gradient_fill_check_length (SwfdecAsObject *colors, SwfdecAsObject *alphas, SwfdecAsObject *ratios)
+{
+ guint c, a, r;
+
+ c = swfdec_sprite_movie_gradient_fill_get_length (colors);
+ a = swfdec_sprite_movie_gradient_fill_get_length (alphas);
+ r = swfdec_sprite_movie_gradient_fill_get_length (ratios);
+ if (c != a || a != r)
+ return -1;
+ return c;
+}
+
+static void
+swfdec_sprite_movie_extract_matrix (SwfdecAsObject *o, cairo_matrix_t *mat)
+{
+ SwfdecAsContext *cx = o->context;
+ SwfdecAsValue val;
+
+ /* FIXME: This function does not call valueOf in the right order */
+ if (swfdec_as_object_get_variable (o, SWFDEC_AS_STR_matrixType, &val)) {
+ const char *s = swfdec_as_value_to_string (cx, &val);
+ cairo_matrix_init_translate (mat, SWFDEC_TWIPS_SCALE_FACTOR / 2.0, SWFDEC_TWIPS_SCALE_FACTOR / 2.0);
+ cairo_matrix_scale (mat, SWFDEC_TWIPS_SCALE_FACTOR / 32768.0, SWFDEC_TWIPS_SCALE_FACTOR / 32768.0);
+ if (s == SWFDEC_AS_STR_box) {
+ double x, y, w, h, r;
+ cairo_matrix_t input;
+ swfdec_as_object_get_variable (o, SWFDEC_AS_STR_x, &val);
+ x = swfdec_as_value_to_number (cx, &val);
+ swfdec_as_object_get_variable (o, SWFDEC_AS_STR_y, &val);
+ y = swfdec_as_value_to_number (cx, &val);
+ swfdec_as_object_get_variable (o, SWFDEC_AS_STR_w, &val);
+ w = swfdec_as_value_to_number (cx, &val);
+ swfdec_as_object_get_variable (o, SWFDEC_AS_STR_h, &val);
+ h = swfdec_as_value_to_number (cx, &val);
+ swfdec_as_object_get_variable (o, SWFDEC_AS_STR_r, &val);
+ r = swfdec_as_value_to_number (cx, &val);
+ cairo_matrix_init_translate (&input, (x + w) / 2, (y + h) / 2);
+ cairo_matrix_scale (&input, w, h);
+ cairo_matrix_rotate (&input, r);
+ cairo_matrix_multiply (mat, mat, &input);
+ } else {
+ SWFDEC_WARNING ("my friend, there's no other matrixType than \"box\"");
+ }
+ } else {
+ cairo_matrix_t input;
+ swfdec_as_object_get_variable (o, SWFDEC_AS_STR_a, &val);
+ input.xx = swfdec_as_value_to_number (cx, &val);
+ swfdec_as_object_get_variable (o, SWFDEC_AS_STR_b, &val);
+ input.yx = swfdec_as_value_to_number (cx, &val);
+ swfdec_as_object_get_variable (o, SWFDEC_AS_STR_d, &val);
+ input.xy = swfdec_as_value_to_number (cx, &val);
+ swfdec_as_object_get_variable (o, SWFDEC_AS_STR_e, &val);
+ input.yy = swfdec_as_value_to_number (cx, &val);
+ swfdec_as_object_get_variable (o, SWFDEC_AS_STR_g, &val);
+ input.x0 = swfdec_as_value_to_number (cx, &val) * SWFDEC_TWIPS_SCALE_FACTOR;
+ swfdec_as_object_get_variable (o, SWFDEC_AS_STR_h, &val);
+ input.y0 = swfdec_as_value_to_number (cx, &val) * SWFDEC_TWIPS_SCALE_FACTOR;
+ cairo_matrix_init_scale (mat, SWFDEC_TWIPS_SCALE_FACTOR / 32768.0, SWFDEC_TWIPS_SCALE_FACTOR / 32768.0);
+ cairo_matrix_multiply (mat, mat, &input);
+ }
+}
+
+SWFDEC_AS_NATIVE (901, 2, swfdec_sprite_movie_beginGradientFill)
+void
+swfdec_sprite_movie_beginGradientFill (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecGradientPattern *gradient;
+ SwfdecPattern *pattern;
+ SwfdecMovie *movie;
+ SwfdecDraw *draw;
+ SwfdecAsObject *colors, *alphas, *ratios, *matrix;
+ const char *s;
+ gboolean radial;
+ int i, len;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "|sOOOO", &s, &colors, &alphas, &ratios, &matrix);
+ movie->draw_fill = NULL;
+
+ if (colors == NULL || alphas == NULL || ratios == NULL || matrix == NULL) {
+ SWFDEC_ERROR ("could not convert one of the parameters to an object");
+ return;
+ }
+ if (s == SWFDEC_AS_STR_linear) {
+ radial = FALSE;
+ } else if (s == SWFDEC_AS_STR_radial) {
+ radial = TRUE;
+ } else {
+ SWFDEC_WARNING ("invalid fill type %s", s);
+ return;
+ }
+ len = swfdec_sprite_movie_gradient_fill_check_length (colors, alphas, ratios);
+ if (len < 0) {
+ SWFDEC_ERROR ("different lengths for colors, alphas and ratios, aborting");
+ return;
+ }
+ draw = swfdec_gradient_pattern_new ();
+ pattern = SWFDEC_PATTERN (draw);
+ gradient = SWFDEC_GRADIENT_PATTERN (draw);
+ gradient->radial = radial;
+ len = MIN (len, 8);
+ gradient->n_gradients = len;
+ for (i = 0; i < len; i++) {
+ int c, a, r;
+ SwfdecAsValue v;
+ int check = swfdec_sprite_movie_gradient_fill_check_length (colors, alphas, ratios);
+ if (check > i) {
+ const char *name = swfdec_as_integer_to_string (cx, i);
+ if (swfdec_as_object_get_variable (colors, name, &v)
+ && SWFDEC_AS_VALUE_IS_NUMBER (&v))
+ c = swfdec_as_value_to_integer (cx, &v);
+ else
+ c = 0;
+ if (!swfdec_as_object_get_variable (alphas, name, &v)) {
+ a = c;
+ } else if (!SWFDEC_AS_VALUE_IS_NUMBER (&v)) {
+ a = 0;
+ } else {
+ a = swfdec_as_value_to_integer (cx, &v);
+ }
+ if (!swfdec_as_object_get_variable (ratios, name, &v))
+ r = CLAMP (a, 0, 255);
+ else if (!SWFDEC_AS_VALUE_IS_NUMBER (&v))
+ r = 0;
+ else
+ r = swfdec_as_value_to_integer (cx, &v);
+ } else {
+ c = a = r = 0;
+ }
+ if (r > 255 || r < 0) {
+ SWFDEC_WARNING ("ratio %d not in [0, 255], ignoring gradient", r);
+ g_object_unref (draw);
+ return;
+ } else if (r < 0) {
+ r = 0;
+ }
+ gradient->gradient[i].color = SWFDEC_COLOR_FROM_COLOR_ALPHA (c, a);
+ gradient->gradient[i].ratio = r;
+ }
+ swfdec_sprite_movie_extract_matrix (matrix, &pattern->start_transform);
+ pattern->transform = pattern->start_transform;
+ if (cairo_matrix_invert (&pattern->transform)) {
+ SWFDEC_ERROR ("gradient transform matrix not invertible, resetting");
+ cairo_matrix_init_identity (&pattern->transform);
+ }
+
+ swfdec_path_move_to (&draw->path, movie->draw_x, movie->draw_y);
+ swfdec_sprite_movie_end_fill (movie, draw);
+}
+
+SWFDEC_AS_NATIVE (901, 3, swfdec_sprite_movie_moveTo)
+void
+swfdec_sprite_movie_moveTo (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+ double x, y;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "|nn", &x, &y);
+
+ x = SWFDEC_DOUBLE_TO_TWIPS (x);
+ y = SWFDEC_DOUBLE_TO_TWIPS (y);
+ /* NB: moves do not extend extents */
+ if (movie->draw_fill) {
+ swfdec_path_move_to (&movie->draw_fill->path, x, y);
+ }
+ if (movie->draw_line) {
+ swfdec_path_move_to (&movie->draw_line->path, x, y);
+ }
+ movie->draw_x = x;
+ movie->draw_y = y;
+}
+
+static void
+swfdec_spite_movie_recompute_draw (SwfdecMovie *movie, SwfdecDraw *draw)
+{
+ swfdec_draw_recompute (draw);
+ if (swfdec_rect_inside (&movie->draw_extents, &draw->extents)) {
+ swfdec_movie_invalidate_last (movie);
+ } else {
+ swfdec_movie_invalidate_next (movie);
+ swfdec_rect_union (&movie->draw_extents, &movie->draw_extents, &draw->extents);
+ swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_EXTENTS);
+ }
+}
+
+SWFDEC_AS_NATIVE (901, 4, swfdec_sprite_movie_lineTo)
+void
+swfdec_sprite_movie_lineTo (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+ double x, y;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "nn", &x, &y);
+
+ x = SWFDEC_DOUBLE_TO_TWIPS (x);
+ y = SWFDEC_DOUBLE_TO_TWIPS (y);
+ if (movie->draw_fill) {
+ swfdec_path_line_to (&movie->draw_fill->path, x, y);
+ swfdec_spite_movie_recompute_draw (movie, movie->draw_fill);
+ }
+ if (movie->draw_line) {
+ swfdec_path_line_to (&movie->draw_line->path, x, y);
+ swfdec_spite_movie_recompute_draw (movie, movie->draw_line);
+ }
+ movie->draw_x = x;
+ movie->draw_y = y;
+}
+
+SWFDEC_AS_NATIVE (901, 5, swfdec_sprite_movie_curveTo)
+void
+swfdec_sprite_movie_curveTo (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+ double x, y, c_x, c_y;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "nnnn", &c_x, &c_y, &x, &y);
+
+ x = SWFDEC_DOUBLE_TO_TWIPS (x);
+ y = SWFDEC_DOUBLE_TO_TWIPS (y);
+ c_x = SWFDEC_DOUBLE_TO_TWIPS (c_x);
+ c_y = SWFDEC_DOUBLE_TO_TWIPS (c_y);
+ if (movie->draw_fill) {
+ swfdec_path_curve_to (&movie->draw_fill->path, movie->draw_x, movie->draw_y,
+ c_x, c_y, x, y);
+ swfdec_spite_movie_recompute_draw (movie, movie->draw_fill);
+ }
+ if (movie->draw_line) {
+ swfdec_path_curve_to (&movie->draw_line->path, movie->draw_x, movie->draw_y,
+ c_x, c_y, x, y);
+ swfdec_spite_movie_recompute_draw (movie, movie->draw_line);
+ }
+ movie->draw_x = x;
+ movie->draw_y = y;
+}
+
+SWFDEC_AS_NATIVE (901, 6, swfdec_sprite_movie_lineStyle)
+void
+swfdec_sprite_movie_lineStyle (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+ SwfdecStroke *stroke;
+ int width, color, alpha;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "|iii", &width, &color, &alpha);
+
+ movie->draw_line = NULL;
+ if (argc < 1 || SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
+ return;
+ if (argc < 3)
+ alpha = 100;
+ if (argc > 3) {
+ SWFDEC_FIXME ("implement Flash 8 arguments to lineStyle");
+ }
+ color = color & 0xFFFFFF;
+ alpha = CLAMP (alpha, 0, 100);
+ alpha = SWFDEC_COLOR_COMBINE (0, 0, 0, alpha * 255 / 100);
+ color = color | alpha;
+ stroke = g_object_new (SWFDEC_TYPE_STROKE, NULL);
+ stroke->start_color = color;
+ stroke->start_width = SWFDEC_DOUBLE_TO_TWIPS (width);
+ movie->draw_line = SWFDEC_DRAW (stroke);
+ swfdec_path_move_to (&movie->draw_line->path, movie->draw_x, movie->draw_y);
+ movie->draws = g_slist_append (movie->draws, movie->draw_line);
+}
+
+SWFDEC_AS_NATIVE (901, 7, swfdec_sprite_movie_endFill)
+void
+swfdec_sprite_movie_endFill (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "");
+ swfdec_sprite_movie_end_fill (movie, NULL);
+}
+
+SWFDEC_AS_NATIVE (901, 8, swfdec_sprite_movie_clear)
+void
+swfdec_sprite_movie_clear (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "");
+ if (movie->draws == NULL)
+ return;
+ swfdec_movie_invalidate_last (movie);
+ swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_EXTENTS);
+ swfdec_rect_init_empty (&movie->draw_extents);
+ g_slist_foreach (movie->draws, (GFunc) g_object_unref, NULL);
+ g_slist_free (movie->draws);
+ movie->draws = NULL;
+ movie->draw_fill = NULL;
+ movie->draw_line = NULL;
+}
+
+SWFDEC_AS_NATIVE (901, 9, swfdec_sprite_movie_lineGradientStyle)
+void
+swfdec_sprite_movie_lineGradientStyle (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.lineGradientStyle");
+}
+
+SWFDEC_AS_NATIVE (901, 10, swfdec_sprite_movie_beginMeshFill)
+void
+swfdec_sprite_movie_beginMeshFill (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.beginMeshFill");
+}
+
+SWFDEC_AS_NATIVE (901, 11, swfdec_sprite_movie_beginBitmapFill)
+void
+swfdec_sprite_movie_beginBitmapFill (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.beginBitmapFill");
+}
+
+SWFDEC_AS_NATIVE (901, 12, swfdec_sprite_movie_get_scale9Grid)
+void
+swfdec_sprite_movie_get_scale9Grid (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.scale9Grid (get)");
+}
+
+SWFDEC_AS_NATIVE (901, 13, swfdec_sprite_movie_set_scale9Grid)
+void
+swfdec_sprite_movie_set_scale9Grid (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.scale9Grid (set)");
+}
diff --git a/swfdec/swfdec_movie_asprops.c b/swfdec/swfdec_movie_asprops.c
new file mode 100644
index 0000000..c2985a5
--- /dev/null
+++ b/swfdec/swfdec_movie_asprops.c
@@ -0,0 +1,484 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <string.h>
+#include <math.h>
+
+#include "swfdec_movie.h"
+#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"
+#include "swfdec_resource.h"
+
+static void
+mc_x_get (SwfdecMovie *movie, SwfdecAsValue *rval)
+{
+ double d;
+
+ swfdec_movie_update (movie);
+ d = SWFDEC_TWIPS_TO_DOUBLE (movie->matrix.x0);
+ SWFDEC_AS_VALUE_SET_NUMBER (rval, d);
+}
+
+static void
+mc_x_set (SwfdecMovie *movie, const SwfdecAsValue *val)
+{
+ double d;
+
+ d = swfdec_as_value_to_number (SWFDEC_AS_OBJECT (movie)->context, val);
+ if (!isfinite (d)) {
+ SWFDEC_WARNING ("trying to move %s._x to a non-finite value, ignoring", movie->name);
+ return;
+ }
+ movie->modified = TRUE;
+ d = SWFDEC_DOUBLE_TO_TWIPS (d);
+ if (d != movie->matrix.x0) {
+ swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
+ movie->matrix.x0 = d;
+ }
+}
+
+static void
+mc_y_get (SwfdecMovie *movie, SwfdecAsValue *rval)
+{
+ double d;
+
+ swfdec_movie_update (movie);
+ d = SWFDEC_TWIPS_TO_DOUBLE (movie->matrix.y0);
+ SWFDEC_AS_VALUE_SET_NUMBER (rval, d);
+}
+
+static void
+mc_y_set (SwfdecMovie *movie, const SwfdecAsValue *val)
+{
+ double d;
+
+ d = swfdec_as_value_to_number (SWFDEC_AS_OBJECT (movie)->context, val);
+ if (!isfinite (d)) {
+ SWFDEC_WARNING ("trying to move %s._y to a non-finite value, ignoring", movie->name);
+ return;
+ }
+ movie->modified = TRUE;
+ d = SWFDEC_DOUBLE_TO_TWIPS (d);
+ if (d != movie->matrix.y0) {
+ swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
+ movie->matrix.y0 = d;
+ }
+}
+
+static void
+mc_xscale_get (SwfdecMovie *movie, SwfdecAsValue *rval)
+{
+ SWFDEC_AS_VALUE_SET_NUMBER (rval, movie->xscale);
+}
+
+static void
+mc_xscale_set (SwfdecMovie *movie, const SwfdecAsValue *val)
+{
+ double d;
+
+ d = swfdec_as_value_to_number (SWFDEC_AS_OBJECT (movie)->context, val);
+ if (!isfinite (d)) {
+ SWFDEC_WARNING ("trying to set xscale to a non-finite value, ignoring");
+ return;
+ }
+ movie->modified = TRUE;
+ if (movie->xscale != d) {
+ swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
+ movie->xscale = d;
+ }
+}
+
+static void
+mc_yscale_get (SwfdecMovie *movie, SwfdecAsValue *rval)
+{
+ SWFDEC_AS_VALUE_SET_NUMBER (rval, movie->yscale);
+}
+
+static void
+mc_yscale_set (SwfdecMovie *movie, const SwfdecAsValue *val)
+{
+ double d;
+
+ d = swfdec_as_value_to_number (SWFDEC_AS_OBJECT (movie)->context, val);
+ if (!isfinite (d)) {
+ SWFDEC_WARNING ("trying to set yscale to a non-finite value, ignoring");
+ return;
+ }
+ movie->modified = TRUE;
+ if (movie->yscale != d) {
+ swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
+ movie->yscale = d;
+ }
+}
+
+static void
+mc_name_get (SwfdecMovie *movie, SwfdecAsValue *rval)
+{
+ SWFDEC_AS_VALUE_SET_STRING (rval, movie->name);
+}
+
+static void
+mc_name_set (SwfdecMovie *movie, const SwfdecAsValue *val)
+{
+ movie->name = swfdec_as_value_to_string (SWFDEC_AS_OBJECT (movie)->context, val);
+}
+
+static void
+mc_currentframe (SwfdecMovie *movie, SwfdecAsValue *rval)
+{
+ g_assert (SWFDEC_IS_SPRITE_MOVIE (movie));
+ SWFDEC_AS_VALUE_SET_NUMBER (rval, SWFDEC_SPRITE_MOVIE (movie)->frame);
+}
+
+static void
+mc_framesloaded (SwfdecMovie *mov, SwfdecAsValue *rval)
+{
+ SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov);
+
+ SWFDEC_AS_VALUE_SET_INT (rval,
+ swfdec_sprite_movie_get_frames_loaded (movie));
+}
+
+static void
+mc_totalframes (SwfdecMovie *mov, SwfdecAsValue *rval)
+{
+ SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov);
+
+ SWFDEC_AS_VALUE_SET_INT (rval,
+ swfdec_sprite_movie_get_frames_total (movie));
+}
+
+static void
+mc_alpha_get (SwfdecMovie *movie, SwfdecAsValue *rval)
+{
+ SWFDEC_AS_VALUE_SET_NUMBER (rval,
+ movie->color_transform.aa * 100.0 / 256.0);
+}
+
+static void
+mc_alpha_set (SwfdecMovie *movie, const SwfdecAsValue *val)
+{
+ double d;
+ int alpha;
+
+ d = swfdec_as_value_to_number (SWFDEC_AS_OBJECT (movie)->context, val);
+ if (!isfinite (d)) {
+ SWFDEC_WARNING ("trying to set alpha to a non-finite value, ignoring");
+ return;
+ }
+ alpha = d * 256.0 / 100.0;
+ if (alpha != movie->color_transform.aa) {
+ movie->color_transform.aa = alpha;
+ swfdec_movie_invalidate_last (movie);
+ }
+}
+
+static void
+mc_visible_get (SwfdecMovie *movie, SwfdecAsValue *rval)
+{
+ SWFDEC_AS_VALUE_SET_BOOLEAN (rval, movie->visible);
+}
+
+static void
+mc_visible_set (SwfdecMovie *movie, const SwfdecAsValue *val)
+{
+ gboolean b;
+
+ b = swfdec_as_value_to_boolean (SWFDEC_AS_OBJECT (movie)->context, val);
+ if (b != movie->visible) {
+ movie->visible = b;
+ swfdec_movie_invalidate_last (movie);
+ }
+}
+
+static void
+mc_width_get (SwfdecMovie *movie, SwfdecAsValue *rval)
+{
+ double d;
+
+ swfdec_movie_update (movie);
+ d = rint (movie->extents.x1 - movie->extents.x0);
+ d = SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) d);
+ SWFDEC_AS_VALUE_SET_NUMBER (rval, d);
+}
+
+static void
+mc_width_set (SwfdecMovie *movie, const SwfdecAsValue *val)
+{
+ double d, cur;
+
+ /* property was readonly in Flash 4 and before */
+ if (SWFDEC_AS_OBJECT (movie)->context->version < 5)
+ return;
+ d = swfdec_as_value_to_number (SWFDEC_AS_OBJECT (movie)->context, val);
+ if (!isfinite (d)) {
+ SWFDEC_WARNING ("trying to set width to a non-finite value, ignoring");
+ return;
+ }
+ swfdec_movie_update (movie);
+ movie->modified = TRUE;
+ cur = rint (movie->original_extents.x1 - movie->original_extents.x0);
+ cur = SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) cur);
+ if (cur != 0) {
+ d = 100 * d / cur;
+ if (d == movie->xscale)
+ return;
+ swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
+ movie->xscale = d;
+ } else {
+ swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
+ movie->xscale = 0;
+ movie->yscale = 0;
+ }
+}
+
+static void
+mc_height_get (SwfdecMovie *movie, SwfdecAsValue *rval)
+{
+ double d;
+
+ swfdec_movie_update (movie);
+ d = rint (movie->extents.y1 - movie->extents.y0);
+ d = SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) d);
+ SWFDEC_AS_VALUE_SET_NUMBER (rval, d);
+}
+
+static void
+mc_height_set (SwfdecMovie *movie, const SwfdecAsValue *val)
+{
+ double d, cur;
+
+ /* property was readonly in Flash 4 and before */
+ if (SWFDEC_AS_OBJECT (movie)->context->version < 5)
+ return;
+ d = swfdec_as_value_to_number (SWFDEC_AS_OBJECT (movie)->context, val);
+ if (!isfinite (d)) {
+ SWFDEC_WARNING ("trying to set height to a non-finite value, ignoring");
+ return;
+ }
+ swfdec_movie_update (movie);
+ movie->modified = TRUE;
+ cur = rint (movie->original_extents.y1 - movie->original_extents.y0);
+ cur = SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) cur);
+ if (cur != 0) {
+ d = 100 * d / cur;
+ if (d == movie->yscale)
+ return;
+ swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
+ movie->yscale = d;
+ } else {
+ swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
+ movie->xscale = 0;
+ movie->yscale = 0;
+ }
+}
+
+static void
+mc_rotation_get (SwfdecMovie *movie, SwfdecAsValue *rval)
+{
+ SWFDEC_AS_VALUE_SET_NUMBER (rval, movie->rotation);
+}
+
+static void
+mc_rotation_set (SwfdecMovie *movie, const SwfdecAsValue *val)
+{
+ double d;
+
+ /* FIXME: Flash 4 handles this differently */
+ d = swfdec_as_value_to_number (SWFDEC_AS_OBJECT (movie)->context, val);
+ if (isnan (d)) {
+ SWFDEC_WARNING ("setting rotation to NaN - not allowed");
+ return;
+ }
+ d = fmod (d, 360.0);
+ if (d > 180.0)
+ d -= 360.0;
+ if (d < -180.0)
+ d += 360.0;
+ if (SWFDEC_AS_OBJECT (movie)->context->version < 5) {
+ if (!isfinite (d))
+ return;
+ SWFDEC_ERROR ("FIXME: implement correct rounding errors here");
+ }
+ movie->modified = TRUE;
+ if (movie->rotation != d) {
+ swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
+ movie->rotation = d;
+ }
+}
+
+static void
+mc_xmouse_get (SwfdecMovie *movie, SwfdecAsValue *rval)
+{
+ double x, y;
+
+ swfdec_movie_get_mouse (movie, &x, &y);
+ x = SWFDEC_TWIPS_TO_DOUBLE (rint (x));
+ SWFDEC_AS_VALUE_SET_NUMBER (rval, x);
+}
+
+static void
+mc_ymouse_get (SwfdecMovie *movie, SwfdecAsValue *rval)
+{
+ double x, y;
+
+ swfdec_movie_get_mouse (movie, &x, &y);
+ y = SWFDEC_TWIPS_TO_DOUBLE (rint (y));
+ SWFDEC_AS_VALUE_SET_NUMBER (rval, y);
+}
+
+static void
+mc_parent (SwfdecMovie *movie, SwfdecAsValue *rval)
+{
+ if (movie->parent) {
+ SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (movie->parent));
+ } else {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (rval);
+ }
+}
+
+static void
+mc_root (SwfdecMovie *movie, SwfdecAsValue *rval)
+{
+ movie = swfdec_movie_get_root (movie);
+ SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (movie));
+}
+
+static void
+mc_target_get (SwfdecMovie *movie, SwfdecAsValue *rval)
+{
+ GString *s;
+
+ s = g_string_new ("");
+ while (movie->parent) {
+ g_string_prepend (s, movie->name);
+ g_string_prepend_c (s, '/');
+ movie = movie->parent;
+ }
+ if (s->len == 0) {
+ SWFDEC_AS_VALUE_SET_STRING (rval, SWFDEC_AS_STR_SLASH);
+ g_string_free (s, TRUE);
+ } else {
+ SWFDEC_AS_VALUE_SET_STRING (rval, swfdec_as_context_give_string (
+ SWFDEC_AS_OBJECT (movie)->context, g_string_free (s, FALSE)));
+ }
+}
+
+static void
+mc_url_get (SwfdecMovie *movie, SwfdecAsValue *rval)
+{
+ SWFDEC_AS_VALUE_SET_STRING (rval, swfdec_as_context_get_string (
+ SWFDEC_AS_OBJECT (movie)->context,
+ swfdec_url_get_url (swfdec_loader_get_url (movie->resource->loader))));
+}
+
+struct {
+ gboolean needs_movie;
+ const char *name;
+ void (* get) (SwfdecMovie *movie, SwfdecAsValue *ret);
+ void (* set) (SwfdecMovie *movie, const SwfdecAsValue *val);
+} swfdec_movieclip_props[] = {
+ { 0, SWFDEC_AS_STR__x, mc_x_get, mc_x_set },
+ { 0, SWFDEC_AS_STR__y, mc_y_get, mc_y_set },
+ { 0, SWFDEC_AS_STR__xscale, mc_xscale_get, mc_xscale_set },
+ { 0, SWFDEC_AS_STR__yscale, mc_yscale_get, mc_yscale_set },
+ { 1, SWFDEC_AS_STR__currentframe,mc_currentframe, NULL },
+ { 1, SWFDEC_AS_STR__totalframes, mc_totalframes, NULL },
+ { 0, SWFDEC_AS_STR__alpha, mc_alpha_get, mc_alpha_set },
+ { 0, SWFDEC_AS_STR__visible, mc_visible_get, mc_visible_set },
+ { 0, SWFDEC_AS_STR__width, mc_width_get, mc_width_set },
+ { 0, SWFDEC_AS_STR__height, mc_height_get, mc_height_set },
+ { 0, SWFDEC_AS_STR__rotation, mc_rotation_get, mc_rotation_set },
+ { 1, SWFDEC_AS_STR__target, mc_target_get, NULL }, //"_target"
+ { 1, SWFDEC_AS_STR__framesloaded,mc_framesloaded, NULL},
+ { 0, SWFDEC_AS_STR__name, mc_name_get, mc_name_set },
+ { 1, SWFDEC_AS_STR__droptarget, NULL, NULL }, //"_droptarget"
+ { 0, SWFDEC_AS_STR__url, mc_url_get, NULL },
+ { 0, SWFDEC_AS_STR__highquality, NULL, NULL }, //"_highquality"
+ { 0, SWFDEC_AS_STR__focusrect, NULL, NULL }, //"_focusrect"
+ { 0, SWFDEC_AS_STR__soundbuftime,NULL, NULL }, //"_soundbuftime"
+ { 0, SWFDEC_AS_STR__quality, NULL, NULL }, //"_quality"
+ { 0, SWFDEC_AS_STR__xmouse, mc_xmouse_get, NULL },
+ { 0, SWFDEC_AS_STR__ymouse, mc_ymouse_get, NULL },
+ { 0, SWFDEC_AS_STR__parent, mc_parent, NULL },
+ { 0, SWFDEC_AS_STR__root, mc_root, NULL },
+};
+
+static inline int
+swfdec_movie_get_asprop_index (SwfdecMovie *movie, const char *name)
+{
+ guint i;
+
+ if (name < SWFDEC_AS_STR__x || name > SWFDEC_AS_STR__root)
+ return -1;
+
+ for (i = 0; i < G_N_ELEMENTS (swfdec_movieclip_props); i++) {
+ if (swfdec_movieclip_props[i].name == name) {
+ if (swfdec_movieclip_props[i].needs_movie && !SWFDEC_IS_SPRITE_MOVIE (movie))
+ return -1;
+ if (swfdec_movieclip_props[i].get == NULL) {
+ SWFDEC_ERROR ("property %s not implemented", name);
+ }
+ return i;
+ }
+ }
+ g_assert_not_reached ();
+ return -1;
+}
+
+gboolean
+swfdec_movie_set_asprop (SwfdecMovie *movie, const char *name, const SwfdecAsValue *val)
+{
+ int i;
+
+ i = swfdec_movie_get_asprop_index (movie, name);
+ if (i == -1)
+ return FALSE;
+ if (swfdec_movieclip_props[i].set != NULL) {
+ swfdec_movieclip_props[i].set (movie, val);
+ }
+ return TRUE;
+}
+
+gboolean
+swfdec_movie_get_asprop (SwfdecMovie *movie, const char *name, SwfdecAsValue *val)
+{
+ int i;
+
+ i = swfdec_movie_get_asprop_index (movie, name);
+ if (i == -1)
+ return FALSE;
+ if (swfdec_movieclip_props[i].get != NULL) {
+ swfdec_movieclip_props[i].get (movie, val);
+ } else {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (val);
+ }
+ return TRUE;
+}
+
diff --git a/swfdec/swfdec_movie_clip_loader.c b/swfdec/swfdec_movie_clip_loader.c
new file mode 100644
index 0000000..77d8704
--- /dev/null
+++ b/swfdec/swfdec_movie_clip_loader.c
@@ -0,0 +1,127 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_movie_clip_loader.h"
+#include "swfdec_as_array.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_decoder.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_resource.h"
+
+
+G_DEFINE_TYPE (SwfdecMovieClipLoader, swfdec_movie_clip_loader, SWFDEC_TYPE_AS_OBJECT)
+
+static void
+swfdec_movie_clip_loader_class_init (SwfdecMovieClipLoaderClass *klass)
+{
+}
+
+static void
+swfdec_movie_clip_loader_init (SwfdecMovieClipLoader *movie_clip_loader)
+{
+}
+
+SWFDEC_AS_CONSTRUCTOR (112, 0, swfdec_movie_clip_loader_construct, swfdec_movie_clip_loader_get_type)
+void
+swfdec_movie_clip_loader_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecAsValue val;
+ SwfdecAsObject *array;
+
+ if (!swfdec_as_context_is_constructing (cx))
+ return;
+
+ array = swfdec_as_array_new (cx);
+ if (array == NULL)
+ return;
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, object);
+ swfdec_as_array_push (SWFDEC_AS_ARRAY (array), &val);
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, array);
+ swfdec_as_object_set_variable_and_flags (object, SWFDEC_AS_STR__listeners,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+}
+
+SWFDEC_AS_NATIVE (112, 100, swfdec_movie_clip_loader_loadClip)
+void
+swfdec_movie_clip_loader_loadClip (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovieClipLoader *loader;
+ const char *url, *target;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE_CLIP_LOADER, &loader, "ss", &url, &target);
+
+ swfdec_resource_load (SWFDEC_PLAYER (cx), target, url,
+ SWFDEC_LOADER_REQUEST_DEFAULT, NULL, loader, TRUE);
+}
+
+SWFDEC_AS_NATIVE (112, 102, swfdec_movie_clip_loader_unloadClip)
+void
+swfdec_movie_clip_loader_unloadClip (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovieClipLoader *loader;
+ const char *target;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE_CLIP_LOADER, &loader, "s", &target);
+
+ swfdec_resource_load (SWFDEC_PLAYER (cx), target, "",
+ SWFDEC_LOADER_REQUEST_DEFAULT, NULL, loader, TRUE);
+}
+
+SWFDEC_AS_NATIVE (112, 101, swfdec_movie_clip_loader_getProgress)
+void
+swfdec_movie_clip_loader_getProgress (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovieClipLoader *loader;
+ SwfdecMovie *movie;
+ SwfdecAsObject *ret;
+ const char *target;
+ SwfdecResource *resource;
+ SwfdecAsValue loaded, total;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE_CLIP_LOADER, &loader, "s", &target);
+
+ movie = swfdec_player_get_movie_from_string (SWFDEC_PLAYER (cx), target);
+ if (movie == NULL)
+ return;
+ ret = swfdec_as_object_new_empty (cx);
+ if (ret == NULL)
+ return;
+ SWFDEC_AS_VALUE_SET_OBJECT (rval, ret);
+ resource = swfdec_movie_get_own_resource (movie);
+ if (resource == NULL || resource->decoder == NULL) {
+ SWFDEC_AS_VALUE_SET_INT (&loaded, 0);
+ SWFDEC_AS_VALUE_SET_INT (&total, 0);
+ } else {
+ SWFDEC_AS_VALUE_SET_INT (&loaded, resource->decoder->bytes_loaded);
+ SWFDEC_AS_VALUE_SET_INT (&total, resource->decoder->bytes_total);
+ }
+ swfdec_as_object_set_variable (ret, SWFDEC_AS_STR_bytesLoaded, &loaded);
+ swfdec_as_object_set_variable (ret, SWFDEC_AS_STR_bytesTotal, &total);
+}
+
diff --git a/swfdec/swfdec_movie_clip_loader.h b/swfdec/swfdec_movie_clip_loader.h
new file mode 100644
index 0000000..9ef0d1c
--- /dev/null
+++ b/swfdec/swfdec_movie_clip_loader.h
@@ -0,0 +1,51 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_MOVIE_CLIP_LOADER_H_
+#define _SWFDEC_MOVIE_CLIP_LOADER_H_
+
+#include <libswfdec/swfdec_as_object.h>
+
+G_BEGIN_DECLS
+
+//typedef struct _SwfdecMovieClipLoader SwfdecMovieClipLoader;
+typedef struct _SwfdecMovieClipLoaderClass SwfdecMovieClipLoaderClass;
+
+#define SWFDEC_TYPE_MOVIE_CLIP_LOADER (swfdec_movie_clip_loader_get_type())
+#define SWFDEC_IS_MOVIE_CLIP_LOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_MOVIE_CLIP_LOADER))
+#define SWFDEC_IS_MOVIE_CLIP_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_MOVIE_CLIP_LOADER))
+#define SWFDEC_MOVIE_CLIP_LOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_MOVIE_CLIP_LOADER, SwfdecMovieClipLoader))
+#define SWFDEC_MOVIE_CLIP_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_MOVIE_CLIP_LOADER, SwfdecMovieClipLoaderClass))
+#define SWFDEC_MOVIE_CLIP_LOADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_MOVIE_CLIP_LOADER, SwfdecMovieClipLoaderClass))
+
+struct _SwfdecMovieClipLoader
+{
+ SwfdecAsObject object;
+};
+
+struct _SwfdecMovieClipLoaderClass
+{
+ SwfdecAsObjectClass object_class;
+};
+
+GType swfdec_movie_clip_loader_get_type (void);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_net_connection.c b/swfdec/swfdec_net_connection.c
new file mode 100644
index 0000000..ad16614
--- /dev/null
+++ b/swfdec/swfdec_net_connection.c
@@ -0,0 +1,186 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include "swfdec_net_connection.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_object.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_internal.h"
+
+/*** SwfdecNetConnection ***/
+
+G_DEFINE_TYPE (SwfdecNetConnection, swfdec_net_connection, SWFDEC_TYPE_AS_OBJECT)
+
+static void
+swfdec_net_connection_dispose (GObject *object)
+{
+ SwfdecNetConnection *net_connection = SWFDEC_NET_CONNECTION (object);
+
+ g_free (net_connection->url);
+ net_connection->url = NULL;
+
+ G_OBJECT_CLASS (swfdec_net_connection_parent_class)->dispose (object);
+}
+
+static void
+swfdec_net_connection_class_init (SwfdecNetConnectionClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = swfdec_net_connection_dispose;
+}
+
+static void
+swfdec_net_connection_init (SwfdecNetConnection *net_connection)
+{
+}
+
+static void
+swfdec_net_connection_onstatus (SwfdecNetConnection *conn, const char *code,
+ const char *level, const char *description)
+{
+ SwfdecAsValue value;
+ SwfdecAsObject *info;
+
+ info = swfdec_as_object_new (SWFDEC_AS_OBJECT (conn)->context);
+ if (info == NULL)
+ return;
+ SWFDEC_AS_VALUE_SET_STRING (&value, code);
+ swfdec_as_object_set_variable (info, SWFDEC_AS_STR_code, &value);
+ SWFDEC_AS_VALUE_SET_STRING (&value, level);
+ swfdec_as_object_set_variable (info, SWFDEC_AS_STR_level, &value);
+ if (description) {
+ SWFDEC_AS_VALUE_SET_STRING (&value, description);
+ swfdec_as_object_set_variable (info, SWFDEC_AS_STR_description, &value);
+ }
+ SWFDEC_AS_VALUE_SET_OBJECT (&value, info);
+ swfdec_as_object_call (SWFDEC_AS_OBJECT (conn), SWFDEC_AS_STR_onStatus, 1, &value, NULL);
+}
+
+SwfdecNetConnection *
+swfdec_net_connection_new (SwfdecAsContext *context)
+{
+ SwfdecNetConnection *conn;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
+
+ if (!swfdec_as_context_use_mem (context, sizeof (SwfdecNetConnection)))
+ return NULL;
+ conn = g_object_new (SWFDEC_TYPE_NET_CONNECTION, NULL);
+ swfdec_as_object_add (SWFDEC_AS_OBJECT (conn), context, sizeof (SwfdecNetConnection));
+
+ return conn;
+}
+
+void
+swfdec_net_connection_connect (SwfdecNetConnection *conn, const char *url)
+{
+ g_return_if_fail (SWFDEC_IS_NET_CONNECTION (conn));
+
+ g_free (conn->url);
+ conn->url = g_strdup (url);
+ if (url) {
+ SWFDEC_ERROR ("FIXME: using NetConnection with non-null URLs is not implemented");
+ }
+ swfdec_net_connection_onstatus (conn, SWFDEC_AS_STR_NetConnection_Connect_Success,
+ SWFDEC_AS_STR_status, NULL);
+}
+
+/*** AS CODE ***/
+
+SWFDEC_AS_NATIVE (2100, 0, swfdec_net_connection_do_connect)
+void
+swfdec_net_connection_do_connect (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecNetConnection *conn;
+ SwfdecAsValue val;
+ const char *url;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_NET_CONNECTION, &conn, "v", &val);
+
+ if (SWFDEC_AS_VALUE_IS_STRING (&val)) {
+ url = SWFDEC_AS_VALUE_GET_STRING (&val);
+ } else if (SWFDEC_AS_VALUE_IS_NULL (&val)) {
+ url = NULL;
+ } else {
+ SWFDEC_FIXME ("untested argument to NetConnection.connect: type %u", val.type);
+ url = NULL;
+ }
+ swfdec_net_connection_connect (conn, url);
+}
+
+SWFDEC_AS_NATIVE (2100, 1, swfdec_net_connection_do_close)
+void
+swfdec_net_connection_do_close (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("NetConnection.close");
+}
+
+SWFDEC_AS_NATIVE (2100, 2, swfdec_net_connection_do_call)
+void
+swfdec_net_connection_do_call (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("NetConnection.call");
+}
+
+SWFDEC_AS_NATIVE (2100, 3, swfdec_net_connection_do_addHeader)
+void
+swfdec_net_connection_do_addHeader (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("NetConnection.addHeader");
+}
+
+SWFDEC_AS_NATIVE (2100, 4, swfdec_net_connection_get_connectedProxyType)
+void
+swfdec_net_connection_get_connectedProxyType (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("NetConnection.connectedProxyType (get)");
+}
+
+SWFDEC_AS_NATIVE (2100, 5, swfdec_net_connection_get_usingTLS)
+void
+swfdec_net_connection_get_usingTLS (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("NetConnection.usingTLS (get)");
+}
+
+// not actually the constructor, but called from the constructor
+SWFDEC_AS_CONSTRUCTOR (2100, 200, swfdec_net_connection_construct, swfdec_net_connection_get_type)
+void
+swfdec_net_connection_construct (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ // FIXME: Set contentType and possible do some other stuff too
+}
diff --git a/swfdec/swfdec_net_connection.h b/swfdec/swfdec_net_connection.h
new file mode 100644
index 0000000..e7bd3fa
--- /dev/null
+++ b/swfdec/swfdec_net_connection.h
@@ -0,0 +1,57 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_NET_CONNECTION_H_
+#define _SWFDEC_NET_CONNECTION_H_
+
+#include <libswfdec/swfdec_as_object.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _SwfdecNetConnection SwfdecNetConnection;
+typedef struct _SwfdecNetConnectionClass SwfdecNetConnectionClass;
+
+#define SWFDEC_TYPE_NET_CONNECTION (swfdec_net_connection_get_type())
+#define SWFDEC_IS_NET_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_NET_CONNECTION))
+#define SWFDEC_IS_NET_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_NET_CONNECTION))
+#define SWFDEC_NET_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_NET_CONNECTION, SwfdecNetConnection))
+#define SWFDEC_NET_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_NET_CONNECTION, SwfdecNetConnectionClass))
+#define SWFDEC_NET_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_NET_CONNECTION, SwfdecNetConnectionClass))
+
+struct _SwfdecNetConnection {
+ SwfdecAsObject object;
+
+ char * url; /* url for this net_connection or NULL for none */
+};
+
+struct _SwfdecNetConnectionClass {
+ SwfdecAsObjectClass object_class;
+};
+
+GType swfdec_net_connection_get_type (void);
+
+SwfdecNetConnection * swfdec_net_connection_new (SwfdecAsContext * context);
+
+void swfdec_net_connection_connect (SwfdecNetConnection * conn,
+ const char * url);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_net_stream.c b/swfdec/swfdec_net_stream.c
new file mode 100644
index 0000000..a8ec140
--- /dev/null
+++ b/swfdec/swfdec_net_stream.c
@@ -0,0 +1,662 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+#include "swfdec_net_stream.h"
+#include "swfdec_amf.h"
+#include "swfdec_as_frame_internal.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_audio_flv.h"
+#include "swfdec_debug.h"
+#include "swfdec_loader_internal.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_resource.h"
+#include "swfdec_sandbox.h"
+#include "swfdec_stream_target.h"
+
+/* NB: code and level must be rooted gc-strings */
+static void
+swfdec_net_stream_onstatus (SwfdecNetStream *stream, const char *code, const char *level)
+{
+ SwfdecAsValue val;
+ SwfdecAsObject *object;
+
+ swfdec_sandbox_use (stream->sandbox);
+ object = swfdec_as_object_new (SWFDEC_AS_OBJECT (stream)->context);
+ if (!object) {
+ swfdec_sandbox_unuse (stream->sandbox);
+ return;
+ }
+ SWFDEC_INFO ("emitting onStatus for %s %s", level, code);
+ SWFDEC_AS_VALUE_SET_STRING (&val, code);
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_code, &val);
+ SWFDEC_AS_VALUE_SET_STRING (&val, level);
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_level, &val);
+
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, object);
+ swfdec_as_object_call (SWFDEC_AS_OBJECT (stream), SWFDEC_AS_STR_onStatus, 1, &val, NULL);
+ swfdec_sandbox_unuse (stream->sandbox);
+}
+
+static cairo_surface_t *
+swfdec_net_stream_decode_video (SwfdecNetStream *stream, SwfdecBuffer *buffer)
+{
+ SwfdecVideoDecoder *decoder = stream->decoder;
+ cairo_surface_t *surface;
+
+ if (decoder == NULL)
+ return NULL;
+
+ if (decoder->codec == SWFDEC_VIDEO_CODEC_VP6 ||
+ decoder->codec == SWFDEC_VIDEO_CODEC_VP6_ALPHA) {
+ guint wsub, hsub;
+ SwfdecBuffer *tmp;
+ if (buffer->length == 0) {
+ SWFDEC_ERROR ("0-byte VP6 video image buffer?");
+ return NULL;
+ }
+ wsub = *buffer->data;
+ hsub = wsub & 0xF;
+ wsub >>= 4;
+ tmp = swfdec_buffer_new_subbuffer (buffer, 1, buffer->length - 1);
+ surface = swfdec_video_decoder_decode (decoder, tmp);
+ swfdec_buffer_unref (tmp);
+ if (hsub || wsub) {
+ SWFDEC_FIXME ("need to subtract %ux%u pixels", wsub, hsub);
+ }
+ } else {
+ surface = swfdec_video_decoder_decode (decoder, buffer);
+ }
+ return surface;
+}
+
+static void swfdec_net_stream_update_playing (SwfdecNetStream *stream);
+static void
+swfdec_net_stream_video_goto (SwfdecNetStream *stream, guint timestamp)
+{
+ SwfdecBuffer *buffer;
+ guint format;
+ cairo_surface_t *old;
+ gboolean process_events;
+ guint process_events_from;
+
+ SWFDEC_LOG ("goto %ums", timestamp);
+ process_events = timestamp == stream->next_time;
+ process_events_from = MIN (stream->next_time, stream->current_time + 1);
+ old = stream->surface;
+ if (stream->surface) {
+ cairo_surface_destroy (stream->surface);
+ stream->surface = NULL;
+ }
+ if (stream->flvdecoder->video) {
+ buffer = swfdec_flv_decoder_get_video (stream->flvdecoder, timestamp,
+ FALSE, &format, &stream->current_time, &stream->next_time);
+ } else {
+ buffer = NULL;
+ }
+ if (buffer == NULL) {
+ SWFDEC_ERROR ("got no buffer - no video available?");
+ } else {
+ if (format != stream->format) {
+ if (stream->decoder)
+ swfdec_video_decoder_free (stream->decoder);
+ stream->format = format;
+ stream->decoder = swfdec_video_decoder_new (format);
+ }
+ stream->surface = swfdec_net_stream_decode_video (stream, buffer);
+ if (stream->surface) {
+ GList *walk;
+ for (walk = stream->movies; walk; walk = walk->next) {
+ swfdec_video_movie_new_image (walk->data);
+ }
+ }
+ }
+ if (stream->next_time <= stream->current_time) {
+ if (swfdec_flv_decoder_is_eof (stream->flvdecoder)) {
+ swfdec_net_stream_onstatus (stream, SWFDEC_AS_STR_NetStream_Play_Stop, SWFDEC_AS_STR_status);
+ } else {
+ stream->buffering = TRUE;
+ swfdec_net_stream_onstatus (stream, SWFDEC_AS_STR_NetStream_Buffer_Empty,
+ SWFDEC_AS_STR_status);
+ }
+ swfdec_net_stream_update_playing (stream);
+ }
+ if (process_events) {
+ while (process_events_from <= stream->current_time) {
+ SwfdecAsValue name, value;
+ SwfdecBits bits;
+ SwfdecBuffer *event = swfdec_flv_decoder_get_data (stream->flvdecoder, process_events_from, &process_events_from);
+ if (!event)
+ break;
+ SWFDEC_LOG ("processing event from timestamp %u", process_events_from);
+ process_events_from++; /* increase so we get the next event next time */
+ swfdec_bits_init (&bits, event);
+ swfdec_sandbox_use (stream->sandbox);
+ if (swfdec_amf_parse (SWFDEC_AS_OBJECT (stream)->context, &bits, 2,
+ SWFDEC_AMF_STRING, &name, SWFDEC_AMF_MIXED_ARRAY, &value) != 2) {
+ SWFDEC_ERROR ("could not parse data tag");
+ } else {
+ swfdec_as_object_call (SWFDEC_AS_OBJECT (stream),
+ SWFDEC_AS_VALUE_GET_STRING (&name), 1, &value, NULL);
+ }
+ swfdec_sandbox_unuse (stream->sandbox);
+ }
+ }
+}
+
+static void
+swfdec_net_stream_timeout (SwfdecTimeout *timeout)
+{
+ SwfdecNetStream *stream = SWFDEC_NET_STREAM ((void *) ((guchar *) timeout - G_STRUCT_OFFSET (SwfdecNetStream, timeout)));
+
+ SWFDEC_LOG ("timeout fired");
+ stream->timeout.callback = NULL;
+ swfdec_net_stream_video_goto (stream, stream->next_time);
+ if (stream->next_time > stream->current_time) {
+ SWFDEC_LOG ("readding timeout");
+ stream->timeout.timestamp += SWFDEC_MSECS_TO_TICKS (stream->next_time - stream->current_time);
+ stream->timeout.callback = swfdec_net_stream_timeout;
+ swfdec_player_add_timeout (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (stream)->context), &stream->timeout);
+ } else {
+ if (stream->audio) {
+ /* FIXME: just unref and let it take care of removing itself? */
+ SWFDEC_LOG ("stopping audio due to EOS");
+ swfdec_audio_remove (stream->audio);
+ g_object_unref (stream->audio);
+ stream->audio = NULL;
+ }
+ }
+}
+
+static void
+swfdec_net_stream_update_playing (SwfdecNetStream *stream)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (stream)->context);
+ gboolean should_play;
+
+ should_play = stream->playing; /* checks user-set play/pause */
+ should_play &= !stream->buffering; /* checks enough data is available */
+ should_play &= stream->flvdecoder != NULL; /* checks there even is something to play */
+ should_play &= stream->next_time > stream->current_time; /* checks if EOF */
+ if (should_play && stream->timeout.callback == NULL) {
+ SWFDEC_DEBUG ("starting playback");
+ stream->timeout.callback = swfdec_net_stream_timeout;
+ stream->timeout.timestamp = player->priv->time + SWFDEC_MSECS_TO_TICKS (stream->next_time - stream->current_time);
+ swfdec_player_add_timeout (player, &stream->timeout);
+ if (stream->flvdecoder->audio) {
+ g_assert (stream->audio == NULL);
+ SWFDEC_LOG ("starting audio");
+ stream->audio = swfdec_audio_flv_new (player,
+ stream->flvdecoder, stream->current_time);
+ } else {
+ SWFDEC_LOG ("no audio");
+ }
+ } else if (!should_play && stream->timeout.callback != NULL) {
+ if (stream->audio) {
+ SWFDEC_LOG ("stopping audio");
+ swfdec_audio_remove (stream->audio);
+ g_object_unref (stream->audio);
+ stream->audio = NULL;
+ }
+ swfdec_player_remove_timeout (player, &stream->timeout);
+ stream->timeout.callback = NULL;
+ SWFDEC_DEBUG ("stopping playback");
+ }
+}
+
+/*** SWFDEC_STREAM_TARGET interface ***/
+
+static SwfdecPlayer *
+swfdec_net_stream_stream_target_get_player (SwfdecStreamTarget *target)
+{
+ return SWFDEC_PLAYER (SWFDEC_AS_OBJECT (target)->context);
+}
+
+static void
+swfdec_net_stream_stream_target_error (SwfdecStreamTarget *target,
+ SwfdecStream *stream)
+{
+ SwfdecNetStream *ns = SWFDEC_NET_STREAM (target);
+
+ if (ns->flvdecoder == NULL)
+ swfdec_net_stream_onstatus (ns, SWFDEC_AS_STR_NetStream_Play_StreamNotFound,
+ SWFDEC_AS_STR_error);
+}
+
+static void
+swfdec_net_stream_stream_target_recheck (SwfdecNetStream *stream)
+{
+ if (stream->buffering) {
+ guint first, last;
+ if (swfdec_flv_decoder_get_video_info (stream->flvdecoder, &first, &last)) {
+ guint current = MAX (first, stream->current_time);
+ if (current + stream->buffer_time <= last) {
+ swfdec_net_stream_video_goto (stream, current);
+ stream->buffering = FALSE;
+ swfdec_net_stream_onstatus (stream, SWFDEC_AS_STR_NetStream_Buffer_Full,
+ SWFDEC_AS_STR_status);
+ }
+ } else {
+ SWFDEC_ERROR ("no video stream, how do we update buffering?");
+ }
+ }
+ swfdec_net_stream_update_playing (stream);
+}
+
+static void
+swfdec_net_stream_stream_target_parse (SwfdecStreamTarget *target,
+ SwfdecStream *stream)
+{
+ SwfdecNetStream *ns = SWFDEC_NET_STREAM (target);
+ SwfdecBufferQueue *queue;
+ SwfdecStatus status;
+
+ if (ns->flvdecoder == NULL) {
+ /* FIXME: add mp3 support */
+ ns->flvdecoder = g_object_new (SWFDEC_TYPE_FLV_DECODER, NULL);
+ SWFDEC_DECODER (ns->flvdecoder)->player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (ns)->context);
+ swfdec_net_stream_onstatus (ns, SWFDEC_AS_STR_NetStream_Play_Start,
+ SWFDEC_AS_STR_status);
+ swfdec_loader_set_data_type (SWFDEC_LOADER (stream), SWFDEC_LOADER_DATA_FLV);
+ }
+
+ status = SWFDEC_STATUS_OK;
+ queue = swfdec_stream_get_queue (stream);
+ do {
+ SwfdecBuffer *buffer = swfdec_buffer_queue_pull_buffer (queue);
+ if (buffer == NULL)
+ break;
+ status &= ~SWFDEC_STATUS_NEEDBITS;
+ status |= swfdec_decoder_parse (SWFDEC_DECODER (ns->flvdecoder), buffer);
+ } while ((status & (SWFDEC_STATUS_ERROR | SWFDEC_STATUS_EOF)) == 0);
+
+ if (status & SWFDEC_STATUS_IMAGE)
+ swfdec_net_stream_stream_target_recheck (ns);
+}
+
+static void
+swfdec_net_stream_stream_target_close (SwfdecStreamTarget *target,
+ SwfdecStream *stream)
+{
+ SwfdecNetStream *ns = SWFDEC_NET_STREAM (target);
+ guint first, last;
+
+ swfdec_decoder_eof (SWFDEC_DECODER (ns->flvdecoder));
+ swfdec_net_stream_onstatus (ns, SWFDEC_AS_STR_NetStream_Buffer_Flush,
+ SWFDEC_AS_STR_status);
+ swfdec_net_stream_video_goto (ns, ns->current_time);
+ ns->buffering = FALSE;
+ if (swfdec_flv_decoder_get_video_info (ns->flvdecoder, &first, &last) &&
+ ns->current_time + ns->buffer_time <= last) {
+ swfdec_net_stream_onstatus (ns, SWFDEC_AS_STR_NetStream_Buffer_Full,
+ SWFDEC_AS_STR_status);
+ }
+ swfdec_net_stream_stream_target_recheck (ns);
+}
+
+static void
+swfdec_net_stream_stream_target_init (SwfdecStreamTargetInterface *iface)
+{
+ iface->get_player = swfdec_net_stream_stream_target_get_player;
+ iface->parse = swfdec_net_stream_stream_target_parse;
+ iface->close = swfdec_net_stream_stream_target_close;
+ iface->error = swfdec_net_stream_stream_target_error;
+}
+
+/*** SWFDEC VIDEO MOVIE INPUT ***/
+
+static void
+swfdec_net_stream_input_connect (SwfdecVideoMovieInput *input, SwfdecVideoMovie *movie)
+{
+ SwfdecNetStream *stream = SWFDEC_NET_STREAM ((void *)((guchar *) input - G_STRUCT_OFFSET (SwfdecNetStream, input)));
+
+ stream->movies = g_list_prepend (stream->movies, movie);
+ g_object_ref (stream);
+}
+
+static void
+swfdec_net_stream_input_disconnect (SwfdecVideoMovieInput *input, SwfdecVideoMovie *movie)
+{
+ SwfdecNetStream *stream = SWFDEC_NET_STREAM ((void *)((guchar *) input - G_STRUCT_OFFSET (SwfdecNetStream, input)));
+
+ stream->movies = g_list_remove (stream->movies, movie);
+ g_object_unref (stream);
+}
+
+static cairo_surface_t *
+swfdec_net_stream_input_get_image (SwfdecVideoMovieInput *input)
+{
+ SwfdecNetStream *stream = SWFDEC_NET_STREAM ((void *)((guchar *) input - G_STRUCT_OFFSET (SwfdecNetStream, input)));
+
+ return stream->surface;
+}
+
+/*** SWFDEC_NET_STREAM ***/
+
+G_DEFINE_TYPE_WITH_CODE (SwfdecNetStream, swfdec_net_stream, SWFDEC_TYPE_AS_OBJECT,
+ G_IMPLEMENT_INTERFACE (SWFDEC_TYPE_STREAM_TARGET, swfdec_net_stream_stream_target_init))
+
+static void
+swfdec_net_stream_dispose (GObject *object)
+{
+ SwfdecNetStream *stream = SWFDEC_NET_STREAM (object);
+
+ swfdec_net_stream_set_playing (stream, FALSE);
+ if (stream->surface) {
+ cairo_surface_destroy (stream->surface);
+ stream->surface = NULL;
+ }
+ if (stream->decoder) {
+ swfdec_video_decoder_free (stream->decoder);
+ stream->decoder = NULL;
+ }
+ swfdec_net_stream_set_loader (stream, NULL);
+ g_assert (stream->movies == NULL);
+ g_free (stream->requested_url);
+ stream->requested_url = NULL;
+
+ G_OBJECT_CLASS (swfdec_net_stream_parent_class)->dispose (object);
+}
+
+static gboolean
+swfdec_net_stream_get_variable (SwfdecAsObject *object, SwfdecAsObject *orig,
+ const char *variable, SwfdecAsValue *val, guint *flags)
+{
+ SwfdecNetStream *stream;
+
+ if (SWFDEC_AS_OBJECT_CLASS (swfdec_net_stream_parent_class)->get (object, orig, variable, val, flags))
+ return TRUE;
+
+ stream = SWFDEC_NET_STREAM (object);
+ /* FIXME: need case insensitive comparisons? */
+ if (variable == SWFDEC_AS_STR_time) {
+ guint msecs;
+ if (stream->flvdecoder == NULL ||
+ !swfdec_flv_decoder_get_video_info (stream->flvdecoder, &msecs, NULL)) {
+ SWFDEC_AS_VALUE_SET_INT (val, 0);
+ } else {
+ if (msecs >= stream->current_time)
+ msecs = 0;
+ else
+ msecs = stream->current_time - msecs;
+ SWFDEC_AS_VALUE_SET_NUMBER (val, msecs / 1000.);
+ }
+ *flags = 0;
+ return TRUE;
+ } else if (variable == SWFDEC_AS_STR_bytesLoaded) {
+ if (stream->loader == NULL)
+ SWFDEC_AS_VALUE_SET_INT (val, 0);
+ else
+ SWFDEC_AS_VALUE_SET_NUMBER (val, swfdec_loader_get_loaded (stream->loader));
+ *flags = 0;
+ return TRUE;
+ } else if (variable == SWFDEC_AS_STR_bytesTotal) {
+ glong bytes;
+ if (stream->loader == NULL) {
+ bytes = 0;
+ } else {
+ bytes = swfdec_loader_get_size (stream->loader);
+ if (bytes < 0)
+ bytes = swfdec_loader_get_loaded (stream->loader);
+ }
+ SWFDEC_AS_VALUE_SET_NUMBER (val, bytes);
+ *flags = 0;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static void
+swfdec_net_stream_mark (SwfdecAsObject *object)
+{
+ SwfdecNetStream *stream = SWFDEC_NET_STREAM (object);
+
+ if (stream->conn)
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (stream->conn));
+ if (stream->sandbox)
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (stream->sandbox));
+
+ SWFDEC_AS_OBJECT_CLASS (swfdec_net_stream_parent_class)->mark (object);
+}
+
+static void
+swfdec_net_stream_class_init (SwfdecNetStreamClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
+
+ object_class->dispose = swfdec_net_stream_dispose;
+
+ asobject_class->get = swfdec_net_stream_get_variable;
+ asobject_class->mark = swfdec_net_stream_mark;
+}
+
+static void
+swfdec_net_stream_init (SwfdecNetStream *stream)
+{
+ stream->input.connect = swfdec_net_stream_input_connect;
+ stream->input.disconnect = swfdec_net_stream_input_disconnect;
+ stream->input.get_image = swfdec_net_stream_input_get_image;
+
+ stream->buffer_time = 100; /* msecs */
+}
+
+SwfdecNetStream *
+swfdec_net_stream_new (SwfdecNetConnection *conn)
+{
+ SwfdecAsContext *context;
+ SwfdecNetStream *stream;
+
+ g_return_val_if_fail (SWFDEC_IS_NET_CONNECTION (conn), NULL);
+
+ context = SWFDEC_AS_OBJECT (conn)->context;
+ if (!swfdec_as_context_use_mem (context, sizeof (SwfdecNetStream)))
+ return NULL;
+ stream = g_object_new (SWFDEC_TYPE_NET_STREAM, NULL);
+ swfdec_as_object_add (SWFDEC_AS_OBJECT (stream), context, sizeof (SwfdecNetStream));
+ stream->conn = conn;
+
+ return stream;
+}
+
+static void
+swfdec_net_stream_load (SwfdecPlayer *player, gboolean allowed, gpointer streamp)
+{
+ SwfdecNetStream *stream = streamp;
+ SwfdecLoader *loader;
+
+ if (allowed) {
+ loader = swfdec_player_load (player, stream->requested_url,
+ SWFDEC_LOADER_REQUEST_DEFAULT, NULL);
+ swfdec_net_stream_set_loader (stream, loader);
+ g_object_unref (loader);
+ } else {
+ SWFDEC_WARNING ("SECURITY: no access to %s from NetStream",
+ stream->requested_url);
+ stream->sandbox = NULL;
+ }
+ g_free (stream->requested_url);
+ stream->requested_url = NULL;
+}
+
+void
+swfdec_net_stream_set_url (SwfdecNetStream *stream, SwfdecSandbox *sandbox, const char *url_string)
+{
+ SwfdecPlayer *player;
+ SwfdecAsContext *cx;
+ SwfdecURL *url;
+
+ g_return_if_fail (SWFDEC_IS_NET_STREAM (stream));
+ g_return_if_fail (SWFDEC_IS_SANDBOX (sandbox));
+
+ cx = SWFDEC_AS_OBJECT (stream)->context;
+ player = SWFDEC_PLAYER (cx);
+
+ if (stream->requested_url != NULL) {
+ SWFDEC_FIXME ("can't load %s - already loading %s, what now?",
+ url_string, stream->requested_url);
+ return;
+ }
+ stream->requested_url = g_strdup (url_string);
+ stream->sandbox = sandbox;
+ if (swfdec_url_path_is_relative (url_string)) {
+ swfdec_net_stream_load (player, TRUE, stream);
+ return;
+ }
+ url = swfdec_player_create_url (player, url_string);
+ if (url == NULL) {
+ swfdec_net_stream_load (player, FALSE, stream);
+ return;
+ }
+ if (swfdec_url_is_local (url)) {
+ swfdec_net_stream_load (player, TRUE, stream);
+ } else {
+ switch (sandbox->type) {
+ case SWFDEC_SANDBOX_REMOTE:
+ swfdec_net_stream_load (player, TRUE, stream);
+ break;
+ case SWFDEC_SANDBOX_LOCAL_NETWORK:
+ case SWFDEC_SANDBOX_LOCAL_TRUSTED:
+ {
+ SwfdecURL *load_url = swfdec_url_new_components (
+ swfdec_url_get_protocol (url), swfdec_url_get_host (url),
+ swfdec_url_get_port (url), "crossdomain.xml", NULL);
+ swfdec_player_allow_or_load (player, url, load_url,
+ swfdec_net_stream_load, stream);
+ swfdec_url_free (load_url);
+ }
+ break;
+ case SWFDEC_SANDBOX_LOCAL_FILE:
+ swfdec_net_stream_load (player, FALSE, stream);
+ break;
+ case SWFDEC_SANDBOX_NONE:
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+ }
+
+ swfdec_url_free (url);
+}
+
+void
+swfdec_net_stream_set_loader (SwfdecNetStream *stream, SwfdecLoader *loader)
+{
+ g_return_if_fail (SWFDEC_IS_NET_STREAM (stream));
+ g_return_if_fail (loader == NULL || SWFDEC_IS_SANDBOX (stream->sandbox));
+ g_return_if_fail (loader == NULL || SWFDEC_IS_LOADER (loader));
+
+ if (stream->loader) {
+ SwfdecStream *lstream = SWFDEC_STREAM (stream->loader);
+ swfdec_stream_close (lstream);
+ swfdec_stream_set_target (lstream, NULL);
+ g_object_unref (lstream);
+ }
+ if (stream->flvdecoder) {
+ g_object_unref (stream->flvdecoder);
+ stream->flvdecoder = NULL;
+ }
+ stream->loader = loader;
+ stream->buffering = TRUE;
+ if (loader) {
+ g_object_ref (loader);
+ swfdec_stream_set_target (SWFDEC_STREAM (loader), SWFDEC_STREAM_TARGET (stream));
+ }
+ swfdec_net_stream_set_playing (stream, TRUE);
+}
+
+void
+swfdec_net_stream_set_playing (SwfdecNetStream *stream, gboolean playing)
+{
+ g_return_if_fail (SWFDEC_IS_NET_STREAM (stream));
+
+ stream->playing = playing;
+
+ swfdec_net_stream_update_playing (stream);
+}
+
+gboolean
+swfdec_net_stream_get_playing (SwfdecNetStream *stream)
+{
+ g_return_val_if_fail (SWFDEC_IS_NET_STREAM (stream), FALSE);
+
+ return stream->playing;
+}
+
+void
+swfdec_net_stream_set_buffer_time (SwfdecNetStream *stream, double secs)
+{
+ g_return_if_fail (SWFDEC_IS_NET_STREAM (stream));
+
+ /* FIXME: is this correct? */
+ if (secs <= 0)
+ return;
+
+ stream->buffer_time = secs * 1000;
+}
+
+double
+swfdec_net_stream_get_buffer_time (SwfdecNetStream *stream)
+{
+ g_return_val_if_fail (SWFDEC_IS_NET_STREAM (stream), 0.1);
+
+ return (double) stream->buffer_time / 1000.0;
+}
+
+void
+swfdec_net_stream_seek (SwfdecNetStream *stream, double secs)
+{
+ guint first, last, msecs;
+
+ g_return_if_fail (SWFDEC_IS_NET_STREAM (stream));
+
+ if (stream->flvdecoder == NULL)
+ return;
+ if (!isfinite (secs) || secs < 0) {
+ SWFDEC_ERROR ("seeking to %g doesn't work", secs);
+ return;
+ }
+ if (!swfdec_flv_decoder_get_video_info (stream->flvdecoder, &first, &last)) {
+ SWFDEC_ERROR ("FIXME: implement seeking in audio only NetStream");
+ return;
+ }
+ msecs = secs * 1000;
+ msecs += first;
+ if (msecs > last)
+ msecs = last;
+ swfdec_flv_decoder_get_video (stream->flvdecoder, msecs, TRUE, NULL, &msecs, NULL);
+ swfdec_net_stream_video_goto (stream, msecs);
+ /* FIXME: this needs to be implemented correctly, but requires changes to audio handling:
+ * - creating a new audio stream will cause attachAudio scripts to lose information
+ * - implementing seek on audio stream requires a SwfdecAudio::changed signal so audio
+ * backends can react correctly.
+ */
+ if (stream->audio) {
+ SWFDEC_WARNING ("FIXME: restarting audio after seek");
+ swfdec_audio_remove (stream->audio);
+ g_object_unref (stream->audio);
+ stream->audio = swfdec_audio_flv_new (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (stream)->context),
+ stream->flvdecoder, stream->current_time);
+ }
+}
+
diff --git a/swfdec/swfdec_net_stream.h b/swfdec/swfdec_net_stream.h
new file mode 100644
index 0000000..943c834
--- /dev/null
+++ b/swfdec/swfdec_net_stream.h
@@ -0,0 +1,99 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_NET_STREAM_H_
+#define _SWFDEC_NET_STREAM_H_
+
+#include <libswfdec/swfdec.h>
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_codec_video.h>
+#include <libswfdec/swfdec_net_connection.h>
+#include <libswfdec/swfdec_flv_decoder.h>
+#include <libswfdec/swfdec_player_internal.h>
+#include <libswfdec/swfdec_sandbox.h>
+#include <libswfdec/swfdec_video_movie.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecNetStream SwfdecNetStream;
+typedef struct _SwfdecNetStreamClass SwfdecNetStreamClass;
+
+#define SWFDEC_TYPE_NET_STREAM (swfdec_net_stream_get_type())
+#define SWFDEC_IS_NET_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_NET_STREAM))
+#define SWFDEC_IS_NET_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_NET_STREAM))
+#define SWFDEC_NET_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_NET_STREAM, SwfdecNetStream))
+#define SWFDEC_NET_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_NET_STREAM, SwfdecNetStreamClass))
+#define SWFDEC_NET_STREAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_NET_STREAM, SwfdecNetStreamClass))
+
+struct _SwfdecNetStream
+{
+ SwfdecAsObject object;
+
+ SwfdecNetConnection * conn; /* connection used for opening streams */
+ char * requested_url; /* URL we have requested that isn't loaded yet */
+ SwfdecLoader * loader; /* input stream */
+ SwfdecSandbox * sandbox; /* sandbox to emit events in */
+ SwfdecFlvDecoder * flvdecoder; /* flv decoder */
+ gboolean playing; /* TRUE if this stream is playing */
+ gboolean buffering; /* TRUE if we're waiting for more input data */
+ gboolean error; /* in error */
+
+ /* properties */
+ guint buffer_time; /* buffering time in msecs */
+
+ /* video decoding */
+ guint current_time; /* current playback timestamp */
+ guint next_time; /* next video image at this timestamp */
+ guint format; /* current format */
+ SwfdecVideoDecoder * decoder; /* decoder used for decoding */
+ cairo_surface_t * surface; /* current image */
+ SwfdecTimeout timeout; /* timeout to advance to */
+ SwfdecVideoMovieInput input; /* used when attaching to a video movie */
+ GList * movies; /* movies we're connected to */
+
+ /* audio */
+ SwfdecAudio * audio; /* audio stream or NULL when not playing */
+};
+
+struct _SwfdecNetStreamClass
+{
+ SwfdecAsObjectClass object_class;
+};
+
+GType swfdec_net_stream_get_type (void);
+
+SwfdecNetStream * swfdec_net_stream_new (SwfdecNetConnection * conn);
+
+void swfdec_net_stream_set_url (SwfdecNetStream * stream,
+ SwfdecSandbox * sandbox,
+ const char * url);
+void swfdec_net_stream_set_loader (SwfdecNetStream * stream,
+ SwfdecLoader * loader);
+void swfdec_net_stream_set_playing (SwfdecNetStream * stream,
+ gboolean playing);
+gboolean swfdec_net_stream_get_playing (SwfdecNetStream * stream);
+void swfdec_net_stream_set_buffer_time (SwfdecNetStream * stream,
+ double secs);
+double swfdec_net_stream_get_buffer_time (SwfdecNetStream * stream);
+void swfdec_net_stream_seek (SwfdecNetStream * stream,
+ double secs);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_net_stream_as.c b/swfdec/swfdec_net_stream_as.c
new file mode 100644
index 0000000..1dce4ba
--- /dev/null
+++ b/swfdec/swfdec_net_stream_as.c
@@ -0,0 +1,187 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_net_stream.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_internal.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_player_internal.h"
+
+SWFDEC_AS_NATIVE (2101, 0, swfdec_net_stream_close)
+void
+swfdec_net_stream_close (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecNetStream *stream;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_NET_STREAM, &stream, "");
+
+ swfdec_net_stream_set_loader (stream, NULL);
+ swfdec_net_stream_set_playing (stream, TRUE);
+}
+
+static void
+swfdec_net_stream_play (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecNetStream *stream = SWFDEC_NET_STREAM (obj);
+ const char *url;
+
+ url = swfdec_as_value_to_string (cx, &argv[0]);
+ swfdec_net_stream_set_url (stream, SWFDEC_SANDBOX (cx->global), url);
+ swfdec_net_stream_set_playing (stream, TRUE);
+}
+
+static void
+swfdec_net_stream_pause (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecNetStream *stream = SWFDEC_NET_STREAM (obj);
+ gboolean playing;
+
+ if (argc == 0) {
+ playing = !swfdec_net_stream_get_playing (stream);
+ } else {
+ playing = !swfdec_as_value_to_boolean (cx, &argv[0]);
+ }
+ SWFDEC_LOG ("%s stream %p", playing ? "playing" : "pausing", stream);
+ swfdec_net_stream_set_playing (stream, playing);
+}
+
+SWFDEC_AS_NATIVE (2101, 1, swfdec_net_stream_attachAudio)
+void
+swfdec_net_stream_attachAudio (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("NetStream.attachAudio");
+}
+
+SWFDEC_AS_NATIVE (2101, 2, swfdec_net_stream_attachVideo)
+void
+swfdec_net_stream_attachVideo (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("NetStream.attachVideo");
+}
+
+SWFDEC_AS_NATIVE (2101, 3, swfdec_net_stream_send)
+void
+swfdec_net_stream_send (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc,
+ SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("NetStream.send");
+}
+
+SWFDEC_AS_NATIVE (2101, 4, swfdec_net_stream_setBufferTime)
+void
+swfdec_net_stream_setBufferTime (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecNetStream *stream;
+ double d;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_NET_STREAM, &stream, "n", &d);
+
+ swfdec_net_stream_set_buffer_time (stream, d);
+}
+
+SWFDEC_AS_NATIVE (2101, 5, swfdec_net_stream_get_checkPolicyFile)
+void
+swfdec_net_stream_get_checkPolicyFile (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("NetStream.checkPolicyFile (get)");
+}
+
+SWFDEC_AS_NATIVE (2101, 6, swfdec_net_stream_set_checkPolicyFile)
+void
+swfdec_net_stream_set_checkPolicyFile (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("NetStream.checkPolicyFile (set)");
+}
+
+static void
+swfdec_net_stream_do_seek (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecNetStream *stream = SWFDEC_NET_STREAM (obj);
+ double d;
+
+ d = swfdec_as_value_to_number (cx, &argv[0]);
+ swfdec_net_stream_seek (stream, d);
+}
+
+static void
+swfdec_net_stream_construct (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecNetStream *stream = SWFDEC_NET_STREAM (obj);
+ SwfdecNetConnection *conn;
+
+ if (!swfdec_as_context_is_constructing (cx)) {
+ SWFDEC_FIXME ("What do we do if not constructing?");
+ return;
+ }
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]) ||
+ !SWFDEC_IS_NET_CONNECTION ((conn = (SwfdecNetConnection *) SWFDEC_AS_VALUE_GET_OBJECT (&argv[0])))) {
+ SWFDEC_WARNING ("no connection passed to NetStream ()");
+ return;
+ }
+ stream->conn = conn;
+}
+
+void
+swfdec_net_stream_init_context (SwfdecPlayer *player)
+{
+ SwfdecAsContext *context;
+ SwfdecAsObject *stream, *proto;
+ SwfdecAsValue val;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+ context = SWFDEC_AS_CONTEXT (player);
+ proto = swfdec_as_object_new_empty (context);
+ if (proto == NULL)
+ return;
+ stream = SWFDEC_AS_OBJECT (swfdec_as_object_add_constructor (context->global,
+ SWFDEC_AS_STR_NetStream, SWFDEC_TYPE_NET_STREAM, SWFDEC_TYPE_NET_STREAM,
+ swfdec_net_stream_construct, 1, proto));
+ if (stream == NULL)
+ return;
+ /* set the right properties on the NetStream.prototype object */
+ swfdec_as_object_add_function (proto, SWFDEC_AS_STR_pause, SWFDEC_TYPE_NET_STREAM,
+ swfdec_net_stream_pause, 0);
+ swfdec_as_object_add_function (proto, SWFDEC_AS_STR_play, SWFDEC_TYPE_NET_STREAM,
+ swfdec_net_stream_play, 1);
+ swfdec_as_object_add_function (proto, SWFDEC_AS_STR_seek, SWFDEC_TYPE_NET_STREAM,
+ swfdec_net_stream_do_seek, 1);
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, stream);
+ swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object_prototype);
+ swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR___proto__, &val,
+ SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+}
+
diff --git a/swfdec/swfdec_path.c b/swfdec/swfdec_path.c
new file mode 100644
index 0000000..d2da710
--- /dev/null
+++ b/swfdec/swfdec_path.c
@@ -0,0 +1,273 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+
+#include "swfdec_path.h"
+#include "swfdec_debug.h"
+
+void
+swfdec_path_init (cairo_path_t *path)
+{
+ path->status = CAIRO_STATUS_SUCCESS;
+ path->data = NULL;
+ path->num_data = 0;
+}
+
+void
+swfdec_path_reset (cairo_path_t *path)
+{
+ path->status = CAIRO_STATUS_SUCCESS;
+ g_free (path->data);
+ path->data = NULL;
+ path->num_data = 0;
+}
+
+void
+swfdec_path_ensure_size (cairo_path_t *path, int size)
+{
+#define SWFDEC_PATH_STEPS 32
+ /* round up to next multiple of SWFDEC_PATH_STEPS */
+ int current_size = path->num_data - path->num_data % SWFDEC_PATH_STEPS;
+ if (path->num_data % SWFDEC_PATH_STEPS)
+ current_size += SWFDEC_PATH_STEPS;
+
+ if (size % SWFDEC_PATH_STEPS)
+ size += SWFDEC_PATH_STEPS - size % SWFDEC_PATH_STEPS;
+ g_assert (current_size % SWFDEC_PATH_STEPS == 0);
+ g_assert (size % SWFDEC_PATH_STEPS == 0);
+ while (size <= current_size)
+ return;
+ SWFDEC_LOG ("extending size of %p from %u to %u", path, current_size, size);
+ path->data = g_renew (cairo_path_data_t, path->data, size);
+}
+
+void
+swfdec_path_move_to (cairo_path_t *path, double x, double y)
+{
+ cairo_path_data_t *cur;
+
+ swfdec_path_require_size (path, 2);
+ cur = &path->data[path->num_data++];
+ cur->header.type = CAIRO_PATH_MOVE_TO;
+ cur->header.length = 2;
+ cur = &path->data[path->num_data++];
+ cur->point.x = x;
+ cur->point.y = y;
+}
+
+void
+swfdec_path_line_to (cairo_path_t *path, double x, double y)
+{
+ cairo_path_data_t *cur;
+
+ swfdec_path_require_size (path, 2);
+ cur = &path->data[path->num_data++];
+ cur->header.type = CAIRO_PATH_LINE_TO;
+ cur->header.length = 2;
+ cur = &path->data[path->num_data++];
+ cur->point.x = x;
+ cur->point.y = y;
+}
+
+void
+swfdec_path_curve_to (cairo_path_t *path, double start_x, double start_y,
+ double control_x, double control_y, double end_x, double end_y)
+{
+ cairo_path_data_t *cur;
+
+ swfdec_path_require_size (path, 4);
+ cur = &path->data[path->num_data++];
+ cur->header.type = CAIRO_PATH_CURVE_TO;
+ cur->header.length = 4;
+#define WEIGHT (2.0/3.0)
+ cur = &path->data[path->num_data++];
+ cur->point.x = control_x * WEIGHT + (1-WEIGHT) * start_x;
+ cur->point.y = control_y * WEIGHT + (1-WEIGHT) * start_y;
+ cur = &path->data[path->num_data++];
+ cur->point.x = control_x * WEIGHT + (1-WEIGHT) * end_x;
+ cur->point.y = control_y * WEIGHT + (1-WEIGHT) * end_y;
+ cur = &path->data[path->num_data++];
+ cur->point.x = end_x;
+ cur->point.y = end_y;
+}
+
+void
+swfdec_path_append (cairo_path_t *path, const cairo_path_t *append)
+{
+ swfdec_path_require_size (path, append->num_data);
+ memcpy (&path->data[path->num_data], append->data, sizeof (cairo_path_data_t) * append->num_data);
+ path->num_data += append->num_data;
+}
+
+void
+swfdec_path_append_reverse (cairo_path_t *path, const cairo_path_t *append,
+ double x, double y)
+{
+ cairo_path_data_t *out, *in;
+ int i;
+
+ swfdec_path_require_size (path, append->num_data);
+ path->num_data += append->num_data;
+ out = &path->data[path->num_data - 1];
+ in = append->data;
+ for (i = 0; i < append->num_data; i++) {
+ switch (in[i].header.type) {
+ case CAIRO_PATH_LINE_TO:
+ out[-i].point.x = x;
+ out[-i].point.y = y;
+ out[-i - 1].header = in[i].header;
+ i++;
+ break;
+ case CAIRO_PATH_CURVE_TO:
+ out[-i].point.x = x;
+ out[-i].point.y = y;
+ out[-i - 3].header = in[i].header;
+ out[-i - 1].point = in[i + 1].point;
+ out[-i - 2].point = in[i + 2].point;
+ i += 3;
+ break;
+ case CAIRO_PATH_CLOSE_PATH:
+ case CAIRO_PATH_MOVE_TO:
+ /* these two don't exist in our code */
+ default:
+ g_assert_not_reached ();
+ }
+ x = in[i].point.x;
+ y = in[i].point.y;
+ }
+}
+
+void
+swfdec_path_get_extents (const cairo_path_t *path, SwfdecRect *extents)
+{
+ cairo_path_data_t *data = path->data;
+ int i;
+ double x = 0, y = 0;
+ gboolean need_current = TRUE;
+ gboolean start = TRUE;
+#define ADD_POINT(extents, x, y) G_STMT_START { \
+ if (x < extents->x0) \
+ extents->x0 = x; \
+ else if (x > extents->x1) \
+ extents->x1 = x; \
+ if (y < extents->y0) \
+ extents->y0 = y; \
+ else if (y > extents->y1) \
+ extents->y1 = y; \
+} G_STMT_END
+ for (i = 0; i < path->num_data; i++) {
+ switch (data[i].header.type) {
+ case CAIRO_PATH_CURVE_TO:
+ if (need_current) {
+ if (start) {
+ start = FALSE;
+ extents->x0 = x;
+ extents->x1 = x;
+ extents->y0 = y;
+ extents->y1 = y;
+ } else {
+ ADD_POINT (extents, x, y);
+ }
+ need_current = FALSE;
+ }
+ ADD_POINT (extents, data[i+1].point.x, data[i+1].point.y);
+ ADD_POINT (extents, data[i+2].point.x, data[i+2].point.y);
+ ADD_POINT (extents, data[i+3].point.x, data[i+3].point.y);
+ i += 3;
+ break;
+ case CAIRO_PATH_LINE_TO:
+ if (need_current) {
+ if (start) {
+ start = FALSE;
+ extents->x0 = x;
+ extents->x1 = x;
+ extents->y0 = y;
+ extents->y1 = y;
+ } else {
+ ADD_POINT (extents, x, y);
+ }
+ need_current = FALSE;
+ }
+ ADD_POINT (extents, data[i+1].point.x, data[i+1].point.y);
+ i++;
+ break;
+ case CAIRO_PATH_CLOSE_PATH:
+ x = 0;
+ y = 0;
+ need_current = TRUE;
+ break;
+ case CAIRO_PATH_MOVE_TO:
+ x = data[i+1].point.x;
+ y = data[i+1].point.y;
+ need_current = TRUE;
+ i++;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ }
+#undef ADD_POINT
+}
+
+void
+swfdec_path_merge (cairo_path_t *dest, const cairo_path_t *start,
+ const cairo_path_t *end, double ratio)
+{
+ int i;
+ cairo_path_data_t *ddata, *sdata, *edata;
+ double inv = 1.0 - ratio;
+
+ g_assert (start->num_data == end->num_data);
+
+ swfdec_path_reset (dest);
+ swfdec_path_ensure_size (dest, start->num_data);
+ dest->num_data = start->num_data;
+ ddata = dest->data;
+ sdata = start->data;
+ edata = end->data;
+ for (i = 0; i < dest->num_data; i++) {
+ g_assert (sdata[i].header.type == edata[i].header.type);
+ ddata[i] = sdata[i];
+ switch (sdata[i].header.type) {
+ case CAIRO_PATH_CURVE_TO:
+ ddata[i+1].point.x = sdata[i+1].point.x * inv + edata[i+1].point.x * ratio;
+ ddata[i+1].point.y = sdata[i+1].point.y * inv + edata[i+1].point.y * ratio;
+ ddata[i+2].point.x = sdata[i+2].point.x * inv + edata[i+2].point.x * ratio;
+ ddata[i+2].point.y = sdata[i+2].point.y * inv + edata[i+2].point.y * ratio;
+ i += 2;
+ case CAIRO_PATH_MOVE_TO:
+ case CAIRO_PATH_LINE_TO:
+ ddata[i+1].point.x = sdata[i+1].point.x * inv + edata[i+1].point.x * ratio;
+ ddata[i+1].point.y = sdata[i+1].point.y * inv + edata[i+1].point.y * ratio;
+ i++;
+ case CAIRO_PATH_CLOSE_PATH:
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ }
+}
+
diff --git a/swfdec/swfdec_path.h b/swfdec/swfdec_path.h
new file mode 100644
index 0000000..502a049
--- /dev/null
+++ b/swfdec/swfdec_path.h
@@ -0,0 +1,67 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_PATH_H_
+#define _SWFDEC_PATH_H_
+
+#include <cairo.h>
+#include <libswfdec/swfdec_rect.h>
+
+G_BEGIN_DECLS
+
+/* FIXME: Shouldn't this code be in cairo somewhere? */
+
+void swfdec_path_init (cairo_path_t * path);
+void swfdec_path_reset (cairo_path_t * path);
+
+#define swfdec_path_require_size(path, steps) \
+ swfdec_path_ensure_size ((path), (path)->num_data + steps)
+void swfdec_path_ensure_size (cairo_path_t * path,
+ int size);
+void swfdec_path_move_to (cairo_path_t * path,
+ double x,
+ double y);
+void swfdec_path_line_to (cairo_path_t * path,
+ double x,
+ double y);
+void swfdec_path_curve_to (cairo_path_t * path,
+ double start_x,
+ double start_y,
+ double control_x,
+ double control_y,
+ double end_x,
+ double end_y);
+void swfdec_path_append (cairo_path_t * path,
+ const cairo_path_t * append);
+void swfdec_path_append_reverse (cairo_path_t * path,
+ const cairo_path_t * append,
+ double x,
+ double y);
+
+void swfdec_path_get_extents (const cairo_path_t * path,
+ SwfdecRect * extents);
+
+void swfdec_path_merge (cairo_path_t * dest,
+ const cairo_path_t * start,
+ const cairo_path_t * end,
+ double ratio);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_pattern.c b/swfdec/swfdec_pattern.c
new file mode 100644
index 0000000..d641556
--- /dev/null
+++ b/swfdec/swfdec_pattern.c
@@ -0,0 +1,559 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+
+#include "swfdec_pattern.h"
+#include "swfdec_bits.h"
+#include "swfdec_color.h"
+#include "swfdec_debug.h"
+#include "swfdec_decoder.h"
+#include "swfdec_gradient_pattern.h"
+#include "swfdec_image.h"
+#include "swfdec_path.h"
+#include "swfdec_stroke.h"
+
+/*** PATTERN ***/
+
+G_DEFINE_ABSTRACT_TYPE (SwfdecPattern, swfdec_pattern, SWFDEC_TYPE_DRAW);
+
+static void
+swfdec_pattern_compute_extents (SwfdecDraw *draw)
+{
+ swfdec_path_get_extents (&draw->path, &draw->extents);
+}
+
+static void
+swfdec_pattern_paint (SwfdecDraw *draw, cairo_t *cr, const SwfdecColorTransform *trans)
+{
+ cairo_pattern_t *pattern;
+
+ pattern = swfdec_pattern_get_pattern (SWFDEC_PATTERN (draw), trans);
+ if (pattern == NULL)
+ return;
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
+ cairo_append_path (cr, &draw->path);
+ cairo_set_source (cr, pattern);
+ cairo_pattern_destroy (pattern);
+ cairo_fill (cr);
+}
+
+static void
+swfdec_pattern_morph (SwfdecDraw *dest, SwfdecDraw *source, guint ratio)
+{
+ SwfdecPattern *dpattern = SWFDEC_PATTERN (dest);
+ SwfdecPattern *spattern = SWFDEC_PATTERN (source);
+
+ swfdec_matrix_morph (&dpattern->start_transform,
+ &spattern->start_transform, &spattern->end_transform, ratio);
+ dpattern->transform = dpattern->start_transform;
+ if (cairo_matrix_invert (&dpattern->transform)) {
+ SWFDEC_ERROR ("morphed paint transform matrix not invertible, using default");
+ dpattern->transform = spattern->transform;
+ }
+
+ SWFDEC_DRAW_CLASS (swfdec_pattern_parent_class)->morph (dest, source, ratio);
+}
+
+static gboolean
+swfdec_pattern_contains (SwfdecDraw *draw, cairo_t *cr, double x, double y)
+{
+ cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
+ cairo_append_path (cr, &draw->path);
+ return cairo_in_fill (cr, x, y);
+}
+
+static void
+swfdec_pattern_class_init (SwfdecPatternClass *klass)
+{
+ SwfdecDrawClass *draw_class = SWFDEC_DRAW_CLASS (klass);
+
+ draw_class->morph = swfdec_pattern_morph;
+ draw_class->paint = swfdec_pattern_paint;
+ draw_class->compute_extents = swfdec_pattern_compute_extents;
+ draw_class->contains = swfdec_pattern_contains;
+}
+
+static void
+swfdec_pattern_init (SwfdecPattern *pattern)
+{
+ cairo_matrix_init_identity (&pattern->transform);
+ cairo_matrix_init_identity (&pattern->start_transform);
+ cairo_matrix_init_identity (&pattern->end_transform);
+}
+
+/*** COLOR PATTERN ***/
+
+typedef struct _SwfdecColorPattern SwfdecColorPattern;
+typedef struct _SwfdecColorPatternClass SwfdecColorPatternClass;
+
+#define SWFDEC_TYPE_COLOR_PATTERN (swfdec_color_pattern_get_type())
+#define SWFDEC_IS_COLOR_PATTERN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_COLOR_PATTERN))
+#define SWFDEC_IS_COLOR_PATTERN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_COLOR_PATTERN))
+#define SWFDEC_COLOR_PATTERN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_COLOR_PATTERN, SwfdecColorPattern))
+#define SWFDEC_COLOR_PATTERN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_COLOR_PATTERN, SwfdecColorPatternClass))
+#define SWFDEC_COLOR_PATTERN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_COLOR_PATTERN, SwfdecColorPatternClass))
+
+struct _SwfdecColorPattern
+{
+ SwfdecPattern pattern;
+
+ SwfdecColor start_color; /* color to paint with at the beginning */
+ SwfdecColor end_color; /* color to paint with in the end */
+};
+
+struct _SwfdecColorPatternClass
+{
+ SwfdecPatternClass pattern_class;
+};
+
+GType swfdec_color_pattern_get_type (void);
+G_DEFINE_TYPE (SwfdecColorPattern, swfdec_color_pattern, SWFDEC_TYPE_PATTERN);
+
+static void
+swfdec_color_pattern_morph (SwfdecDraw *dest, SwfdecDraw *source, guint ratio)
+{
+ SwfdecColorPattern *dpattern = SWFDEC_COLOR_PATTERN (dest);
+ SwfdecColorPattern *spattern = SWFDEC_COLOR_PATTERN (source);
+
+ dpattern->start_color = swfdec_color_apply_morph (spattern->start_color, spattern->end_color, ratio);
+
+ SWFDEC_DRAW_CLASS (swfdec_color_pattern_parent_class)->morph (dest, source, ratio);
+}
+
+static cairo_pattern_t *
+swfdec_color_pattern_get_pattern (SwfdecPattern *pat, const SwfdecColorTransform *trans)
+{
+ SwfdecColor color = SWFDEC_COLOR_PATTERN (pat)->start_color;
+
+ color = swfdec_color_apply_transform (color, trans);
+ return cairo_pattern_create_rgba (
+ SWFDEC_COLOR_R (color) / 255.0, SWFDEC_COLOR_G (color) / 255.0,
+ SWFDEC_COLOR_B (color) / 255.0, SWFDEC_COLOR_A (color) / 255.0);
+}
+
+static void
+swfdec_color_pattern_class_init (SwfdecColorPatternClass *klass)
+{
+ SWFDEC_DRAW_CLASS (klass)->morph = swfdec_color_pattern_morph;
+
+ SWFDEC_PATTERN_CLASS (klass)->get_pattern = swfdec_color_pattern_get_pattern;
+}
+
+static void
+swfdec_color_pattern_init (SwfdecColorPattern *pattern)
+{
+}
+
+/*** IMAGE PATTERN ***/
+
+typedef struct _SwfdecImagePattern SwfdecImagePattern;
+typedef struct _SwfdecImagePatternClass SwfdecImagePatternClass;
+
+#define SWFDEC_TYPE_IMAGE_PATTERN (swfdec_image_pattern_get_type())
+#define SWFDEC_IS_IMAGE_PATTERN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_IMAGE_PATTERN))
+#define SWFDEC_IS_IMAGE_PATTERN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_IMAGE_PATTERN))
+#define SWFDEC_IMAGE_PATTERN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_IMAGE_PATTERN, SwfdecImagePattern))
+#define SWFDEC_IMAGE_PATTERN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_IMAGE_PATTERN, SwfdecImagePatternClass))
+#define SWFDEC_IMAGE_PATTERN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_IMAGE_PATTERN, SwfdecImagePatternClass))
+
+struct _SwfdecImagePattern
+{
+ SwfdecPattern pattern;
+
+ SwfdecImage * image; /* image to paint */
+ cairo_extend_t extend;
+ cairo_filter_t filter;
+};
+
+struct _SwfdecImagePatternClass
+{
+ SwfdecPatternClass pattern_class;
+};
+
+GType swfdec_image_pattern_get_type (void);
+G_DEFINE_TYPE (SwfdecImagePattern, swfdec_image_pattern, SWFDEC_TYPE_PATTERN);
+
+static void
+swfdec_image_pattern_morph (SwfdecDraw *dest, SwfdecDraw *source, guint ratio)
+{
+ SwfdecImagePattern *dpattern = SWFDEC_IMAGE_PATTERN (dest);
+ SwfdecImagePattern *spattern = SWFDEC_IMAGE_PATTERN (source);
+
+ dpattern->image = g_object_ref (spattern->image);
+ dpattern->extend = spattern->extend;
+ dpattern->filter = spattern->filter;
+
+ SWFDEC_DRAW_CLASS (swfdec_image_pattern_parent_class)->morph (dest, source, ratio);
+}
+
+static cairo_pattern_t *
+swfdec_image_pattern_get_pattern (SwfdecPattern *pat, const SwfdecColorTransform *trans)
+{
+ SwfdecImagePattern *image = SWFDEC_IMAGE_PATTERN (pat);
+ cairo_pattern_t *pattern;
+ cairo_surface_t *surface;
+
+ surface = swfdec_image_create_surface_transformed (image->image, trans);
+ if (surface == NULL)
+ return NULL;
+ pattern = cairo_pattern_create_for_surface (surface);
+ cairo_surface_destroy (surface);
+ cairo_pattern_set_matrix (pattern, &pat->transform);
+ cairo_pattern_set_extend (pattern, image->extend);
+ cairo_pattern_set_filter (pattern, image->filter);
+ return pattern;
+}
+
+static void
+swfdec_image_pattern_class_init (SwfdecImagePatternClass *klass)
+{
+ SWFDEC_DRAW_CLASS (klass)->morph = swfdec_image_pattern_morph;
+
+ SWFDEC_PATTERN_CLASS (klass)->get_pattern = swfdec_image_pattern_get_pattern;
+}
+
+static void
+swfdec_image_pattern_init (SwfdecImagePattern *pattern)
+{
+}
+
+/*** EXPORTED API ***/
+
+static SwfdecDraw *
+swfdec_pattern_do_parse (SwfdecBits *bits, SwfdecSwfDecoder *dec, gboolean rgba)
+{
+ guint paint_style_type;
+ SwfdecPattern *pattern;
+
+ paint_style_type = swfdec_bits_get_u8 (bits);
+ SWFDEC_LOG (" type 0x%02x", paint_style_type);
+
+ if (paint_style_type == 0x00) {
+ pattern = g_object_new (SWFDEC_TYPE_COLOR_PATTERN, NULL);
+ if (rgba) {
+ SWFDEC_COLOR_PATTERN (pattern)->start_color = swfdec_bits_get_rgba (bits);
+ } else {
+ SWFDEC_COLOR_PATTERN (pattern)->start_color = swfdec_bits_get_color (bits);
+ }
+ SWFDEC_COLOR_PATTERN (pattern)->end_color = SWFDEC_COLOR_PATTERN (pattern)->start_color;
+ SWFDEC_LOG (" color %08x", SWFDEC_COLOR_PATTERN (pattern)->start_color);
+ } else if (paint_style_type == 0x10 || paint_style_type == 0x12 || paint_style_type == 0x13) {
+ SwfdecGradientPattern *gradient;
+ guint i, interpolation;
+ pattern = SWFDEC_PATTERN (swfdec_gradient_pattern_new ());
+ gradient = SWFDEC_GRADIENT_PATTERN (pattern);
+ swfdec_bits_get_matrix (bits, &pattern->start_transform, NULL);
+ pattern->end_transform = pattern->start_transform;
+ switch (swfdec_bits_getbits (bits, 2)) {
+ case 0:
+ gradient->extend = CAIRO_EXTEND_PAD;
+ break;
+ case 1:
+ gradient->extend = CAIRO_EXTEND_REFLECT;
+ break;
+ case 2:
+ gradient->extend = CAIRO_EXTEND_REPEAT;
+ break;
+ case 3:
+ SWFDEC_ERROR ("spread mode 3 is undefined for gradients");
+ gradient->extend = CAIRO_EXTEND_PAD;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ interpolation = swfdec_bits_getbits (bits, 2);
+ if (interpolation) {
+ SWFDEC_FIXME ("only normal interpolation is implemented, mode %u is not", interpolation);
+ }
+ gradient->n_gradients = swfdec_bits_getbits (bits, 4);
+ for (i = 0; i < gradient->n_gradients; i++) {
+ gradient->gradient[i].ratio = swfdec_bits_get_u8 (bits);
+ if (rgba)
+ gradient->gradient[i].color = swfdec_bits_get_rgba (bits);
+ else
+ gradient->gradient[i].color = swfdec_bits_get_color (bits);
+ }
+ gradient->radial = (paint_style_type != 0x10);
+ /* FIXME: need a way to ensure 0x13 only happens in Flash 8 */
+ if (paint_style_type == 0x13) {
+ gradient->focus = swfdec_bits_get_s16 (bits) / 256.0;
+ }
+ } else if (paint_style_type >= 0x40 && paint_style_type <= 0x43) {
+ guint paint_id = swfdec_bits_get_u16 (bits);
+ SWFDEC_LOG (" background paint id = %d (type 0x%02x)",
+ paint_id, paint_style_type);
+ if (paint_id == 65535) {
+ /* FIXME: someone explain this magic paint id here */
+ pattern = g_object_new (SWFDEC_TYPE_COLOR_PATTERN, NULL);
+ SWFDEC_COLOR_PATTERN (pattern)->start_color = SWFDEC_COLOR_COMBINE (0, 255, 255, 255);
+ SWFDEC_COLOR_PATTERN (pattern)->end_color = SWFDEC_COLOR_PATTERN (pattern)->start_color;
+ swfdec_bits_get_matrix (bits, &pattern->start_transform, NULL);
+ pattern->end_transform = pattern->start_transform;
+ } else {
+ pattern = g_object_new (SWFDEC_TYPE_IMAGE_PATTERN, NULL);
+ swfdec_bits_get_matrix (bits, &pattern->start_transform, NULL);
+ pattern->end_transform = pattern->start_transform;
+ SWFDEC_IMAGE_PATTERN (pattern)->image = swfdec_swf_decoder_get_character (dec, paint_id);
+ if (!SWFDEC_IS_IMAGE (SWFDEC_IMAGE_PATTERN (pattern)->image)) {
+ g_object_unref (pattern);
+ SWFDEC_ERROR ("could not find image with id %u for pattern", paint_id);
+ return NULL;
+ }
+ if (paint_style_type == 0x40 || paint_style_type == 0x42) {
+ SWFDEC_IMAGE_PATTERN (pattern)->extend = CAIRO_EXTEND_REPEAT;
+ } else {
+#if 0
+ /* not implemented yet in cairo */
+ SWFDEC_IMAGE_PATTERN (pattern)->extend = CAIRO_EXTEND_PAD;
+#else
+ SWFDEC_FIXME ("CAIRO_EXTEND_PAD is not yet implemented");
+ SWFDEC_IMAGE_PATTERN (pattern)->extend = CAIRO_EXTEND_NONE;
+#endif
+ }
+ if (paint_style_type == 0x40 || paint_style_type == 0x41) {
+ SWFDEC_IMAGE_PATTERN (pattern)->filter = CAIRO_FILTER_BILINEAR;
+ } else {
+ SWFDEC_IMAGE_PATTERN (pattern)->filter = CAIRO_FILTER_NEAREST;
+ }
+ }
+ } else {
+ SWFDEC_ERROR ("unknown paint style type 0x%02x", paint_style_type);
+ return NULL;
+ }
+ pattern->transform = pattern->start_transform;
+ if (cairo_matrix_invert (&pattern->transform)) {
+ SWFDEC_ERROR ("paint transform matrix not invertible, resetting");
+ cairo_matrix_init_identity (&pattern->transform);
+ }
+ swfdec_bits_syncbits (bits);
+ return SWFDEC_DRAW (pattern);
+}
+
+/**
+ * swfdec_pattern_parse:
+ * @bits: the bits to parse from
+ * @dec: a #SwfdecDecoder to take context from
+ * @rgba: TRUE if colors are RGBA, FALSE if they're just RGB
+ *
+ * Continues parsing @dec into a new #SwfdecPattern
+ *
+ * Returns: a new #SwfdecPattern or NULL on error
+ **/
+SwfdecDraw *
+swfdec_pattern_parse (SwfdecBits *bits, SwfdecSwfDecoder *dec)
+{
+ g_return_val_if_fail (bits != NULL, NULL);
+ g_return_val_if_fail (SWFDEC_IS_SWF_DECODER (dec), NULL);
+
+ return swfdec_pattern_do_parse (bits, dec, FALSE);
+}
+
+SwfdecDraw *
+swfdec_pattern_parse_rgba (SwfdecBits *bits, SwfdecSwfDecoder *dec)
+{
+ g_return_val_if_fail (bits != NULL, NULL);
+ g_return_val_if_fail (SWFDEC_IS_SWF_DECODER (dec), NULL);
+
+ return swfdec_pattern_do_parse (bits, dec, TRUE);
+}
+
+/**
+ * swfdec_pattern_parse_morph:
+ * @dec: a #SwfdecDecoder to parse from
+ *
+ * Continues parsing @dec into a new #SwfdecPattern. This function is used by
+ * morph shapes.
+ *
+ * Returns: a new #SwfdecPattern or NULL on error
+ **/
+SwfdecDraw *
+swfdec_pattern_parse_morph (SwfdecBits *bits, SwfdecSwfDecoder *dec)
+{
+ guint paint_style_type;
+ SwfdecPattern *pattern;
+
+ g_return_val_if_fail (bits != NULL, NULL);
+ g_return_val_if_fail (SWFDEC_IS_SWF_DECODER (dec), NULL);
+
+ paint_style_type = swfdec_bits_get_u8 (bits);
+ SWFDEC_LOG (" type 0x%02x", paint_style_type);
+
+ if (paint_style_type == 0x00) {
+ pattern = g_object_new (SWFDEC_TYPE_COLOR_PATTERN, NULL);
+ SWFDEC_COLOR_PATTERN (pattern)->start_color = swfdec_bits_get_rgba (bits);
+ SWFDEC_COLOR_PATTERN (pattern)->end_color = swfdec_bits_get_rgba (bits);
+ SWFDEC_LOG (" color %08x => %08x", SWFDEC_COLOR_PATTERN (pattern)->start_color,
+ SWFDEC_COLOR_PATTERN (pattern)->end_color);
+ } else if (paint_style_type == 0x10 || paint_style_type == 0x12 || paint_style_type == 0x13) {
+ SwfdecGradientPattern *gradient;
+ guint i, interpolation;
+ pattern = SWFDEC_PATTERN (swfdec_gradient_pattern_new ());
+ gradient = SWFDEC_GRADIENT_PATTERN (pattern);
+ swfdec_bits_get_matrix (bits, &pattern->start_transform, NULL);
+ swfdec_bits_get_matrix (bits, &pattern->end_transform, NULL);
+ switch (swfdec_bits_getbits (bits, 2)) {
+ case 0:
+ gradient->extend = CAIRO_EXTEND_PAD;
+ break;
+ case 1:
+ gradient->extend = CAIRO_EXTEND_REFLECT;
+ break;
+ case 2:
+ gradient->extend = CAIRO_EXTEND_REPEAT;
+ break;
+ case 3:
+ SWFDEC_ERROR ("spread mode 3 is undefined for gradients");
+ gradient->extend = CAIRO_EXTEND_PAD;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ interpolation = swfdec_bits_getbits (bits, 2);
+ if (interpolation) {
+ SWFDEC_FIXME ("only normal interpolation is implemented, mode %u is not", interpolation);
+ }
+ gradient->n_gradients = swfdec_bits_getbits (bits, 4);
+ for (i = 0; i < gradient->n_gradients; i++) {
+ gradient->gradient[i].ratio = swfdec_bits_get_u8 (bits);
+ gradient->gradient[i].color = swfdec_bits_get_rgba (bits);
+ gradient->end_gradient[i].ratio = swfdec_bits_get_u8 (bits);
+ gradient->end_gradient[i].color = swfdec_bits_get_rgba (bits);
+ }
+ gradient->radial = (paint_style_type != 0x10);
+ /* FIXME: need a way to ensure 0x13 only happens in Flash 8 */
+ if (paint_style_type == 0x13) {
+ gradient->focus = swfdec_bits_get_s16 (bits) / 256.0;
+ }
+ } else if (paint_style_type >= 0x40 && paint_style_type <= 0x43) {
+ guint paint_id = swfdec_bits_get_u16 (bits);
+ SWFDEC_LOG (" background paint id = %d (type 0x%02x)",
+ paint_id, paint_style_type);
+ if (paint_id == 65535) {
+ /* FIXME: someone explain this magic paint id here */
+ pattern = g_object_new (SWFDEC_TYPE_COLOR_PATTERN, NULL);
+ SWFDEC_COLOR_PATTERN (pattern)->start_color = SWFDEC_COLOR_COMBINE (0, 255, 255, 255);
+ SWFDEC_COLOR_PATTERN (pattern)->end_color = SWFDEC_COLOR_PATTERN (pattern)->start_color;
+ swfdec_bits_get_matrix (bits, &pattern->start_transform, NULL);
+ swfdec_bits_get_matrix (bits, &pattern->end_transform, NULL);
+ } else {
+ pattern = g_object_new (SWFDEC_TYPE_IMAGE_PATTERN, NULL);
+ swfdec_bits_get_matrix (bits, &pattern->start_transform, NULL);
+ swfdec_bits_get_matrix (bits, &pattern->end_transform, NULL);
+ SWFDEC_IMAGE_PATTERN (pattern)->image = swfdec_swf_decoder_get_character (dec, paint_id);
+ if (!SWFDEC_IS_IMAGE (SWFDEC_IMAGE_PATTERN (pattern)->image)) {
+ g_object_unref (pattern);
+ SWFDEC_ERROR ("could not find image with id %u for pattern", paint_id);
+ return NULL;
+ }
+ if (paint_style_type == 0x40 || paint_style_type == 0x42) {
+ SWFDEC_IMAGE_PATTERN (pattern)->extend = CAIRO_EXTEND_REPEAT;
+ } else {
+#if 0
+ /* not implemented yet in cairo */
+ SWFDEC_IMAGE_PATTERN (pattern)->extend = CAIRO_EXTEND_PAD;
+#else
+ SWFDEC_FIXME ("CAIRO_EXTEND_PAD is not yet implemented");
+ SWFDEC_IMAGE_PATTERN (pattern)->extend = CAIRO_EXTEND_NONE;
+#endif
+ }
+ if (paint_style_type == 0x40 || paint_style_type == 0x41) {
+ SWFDEC_IMAGE_PATTERN (pattern)->filter = CAIRO_FILTER_BILINEAR;
+ } else {
+ SWFDEC_IMAGE_PATTERN (pattern)->filter = CAIRO_FILTER_NEAREST;
+ }
+ }
+ } else {
+ SWFDEC_ERROR ("unknown paint style type 0x%02x", paint_style_type);
+ return NULL;
+ }
+ pattern->transform = pattern->start_transform;
+ if (cairo_matrix_invert (&pattern->transform)) {
+ SWFDEC_ERROR ("paint transform matrix not invertible, resetting");
+ cairo_matrix_init_identity (&pattern->transform);
+ }
+ swfdec_bits_syncbits (bits);
+ return SWFDEC_DRAW (pattern);
+}
+
+/**
+ * swfdec_pattern_new_color:
+ * @color: color to paint in
+ *
+ * Creates a new pattern to paint with the given color
+ *
+ * Returns: a new @SwfdecPattern to paint with
+ */
+SwfdecPattern *
+swfdec_pattern_new_color (SwfdecColor color)
+{
+ SwfdecPattern *pattern = g_object_new (SWFDEC_TYPE_COLOR_PATTERN, NULL);
+
+ SWFDEC_COLOR_PATTERN (pattern)->start_color = color;
+ SWFDEC_COLOR_PATTERN (pattern)->end_color = color;
+
+ return pattern;
+}
+
+char *
+swfdec_pattern_to_string (SwfdecPattern *pattern)
+{
+ g_return_val_if_fail (SWFDEC_IS_PATTERN (pattern), NULL);
+
+ if (SWFDEC_IS_IMAGE_PATTERN (pattern)) {
+ SwfdecImagePattern *image = SWFDEC_IMAGE_PATTERN (pattern);
+ if (image->image->width == 0)
+ cairo_surface_destroy (swfdec_image_create_surface (image->image));
+ return g_strdup_printf ("%ux%u image %u (%s, %s)", image->image->width,
+ image->image->height, SWFDEC_CHARACTER (image->image)->id,
+ image->extend == CAIRO_EXTEND_REPEAT ? "repeat" : "no repeat",
+ image->filter == CAIRO_FILTER_BILINEAR ? "bilinear" : "nearest");
+ } else if (SWFDEC_IS_COLOR_PATTERN (pattern)) {
+ if (SWFDEC_COLOR_PATTERN (pattern)->start_color == SWFDEC_COLOR_PATTERN (pattern)->end_color)
+ return g_strdup_printf ("color #%08X", SWFDEC_COLOR_PATTERN (pattern)->start_color);
+ else
+ return g_strdup_printf ("color #%08X => #%08X", SWFDEC_COLOR_PATTERN (pattern)->start_color,
+ SWFDEC_COLOR_PATTERN (pattern)->end_color);
+ } else if (SWFDEC_IS_GRADIENT_PATTERN (pattern)) {
+ SwfdecGradientPattern *gradient = SWFDEC_GRADIENT_PATTERN (pattern);
+ return g_strdup_printf ("%s gradient (%u colors)", gradient->radial ? "radial" : "linear",
+ gradient->n_gradients);
+ } else {
+ return g_strdup_printf ("%s", G_OBJECT_TYPE_NAME (pattern));
+ }
+}
+
+cairo_pattern_t *
+swfdec_pattern_get_pattern (SwfdecPattern *pattern, const SwfdecColorTransform *trans)
+{
+ SwfdecPatternClass *klass;
+
+ g_return_val_if_fail (SWFDEC_IS_PATTERN (pattern), NULL);
+ g_return_val_if_fail (trans != NULL, NULL);
+
+ klass = SWFDEC_PATTERN_GET_CLASS (pattern);
+ g_assert (klass->get_pattern);
+ return klass->get_pattern (pattern, trans);
+}
+
diff --git a/swfdec/swfdec_pattern.h b/swfdec/swfdec_pattern.h
new file mode 100644
index 0000000..3fdcf99
--- /dev/null
+++ b/swfdec/swfdec_pattern.h
@@ -0,0 +1,75 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_PATTERN_H_
+#define _SWFDEC_PATTERN_H_
+
+#include <glib-object.h>
+#include <cairo.h>
+#include <libswfdec/swfdec_draw.h>
+#include <libswfdec/swfdec_swf_decoder.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecPattern SwfdecPattern;
+typedef struct _SwfdecPatternClass SwfdecPatternClass;
+
+#define SWFDEC_TYPE_PATTERN (swfdec_pattern_get_type())
+#define SWFDEC_IS_PATTERN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_PATTERN))
+#define SWFDEC_IS_PATTERN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_PATTERN))
+#define SWFDEC_PATTERN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_PATTERN, SwfdecPattern))
+#define SWFDEC_PATTERN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_PATTERN, SwfdecPatternClass))
+#define SWFDEC_PATTERN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_PATTERN, SwfdecPatternClass))
+
+struct _SwfdecPattern
+{
+ SwfdecDraw draw;
+
+ cairo_matrix_t transform; /* user-to-pattern transform */
+ cairo_matrix_t start_transform; /* start transform */
+ cairo_matrix_t end_transform; /* end transform (if morph) */
+};
+
+struct _SwfdecPatternClass
+{
+ SwfdecDrawClass draw_class;
+
+ /* create a cairo pattern for the given values */
+ cairo_pattern_t * (* get_pattern) (SwfdecPattern * pattern,
+ const SwfdecColorTransform * trans);
+};
+
+GType swfdec_pattern_get_type (void);
+
+SwfdecPattern * swfdec_pattern_new_color (SwfdecColor color);
+SwfdecDraw * swfdec_pattern_parse (SwfdecBits * bits,
+ SwfdecSwfDecoder * dec);
+SwfdecDraw * swfdec_pattern_parse_rgba (SwfdecBits * bits,
+ SwfdecSwfDecoder * dec);
+SwfdecDraw * swfdec_pattern_parse_morph (SwfdecBits * bits,
+ SwfdecSwfDecoder * dec);
+
+cairo_pattern_t *swfdec_pattern_get_pattern (SwfdecPattern * pattern,
+ const SwfdecColorTransform * trans);
+
+/* debug */
+char * swfdec_pattern_to_string (SwfdecPattern * pattern);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_player.c b/swfdec/swfdec_player.c
new file mode 100644
index 0000000..5b996ef
--- /dev/null
+++ b/swfdec/swfdec_player.c
@@ -0,0 +1,3030 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <errno.h>
+#include <math.h>
+#include <string.h>
+#include <stdlib.h>
+#include <liboil/liboil.h>
+
+#include "swfdec_player_internal.h"
+#include "swfdec_as_frame_internal.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_audio_internal.h"
+#include "swfdec_button_movie.h" /* for mouse cursor */
+#include "swfdec_cache.h"
+#include "swfdec_debug.h"
+#include "swfdec_enums.h"
+#include "swfdec_event.h"
+#include "swfdec_loader_internal.h"
+#include "swfdec_marshal.h"
+#include "swfdec_movie.h"
+#include "swfdec_resource.h"
+#include "swfdec_script_internal.h"
+#include "swfdec_sprite_movie.h"
+#include "swfdec_utils.h"
+
+/*** gtk-doc ***/
+
+/**
+ * SECTION:SwfdecPlayer
+ * @title: SwfdecPlayer
+ * @short_description: main playback object
+ *
+ * A #SwfdecPlayer is the main object used for playing back Flash files through
+ * Swfdec.
+ *
+ * A player interacts with the outside world in a multitude of ways. The most
+ * important ones are described below.
+ *
+ * Input is handled via the
+ * <link linkend="swfdec-SwfdecLoader">SwfdecLoader</link> class. A
+ * #SwfdecLoader is set on a new player using swfdec_player_set_loader().
+ *
+ * When the loader has provided enough data, you can start playing the file.
+ * This is done in steps by calling swfdec_player_advance() - preferrably as
+ * often as swfdec_player_get_next_event() indicates. Or you can provide user input
+ * to the player by calling for example swfdec_player_handle_mouse().
+ *
+ * You can use swfdec_player_render() to draw the current state of the player.
+ * After that, connect to the SwfdecPlayer::invalidate signal to be notified of
+ * changes.
+ *
+ * Audio output is handled via the
+ * <link linkend="swfdec-SwfdecAudio">SwfdecAudio</link> class. One
+ * #SwfdecAudio object is created for every output using the
+ * SwfdecPlayer::audio-added signal.
+ */
+
+/**
+ * SwfdecPlayer:
+ *
+ * This is the base object used for playing Flash files.
+ */
+
+/**
+ * SECTION:Enumerations
+ * @title: Enumerations
+ * @short_description: enumerations used in Swfdec
+ *
+ * This file lists all of the enumerations used in various parts of Swfdec.
+ */
+
+/**
+ * SwfdecMouseCursor:
+ * @SWFDEC_MOUSE_CURSOR_NORMAL: a normal mouse cursor
+ * @SWFDEC_MOUSE_CURSOR_NONE: no mouse image
+ * @SWFDEC_MOUSE_CURSOR_TEXT: a mouse cursor suitable for text editing
+ * @SWFDEC_MOUSE_CURSOR_CLICK: a mouse cursor for clicking a hyperlink or a
+ * button
+ *
+ * This enumeration describes the possible types for the SwfdecPlayer::mouse-cursor
+ * property.
+ */
+
+/**
+ * SwfdecAlignment:
+ * @SWFDEC_ALIGNMENT_TOP_LEFT: top left
+ * @SWFDEC_ALIGNMENT_TOP: top
+ * @SWFDEC_ALIGNMENT_TOP_RIGHT: top right
+ * @SWFDEC_ALIGNMENT_LEFT: left
+ * @SWFDEC_ALIGNMENT_CENTER: center
+ * @SWFDEC_ALIGNMENT_RIGHT: right
+ * @SWFDEC_ALIGNMENT_BOTTOM_LEFT: left
+ * @SWFDEC_ALIGNMENT_BOTTOM: bottom
+ * @SWFDEC_ALIGNMENT_BOTTOM_RIGHT: bottom right
+ *
+ * These are the possible values for the alignment of an unscaled movie.
+ */
+
+/**
+ * SwfdecScaleMode:
+ * @SWFDEC_SCALE_SHOW_ALL: Show the whole content as large as possible
+ * @SWFDEC_SCALE_NO_BORDER: Fill the whole area, possibly cropping parts
+ * @SWFDEC_SCALE_EXACT_FIT: Fill the whole area, don't keep aspect ratio
+ * @SWFDEC_SCALE_NONE: Do not scale the movie at all
+ *
+ * Describes how the movie should be scaled if the given size doesn't equal the
+ * movie's size.
+ */
+
+/**
+ * SwfdecKey:
+ * @SWFDEC_KEY_BACKSPACE: the backspace key
+ * @SWFDEC_KEY_TAB: the tab key
+ * @SWFDEC_KEY_CLEAR: the clear key
+ * @SWFDEC_KEY_ENTER: the enter key
+ * @SWFDEC_KEY_SHIFT: the shift key
+ * @SWFDEC_KEY_CONTROL: the control key
+ * @SWFDEC_KEY_ALT: the alt key
+ * @SWFDEC_KEY_CAPS_LOCK: the caps lock key
+ * @SWFDEC_KEY_ESCAPE: the escape key
+ * @SWFDEC_KEY_SPACE: the space key
+ * @SWFDEC_KEY_PAGE_UP: the page up key
+ * @SWFDEC_KEY_PAGE_DOWN: the page down key
+ * @SWFDEC_KEY_END: the end key
+ * @SWFDEC_KEY_HOME: the home key
+ * @SWFDEC_KEY_LEFT: the left key
+ * @SWFDEC_KEY_UP: the up key
+ * @SWFDEC_KEY_RIGHT: the right key
+ * @SWFDEC_KEY_DOWN: the down key
+ * @SWFDEC_KEY_INSERT: the insert key
+ * @SWFDEC_KEY_DELETE: the delete key
+ * @SWFDEC_KEY_HELP: the help key
+ * @SWFDEC_KEY_0: the 0 key
+ * @SWFDEC_KEY_1: the 1 key
+ * @SWFDEC_KEY_2: the 2 key
+ * @SWFDEC_KEY_3: the 3 key
+ * @SWFDEC_KEY_4: the 4 key
+ * @SWFDEC_KEY_5: the 5 key
+ * @SWFDEC_KEY_6: the 6 key
+ * @SWFDEC_KEY_7: the 7 key
+ * @SWFDEC_KEY_8: the 8 key
+ * @SWFDEC_KEY_9: the 9 key
+ * @SWFDEC_KEY_A: the ! key
+ * @SWFDEC_KEY_B: the B key
+ * @SWFDEC_KEY_C: the C key
+ * @SWFDEC_KEY_D: the D key
+ * @SWFDEC_KEY_E: the E key
+ * @SWFDEC_KEY_F: the F key
+ * @SWFDEC_KEY_G: the G key
+ * @SWFDEC_KEY_H: the H key
+ * @SWFDEC_KEY_I: the I key
+ * @SWFDEC_KEY_J: the J key
+ * @SWFDEC_KEY_K: the K key
+ * @SWFDEC_KEY_L: the L key
+ * @SWFDEC_KEY_M: the M key
+ * @SWFDEC_KEY_N: the N key
+ * @SWFDEC_KEY_O: the O key
+ * @SWFDEC_KEY_P: the P key
+ * @SWFDEC_KEY_Q: the Q key
+ * @SWFDEC_KEY_R: the R key
+ * @SWFDEC_KEY_S: the S key
+ * @SWFDEC_KEY_T: the T key
+ * @SWFDEC_KEY_U: the U key
+ * @SWFDEC_KEY_V: the V key
+ * @SWFDEC_KEY_W: the W key
+ * @SWFDEC_KEY_X: the X key
+ * @SWFDEC_KEY_Y: the Y key
+ * @SWFDEC_KEY_Z: the Z key
+ * @SWFDEC_KEY_NUMPAD_0: the 0 key on the numeric keypad
+ * @SWFDEC_KEY_NUMPAD_1: the 1 key on the numeric keypad
+ * @SWFDEC_KEY_NUMPAD_2: the 2 key on the numeric keypad
+ * @SWFDEC_KEY_NUMPAD_3: the 3 key on the numeric keypad
+ * @SWFDEC_KEY_NUMPAD_4: the 4 key on the numeric keypad
+ * @SWFDEC_KEY_NUMPAD_5: the 5 key on the numeric keypad
+ * @SWFDEC_KEY_NUMPAD_6: the 6 key on the numeric keypad
+ * @SWFDEC_KEY_NUMPAD_7: the 7 key on the numeric keypad
+ * @SWFDEC_KEY_NUMPAD_8: the 8 key on the numeric keypad
+ * @SWFDEC_KEY_NUMPAD_9: the 9 key on the numeric keypad
+ * @SWFDEC_KEY_NUMPAD_MULTIPLY: the multiply key on the numeric keypad
+ * @SWFDEC_KEY_NUMPAD_ADD: the add key on the numeric keypad
+ * @SWFDEC_KEY_NUMPAD_SUBTRACT: the subtract key on the numeric keypad
+ * @SWFDEC_KEY_NUMPAD_DECIMAL: the decimal key on the numeric keypad
+ * @SWFDEC_KEY_NUMPAD_DIVIDE: the divide key on the numeric keypad
+ * @SWFDEC_KEY_F1: the F1 key
+ * @SWFDEC_KEY_F2: the F2 key
+ * @SWFDEC_KEY_F3: the F3 key
+ * @SWFDEC_KEY_F4: the F4 key
+ * @SWFDEC_KEY_F5: the F5 key
+ * @SWFDEC_KEY_F6: the F6 key
+ * @SWFDEC_KEY_F7: the F7 key
+ * @SWFDEC_KEY_F8: the F8 key
+ * @SWFDEC_KEY_F9: the F9 key
+ * @SWFDEC_KEY_F10: the F10 key
+ * @SWFDEC_KEY_F11: the F11 key
+ * @SWFDEC_KEY_F12: the F12 key
+ * @SWFDEC_KEY_F13: the F13 key
+ * @SWFDEC_KEY_F14: the F14 key
+ * @SWFDEC_KEY_F15: the F15 key
+ * @SWFDEC_KEY_NUM_LOCK: the num lock key
+ * @SWFDEC_KEY_SEMICOLON: the semicolon key (on English keyboards)
+ * @SWFDEC_KEY_EQUAL: the equal key (on English keyboards)
+ * @SWFDEC_KEY_MINUS: the minus key (on English keyboards)
+ * @SWFDEC_KEY_SLASH: the slash key (on English keyboards)
+ * @SWFDEC_KEY_GRAVE: the grave key (on English keyboards)
+ * @SWFDEC_KEY_LEFT_BRACKET: the left bracket key (on English keyboards)
+ * @SWFDEC_KEY_BACKSLASH: the backslash key (on English keyboards)
+ * @SWFDEC_KEY_RIGHT_BRACKET: the right bracket key (on English keyboards)
+ * @SWFDEC_KEY_APOSTROPHE: the apostrophe key (on English keyboards)
+ *
+ * Lists all known key codes in Swfdec and their meanings on an English
+ * keyboard.
+ */
+
+/*** Timeouts ***/
+
+static SwfdecTick
+swfdec_player_get_next_event_time (SwfdecPlayer *player)
+{
+ SwfdecPlayerPrivate *priv = player->priv;
+
+ if (priv->timeouts) {
+ return ((SwfdecTimeout *) priv->timeouts->data)->timestamp - priv->time;
+ } else {
+ return G_MAXUINT64;
+ }
+}
+
+/**
+ * swfdec_player_add_timeout:
+ * @player: a #SwfdecPlayer
+ * @timeout: timeout to add
+ *
+ * Adds a timeout to @player. The timeout will be removed automatically when
+ * triggered, so you need to use swfdec_player_add_timeout() to add it again.
+ * The #SwfdecTimeout struct and callback does not use a data callback pointer.
+ * It's suggested that you use the struct as part of your own bigger struct
+ * and get it back like this:
+ * <programlisting>
+ * typedef struct {
+ * // ...
+ * SwfdecTimeout timeout;
+ * } MyStruct;
+ *
+ * static void
+ * my_struct_timeout_callback (SwfdecTimeout *timeout)
+ * {
+ * MyStruct *mystruct = (MyStruct *) ((void *) timeout - G_STRUCT_OFFSET (MyStruct, timeout));
+ *
+ * // do stuff
+ * }
+ * </programlisting>
+ **/
+void
+swfdec_player_add_timeout (SwfdecPlayer *player, SwfdecTimeout *timeout)
+{
+ SwfdecPlayerPrivate *priv;
+ GList *walk;
+ SwfdecTick next_tick;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (timeout != NULL);
+ g_return_if_fail (timeout->timestamp >= player->priv->time);
+ g_return_if_fail (timeout->callback != NULL);
+
+ priv = player->priv;
+ SWFDEC_LOG ("adding timeout %p in %"G_GUINT64_FORMAT" msecs", timeout,
+ SWFDEC_TICKS_TO_MSECS (timeout->timestamp - priv->time));
+ next_tick = swfdec_player_get_next_event_time (player);
+ /* the order is important, on events with the same time, we make sure the new one is last */
+ for (walk = priv->timeouts; walk; walk = walk->next) {
+ SwfdecTimeout *cur = walk->data;
+ if (cur->timestamp > timeout->timestamp)
+ break;
+ }
+ priv->timeouts = g_list_insert_before (priv->timeouts, walk, timeout);
+ if (next_tick != swfdec_player_get_next_event_time (player))
+ g_object_notify (G_OBJECT (player), "next-event");
+}
+
+/**
+ * swfdec_player_remove_timeout:
+ * @player: a #SwfdecPlayer
+ * @timeout: a timeout that should be removed
+ *
+ * Removes the @timeout from the list of scheduled timeouts. The timeout must
+ * have been added with swfdec_player_add_timeout() before.
+ **/
+void
+swfdec_player_remove_timeout (SwfdecPlayer *player, SwfdecTimeout *timeout)
+{
+ SwfdecPlayerPrivate *priv;
+ SwfdecTick next_tick;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (timeout != NULL);
+ g_return_if_fail (timeout->timestamp >= player->priv->time);
+ g_return_if_fail (timeout->callback != NULL);
+
+ SWFDEC_LOG ("removing timeout %p", timeout);
+ priv = player->priv;
+ next_tick = swfdec_player_get_next_event_time (player);
+ priv->timeouts = g_list_remove (priv->timeouts, timeout);
+ if (next_tick != swfdec_player_get_next_event_time (player))
+ g_object_notify (G_OBJECT (player), "next-event");
+}
+
+/*** Actions ***/
+
+typedef struct {
+ SwfdecMovie * movie; /* the movie to trigger the action on */
+ SwfdecScript * script; /* script to execute or NULL to trigger action */
+ SwfdecEventType event; /* the action to trigger */
+} SwfdecPlayerAction;
+
+typedef struct {
+ gpointer object;
+ SwfdecActionFunc func;
+ gpointer data;
+} SwfdecPlayerExternalAction;
+
+static void
+swfdec_player_compress_actions (SwfdecRingBuffer *buffer)
+{
+ SwfdecPlayerAction *action, tmp;
+ guint i = 0;
+
+ for (i = swfdec_ring_buffer_get_n_elements (buffer); i > 0; i--) {
+ action = swfdec_ring_buffer_pop (buffer);
+ g_assert (action);
+ if (action->movie == NULL)
+ continue;
+ tmp = *action;
+ action = swfdec_ring_buffer_push (buffer);
+ *action = tmp;
+ }
+ SWFDEC_INFO ("compresed action queue to %u elements",
+ swfdec_ring_buffer_get_n_elements (buffer));
+ for (i = 0; i < swfdec_ring_buffer_get_n_elements (buffer); i++) {
+ action = swfdec_ring_buffer_peek_nth (buffer, i);
+ g_assert (action->movie != NULL);
+ }
+}
+
+static void
+swfdec_player_do_add_action (SwfdecPlayer *player, guint importance, SwfdecPlayerAction *act)
+{
+ SwfdecPlayerPrivate *priv = player->priv;
+ SwfdecPlayerAction *action = swfdec_ring_buffer_push (priv->actions[importance]);
+ if (action == NULL) {
+ /* try to get rid of freed actions */
+ swfdec_player_compress_actions (priv->actions[importance]);
+ action = swfdec_ring_buffer_push (priv->actions[importance]);
+ if (action == NULL) {
+ if (swfdec_ring_buffer_get_size (priv->actions[importance]) == 256) {
+ SWFDEC_WARNING ("256 levels of recursion were exceeded in one action list.");
+ }
+ swfdec_ring_buffer_set_size (priv->actions[importance],
+ swfdec_ring_buffer_get_size (priv->actions[importance]) + 16);
+ action = swfdec_ring_buffer_push (priv->actions[importance]);
+ g_assert (action);
+ }
+ }
+ *action = *act;
+}
+
+/**
+ * swfdec_player_add_event:
+ * @player: a #SwfdecPlayer
+ * @movie: the movie on which to trigger the event
+ * @type: type of the event
+ * @importance: importance of the event
+ *
+ * Adds an action to the @player. Actions are used by Flash player to solve
+ * reentrancy issues. Instead of calling back into the Actionscript engine,
+ * an action is queued for later execution. So if you're writing code that
+ * is calling Actionscript code, you want to do this by using actions.
+ **/
+void
+swfdec_player_add_action (SwfdecPlayer *player, SwfdecMovie *movie, SwfdecEventType type,
+ guint importance)
+{
+ SwfdecPlayerAction action = { movie, NULL, type };
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+ g_return_if_fail (importance < SWFDEC_PLAYER_N_ACTION_QUEUES);
+
+ SWFDEC_LOG ("adding action %s %u", movie->name, type);
+ swfdec_player_do_add_action (player, importance, &action);
+}
+
+void
+swfdec_player_add_action_script (SwfdecPlayer *player, SwfdecMovie *movie,
+ SwfdecScript *script, guint importance)
+{
+ SwfdecPlayerAction action = { movie, script, 0 };
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+ g_return_if_fail (script != NULL);
+ g_return_if_fail (importance < SWFDEC_PLAYER_N_ACTION_QUEUES);
+
+ SWFDEC_LOG ("adding action script %s %s", movie->name, script->name);
+ swfdec_player_do_add_action (player, importance, &action);
+}
+
+/**
+ * swfdec_player_remove_all_actions:
+ * @player: a #SwfdecPlayer
+ * @movie: movie pointer identifying the actions to be removed
+ *
+ * Removes all actions associated with @movie that have not yet been executed.
+ * See swfdec_player_add_action() for details about actions.
+ **/
+void
+swfdec_player_remove_all_actions (SwfdecPlayer *player, SwfdecMovie *movie)
+{
+ SwfdecPlayerAction *action;
+ SwfdecPlayerPrivate *priv;
+ guint i, j;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+
+ priv = player->priv;
+ for (i = 0; i < SWFDEC_PLAYER_N_ACTION_QUEUES; i++) {
+ for (j = 0; j < swfdec_ring_buffer_get_n_elements (priv->actions[i]); j++) {
+ action = swfdec_ring_buffer_peek_nth (priv->actions[i], j);
+
+ if (action->movie == movie) {
+ SWFDEC_LOG ("removing action %p %u",
+ action->movie, action->event);
+ action->movie = NULL;
+ }
+ }
+ }
+}
+
+static gboolean
+swfdec_player_do_action (SwfdecPlayer *player)
+{
+ SwfdecPlayerAction *action;
+ SwfdecPlayerPrivate *priv;
+ guint i;
+
+ priv = player->priv;
+ for (i = 0; i < SWFDEC_PLAYER_N_ACTION_QUEUES; i++) {
+ do {
+ action = swfdec_ring_buffer_pop (priv->actions[i]);
+ if (action == NULL)
+ break;
+ } while (action->movie == NULL); /* skip removed actions */
+ if (action) {
+ if (action->script) {
+ SwfdecSandbox *sandbox = action->movie->resource->sandbox;
+ swfdec_sandbox_use (sandbox);
+ swfdec_as_object_run (SWFDEC_AS_OBJECT (action->movie), action->script);
+ swfdec_sandbox_unuse (sandbox);
+ } else {
+ swfdec_movie_execute (action->movie, action->event);
+ }
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static void
+swfdec_player_perform_external_actions (SwfdecPlayer *player)
+{
+ SwfdecPlayerExternalAction *action;
+ SwfdecPlayerPrivate *priv = player->priv;
+ guint i;
+
+ /* remove timeout if it exists - do this before executing stuff below */
+ if (priv->external_timeout.callback) {
+ swfdec_player_remove_timeout (player, &priv->external_timeout);
+ priv->external_timeout.callback = NULL;
+ }
+
+ /* we need to query the number of current actions so newly added ones aren't
+ * executed in here */
+ for (i = swfdec_ring_buffer_get_n_elements (priv->external_actions); i > 0; i--) {
+ action = swfdec_ring_buffer_pop (priv->external_actions);
+ g_assert (action != NULL);
+ /* skip removed actions */
+ if (action->object == NULL)
+ continue;
+ action->func (action->object, action->data);
+ swfdec_player_perform_actions (player);
+ }
+}
+
+static void
+swfdec_player_trigger_external_actions (SwfdecTimeout *advance)
+{
+ SwfdecPlayerPrivate *priv = (SwfdecPlayerPrivate *) ((void *) ((guint8 *) advance - G_STRUCT_OFFSET (SwfdecPlayerPrivate, external_timeout)));
+
+ priv->external_timeout.callback = NULL;
+ swfdec_player_perform_external_actions (priv->player);
+}
+
+void
+swfdec_player_add_external_action (SwfdecPlayer *player, gpointer object,
+ SwfdecActionFunc action_func, gpointer action_data)
+{
+ SwfdecPlayerExternalAction *action;
+ SwfdecPlayerPrivate *priv;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (action_func != NULL);
+
+ SWFDEC_LOG ("adding external action %p %p %p", object, action_func, action_data);
+ priv = player->priv;
+ action = swfdec_ring_buffer_push (priv->external_actions);
+ if (action == NULL) {
+ /* FIXME: limit number of actions to not get inf loops due to scripts? */
+ swfdec_ring_buffer_set_size (priv->external_actions,
+ swfdec_ring_buffer_get_size (priv->external_actions) + 16);
+ action = swfdec_ring_buffer_push (priv->external_actions);
+ g_assert (action);
+ }
+ action->object = object;
+ action->func = action_func;
+ action->data = action_data;
+ if (!priv->external_timeout.callback) {
+ /* trigger execution immediately.
+ * But if initialized, keep at least 100ms from when the last external
+ * timeout triggered. This is a crude method to get around infinite loops
+ * when script actions executed by external actions trigger another external
+ * action that would execute instantly.
+ */
+ if (priv->initialized) {
+ priv->external_timeout.timestamp = MAX (priv->time,
+ priv->external_timeout.timestamp + SWFDEC_MSECS_TO_TICKS (100));
+ } else {
+ priv->external_timeout.timestamp = priv->time;
+ }
+ priv->external_timeout.callback = swfdec_player_trigger_external_actions;
+ swfdec_player_add_timeout (player, &priv->external_timeout);
+ }
+}
+
+void
+swfdec_player_remove_all_external_actions (SwfdecPlayer *player, gpointer object)
+{
+ SwfdecPlayerExternalAction *action;
+ SwfdecPlayerPrivate *priv;
+ guint i;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (object != NULL);
+
+ priv = player->priv;
+ for (i = 0; i < swfdec_ring_buffer_get_n_elements (priv->external_actions); i++) {
+ action = swfdec_ring_buffer_peek_nth (priv->external_actions, i);
+
+ if (action->object == object) {
+ SWFDEC_LOG ("removing external action %p %p %p",
+ action->object, action->func, action->data);
+ action->object = NULL;
+ }
+ }
+}
+
+/*** SwfdecPlayer ***/
+
+enum {
+ INVALIDATE,
+ ADVANCE,
+ HANDLE_KEY,
+ HANDLE_MOUSE,
+ AUDIO_ADDED,
+ AUDIO_REMOVED,
+ LAUNCH,
+ FSCOMMAND,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0, };
+
+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,
+ PROP_WIDTH,
+ PROP_HEIGHT,
+ PROP_ALIGNMENT,
+ PROP_SCALE,
+ PROP_SCRIPTING,
+ PROP_SYSTEM,
+ PROP_MAX_RUNTIME,
+ PROP_LOADER_TYPE,
+ PROP_SOCKET_TYPE,
+ PROP_BASE_URL,
+ PROP_URL,
+ PROP_VARIABLES
+};
+
+G_DEFINE_TYPE (SwfdecPlayer, swfdec_player, SWFDEC_TYPE_AS_CONTEXT)
+
+void
+swfdec_player_remove_movie (SwfdecPlayer *player, SwfdecMovie *movie)
+{
+ SwfdecPlayerPrivate *priv = player->priv;
+
+ swfdec_movie_remove (movie);
+ priv->movies = g_list_remove (priv->movies, movie);
+}
+
+static guint
+swfdec_player_alignment_to_flags (SwfdecAlignment alignment)
+{
+ static const guint align_flags[9] = {
+ SWFDEC_ALIGN_FLAG_TOP | SWFDEC_ALIGN_FLAG_LEFT,
+ SWFDEC_ALIGN_FLAG_TOP,
+ SWFDEC_ALIGN_FLAG_TOP | SWFDEC_ALIGN_FLAG_RIGHT,
+ SWFDEC_ALIGN_FLAG_LEFT,
+ 0,
+ SWFDEC_ALIGN_FLAG_RIGHT,
+ SWFDEC_ALIGN_FLAG_BOTTOM | SWFDEC_ALIGN_FLAG_LEFT,
+ SWFDEC_ALIGN_FLAG_BOTTOM,
+ SWFDEC_ALIGN_FLAG_BOTTOM | SWFDEC_ALIGN_FLAG_RIGHT
+ };
+ return align_flags[alignment];
+}
+
+static SwfdecAlignment
+swfdec_player_alignment_from_flags (guint flags)
+{
+ if (flags & SWFDEC_ALIGN_FLAG_TOP) {
+ if (flags & SWFDEC_ALIGN_FLAG_LEFT) {
+ return SWFDEC_ALIGNMENT_TOP_LEFT;
+ } else if (flags & SWFDEC_ALIGN_FLAG_RIGHT) {
+ return SWFDEC_ALIGNMENT_TOP_RIGHT;
+ } else {
+ return SWFDEC_ALIGNMENT_TOP;
+ }
+ } else if (flags & SWFDEC_ALIGN_FLAG_BOTTOM) {
+ if (flags & SWFDEC_ALIGN_FLAG_LEFT) {
+ return SWFDEC_ALIGNMENT_BOTTOM_LEFT;
+ } else if (flags & SWFDEC_ALIGN_FLAG_RIGHT) {
+ return SWFDEC_ALIGNMENT_BOTTOM_RIGHT;
+ } else {
+ return SWFDEC_ALIGNMENT_BOTTOM;
+ }
+ } else {
+ if (flags & SWFDEC_ALIGN_FLAG_LEFT) {
+ return SWFDEC_ALIGNMENT_LEFT;
+ } else if (flags & SWFDEC_ALIGN_FLAG_RIGHT) {
+ return SWFDEC_ALIGNMENT_RIGHT;
+ } else {
+ return SWFDEC_ALIGNMENT_CENTER;
+ }
+ }
+}
+
+static void
+swfdec_player_get_property (GObject *object, guint param_id, GValue *value,
+ GParamSpec * pspec)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (object);
+ SwfdecPlayerPrivate *priv = player->priv;
+
+ switch (param_id) {
+ case PROP_BACKGROUND_COLOR:
+ g_value_set_uint (value, swfdec_player_get_background_color (player));
+ break;
+ case PROP_CACHE_SIZE:
+ g_value_set_ulong (value, swfdec_cache_get_size (priv->cache));
+ break;
+ case PROP_INITIALIZED:
+ g_value_set_boolean (value, swfdec_player_is_initialized (player));
+ break;
+ case PROP_DEFAULT_WIDTH:
+ g_value_set_uint (value, priv->width);
+ break;
+ case PROP_DEFAULT_HEIGHT:
+ g_value_set_uint (value, priv->height);
+ break;
+ case PROP_RATE:
+ g_value_set_double (value, priv->rate / 256.0);
+ break;
+ case PROP_MOUSE_CURSOR:
+ g_value_set_enum (value, priv->mouse_cursor);
+ break;
+ case PROP_NEXT_EVENT:
+ g_value_set_uint (value, swfdec_player_get_next_event (player));
+ break;
+ case PROP_WIDTH:
+ g_value_set_int (value, priv->stage_width);
+ break;
+ case PROP_HEIGHT:
+ g_value_set_int (value, priv->stage_height);
+ break;
+ case PROP_ALIGNMENT:
+ g_value_set_enum (value, swfdec_player_alignment_from_flags (priv->align_flags));
+ break;
+ case PROP_SCALE:
+ g_value_set_enum (value, priv->scale_mode);
+ break;
+ case PROP_SCRIPTING:
+ g_value_set_object (value, priv->scripting);
+ break;
+ case PROP_SYSTEM:
+ g_value_set_object (value, priv->system);
+ break;
+ case PROP_MAX_RUNTIME:
+ g_value_set_ulong (value, priv->max_runtime);
+ break;
+ case PROP_LOADER_TYPE:
+ g_value_set_gtype (value, priv->loader_type);
+ break;
+ case PROP_SOCKET_TYPE:
+ g_value_set_gtype (value, priv->socket_type);
+ break;
+ case PROP_URL:
+ g_value_set_boxed (value, priv->url);
+ break;
+ case PROP_BASE_URL:
+ g_value_set_boxed (value, priv->base_url);
+ break;
+ case PROP_VARIABLES:
+ g_value_set_string (value, priv->variables);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+void
+swfdec_player_update_scale (SwfdecPlayer *player)
+{
+ SwfdecPlayerPrivate *priv = player->priv;
+ int width, height;
+ double scale_x, scale_y;
+
+ priv->stage.width = priv->stage_width >= 0 ? priv->stage_width : (int) priv->width;
+ priv->stage.height = priv->stage_height >= 0 ? priv->stage_height : (int) priv->height;
+ if (priv->stage.height == 0 || priv->stage.width == 0) {
+ priv->scale_x = 1.0;
+ priv->scale_y = 1.0;
+ priv->offset_x = 0;
+ priv->offset_y = 0;
+ return;
+ }
+ if (priv->width == 0 || priv->height == 0) {
+ scale_x = 1.0;
+ scale_y = 1.0;
+ } else {
+ scale_x = (double) priv->stage.width / priv->width;
+ scale_y = (double) priv->stage.height / priv->height;
+ }
+ switch (priv->scale_mode) {
+ case SWFDEC_SCALE_SHOW_ALL:
+ priv->scale_x = MIN (scale_x, scale_y);
+ priv->scale_y = priv->scale_x;
+ break;
+ case SWFDEC_SCALE_NO_BORDER:
+ priv->scale_x = MAX (scale_x, scale_y);
+ priv->scale_y = priv->scale_x;
+ break;
+ case SWFDEC_SCALE_EXACT_FIT:
+ priv->scale_x = scale_x;
+ priv->scale_y = scale_y;
+ break;
+ case SWFDEC_SCALE_NONE:
+ priv->scale_x = 1.0;
+ priv->scale_y = 1.0;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ width = priv->stage.width - ceil (priv->width * priv->scale_x);
+ height = priv->stage.height - ceil (priv->height * priv->scale_y);
+ if (priv->align_flags & SWFDEC_ALIGN_FLAG_LEFT) {
+ priv->offset_x = 0;
+ } else if (priv->align_flags & SWFDEC_ALIGN_FLAG_RIGHT) {
+ priv->offset_x = width;
+ } else {
+ priv->offset_x = width / 2;
+ }
+ if (priv->align_flags & SWFDEC_ALIGN_FLAG_TOP) {
+ priv->offset_y = 0;
+ } else if (priv->align_flags & SWFDEC_ALIGN_FLAG_BOTTOM) {
+ priv->offset_y = height;
+ } else {
+ priv->offset_y = height / 2;
+ }
+ SWFDEC_LOG ("coordinate translation is %g * x + %d - %g * y + %d",
+ priv->scale_x, priv->offset_x, priv->scale_y, priv->offset_y);
+#if 0
+ /* FIXME: make this emit the signal at the right time */
+ priv->invalid.x0 = 0;
+ priv->invalid.y0 = 0;
+ priv->invalid.x1 = priv->stage_width;
+ priv->invalid.y1 = priv->stage_height;
+#endif
+}
+
+static void
+swfdec_player_set_property (GObject *object, guint param_id, const GValue *value,
+ GParamSpec *pspec)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (object);
+ SwfdecPlayerPrivate *priv = player->priv;
+
+ switch (param_id) {
+ case PROP_BACKGROUND_COLOR:
+ swfdec_player_set_background_color (player, g_value_get_uint (value));
+ break;
+ case PROP_CACHE_SIZE:
+ swfdec_cache_set_size (priv->cache, g_value_get_ulong (value));
+ break;
+ case PROP_WIDTH:
+ swfdec_player_set_size (player, g_value_get_int (value), priv->stage_height);
+ break;
+ case PROP_HEIGHT:
+ swfdec_player_set_size (player, priv->stage_width, g_value_get_int (value));
+ break;
+ case PROP_ALIGNMENT:
+ priv->align_flags = swfdec_player_alignment_to_flags (g_value_get_enum (value));
+ swfdec_player_update_scale (player);
+ break;
+ case PROP_SCALE:
+ swfdec_player_set_scale_mode (player, g_value_get_enum (value));
+ break;
+ case PROP_SCRIPTING:
+ swfdec_player_set_scripting (player, g_value_get_object (value));
+ break;
+ case PROP_SYSTEM:
+ g_object_unref (priv->system);
+ if (g_value_get_object (value)) {
+ priv->system = SWFDEC_SYSTEM (g_value_dup_object (value));
+ } else {
+ priv->system = swfdec_system_new ();
+ }
+ break;
+ case PROP_MAX_RUNTIME:
+ swfdec_player_set_maximum_runtime (player, g_value_get_ulong (value));
+ break;
+ case PROP_LOADER_TYPE:
+ g_return_if_fail (G_TYPE_IS_INSTANTIATABLE (g_value_get_gtype (value)));
+ priv->loader_type = g_value_get_gtype (value);
+ break;
+ case PROP_SOCKET_TYPE:
+ priv->socket_type = g_value_get_gtype (value);
+ break;
+ case PROP_URL:
+ swfdec_player_set_url (player, g_value_get_boxed (value));
+ break;
+ case PROP_BASE_URL:
+ swfdec_player_set_base_url (player, g_value_get_boxed (value));
+ break;
+ case PROP_VARIABLES:
+ swfdec_player_set_variables (player, g_value_get_boxed (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+swfdec_player_dispose (GObject *object)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (object);
+ SwfdecPlayerPrivate *priv = player->priv;
+ guint i;
+
+ swfdec_player_stop_all_sounds (player);
+ swfdec_function_list_clear (&priv->resource_requests);
+ g_hash_table_destroy (priv->registered_classes);
+ g_hash_table_destroy (priv->scripting_callbacks);
+
+ g_list_foreach (priv->loading_policy_files, (GFunc) g_object_unref, NULL);
+ g_list_free (priv->loading_policy_files);
+ priv->loading_policy_files = NULL;
+ g_slist_foreach (priv->policy_files, (GFunc) g_object_unref, NULL);
+ g_slist_free (priv->policy_files);
+ priv->policy_files = NULL;
+
+ while (priv->roots)
+ swfdec_movie_destroy (priv->roots->data);
+
+ swfdec_function_list_clear (&priv->rooted);
+ /* we do this here so references to GC'd objects get freed */
+ G_OBJECT_CLASS (swfdec_player_parent_class)->dispose (object);
+
+ swfdec_player_remove_all_external_actions (player, player);
+#ifndef G_DISABLE_ASSERT
+ {
+ SwfdecPlayerExternalAction *action;
+ while ((action = swfdec_ring_buffer_pop (priv->external_actions)) != NULL) {
+ g_assert (action->object == NULL); /* skip removed actions */
+ }
+ }
+ {
+ SwfdecPlayerAction *action;
+ for (i = 0; i < SWFDEC_PLAYER_N_ACTION_QUEUES; i++) {
+ while ((action = swfdec_ring_buffer_pop (priv->actions[i])) != NULL) {
+ g_assert (action->movie == NULL); /* skip removed actions */
+ }
+ }
+ }
+#endif
+ swfdec_ring_buffer_free (priv->external_actions);
+ for (i = 0; i < SWFDEC_PLAYER_N_ACTION_QUEUES; i++) {
+ swfdec_ring_buffer_free (priv->actions[i]);
+ }
+ g_assert (priv->movies == NULL);
+ g_assert (priv->audio == NULL);
+ g_slist_free (priv->sandboxes);
+ if (priv->external_timeout.callback)
+ swfdec_player_remove_timeout (player, &priv->external_timeout);
+ if (priv->rate) {
+ swfdec_player_remove_timeout (player, &priv->iterate_timeout);
+ }
+ g_assert (priv->timeouts == NULL);
+ g_list_free (priv->intervals);
+ priv->intervals = NULL;
+ swfdec_cache_unref (priv->cache);
+ if (priv->system) {
+ g_object_unref (priv->system);
+ priv->system = NULL;
+ }
+ g_array_free (priv->invalidations, TRUE);
+ priv->invalidations = NULL;
+ if (priv->runtime) {
+ g_timer_destroy (priv->runtime);
+ priv->runtime = NULL;
+ }
+ if (priv->base_url) {
+ swfdec_url_free (priv->base_url);
+ priv->base_url = NULL;
+ }
+ if (priv->url) {
+ swfdec_url_free (priv->url);
+ priv->url = NULL;
+ }
+ g_free (priv->variables);
+ priv->variables = NULL;
+}
+
+static void
+swfdec_player_broadcast (SwfdecPlayer *player, const char *object_name, const char *signal)
+{
+ GSList *walk;
+ SwfdecAsValue val;
+ SwfdecAsObject *obj;
+
+ SWFDEC_DEBUG ("broadcasting message %s.%s", object_name, signal);
+ for (walk = player->priv->sandboxes; walk; walk = walk->next) {
+ SwfdecSandbox *sandbox = walk->data;
+ swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (sandbox), object_name, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return;
+ obj = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+ SWFDEC_AS_VALUE_SET_STRING (&val, signal);
+ swfdec_sandbox_use (sandbox);
+ swfdec_as_object_call (obj, SWFDEC_AS_STR_broadcastMessage, 1, &val, NULL);
+ swfdec_sandbox_unuse (sandbox);
+ }
+}
+
+static void
+swfdec_player_update_mouse_cursor (SwfdecPlayer *player)
+{
+ SwfdecPlayerPrivate *priv = player->priv;
+ SwfdecMouseCursor new = SWFDEC_MOUSE_CURSOR_NORMAL;
+
+ if (!priv->mouse_visible) {
+ new = SWFDEC_MOUSE_CURSOR_NONE;
+ } else if (priv->mouse_grab != NULL) {
+ SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (priv->mouse_grab);
+
+ if (klass->mouse_cursor)
+ new = klass->mouse_cursor (priv->mouse_grab);
+ else
+ new = SWFDEC_MOUSE_CURSOR_CLICK;
+ }
+
+ if (new != priv->mouse_cursor) {
+ priv->mouse_cursor = new;
+ g_object_notify (G_OBJECT (player), "mouse-cursor");
+ }
+}
+
+static void
+swfdec_player_update_drag_movie (SwfdecPlayer *player)
+{
+ SwfdecPlayerPrivate *priv = player->priv;
+ double x, y;
+ SwfdecMovie *movie;
+
+ if (priv->mouse_drag == NULL)
+ return;
+
+ movie = priv->mouse_drag;
+ g_assert (movie->cache_state == SWFDEC_MOVIE_UP_TO_DATE);
+ x = priv->mouse_x;
+ y = priv->mouse_y;
+ swfdec_player_stage_to_global (player, &x, &y);
+ if (movie->parent)
+ swfdec_movie_global_to_local (movie->parent, &x, &y);
+ if (priv->mouse_drag_center) {
+ x -= (movie->extents.x1 - movie->extents.x0) / 2;
+ y -= (movie->extents.y1 - movie->extents.y0) / 2;
+ } else {
+ x -= priv->mouse_drag_x;
+ y -= priv->mouse_drag_y;
+ }
+ x = CLAMP (x, priv->mouse_drag_rect.x0, priv->mouse_drag_rect.x1);
+ y = CLAMP (y, priv->mouse_drag_rect.y0, priv->mouse_drag_rect.y1);
+ SWFDEC_LOG ("mouse is at %g %g, originally (%g %g)", x, y, priv->mouse_x, priv->mouse_y);
+ if (x != movie->matrix.x0 || y != movie->matrix.y0) {
+ swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_MATRIX);
+ movie->matrix.x0 = x;
+ movie->matrix.y0 = y;
+ }
+}
+
+/**
+ * swfdec_player_set_drag_movie:
+ * @player: a #SwfdecPlayer
+ * @drag: the movie to be dragged by the mouse or NULL to unset
+ * @center: TRUE if the center of @drag should be at the mouse pointer, FALSE if (0,0)
+ * of @drag should be at the mouse pointer.
+ * @rect: NULL or the rectangle that clips the mouse position. The coordinates
+ * are in the coordinate system of the parent of @drag.
+ *
+ * Sets or unsets the movie that is dragged by the mouse.
+ **/
+void
+swfdec_player_set_drag_movie (SwfdecPlayer *player, SwfdecMovie *drag, gboolean center,
+ SwfdecRect *rect)
+{
+ SwfdecPlayerPrivate *priv;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (drag == NULL || SWFDEC_IS_MOVIE (drag));
+
+ /* FIXME: need to do anything with old drag? */
+ priv = player->priv;
+ priv->mouse_drag = drag;
+ priv->mouse_drag_center = center;
+ if (drag && !center) {
+ priv->mouse_drag_x = priv->mouse_x;
+ priv->mouse_drag_y = priv->mouse_y;
+ swfdec_player_stage_to_global (player, &priv->mouse_drag_x, &priv->mouse_drag_y);
+ if (drag->parent)
+ swfdec_movie_global_to_local (drag->parent, &priv->mouse_drag_x, &priv->mouse_drag_y);
+ priv->mouse_drag_x -= drag->matrix.x0;
+ priv->mouse_drag_y -= drag->matrix.y0;
+ }
+ if (rect) {
+ priv->mouse_drag_rect = *rect;
+ } else {
+ priv->mouse_drag_rect.x0 = -G_MAXDOUBLE;
+ priv->mouse_drag_rect.y0 = -G_MAXDOUBLE;
+ priv->mouse_drag_rect.x1 = G_MAXDOUBLE;
+ priv->mouse_drag_rect.y1 = G_MAXDOUBLE;
+ }
+ SWFDEC_DEBUG ("starting drag in %g %g %g %g",
+ priv->mouse_drag_rect.x0, priv->mouse_drag_rect.y0,
+ priv->mouse_drag_rect.x1, priv->mouse_drag_rect.y1);
+ /* FIXME: need a way to make sure we get updated */
+ if (drag) {
+ swfdec_movie_update (drag);
+ drag->modified = TRUE;
+ swfdec_player_update_drag_movie (player);
+ }
+}
+
+static void
+swfdec_player_grab_mouse_movie (SwfdecPlayer *player)
+{
+ SwfdecPlayerPrivate *priv = player->priv;
+ GList *walk;
+ double x, y;
+ SwfdecMovie *below_mouse = NULL;
+
+ x = priv->mouse_x;
+ y = priv->mouse_y;
+ swfdec_player_stage_to_global (player, &x, &y);
+ for (walk = g_list_last (priv->roots); walk; walk = walk->prev) {
+ below_mouse = swfdec_movie_get_movie_at (walk->data, x, y, TRUE);
+ if (below_mouse) {
+ if (swfdec_movie_get_mouse_events (below_mouse))
+ break;
+ below_mouse = NULL;
+ }
+ }
+ if (swfdec_player_is_mouse_pressed (player)) {
+ /* a mouse grab is active */
+ if (priv->mouse_grab) {
+ if (below_mouse == priv->mouse_grab &&
+ priv->mouse_below != priv->mouse_grab) {
+ SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (priv->mouse_grab);
+ if (klass->mouse_in)
+ klass->mouse_in (priv->mouse_grab);
+ } else if (below_mouse != priv->mouse_grab &&
+ priv->mouse_below == priv->mouse_grab) {
+ SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (priv->mouse_grab);
+ if (klass->mouse_out)
+ klass->mouse_out (priv->mouse_grab);
+ }
+ }
+ } else {
+ /* no mouse grab is active */
+ if (below_mouse != priv->mouse_grab) {
+ if (priv->mouse_grab) {
+ SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (priv->mouse_grab);
+ if (klass->mouse_out)
+ klass->mouse_out (priv->mouse_grab);
+ }
+ if (below_mouse) {
+ SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (below_mouse);
+ if (klass->mouse_in)
+ klass->mouse_in (below_mouse);
+ }
+ }
+ priv->mouse_grab = below_mouse;
+ }
+ priv->mouse_below = below_mouse;
+ SWFDEC_DEBUG ("%s %p has mouse at %g %g",
+ priv->mouse_grab ? G_OBJECT_TYPE_NAME (priv->mouse_grab) : "---",
+ priv->mouse_grab, priv->mouse_x, priv->mouse_y);
+}
+
+static gboolean
+swfdec_player_do_mouse_move (SwfdecPlayer *player, double x, double y)
+{
+ SwfdecPlayerPrivate *priv = player->priv;
+ GList *walk;
+
+ if (priv->mouse_x != x || priv->mouse_y != y) {
+ priv->mouse_x = x;
+ priv->mouse_y = y;
+ for (walk = priv->movies; walk; walk = walk->next) {
+ swfdec_movie_queue_script (walk->data, SWFDEC_EVENT_MOUSE_MOVE);
+ }
+ swfdec_player_broadcast (player, SWFDEC_AS_STR_Mouse, SWFDEC_AS_STR_onMouseMove);
+ }
+ swfdec_player_grab_mouse_movie (player);
+ swfdec_player_update_drag_movie (player);
+
+ /* FIXME: allow events to pass through */
+ return TRUE;
+}
+
+static gboolean
+swfdec_player_do_mouse_press (SwfdecPlayer *player, guint button)
+{
+ SwfdecPlayerPrivate *priv = player->priv;
+ GList *walk;
+
+ priv->mouse_button |= 1 << button;
+ if (button == 0) {
+ for (walk = priv->movies; walk; walk = walk->next) {
+ swfdec_movie_queue_script (walk->data, SWFDEC_EVENT_MOUSE_DOWN);
+ }
+ swfdec_player_broadcast (player, SWFDEC_AS_STR_Mouse, SWFDEC_AS_STR_onMouseDown);
+ }
+ if (priv->mouse_grab) {
+ SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (priv->mouse_grab);
+ if (klass->mouse_press)
+ klass->mouse_press (priv->mouse_grab, button);
+ }
+
+ /* FIXME: allow events to pass through */
+ return TRUE;
+}
+
+static gboolean
+swfdec_player_do_mouse_release (SwfdecPlayer *player, guint button)
+{
+ SwfdecPlayerPrivate *priv = player->priv;
+ GList *walk;
+
+ priv->mouse_button &= ~(1 << button);
+ if (button == 0) {
+ for (walk = priv->movies; walk; walk = walk->next) {
+ swfdec_movie_queue_script (walk->data, SWFDEC_EVENT_MOUSE_UP);
+ }
+ swfdec_player_broadcast (player, SWFDEC_AS_STR_Mouse, SWFDEC_AS_STR_onMouseUp);
+ }
+ if (priv->mouse_grab) {
+ SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (priv->mouse_grab);
+ if (klass->mouse_release)
+ klass->mouse_release (priv->mouse_grab, button);
+ if (button == 0 && priv->mouse_grab != priv->mouse_below) {
+ priv->mouse_grab = priv->mouse_below;
+ if (priv->mouse_grab) {
+ klass = SWFDEC_MOVIE_GET_CLASS (priv->mouse_grab);
+ if (klass->mouse_in)
+ klass->mouse_in (priv->mouse_grab);
+ }
+ }
+ }
+
+ /* FIXME: allow events to pass through */
+ return TRUE;
+}
+
+static void
+swfdec_player_emit_signals (SwfdecPlayer *player)
+{
+ SwfdecPlayerPrivate *priv = player->priv;
+ GList *walk;
+
+ /* emit invalidate signal */
+ if (!swfdec_rectangle_is_empty (&priv->invalid_extents)) {
+ g_signal_emit (player, signals[INVALIDATE], 0, &priv->invalid_extents,
+ priv->invalidations->data, priv->invalidations->len);
+ swfdec_rectangle_init_empty (&priv->invalid_extents);
+ g_array_set_size (priv->invalidations, 0);
+ }
+
+ /* emit audio-added for all added audio streams */
+ for (walk = priv->audio; walk; walk = walk->next) {
+ SwfdecAudio *audio = walk->data;
+
+ if (audio->added)
+ continue;
+ g_signal_emit (player, signals[AUDIO_ADDED], 0, audio);
+ audio->added = TRUE;
+ }
+}
+
+static gboolean
+swfdec_player_do_handle_key (SwfdecPlayer *player, guint keycode, guint character, gboolean down)
+{
+ SwfdecPlayerPrivate *priv = player->priv;
+ g_assert (keycode < 256);
+
+ if (!swfdec_player_lock (player))
+ return FALSE;
+ /* set the correct variables */
+ priv->last_keycode = keycode;
+ priv->last_character = character;
+ if (down) {
+ priv->key_pressed[keycode / 8] |= 1 << keycode % 8;
+ } else {
+ priv->key_pressed[keycode / 8] &= ~(1 << keycode % 8);
+ }
+ swfdec_player_broadcast (player, SWFDEC_AS_STR_Key, down ? SWFDEC_AS_STR_onKeyDown : SWFDEC_AS_STR_onKeyUp);
+ swfdec_player_perform_actions (player);
+ swfdec_player_unlock (player);
+
+ return TRUE;
+}
+
+static gboolean
+swfdec_player_do_handle_mouse (SwfdecPlayer *player,
+ double x, double y, int button)
+{
+ gboolean ret;
+
+ if (!swfdec_player_lock (player))
+ return FALSE;
+
+ SWFDEC_LOG ("handling mouse for %g %g %d", x, y, button);
+ ret = swfdec_player_do_mouse_move (player, x, y);
+ if (button > 0) {
+ ret |= swfdec_player_do_mouse_press (player, button - 1);
+ } else if (button < 0) {
+ ret |= swfdec_player_do_mouse_release (player, -button - 1);
+ }
+ swfdec_player_perform_actions (player);
+ swfdec_player_unlock (player);
+
+ return ret;
+}
+
+void
+swfdec_player_global_to_stage (SwfdecPlayer *player, double *x, double *y)
+{
+ SwfdecPlayerPrivate *priv = player->priv;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (x != NULL);
+ g_return_if_fail (y != NULL);
+
+ *x = *x / SWFDEC_TWIPS_SCALE_FACTOR * priv->scale_x + priv->offset_x;
+ *y = *y / SWFDEC_TWIPS_SCALE_FACTOR * priv->scale_y + priv->offset_y;
+}
+
+void
+swfdec_player_stage_to_global (SwfdecPlayer *player, double *x, double *y)
+{
+ SwfdecPlayerPrivate *priv = player->priv;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (x != NULL);
+ g_return_if_fail (y != NULL);
+
+ *x = (*x - priv->offset_x) / priv->scale_x * SWFDEC_TWIPS_SCALE_FACTOR;
+ *y = (*y - priv->offset_y) / priv->scale_y * SWFDEC_TWIPS_SCALE_FACTOR;
+}
+
+static void
+swfdec_player_execute_on_load_init (SwfdecPlayer *player)
+{
+ GList *walk;
+
+ /* FIXME: This can be made a LOT faster with correct caching, but I'm lazy */
+ do {
+ for (walk = player->priv->movies; walk; walk = walk->next) {
+ SwfdecMovie *movie = walk->data;
+ SwfdecResource *resource = swfdec_movie_get_own_resource (movie);
+ if (resource == NULL)
+ continue;
+ if (swfdec_resource_emit_on_load_init (resource))
+ break;
+ }
+ } while (walk != NULL);
+}
+
+static void
+swfdec_player_iterate (SwfdecTimeout *timeout)
+{
+ SwfdecPlayerPrivate *priv = (SwfdecPlayerPrivate *) ((void *) ((guint8 *) timeout - G_STRUCT_OFFSET (SwfdecPlayerPrivate, iterate_timeout)));
+ SwfdecPlayer *player = priv->player;
+ GList *walk;
+
+ /* add timeout again - do this first because later code can change it */
+ /* FIXME: rounding issues? */
+ priv->iterate_timeout.timestamp += SWFDEC_TICKS_PER_SECOND * 256 / priv->rate;
+ swfdec_player_add_timeout (player, &priv->iterate_timeout);
+ swfdec_player_perform_external_actions (player);
+ SWFDEC_INFO ("=== START ITERATION ===");
+ /* start the iteration. This performs a goto next frame on all
+ * movies that are not stopped. It also queues onEnterFrame.
+ */
+ for (walk = priv->movies; walk; walk = walk->next) {
+ SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (walk->data);
+ if (klass->iterate_start)
+ klass->iterate_start (walk->data);
+ }
+ swfdec_player_perform_actions (player);
+ SWFDEC_INFO ("=== STOP ITERATION ===");
+ /* this loop allows removal of walk->data */
+ walk = priv->movies;
+ while (walk) {
+ SwfdecMovie *cur = walk->data;
+ SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (cur);
+ walk = walk->next;
+ g_assert (klass->iterate_end);
+ if (!klass->iterate_end (cur))
+ swfdec_movie_destroy (cur);
+ }
+ swfdec_player_execute_on_load_init (player);
+ swfdec_function_list_execute_and_clear (&priv->resource_requests, player);
+ swfdec_player_perform_actions (player);
+}
+
+static void
+swfdec_player_advance_audio (SwfdecPlayer *player, guint samples)
+{
+ SwfdecAudio *audio;
+ GList *walk;
+
+ if (samples == 0)
+ return;
+
+ /* don't use for loop here, because we need to advance walk before
+ * removing the audio */
+ walk = player->priv->audio;
+ while (walk) {
+ audio = walk->data;
+ walk = walk->next;
+ if (swfdec_audio_iterate (audio, samples) == 0)
+ swfdec_audio_remove (audio);
+ }
+}
+
+static void
+swfdec_player_do_advance (SwfdecPlayer *player, gulong msecs, guint audio_samples)
+{
+ SwfdecPlayerPrivate *priv = player->priv;
+ SwfdecTimeout *timeout;
+ SwfdecTick target_time;
+ guint frames_now;
+
+ if (!swfdec_player_lock (player))
+ return;
+
+ target_time = priv->time + SWFDEC_MSECS_TO_TICKS (msecs);
+ SWFDEC_DEBUG ("advancing %lu msecs (%u audio frames)", msecs, audio_samples);
+
+ for (timeout = priv->timeouts ? priv->timeouts->data : NULL;
+ timeout && timeout->timestamp <= target_time;
+ timeout = priv->timeouts ? priv->timeouts->data : NULL) {
+ priv->timeouts = g_list_remove (priv->timeouts, timeout);
+ frames_now = SWFDEC_TICKS_TO_SAMPLES (timeout->timestamp) -
+ SWFDEC_TICKS_TO_SAMPLES (priv->time);
+ priv->time = timeout->timestamp;
+ swfdec_player_advance_audio (player, frames_now);
+ audio_samples -= frames_now;
+ SWFDEC_LOG ("activating timeout %p now (timeout is %"G_GUINT64_FORMAT", target time is %"G_GUINT64_FORMAT,
+ timeout, timeout->timestamp, target_time);
+ timeout->callback (timeout);
+ swfdec_player_perform_actions (player);
+ }
+ if (target_time > priv->time) {
+ frames_now = SWFDEC_TICKS_TO_SAMPLES (target_time) -
+ SWFDEC_TICKS_TO_SAMPLES (priv->time);
+ priv->time = target_time;
+ swfdec_player_advance_audio (player, frames_now);
+ audio_samples -= frames_now;
+ }
+ g_assert (audio_samples == 0);
+
+ g_object_notify (G_OBJECT (player), "next-event");
+ swfdec_player_unlock (player);
+}
+
+void
+swfdec_player_perform_actions (SwfdecPlayer *player)
+{
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+ while (swfdec_player_do_action (player));
+}
+
+/* used for breakpoints */
+void
+swfdec_player_lock_soft (SwfdecPlayer *player)
+{
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_assert (swfdec_rectangle_is_empty (&player->priv->invalid_extents));
+
+ g_object_freeze_notify (G_OBJECT (player));
+ g_timer_start (player->priv->runtime);
+ SWFDEC_DEBUG ("LOCKED");
+}
+
+gboolean
+swfdec_player_lock (SwfdecPlayer *player)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE);
+ g_assert (swfdec_ring_buffer_get_n_elements (player->priv->actions[0]) == 0);
+ g_assert (swfdec_ring_buffer_get_n_elements (player->priv->actions[1]) == 0);
+ g_assert (swfdec_ring_buffer_get_n_elements (player->priv->actions[2]) == 0);
+ g_assert (swfdec_ring_buffer_get_n_elements (player->priv->actions[3]) == 0);
+
+ if (swfdec_as_context_is_aborted (SWFDEC_AS_CONTEXT (player)))
+ return FALSE;
+
+ g_object_ref (player);
+ swfdec_player_lock_soft (player);
+ return TRUE;
+}
+
+/* runs queued invalidations for all movies and resets the movies */
+static void
+swfdec_player_update_movies (SwfdecPlayer *player)
+{
+ SwfdecMovie *movie;
+ GList *walk;
+
+ /* FIXME: This g_list_last could be slow */
+ for (walk = g_list_last (player->priv->movies); walk; walk = walk->prev) {
+ movie = walk->data;
+
+ swfdec_movie_update (movie);
+ if (movie->invalidate_last) {
+ cairo_matrix_t matrix;
+
+ if (movie->parent)
+ swfdec_movie_local_to_global_matrix (movie->parent, &matrix);
+ else
+ cairo_matrix_init_identity (&matrix);
+ swfdec_movie_invalidate (movie, &matrix, TRUE);
+ movie->invalidate_last = FALSE;
+ }
+ }
+}
+
+/* used for breakpoints */
+void
+swfdec_player_unlock_soft (SwfdecPlayer *player)
+{
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+ SWFDEC_DEBUG ("UNLOCK");
+ g_timer_stop (player->priv->runtime);
+ swfdec_player_update_movies (player);
+ swfdec_player_update_mouse_cursor (player);
+ g_object_thaw_notify (G_OBJECT (player));
+ swfdec_player_emit_signals (player);
+}
+
+void
+swfdec_player_unlock (SwfdecPlayer *player)
+{
+ SwfdecAsContext *context;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_assert (swfdec_ring_buffer_get_n_elements (player->priv->actions[0]) == 0);
+ g_assert (swfdec_ring_buffer_get_n_elements (player->priv->actions[1]) == 0);
+ g_assert (swfdec_ring_buffer_get_n_elements (player->priv->actions[2]) == 0);
+ g_assert (swfdec_ring_buffer_get_n_elements (player->priv->actions[3]) == 0);
+ context = SWFDEC_AS_CONTEXT (player);
+ g_return_if_fail (context->state != SWFDEC_AS_CONTEXT_INTERRUPTED);
+
+ if (context->state == SWFDEC_AS_CONTEXT_RUNNING)
+ swfdec_as_context_maybe_gc (SWFDEC_AS_CONTEXT (player));
+ swfdec_player_unlock_soft (player);
+ g_object_unref (player);
+}
+
+static gboolean
+swfdec_accumulate_or (GSignalInvocationHint *ihint, GValue *return_accu,
+ const GValue *handler_return, gpointer data)
+{
+ if (g_value_get_boolean (handler_return))
+ g_value_set_boolean (return_accu, TRUE);
+ return TRUE;
+}
+
+static void
+swfdec_player_mark_string_object (gpointer key, gpointer value, gpointer data)
+{
+ swfdec_as_string_mark (key);
+ swfdec_as_object_mark (value);
+}
+
+static void
+swfdec_player_mark (SwfdecAsContext *context)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (context);
+ SwfdecPlayerPrivate *priv = player->priv;
+
+ g_hash_table_foreach (priv->registered_classes, swfdec_player_mark_string_object, NULL);
+ g_hash_table_foreach (priv->scripting_callbacks, swfdec_player_mark_string_object, NULL);
+ g_list_foreach (priv->roots, (GFunc) swfdec_as_object_mark, NULL);
+ g_list_foreach (priv->intervals, (GFunc) swfdec_as_object_mark, NULL);
+ g_slist_foreach (priv->sandboxes, (GFunc) swfdec_as_object_mark, NULL);
+ swfdec_function_list_execute (&priv->rooted, player);
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (priv->resource));
+
+ SWFDEC_AS_CONTEXT_CLASS (swfdec_player_parent_class)->mark (context);
+}
+
+static void
+swfdec_player_get_time (SwfdecAsContext *context, GTimeVal *tv)
+{
+ *tv = context->start_time;
+
+ /* FIXME: what granularity do we want? Currently it's milliseconds */
+ g_time_val_add (tv, SWFDEC_TICKS_TO_MSECS (SWFDEC_PLAYER (context)->priv->time) * 1000);
+}
+
+static gboolean
+swfdec_player_check_continue (SwfdecAsContext *context)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (context);
+ SwfdecPlayerPrivate *priv = player->priv;
+
+ if (priv->max_runtime == 0)
+ return TRUE;
+ return g_timer_elapsed (priv->runtime, NULL) * 1000 <= priv->max_runtime;
+}
+
+static void
+swfdec_player_class_init (SwfdecPlayerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ SwfdecAsContextClass *context_class = SWFDEC_AS_CONTEXT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (SwfdecPlayerPrivate));
+
+ object_class->get_property = swfdec_player_get_property;
+ object_class->set_property = swfdec_player_set_property;
+ object_class->dispose = swfdec_player_dispose;
+
+ 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));
+ g_object_class_install_property (object_class, PROP_NEXT_EVENT,
+ g_param_spec_long ("next-event", "next event", "how many milliseconds until the next event or -1 when no event pending",
+ -1, G_MAXLONG, -1, G_PARAM_READABLE));
+ g_object_class_install_property (object_class, PROP_CACHE_SIZE,
+ g_param_spec_ulong ("cache-size", "cache size", "maximum cache size in bytes",
+ 0, G_MAXUINT, 50 * 1024 * 1024, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_BACKGROUND_COLOR,
+ g_param_spec_uint ("background-color", "background color", "ARGB color used to draw the background",
+ 0, G_MAXUINT, SWFDEC_COLOR_COMBINE (0xFF, 0xFF, 0xFF, 0xFF), G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_WIDTH,
+ g_param_spec_int ("width", "width", "current width of the movie",
+ -1, G_MAXINT, -1, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_HEIGHT,
+ g_param_spec_int ("height", "height", "current height of the movie",
+ -1, G_MAXINT, -1, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_ALIGNMENT,
+ g_param_spec_enum ("alignment", "alignment", "point of the screen to align the output to",
+ SWFDEC_TYPE_ALIGNMENT, SWFDEC_ALIGNMENT_CENTER, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_SCALE,
+ g_param_spec_enum ("scale-mode", "scale mode", "method used to scale the movie",
+ SWFDEC_TYPE_SCALE_MODE, SWFDEC_SCALE_SHOW_ALL, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_SCRIPTING,
+ g_param_spec_object ("scripting", "scripting", "external scripting implementation",
+ SWFDEC_TYPE_PLAYER_SCRIPTING, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_SCALE,
+ g_param_spec_object ("system", "system", "object holding system information",
+ SWFDEC_TYPE_SYSTEM, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_MAX_RUNTIME,
+ g_param_spec_ulong ("max-runtime", "maximum runtime", "maximum time in msecs scripts may run in the player before aborting",
+ 0, G_MAXULONG, 10 * 1000, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_LOADER_TYPE,
+ g_param_spec_gtype ("loader-type", "loader type", "type to use for creating loaders",
+ SWFDEC_TYPE_LOADER, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class, PROP_SOCKET_TYPE,
+ g_param_spec_gtype ("socket-type", "socket type", "type to use for creating sockets",
+ SWFDEC_TYPE_SOCKET, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class, PROP_URL,
+ g_param_spec_boxed ("url", "url", "URL of resource currently played back or NULL if not set",
+ SWFDEC_TYPE_URL, G_PARAM_READABLE));
+ g_object_class_install_property (object_class, PROP_BASE_URL,
+ g_param_spec_boxed ("base-url", "base url", "base URL for creating new resource or NULL if not set yet",
+ SWFDEC_TYPE_URL, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_VARIABLES,
+ g_param_spec_string ("variables", "variables", "variables to use when setting the URL",
+ NULL, G_PARAM_READWRITE));
+
+ /**
+ * SwfdecPlayer::invalidate:
+ * @player: the #SwfdecPlayer affected
+ * @extents: the smallest rectangle enclosing the full region of changes
+ * @rectangles: a number of smaller rectangles for fine-grained control over
+ * changes
+ * @n_rectangles: number of rectangles in @rectangles
+ *
+ * This signal is emitted whenever graphical elements inside the player have
+ * changed. It provides two ways to look at the changes: By looking at the
+ * @extents parameter, it provides a simple way to get a single rectangle that
+ * encloses all changes. By looking at the @rectangles array, you can get
+ * finer control over changes which is very useful if your rendering system
+ * provides a way to handle regions.
+ */
+ signals[INVALIDATE] = g_signal_new ("invalidate", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, swfdec_marshal_VOID__BOXED_POINTER_UINT,
+ G_TYPE_NONE, 3, SWFDEC_TYPE_RECTANGLE, G_TYPE_POINTER, G_TYPE_UINT);
+ /**
+ * SwfdecPlayer::advance:
+ * @player: the #SwfdecPlayer affected
+ * @msecs: the amount of milliseconds the player will advance
+ * @audio_samples: number of frames the audio is advanced (in 44100Hz steps)
+ *
+ * Emitted whenever the player advances.
+ */
+ signals[ADVANCE] = g_signal_new ("advance", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (SwfdecPlayerClass, advance),
+ NULL, NULL, swfdec_marshal_VOID__ULONG_UINT,
+ G_TYPE_NONE, 2, G_TYPE_ULONG, G_TYPE_UINT);
+ /**
+ * SwfdecPlayer::handle-key:
+ * @player: the #SwfdecPlayer affected
+ * @key: #SwfdecKey that was pressed or released
+ * @pressed: %TRUE if the @key was pressed or %FALSE if it was released
+ *
+ * This signal is emitted whenever @player should respond to a key event. If
+ * any of the handlers returns TRUE, swfdec_player_key_press() or
+ * swfdec_player_key_release() will return TRUE. Note that unlike many event
+ * handlers in gtk, returning TRUE will not stop further event handlers from
+ * being invoked. Use g_signal_stop_emission() in that case.
+ *
+ * Returns: TRUE if this handler handles the event.
+ **/
+ signals[HANDLE_KEY] = g_signal_new ("handle-key", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (SwfdecPlayerClass, handle_key),
+ swfdec_accumulate_or, NULL, swfdec_marshal_BOOLEAN__UINT_UINT_BOOLEAN,
+ G_TYPE_BOOLEAN, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_BOOLEAN);
+ /**
+ * SwfdecPlayer::handle-mouse:
+ * @player: the #SwfdecPlayer affected
+ * @x: new x coordinate of the mouse
+ * @y: new y coordinate of the mouse
+ * @button: 0 for a mouse move, a positive number if a button was pressed,
+ * a negative number if a button was released
+ *
+ * This signal is emitted whenever @player should respond to a mouse event. If
+ * any of the handlers returns TRUE, swfdec_player_handle_mouse() will return
+ * TRUE. Note that unlike many event handlers in gtk, returning TRUE will not
+ * stop further event handlers from being invoked. Use g_signal_stop_emission()
+ * in that case.
+ *
+ * Returns: TRUE if this handler handles the event.
+ **/
+ signals[HANDLE_MOUSE] = g_signal_new ("handle-mouse", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (SwfdecPlayerClass, handle_mouse),
+ swfdec_accumulate_or, NULL, swfdec_marshal_BOOLEAN__DOUBLE_DOUBLE_INT,
+ G_TYPE_BOOLEAN, 3, G_TYPE_DOUBLE, G_TYPE_DOUBLE, G_TYPE_INT);
+ /**
+ * SwfdecPlayer::audio-added:
+ * @player: the #SwfdecPlayer affected
+ * @audio: the audio stream that was added
+ *
+ * Emitted whenever a new audio stream was added to @player.
+ */
+ signals[AUDIO_ADDED] = g_signal_new ("audio-added", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, SWFDEC_TYPE_AUDIO);
+ /**
+ * SwfdecPlayer::audio-removed:
+ * @player: the #SwfdecPlayer affected
+ * @audio: the audio stream that was removed
+ *
+ * Emitted whenever an audio stream was removed from @player. The stream will
+ * have been added with the SwfdecPlayer::audio-added signal previously.
+ */
+ signals[AUDIO_REMOVED] = g_signal_new ("audio-removed", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, SWFDEC_TYPE_AUDIO);
+ /**
+ * SwfdecPlayer::fscommand:
+ * @player: the #SwfdecPlayer affected
+ * @command: the command to execute. This is a lower case string.
+ * @parameter: parameter to pass to the command. The parameter depends on the
+ * function.
+ *
+ * This signal is emited whenever a Flash script command (also known as
+ * fscommand) is encountered. This method is ued by the Flash file to
+ * communicate with the hosting environment. In web browsers it is used to
+ * call Javascript functions. Standalone Flash players understand a limited
+ * set of functions. They vary from player to player, but the most common are
+ * listed here: <itemizedlist>
+ * <listitem><para>"quit": quits the player.</para></listitem>
+ * <listitem><para>"fullscreen": A boolean setting (parameter is "true" or
+ * "false") that sets the player into fullscreen mode.</para></listitem>
+ * <listitem><para>"allowscale": A boolean setting that tells the player to
+ * not scale the Flash application.</para></listitem>
+ * <listitem><para>"showmenu": A boolean setting that tells the Flash player
+ * to not show its own entries in the right-click menu.</para></listitem>
+ * <listitem><para>"exec": Run an external executable. The parameter
+ * specifies the path.</para></listitem>
+ * <listitem><para>"trapallkeys": A boolean setting that tells the Flash
+ * player to pass all key events to the Flash application instead of using it
+ * for keyboard shortcuts or similar.</para></listitem>
+ * </itemizedlist>
+ */
+ /* FIXME: document fscommand:toggle */
+ signals[FSCOMMAND] = g_signal_new ("fscommand", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, swfdec_marshal_VOID__STRING_STRING,
+ G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
+ /**
+ * SwfdecPlayer::launch:
+ * @player: the #SwfdecPlayer affected
+ * @request: the type of request
+ * @url: URL to open
+ * @target: target to load the URL into
+ * @data: optional data to pass on with the request. Will be of mime type
+ * application/x-www-form-urlencoded. Can be %NULL indicating no data
+ * should be passed.
+ *
+ * Emitted whenever the @player encounters an URL that should be loaded into
+ * a target the Flash player does not recognize. In most cases this happens
+ * when the user clicks a link in an embedded Flash movie that should open a
+ * new web page.
+ * The effect of calling any swfdec functions on the emitting @player is undefined.
+ */
+ signals[LAUNCH] = g_signal_new ("launch", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, swfdec_marshal_VOID__ENUM_STRING_STRING_BOXED,
+ G_TYPE_NONE, 4, SWFDEC_TYPE_LOADER_REQUEST, G_TYPE_STRING, G_TYPE_STRING,
+ SWFDEC_TYPE_BUFFER);
+
+ context_class->mark = swfdec_player_mark;
+ context_class->get_time = swfdec_player_get_time;
+ context_class->check_continue = swfdec_player_check_continue;
+
+ klass->advance = swfdec_player_do_advance;
+ klass->handle_key = swfdec_player_do_handle_key;
+ klass->handle_mouse = swfdec_player_do_handle_mouse;
+}
+
+static void
+swfdec_player_init (SwfdecPlayer *player)
+{
+ SwfdecPlayerPrivate *priv;
+ guint i;
+
+ player->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (player, SWFDEC_TYPE_PLAYER, SwfdecPlayerPrivate);
+ priv->player = player;
+
+ priv->system = swfdec_system_new ();
+ priv->registered_classes = g_hash_table_new (g_direct_hash, g_direct_equal);
+ priv->scripting_callbacks = g_hash_table_new (g_direct_hash, g_direct_equal);
+
+ for (i = 0; i < SWFDEC_PLAYER_N_ACTION_QUEUES; i++) {
+ priv->actions[i] = swfdec_ring_buffer_new_for_type (SwfdecPlayerAction, 16);
+ }
+ priv->external_actions = swfdec_ring_buffer_new_for_type (SwfdecPlayerExternalAction, 8);
+ priv->cache = swfdec_cache_new (50 * 1024 * 1024); /* 100 MB */
+ priv->bgcolor = SWFDEC_COLOR_COMBINE (0xFF, 0xFF, 0xFF, 0xFF);
+ priv->socket_type = SWFDEC_TYPE_SOCKET;
+
+ priv->runtime = g_timer_new ();
+ g_timer_stop (priv->runtime);
+ priv->max_runtime = 10 * 1000;
+ priv->invalidations = g_array_new (FALSE, FALSE, sizeof (SwfdecRectangle));
+ priv->mouse_visible = TRUE;
+ priv->mouse_cursor = SWFDEC_MOUSE_CURSOR_NORMAL;
+ priv->iterate_timeout.callback = swfdec_player_iterate;
+ priv->stage_width = -1;
+ priv->stage_height = -1;
+}
+
+void
+swfdec_player_stop_all_sounds (SwfdecPlayer *player)
+{
+ SwfdecPlayerPrivate *priv;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+ priv = player->priv;
+ while (priv->audio) {
+ swfdec_audio_remove (priv->audio->data);
+ }
+}
+
+void
+swfdec_player_stop_sounds (SwfdecPlayer *player, SwfdecAudioRemoveFunc func, gpointer data)
+{
+ GList *walk;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (func);
+
+ walk = player->priv->audio;
+ while (walk) {
+ SwfdecAudio *audio = walk->data;
+ walk = walk->next;
+ if (func (audio, data))
+ swfdec_audio_remove (audio);
+ }
+}
+
+/* rect is in global coordinates */
+void
+swfdec_player_invalidate (SwfdecPlayer *player, const SwfdecRect *rect)
+{
+ SwfdecPlayerPrivate *priv = player->priv;
+ SwfdecRectangle r;
+ SwfdecRect tmp;
+ guint i;
+
+ if (swfdec_rect_is_empty (rect))
+ return;
+
+ tmp = *rect;
+ swfdec_player_global_to_stage (player, &tmp.x0, &tmp.y0);
+ swfdec_player_global_to_stage (player, &tmp.x1, &tmp.y1);
+ swfdec_rectangle_init_rect (&r, &tmp);
+ /* FIXME: currently we clamp the rectangle to the visible area, it might
+ * be useful to allow out-of-bounds drawing. In that case this needs to be
+ * changed */
+ swfdec_rectangle_intersect (&r, &r, &priv->stage);
+ if (swfdec_rectangle_is_empty (&r))
+ return;
+
+ SWFDEC_LOG (" invalidating %d %d %d %d", r.x, r.y, r.width, r.height);
+ /* FIXME: get region code into swfdec? */
+ for (i = 0; i < priv->invalidations->len; i++) {
+ SwfdecRectangle *cur = &g_array_index (priv->invalidations, SwfdecRectangle, i);
+ if (swfdec_rectangle_contains (cur, &r))
+ break;
+ if (swfdec_rectangle_contains (&r, cur)) {
+ *cur = r;
+ swfdec_rectangle_union (&priv->invalid_extents, &priv->invalid_extents, &r);
+ }
+ }
+ if (i == priv->invalidations->len) {
+ g_array_append_val (priv->invalidations, r);
+ swfdec_rectangle_union (&priv->invalid_extents, &priv->invalid_extents, &r);
+ }
+ SWFDEC_DEBUG ("toplevel invalidation of %g %g %g %g - invalid region now %d %d %d %d (%u subregions)",
+ rect->x0, rect->y0, rect->x1, rect->y1,
+ priv->invalid_extents.x, priv->invalid_extents.y,
+ priv->invalid_extents.x + priv->invalid_extents.width,
+ priv->invalid_extents.y + priv->invalid_extents.height,
+ priv->invalidations->len);
+}
+
+/**
+ * swfdec_player_get_level:
+ * @player: a #SwfdecPlayer
+ * @name: a name that is supposed to refer to a level
+ *
+ * Checks if the given @name refers to a level, and if so, returns the level.
+ * An example for such a name is "_level5". These strings are used to refer to
+ * root movies inside the Flash player.
+ *
+ * Returns: the level referred to by @name or -1 if none
+ **/
+int
+swfdec_player_get_level (SwfdecPlayer *player, const char *name)
+{
+ char *end;
+ gulong l;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), -1);
+ g_return_val_if_fail (name != NULL, -1);
+
+ /* check name starts with "_level" */
+ if (swfdec_strncmp (SWFDEC_AS_CONTEXT (player)->version, name, "_level", 6) != 0)
+ return -1;
+ name += 6;
+ /* extract depth from rest string (or fail if it's not a depth) */
+ errno = 0;
+ l = strtoul (name, &end, 10);
+ if (errno != 0 || *end != 0 || l > G_MAXINT)
+ return -1;
+ return l;
+}
+
+SwfdecSpriteMovie *
+swfdec_player_create_movie_at_level (SwfdecPlayer *player, SwfdecResource *resource,
+ int level)
+{
+ SwfdecMovie *movie;
+ const char *s;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (level >= 0, NULL);
+ g_return_val_if_fail (swfdec_player_get_movie_at_level (player, level) == NULL, NULL);
+
+ /* create new root movie */
+ s = swfdec_as_context_give_string (SWFDEC_AS_CONTEXT (player), g_strdup_printf ("_level%d", level));
+ movie = swfdec_movie_new (player, level - 16384, NULL, resource, NULL, s);
+ if (movie == NULL)
+ return NULL;
+ movie->name = SWFDEC_AS_STR_EMPTY;
+ return SWFDEC_SPRITE_MOVIE (movie);
+}
+
+/**
+ * swfdec_player_get_movie_at_level:
+ * @player: a #SwfdecPlayer
+ * @level: number of the level
+ *
+ * This function is used to look up root movies in the given @player.
+ *
+ * Returns: the #SwfdecMovie located at the given level or %NULL if there is no
+ * movie at that level.
+ **/
+SwfdecSpriteMovie *
+swfdec_player_get_movie_at_level (SwfdecPlayer *player, int level)
+{
+ GList *walk;
+ int depth;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (level >= 0, NULL);
+
+ depth = level - 16384;
+ /* find movie */
+ for (walk = player->priv->roots; walk; walk = walk->next) {
+ SwfdecMovie *cur = walk->data;
+ if (cur->depth < depth)
+ continue;
+ if (cur->depth == depth)
+ return SWFDEC_SPRITE_MOVIE (cur);
+ break;
+ }
+ return NULL;
+}
+
+void
+swfdec_player_launch (SwfdecPlayer *player, SwfdecLoaderRequest request, const char *url,
+ const char *target, SwfdecBuffer *data)
+{
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (url != NULL);
+ g_return_if_fail (target != NULL);
+
+ if (!g_ascii_strncasecmp (url, "FSCommand:", strlen ("FSCommand:"))) {
+ const char *command = url + strlen ("FSCommand:");
+ g_signal_emit (player, signals[FSCOMMAND], 0, command, target);
+ return;
+ }
+ g_signal_emit (player, signals[LAUNCH], 0, (int) request, url, target, data);
+}
+
+/**
+ * swfdec_player_initialize:
+ * @player: a #SwfdecPlayer
+ * @version: Flash version to use
+ * @rate: framerate in 256th or 0 for undefined
+ * @width: width of movie
+ * @height: height of movie
+ *
+ * Initializes the player to the given @version, @width, @height and @rate. If
+ * the player is already initialized, this function does nothing.
+ **/
+void
+swfdec_player_initialize (SwfdecPlayer *player, guint rate, guint width, guint height)
+{
+ SwfdecPlayerPrivate *priv;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (rate > 0);
+
+ priv = player->priv;
+ if (!priv->initialized) {
+ priv->initialized = TRUE;
+ g_object_notify (G_OBJECT (player), "initialized");
+ } else {
+ /* FIXME: need to kick all other movies out here */
+ swfdec_player_remove_timeout (player, &priv->iterate_timeout);
+ }
+
+ SWFDEC_INFO ("initializing player to size %ux%u and rate %u/256", width, height, rate);
+ if (rate != priv->rate) {
+ priv->rate = rate;
+ g_object_notify (G_OBJECT (player), "rate");
+ }
+ if (priv->width != width) {
+ priv->width = width;
+ g_object_notify (G_OBJECT (player), "default-width");
+ }
+ if (priv->height != height) {
+ priv->height = height;
+ g_object_notify (G_OBJECT (player), "default-height");
+ }
+ priv->broadcasted_width = priv->internal_width = priv->stage_width >= 0 ? (guint) priv->stage_width : priv->width;
+ priv->broadcasted_height = priv->internal_height = priv->stage_height >= 0 ? (guint) priv->stage_height : priv->height;
+ swfdec_player_update_scale (player);
+
+ priv->iterate_timeout.timestamp = priv->time + SWFDEC_TICKS_PER_SECOND * 256 / priv->rate / 10;
+ swfdec_player_add_timeout (player, &priv->iterate_timeout);
+ SWFDEC_LOG ("initialized iterate timeout %p to %"G_GUINT64_FORMAT" (now %"G_GUINT64_FORMAT")",
+ &priv->iterate_timeout, priv->iterate_timeout.timestamp, priv->time);
+}
+
+/**
+ * swfdec_player_get_export_class:
+ * @player: a #SwfdecPlayer
+ * @name: garbage-collected string naming the export
+ *
+ * Looks up the constructor for characters that are exported using @name.
+ *
+ * Returns: a #SwfdecAsObject naming the constructor or %NULL if none
+ **/
+SwfdecAsObject *
+swfdec_player_get_export_class (SwfdecPlayer *player, const char *name)
+{
+ SwfdecPlayerPrivate *priv = player->priv;
+ SwfdecAsObject *ret;
+
+ ret = g_hash_table_lookup (priv->registered_classes, name);
+ if (ret) {
+ SWFDEC_LOG ("found registered class %p for %s", ret, name);
+ return ret;
+ }
+ return NULL;
+}
+
+/**
+ * swfdec_player_set_export_class:
+ * @player: a #SwfdecPlayer
+ * @name: garbage-collected string naming the export
+ * @object: object to use as constructor or %NULL for none
+ *
+ * Sets the constructor to be used for instances created using the object
+ * exported with @name.
+ **/
+void
+swfdec_player_set_export_class (SwfdecPlayer *player, const char *name, SwfdecAsObject *object)
+{
+ SwfdecPlayerPrivate *priv;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (name != NULL);
+ g_return_if_fail (object == NULL || SWFDEC_IS_AS_OBJECT (object));
+
+ priv = player->priv;
+ if (object) {
+ SWFDEC_LOG ("setting class %p for %s", object, name);
+ g_hash_table_insert (priv->registered_classes, (gpointer) name, object);
+ } else {
+ g_hash_table_remove (priv->registered_classes, name);
+ }
+}
+
+/**
+ * swfdec_player_create_socket:
+ * @player: a #SwfdecPlayer
+ * @hostname: the host name to connect to.
+ * @port: the port to connect to
+ *
+ * Creates a new socket connecting to the given hostname and port.
+ *
+ * Returns: a new socket or %NULL if no socket implementation exists
+ **/
+/* FIXME: always return a socket? */
+SwfdecSocket *
+swfdec_player_create_socket (SwfdecPlayer *player, const char *hostname, guint port)
+{
+ SwfdecSocket *sock;
+ SwfdecSocketClass *klass;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (hostname != NULL, NULL);
+ g_return_val_if_fail (port > 0, NULL);
+
+ if (!G_TYPE_IS_INSTANTIATABLE (player->priv->socket_type)) {
+ SWFDEC_INFO ("can't create socket, no socket type set.");
+ return NULL;
+ }
+ klass = g_type_class_ref (player->priv->socket_type);
+ sock = klass->create (hostname, port);
+ g_type_class_unref (klass);
+
+ return sock;
+}
+
+SwfdecURL *
+swfdec_player_create_url (SwfdecPlayer *player, const char *string)
+{
+ SwfdecURL *url;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (string != NULL, NULL);
+
+ url = swfdec_url_new_relative (player->priv->base_url, string);
+ /* FIXME: check that we don't go below base for local urls */
+ return url;
+}
+
+SwfdecLoader *
+swfdec_player_load (SwfdecPlayer *player, const char *url,
+ SwfdecLoaderRequest request, SwfdecBuffer *buffer)
+{
+ SwfdecLoader *loader;
+ SwfdecLoaderClass *klass;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (url != NULL, NULL);
+
+ loader = g_object_new (player->priv->loader_type, NULL);
+ klass = SWFDEC_LOADER_GET_CLASS (loader);
+ g_return_val_if_fail (klass->load != NULL, NULL);
+ klass->load (loader, player, url, request, buffer);
+
+ return loader;
+}
+
+/** PUBLIC API ***/
+
+/**
+ * swfdec_player_new:
+ * @debugger: %NULL or a #SwfdecAsDebugger to use for debugging this player.
+ *
+ * Creates a new player. This function is supposed to be used for testing.
+ * Because of this, the created player will behave as predictable as possible.
+ * For example, it will generate the same random number sequence every time.
+ * The function calls swfdec_init () for you if it wasn't called before.
+ *
+ * Returns: The new player
+ **/
+SwfdecPlayer *
+swfdec_player_new (SwfdecAsDebugger *debugger)
+{
+ static const GTimeVal the_beginning = { 1035840244, 0 };
+ SwfdecPlayer *player;
+
+ g_return_val_if_fail (debugger == NULL || SWFDEC_IS_AS_DEBUGGER (debugger), NULL);
+
+ swfdec_init ();
+ player = g_object_new (SWFDEC_TYPE_PLAYER, "random-seed", 0,
+ "loader-type", SWFDEC_TYPE_FILE_LOADER, "socket-type", SWFDEC_TYPE_SOCKET,
+ "max-runtime", 0,
+ "debugger", debugger, NULL);
+ /* FIXME: make this a property or something and don't set it here */
+ SWFDEC_AS_CONTEXT (player)->start_time = the_beginning;
+
+ return player;
+}
+
+/**
+ * swfdec_init:
+ *
+ * Initializes the Swfdec library.
+ **/
+void
+swfdec_init (void)
+{
+ static gboolean _inited = FALSE;
+ const char *s;
+
+ if (_inited)
+ return;
+
+ _inited = TRUE;
+
+ if (!g_thread_supported ())
+ g_thread_init (NULL);
+ g_type_init ();
+ oil_init ();
+
+ s = g_getenv ("SWFDEC_DEBUG");
+ if (s && s[0]) {
+ char *end;
+ int level;
+
+ level = strtoul (s, &end, 0);
+ if (end[0] == 0) {
+ swfdec_debug_set_level (level);
+ }
+ }
+}
+
+/**
+ * swfdec_player_mouse_move:
+ * @player: a #SwfdecPlayer
+ * @x: x coordinate of mouse
+ * @y: y coordinate of mouse
+ *
+ * Updates the current mouse position. If the mouse has left the area of @player,
+ * you should pass values outside the movie size for @x and @y. You will
+ * probably want to call swfdec_player_advance() before to update the player to
+ * the correct time when calling this function.
+ *
+ * Returns: %TRUE if the mouse event was handled. %FALSE if the event should be
+ * propagated further. A mouse event may not be handled if the user
+ * clicked on a translucent area.
+ **/
+gboolean
+swfdec_player_mouse_move (SwfdecPlayer *player, double x, double y)
+{
+ gboolean ret;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE);
+
+ g_signal_emit (player, signals[HANDLE_MOUSE], 0, x, y, 0, &ret);
+
+ return ret;
+}
+
+/**
+ * swfdec_player_mouse_press:
+ * @player: a #SwfdecPlayer
+ * @x: x coordinate of mouse
+ * @y: y coordinate of mouse
+ * @button: number of the button that was pressed. Swfdec supports up to 32
+ * buttons.
+ *
+ * Tells the @player that the mouse button @button was pressed at the given
+ * coordinate.
+ *
+ * Returns: %TRUE if the mouse event was handled. %FALSE if the event should be
+ * propagated further. A mouse event may not be handled if the user
+ * clicked on a translucent area.
+ **/
+gboolean
+swfdec_player_mouse_press (SwfdecPlayer *player, double x, double y,
+ guint button)
+{
+ gboolean ret;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE);
+ g_return_val_if_fail (button > 0 && button <= 32, FALSE);
+
+ g_signal_emit (player, signals[HANDLE_MOUSE], 0, x, y, button, &ret);
+
+ return ret;
+}
+
+/**
+ * swfdec_player_mouse_release:
+ * @player: a #SwfdecPlayer
+ * @x: x coordinate of mouse
+ * @y: y coordinate of mouse
+ * @button: number of the button that was released. Swfdec supports up to 32
+ * buttons.
+ *
+ * Tells the @player that the mouse button @button was released at the given
+ * coordinate.
+ *
+ * Returns: %TRUE if the mouse event was handled. %FALSE if the event should be
+ * propagated further. A mouse event may not be handled if the user
+ * clicked on a translucent area.
+ **/
+gboolean
+swfdec_player_mouse_release (SwfdecPlayer *player, double x, double y,
+ guint button)
+{
+ gboolean ret;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE);
+ g_return_val_if_fail (button > 0 && button <= 32, FALSE);
+
+ g_signal_emit (player, signals[HANDLE_MOUSE], 0, x, y, -button, &ret);
+
+ return ret;
+}
+
+/**
+ * swfdec_player_key_press:
+ * @player: a #SwfdecPlayer
+ * @keycode: the key that was pressed
+ * @character: UCS4 of the character that was inserted or 0 if none
+ *
+ * Call this function to make the @player react to a key press. Be sure to
+ * check that keycode transformations are done correctly. For a list of
+ * keycodes see FIXME.
+ *
+ * Returns: %TRUE if the key press was handled by the @player, %FALSE if it
+ * should be propagated further
+ **/
+gboolean
+swfdec_player_key_press (SwfdecPlayer *player, guint keycode, guint character)
+{
+ gboolean ret;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE);
+ g_return_val_if_fail (keycode < 256, FALSE);
+
+ g_signal_emit (player, signals[HANDLE_KEY], 0, keycode, character, TRUE, &ret);
+
+ return ret;
+}
+
+/**
+ * swfdec_player_key_release:
+ * @player: a #SwfdecPlayer
+ * @keycode: the key that was released
+ * @character: UCS4 of the character that was inserted or 0 if none
+ *
+ * Call this function to make the @player react to a key being released. See
+ * swfdec_player_key_press() for details.
+ *
+ * Returns: %TRUE if the key press was handled by the @player, %FALSE if it
+ * should be propagated further
+ **/
+gboolean
+swfdec_player_key_release (SwfdecPlayer *player, guint keycode, guint character)
+{
+ gboolean ret;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE);
+ g_return_val_if_fail (keycode < 256, FALSE);
+
+ g_signal_emit (player, signals[HANDLE_KEY], 0, keycode, character, FALSE, &ret);
+
+ return ret;
+}
+
+/**
+ * swfdec_player_render:
+ * @player: a #SwfdecPlayer
+ * @cr: #cairo_t to render to
+ * @x: x coordinate of top left position to render
+ * @y: y coordinate of top left position to render
+ * @width: width of area to render or 0 for full width
+ * @height: height of area to render or 0 for full height
+ *
+ * Renders the given area of the current frame to @cr.
+ **/
+void
+swfdec_player_render (SwfdecPlayer *player, cairo_t *cr,
+ double x, double y, double width, double height)
+{
+ static const SwfdecColorTransform trans = { FALSE, 256, 0, 256, 0, 256, 0, 256, 0 };
+ SwfdecPlayerPrivate *priv;
+ GList *walk;
+ SwfdecRect real;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (cr != NULL);
+ g_return_if_fail (width >= 0.0);
+ g_return_if_fail (height >= 0.0);
+
+ /* FIXME: fail when !initialized? */
+ if (!swfdec_player_is_initialized (player))
+ return;
+
+ priv = player->priv;
+ if (width == 0.0)
+ width = priv->stage_width;
+ if (height == 0.0)
+ height = priv->stage_height;
+ /* clip the area */
+ cairo_save (cr);
+ cairo_rectangle (cr, x, y, width, height);
+ cairo_clip (cr);
+ /* compute the rectangle */
+ x -= priv->offset_x;
+ y -= priv->offset_y;
+ real.x0 = floor (x * SWFDEC_TWIPS_SCALE_FACTOR) / priv->scale_x;
+ real.y0 = floor (y * SWFDEC_TWIPS_SCALE_FACTOR) / priv->scale_y;
+ real.x1 = ceil ((x + width) * SWFDEC_TWIPS_SCALE_FACTOR) / priv->scale_x;
+ real.y1 = ceil ((y + height) * SWFDEC_TWIPS_SCALE_FACTOR) / priv->scale_y;
+ SWFDEC_INFO ("=== %p: START RENDER, area %g %g %g %g ===", player,
+ real.x0, real.y0, real.x1, real.y1);
+ /* convert the cairo matrix */
+ cairo_translate (cr, priv->offset_x, priv->offset_y);
+ cairo_scale (cr, priv->scale_x / SWFDEC_TWIPS_SCALE_FACTOR, priv->scale_y / SWFDEC_TWIPS_SCALE_FACTOR);
+ swfdec_color_set_source (cr, priv->bgcolor);
+ cairo_paint (cr);
+
+ for (walk = priv->roots; walk; walk = walk->next) {
+ swfdec_movie_render (walk->data, cr, &trans, &real);
+ }
+ SWFDEC_INFO ("=== %p: END RENDER ===", player);
+ cairo_restore (cr);
+}
+
+/**
+ * swfdec_player_advance:
+ * @player: the #SwfdecPlayer to advance
+ * @msecs: number of milliseconds to advance
+ *
+ * Advances @player by @msecs. You should make sure to call this function as
+ * often as the SwfdecPlayer::next-event property indicates.
+ **/
+void
+swfdec_player_advance (SwfdecPlayer *player, gulong msecs)
+{
+ SwfdecPlayerPrivate *priv;
+ guint frames;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+ priv = player->priv;
+ frames = SWFDEC_TICKS_TO_SAMPLES (priv->time + SWFDEC_MSECS_TO_TICKS (msecs))
+ - SWFDEC_TICKS_TO_SAMPLES (priv->time);
+ g_signal_emit (player, signals[ADVANCE], 0, msecs, frames);
+}
+
+/**
+ * swfdec_player_is_initialized:
+ * @player: a #SwfdecPlayer
+ *
+ * Determines if the @player is initalized yet. An initialized player is able
+ * to provide basic values like width, height or rate. A player may not be
+ * initialized if the loader it was started with does not reference a Flash
+ * resources or it did not provide enough data yet. If a player is initialized,
+ * it will never be uninitialized again.
+ *
+ * Returns: TRUE if the basic values are known.
+ **/
+gboolean
+swfdec_player_is_initialized (SwfdecPlayer *player)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE);
+
+ return player->priv->initialized;
+}
+
+/**
+ * swfdec_player_get_next_event:
+ * @player: ia #SwfdecPlayer
+ *
+ * Queries how long to the next event. This is the next time when you should
+ * call swfdec_player_advance() to forward to.
+ *
+ * Returns: number of milliseconds until next event or -1 if no outstanding event
+ **/
+glong
+swfdec_player_get_next_event (SwfdecPlayer *player)
+{
+ SwfdecTick tick;
+ guint ret;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), 0);
+
+ if (swfdec_as_context_is_aborted (SWFDEC_AS_CONTEXT (player)))
+ return -1;
+
+ tick = swfdec_player_get_next_event_time (player);
+ if (tick == G_MAXUINT64)
+ return -1;
+ /* round up to full msecs */
+ ret = SWFDEC_TICKS_TO_MSECS (tick + SWFDEC_TICKS_PER_SECOND / 1000 - 1);
+
+ return ret;
+}
+
+/**
+ * swfdec_player_get_rate:
+ * @player: a #SwfdecPlayer
+ *
+ * Queries the framerate of this movie. This number specifies the number
+ * of frames that are supposed to pass per second. It is a
+ * multiple of 1/256. It is possible that the movie has no framerate if it does
+ * not display a Flash movie but an FLV video for example. This does not mean
+ * it will not change however.
+ *
+ * Returns: The framerate of this movie or 0 if it isn't known yet or the
+ * movie doesn't have a framerate.
+ **/
+double
+swfdec_player_get_rate (SwfdecPlayer *player)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), 0.0);
+
+ return player->priv->rate / 256.0;
+}
+
+/**
+ * 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
+ *
+ * If the default size of the movie is initialized, fills in @width and @height
+ * with the size. Otherwise @width and @height are set to 0.
+ **/
+void
+swfdec_player_get_default_size (SwfdecPlayer *player, guint *width, guint *height)
+{
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+ if (width)
+ *width = player->priv->width;
+ if (height)
+ *height = player->priv->height;
+}
+
+/**
+ * swfdec_player_get_size:
+ * @player: a #SwfdecPlayer
+ * @width: integer to store the width in or %NULL
+ * @height: integer to store the height in or %NULL
+ *
+ * Gets the currently set image size. If the default width or height should be
+ * used, the width or height respectively is set to -1.
+ **/
+void
+swfdec_player_get_size (SwfdecPlayer *player, int *width, int *height)
+{
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+ if (width)
+ *width = player->priv->stage_width;
+ if (height)
+ *height = player->priv->stage_height;
+}
+
+static void
+swfdec_player_update_size (gpointer playerp, gpointer unused)
+{
+ SwfdecPlayer *player = playerp;
+ SwfdecPlayerPrivate *priv = player->priv;
+
+ /* FIXME: only update if not fullscreen */
+ priv->internal_width = priv->stage_width >=0 ? (guint) priv->stage_width : priv->width;
+ priv->internal_height = priv->stage_height >=0 ? (guint) priv->stage_height : priv->height;
+
+ if (priv->scale_mode != SWFDEC_SCALE_NONE)
+ return;
+
+ /* only broadcast once */
+ if (priv->internal_width == priv->broadcasted_width &&
+ priv->internal_height == priv->broadcasted_height)
+ return;
+
+ priv->broadcasted_width = priv->internal_width;
+ priv->broadcasted_height = priv->internal_height;
+ swfdec_player_broadcast (player, SWFDEC_AS_STR_Stage, SWFDEC_AS_STR_onResize);
+}
+
+/**
+ * swfdec_player_set_size:
+ * @player: a #SwfdecPlayer
+ * @width: desired width of the movie or -1 for default
+ * @height: desired height of the movie or -1 for default
+ *
+ * Sets the image size to the given values. The image size is what the area that
+ * the @player will render and advocate with scripts.
+ **/
+void
+swfdec_player_set_size (SwfdecPlayer *player, int width, int height)
+{
+ SwfdecPlayerPrivate *priv;
+ gboolean changed = FALSE;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (width >= -1);
+ g_return_if_fail (height >= -1);
+
+ priv = player->priv;
+ if (priv->stage_width != width) {
+ priv->stage_width = width;
+ g_object_notify (G_OBJECT (player), "width");
+ changed = TRUE;
+ }
+ if (priv->stage_height != height) {
+ priv->stage_height = height;
+ g_object_notify (G_OBJECT (player), "height");
+ changed = TRUE;
+ }
+ swfdec_player_update_scale (player);
+ if (changed)
+ swfdec_player_add_external_action (player, player, swfdec_player_update_size, NULL);
+}
+
+/**
+ * swfdec_player_get_audio:
+ * @player: a #SwfdecPlayer
+ *
+ * Returns a list of all currently active audio streams in @player.
+ *
+ * Returns: A #GList of #SwfdecAudio. You must not modify or free this list.
+ **/
+/* FIXME: I don't like this function */
+const GList *
+swfdec_player_get_audio (SwfdecPlayer * player)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+
+ return player->priv->audio;
+}
+
+/**
+ * swfdec_player_get_background_color:
+ * @player: a #SwfdecPlayer
+ *
+ * Gets the current background color. The color will be an ARGB-quad, with the
+ * MSB being the alpha value.
+ *
+ * Returns: the background color as an ARGB value
+ **/
+guint
+swfdec_player_get_background_color (SwfdecPlayer *player)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), SWFDEC_COLOR_COMBINE (0xFF, 0xFF, 0xFF, 0xFF));
+
+ return player->priv->bgcolor;
+}
+
+/**
+ * swfdec_player_set_background_color:
+ * @player: a #SwfdecPlayer
+ * @color: new color to use as background color
+ *
+ * Sets a new background color as an ARGB value. To get transparency, set the
+ * value to 0. To get a black beackground, use 0xFF000000.
+ **/
+void
+swfdec_player_set_background_color (SwfdecPlayer *player, guint color)
+{
+ SwfdecPlayerPrivate *priv;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+ priv = player->priv;
+ priv->bgcolor_set = TRUE;
+ if (priv->bgcolor == color)
+ return;
+ priv->bgcolor = color;
+ g_object_notify (G_OBJECT (player), "background-color");
+ if (swfdec_player_is_initialized (player)) {
+ g_signal_emit (player, signals[INVALIDATE], 0, 0.0, 0.0,
+ (double) priv->width, (double) priv->height);
+ }
+}
+
+/**
+ * swfdec_player_get_scale_mode:
+ * @player: a #SwfdecPlayer
+ *
+ * Gets the currrent mode used for scaling the movie. See #SwfdecScaleMode for
+ * the different modes.
+ *
+ * Returns: the current scale mode
+ **/
+SwfdecScaleMode
+swfdec_player_get_scale_mode (SwfdecPlayer *player)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), SWFDEC_SCALE_SHOW_ALL);
+
+ return player->priv->scale_mode;
+}
+
+/**
+ * swfdec_player_set_scale_mode:
+ * @player: a #SwfdecPlayer
+ * @mode: a #SwfdecScaleMode
+ *
+ * Sets the currrent mode used for scaling the movie. See #SwfdecScaleMode for
+ * the different modes.
+ **/
+void
+swfdec_player_set_scale_mode (SwfdecPlayer *player, SwfdecScaleMode mode)
+{
+ SwfdecPlayerPrivate *priv;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+ priv = player->priv;
+ if (priv->scale_mode != mode) {
+ priv->scale_mode = mode;
+ swfdec_player_update_scale (player);
+ g_object_notify (G_OBJECT (player), "scale-mode");
+ swfdec_player_add_external_action (player, player, swfdec_player_update_size, NULL);
+ }
+}
+
+/**
+ * swfdec_player_get_alignment:
+ * @player: a #SwfdecPlayer
+ *
+ * Gets the alignment of the player. The alignment describes what point is used
+ * as the anchor for drawing the contents. See #SwfdecAlignment for possible
+ * values.
+ *
+ * Returns: the current alignment
+ **/
+SwfdecAlignment
+swfdec_player_get_alignment (SwfdecPlayer *player)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), SWFDEC_ALIGNMENT_CENTER);
+
+ return swfdec_player_alignment_from_flags (player->priv->align_flags);
+}
+
+/**
+ * swfdec_player_set_alignment:
+ * @player: a #SwfdecPlayer
+ * @align: #SwfdecAlignment to set
+ *
+ * Sets the alignment to @align. For details about alignment, see
+ * swfdec_player_get_alignment() and #SwfdecAlignment.
+ **/
+void
+swfdec_player_set_alignment (SwfdecPlayer *player, SwfdecAlignment align)
+{
+ guint flags;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+ flags = swfdec_player_alignment_to_flags (align);
+ swfdec_player_set_align_flags (player, flags);
+}
+
+void
+swfdec_player_set_align_flags (SwfdecPlayer *player, guint flags)
+{
+ SwfdecPlayerPrivate *priv;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+ priv = player->priv;
+ if (flags != priv->align_flags) {
+ priv->align_flags = flags;
+ swfdec_player_update_scale (player);
+ g_object_notify (G_OBJECT (player), "alignment");
+ }
+}
+
+/**
+ * swfdec_player_get_maximum_runtime:
+ * @player: a #SwfdecPlayer
+ *
+ * Queries the given @player for how long scripts may run. see
+ * swfdec_player_set_maximum_runtime() for a longer discussion of this value.
+ *
+ * Returns: the maximum time in milliseconds that scripts are allowed to run or
+ * 0 for infinite.
+ **/
+gulong
+swfdec_player_get_maximum_runtime (SwfdecPlayer *player)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), 0);
+
+ return player->priv->max_runtime;
+}
+
+/**
+ * swfdec_player_set_maximum_runtime:
+ * @player: a #SwfdecPlayer
+ * @msecs: time in milliseconds that scripts are allowed to run or 0 for
+ * infinite
+ *
+ * Sets the time that the player may use to let internal scripts run. If the
+ * Flash file that is currently played back does not manage to complete its
+ * scripts in the given time, it is aborted. You cannot continue the scripts at
+ * a later point in time. However, your application may become unresponsive and
+ * your users annoyed if they cannot interact with it for too long. To give a
+ * reference point, the Adobe Flash player usually sets this value to 10
+ * seconds. Note that this time determines the maximum time calling
+ * swfdec_player_advance() may take, even if it is called with a large value.
+ * Also note that this setting is ignored when running inside a debugger.
+ **/
+void
+swfdec_player_set_maximum_runtime (SwfdecPlayer *player, gulong msecs)
+{
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+ player->priv->max_runtime = msecs;
+ g_object_notify (G_OBJECT (player), "max-runtime");
+}
+
+/**
+ * swfdec_player_get_scripting:
+ * @player: a #SwfdecPlayer
+ *
+ * Gets the current scripting implementation in use. If no implementation is in
+ * use (the default), %NULL is returned.
+ *
+ * Returns: the current scripting implementation used or %NULL if none
+ **/
+SwfdecPlayerScripting *
+swfdec_player_get_scripting (SwfdecPlayer *player)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+
+ return player->priv->scripting;
+}
+
+/**
+ * swfdec_player_set_scripting:
+ * @player: a #SwfdecPlayer
+ * @scripting: the scripting implementation to use or %NULL to disable scripting
+ *
+ * Sets the implementation to use for external scripting in the given @player.
+ * Note that this is different from the internal script engine. See the
+ * #SwfdecPlayerScripting paragraph for details about external scripting.
+ **/
+void
+swfdec_player_set_scripting (SwfdecPlayer *player, SwfdecPlayerScripting *scripting)
+{
+ SwfdecPlayerPrivate *priv;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (scripting == NULL || SWFDEC_IS_PLAYER_SCRIPTING (scripting));
+
+ priv = player->priv;
+ if (priv->scripting == scripting)
+ return;
+
+ if (priv->scripting)
+ g_object_unref (priv->scripting);
+ priv->scripting = g_object_ref (scripting);
+ g_object_notify (G_OBJECT (player), "scripting");
+}
+
+/**
+ * swfdec_player_get_base_url:
+ * @player: a #SwfdecPlayer
+ *
+ * Gets the base URL that this player uses when resolving a relative URL. It is
+ * automatically set to the parent directory of the currently played back
+ * resource, but can be changed using swfdec_player_set_base_url(). When no
+ * resource has been set on the @player yet, %NULL is returned.
+ *
+ * Returns: the base #SwfdecURL for resolving relative links or %NULL
+ **/
+const SwfdecURL *
+swfdec_player_get_base_url (SwfdecPlayer *player)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+
+ return player->priv->base_url;
+}
+
+/**
+ * swfdec_player_set_base_url:
+ * @player: a #SwfdecPlayer
+ * @url: a #SwfdecURL or %NULL to reset to defaults
+ *
+ * Sets the URL that will be used for resolving realtive links inside the
+ * @player.
+ **/
+void
+swfdec_player_set_base_url (SwfdecPlayer *player, const SwfdecURL *url)
+{
+ SwfdecPlayerPrivate *priv;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+ priv = player->priv;
+ if (priv->base_url)
+ swfdec_url_free (priv->base_url);
+ if (url == NULL) {
+ if (priv->url) {
+ priv->base_url = swfdec_url_new_parent (priv->url);
+ } else {
+ priv->base_url = NULL;
+ }
+ } else {
+ priv->base_url = swfdec_url_copy (url);
+ }
+ g_object_notify (G_OBJECT (player), "base-url");
+}
+
+/**
+ * swfdec_player_get_url:
+ * @player: a #SwfdecPlayer
+ *
+ * Gets the URL of the resource that is currently played back. If no URL has
+ * been set on the @player yet, %NULL is returned.
+ *
+ * Returns: the #SwfdecURL currently played back or %NULL
+ **/
+const SwfdecURL *
+swfdec_player_get_url (SwfdecPlayer *player)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+
+ if (player->priv->resource == NULL)
+ return NULL;
+
+ return swfdec_loader_get_url (player->priv->resource->loader);
+}
+
+/**
+ * swfdec_player_set_url:
+ * @player: a #SwfdecPlayer
+ * @url: the url for the initial reference in this player
+ *
+ * Sets the @url for the main data. This function may only be called once.
+ **/
+void
+swfdec_player_set_url (SwfdecPlayer *player, const SwfdecURL *url)
+{
+ SwfdecPlayerPrivate *priv;
+ SwfdecLoader *loader;
+ SwfdecMovie *movie;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (player->priv->url == NULL);
+ g_return_if_fail (url != NULL);
+
+ g_object_freeze_notify (G_OBJECT (player));
+ priv = player->priv;
+ priv->url = swfdec_url_copy (url);
+ loader = swfdec_player_load (player, swfdec_url_get_url (url),
+ SWFDEC_LOADER_REQUEST_DEFAULT, NULL);
+ priv->resource = swfdec_resource_new (player, loader, priv->variables);
+ if (priv->base_url == NULL) {
+ priv->base_url = swfdec_url_new_parent (swfdec_loader_get_url (loader));
+ g_object_notify (G_OBJECT (player), "base-url");
+ }
+ movie = swfdec_movie_new (player, -16384, NULL, priv->resource, NULL, SWFDEC_AS_STR__level0);
+ movie->name = SWFDEC_AS_STR_EMPTY;
+ g_object_unref (loader);
+ g_object_notify (G_OBJECT (player), "url");
+ g_object_thaw_notify (G_OBJECT (player));
+}
+
+/**
+ * swfdec_player_get_variables:
+ * @player: a #SwfdecPlayer
+ *
+ * Gets the initial variables for this player. See swfdec_player_set_variables()
+ * for details about variables.
+ *
+ * Returns: a string represetation of the current variables or %NULL if none are
+ * set on the @player.
+ **/
+const char *
+swfdec_player_get_variables (SwfdecPlayer *player)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+
+ return player->priv->variables;
+}
+
+/**
+ * swfdec_player_set_variables:
+ * @player: a #SwfdecPlayer
+ * @variables: a string that is checked to be in 'application/x-www-form-urlencoded'
+ * syntax describing the arguments to set on the new player or NULL for
+ * none.
+ *
+ * Sets the loader for the main data. This function may only be called if
+ * swfdec_player_set_url() has not been called yet.
+ * If the @variables are set and validate, they will be set as properties on the
+ * root movie.
+ **/
+void
+swfdec_player_set_variables (SwfdecPlayer *player, const char *variables)
+{
+ SwfdecPlayerPrivate *priv;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (player->priv->url == NULL);
+
+ g_free (priv->variables);
+ priv->variables = g_strdup (variables);
+ g_object_notify (G_OBJECT (player), "variables");
+}
+
diff --git a/swfdec/swfdec_player.h b/swfdec/swfdec_player.h
new file mode 100644
index 0000000..b3ec5f5
--- /dev/null
+++ b/swfdec/swfdec_player.h
@@ -0,0 +1,177 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_PLAYER_H_
+#define _SWFDEC_PLAYER_H_
+
+#include <glib-object.h>
+#include <cairo.h>
+#include <libswfdec/swfdec_as_context.h>
+#include <libswfdec/swfdec_as_types.h>
+#include <libswfdec/swfdec_url.h>
+
+G_BEGIN_DECLS
+
+typedef enum {
+ SWFDEC_MOUSE_CURSOR_NORMAL,
+ SWFDEC_MOUSE_CURSOR_NONE,
+ SWFDEC_MOUSE_CURSOR_TEXT,
+ SWFDEC_MOUSE_CURSOR_CLICK
+} SwfdecMouseCursor;
+
+typedef enum {
+ SWFDEC_ALIGNMENT_TOP_LEFT,
+ SWFDEC_ALIGNMENT_TOP,
+ SWFDEC_ALIGNMENT_TOP_RIGHT,
+ SWFDEC_ALIGNMENT_LEFT,
+ SWFDEC_ALIGNMENT_CENTER,
+ SWFDEC_ALIGNMENT_RIGHT,
+ SWFDEC_ALIGNMENT_BOTTOM_LEFT,
+ SWFDEC_ALIGNMENT_BOTTOM,
+ SWFDEC_ALIGNMENT_BOTTOM_RIGHT
+} SwfdecAlignment;
+
+typedef enum {
+ SWFDEC_SCALE_SHOW_ALL,
+ SWFDEC_SCALE_NO_BORDER,
+ SWFDEC_SCALE_EXACT_FIT,
+ SWFDEC_SCALE_NONE
+} SwfdecScaleMode;
+
+/* forward declarations */
+typedef struct _SwfdecPlayerScripting SwfdecPlayerScripting;
+
+typedef struct _SwfdecPlayer SwfdecPlayer;
+typedef struct _SwfdecPlayerPrivate SwfdecPlayerPrivate;
+typedef struct _SwfdecPlayerClass SwfdecPlayerClass;
+
+#define SWFDEC_TYPE_PLAYER (swfdec_player_get_type())
+#define SWFDEC_IS_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_PLAYER))
+#define SWFDEC_IS_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_PLAYER))
+#define SWFDEC_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_PLAYER, SwfdecPlayer))
+#define SWFDEC_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_PLAYER, SwfdecPlayerClass))
+#define SWFDEC_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_PLAYER, SwfdecPlayerClass))
+
+struct _SwfdecPlayer
+{
+ SwfdecAsContext context;
+ SwfdecPlayerPrivate * priv;
+};
+
+struct _SwfdecPlayerClass
+{
+ SwfdecAsContextClass context_class;
+
+ void (* advance) (SwfdecPlayer * player,
+ gulong msecs,
+ guint audio_samples);
+ gboolean (* handle_key) (SwfdecPlayer * player,
+ guint key,
+ guint character,
+ gboolean down);
+ gboolean (* handle_mouse) (SwfdecPlayer * player,
+ double x,
+ double y,
+ int button);
+};
+
+void swfdec_init (void);
+
+GType swfdec_player_get_type (void);
+
+SwfdecPlayer * swfdec_player_new (SwfdecAsDebugger * debugger);
+
+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_default_size (SwfdecPlayer * player,
+ guint * width,
+ guint * height);
+void swfdec_player_get_size (SwfdecPlayer * player,
+ int * width,
+ int * height);
+void swfdec_player_set_size (SwfdecPlayer * player,
+ int width,
+ int height);
+guint swfdec_player_get_background_color
+ (SwfdecPlayer * player);
+void swfdec_player_set_background_color
+ (SwfdecPlayer * player,
+ guint color);
+SwfdecScaleMode swfdec_player_get_scale_mode (SwfdecPlayer * player);
+void swfdec_player_set_scale_mode (SwfdecPlayer * player,
+ SwfdecScaleMode mode);
+SwfdecAlignment swfdec_player_get_alignment (SwfdecPlayer * player);
+void swfdec_player_set_alignment (SwfdecPlayer * player,
+ SwfdecAlignment align);
+gulong swfdec_player_get_maximum_runtime
+ (SwfdecPlayer * player);
+void swfdec_player_set_maximum_runtime
+ (SwfdecPlayer * player,
+ gulong msecs);
+const SwfdecURL *
+ swfdec_player_get_url (SwfdecPlayer * player);
+void swfdec_player_set_url (SwfdecPlayer * player,
+ const SwfdecURL * url);
+const SwfdecURL *
+ swfdec_player_get_base_url (SwfdecPlayer * player);
+void swfdec_player_set_base_url (SwfdecPlayer * player,
+ const SwfdecURL * url);
+const char* swfdec_player_get_variables (SwfdecPlayer * player);
+void swfdec_player_set_variables (SwfdecPlayer * player,
+ const char * variables);
+SwfdecPlayerScripting *
+ swfdec_player_get_scripting (SwfdecPlayer * player);
+void swfdec_player_set_scripting (SwfdecPlayer * player,
+ SwfdecPlayerScripting *scripting);
+
+void swfdec_player_render (SwfdecPlayer * player,
+ cairo_t * cr,
+ double x,
+ double y,
+ double width,
+ double height);
+void swfdec_player_advance (SwfdecPlayer * player,
+ gulong msecs);
+gboolean swfdec_player_mouse_move (SwfdecPlayer * player,
+ double x,
+ double y);
+gboolean swfdec_player_mouse_press (SwfdecPlayer * player,
+ double x,
+ double y,
+ guint button);
+gboolean swfdec_player_mouse_release (SwfdecPlayer * player,
+ double x,
+ double y,
+ guint button);
+gboolean swfdec_player_key_press (SwfdecPlayer * player,
+ guint keycode,
+ guint character);
+gboolean swfdec_player_key_release (SwfdecPlayer * player,
+ guint keycode,
+ guint character);
+/* audio - see swfdec_audio.c */
+void swfdec_player_render_audio (SwfdecPlayer * player,
+ gint16 * dest,
+ guint start_offset,
+ guint n_samples);
+const GList * swfdec_player_get_audio (SwfdecPlayer * player);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_player_as.c b/swfdec/swfdec_player_as.c
new file mode 100644
index 0000000..d4d8dd5
--- /dev/null
+++ b/swfdec/swfdec_player_as.c
@@ -0,0 +1,367 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+/* NB: include this first, it redefines SWFDEC_AS_NATIVE */
+#include "swfdec_asnative.h"
+
+#include "swfdec_player_internal.h"
+#include "swfdec_as_function.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_as_object.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_internal.h"
+#include "swfdec_interval.h"
+#include "swfdec_as_frame_internal.h"
+
+/* FIXME: to avoid duplicate definitions */
+#undef SWFDEC_AS_NATIVE
+#define SWFDEC_AS_NATIVE(x, y, func)
+
+/*** INTERVALS ***/
+
+static void
+swfdec_player_do_set_interval (gboolean repeat, SwfdecAsContext *cx, guint argc,
+ SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+ SwfdecAsObject *object;
+ guint id, msecs;
+#define MIN_INTERVAL_TIME 10
+
+ if (argc < 2) {
+ SWFDEC_WARNING ("setInterval needs at least 2 arguments");
+ return;
+ }
+
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0])) {
+ SWFDEC_WARNING ("first argument to setInterval is not an object");
+ return;
+ }
+ object = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
+ if (SWFDEC_IS_AS_FUNCTION (object)) {
+ msecs = swfdec_as_value_to_integer (cx, &argv[1]);
+ if (msecs < MIN_INTERVAL_TIME) {
+ SWFDEC_INFO ("interval duration is %u, making it %u msecs", msecs, MIN_INTERVAL_TIME);
+ msecs = MIN_INTERVAL_TIME;
+ }
+ id = swfdec_interval_new_function (player, msecs, repeat,
+ SWFDEC_AS_FUNCTION (object), argc - 2, &argv[2]);
+ } else {
+ const char *name;
+ if (argc < 3) {
+ SWFDEC_WARNING ("setInterval needs 3 arguments when not called with function");
+ return;
+ }
+ name = swfdec_as_value_to_string (cx, &argv[1]);
+ msecs = swfdec_as_value_to_integer (cx, &argv[2]);
+ if (msecs < MIN_INTERVAL_TIME) {
+ SWFDEC_INFO ("interval duration is %u, making it %u msecs", msecs, MIN_INTERVAL_TIME);
+ msecs = MIN_INTERVAL_TIME;
+ }
+ id = swfdec_interval_new_object (player, msecs, repeat, object, name, argc - 3, &argv[3]);
+ }
+ SWFDEC_AS_VALUE_SET_INT (rval, id);
+}
+
+SWFDEC_AS_NATIVE (2, 0, swfdec_player_ASnew)
+void
+swfdec_player_ASnew (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ g_return_if_fail (cx->frame->next != NULL);
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (rval, cx->frame->next->construct);
+}
+
+SWFDEC_AS_NATIVE (250, 0, swfdec_player_setInterval)
+void
+swfdec_player_setInterval (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ swfdec_player_do_set_interval (TRUE, cx, argc, argv, rval);
+}
+
+SWFDEC_AS_NATIVE (250, 2, swfdec_player_setTimeout)
+void
+swfdec_player_setTimeout (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ swfdec_player_do_set_interval (FALSE, cx, argc, argv, rval);
+}
+
+SWFDEC_AS_NATIVE (250, 1, swfdec_player_clearInterval)
+void
+swfdec_player_clearInterval (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+ guint id;
+
+ SWFDEC_AS_CHECK (0, NULL, "i", &id);
+
+ swfdec_interval_remove (player, id);
+}
+
+/*** VARIOUS ***/
+
+SWFDEC_AS_NATIVE (100, 4, swfdec_player_trace)
+void
+swfdec_player_trace (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_FIXME ("Is _global.trace supposed to do something?");
+}
+
+SWFDEC_AS_NATIVE (9, 0, swfdec_player_updateAfterEvent)
+void
+swfdec_player_updateAfterEvent (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("updateAfterEvent");
+}
+
+SWFDEC_AS_NATIVE (1021, 1, swfdec_player_showRedrawRegions)
+void
+swfdec_player_showRedrawRegions (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("showRedrawRegions");
+}
+
+static void
+swfdec_player_enableDebugConsole (SwfdecAsContext *cx, SwfdecAsObject *obj,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("enableDebugConsole");
+}
+
+static void
+swfdec_player_do_nothing (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+}
+
+static SwfdecAsFunction *
+swfdec_get_asnative (SwfdecAsContext *cx, guint x, guint y)
+{
+ gboolean x_exists;
+ guint i;
+
+ x_exists = FALSE;
+ for (i = 0; native_funcs[i].func != NULL; i++) {
+ if (native_funcs[i].x == x)
+ x_exists = TRUE;
+ if (native_funcs[i].x == x && native_funcs[i].y == y) {
+ SwfdecAsFunction *fun = swfdec_as_native_function_new (cx, native_funcs[i].name,
+ native_funcs[i].func, 0, NULL);
+ if (native_funcs[i].get_type) {
+ swfdec_as_native_function_set_construct_type (SWFDEC_AS_NATIVE_FUNCTION (fun),
+ native_funcs[i].get_type ());
+ }
+ return fun;
+ }
+ }
+ SWFDEC_WARNING ("no ASnative (%u, %u)", x, y);
+ if (x_exists) {
+ SwfdecAsFunction *func;
+ char *name = g_strdup_printf ("ASnative (%u, %u)", x, y);
+ func = swfdec_as_native_function_new (cx, name, swfdec_player_do_nothing,
+ 0, NULL);
+ g_free (name);
+ return func;
+ } else {
+ return NULL;
+ }
+}
+
+// same as ASnative, but also sets prototype
+static void
+swfdec_player_ASconstructor (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecAsValue val;
+ SwfdecAsObject *proto;
+ SwfdecAsFunction *func;
+ guint x, y;
+
+ SWFDEC_AS_CHECK (0, NULL, "ii", &x, &y);
+
+ func = swfdec_get_asnative (cx, x, y);
+ if (func) {
+ proto = swfdec_as_object_new (cx);
+
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
+ swfdec_as_object_set_variable_and_flags (SWFDEC_AS_OBJECT (func),
+ SWFDEC_AS_STR_prototype, &val,
+ SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (func));
+ swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+
+ SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (func));
+ }
+}
+
+static void
+swfdec_player_ASnative (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecAsFunction *func;
+ guint x, y;
+
+ SWFDEC_AS_CHECK (0, NULL, "ii", &x, &y);
+
+ func = swfdec_get_asnative (cx, x, y);
+ if (func) {
+ SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (func));
+ }
+}
+
+SWFDEC_AS_NATIVE (4, 0, ASSetNative)
+void
+ASSetNative (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecAsFunction *function;
+ SwfdecAsObject *target;
+ SwfdecAsValue val;
+ SwfdecAsVariableFlag flags;
+ const char *s;
+ char **names;
+ guint i, x, y;
+
+ SWFDEC_AS_CHECK (0, NULL, "ois", &target, &x, &s);
+
+ if (argc > 3)
+ y = swfdec_as_value_to_integer (cx, &argv[3]);
+ else
+ y = 0;
+ names = g_strsplit (s, ",", -1);
+ for (i = 0; names[i]; i++) {
+ s = names[i];
+ flags = 0;
+ if (s[0] == '6') {
+ flags |= SWFDEC_AS_VARIABLE_VERSION_6_UP;
+ s++;
+ } else if (s[0] == '7') {
+ flags |= SWFDEC_AS_VARIABLE_VERSION_7_UP;
+ s++;
+ } else if (s[0] == '8') {
+ flags |= SWFDEC_AS_VARIABLE_VERSION_8_UP;
+ s++;
+ } else if (s[0] == '9') {
+ flags |= SWFDEC_AS_VARIABLE_VERSION_9_UP;
+ s++;
+ }
+ function = swfdec_get_asnative (cx, x, y);
+ if (function == NULL)
+ break;
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (function));
+ swfdec_as_object_set_variable_and_flags (target,
+ swfdec_as_context_get_string (cx, s), &val, flags);
+ y++;
+ }
+ g_strfreev (names);
+}
+
+SWFDEC_AS_NATIVE (4, 1, ASSetNativeAccessor)
+void
+ASSetNativeAccessor (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecAsFunction *get, *set;
+ SwfdecAsObject *target;
+ SwfdecAsVariableFlag flags;
+ const char *s;
+ char **names;
+ guint i, x, y;
+
+ SWFDEC_AS_CHECK (0, NULL, "ois|i", &target, &x, &s, &y);
+
+ names = g_strsplit (s, ",", -1);
+ for (i = 0; names[i]; i++) {
+ s = names[i];
+ flags = 0;
+ if (s[0] == '6') {
+ flags |= SWFDEC_AS_VARIABLE_VERSION_6_UP;
+ s++;
+ } else if (s[0] == '7') {
+ flags |= SWFDEC_AS_VARIABLE_VERSION_7_UP;
+ s++;
+ } else if (s[0] == '8') {
+ flags |= SWFDEC_AS_VARIABLE_VERSION_8_UP;
+ s++;
+ } else if (s[0] == '9') {
+ flags |= SWFDEC_AS_VARIABLE_VERSION_9_UP;
+ s++;
+ }
+ get = swfdec_get_asnative (cx, x, y++);
+ set = swfdec_get_asnative (cx, x, y++);
+ if (get == NULL) {
+ SWFDEC_ERROR ("no getter for %s", s);
+ break;
+ }
+ swfdec_as_object_add_variable (target, swfdec_as_context_get_string (cx, s),
+ get, set, flags);
+ }
+ g_strfreev (names);
+}
+
+SWFDEC_AS_NATIVE (101, 8, swfdec_player_object_registerClass)
+void
+swfdec_player_object_registerClass (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ const char *name;
+
+ SWFDEC_AS_CHECK (0, NULL, "s", &name);
+
+ if (argc < 2 || !SWFDEC_AS_VALUE_IS_OBJECT (&argv[1])) {
+ SWFDEC_AS_VALUE_SET_BOOLEAN (rval, FALSE);
+ return;
+ }
+
+ swfdec_player_set_export_class (SWFDEC_PLAYER (cx), name,
+ SWFDEC_AS_VALUE_GET_OBJECT (&argv[1]));
+ SWFDEC_AS_VALUE_SET_BOOLEAN (rval, TRUE);
+}
+
+/* This is ran at the beginning of swfdec_as_context_startup.
+ * Yes, this is a hack */
+void
+swfdec_player_preinit_global (SwfdecAsContext *context)
+{
+ /* init these two before swfdec_as_context_startup, so they won't get
+ * __proto__ and constructor properties */
+ swfdec_as_object_add_function (context->global, SWFDEC_AS_STR_ASnative,
+ 0, swfdec_player_ASnative, 2);
+ swfdec_as_object_add_function (context->global, SWFDEC_AS_STR_ASconstructor,
+ 0, swfdec_player_ASconstructor, 2);
+ // FIXME: is this only the debug player?
+ swfdec_as_object_add_function (context->global,
+ SWFDEC_AS_STR_enableDebugConsole, 0, swfdec_player_enableDebugConsole,
+ 2);
+}
diff --git a/swfdec/swfdec_player_internal.h b/swfdec/swfdec_player_internal.h
new file mode 100644
index 0000000..a38b957
--- /dev/null
+++ b/swfdec/swfdec_player_internal.h
@@ -0,0 +1,263 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_PLAYER_INTERNAL_H_
+#define _SWFDEC_PLAYER_INTERNAL_H_
+
+#include <libswfdec/swfdec_player.h>
+#include <libswfdec/swfdec_audio.h>
+#include <libswfdec/swfdec_event.h>
+#include <libswfdec/swfdec_function_list.h>
+#include <libswfdec/swfdec_loader.h>
+#include <libswfdec/swfdec_player_scripting.h>
+#include <libswfdec/swfdec_rect.h>
+#include <libswfdec/swfdec_ringbuffer.h>
+#include <libswfdec/swfdec_socket.h>
+#include <libswfdec/swfdec_system.h>
+
+G_BEGIN_DECLS
+
+typedef enum {
+ SWFDEC_ALIGN_FLAG_TOP = (1 << 0),
+ SWFDEC_ALIGN_FLAG_BOTTOM = (1 << 1),
+ SWFDEC_ALIGN_FLAG_LEFT = (1 << 2),
+ SWFDEC_ALIGN_FLAG_RIGHT = (1 << 3)
+} SwfdecAlignFlag;
+
+typedef void (* SwfdecActionFunc) (gpointer object, gpointer data);
+typedef gboolean (* SwfdecAudioRemoveFunc) (SwfdecAudio *audio, gpointer data);
+typedef void (* SwfdecPolicyFunc) (SwfdecPlayer *player, gboolean allow, gpointer data);
+
+typedef struct _SwfdecTimeout SwfdecTimeout;
+struct _SwfdecTimeout {
+ SwfdecTick timestamp; /* timestamp at which this thing is supposed to trigger */
+ void (* callback) (SwfdecTimeout *advance);
+ void (* free) (SwfdecTimeout *advance);
+};
+
+#define SWFDEC_PLAYER_N_ACTION_QUEUES 4
+
+struct _SwfdecPlayerPrivate
+{
+ SwfdecPlayer * player; /* backlink */
+
+ /* global properties */
+ SwfdecSystem * system; /* our system properties */
+ gboolean initialized; /* if width and height are set already */
+ guint rate; /* divide by 256 to get iterations per second */
+ guint width; /* width of movie */
+ guint height; /* height of movie */
+ GList * roots; /* all the root movies */
+ SwfdecCache * cache; /* player cache */
+ gboolean bgcolor_set; /* TRUE if the background color has been set */
+ SwfdecColor bgcolor; /* background color */
+ SwfdecResource * resource; /* initial resource loaded */
+ char * variables; /* variables to set on the player */
+ SwfdecURL * url; /* url or NULL if not set yet */
+ SwfdecURL * base_url; /* base url or NULL if not set yet */
+ SwfdecPlayerScripting *scripting; /* scripting object */
+ GHashTable * scripting_callbacks; /* GC string => SwfdecAsFunction mapping of script callbacks */
+ GType loader_type; /* type to use for creating sockets */
+ GType socket_type; /* type to use for creating sockets */
+ /* stage properties */
+ guint internal_width; /* width used by the scripting engine */
+ guint internal_height; /* height used by the scripting engine */
+ guint broadcasted_width; /* width given in the last onResize event */
+ guint broadcasted_height; /* height given in the last onResize event */
+ gint stage_width; /* width set by the user */
+ gint stage_height; /* height set by the user */
+ SwfdecRectangle stage; /* size of the stage set by user */
+ guint align_flags; /* SwfdecAlignFlag */
+ SwfdecScaleMode scale_mode; /* scale mode */
+ double scale_x; /* cached x scale value */
+ double scale_y; /* cached y scale value */
+ int offset_x; /* x offset from top left edge after scaling */
+ int offset_y; /* y offset from top left edge after scaling */
+
+ SwfdecFunctionList resource_requests; /* all external requested URIs - see swfdec_resource_request.[ch] */
+ guint unnamed_count; /* variable used for naming unnamed movies */
+ /* ActionScript */
+ SwfdecFunctionList rooted; /* all the objects we keep track of */
+ guint interval_id; /* id returned from setInterval call */
+ GList * intervals; /* all currently running intervals */
+ GHashTable * registered_classes; /* name => SwfdecAsObject constructor */
+
+ /* rendering */
+ SwfdecRectangle invalid_extents; /* extents of area that needs a redraw in global coordinates */
+ GArray * invalidations; /* fine-grained areas in need of redraw */
+
+ /* mouse */
+ gboolean mouse_visible; /* show the mouse (actionscriptable) */
+ SwfdecMouseCursor mouse_cursor; /* cursor that should be shown */
+ double mouse_x; /* in stage coordinates */
+ double mouse_y; /* in stage coordinates */
+ guint mouse_button; /* 0 for not pressed, 1 for pressed */
+ SwfdecMovie * mouse_below; /* movie that currently is below the mouse */
+ SwfdecMovie * mouse_grab; /* movie that currently has the mouse */
+ SwfdecMovie * mouse_drag; /* current movie activated by startDrag */
+ gboolean mouse_drag_center; /* TRUE to use center of movie at mouse, FALSE for movie's (0,0) */
+ SwfdecRect mouse_drag_rect; /* clipping rectangle for movements */
+ double mouse_drag_x; /* offset of mouse in x direction */
+ double mouse_drag_y; /* offset of mouse in y direction */
+
+ /* key */
+ guint last_keycode; /* last keycode that was pressed/released */
+ guint last_character; /* UCS4 of last character pressed/released */
+ guint8 key_pressed[256/8]; /* boolean array for isDown */
+
+ /* audio */
+ GList * audio; /* list of playing SwfdecAudio */
+
+ /* events and advancing */
+ SwfdecTick time; /* current time */
+ GList * timeouts; /* list of events, sorted by timestamp */
+ guint tick; /* next tick */
+ SwfdecTimeout iterate_timeout; /* callback for iterating */
+ GTimer * runtime; /* for checking how long we've been running */
+ gulong max_runtime; /* maximum number of seconds the player may run */
+ SwfdecRingBuffer * external_actions; /* external actions we've queued up, like resize or loader stuff */
+ SwfdecTimeout external_timeout; /* callback for iterating */
+ /* iterating */
+ GList * movies; /* list of all movies that want to be iterated */
+ SwfdecRingBuffer * actions[SWFDEC_PLAYER_N_ACTION_QUEUES]; /* all actions we've queued up so far */
+
+ /* security */
+ GSList * sandboxes; /* all existing sandboxes */
+ GList * loading_policy_files; /* list of loading SwfdecPlayerLoader - newest first */
+ GSList * policy_files; /* list of SwfdecPolicyLoader that finished loading */
+};
+
+void swfdec_player_initialize (SwfdecPlayer * player,
+ guint rate,
+ guint width,
+ guint height);
+void swfdec_player_add_movie (SwfdecPlayer * player,
+ guint depth,
+ const char * url);
+void swfdec_player_remove_movie (SwfdecPlayer * player,
+ SwfdecMovie * movie);
+
+gboolean swfdec_player_lock (SwfdecPlayer * player);
+void swfdec_player_lock_soft (SwfdecPlayer * player);
+void swfdec_player_unlock (SwfdecPlayer * player);
+void swfdec_player_unlock_soft (SwfdecPlayer * player);
+void swfdec_player_perform_actions (SwfdecPlayer * player);
+
+#define swfdec_player_root(player, data, mark_func) \
+ swfdec_function_list_add (&(player)->priv->rooted, (mark_func), (data), NULL)
+#define swfdec_player_root_full(player, data, mark_func, destroy_notify) \
+ swfdec_function_list_add (&(player)->priv->rooted, (mark_func), (data), (destroy_notify))
+#define swfdec_player_unroot(player, data) \
+ swfdec_function_list_remove (&(player)->priv->rooted, (data))
+#define swfdec_player_request_resource(player, request_func, data, destroy_notify) \
+ swfdec_function_list_add (&(player)->priv->resource_requests, (request_func), (data), (destroy_notify))
+SwfdecURL * swfdec_player_create_url (SwfdecPlayer * player,
+ const char * string);
+SwfdecLoader * swfdec_player_load (SwfdecPlayer * player,
+ const char * url,
+ SwfdecLoaderRequest request,
+ SwfdecBuffer * buffer);
+SwfdecAsObject *swfdec_player_get_export_class (SwfdecPlayer * player,
+ const char * name);
+void swfdec_player_set_export_class (SwfdecPlayer * player,
+ const char * name,
+ SwfdecAsObject * object);
+
+SwfdecSocket * swfdec_player_create_socket (SwfdecPlayer * player,
+ const char * hostname,
+ guint port);
+
+#define swfdec_player_is_mouse_pressed(player) ((player)->priv->mouse_button & 1)
+void swfdec_player_invalidate (SwfdecPlayer * player,
+ const SwfdecRect * rect);
+void swfdec_player_add_timeout (SwfdecPlayer * player,
+ SwfdecTimeout * timeout);
+void swfdec_player_remove_timeout (SwfdecPlayer * player,
+ SwfdecTimeout * timeout);
+void swfdec_player_add_external_action
+ (SwfdecPlayer * player,
+ gpointer object,
+ SwfdecActionFunc action_func,
+ gpointer action_data);
+void swfdec_player_remove_all_external_actions
+ (SwfdecPlayer * player,
+ gpointer object);
+void swfdec_player_add_action (SwfdecPlayer * player,
+ SwfdecMovie * movie,
+ SwfdecEventType type,
+ guint importance);
+void swfdec_player_add_action_script (SwfdecPlayer * player,
+ SwfdecMovie * movie,
+ SwfdecScript * script,
+ guint importance);
+void swfdec_player_remove_all_actions (SwfdecPlayer * player,
+ SwfdecMovie * movie);
+
+void swfdec_player_set_drag_movie (SwfdecPlayer * player,
+ SwfdecMovie * drag,
+ gboolean center,
+ SwfdecRect * rect);
+void swfdec_player_set_align_flags (SwfdecPlayer * player,
+ guint flags);
+void swfdec_player_stop_sounds (SwfdecPlayer * player,
+ SwfdecAudioRemoveFunc func,
+ gpointer data);
+void swfdec_player_stop_all_sounds (SwfdecPlayer * player);
+gboolean swfdec_player_get_level (SwfdecPlayer * player,
+ const char * name);
+SwfdecSpriteMovie *
+ swfdec_player_get_movie_at_level(SwfdecPlayer * player,
+ int level);
+SwfdecSpriteMovie *
+ swfdec_player_create_movie_at_level
+ (SwfdecPlayer * player,
+ SwfdecResource * resource,
+ int level);
+void swfdec_player_launch (SwfdecPlayer * player,
+ SwfdecLoaderRequest request,
+ const char * url,
+ const char * target,
+ SwfdecBuffer * data);
+void swfdec_player_stage_to_global (SwfdecPlayer * player,
+ double * x,
+ double * y);
+void swfdec_player_global_to_stage (SwfdecPlayer * player,
+ double * x,
+ double * y);
+void swfdec_player_update_scale (SwfdecPlayer * player);
+
+/* in swfdec_policy_file.c */
+gboolean swfdec_player_allow_now (SwfdecPlayer * player,
+ const SwfdecURL * url);
+void swfdec_player_allow_or_load (SwfdecPlayer * player,
+ const SwfdecURL * url,
+ const SwfdecURL * load_url,
+ SwfdecPolicyFunc func,
+ gpointer data);
+/* in swfdec_as_interpret.c */
+SwfdecMovie * swfdec_player_get_movie_from_value
+ (SwfdecPlayer * player,
+ SwfdecAsValue * val);
+SwfdecMovie * swfdec_player_get_movie_from_string
+ (SwfdecPlayer * player,
+ const char * s);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_player_scripting.c b/swfdec/swfdec_player_scripting.c
new file mode 100644
index 0000000..0063a62
--- /dev/null
+++ b/swfdec/swfdec_player_scripting.c
@@ -0,0 +1,39 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_player_scripting.h"
+#include "swfdec_debug.h"
+
+
+G_DEFINE_ABSTRACT_TYPE (SwfdecPlayerScripting, swfdec_player_scripting, G_TYPE_OBJECT)
+
+static void
+swfdec_player_scripting_class_init (SwfdecPlayerScriptingClass *klass)
+{
+}
+
+static void
+swfdec_player_scripting_init (SwfdecPlayerScripting *player_scripting)
+{
+}
+
diff --git a/swfdec/swfdec_player_scripting.h b/swfdec/swfdec_player_scripting.h
new file mode 100644
index 0000000..8ad3c8f
--- /dev/null
+++ b/swfdec/swfdec_player_scripting.h
@@ -0,0 +1,62 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_PLAYER_SCRIPTING_H_
+#define _SWFDEC_PLAYER_SCRIPTING_H_
+
+#include <glib-object.h>
+#include <libswfdec/swfdec_player.h>
+
+G_BEGIN_DECLS
+
+/* forward-declared in swfdec-player.h */
+/* typedef struct _SwfdecPlayerScripting SwfdecPlayerScripting; */
+typedef struct _SwfdecPlayerScriptingClass SwfdecPlayerScriptingClass;
+
+#define SWFDEC_TYPE_PLAYER_SCRIPTING (swfdec_player_scripting_get_type())
+#define SWFDEC_IS_PLAYER_SCRIPTING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_PLAYER_SCRIPTING))
+#define SWFDEC_IS_PLAYER_SCRIPTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_PLAYER_SCRIPTING))
+#define SWFDEC_PLAYER_SCRIPTING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_PLAYER_SCRIPTING, SwfdecPlayerScripting))
+#define SWFDEC_PLAYER_SCRIPTING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_PLAYER_SCRIPTING, SwfdecPlayerScriptingClass))
+#define SWFDEC_PLAYER_SCRIPTING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_PLAYER_SCRIPTING, SwfdecPlayerScriptingClass))
+
+struct _SwfdecPlayerScripting
+{
+ GObject object;
+};
+
+struct _SwfdecPlayerScriptingClass
+{
+ GObjectClass object_class;
+
+ char * (* js_get_id) (SwfdecPlayerScripting *scripting,
+ SwfdecPlayer * player);
+ char * (* js_call) (SwfdecPlayerScripting *scripting,
+ SwfdecPlayer * player,
+ const char * code);
+ char * (* xml_call) (SwfdecPlayerScripting *scripting,
+ SwfdecPlayer * player,
+ const char * xml);
+};
+
+GType swfdec_player_scripting_get_type (void);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_policy_file.c b/swfdec/swfdec_policy_file.c
new file mode 100644
index 0000000..80fd599
--- /dev/null
+++ b/swfdec/swfdec_policy_file.c
@@ -0,0 +1,350 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+
+#include "swfdec_policy_file.h"
+#include "swfdec_resource.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_loader_internal.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_xml.h"
+#include "swfdec_xml_node.h"
+
+typedef struct _SwfdecPolicyFileRequest SwfdecPolicyFileRequest;
+struct _SwfdecPolicyFileRequest {
+ SwfdecURL * url; /* URL we are supposed to check */
+ SwfdecPolicyFunc func; /* function to call when we know if access is (not) allowed */
+ gpointer data; /* data to pass to func */
+};
+
+static void
+swfdec_policy_file_request_free (SwfdecPolicyFileRequest *request)
+{
+ swfdec_url_free (request->url);
+ g_slice_free (SwfdecPolicyFileRequest, request);
+}
+
+/*** PARSING THE FILE ***/
+
+static void
+swfdec_policy_file_parse (SwfdecPolicyFile *file, const char *text)
+{
+ SwfdecXml *xml;
+ gint32 i, j;
+
+ g_return_if_fail (SWFDEC_IS_POLICY_FILE (file));
+ g_return_if_fail (text != NULL);
+
+ xml = swfdec_xml_new_no_properties (SWFDEC_AS_CONTEXT (file->player), text, TRUE);
+
+ if (xml == NULL) {
+ SWFDEC_ERROR ("failed to create an XML object for crossdomain policy");
+ return;
+ }
+
+ if (SWFDEC_XML_NODE (xml)->type != SWFDEC_XML_NODE_ELEMENT) {
+ SWFDEC_LOG ("empty crossdomain policy file");
+ return;
+ }
+
+ for (i = 0; i < swfdec_xml_node_num_children (SWFDEC_XML_NODE (xml)); i++) {
+ SwfdecXmlNode *node_cdp =
+ swfdec_xml_node_get_child (SWFDEC_XML_NODE (xml), i);
+
+ if (node_cdp->type != SWFDEC_XML_NODE_ELEMENT)
+ continue;
+
+ if (g_ascii_strcasecmp (node_cdp->name, "cross-domain-policy") != 0)
+ continue;
+
+ for (j = 0; j < swfdec_xml_node_num_children (node_cdp); j++) {
+ SwfdecXmlNode *node_aaf = swfdec_xml_node_get_child (node_cdp, j);
+ const char *value;
+ GPatternSpec *pattern;
+ char *value_lower;
+
+ if (node_aaf->type != SWFDEC_XML_NODE_ELEMENT)
+ continue;
+
+ if (g_ascii_strcasecmp (node_aaf->name, "allow-access-from") != 0)
+ continue;
+
+ // FIXME: secure attribute?
+
+ value = swfdec_xml_node_get_attribute (node_aaf, SWFDEC_AS_STR_domain);
+ if (value == NULL)
+ continue;
+
+ if (strchr (value, '?') != NULL) {
+ SWFDEC_WARNING ("'?' in allowed domain attribute for %s", value);
+ continue;
+ }
+
+ value_lower = g_ascii_strdown (value, -1);
+ pattern = g_pattern_spec_new (value_lower);
+ g_free (value_lower);
+
+ file->allowed_hosts = g_slist_prepend (file->allowed_hosts, pattern);
+ }
+ }
+}
+
+/*** SWFDEC_STREAM_TARGET ***/
+
+static SwfdecPlayer *
+swfdec_policy_file_target_get_player (SwfdecStreamTarget *target)
+{
+ return SWFDEC_POLICY_FILE (target)->player;
+}
+
+static void
+swfdec_policy_file_finished_loading (SwfdecPolicyFile *file, const char *text)
+{
+ SwfdecPlayerPrivate *priv;
+ SwfdecPolicyFile *next;
+ GList *link;
+
+ swfdec_stream_set_target (file->stream, NULL);
+ file->stream = NULL;
+
+ if (text)
+ swfdec_policy_file_parse (file, text);
+
+ priv = file->player->priv;
+ link = g_list_find (priv->loading_policy_files, file);
+ next = link->next ? link->next->data : NULL;
+ priv->loading_policy_files = g_list_delete_link (priv->loading_policy_files, link);
+ priv->policy_files = g_slist_prepend (priv->policy_files, file);
+ if (next) {
+ next->requests = g_slist_concat (next->requests, file->requests);
+ } else {
+ GSList *walk;
+
+ for (walk = file->requests; walk; walk = walk->next) {
+ SwfdecPolicyFileRequest *request = walk->data;
+ gboolean allow = swfdec_player_allow_now (file->player, request->url);
+ request->func (file->player, allow, request->data);
+ swfdec_policy_file_request_free (request);
+ }
+ g_slist_free (file->requests);
+ }
+ file->requests = NULL;
+}
+
+static void
+swfdec_policy_file_target_error (SwfdecStreamTarget *target,
+ SwfdecStream *stream)
+{
+ SwfdecPolicyFile *file = SWFDEC_POLICY_FILE (target);
+
+ swfdec_policy_file_finished_loading (file, NULL);
+}
+
+static void
+swfdec_policy_file_target_close (SwfdecStreamTarget *target,
+ SwfdecStream *stream)
+{
+ SwfdecPolicyFile *file = SWFDEC_POLICY_FILE (target);
+ char *text;
+
+ swfdec_stream_set_target (stream, NULL);
+ file->stream = NULL;
+ if (SWFDEC_IS_LOADER (stream)) {
+ text = swfdec_loader_get_text (SWFDEC_LOADER (stream), 8);
+ } else {
+ SWFDEC_FIXME ("rewrite swfdec_loader_get_text() to swfdec_buffer_queue_get_text()");
+ text = NULL;
+ }
+
+ if (text == NULL) {
+ SWFDEC_ERROR ("couldn't get text from crossdomain policy file %s",
+ swfdec_url_get_url (file->load_url));
+ }
+ swfdec_policy_file_finished_loading (file, text);
+ g_free (text);
+}
+
+static void
+swfdec_policy_file_stream_target_init (SwfdecStreamTargetInterface *iface)
+{
+ iface->get_player = swfdec_policy_file_target_get_player;
+ iface->close = swfdec_policy_file_target_close;
+ iface->error = swfdec_policy_file_target_error;
+}
+
+/*** SWFDEC_POLICY_FILE ***/
+
+G_DEFINE_TYPE_WITH_CODE (SwfdecPolicyFile, swfdec_policy_file, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (SWFDEC_TYPE_STREAM_TARGET, swfdec_policy_file_stream_target_init))
+
+static void
+swfdec_policy_file_dispose (GObject *object)
+{
+ SwfdecPolicyFile *file = SWFDEC_POLICY_FILE (object);
+
+ if (file->stream) {
+ swfdec_stream_set_target (file->stream, NULL);
+ g_object_unref (file->stream);
+ file->stream = NULL;
+ g_slist_foreach (file->requests, (GFunc) swfdec_policy_file_request_free, NULL);
+ g_slist_free (file->requests);
+ file->requests = NULL;
+ } else {
+ g_assert (file->requests == NULL);
+ }
+ swfdec_url_free (file->load_url);
+ swfdec_url_free (file->url);
+
+ G_OBJECT_CLASS (swfdec_policy_file_parent_class)->dispose (object);
+}
+
+static void
+swfdec_policy_file_class_init (SwfdecPolicyFileClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = swfdec_policy_file_dispose;
+}
+
+static void
+swfdec_policy_file_init (SwfdecPolicyFile *policy_file)
+{
+}
+
+SwfdecPolicyFile *
+swfdec_policy_file_new (SwfdecPlayer *player, const SwfdecURL *url)
+{
+ SwfdecPolicyFile *file;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (url != NULL, NULL);
+
+ file = g_object_new (SWFDEC_TYPE_POLICY_FILE, NULL);
+ file->player = player;
+ file->load_url = swfdec_url_copy (url);
+ file->url = swfdec_url_new_parent (url);
+ if (swfdec_url_has_protocol (url, "xmlsocket")) {
+ SWFDEC_FIXME ("implement xmlsocket: protocol");
+ } else {
+ file->stream = SWFDEC_STREAM (swfdec_player_load (player,
+ swfdec_url_get_url (url), SWFDEC_LOADER_REQUEST_DEFAULT, NULL));
+ swfdec_stream_set_target (file->stream, SWFDEC_STREAM_TARGET (file));
+ }
+ player->priv->loading_policy_files =
+ g_list_prepend (player->priv->loading_policy_files, file);
+
+ return file;
+}
+
+gboolean
+swfdec_policy_file_is_loading (SwfdecPolicyFile *file)
+{
+ g_return_val_if_fail (SWFDEC_IS_POLICY_FILE (file), FALSE);
+
+ return file->stream != NULL;
+}
+
+gboolean
+swfdec_policy_file_allow (SwfdecPolicyFile *file, const SwfdecURL *url)
+{
+ GSList *walk;
+ gsize len;
+ char *emantsoh;
+ const char *hostname;
+
+ g_return_val_if_fail (SWFDEC_IS_POLICY_FILE (file), FALSE);
+ g_return_val_if_fail (url != NULL, FALSE);
+
+ hostname = swfdec_url_get_host (url);
+ /* This is a hack that simplifies the following code. As the pattern can not
+ * contain any ?, the only pattern that matches the string "?" is the pattern
+ * "*"
+ */
+ if (hostname == NULL)
+ hostname = "?";
+ len = strlen (hostname);
+ emantsoh = g_utf8_strreverse (hostname, len);
+ for (walk = file->allowed_hosts; walk; walk = walk->next) {
+ GPatternSpec *pattern = walk->data;
+ if (g_pattern_match (pattern, len, hostname, emantsoh)) {
+ g_free (emantsoh);
+ return TRUE;
+ }
+ }
+ g_free (emantsoh);
+ return FALSE;
+}
+
+/*** PLAYER API ***/
+
+gboolean
+swfdec_player_allow_now (SwfdecPlayer *player, const SwfdecURL *url)
+{
+ GSList *walk;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE);
+ g_return_val_if_fail (url != NULL, FALSE);
+
+ for (walk = player->priv->policy_files; walk; walk = walk->next) {
+ if (swfdec_policy_file_allow (walk->data, url))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void
+swfdec_player_allow_or_load (SwfdecPlayer *player, const SwfdecURL *url,
+ const SwfdecURL *load_url, SwfdecPolicyFunc func, gpointer data)
+{
+ SwfdecPlayerPrivate *priv;
+ SwfdecPolicyFileRequest *request;
+ SwfdecPolicyFile *file;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (url != NULL);
+ g_return_if_fail (func);
+
+ if (swfdec_player_allow_now (player, url)) {
+ func (player, TRUE, data);
+ return;
+ }
+ if (load_url)
+ swfdec_policy_file_new (player, load_url);
+
+ priv = player->priv;
+ if (priv->loading_policy_files == NULL) {
+ func (player, FALSE, data);
+ return;
+ }
+ request = g_slice_new (SwfdecPolicyFileRequest);
+ request->url = swfdec_url_copy (url);
+ request->func = func;
+ request->data = data;
+
+ file = priv->loading_policy_files->data;
+ file->requests = g_slist_append (file->requests, request);
+}
+
diff --git a/swfdec/swfdec_policy_file.h b/swfdec/swfdec_policy_file.h
new file mode 100644
index 0000000..b849562
--- /dev/null
+++ b/swfdec/swfdec_policy_file.h
@@ -0,0 +1,65 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_FLASH_SECURITY_POLICY_H_
+#define _SWFDEC_FLASH_SECURITY_POLICY_H_
+
+#include <libswfdec/swfdec.h>
+#include <libswfdec/swfdec_player.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecPolicyFile SwfdecPolicyFile;
+typedef struct _SwfdecPolicyFileClass SwfdecPolicyFileClass;
+
+#define SWFDEC_TYPE_POLICY_FILE (swfdec_policy_file_get_type())
+#define SWFDEC_IS_POLICY_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_POLICY_FILE))
+#define SWFDEC_IS_POLICY_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_POLICY_FILE))
+#define SWFDEC_POLICY_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_POLICY_FILE, SwfdecPolicyFile))
+#define SWFDEC_POLICY_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_POLICY_FILE, SwfdecPolicyFileClass))
+#define SWFDEC_POLICY_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_POLICY_FILE, SwfdecPolicyFileClass))
+
+struct _SwfdecPolicyFile {
+ GObject object;
+
+ SwfdecPlayer * player; /* player we're loaded from */
+ SwfdecURL * load_url; /* url we're loaded from */
+ SwfdecURL * url; /* parent url we check with */
+ SwfdecStream * stream; /* stream we are loading or NULL if done loading */
+ GSList * allowed_hosts; /* list of GPatternSpec of the allowed hosts */
+
+ GSList * requests; /* requests waiting for this file to finish loading */
+};
+
+struct _SwfdecPolicyFileClass {
+ GObjectClass object_class;
+};
+
+GType swfdec_policy_file_get_type (void);
+
+SwfdecPolicyFile *swfdec_policy_file_new (SwfdecPlayer * player,
+ const SwfdecURL * url);
+gboolean swfdec_policy_file_is_loading (SwfdecPolicyFile * file);
+gboolean swfdec_policy_file_allow (SwfdecPolicyFile * file,
+ const SwfdecURL * url);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_print_job.c b/swfdec/swfdec_print_job.c
new file mode 100644
index 0000000..1428a6a
--- /dev/null
+++ b/swfdec/swfdec_print_job.c
@@ -0,0 +1,130 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_as_context.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (111, 100, swfdec_print_job_start)
+void
+swfdec_print_job_start (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("PrintJob.start");
+}
+
+SWFDEC_AS_NATIVE (111, 101, swfdec_print_job_addPage)
+void
+swfdec_print_job_addPage (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("PrintJob.addPage");
+}
+
+SWFDEC_AS_NATIVE (111, 102, swfdec_print_job_send)
+void
+swfdec_print_job_send (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("PrintJob.send");
+}
+
+static void
+swfdec_print_job_get_orientation (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("PrintJob.orientation (get)");
+}
+
+static void
+swfdec_print_job_get_pageHeight (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("PrintJob.pageHeight (get)");
+}
+
+static void
+swfdec_print_job_get_pageWidth (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("PrintJob.pageWidth (get)");
+}
+
+static void
+swfdec_print_job_get_paperHeight (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("PrintJob.paperHeight (get)");
+}
+
+static void
+swfdec_print_job_get_paperWidth (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("PrintJob.paperWidth (get)");
+}
+
+static void
+swfdec_print_job_init_properties (SwfdecAsContext *cx)
+{
+ SwfdecAsValue val;
+ SwfdecAsObject *xml, *proto;
+
+ // FIXME: We should only initialize if the prototype Object has not been
+ // initialized by any object's constructor with native properties
+ // (TextField, TextFormat, XML, XMLNode at least)
+
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (cx));
+
+ swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_PrintJob, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return;
+ xml = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+
+ swfdec_as_object_get_variable (xml, SWFDEC_AS_STR_prototype, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return;
+ proto = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_orientation,
+ swfdec_print_job_get_orientation, NULL);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_pageHeight,
+ swfdec_print_job_get_pageHeight, NULL);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_pageWidth,
+ swfdec_print_job_get_pageWidth, NULL);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_paperHeight,
+ swfdec_print_job_get_paperHeight, NULL);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_paperWidth,
+ swfdec_print_job_get_paperWidth, NULL);
+}
+
+SWFDEC_AS_NATIVE (111, 0, swfdec_print_job_construct)
+void
+swfdec_print_job_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("PrintJob");
+
+ swfdec_print_job_init_properties (cx);
+}
diff --git a/swfdec/swfdec_rect.c b/swfdec/swfdec_rect.c
new file mode 100644
index 0000000..c6365c1
--- /dev/null
+++ b/swfdec/swfdec_rect.c
@@ -0,0 +1,223 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+#include "swfdec_rect.h"
+
+void
+swfdec_rect_init_empty (SwfdecRect *rect)
+{
+ g_return_if_fail (rect != NULL);
+
+ rect->x0 = 0;
+ rect->y0 = 0;
+ rect->x1 = 0;
+ rect->y1 = 0;
+}
+
+/**
+ * swfdec_rect_round:
+ * @dest: pointer to rect that will take the result
+ * @src: #SwfdecRect that should be rounded
+ *
+ * Puts the smallest rectangle in @dest that includes @src but only
+ * contains integer numbers
+ **/
+void
+swfdec_rect_round (SwfdecRect *dest, SwfdecRect *src)
+{
+ g_return_if_fail (dest != NULL);
+ g_return_if_fail (src != NULL);
+
+ if (swfdec_rect_is_empty (src)) {
+ swfdec_rect_init_empty (dest);
+ return;
+ }
+ dest->x0 = floor (src->x0);
+ dest->y0 = floor (src->y0);
+ dest->x1 = ceil (src->x1);
+ dest->y1 = ceil (src->y1);
+}
+
+gboolean
+swfdec_rect_intersect (SwfdecRect * dest, const SwfdecRect * a, const SwfdecRect * b)
+{
+ SwfdecRect tmp;
+
+ g_return_val_if_fail (a != NULL, FALSE);
+ g_return_val_if_fail (b != NULL, FALSE);
+ if (dest == NULL)
+ dest = &tmp;
+
+ dest->x0 = MAX (a->x0, b->x0);
+ dest->y0 = MAX (a->y0, b->y0);
+ dest->x1 = MIN (a->x1, b->x1);
+ dest->y1 = MIN (a->y1, b->y1);
+
+ return !swfdec_rect_is_empty (dest);
+}
+
+/**
+ * swfdec_rect_union:
+ * @dest: destination rectangle
+ * @a: first source rectangle, may be emtpy
+ * @b: second source rectangle, may be empty
+ *
+ * Stores the union of @a and @b into @dest. The union is the smallest
+ * rectangle that includes both source rectangles. @a, @b and @dest may point
+ * to the same rectangle.
+ **/
+void
+swfdec_rect_union (SwfdecRect * dest, const SwfdecRect * a, const SwfdecRect * b)
+{
+ g_return_if_fail (dest != NULL);
+ g_return_if_fail (a != NULL);
+ g_return_if_fail (b != NULL);
+
+ if (swfdec_rect_is_empty (a)) {
+ *dest = *b;
+ } else if (swfdec_rect_is_empty (b)) {
+ *dest = *a;
+ } else {
+ dest->x0 = MIN (a->x0, b->x0);
+ dest->y0 = MIN (a->y0, b->y0);
+ dest->x1 = MAX (a->x1, b->x1);
+ dest->y1 = MAX (a->y1, b->y1);
+ }
+}
+
+void
+swfdec_rect_subtract (SwfdecRect *dest, const SwfdecRect *a, const SwfdecRect *b)
+{
+ g_return_if_fail (dest != NULL);
+ g_return_if_fail (a != NULL);
+ g_return_if_fail (b != NULL);
+
+ /* FIXME: improve this */
+ if (swfdec_rect_is_empty (a)) {
+ swfdec_rect_init_empty (dest);
+ } else if (swfdec_rect_is_empty (b)) {
+ *dest = *a;
+ } else if (b->x0 <= a->x0 && b->x1 >= a->x1 &&
+ b->y0 <= a->y0 && b->y1 >= a->y1) {
+ swfdec_rect_init_empty (dest);
+ } else {
+ *dest = *a;
+ }
+}
+
+void
+swfdec_rect_scale (SwfdecRect *dest, const SwfdecRect *src, double factor)
+{
+ g_return_if_fail (dest != NULL);
+ g_return_if_fail (src != NULL);
+
+ dest->x0 = src->x0 * factor;
+ dest->x1 = src->x1 * factor;
+ dest->y0 = src->y0 * factor;
+ dest->y1 = src->y1 * factor;
+}
+
+gboolean
+swfdec_rect_is_empty (const SwfdecRect * a)
+{
+ return (a->x1 <= a->x0) || (a->y1 <= a->y0);
+}
+
+gboolean
+swfdec_rect_contains (const SwfdecRect *rect, double x, double y)
+{
+ return x >= rect->x0 &&
+ x < rect->x1 &&
+ y >= rect->y0 &&
+ y < rect->y1;
+}
+
+/**
+ * swfdec_rect_transform:
+ * @dest: destination rectangle
+ * @src: source rectangle
+ * @matrix: matrix to apply to source
+ *
+ * Computes a rectangle that completely encloses the area that results from
+ * applying @matrix to @src.
+ **/
+void
+swfdec_rect_transform (SwfdecRect *dest, const SwfdecRect *src, const cairo_matrix_t *matrix)
+{
+ SwfdecRect tmp, tmp2;
+
+ g_return_if_fail (dest != NULL);
+ g_return_if_fail (src != NULL);
+ g_return_if_fail (matrix != NULL);
+
+ tmp = *src;
+ tmp2 = *src;
+ cairo_matrix_transform_point (matrix, &tmp.x0, &tmp.y0);
+ cairo_matrix_transform_point (matrix, &tmp.x1, &tmp.y1);
+ cairo_matrix_transform_point (matrix, &tmp2.x0, &tmp2.y1);
+ cairo_matrix_transform_point (matrix, &tmp2.x1, &tmp2.y0);
+
+ dest->x0 = MIN (MIN (tmp.x0, tmp.x1), MIN (tmp2.x0, tmp2.x1));
+ dest->y0 = MIN (MIN (tmp.y0, tmp.y1), MIN (tmp2.y0, tmp2.y1));
+ dest->x1 = MAX (MAX (tmp.x0, tmp.x1), MAX (tmp2.x0, tmp2.x1));
+ dest->y1 = MAX (MAX (tmp.y0, tmp.y1), MAX (tmp2.y0, tmp2.y1));
+}
+
+/**
+ * swfdec_rect_inside:
+ * @outer: the supposed outer rectangle
+ * @inner: the supposed inner rectangle
+ *
+ * Checks if @outer completely includes the rectangle specified by @inner.
+ * If both rectangles are empty, TRUE is returned.
+ *
+ * Returns: TRUE if @outer includes @inner, FALSE otherwise
+ **/
+gboolean
+swfdec_rect_inside (const SwfdecRect *outer, const SwfdecRect *inner)
+{
+ /* empty includes empty */
+ if (swfdec_rect_is_empty (inner))
+ return TRUE;
+ /* if outer is empty, below will return FALSE */
+ return outer->x0 <= inner->x0 &&
+ outer->y0 <= inner->y0 &&
+ outer->x1 >= inner->x1 &&
+ outer->y1 >= inner->y1;
+}
+
+void
+swfdec_rectangle_init_rect (SwfdecRectangle *rectangle, const SwfdecRect *rect)
+{
+ g_return_if_fail (rectangle != NULL);
+ g_return_if_fail (rect != NULL);
+
+ rectangle->x = floor (rect->x0);
+ rectangle->y = floor (rect->y0);
+ rectangle->width = ceil (rect->x1) - rectangle->x;
+ rectangle->height = ceil (rect->y1) - rectangle->y;
+}
+
diff --git a/swfdec/swfdec_rect.h b/swfdec/swfdec_rect.h
new file mode 100644
index 0000000..d43cee4
--- /dev/null
+++ b/swfdec/swfdec_rect.h
@@ -0,0 +1,51 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SWFDEC_RECT_H__
+#define __SWFDEC_RECT_H__
+
+#include <libswfdec/swfdec_types.h>
+#include <libswfdec/swfdec_rectangle.h>
+
+struct _SwfdecRect
+{
+ double x0;
+ double y0;
+ double x1;
+ double y1;
+};
+
+void swfdec_rect_init_empty (SwfdecRect *rect);
+
+gboolean swfdec_rect_intersect (SwfdecRect * dest, const SwfdecRect * a, const SwfdecRect * b);
+void swfdec_rect_round (SwfdecRect *dest, SwfdecRect *src);
+void swfdec_rect_union (SwfdecRect * dest, const SwfdecRect * a, const SwfdecRect * b);
+void swfdec_rect_subtract (SwfdecRect *dest, const SwfdecRect *a, const SwfdecRect *b);
+void swfdec_rect_scale (SwfdecRect *dest, const SwfdecRect *src, double factor);
+gboolean swfdec_rect_is_empty (const SwfdecRect * a);
+/* FIXME: rename to _contains_point and _contains instead of _inside? */
+gboolean swfdec_rect_contains (const SwfdecRect *rect, double x, double y);
+gboolean swfdec_rect_inside (const SwfdecRect *outer, const SwfdecRect *inner);
+void swfdec_rect_transform (SwfdecRect *dest, const SwfdecRect *src, const cairo_matrix_t *matrix);
+
+void swfdec_rectangle_init_rect (SwfdecRectangle *rectangle, const SwfdecRect *rect);
+
+#endif
diff --git a/swfdec/swfdec_rectangle.c b/swfdec/swfdec_rectangle.c
new file mode 100644
index 0000000..622f15a
--- /dev/null
+++ b/swfdec/swfdec_rectangle.c
@@ -0,0 +1,203 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_rectangle.h"
+
+/**
+ * SECTION:SwfdecRectangle
+ * @title: SwfdecRectangle
+ * @short_description: handling regions on the screen
+ *
+ * This section describes how regions are handled in Swfdec. Regions are
+ * important when tracking which parts of the screen have been invalidated and
+ * need to be repainted. See SwfdecPlayer::invalidate for an example.
+ */
+
+/**
+ * SwfdecRectangle:
+ * @x: x coordinate of top-left point
+ * @y: y coordinate of top-left point
+ * @width: width of rectangle or 0 for empty
+ * @height: height of rectangle or 0 for empty
+ *
+ * This structure represents a rectangular region. It is identical to the
+ * #GdkRectangle structure, so you can cast freely between them. The only
+ * difference is that Gdk does not allow empty rectangles, while Swfdec does.
+ * You can use swfdec_rectangle_is_empty() to check for this.
+ */
+
+static gpointer
+swfdec_rectangle_copy (gpointer src)
+{
+ return g_memdup (src, sizeof (SwfdecRectangle));
+}
+
+GType
+swfdec_rectangle_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type)
+ type = g_boxed_type_register_static ("SwfdecRectangle",
+ swfdec_rectangle_copy, g_free);
+
+ return type;
+}
+
+/**
+ * swfdec_rectangle_init_empty:
+ * @rectangle: rectangle to initialize
+ *
+ * Initializes the rectangle as empty.
+ **/
+void
+swfdec_rectangle_init_empty (SwfdecRectangle *rectangle)
+{
+ rectangle->x = rectangle->y = rectangle->width = rectangle->height = 0;
+}
+
+/**
+ * swfdec_rectangle_is_empty:
+ * @rectangle: rectangle to check
+ *
+ * Checks if the given @rectangle is empty.
+ *
+ * Returns: %TRUE if the rectangle is emtpy
+ **/
+gboolean
+swfdec_rectangle_is_empty (const SwfdecRectangle *rectangle)
+{
+ g_return_val_if_fail (rectangle != NULL, FALSE);
+
+ return rectangle->width <= 0 || rectangle->height <= 0;
+}
+
+/**
+ * swfdec_rectangle_intersect:
+ * @dest: the rectangle to take the result or %NULL
+ * @a: first rectangle to intersect
+ * @b: second rectangle to intersect
+ *
+ * Intersects the rectangles @a and @b and puts the result into @dest. It is
+ * allowed if @dest is the same as @a or @b.
+ *
+ * Returns: %TRUE if the intersection is not empty.
+ **/
+gboolean
+swfdec_rectangle_intersect (SwfdecRectangle *dest, const SwfdecRectangle *a,
+ const SwfdecRectangle *b)
+{
+ SwfdecRectangle tmp;
+
+ g_return_val_if_fail (a != NULL, FALSE);
+ g_return_val_if_fail (b != NULL, FALSE);
+
+ tmp.x = MAX (a->x, b->x);
+ tmp.y = MAX (a->y, b->y);
+ tmp.width = MIN (a->x + a->width, b->x + b->width) - tmp.x;
+ tmp.height = MIN (a->y + a->height, b->y + b->height) - tmp.y;
+
+ if (tmp.width <= 0 && tmp.height <= 0) {
+ if (dest)
+ dest->x = dest->y = dest->width = dest->height = 0;
+ return FALSE;
+ }
+
+ if (dest != NULL)
+ *dest = tmp;
+ return TRUE;
+}
+
+/**
+ * swfdec_rectangle_union:
+ * @dest: destination to take the union
+ * @a: first rectangle to union
+ * @b: second rectangle to union
+ *
+ * Computes the smallest rectangle that contains both @a and @b and puts it in
+ * @dest.
+ **/
+void
+swfdec_rectangle_union (SwfdecRectangle *dest, const SwfdecRectangle *a,
+ const SwfdecRectangle *b)
+{
+ int x, y;
+
+ g_return_if_fail (dest != NULL);
+ g_return_if_fail (a != NULL);
+ g_return_if_fail (b != NULL);
+
+ if (swfdec_rectangle_is_empty (a)) {
+ *dest = *b;
+ return;
+ } else if (swfdec_rectangle_is_empty (b)) {
+ *dest = *a;
+ return;
+ }
+ x = MIN (a->x, b->x);
+ y = MIN (a->y, b->y);
+ dest->width = MAX (a->x + a->width, b->x + b->width) - x;
+ dest->height = MAX (a->y + a->height, b->y + b->height) - y;
+ dest->x = x;
+ dest->y = y;
+}
+
+/**
+ * swfdec_rectangle_contains:
+ * @container: the supposedly bigger rectangle
+ * @content: the supposedly smaller rectangle
+ *
+ * Checks if @container contains the whole rectangle @content.
+ *
+ * Returns: %TRUE if @container contains @content.
+ **/
+gboolean
+swfdec_rectangle_contains (const SwfdecRectangle *container, const SwfdecRectangle *content)
+{
+ g_return_val_if_fail (container != NULL, FALSE);
+ g_return_val_if_fail (content != NULL, FALSE);
+
+ return container->x <= content->x &&
+ container->y <= content->y &&
+ container->x + container->width >= content->x + content->width &&
+ container->y + container->height >= content->y + content->height;
+}
+
+/**
+ * swfdec_rectangle_contains_point:
+ * @rectangle: a rectangle
+ * @x: x coordinate of point to check
+ * @y: y coordinate of point to check
+ *
+ * Checks if the given point is inside the given rectangle.
+ *
+ * Returns: %TRUE if the point is inside the rectangle
+ **/
+gboolean
+swfdec_rectangle_contains_point (const SwfdecRectangle *rectangle, int x, int y)
+{
+ g_return_val_if_fail (rectangle != NULL, FALSE);
+
+ return rectangle->x <= x && rectangle->y <= y &&
+ rectangle->x + rectangle->width > x && rectangle->y + rectangle->height > y;
+}
diff --git a/swfdec/swfdec_rectangle.h b/swfdec/swfdec_rectangle.h
new file mode 100644
index 0000000..4d34ae6
--- /dev/null
+++ b/swfdec/swfdec_rectangle.h
@@ -0,0 +1,55 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SWFDEC_RECTANGLE_H__
+#define __SWFDEC_RECTANGLE_H__
+
+#include <glib-object.h>
+
+#define SWFDEC_TYPE_RECTANGLE swfdec_rectangle_get_type ()
+
+typedef struct _SwfdecRectangle SwfdecRectangle;
+
+struct _SwfdecRectangle {
+ int x; /* x coordinate of top-left point */
+ int y; /* y coordinate of top left point */
+ int width; /* width of rectangle or 0 for empty */
+ int height; /* height of rectangle or 0 for empty */
+};
+
+GType swfdec_rectangle_get_type (void);
+
+void swfdec_rectangle_init_empty (SwfdecRectangle * rectangle);
+
+gboolean swfdec_rectangle_is_empty (const SwfdecRectangle * rectangle);
+
+gboolean swfdec_rectangle_intersect (SwfdecRectangle * dest,
+ const SwfdecRectangle * a,
+ const SwfdecRectangle * b);
+void swfdec_rectangle_union (SwfdecRectangle * dest,
+ const SwfdecRectangle * a,
+ const SwfdecRectangle * b);
+gboolean swfdec_rectangle_contains (const SwfdecRectangle * container,
+ const SwfdecRectangle * content);
+gboolean swfdec_rectangle_contains_point (const SwfdecRectangle * rectangle,
+ int x,
+ int y);
+
+
+#endif
diff --git a/swfdec/swfdec_resource.c b/swfdec/swfdec_resource.c
new file mode 100644
index 0000000..2ea802f
--- /dev/null
+++ b/swfdec/swfdec_resource.c
@@ -0,0 +1,691 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include "swfdec_resource.h"
+#include "swfdec_as_object.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_interpret.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_character.h"
+#include "swfdec_debug.h"
+#include "swfdec_decoder.h"
+#include "swfdec_image_decoder.h"
+#include "swfdec_loader_internal.h"
+#include "swfdec_movie_clip_loader.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_sandbox.h"
+#include "swfdec_script.h"
+#include "swfdec_sprite.h"
+#include "swfdec_stream_target.h"
+#include "swfdec_swf_decoder.h"
+#include "swfdec_utils.h"
+
+
+static void swfdec_resource_stream_target_init (SwfdecStreamTargetInterface *iface);
+G_DEFINE_TYPE_WITH_CODE (SwfdecResource, swfdec_resource, SWFDEC_TYPE_AS_OBJECT,
+ G_IMPLEMENT_INTERFACE (SWFDEC_TYPE_STREAM_TARGET, swfdec_resource_stream_target_init))
+
+/*** SWFDEC_STREAM_TARGET interface ***/
+
+static gboolean
+swfdec_resource_is_root (SwfdecResource *resource)
+{
+ g_return_val_if_fail (SWFDEC_IS_RESOURCE (resource), FALSE);
+
+ return
+ resource->movie == SWFDEC_PLAYER (SWFDEC_AS_OBJECT (resource)->context)->priv->roots->data;
+}
+
+static SwfdecPlayer *
+swfdec_resource_stream_target_get_player (SwfdecStreamTarget *target)
+{
+ return SWFDEC_PLAYER (SWFDEC_AS_OBJECT (target)->context);
+}
+
+static void
+swfdec_resource_stream_target_image (SwfdecResource *instance)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (instance)->context);
+ SwfdecSpriteMovie *movie = instance->movie;
+
+ if (movie->sprite != NULL)
+ return;
+
+ if (SWFDEC_IS_SWF_DECODER (instance->decoder)) {
+ SwfdecSwfDecoder *dec = SWFDEC_SWF_DECODER (instance->decoder);
+
+ instance->sandbox = swfdec_sandbox_get_for_url (player,
+ swfdec_loader_get_url (instance->loader), instance->version,
+ SWFDEC_SWF_DECODER (instance->decoder)->use_network);
+ if (instance->sandbox) {
+ movie->sprite = dec->main_sprite;
+ g_assert (movie->sprite->parse_frame > 0);
+ movie->n_frames = movie->sprite->n_frames;
+ swfdec_movie_invalidate_last (SWFDEC_MOVIE (movie));
+ swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (movie), instance->sandbox->MovieClip);
+ if (swfdec_resource_is_root (instance)) {
+ swfdec_movie_initialize (SWFDEC_MOVIE (movie));
+ swfdec_player_perform_actions (player);
+ }
+ } else {
+ SWFDEC_FIXME ("cannot continue loading %s, invalid rights",
+ swfdec_url_get_url (swfdec_loader_get_url (instance->loader)));
+ swfdec_stream_set_target (SWFDEC_STREAM (instance->loader), NULL);
+ /* FIXME: anyting on the movie we need to clear? */
+ }
+ } else {
+ g_assert_not_reached ();
+ }
+}
+
+/* NB: name must be GC'ed */
+static void
+swfdec_resource_emit_signal (SwfdecResource *resource, const char *name, gboolean progress,
+ SwfdecAsValue *args, guint n_args)
+{
+ SwfdecAsContext *cx;
+ SwfdecAsObject *movie;
+ guint skip = progress ? 4 : 2;
+ SwfdecAsValue vals[n_args + skip];
+
+ if (resource->clip_loader == NULL)
+ return;
+ cx = SWFDEC_AS_OBJECT (resource->clip_loader)->context;
+ g_assert (resource->target);
+ movie = swfdec_action_lookup_object (cx, SWFDEC_PLAYER (cx)->priv->roots->data,
+ resource->target, resource->target + strlen (resource->target));
+ if (!SWFDEC_IS_SPRITE_MOVIE (movie)) {
+ SWFDEC_DEBUG ("no movie, not emitting signal");
+ return;
+ }
+ if (name == SWFDEC_AS_STR_onLoadInit &&
+ movie != SWFDEC_AS_OBJECT (resource->movie)) {
+ SWFDEC_INFO ("not emitting onLoadInit - the movie is different");
+ return;
+ }
+
+ 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[skip], args, sizeof (SwfdecAsValue) * n_args);
+ /* FIXME: what's the correct sandbox here? */
+ swfdec_sandbox_use (resource->clip_loader_sandbox);
+ swfdec_as_object_call (SWFDEC_AS_OBJECT (resource->clip_loader), SWFDEC_AS_STR_broadcastMessage,
+ n_args + skip, vals, NULL);
+ swfdec_sandbox_unuse (resource->clip_loader_sandbox);
+}
+
+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 SwfdecSpriteMovie *
+swfdec_resource_replace_movie (SwfdecSpriteMovie *movie, SwfdecResource *resource)
+{
+ /* can't use swfdec_movie_duplicate() here, we copy to same depth */
+ SwfdecMovie *mov = SWFDEC_MOVIE (movie);
+ SwfdecMovie *copy;
+
+ copy = swfdec_movie_new (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context),
+ mov->depth, mov->parent, resource, NULL, mov->name);
+ if (copy == NULL)
+ return FALSE;
+ copy->matrix = mov->matrix;
+ copy->original_name = mov->original_name;
+ copy->modified = mov->modified;
+ copy->xscale = mov->xscale;
+ copy->yscale = mov->yscale;
+ copy->rotation = mov->rotation;
+ /* FIXME: are events copied? If so, wouldn't that be a security issue? */
+ swfdec_movie_set_static_properties (copy, &mov->original_transform,
+ &mov->original_ctrans, mov->original_ratio, mov->clip_depth,
+ mov->blend_mode, NULL);
+ swfdec_movie_remove (mov);
+ swfdec_movie_queue_update (copy, SWFDEC_MOVIE_INVALID_MATRIX);
+ return SWFDEC_SPRITE_MOVIE (copy);
+}
+
+static gboolean
+swfdec_resource_create_movie (SwfdecResource *resource)
+{
+ SwfdecPlayer *player;
+ SwfdecSpriteMovie *movie;
+ int level = -1;
+
+ if (resource->movie)
+ return TRUE;
+ player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (resource)->context);
+ movie = (SwfdecSpriteMovie *) swfdec_action_lookup_object (SWFDEC_AS_CONTEXT (player),
+ player->priv->roots->data, resource->target, resource->target + strlen (resource->target));
+ if (!SWFDEC_IS_SPRITE_MOVIE (movie)) {
+ level = swfdec_player_get_level (player, resource->target);
+ if (level < 0) {
+ SWFDEC_WARNING ("%s does not reference a movie, not loading %s", resource->target,
+ swfdec_url_get_url (swfdec_loader_get_url (resource->loader)));
+ swfdec_stream_close (SWFDEC_STREAM (resource->loader));
+ swfdec_player_unroot (player, resource);
+ return FALSE;
+ }
+ movie = swfdec_player_get_movie_at_level (player, level);
+ }
+ if (movie == NULL) {
+ movie = swfdec_player_create_movie_at_level (player, resource, level);
+ } else {
+ /* FIXME: is this correct? */
+ movie = swfdec_resource_replace_movie (movie, resource);
+ }
+ swfdec_player_unroot (player, resource);
+ return TRUE;
+}
+
+static void
+swfdec_resource_stream_target_open (SwfdecStreamTarget *target, SwfdecStream *stream)
+{
+ SwfdecLoader *loader = SWFDEC_LOADER (stream);
+ SwfdecResource *instance = SWFDEC_RESOURCE (target);
+ const char *query;
+
+ if (!swfdec_resource_create_movie (instance))
+ return;
+ query = swfdec_url_get_query (swfdec_loader_get_url (loader));
+ if (query) {
+ SWFDEC_INFO ("set url query movie variables: %s", query);
+ swfdec_as_object_decode (SWFDEC_AS_OBJECT (instance->movie), query);
+ }
+ if (instance->variables) {
+ SWFDEC_INFO ("set manual movie variables: %s", instance->variables);
+ swfdec_as_object_decode (SWFDEC_AS_OBJECT (instance->movie), instance->variables);
+ }
+ swfdec_resource_emit_signal (instance, SWFDEC_AS_STR_onLoadStart, FALSE, NULL, 0);
+ instance->state = SWFDEC_RESOURCE_OPENED;
+}
+
+static void
+swfdec_resource_stream_target_parse (SwfdecStreamTarget *target, SwfdecStream *stream)
+{
+ SwfdecLoader *loader = SWFDEC_LOADER (stream);
+ SwfdecResource *resource = SWFDEC_RESOURCE (target);
+ SwfdecBufferQueue *queue;
+ SwfdecBuffer *buffer;
+ SwfdecDecoder *dec = resource->decoder;
+ SwfdecStatus status;
+ guint parsed;
+
+ queue = swfdec_stream_get_queue (stream);
+ if (dec == NULL && swfdec_buffer_queue_get_offset (queue) == 0) {
+ if (swfdec_buffer_queue_get_depth (queue) < SWFDEC_DECODER_DETECT_LENGTH)
+ return;
+ buffer = swfdec_buffer_queue_peek (queue, 4);
+ dec =
+ swfdec_decoder_new (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (resource)->context), buffer);
+ swfdec_buffer_unref (buffer);
+ if (dec == NULL) {
+ SWFDEC_ERROR ("no decoder found for format");
+ } else {
+ glong total;
+ resource->decoder = dec;
+ total = swfdec_loader_get_size (loader);
+ if (total >= 0)
+ dec->bytes_total = total;
+ }
+ }
+ while (swfdec_buffer_queue_get_depth (queue)) {
+ parsed = 0;
+ status = 0;
+ do {
+ buffer = swfdec_buffer_queue_peek_buffer (queue);
+ if (buffer == NULL)
+ break;
+ if (parsed + buffer->length <= 65536) {
+ swfdec_buffer_unref (buffer);
+ buffer = swfdec_buffer_queue_pull_buffer (queue);
+ } else {
+ swfdec_buffer_unref (buffer);
+ buffer = swfdec_buffer_queue_pull (queue, 65536 - parsed);
+ }
+ parsed += buffer->length;
+ if (dec) {
+ status |= swfdec_decoder_parse (dec, buffer);
+ } else {
+ swfdec_buffer_unref (buffer);
+ }
+ } while (parsed < 65536 && (status & (SWFDEC_STATUS_ERROR | SWFDEC_STATUS_EOF)) == 0);
+ if (status & SWFDEC_STATUS_ERROR) {
+ SWFDEC_ERROR ("parsing error");
+ swfdec_stream_set_target (SWFDEC_STREAM (loader), NULL);
+ return;
+ }
+ if ((status & SWFDEC_STATUS_INIT)) {
+ if (SWFDEC_IS_SWF_DECODER (dec))
+ resource->version = SWFDEC_SWF_DECODER (dec)->version;
+ if (swfdec_resource_is_root (resource)) {
+ swfdec_player_initialize (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (resource)->context),
+ dec->rate, dec->width, dec->height);
+ }
+ }
+ if (status & SWFDEC_STATUS_IMAGE)
+ swfdec_resource_stream_target_image (resource);
+ swfdec_resource_emit_signal (resource, SWFDEC_AS_STR_onLoadProgress, TRUE, NULL, 0);
+ if (status & SWFDEC_STATUS_EOF)
+ return;
+ }
+}
+
+static void
+swfdec_resource_stream_target_close (SwfdecStreamTarget *target, SwfdecStream *stream)
+{
+ SwfdecResource *resource = SWFDEC_RESOURCE (target);
+ SwfdecAsValue val;
+
+ swfdec_resource_emit_signal (resource, SWFDEC_AS_STR_onLoadProgress, TRUE, NULL, 0);
+ if (resource->decoder) {
+ SwfdecDecoder *dec = resource->decoder;
+ swfdec_decoder_eof (dec);
+ if (dec->data_type != SWFDEC_LOADER_DATA_UNKNOWN)
+ swfdec_loader_set_data_type (SWFDEC_LOADER (stream), dec->data_type);
+ }
+ 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_stream_target_error (SwfdecStreamTarget *target, SwfdecStream *stream)
+{
+ 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:
+ default:
+ g_assert_not_reached ();
+ message = SWFDEC_AS_STR_EMPTY;
+ break;
+ }
+ swfdec_resource_emit_error (resource, message);
+}
+
+static void
+swfdec_resource_stream_target_init (SwfdecStreamTargetInterface *iface)
+{
+ iface->get_player = swfdec_resource_stream_target_get_player;
+ iface->open = swfdec_resource_stream_target_open;
+ iface->parse = swfdec_resource_stream_target_parse;
+ iface->error = swfdec_resource_stream_target_error;
+ iface->close = swfdec_resource_stream_target_close;
+}
+
+static void
+swfdec_resource_mark (SwfdecAsObject *object)
+{
+ SwfdecResource *resource = SWFDEC_RESOURCE (object);
+
+ if (resource->clip_loader) {
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (resource->clip_loader));
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (resource->clip_loader_sandbox));
+ }
+ if (resource->sandbox)
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (resource->sandbox));
+
+ SWFDEC_AS_OBJECT_CLASS (swfdec_resource_parent_class)->mark (object);
+}
+
+static void
+swfdec_resource_dispose (GObject *object)
+{
+ SwfdecResource *resource = SWFDEC_RESOURCE (object);
+
+ if (resource->loader) {
+ swfdec_stream_set_target (SWFDEC_STREAM (resource->loader), NULL);
+ g_object_unref (resource->loader);
+ resource->loader = NULL;
+ }
+ if (resource->decoder) {
+ g_object_unref (resource->decoder);
+ resource->decoder = NULL;
+ }
+ g_free (resource->target);
+ g_free (resource->variables);
+ g_hash_table_destroy (resource->exports);
+ g_hash_table_destroy (resource->export_names);
+
+ G_OBJECT_CLASS (swfdec_resource_parent_class)->dispose (object);
+}
+
+static void
+swfdec_resource_class_init (SwfdecResourceClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
+
+ object_class->dispose = swfdec_resource_dispose;
+
+ asobject_class->mark = swfdec_resource_mark;
+}
+
+static void
+swfdec_resource_init (SwfdecResource *instance)
+{
+ instance->exports = g_hash_table_new_full (swfdec_str_case_hash,
+ swfdec_str_case_equal, g_free, g_object_unref);
+ instance->export_names = g_hash_table_new_full (g_direct_hash, g_direct_equal,
+ g_object_unref, g_free);
+}
+
+static void
+swfdec_resource_set_loader (SwfdecResource *resource, SwfdecLoader *loader)
+{
+ g_return_if_fail (SWFDEC_IS_RESOURCE (resource));
+ g_return_if_fail (SWFDEC_IS_LOADER (loader));
+ g_return_if_fail (resource->loader == NULL);
+
+ resource->loader = g_object_ref (loader);
+ swfdec_stream_set_target (SWFDEC_STREAM (resource->loader), SWFDEC_STREAM_TARGET (resource));
+ resource->state = SWFDEC_RESOURCE_REQUESTED;
+}
+
+SwfdecResource *
+swfdec_resource_new (SwfdecPlayer *player, SwfdecLoader *loader, const char *variables)
+{
+ SwfdecResource *resource;
+ guint size;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (SWFDEC_IS_LOADER (loader), NULL);
+
+ size = sizeof (SwfdecResource);
+ if (!swfdec_as_context_use_mem (SWFDEC_AS_CONTEXT (player), size))
+ size = 0;
+ resource = g_object_new (SWFDEC_TYPE_RESOURCE, NULL);
+ swfdec_as_object_add (SWFDEC_AS_OBJECT (resource), SWFDEC_AS_CONTEXT (player), size);
+ resource->version = 8;
+ resource->variables = g_strdup (variables);
+ swfdec_resource_set_loader (resource, loader);
+
+ return resource;
+}
+
+gpointer
+swfdec_resource_get_export (SwfdecResource *instance, const char *name)
+{
+ g_return_val_if_fail (SWFDEC_IS_RESOURCE (instance), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+
+ return g_hash_table_lookup (instance->exports, name);
+}
+
+const char *
+swfdec_resource_get_export_name (SwfdecResource *instance, SwfdecCharacter *character)
+{
+ g_return_val_if_fail (SWFDEC_IS_RESOURCE (instance), NULL);
+ g_return_val_if_fail (SWFDEC_IS_CHARACTER (character), NULL);
+
+ return g_hash_table_lookup (instance->export_names, character);
+}
+
+void
+swfdec_resource_add_export (SwfdecResource *instance, SwfdecCharacter *character, const char *name)
+{
+ g_return_if_fail (SWFDEC_IS_RESOURCE (instance));
+ g_return_if_fail (SWFDEC_IS_CHARACTER (character));
+ g_return_if_fail (name != NULL);
+
+ g_hash_table_insert (instance->exports, g_strdup (name), g_object_ref (character));
+ g_hash_table_insert (instance->export_names, g_object_ref (character), g_strdup (name));
+}
+
+/*** RESOURC LOAD ***/
+
+typedef struct _SwfdecResourceLoad SwfdecResourceLoad;
+struct _SwfdecResourceLoad {
+ SwfdecSandbox * sandbox;
+ char * target;
+ char * url;
+ SwfdecLoaderRequest request;
+ SwfdecBuffer * buffer;
+ SwfdecMovieClipLoader * loader;
+ gboolean target_is_movie;
+};
+
+static void
+swfdec_resource_load_free (gpointer loadp)
+{
+ SwfdecResourceLoad *load = loadp;
+
+ swfdec_player_unroot (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (load->sandbox)->context), load);
+ g_free (load->url);
+ g_free (load->target);
+ if (load->buffer)
+ swfdec_buffer_unref (load->buffer);
+ g_slice_free (SwfdecResourceLoad, load);
+}
+
+static void
+swfdec_resource_load_mark (gpointer loadp, gpointer playerp)
+{
+ SwfdecResourceLoad *load = loadp;
+
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (load->sandbox));
+ if (load->loader)
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (load->loader));
+}
+
+static void
+swfdec_resource_do_load (SwfdecPlayer *player, gboolean allowed, gpointer loadp)
+{
+ SwfdecResourceLoad *load = loadp;
+ SwfdecResource *resource;
+ SwfdecLoader *loader;
+
+ if (!swfdec_as_context_use_mem (SWFDEC_AS_CONTEXT (player), sizeof (SwfdecResource)))
+ return;
+ resource = g_object_new (SWFDEC_TYPE_RESOURCE, NULL);
+ swfdec_as_object_add (SWFDEC_AS_OBJECT (resource), SWFDEC_AS_CONTEXT (player), sizeof (SwfdecResource));
+ resource->version = 8;
+ resource->target = g_strdup (load->target);
+ if (load->loader) {
+ resource->clip_loader = load->loader;
+ resource->clip_loader_sandbox = load->sandbox;
+ }
+ resource->sandbox = load->sandbox;
+
+ if (!allowed) {
+ SWFDEC_WARNING ("SECURITY: no access to %s from %s",
+ load->url, swfdec_url_get_url (load->sandbox->url));
+ /* FIXME: is replacing correct? */
+ swfdec_resource_emit_error (resource, SWFDEC_AS_STR_IllegalRequest);
+ return;
+ }
+
+ swfdec_player_root (player, resource, (GFunc) swfdec_as_object_mark);
+ loader = swfdec_player_load (player, load-> url, load->request, load->buffer);
+ swfdec_resource_set_loader (resource, loader);
+ g_object_unref (loader);
+}
+
+static void
+swfdec_resource_load_request (gpointer loadp, gpointer playerp)
+{
+ SwfdecResourceLoad *load = loadp;
+ SwfdecPlayer *player = playerp;
+ SwfdecURL *url;
+
+ /* empty URL means unload (yay!) */
+ if (load->url[0] == '\0') {
+ SwfdecSpriteMovie *movie;
+
+ movie = (SwfdecSpriteMovie *) swfdec_action_lookup_object (
+ SWFDEC_AS_CONTEXT (player), player->priv->roots->data,
+ load->target, load->target + strlen (load->target));
+ if (!SWFDEC_IS_SPRITE_MOVIE (movie)) {
+ SWFDEC_DEBUG ("no movie, not unloading");
+ return;
+ }
+ swfdec_resource_replace_movie (movie, SWFDEC_MOVIE (movie)->resource);
+ return;
+ }
+
+ /* fscommand? */
+ if (g_ascii_strncasecmp (load->url, "FSCommand:", 10) == 0) {
+ char *command = load->url + 10;
+ g_signal_emit_by_name (player, "fscommand", command, load->target);
+ return;
+ }
+
+ /* LAUNCH command (aka getURL) */
+ if (!load->target_is_movie && swfdec_player_get_level (player, load->target) < 0) {
+ swfdec_player_launch (player, load->request, load->url,load->target, load->buffer);
+ return;
+ }
+
+ if (swfdec_url_path_is_relative (load->url)) {
+ swfdec_resource_do_load (player, TRUE, load);
+ return;
+ }
+ url = swfdec_player_create_url (player, load->url);
+ if (url == NULL) {
+ swfdec_resource_do_load (player, FALSE, load);
+ return;
+ }
+ switch (load->sandbox->type) {
+ case SWFDEC_SANDBOX_REMOTE:
+ swfdec_resource_do_load (player, !swfdec_url_is_local (url), load);
+ break;
+ case SWFDEC_SANDBOX_LOCAL_NETWORK:
+ case SWFDEC_SANDBOX_LOCAL_TRUSTED:
+ if (!swfdec_url_is_local (url)) {
+ SWFDEC_FIXME ("Adobe claims you need to be allowed by policy files now, "
+ "we don't check that though");
+ }
+ swfdec_resource_do_load (player, TRUE, load);
+ break;
+ case SWFDEC_SANDBOX_LOCAL_FILE:
+ swfdec_resource_do_load (player, swfdec_url_is_local (url), load);
+ break;
+ case SWFDEC_SANDBOX_NONE:
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+ swfdec_url_free (url);
+}
+
+/* NB: must be called from a script */
+/* FIXME: 7 arguments?! */
+void
+swfdec_resource_load (SwfdecPlayer *player, const char *target, const char *url,
+ SwfdecLoaderRequest request, SwfdecBuffer *buffer, SwfdecMovieClipLoader *loader,
+ gboolean target_is_movie)
+{
+ SwfdecSpriteMovie *movie;
+ SwfdecResourceLoad *load;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (target != NULL);
+ g_return_if_fail (url != NULL);
+ g_return_if_fail (loader == NULL || SWFDEC_IS_MOVIE_CLIP_LOADER (loader));
+
+ g_assert (SWFDEC_AS_CONTEXT (player)->frame != NULL);
+ load = g_slice_new (SwfdecResourceLoad);
+
+ if (target_is_movie) {
+ movie = (SwfdecSpriteMovie *) swfdec_player_get_movie_from_string (player, target);
+ if (SWFDEC_IS_SPRITE_MOVIE (movie)) {
+ load->target = swfdec_movie_get_path (SWFDEC_MOVIE (movie), TRUE);
+ } else if (swfdec_player_get_level (player, target) >= 0) {
+ load->target = g_strdup (target);
+ } else {
+ SWFDEC_WARNING ("%s does not reference a movie, not loading %s", target, url);
+ return;
+ }
+ } else {
+ load->target = g_strdup (target);
+ }
+ load->sandbox = SWFDEC_SANDBOX (SWFDEC_AS_CONTEXT (player)->global);
+ load->url = g_strdup (url);
+ load->request = request;
+ load->buffer = buffer;
+ load->loader = loader;
+ load->target_is_movie = target_is_movie;
+
+ swfdec_player_root (player, load, swfdec_resource_load_mark);
+ swfdec_player_request_resource (player, swfdec_resource_load_request, load, swfdec_resource_load_free);
+}
+
+gboolean
+swfdec_resource_emit_on_load_init (SwfdecResource *resource)
+{
+ g_return_val_if_fail (SWFDEC_IS_RESOURCE (resource), FALSE);
+
+ if (resource->state != SWFDEC_RESOURCE_COMPLETE)
+ return FALSE;
+
+ if (resource->movie && SWFDEC_IS_IMAGE_DECODER (resource->decoder)) {
+ SwfdecImage *image = SWFDEC_IMAGE_DECODER (resource->decoder)->image;
+ if (image) {
+ swfdec_movie_invalidate_next (SWFDEC_MOVIE (resource->movie));
+ swfdec_movie_queue_update (SWFDEC_MOVIE (resource->movie), SWFDEC_MOVIE_INVALID_EXTENTS);
+ SWFDEC_MOVIE (resource->movie)->image = g_object_ref (image);
+ }
+ }
+ swfdec_resource_emit_signal (resource, SWFDEC_AS_STR_onLoadInit, FALSE, NULL, 0);
+ resource->state = SWFDEC_RESOURCE_DONE;
+ /* free now unneeded resources */
+ resource->clip_loader = NULL;
+ resource->clip_loader_sandbox = NULL;
+ return TRUE;
+}
diff --git a/swfdec/swfdec_resource.h b/swfdec/swfdec_resource.h
new file mode 100644
index 0000000..fba2f95
--- /dev/null
+++ b/swfdec/swfdec_resource.h
@@ -0,0 +1,98 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_RESOURCE_H_
+#define _SWFDEC_RESOURCE_H_
+
+#include <libswfdec/swfdec_player.h>
+#include <libswfdec/swfdec_sandbox.h>
+#include <libswfdec/swfdec_sprite_movie.h>
+
+G_BEGIN_DECLS
+
+//typedef struct _SwfdecResource SwfdecResource;
+typedef struct _SwfdecResourceClass SwfdecResourceClass;
+
+#define SWFDEC_TYPE_RESOURCE (swfdec_resource_get_type())
+#define SWFDEC_IS_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_RESOURCE))
+#define SWFDEC_IS_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_RESOURCE))
+#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
+{
+ SwfdecAsObject object;
+
+ guint version; /* version of this resource */
+ SwfdecSandbox * sandbox; /* sandbox this resource belongs to (only NULL for a short time on very first loader) */
+ SwfdecSpriteMovie * movie; /* the movie responsible for creating this instance */
+
+ SwfdecLoader * loader; /* the loader providing data for the decoder */
+ SwfdecDecoder * decoder; /* decoder in use or NULL if broken file */
+ char * variables; /* extra variables to be set */
+
+ GHashTable * exports; /* string->SwfdecCharacter mapping of exported characters */
+ 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 */
+ SwfdecSandbox * clip_loader_sandbox; /* sandbox used for events on the clip loader */
+};
+
+struct _SwfdecResourceClass
+{
+ SwfdecAsObjectClass object_class;
+};
+
+GType swfdec_resource_get_type (void);
+
+SwfdecResource *swfdec_resource_new (SwfdecPlayer * player,
+ SwfdecLoader * loader,
+ const char * variables);
+
+gboolean swfdec_resource_emit_on_load_init (SwfdecResource * resource);
+void swfdec_resource_add_export (SwfdecResource * instance,
+ SwfdecCharacter * character,
+ const char * name);
+gpointer swfdec_resource_get_export (SwfdecResource * root,
+ const char * name);
+const char * swfdec_resource_get_export_name (SwfdecResource * root,
+ SwfdecCharacter * character);
+
+void swfdec_resource_load (SwfdecPlayer * player,
+ const char * target,
+ const char * url,
+ SwfdecLoaderRequest request,
+ SwfdecBuffer * buffer,
+ SwfdecMovieClipLoader *loader,
+ gboolean target_is_movie);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_ringbuffer.c b/swfdec/swfdec_ringbuffer.c
new file mode 100644
index 0000000..6d3dd04
--- /dev/null
+++ b/swfdec/swfdec_ringbuffer.c
@@ -0,0 +1,125 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include "swfdec_ringbuffer.h"
+
+SwfdecRingBuffer *
+swfdec_ring_buffer_new (guint element_size, guint size)
+{
+ SwfdecRingBuffer *buffer;
+
+ g_return_val_if_fail (element_size > 0, NULL);
+ g_return_val_if_fail (size > 1, NULL);
+
+ buffer = g_new0 (SwfdecRingBuffer, 1);
+ buffer->element_size = element_size;
+ buffer->size = size;
+ buffer->data = g_malloc (element_size * size);
+
+ return buffer;
+}
+
+void
+swfdec_ring_buffer_free (SwfdecRingBuffer *buffer)
+{
+ g_return_if_fail (buffer != NULL);
+
+ g_free (buffer->data);
+ g_free (buffer);
+}
+
+guint
+swfdec_ring_buffer_get_size (SwfdecRingBuffer *buffer)
+{
+ g_return_val_if_fail (buffer != NULL, 0);
+
+ return buffer->size;
+}
+
+#define GET_ELEMENT(buffer,idx) (buffer->data + buffer->element_size * (idx))
+void
+swfdec_ring_buffer_set_size (SwfdecRingBuffer *buffer, guint new_size)
+{
+ g_return_if_fail (buffer != NULL);
+ g_return_if_fail (buffer->size < new_size);
+
+ buffer->data = g_realloc (buffer->data, buffer->element_size * new_size);
+ if (buffer->tail <= buffer->head && buffer->n_elements) {
+ memmove (GET_ELEMENT (buffer, buffer->head + new_size - buffer->size),
+ GET_ELEMENT (buffer, buffer->head),
+ buffer->element_size * (buffer->size - buffer->head));
+ buffer->head += new_size - buffer->size;
+ }
+ buffer->size = new_size;
+}
+
+guint
+swfdec_ring_buffer_get_n_elements (SwfdecRingBuffer *buffer)
+{
+ g_return_val_if_fail (buffer != NULL, 0);
+
+ return buffer->n_elements;
+}
+
+gpointer
+swfdec_ring_buffer_push (SwfdecRingBuffer *buffer)
+{
+ gpointer ret;
+
+ g_return_val_if_fail (buffer != NULL, NULL);
+
+ if (buffer->n_elements == buffer->size)
+ return NULL;
+
+ ret = GET_ELEMENT (buffer, buffer->tail);
+ buffer->tail = (buffer->tail + 1) % buffer->size;
+ buffer->n_elements++;
+ return ret;
+}
+
+gpointer
+swfdec_ring_buffer_pop (SwfdecRingBuffer *buffer)
+{
+ gpointer ret;
+
+ g_return_val_if_fail (buffer != NULL, NULL);
+
+ if (buffer->n_elements == 0)
+ return NULL;
+
+ ret = GET_ELEMENT (buffer, buffer->head);
+ buffer->head = (buffer->head + 1) % buffer->size;
+ buffer->n_elements--;
+ return ret;
+}
+
+gpointer
+swfdec_ring_buffer_peek_nth (SwfdecRingBuffer *buffer, guint id)
+{
+ g_return_val_if_fail (buffer != NULL, NULL);
+ g_return_val_if_fail (id < buffer->n_elements, NULL);
+
+ id = (buffer->head + id) % buffer->size;
+ return GET_ELEMENT (buffer, id);
+}
diff --git a/swfdec/swfdec_ringbuffer.h b/swfdec/swfdec_ringbuffer.h
new file mode 100644
index 0000000..3f02851
--- /dev/null
+++ b/swfdec/swfdec_ringbuffer.h
@@ -0,0 +1,59 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SWFDEC_RING_BUFFER_H__
+#define __SWFDEC_RING_BUFFER_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _SwfdecRingBuffer SwfdecRingBuffer;
+
+struct _SwfdecRingBuffer
+{
+ unsigned char * data; /* our data */
+ gsize element_size; /* size of one element */
+ guint size; /* number of elements in the buffer */
+
+ guint head; /* index of first element */
+ guint tail; /* index after last element */
+ guint n_elements; /* number of elements in ringbuffer */
+};
+
+SwfdecRingBuffer * swfdec_ring_buffer_new (guint element_size,
+ guint size);
+#define swfdec_ring_buffer_new_for_type(element_type,size) \
+ swfdec_ring_buffer_new (sizeof (element_type), (size))
+void swfdec_ring_buffer_free (SwfdecRingBuffer * buffer);
+
+guint swfdec_ring_buffer_get_size (SwfdecRingBuffer * buffer);
+void swfdec_ring_buffer_set_size (SwfdecRingBuffer * buffer,
+ guint new_size);
+guint swfdec_ring_buffer_get_n_elements (SwfdecRingBuffer * buffer);
+
+gpointer swfdec_ring_buffer_push (SwfdecRingBuffer * buffer);
+gpointer swfdec_ring_buffer_pop (SwfdecRingBuffer * buffer);
+gpointer swfdec_ring_buffer_peek_nth (SwfdecRingBuffer * buffer,
+ guint id);
+
+G_END_DECLS
+
+#endif
diff --git a/swfdec/swfdec_sandbox.c b/swfdec/swfdec_sandbox.c
new file mode 100644
index 0000000..9832f63
--- /dev/null
+++ b/swfdec/swfdec_sandbox.c
@@ -0,0 +1,303 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_sandbox.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+#include "swfdec_initialize.h"
+#include "swfdec_internal.h"
+#include "swfdec_player_internal.h"
+
+/*** GTK-DOC ***/
+
+/**
+ * SECTION:SwfdecSandbox
+ * @title: SwfdecSandbox
+ * @short_description: global object used for security
+ *
+ * The SwfdecSandbox object is a garbage-collected script object that does two
+ * things. The simple thing is its use as the global object while code is
+ * executed in a #SwfdecPlayer. So you can always assume that the global object
+ * is a #SwfdecSandbox. The second task it fulfills is acting as the security
+ * mechanism used by native functions to determine if a given action should be
+ * allowed or not. This is easy, because script functions can always refer to
+ * it as the global object.
+ */
+
+G_DEFINE_TYPE (SwfdecSandbox, swfdec_sandbox, SWFDEC_TYPE_AS_OBJECT)
+
+static void
+swfdec_sandbox_mark (SwfdecAsObject *object)
+{
+ SwfdecSandbox *sandbox = SWFDEC_SANDBOX (object);
+
+ swfdec_as_object_mark (sandbox->Function);
+ swfdec_as_object_mark (sandbox->Function_prototype);
+ swfdec_as_object_mark (sandbox->Object);
+ swfdec_as_object_mark (sandbox->Object_prototype);
+ swfdec_as_object_mark (sandbox->MovieClip);
+ swfdec_as_object_mark (sandbox->Video);
+
+ SWFDEC_AS_OBJECT_CLASS (swfdec_sandbox_parent_class)->mark (object);
+}
+
+static void
+swfdec_sandbox_dispose (GObject *object)
+{
+ SwfdecSandbox *sandbox = SWFDEC_SANDBOX (object);
+
+ swfdec_url_free (sandbox->url);
+
+ G_OBJECT_CLASS (swfdec_sandbox_parent_class)->dispose (object);
+}
+
+static void
+swfdec_sandbox_class_init (SwfdecSandboxClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
+
+ object_class->dispose = swfdec_sandbox_dispose;
+
+ asobject_class->mark = swfdec_sandbox_mark;
+}
+
+static void
+swfdec_sandbox_init (SwfdecSandbox *sandbox)
+{
+ sandbox->type = SWFDEC_SANDBOX_NONE;
+}
+
+static void
+swfdec_sandbox_initialize (SwfdecSandbox *sandbox, guint version)
+{
+ SwfdecAsContext *context = SWFDEC_AS_OBJECT (sandbox)->context;
+ SwfdecPlayer *player = SWFDEC_PLAYER (context);
+
+ swfdec_sandbox_use (sandbox);
+ if (context->state == SWFDEC_AS_CONTEXT_RUNNING)
+ context->state = SWFDEC_AS_CONTEXT_NEW;
+ swfdec_as_context_startup (context);
+ /* reset state for initialization */
+ /* FIXME: have a better way to do this */
+ context->state = SWFDEC_AS_CONTEXT_NEW;
+ swfdec_sprite_movie_init_context (player);
+ swfdec_video_movie_init_context (player);
+ swfdec_net_stream_init_context (player);
+
+ swfdec_as_context_run_init_script (context, swfdec_initialize,
+ sizeof (swfdec_initialize), version);
+
+ sandbox->Function = context->Function;
+ sandbox->Function_prototype = context->Function_prototype;
+ sandbox->Object = context->Object;
+ sandbox->Object_prototype = context->Object_prototype;
+
+ if (context->state == SWFDEC_AS_CONTEXT_NEW)
+ context->state = SWFDEC_AS_CONTEXT_RUNNING;
+ swfdec_sandbox_unuse (sandbox);
+}
+/**
+ * swfdec_sandbox_set_allow_network:
+ * @sandbox: a #SwfdecSandbox
+ * finished, by giving the sandbox network or local file access. This function
+ * should be called on all return values of swfdec_sandbox_get_for_url().
+ *
+ * Returns: %TRUE if the sandbox initialization could be finished as requested,
+ * %FALSE if not and it shouldn't be used.
+ **/
+static gboolean
+swfdec_sandbox_set_allow_network (SwfdecSandbox *sandbox, gboolean network)
+{
+ g_return_val_if_fail (SWFDEC_IS_SANDBOX (sandbox), FALSE);
+
+ switch (sandbox->type) {
+ case SWFDEC_SANDBOX_REMOTE:
+ return TRUE;
+ case SWFDEC_SANDBOX_LOCAL_FILE:
+ return !network;
+ case SWFDEC_SANDBOX_LOCAL_NETWORK:
+ return network;
+ case SWFDEC_SANDBOX_LOCAL_TRUSTED:
+ return TRUE;
+ case SWFDEC_SANDBOX_NONE:
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ if (swfdec_url_is_local (sandbox->url)) {
+ sandbox->type = network ? SWFDEC_SANDBOX_LOCAL_NETWORK : SWFDEC_SANDBOX_LOCAL_FILE;
+ } else {
+ sandbox->type = SWFDEC_SANDBOX_REMOTE;
+ }
+
+ return TRUE;
+}
+
+/**
+ * swfdec_sandbox_get_for_url:
+ * @player: a #SwfdecPlayer
+ * @url: the URL this player refers to
+ * @flash_version: The Flash version for looking up the sandbox
+ * @allow_network: %TRUE to allow network access, %FALSE to only allow local
+ * file access. See the documentation of the use_network flag
+ * of the SWF FileAttributes tag for what that means.
+ *
+ *
+ * Checks if a sandbox is already in use for a given URL and if so, returns it.
+ * Otherwise a new sandbox is created, initialized and returned.
+ * Note that the given url must be a HTTP, HTTPS or a FILE url.
+ *
+ * Returns: the sandbox corresponding to the given URL or %NULL if no such
+ * sandbox is allowed.
+ **/
+SwfdecSandbox *
+swfdec_sandbox_get_for_url (SwfdecPlayer *player, const SwfdecURL *url,
+ guint flash_version, gboolean allow_network)
+{
+ SwfdecPlayerPrivate *priv;
+ SwfdecSandbox *sandbox;
+ SwfdecURL *real;
+ guint as_version;
+ GSList *walk;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (url != NULL, NULL);
+
+ priv = player->priv;
+ real = swfdec_url_new_components (swfdec_url_get_protocol (url),
+ swfdec_url_get_host (url), swfdec_url_get_port (url), NULL, NULL);
+ as_version = flash_version < 7 ? 1 : 2;
+
+ for (walk = priv->sandboxes; walk; walk = walk->next) {
+ sandbox = walk->data;
+ if (sandbox->as_version == as_version &&
+ swfdec_url_equal (sandbox->url, real))
+ break;
+ }
+
+ if (walk) {
+ swfdec_url_free (real);
+
+ if (!swfdec_sandbox_set_allow_network (sandbox, allow_network))
+ return NULL;
+ } else {
+ SwfdecAsContext *context = SWFDEC_AS_CONTEXT (player);
+ guint size = sizeof (SwfdecSandbox);
+ if (!swfdec_as_context_use_mem (context, size))
+ size = 0;
+
+ sandbox = g_object_new (SWFDEC_TYPE_SANDBOX, NULL);
+ swfdec_as_object_add (SWFDEC_AS_OBJECT (sandbox), context, size);
+ sandbox->url = real;
+ sandbox->as_version = as_version;
+ priv->sandboxes = g_slist_append (priv->sandboxes, sandbox);
+
+ if (!swfdec_sandbox_set_allow_network (sandbox, allow_network))
+ return NULL;
+
+ swfdec_sandbox_initialize (sandbox, flash_version);
+ }
+
+
+ return sandbox;
+}
+
+/**
+ * swfdec_sandbox_use:
+ * @sandbox: the sandbox to use when executing scripts
+ *
+ * Sets @sandbox to be used for scripts that are going to be executed next. No
+ * sandbox may be set yet. You must unset the sandbox with
+ * swfdec_sandbox_unuse() after calling your script.
+ **/
+void
+swfdec_sandbox_use (SwfdecSandbox *sandbox)
+{
+ SwfdecAsContext *context;
+ SwfdecPlayerPrivate *priv;
+
+ g_return_if_fail (SWFDEC_IS_SANDBOX (sandbox));
+ g_return_if_fail (sandbox->type != SWFDEC_SANDBOX_NONE);
+ g_return_if_fail (SWFDEC_AS_OBJECT (sandbox)->context->global == NULL);
+
+ context = SWFDEC_AS_OBJECT (sandbox)->context;
+ priv = SWFDEC_PLAYER (context)->priv;
+ context->global = SWFDEC_AS_OBJECT (sandbox);
+
+ context->Function = sandbox->Function;
+ context->Function_prototype = sandbox->Function_prototype;
+ context->Object = sandbox->Object;
+ context->Object_prototype = sandbox->Object_prototype;
+}
+
+/**
+ * swfdec_sandbox_try_use:
+ * @sandbox: the sandbox to use
+ *
+ * Makes sure a sandbox is in use. If no sandbox is in use currently, use the
+ * given @sandbox. This function is intended for cases where code can be called
+ * from both inside scripts with a sandbox already set or outside with no
+ * sandbox in use.
+ *
+ * Returns: %TRUE if the new sandbox will be used. You need to call
+ * swfdec_sandbox_unuse() afterwards. %FALSE if a sandbox is already in
+ * use.
+ **/
+gboolean
+swfdec_sandbox_try_use (SwfdecSandbox *sandbox)
+{
+ g_return_val_if_fail (SWFDEC_IS_SANDBOX (sandbox), FALSE);
+ g_return_val_if_fail (sandbox->type != SWFDEC_SANDBOX_NONE, FALSE);
+
+ if (SWFDEC_AS_OBJECT (sandbox)->context->global)
+ return FALSE;
+
+ swfdec_sandbox_use (sandbox);
+ return TRUE;
+}
+
+/**
+ * swfdec_sandbox_unuse:
+ * @sandbox: a #SwfdecSandbox
+ *
+ * Unsets the sandbox as the current sandbox for executing scripts.
+ **/
+void
+swfdec_sandbox_unuse (SwfdecSandbox *sandbox)
+{
+ SwfdecAsContext *context;
+
+ g_return_if_fail (SWFDEC_IS_SANDBOX (sandbox));
+ g_return_if_fail (SWFDEC_AS_OBJECT (sandbox)->context->global == SWFDEC_AS_OBJECT (sandbox));
+
+ context = SWFDEC_AS_OBJECT (sandbox)->context;
+ context->global = NULL;
+ context->Function = NULL;
+ context->Function_prototype = NULL;
+ context->Object = NULL;
+ context->Object_prototype = NULL;
+}
+
diff --git a/swfdec/swfdec_sandbox.h b/swfdec/swfdec_sandbox.h
new file mode 100644
index 0000000..6fda9b7
--- /dev/null
+++ b/swfdec/swfdec_sandbox.h
@@ -0,0 +1,83 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_SANDBOX_H_
+#define _SWFDEC_SANDBOX_H_
+
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_url.h>
+#include <libswfdec/swfdec_player.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecSandbox SwfdecSandbox;
+typedef struct _SwfdecSandboxClass SwfdecSandboxClass;
+
+typedef enum {
+ SWFDEC_SANDBOX_NONE,
+ SWFDEC_SANDBOX_REMOTE,
+ SWFDEC_SANDBOX_LOCAL_FILE,
+ SWFDEC_SANDBOX_LOCAL_NETWORK,
+ SWFDEC_SANDBOX_LOCAL_TRUSTED
+} SwfdecSandboxType;
+
+#define SWFDEC_TYPE_SANDBOX (swfdec_sandbox_get_type())
+#define SWFDEC_IS_SANDBOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SANDBOX))
+#define SWFDEC_IS_SANDBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SANDBOX))
+#define SWFDEC_SANDBOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SANDBOX, SwfdecSandbox))
+#define SWFDEC_SANDBOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SANDBOX, SwfdecSandboxClass))
+#define SWFDEC_SANDBOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_SANDBOX, SwfdecSandboxClass))
+
+struct _SwfdecSandbox
+{
+ SwfdecAsObject object;
+
+ SwfdecSandboxType type; /* type of this sandbox */
+ SwfdecURL * url; /* URL this sandbox acts for */
+ guint as_version; /* Actionscript version */
+
+ /* global cached objects from context */
+ SwfdecAsObject * Function; /* Function */
+ SwfdecAsObject * Function_prototype; /* Function.prototype */
+ SwfdecAsObject * Object; /* Object */
+ SwfdecAsObject * Object_prototype; /* Object.prototype */
+
+ /* global player objects */
+ SwfdecAsObject * MovieClip; /* MovieClip object */
+ SwfdecAsObject * Video; /* Video object */
+};
+
+struct _SwfdecSandboxClass
+{
+ SwfdecAsObjectClass object_class;
+};
+
+GType swfdec_sandbox_get_type (void);
+
+SwfdecSandbox * swfdec_sandbox_get_for_url (SwfdecPlayer * player,
+ const SwfdecURL * url,
+ guint flash_version,
+ gboolean allow_network);
+
+void swfdec_sandbox_use (SwfdecSandbox * sandbox);
+gboolean swfdec_sandbox_try_use (SwfdecSandbox * sandbox);
+void swfdec_sandbox_unuse (SwfdecSandbox * sandbox);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_script.c b/swfdec/swfdec_script.c
new file mode 100644
index 0000000..ec73386
--- /dev/null
+++ b/swfdec/swfdec_script.c
@@ -0,0 +1,316 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_script.h"
+#include "swfdec_script_internal.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_interpret.h"
+#include "swfdec_debug.h"
+
+/**
+ * SwfdecScript:
+ *
+ * This is the object used for code to be executed by Swfdec. Scripts are
+ * independant from the #SwfdecAsContext they are executed in, so you can
+ * execute the same script in multiple contexts.
+ */
+
+/* Define this to get SWFDEC_WARN'd about missing properties of objects.
+ * This can be useful to find out about unimplemented native properties,
+ * but usually just causes a lot of spam. */
+//#define SWFDEC_WARN_MISSING_PROPERTIES
+
+/*** CONSTANT POOLS ***/
+
+struct _SwfdecConstantPool {
+ SwfdecAsContext * context; /* context we are attached to or NULL */
+ guint n_strings; /* number of strings */
+ char * strings[1]; /* n_strings strings */
+};
+
+SwfdecConstantPool *
+swfdec_constant_pool_new_from_action (const guint8 *data, guint len, guint version)
+{
+ guint i, n;
+ SwfdecBits bits;
+ SwfdecConstantPool *pool;
+
+ swfdec_bits_init_data (&bits, data, len);
+
+ n = swfdec_bits_get_u16 (&bits);
+ if (n == 0)
+ return NULL;
+
+ pool = g_malloc0 (sizeof (SwfdecConstantPool) + (n - 1) * sizeof (char *));
+ pool->n_strings = n;
+ for (i = 0; i < n; i++) {
+ pool->strings[i] = swfdec_bits_get_string (&bits, version);
+ if (pool->strings[i] == NULL) {
+ SWFDEC_ERROR ("not enough strings available");
+ swfdec_constant_pool_free (pool);
+ return NULL;
+ }
+ }
+ if (swfdec_bits_left (&bits)) {
+ SWFDEC_WARNING ("constant pool didn't consume whole buffer (%u bytes leftover)", swfdec_bits_left (&bits) / 8);
+ }
+ return pool;
+}
+
+void
+swfdec_constant_pool_attach_to_context (SwfdecConstantPool *pool, SwfdecAsContext *context)
+{
+ guint i;
+
+ g_return_if_fail (pool != NULL);
+ g_return_if_fail (pool->context == NULL);
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context));
+
+ pool->context = context;
+ for (i = 0; i < pool->n_strings; i++) {
+ pool->strings[i] = (char *) swfdec_as_context_give_string (context, pool->strings[i]);
+ }
+}
+
+guint
+swfdec_constant_pool_size (SwfdecConstantPool *pool)
+{
+ return pool->n_strings;
+}
+
+const char *
+swfdec_constant_pool_get (SwfdecConstantPool *pool, guint i)
+{
+ g_assert (i < pool->n_strings);
+ return pool->strings[i];
+}
+
+void
+swfdec_constant_pool_free (SwfdecConstantPool *pool)
+{
+ if (pool->context == NULL) {
+ guint i;
+ for (i = 0; i < pool->n_strings; i++) {
+ g_free (pool->strings[i]);
+ }
+ }
+ g_free (pool);
+}
+
+/*** SUPPORT FUNCTIONS ***/
+
+char *
+swfdec_script_print_action (guint action, const guint8 *data, guint len)
+{
+ const SwfdecActionSpec *spec = swfdec_as_actions + action;
+
+ if (action & 0x80) {
+ if (spec->print == NULL) {
+ SWFDEC_ERROR ("action %u 0x%02X %s has no print statement",
+ action, action, spec->name ? spec->name : "Unknown");
+ return g_strdup_printf ("erroneous action %s",
+ spec->name ? spec->name : "Unknown");
+ }
+ return spec->print (action, data, len);
+ } else {
+ if (spec->name == NULL) {
+ SWFDEC_ERROR ("action %u is unknown", action);
+ return g_strdup_printf ("unknown Action 0x%02X", action);
+ }
+ return g_strdup (spec->name);
+ }
+}
+
+static gboolean
+swfdec_script_foreach_internal (SwfdecBits *bits, SwfdecScriptForeachFunc func, gpointer user_data)
+{
+ guint action, len;
+ const guint8 *data;
+ gconstpointer bytecode;
+
+ bytecode = bits->ptr;
+ while (swfdec_bits_left (bits) && (action = swfdec_bits_get_u8 (bits))) {
+ if (action & 0x80) {
+ len = swfdec_bits_get_u16 (bits);
+ data = bits->ptr;
+ } else {
+ len = 0;
+ data = NULL;
+ }
+ if (swfdec_bits_skip_bytes (bits, len) != len) {
+ SWFDEC_ERROR ("script too short");
+ return FALSE;
+ }
+ if (!func (bytecode, action, data, len, user_data))
+ return FALSE;
+ bytecode = bits->ptr;
+ }
+ return TRUE;
+}
+
+static gboolean
+validate_action (gconstpointer bytecode, guint action, const guint8 *data, guint len, gpointer scriptp)
+{
+ // TODO: get rid of this function
+ return TRUE;
+}
+
+/*** PUBLIC API ***/
+
+gboolean
+swfdec_script_foreach (SwfdecScript *script, SwfdecScriptForeachFunc func, gpointer user_data)
+{
+ SwfdecBits bits;
+
+ g_return_val_if_fail (script != NULL, FALSE);
+ g_return_val_if_fail (func != NULL, FALSE);
+
+ swfdec_bits_init (&bits, script->buffer);
+ bits.ptr = script->main;
+ return swfdec_script_foreach_internal (&bits, func, user_data);
+}
+
+/**
+ * swfdec_script_new:
+ * @buffer: the #SwfdecBuffer containing the script. This function will take
+ * ownership of the passed in buffer.
+ * @name: name of the script for debugging purposes
+ * @version: Actionscript version to use in this script
+ *
+ * Creates a new script for the actionscript provided in @buffer.
+ *
+ * Returns: a new #SwfdecScript for executing the script i @buffer.
+ **/
+SwfdecScript *
+swfdec_script_new (SwfdecBuffer *buffer, const char *name, guint version)
+{
+ SwfdecBits bits;
+ SwfdecScript *script;
+
+ g_return_val_if_fail (buffer != NULL, NULL);
+
+ swfdec_bits_init (&bits, buffer);
+ script = swfdec_script_new_from_bits (&bits, name, version);
+ swfdec_buffer_unref (buffer);
+ return script;
+}
+
+SwfdecScript *
+swfdec_script_new_from_bits (SwfdecBits *bits, const char *name, guint version)
+{
+ SwfdecScript *script;
+ SwfdecBuffer *buffer;
+ SwfdecBits org;
+ guint len;
+
+ g_return_val_if_fail (bits != NULL, NULL);
+
+ org = *bits;
+ len = swfdec_bits_left (bits) / 8;
+ script = g_new0 (SwfdecScript, 1);
+ script->refcount = 1;
+ script->name = g_strdup (name ? name : "Unnamed script");
+ script->version = version;
+ /* by default, a function has 4 registers */
+ script->n_registers = 5;
+ /* These flags are the default arguments used by scripts read from a file.
+ * DefineFunction and friends override this */
+ script->flags = SWFDEC_SCRIPT_SUPPRESS_ARGS;
+
+ if (!swfdec_script_foreach_internal (bits, validate_action, script)) {
+ swfdec_script_unref (script);
+ return NULL;
+ }
+ len -= swfdec_bits_left (bits) / 8;
+ if (len == 0) {
+ buffer = swfdec_buffer_new ();
+ } else {
+ buffer = swfdec_bits_get_buffer (&org, len);
+ }
+
+ script->main = buffer->data;
+ script->exit = buffer->data + buffer->length;
+ script->buffer = swfdec_buffer_ref (swfdec_buffer_get_super (buffer));
+ swfdec_buffer_unref (buffer);
+ return script;
+}
+
+SwfdecScript *
+swfdec_script_ref (SwfdecScript *script)
+{
+ g_return_val_if_fail (script != NULL, NULL);
+ g_return_val_if_fail (script->refcount > 0, NULL);
+
+ script->refcount++;
+ return script;
+}
+
+void
+swfdec_script_unref (SwfdecScript *script)
+{
+ guint i;
+
+ g_return_if_fail (script != NULL);
+ g_return_if_fail (script->refcount > 0);
+
+ script->refcount--;
+ if (script->refcount > 0)
+ return;
+
+ if (script->buffer)
+ swfdec_buffer_unref (script->buffer);
+ if (script->constant_pool)
+ swfdec_buffer_unref (script->constant_pool);
+ g_free (script->name);
+ for (i = 0; i < script->n_arguments; i++) {
+ g_free (script->arguments[i].name);
+ }
+ g_free (script->arguments);
+ g_free (script);
+}
+
+/*** UTILITY FUNCTIONS ***/
+
+const char *
+swfdec_action_get_name (guint action)
+{
+ g_return_val_if_fail (action < 256, NULL);
+
+ return swfdec_as_actions[action].name;
+}
+
+guint
+swfdec_action_get_from_name (const char *name)
+{
+ guint i;
+
+ g_return_val_if_fail (name != NULL, 0);
+
+ for (i = 0; i < 256; i++) {
+ if (swfdec_as_actions[i].name && g_str_equal (name, swfdec_as_actions[i].name))
+ return i;
+ }
+ return 0;
+}
+
+
diff --git a/swfdec/swfdec_script.h b/swfdec/swfdec_script.h
new file mode 100644
index 0000000..fe90428
--- /dev/null
+++ b/swfdec/swfdec_script.h
@@ -0,0 +1,38 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_SCRIPT_H_
+#define _SWFDEC_SCRIPT_H_
+
+#include <libswfdec/swfdec_as_types.h>
+#include <libswfdec/swfdec_buffer.h>
+
+G_BEGIN_DECLS
+
+
+SwfdecScript * swfdec_script_new (SwfdecBuffer * buffer,
+ const char * name,
+ guint version);
+SwfdecScript * swfdec_script_ref (SwfdecScript * script);
+void swfdec_script_unref (SwfdecScript * script);
+
+
+G_END_DECLS
+
+#endif
diff --git a/swfdec/swfdec_script_internal.h b/swfdec/swfdec_script_internal.h
new file mode 100644
index 0000000..23acb0d
--- /dev/null
+++ b/swfdec/swfdec_script_internal.h
@@ -0,0 +1,95 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_SCRIPT_INTERNAL_H_
+#define _SWFDEC_SCRIPT_INTERNAL_H_
+
+#include <libswfdec/swfdec.h>
+#include <libswfdec/swfdec_as_types.h>
+#include <libswfdec/swfdec_types.h>
+#include <libswfdec/swfdec_bits.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecScriptArgument SwfdecScriptArgument;
+typedef struct _SwfdecConstantPool SwfdecConstantPool;
+
+typedef enum {
+ SWFDEC_SCRIPT_PRELOAD_THIS = (1 << 0),
+ SWFDEC_SCRIPT_SUPPRESS_THIS = (1 << 1),
+ SWFDEC_SCRIPT_PRELOAD_ARGS = (1 << 2),
+ SWFDEC_SCRIPT_SUPPRESS_ARGS = (1 << 3),
+ SWFDEC_SCRIPT_PRELOAD_SUPER = (1 << 4),
+ SWFDEC_SCRIPT_SUPPRESS_SUPER = (1 << 5),
+ SWFDEC_SCRIPT_PRELOAD_ROOT = (1 << 6),
+ SWFDEC_SCRIPT_PRELOAD_PARENT = (1 << 7),
+ SWFDEC_SCRIPT_PRELOAD_GLOBAL = (1 << 8)
+} SwfdecScriptFlag;
+
+typedef gboolean (* SwfdecScriptForeachFunc) (gconstpointer bytecode, guint action,
+ const guint8 *data, guint len, gpointer user_data);
+
+/* FIXME: May want to typedef to SwfdecBuffer directly */
+struct _SwfdecScript {
+ SwfdecBuffer * buffer; /* buffer holding the script */
+ const guint8 * main; /* entry point for script */
+ const guint8 * exit; /* exit point for script */
+ guint refcount; /* reference count */
+ char * name; /* name identifying this script */
+ guint version; /* version of the script */
+ guint n_registers; /* number of registers */
+ SwfdecBuffer * constant_pool; /* constant pool action */
+ guint flags; /* SwfdecScriptFlags */
+ guint n_arguments; /* number of arguments */
+ SwfdecScriptArgument *arguments; /* arguments or NULL if none */
+};
+
+struct _SwfdecScriptArgument {
+ char * name; /* name of the argument (not GC'ed) */
+ guint preload; /* preload slot to preload to or 0 */
+};
+
+const char * swfdec_action_get_name (guint action);
+guint swfdec_action_get_from_name (const char * name);
+
+SwfdecConstantPool *
+ swfdec_constant_pool_new_from_action (const guint8 * data,
+ guint len,
+ guint version);
+void swfdec_constant_pool_free (SwfdecConstantPool * pool);
+guint swfdec_constant_pool_size (SwfdecConstantPool * pool);
+const char * swfdec_constant_pool_get (SwfdecConstantPool * pool,
+ guint i);
+void swfdec_constant_pool_attach_to_context (SwfdecConstantPool * pool,
+ SwfdecAsContext * context);
+
+SwfdecScript * swfdec_script_new_from_bits (SwfdecBits * bits,
+ const char * name,
+ guint version);
+
+gboolean swfdec_script_foreach (SwfdecScript * script,
+ SwfdecScriptForeachFunc func,
+ gpointer user_data);
+char * swfdec_script_print_action (guint action,
+ const guint8 * data,
+ guint len);
+
+G_END_DECLS
+
+#endif
diff --git a/swfdec/swfdec_selection.c b/swfdec/swfdec_selection.c
new file mode 100644
index 0000000..e23e494
--- /dev/null
+++ b/swfdec/swfdec_selection.c
@@ -0,0 +1,75 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_as_context.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (600, 0, swfdec_selection_getBeginIndex)
+void
+swfdec_selection_getBeginIndex (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Selection.getBeginIndex (static)");
+}
+
+SWFDEC_AS_NATIVE (600, 1, swfdec_selection_getEndIndex)
+void
+swfdec_selection_getEndIndex (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Selection.getEndIndex (static)");
+}
+
+SWFDEC_AS_NATIVE (600, 2, swfdec_selection_getCaretIndex)
+void
+swfdec_selection_getCaretIndex (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Selection.getCaretIndex (static)");
+}
+
+SWFDEC_AS_NATIVE (600, 3, swfdec_selection_getFocus)
+void
+swfdec_selection_getFocus (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Selection.getFocus (static)");
+}
+
+SWFDEC_AS_NATIVE (600, 4, swfdec_selection_setFocus)
+void
+swfdec_selection_setFocus (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Selection.setFocus (static)");
+}
+
+SWFDEC_AS_NATIVE (600, 5, swfdec_selection_setSelection)
+void
+swfdec_selection_setSelection (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Selection.setSelection (static)");
+}
diff --git a/swfdec/swfdec_shape.c b/swfdec/swfdec_shape.c
new file mode 100644
index 0000000..ca86d8f
--- /dev/null
+++ b/swfdec/swfdec_shape.c
@@ -0,0 +1,387 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+#include <string.h>
+
+#include "swfdec_shape.h"
+#include "swfdec.h"
+#include "swfdec_debug.h"
+#include "swfdec_path.h"
+#include "swfdec_shape_parser.h"
+#include "swfdec_stroke.h"
+
+G_DEFINE_TYPE (SwfdecShape, swfdec_shape, SWFDEC_TYPE_GRAPHIC)
+
+static void
+swfdec_shape_dispose (GObject *object)
+{
+ SwfdecShape * shape = SWFDEC_SHAPE (object);
+
+ g_slist_foreach (shape->draws, (GFunc) g_object_unref, NULL);
+ g_slist_free (shape->draws);
+ shape->draws = NULL;
+
+ G_OBJECT_CLASS (swfdec_shape_parent_class)->dispose (G_OBJECT (shape));
+}
+
+static void
+swfdec_shape_render (SwfdecGraphic *graphic, cairo_t *cr,
+ const SwfdecColorTransform *trans, const SwfdecRect *inval)
+{
+ SwfdecShape *shape = SWFDEC_SHAPE (graphic);
+ GSList *walk;
+
+ for (walk = shape->draws; walk; walk = walk->next) {
+ SwfdecDraw *draw = walk->data;
+
+ if (!swfdec_rect_intersect (NULL, &draw->extents, inval))
+ continue;
+
+ swfdec_draw_paint (draw, cr, trans);
+ }
+}
+
+static gboolean
+swfdec_shape_mouse_in (SwfdecGraphic *graphic, double x, double y)
+{
+ SwfdecShape *shape = SWFDEC_SHAPE (graphic);
+ GSList *walk;
+
+ for (walk = shape->draws; walk; walk = walk->next) {
+ SwfdecDraw *draw = walk->data;
+
+ if (swfdec_draw_contains (draw, x, y))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static void
+swfdec_shape_class_init (SwfdecShapeClass * g_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+ SwfdecGraphicClass *graphic_class = SWFDEC_GRAPHIC_CLASS (g_class);
+
+ object_class->dispose = swfdec_shape_dispose;
+
+ graphic_class->render = swfdec_shape_render;
+ graphic_class->mouse_in = swfdec_shape_mouse_in;
+}
+
+static void
+swfdec_shape_init (SwfdecShape * shape)
+{
+}
+
+int
+tag_define_shape (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecBits *bits = &s->b;
+ SwfdecShape *shape;
+ SwfdecShapeParser *parser;
+ int id;
+
+ id = swfdec_bits_get_u16 (bits);
+
+ shape = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_SHAPE);
+ if (!shape)
+ return SWFDEC_STATUS_OK;
+
+ SWFDEC_INFO ("id=%d", id);
+
+ swfdec_bits_get_rect (bits, &SWFDEC_GRAPHIC (shape)->extents);
+
+ parser = swfdec_shape_parser_new ((SwfdecParseDrawFunc) swfdec_pattern_parse,
+ (SwfdecParseDrawFunc) swfdec_stroke_parse, s);
+ swfdec_shape_parser_parse (parser, bits);
+ shape->draws = swfdec_shape_parser_free (parser);
+
+ return SWFDEC_STATUS_OK;
+}
+
+int
+tag_define_shape_3 (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecBits *bits = &s->b;
+ SwfdecShape *shape;
+ SwfdecShapeParser *parser;
+ int id;
+
+ id = swfdec_bits_get_u16 (bits);
+ shape = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_SHAPE);
+ if (!shape)
+ return SWFDEC_STATUS_OK;
+
+ swfdec_bits_get_rect (bits, &SWFDEC_GRAPHIC (shape)->extents);
+
+ parser = swfdec_shape_parser_new ((SwfdecParseDrawFunc) swfdec_pattern_parse_rgba,
+ (SwfdecParseDrawFunc) swfdec_stroke_parse_rgba, s);
+ swfdec_shape_parser_parse (parser, bits);
+ shape->draws = swfdec_shape_parser_free (parser);
+
+ return SWFDEC_STATUS_OK;
+}
+
+int
+tag_define_shape_4 (SwfdecSwfDecoder *s, guint tag)
+{
+ SwfdecBits *bits = &s->b;
+ SwfdecShape *shape;
+ SwfdecShapeParser *parser;
+ int id;
+ SwfdecRect tmp;
+ gboolean has_scale_strokes, has_noscale_strokes;
+
+ id = swfdec_bits_get_u16 (bits);
+ shape = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_SHAPE);
+ if (!shape)
+ return SWFDEC_STATUS_OK;
+
+ swfdec_bits_get_rect (bits, &SWFDEC_GRAPHIC (shape)->extents);
+ SWFDEC_LOG (" extents: %g %g x %g %g",
+ SWFDEC_GRAPHIC (shape)->extents.x0, SWFDEC_GRAPHIC (shape)->extents.y0,
+ SWFDEC_GRAPHIC (shape)->extents.x1, SWFDEC_GRAPHIC (shape)->extents.y1);
+ swfdec_bits_get_rect (bits, &tmp);
+ SWFDEC_LOG (" extents: %g %g x %g %g",
+ tmp.x0, tmp.y0, tmp.x1, tmp.y1);
+ swfdec_bits_getbits (bits, 6);
+ has_scale_strokes = swfdec_bits_getbit (bits);
+ has_noscale_strokes = swfdec_bits_getbit (bits);
+ SWFDEC_LOG (" has scaling strokes: %d", has_scale_strokes);
+ SWFDEC_LOG (" has non-scaling strokes: %d", has_noscale_strokes);
+
+ parser = swfdec_shape_parser_new ((SwfdecParseDrawFunc) swfdec_pattern_parse_rgba,
+ (SwfdecParseDrawFunc) swfdec_stroke_parse_extended, s);
+ swfdec_shape_parser_parse (parser, bits);
+ shape->draws = swfdec_shape_parser_free (parser);
+
+ return SWFDEC_STATUS_OK;
+}
+
+#if 0
+/*** MORPH SHAPE ***/
+
+#include "swfdec_morphshape.h"
+
+static SubPath *
+swfdec_morph_shape_do_change (SwfdecBits *end_bits, SubPath *other, SwfdecMorphShape *morph,
+ GArray *path_array, SubPath *path, int *x, int *y)
+{
+ if (path) {
+ path->x_end = *x;
+ path->y_end = *y;
+ }
+ g_array_set_size (path_array, path_array->len + 1);
+ path = &g_array_index (path_array, SubPath, path_array->len - 1);
+ *path = *other;
+ swfdec_path_init (&path->path);
+ if (swfdec_shape_peek_type (end_bits) == SWFDEC_SHAPE_TYPE_CHANGE) {
+ int state_line_styles, state_fill_styles1, state_fill_styles0, state_moveto;
+
+ if (swfdec_bits_getbit (end_bits) != 0) {
+ g_assert_not_reached ();
+ }
+ if (swfdec_bits_getbit (end_bits)) {
+ SWFDEC_ERROR ("new styles aren't allowed in end edges, ignoring");
+ }
+ state_line_styles = swfdec_bits_getbit (end_bits);
+ state_fill_styles1 = swfdec_bits_getbit (end_bits);
+ state_fill_styles0 = swfdec_bits_getbit (end_bits);
+ state_moveto = swfdec_bits_getbit (end_bits);
+ if (state_moveto) {
+ int n_bits = swfdec_bits_getbits (end_bits, 5);
+ *x = swfdec_bits_getsbits (end_bits, n_bits);
+ *y = swfdec_bits_getsbits (end_bits, n_bits);
+
+ SWFDEC_LOG (" moveto %d,%d", *x, *y);
+ }
+ if (state_fill_styles0) {
+ guint check = swfdec_bits_getbits (end_bits, morph->n_fill_bits) +
+ SWFDEC_SHAPE (morph)->fills_offset;
+ if (check != path->fill0style)
+ SWFDEC_ERROR ("end fill0style %u differs from start fill0style %u", check, path->fill0style);
+ }
+ if (state_fill_styles1) {
+ guint check = swfdec_bits_getbits (end_bits, morph->n_fill_bits) +
+ SWFDEC_SHAPE (morph)->fills_offset;
+ if (check != path->fill1style)
+ SWFDEC_ERROR ("end fill1style %u differs from start fill1style %u", check, path->fill1style);
+ }
+ if (state_line_styles) {
+ guint check = swfdec_bits_getbits (end_bits, morph->n_line_bits) +
+ SWFDEC_SHAPE (morph)->lines_offset;
+ if (check != path->linestyle)
+ SWFDEC_ERROR ("end linestyle %u differs from start linestyle %u", check, path->linestyle);
+ }
+ }
+ path->x_start = *x;
+ path->y_start = *y;
+ return path;
+}
+
+static void
+swfdec_morph_shape_get_recs (SwfdecSwfDecoder * s, SwfdecMorphShape *morph, SwfdecBits *end_bits)
+{
+ int start_x = 0, start_y = 0, end_x = 0, end_y = 0;
+ SubPath *start_path = NULL, *end_path = NULL;
+ GArray *start_path_array, *end_path_array, *tmp;
+ SwfdecShapeType start_type, end_type;
+ SwfdecBits *start_bits = &s->b;
+ SwfdecShape *shape = SWFDEC_SHAPE (morph);
+
+ /* First, accumulate all sub-paths into an array */
+ start_path_array = g_array_new (FALSE, TRUE, sizeof (SubPath));
+ end_path_array = g_array_new (FALSE, TRUE, sizeof (SubPath));
+
+ while ((start_type = swfdec_shape_peek_type (start_bits))) {
+ end_type = swfdec_shape_peek_type (end_bits);
+ if (end_type == SWFDEC_SHAPE_TYPE_CHANGE && start_type != SWFDEC_SHAPE_TYPE_CHANGE) {
+ SubPath *path;
+ if (start_path) {
+ start_path->x_end = start_x;
+ start_path->y_end = start_y;
+ }
+ g_array_set_size (start_path_array, start_path_array->len + 1);
+ path = &g_array_index (start_path_array, SubPath, start_path_array->len - 1);
+ if (start_path)
+ *path = *start_path;
+ start_path = path;
+ swfdec_path_init (&start_path->path);
+ start_path->x_start = start_x;
+ start_path->y_start = start_y;
+ end_path = swfdec_morph_shape_do_change (end_bits, start_path, morph, end_path_array, end_path, &end_x, &end_y);
+ continue;
+ }
+ switch (start_type) {
+ case SWFDEC_SHAPE_TYPE_CHANGE:
+ start_path = swfdec_shape_parse_change (s, shape, start_path_array, start_path, &start_x, &start_y,
+ swfdec_pattern_parse_morph, swfdec_stroke_parse_morph);
+ end_path = swfdec_morph_shape_do_change (end_bits, start_path, morph, end_path_array, end_path, &end_x, &end_y);
+ break;
+ case SWFDEC_SHAPE_TYPE_LINE:
+ if (end_type == SWFDEC_SHAPE_TYPE_LINE) {
+ swfdec_shape_parse_line (start_bits, start_path, &start_x, &start_y, FALSE);
+ swfdec_shape_parse_line (end_bits, end_path, &end_x, &end_y, FALSE);
+ } else if (end_type == SWFDEC_SHAPE_TYPE_CURVE) {
+ swfdec_shape_parse_line (start_bits, start_path, &start_x, &start_y, TRUE);
+ swfdec_shape_parse_curve (end_bits, end_path, &end_x, &end_y);
+ } else {
+ SWFDEC_ERROR ("edge type didn't match, wanted line or curve, but got %s",
+ end_type ? "change" : "end");
+ goto error;
+ }
+ break;
+ case SWFDEC_SHAPE_TYPE_CURVE:
+ swfdec_shape_parse_curve (start_bits, start_path, &start_x, &start_y);
+ if (end_type == SWFDEC_SHAPE_TYPE_LINE) {
+ swfdec_shape_parse_line (end_bits, end_path, &end_x, &end_y, TRUE);
+ } else if (end_type == SWFDEC_SHAPE_TYPE_CURVE) {
+ swfdec_shape_parse_curve (end_bits, end_path, &end_x, &end_y);
+ } else {
+ SWFDEC_ERROR ("edge type didn't match, wanted line or curve, but got %s",
+ end_type ? "change" : "end");
+ goto error;
+ }
+ break;
+ case SWFDEC_SHAPE_TYPE_END:
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+ }
+ if (start_path) {
+ start_path->x_end = start_x;
+ start_path->y_end = start_y;
+ }
+ if (end_path) {
+ end_path->x_end = end_x;
+ end_path->y_end = end_y;
+ }
+ swfdec_bits_getbits (start_bits, 6);
+ swfdec_bits_syncbits (start_bits);
+ if (swfdec_bits_getbits (end_bits, 6) != 0) {
+ SWFDEC_ERROR ("end shapes are not finished when start shapes are");
+ }
+ swfdec_bits_syncbits (end_bits);
+
+error:
+ /* FIXME: there's probably a problem if start and end paths get accumulated in
+ * different ways, this could lead to the morphs not looking like they should.
+ * Need a good testcase for this first though.
+ * FIXME: Also, due to error handling, there needs to be syncing of code paths
+ */
+ tmp = shape->vecs;
+ shape->vecs = morph->end_vecs;
+ swfdec_shape_initialize_from_sub_paths (shape, end_path_array);
+ morph->end_vecs = shape->vecs;
+ shape->vecs = tmp;
+ swfdec_shape_initialize_from_sub_paths (shape, start_path_array);
+ g_assert (morph->end_vecs->len == shape->vecs->len);
+}
+#endif
+
+#if 0
+ SwfdecBits end_bits;
+ SwfdecBits *bits = &s->b;
+ SwfdecMorphShape *morph;
+ guint offset;
+ int id;
+ id = swfdec_bits_get_u16 (bits);
+
+ morph = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_MORPH_SHAPE);
+ if (!morph)
+ return SWFDEC_STATUS_OK;
+
+ SWFDEC_INFO ("id=%d", id);
+
+ swfdec_bits_get_rect (bits, &SWFDEC_GRAPHIC (morph)->extents);
+ swfdec_bits_get_rect (bits, &morph->end_extents);
+ offset = swfdec_bits_get_u32 (bits);
+ end_bits = *bits;
+ if (swfdec_bits_skip_bytes (&end_bits, offset) != offset) {
+ SWFDEC_ERROR ("wrong offset in DefineMorphShape");
+ return SWFDEC_STATUS_OK;
+ }
+ bits->end = end_bits.ptr;
+
+ swfdec_shape_add_styles (s, SWFDEC_SHAPE (morph),
+ swfdec_pattern_parse_morph, swfdec_stroke_parse_morph);
+
+ morph->n_fill_bits = swfdec_bits_getbits (&end_bits, 4);
+ morph->n_line_bits = swfdec_bits_getbits (&end_bits, 4);
+ SWFDEC_LOG ("%u fill bits, %u line bits in end shape", morph->n_fill_bits, morph->n_line_bits);
+
+ swfdec_morph_shape_get_recs (s, morph, &end_bits);
+ if (swfdec_bits_left (&s->b)) {
+ SWFDEC_WARNING ("early finish when parsing start shapes: %u bytes",
+ swfdec_bits_left (&s->b));
+ }
+
+ s->b = end_bits;
+
+ return SWFDEC_STATUS_OK;
+}
+#endif
diff --git a/swfdec/swfdec_shape.h b/swfdec/swfdec_shape.h
new file mode 100644
index 0000000..312dc9f
--- /dev/null
+++ b/swfdec/swfdec_shape.h
@@ -0,0 +1,63 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_SHAPE_H_
+#define _SWFDEC_SHAPE_H_
+
+#include <libswfdec/swfdec_types.h>
+#include <libswfdec/swfdec_color.h>
+#include <libswfdec/swfdec_bits.h>
+#include <libswfdec/swfdec_graphic.h>
+#include <libswfdec/swfdec_pattern.h>
+#include <libswfdec/swfdec_stroke.h>
+#include <libswfdec/swfdec_swf_decoder.h>
+
+G_BEGIN_DECLS
+
+//typedef struct _SwfdecShape SwfdecShape;
+typedef struct _SwfdecShapeClass SwfdecShapeClass;
+
+#define SWFDEC_TYPE_SHAPE (swfdec_shape_get_type())
+#define SWFDEC_IS_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SHAPE))
+#define SWFDEC_IS_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SHAPE))
+#define SWFDEC_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SHAPE, SwfdecShape))
+#define SWFDEC_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SHAPE, SwfdecShapeClass))
+
+struct _SwfdecShape {
+ SwfdecGraphic graphic;
+
+ GSList * draws; /* drawing operations - first drawn first */
+};
+
+struct _SwfdecShapeClass
+{
+ SwfdecGraphicClass graphic_class;
+};
+
+GType swfdec_shape_get_type (void);
+
+int tag_define_shape (SwfdecSwfDecoder * s, guint tag);
+int tag_define_shape_3 (SwfdecSwfDecoder * s, guint tag);
+int tag_define_shape_4 (SwfdecSwfDecoder * s, guint tag);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_shape_parser.c b/swfdec/swfdec_shape_parser.c
new file mode 100644
index 0000000..d521a9c
--- /dev/null
+++ b/swfdec/swfdec_shape_parser.c
@@ -0,0 +1,675 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_shape_parser.h"
+#include "swfdec_debug.h"
+#include "swfdec_path.h"
+#include "swfdec_stroke.h"
+
+/*** PATH CONSTRUCTION ***/
+
+typedef enum {
+ SWFDEC_SHAPE_TYPE_END = 0,
+ SWFDEC_SHAPE_TYPE_CHANGE,
+ SWFDEC_SHAPE_TYPE_LINE,
+ SWFDEC_SHAPE_TYPE_CURVE
+} SwfdecShapeType;
+
+static SwfdecShapeType
+swfdec_shape_peek_type (SwfdecBits *bits)
+{
+ guint ret = swfdec_bits_peekbits (bits, 6);
+
+ if (ret == 0)
+ return SWFDEC_SHAPE_TYPE_END;
+ if ((ret & 0x20) == 0)
+ return SWFDEC_SHAPE_TYPE_CHANGE;
+ if ((ret & 0x10) == 0)
+ return SWFDEC_SHAPE_TYPE_CURVE;
+ return SWFDEC_SHAPE_TYPE_LINE;
+}
+
+typedef struct {
+ int x_start, y_start;
+ int x_end, y_end;
+ cairo_path_t path;
+} SwfdecSubPath;
+
+static gboolean
+swfdec_sub_path_match (SwfdecSubPath *from, SwfdecSubPath *to)
+{
+ return from->x_end == to->x_start && from->y_end == to->y_start;
+}
+
+typedef struct {
+ SwfdecDraw * draw; /* drawing operation that should take the subpaths or NULL on parsing error */
+ GSList * subpaths; /* indexes into SubPath array */
+} SwfdecStyle;
+
+struct _SwfdecShapeParser {
+ /* state */
+ GSList * draws; /* completely accumulated drawing commands */
+ SwfdecParseDrawFunc parse_fill; /* function to call to parse a fill style */
+ SwfdecParseDrawFunc parse_line; /* function to call to parse a line style */
+ gpointer data; /* data to pass to parse functions */
+ /* used while parsing */
+ GArray * fillstyles; /* SwfdecStyle objects */
+ GArray * linestyles; /* SwfdecStyle objects */
+ GArray * subpaths; /* SwfdecSubPath partial paths */
+ guint fill0style;
+ guint fill1style;
+ guint linestyle;
+ guint n_fill_bits;
+ guint n_line_bits;
+ /* for morph styles */
+ GArray * subpaths2; /* SwfdecSubPath partial paths */
+ guint fill0style2;
+ guint fill1style2;
+ guint linestyle2;
+ guint n_fill_bits2;
+ guint n_line_bits2;
+};
+
+static void
+swfdec_shape_parser_new_styles (SwfdecShapeParser *parser, SwfdecBits *bits)
+{
+ guint i, n_fill_styles, n_line_styles;
+
+ swfdec_bits_syncbits (bits);
+ if (parser->parse_fill) {
+ n_fill_styles = swfdec_bits_get_u8 (bits);
+ if (n_fill_styles == 0xff) {
+ n_fill_styles = swfdec_bits_get_u16 (bits);
+ }
+ SWFDEC_LOG (" n_fill_styles %d", n_fill_styles);
+ g_array_set_size (parser->fillstyles, n_fill_styles);
+ for (i = 0; i < n_fill_styles && swfdec_bits_left (bits); i++) {
+ g_array_index (parser->fillstyles, SwfdecStyle, i).draw =
+ parser->parse_fill (bits, parser->data);
+ }
+
+ n_line_styles = swfdec_bits_get_u8 (bits);
+ if (n_line_styles == 0xff) {
+ n_line_styles = swfdec_bits_get_u16 (bits);
+ }
+ SWFDEC_LOG (" n_line_styles %d", n_line_styles);
+ g_array_set_size (parser->linestyles, n_line_styles);
+ for (i = 0; i < n_line_styles && swfdec_bits_left (bits); i++) {
+ g_array_index (parser->linestyles, SwfdecStyle, i).draw =
+ parser->parse_line (bits, parser->data);
+ }
+ } else {
+ /* This is the magic part for DefineFont */
+ g_array_set_size (parser->fillstyles, 1);
+ g_array_index (parser->fillstyles, SwfdecStyle, 0).draw =
+ SWFDEC_DRAW (swfdec_pattern_new_color (0xFFFFFFFF));
+ }
+ parser->n_fill_bits = swfdec_bits_getbits (bits, 4);
+ parser->n_line_bits = swfdec_bits_getbits (bits, 4);
+}
+
+
+SwfdecShapeParser *
+swfdec_shape_parser_new (SwfdecParseDrawFunc parse_fill,
+ SwfdecParseDrawFunc parse_line, gpointer data)
+{
+ SwfdecShapeParser *list;
+
+ list = g_slice_new0 (SwfdecShapeParser);
+ list->parse_fill = parse_fill;
+ list->parse_line = parse_line;
+ list->data = data;
+ list->fillstyles = g_array_new (FALSE, TRUE, sizeof (SwfdecStyle));
+ list->linestyles = g_array_new (FALSE, TRUE, sizeof (SwfdecStyle));
+ list->subpaths = g_array_new (FALSE, TRUE, sizeof (SwfdecSubPath));
+ list->subpaths2 = g_array_new (FALSE, TRUE, sizeof (SwfdecSubPath));
+
+ return list;
+}
+
+static inline void
+swfdec_shape_parser_clear_one (GArray *array)
+{
+ guint i;
+
+ for (i = 0; i < array->len; i++) {
+ SwfdecStyle *style = &g_array_index (array, SwfdecStyle, i);
+ if (style->draw)
+ g_object_unref (style->draw);
+ g_slist_free (style->subpaths);
+ }
+ g_array_set_size (array, 0);
+}
+
+static void
+swfdec_shape_parser_clear (SwfdecShapeParser *list)
+{
+ guint i;
+
+ swfdec_shape_parser_clear_one (list->fillstyles);
+ swfdec_shape_parser_clear_one (list->linestyles);
+
+ for (i = 0; i < list->subpaths->len; i++) {
+ SwfdecSubPath *path = &g_array_index (list->subpaths, SwfdecSubPath, i);
+ swfdec_path_reset (&path->path);
+ }
+ g_array_set_size (list->subpaths, 0);
+ for (i = 0; i < list->subpaths2->len; i++) {
+ SwfdecSubPath *path = &g_array_index (list->subpaths2, SwfdecSubPath, i);
+ swfdec_path_reset (&path->path);
+ }
+ g_array_set_size (list->subpaths2, 0);
+}
+
+GSList *
+swfdec_shape_parser_reset (SwfdecShapeParser *parser)
+{
+ GSList *draws = parser->draws;
+
+ parser->draws = NULL;
+ return draws;
+}
+
+GSList *
+swfdec_shape_parser_free (SwfdecShapeParser *parser)
+{
+ GSList *draws = parser->draws;
+
+ swfdec_shape_parser_clear (parser);
+ g_array_free (parser->fillstyles, TRUE);
+ g_array_free (parser->linestyles, TRUE);
+ g_array_free (parser->subpaths, TRUE);
+ g_array_free (parser->subpaths2, TRUE);
+ g_slice_free (SwfdecShapeParser, parser);
+
+ draws = g_slist_reverse (draws);
+ return draws;
+}
+
+/* NB: assumes all fill paths are closed */
+static void
+swfdec_style_finish (SwfdecStyle *style, SwfdecSubPath *paths, SwfdecSubPath *paths2, gboolean line)
+{
+ GSList *walk;
+
+ /* checked before calling this function */
+ g_assert (style->draw);
+
+ /* accumulate paths one by one */
+ while (style->subpaths) {
+ SwfdecSubPath *start, *last;
+ SwfdecSubPath *start2 = NULL, *last2 = NULL;
+
+ last = start = &paths[GPOINTER_TO_UINT (style->subpaths->data)];
+ swfdec_path_move_to (&style->draw->path, start->x_start, start->y_start);
+ swfdec_path_append (&style->draw->path, &start->path);
+ if (paths2) {
+ last2 = start2 = &paths2[GPOINTER_TO_UINT (style->subpaths->data)];
+ swfdec_path_move_to (&style->draw->end_path, start2->x_start, start2->y_start);
+ swfdec_path_append (&style->draw->end_path, &start2->path);
+ }
+ style->subpaths = g_slist_delete_link (style->subpaths, style->subpaths);
+ while (!swfdec_sub_path_match (last, start) ||
+ (paths2 != NULL && !swfdec_sub_path_match (last2, start2))) {
+ for (walk = style->subpaths; walk; walk = walk->next) {
+ SwfdecSubPath *cur = &paths[GPOINTER_TO_UINT (walk->data)];
+ if (swfdec_sub_path_match (last, cur)) {
+ if (paths2) {
+ SwfdecSubPath *cur2 = &paths2[GPOINTER_TO_UINT (walk->data)];
+ if (!swfdec_sub_path_match (last2, cur2))
+ continue;
+ swfdec_path_append (&style->draw->end_path, &cur2->path);
+ last2 = cur2;
+ }
+ swfdec_path_append (&style->draw->path, &cur->path);
+ last = cur;
+ break;
+ }
+ }
+ if (walk) {
+ style->subpaths = g_slist_delete_link (style->subpaths, walk);
+ } else {
+ if (!line) {
+ SWFDEC_ERROR ("fill path not closed");
+ }
+ break;
+ }
+ }
+ }
+ swfdec_draw_recompute (style->draw);
+}
+
+/* merge subpaths into draws, then reset */
+static void
+swfdec_shape_parser_finish (SwfdecShapeParser *parser)
+{
+ guint i;
+ for (i = 0; i < parser->fillstyles->len; i++) {
+ SwfdecStyle *style = &g_array_index (parser->fillstyles, SwfdecStyle, i);
+ if (style->draw == NULL)
+ continue;
+ if (style->subpaths) {
+ swfdec_style_finish (style, (SwfdecSubPath *) (void *) parser->subpaths->data,
+ parser->subpaths2->len ? (SwfdecSubPath *) (void *) parser->subpaths2->data : NULL, FALSE);
+ parser->draws = g_slist_prepend (parser->draws, g_object_ref (style->draw));
+ } else {
+ SWFDEC_INFO ("fillstyle %u has no path", i);
+ }
+ }
+ for (i = 0; i < parser->linestyles->len; i++) {
+ SwfdecStyle *style = &g_array_index (parser->linestyles, SwfdecStyle, i);
+ if (style->draw == NULL)
+ continue;
+ if (style->subpaths) {
+ swfdec_style_finish (style, (SwfdecSubPath *) (void *) parser->subpaths->data,
+ parser->subpaths2->len ? (SwfdecSubPath *) (void *) parser->subpaths2->data : NULL, TRUE);
+ parser->draws = g_slist_prepend (parser->draws, g_object_ref (style->draw));
+ } else {
+ SWFDEC_WARNING ("linestyle %u has no path", i);
+ }
+ }
+ swfdec_shape_parser_clear (parser);
+}
+
+static void
+swfdec_shape_parser_end_path (SwfdecShapeParser *parser, SwfdecSubPath *path1, SwfdecSubPath *path2,
+ int x1, int y1, int x2, int y2)
+{
+ if (path1 == NULL)
+ return;
+ if (path1->path.num_data == 0) {
+ SWFDEC_INFO ("ignoring empty path");
+ return;
+ }
+
+ path1->x_end = x1;
+ path1->y_end = y1;
+
+ if (path2) {
+ path2->x_end = x2;
+ path2->y_end = y2;
+ /* check our assumptions about morph styles */
+ if ((parser->fill0style != parser->fill0style2 &&
+ parser->fill0style != parser->fill1style2) ||
+ (parser->fill1style != parser->fill0style2 &&
+ parser->fill1style != parser->fill1style2)) {
+ SWFDEC_ERROR ("fillstyle assumptions don't hold for %u %u vs %u %u",
+ parser->fill0style, parser->fill1style, parser->fill0style2,
+ parser->fill1style2);
+ return;
+ }
+ if (parser->linestyle != parser->linestyle2) {
+ SWFDEC_ERROR ("linestyle change from %u to %u", parser->linestyle,
+ parser->linestyle2);
+ return;
+ }
+ }
+
+ /* add the path to their styles */
+ if (parser->fill0style) {
+ if (parser->fill0style > parser->fillstyles->len) {
+ SWFDEC_ERROR ("fillstyle too big (%u > %u)", parser->fill0style,
+ parser->fillstyles->len);
+ } else {
+ SwfdecStyle *style = &g_array_index (parser->fillstyles,
+ SwfdecStyle, parser->fill0style - 1);
+ style->subpaths = g_slist_prepend (style->subpaths,
+ GUINT_TO_POINTER (parser->subpaths->len - 1));
+ }
+ }
+ if (parser->fill1style) {
+ if (parser->fill1style > parser->fillstyles->len) {
+ SWFDEC_ERROR ("fillstyle too big (%u > %u)", parser->fill1style,
+ parser->fillstyles->len);
+ } else {
+ SwfdecStyle *style = &g_array_index (parser->fillstyles,
+ SwfdecStyle, parser->fill1style - 1);
+
+ if (swfdec_sub_path_match (path1, path1) &&
+ (path2 == NULL || swfdec_sub_path_match (path2, path2))) {
+ style->subpaths = g_slist_prepend (style->subpaths,
+ GUINT_TO_POINTER (parser->subpaths->len - 1));
+ } else {
+ SwfdecSubPath reverse;
+ SWFDEC_LOG ("reversing path from %d %d to %d %d", path1->x_start, path1->y_start,
+ path1->x_end, path1->y_end);
+ reverse.x_start = path1->x_end;
+ reverse.y_start = path1->y_end;
+ reverse.x_end = path1->x_start;
+ reverse.y_end = path1->y_start;
+ swfdec_path_init (&reverse.path);
+ swfdec_path_append_reverse (&reverse.path, &path1->path, reverse.x_end, reverse.y_end);
+ style->subpaths = g_slist_prepend (style->subpaths,
+ GUINT_TO_POINTER (parser->subpaths->len));
+ g_array_append_val (parser->subpaths, reverse);
+ if (path2) {
+ reverse.x_start = path2->x_end;
+ reverse.y_start = path2->y_end;
+ reverse.x_end = path2->x_start;
+ reverse.y_end = path2->y_start;
+ swfdec_path_init (&reverse.path);
+ swfdec_path_append_reverse (&reverse.path, &path2->path, reverse.x_end, reverse.y_end);
+ g_array_append_val (parser->subpaths2, reverse);
+ }
+ }
+ }
+ }
+ if (parser->linestyle) {
+ if (parser->linestyle > parser->linestyles->len) {
+ SWFDEC_ERROR ("linestyle too big (%u > %u)", parser->linestyle,
+ parser->linestyles->len);
+ } else {
+ SwfdecStyle *style = &g_array_index (parser->linestyles,
+ SwfdecStyle, parser->linestyle - 1);
+ style->subpaths = g_slist_prepend (style->subpaths,
+ GUINT_TO_POINTER (parser->subpaths->len - 1));
+ }
+ }
+}
+
+static SwfdecSubPath *
+swfdec_sub_path_create (GArray *array, int x, int y)
+{
+ SwfdecSubPath *path;
+
+ g_array_set_size (array, array->len + 1);
+ path = &g_array_index (array, SwfdecSubPath, array->len - 1);
+ swfdec_path_init (&path->path);
+ path->x_start = x;
+ path->y_start = y;
+
+ return path;
+}
+
+static SwfdecSubPath *
+swfdec_shape_parser_parse_change (SwfdecShapeParser *parser, SwfdecBits *bits, int *x, int *y)
+{
+ int state_new_styles, state_line_styles, state_fill_styles1, state_fill_styles0, state_moveto;
+ SwfdecSubPath *path;
+
+ if (swfdec_bits_getbit (bits) != 0) {
+ g_assert_not_reached ();
+ }
+
+ state_new_styles = swfdec_bits_getbit (bits);
+ state_line_styles = swfdec_bits_getbit (bits);
+ state_fill_styles1 = swfdec_bits_getbit (bits);
+ state_fill_styles0 = swfdec_bits_getbit (bits);
+ state_moveto = swfdec_bits_getbit (bits);
+
+ if (state_moveto) {
+ int n_bits = swfdec_bits_getbits (bits, 5);
+ *x = swfdec_bits_getsbits (bits, n_bits);
+ *y = swfdec_bits_getsbits (bits, n_bits);
+
+ SWFDEC_LOG (" moveto %d,%d", *x, *y);
+ }
+ if (state_fill_styles0) {
+ parser->fill0style = swfdec_bits_getbits (bits, parser->n_fill_bits);
+ SWFDEC_LOG (" * fill0style = %d", parser->fill0style);
+ } else {
+ SWFDEC_LOG (" * not changing fill0style");
+ }
+ if (state_fill_styles1) {
+ parser->fill1style = swfdec_bits_getbits (bits, parser->n_fill_bits);
+ SWFDEC_LOG (" * fill1style = %d", parser->fill1style);
+ } else {
+ SWFDEC_LOG (" * not changing fill1style");
+ }
+ if (state_line_styles) {
+ parser->linestyle = swfdec_bits_getbits (bits, parser->n_line_bits);
+ SWFDEC_LOG (" * linestyle = %d", parser->linestyle);
+ } else {
+ SWFDEC_LOG (" * not changing linestyle");
+ }
+ if (state_new_styles) {
+ SWFDEC_LOG (" * new styles");
+ swfdec_shape_parser_finish (parser);
+ swfdec_shape_parser_new_styles (parser, bits);
+ }
+ path = swfdec_sub_path_create (parser->subpaths, *x, *y);
+ return path;
+}
+
+static void
+swfdec_shape_parser_parse_curve (SwfdecBits *bits, SwfdecSubPath *path,
+ int *x, int *y)
+{
+ int n_bits;
+ int cur_x, cur_y;
+ int control_x, control_y;
+
+ if (swfdec_bits_getbits (bits, 2) != 2) {
+ g_assert_not_reached ();
+ }
+
+ n_bits = swfdec_bits_getbits (bits, 4) + 2;
+
+ cur_x = *x;
+ cur_y = *y;
+
+ control_x = cur_x + swfdec_bits_getsbits (bits, n_bits);
+ control_y = cur_y + swfdec_bits_getsbits (bits, n_bits);
+ SWFDEC_LOG (" control %d,%d", control_x, control_y);
+
+ *x = control_x + swfdec_bits_getsbits (bits, n_bits);
+ *y = control_y + swfdec_bits_getsbits (bits, n_bits);
+ SWFDEC_LOG (" anchor %d,%d", *x, *y);
+ if (path) {
+ swfdec_path_curve_to (&path->path,
+ cur_x, cur_y,
+ control_x, control_y,
+ *x, *y);
+ } else {
+ SWFDEC_ERROR ("no path to curve in");
+ }
+}
+
+static void
+swfdec_shape_parser_parse_line (SwfdecBits *bits, SwfdecSubPath *path,
+ int *x, int *y, gboolean add_as_curve)
+{
+ int n_bits;
+ int general_line_flag;
+ int cur_x, cur_y;
+
+ if (swfdec_bits_getbits (bits, 2) != 3) {
+ g_assert_not_reached ();
+ }
+
+ cur_x = *x;
+ cur_y = *y;
+ n_bits = swfdec_bits_getbits (bits, 4) + 2;
+ general_line_flag = swfdec_bits_getbit (bits);
+ if (general_line_flag == 1) {
+ *x += swfdec_bits_getsbits (bits, n_bits);
+ *y += swfdec_bits_getsbits (bits, n_bits);
+ } else {
+ int vert_line_flag = swfdec_bits_getbit (bits);
+ if (vert_line_flag == 0) {
+ *x += swfdec_bits_getsbits (bits, n_bits);
+ } else {
+ *y += swfdec_bits_getsbits (bits, n_bits);
+ }
+ }
+ SWFDEC_LOG (" line to %d,%d", *x, *y);
+ if (path) {
+ if (add_as_curve)
+ swfdec_path_curve_to (&path->path, cur_x, cur_y,
+ (cur_x + *x) / 2, (cur_y + *y) / 2, *x, *y);
+ else
+ swfdec_path_line_to (&path->path, *x, *y);
+ } else {
+ SWFDEC_ERROR ("no path to line in");
+ }
+}
+
+void
+swfdec_shape_parser_parse (SwfdecShapeParser *parser, SwfdecBits *bits)
+{
+ int x = 0, y = 0;
+ SwfdecSubPath *path = NULL;
+ SwfdecShapeType type;
+
+ swfdec_shape_parser_new_styles (parser, bits);
+
+ while ((type = swfdec_shape_peek_type (bits))) {
+ switch (type) {
+ case SWFDEC_SHAPE_TYPE_CHANGE:
+ swfdec_shape_parser_end_path (parser, path, NULL, x, y, 0, 0);
+ path = swfdec_shape_parser_parse_change (parser, bits, &x, &y);
+ break;
+ case SWFDEC_SHAPE_TYPE_LINE:
+ swfdec_shape_parser_parse_line (bits, path, &x, &y, FALSE);
+ break;
+ case SWFDEC_SHAPE_TYPE_CURVE:
+ swfdec_shape_parser_parse_curve (bits, path, &x, &y);
+ break;
+ case SWFDEC_SHAPE_TYPE_END:
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+ }
+ swfdec_shape_parser_end_path (parser, path, NULL, x, y, 0, 0);
+ swfdec_bits_getbits (bits, 6);
+ swfdec_bits_syncbits (bits);
+
+ swfdec_shape_parser_finish (parser);
+}
+
+static SwfdecSubPath *
+swfdec_shape_parser_parse_morph_change (SwfdecShapeParser *parser,
+ SwfdecBits *bits, int *x, int *y)
+{
+ SwfdecSubPath *path;
+ int state_line_styles, state_fill_styles1, state_fill_styles0, state_moveto;
+
+ if (swfdec_bits_getbit (bits) != 0) {
+ g_assert_not_reached ();
+ }
+ if (swfdec_bits_getbit (bits)) {
+ SWFDEC_ERROR ("new styles aren't allowed in end edges, ignoring");
+ }
+ state_line_styles = swfdec_bits_getbit (bits);
+ state_fill_styles1 = swfdec_bits_getbit (bits);
+ state_fill_styles0 = swfdec_bits_getbit (bits);
+ state_moveto = swfdec_bits_getbit (bits);
+ if (state_moveto) {
+ int n_bits = swfdec_bits_getbits (bits, 5);
+ *x = swfdec_bits_getsbits (bits, n_bits);
+ *y = swfdec_bits_getsbits (bits, n_bits);
+
+ SWFDEC_LOG (" moveto %d,%d", *x, *y);
+ }
+ path = swfdec_sub_path_create (parser->subpaths2, *x, *y);
+ if (state_fill_styles0) {
+ parser->fill0style2 = swfdec_bits_getbits (bits, parser->n_fill_bits2);
+ }
+ if (state_fill_styles1) {
+ parser->fill1style2 = swfdec_bits_getbits (bits, parser->n_fill_bits2);
+ }
+ if (state_line_styles) {
+ parser->linestyle2 = swfdec_bits_getbits (bits, parser->n_line_bits2);
+ }
+
+ return path;
+}
+
+void
+swfdec_shape_parser_parse_morph (SwfdecShapeParser *parser, SwfdecBits *bits1, SwfdecBits *bits2)
+{
+ int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
+ SwfdecSubPath *path1 = NULL, *path2 = NULL;
+ SwfdecShapeType type1, type2;
+
+ swfdec_shape_parser_new_styles (parser, bits1);
+ parser->n_fill_bits2 = swfdec_bits_getbits (bits2, 4);
+ parser->n_line_bits2 = swfdec_bits_getbits (bits2, 4);
+ parser->fill0style2 = parser->fill0style;
+ parser->fill1style2 = parser->fill1style;
+ parser->linestyle2 = parser->linestyle;
+ SWFDEC_LOG ("%u fill bits, %u line bits in end shape", parser->n_fill_bits2, parser->n_line_bits2);
+
+ while ((type1 = swfdec_shape_peek_type (bits1))) {
+ type2 = swfdec_shape_peek_type (bits2);
+ if (type2 == SWFDEC_SHAPE_TYPE_CHANGE || type1 == SWFDEC_SHAPE_TYPE_CHANGE) {
+ swfdec_shape_parser_end_path (parser, path1, path2, x1, y1, x2, y2);
+ if (type1 == SWFDEC_SHAPE_TYPE_CHANGE) {
+ path1 = swfdec_shape_parser_parse_change (parser, bits1, &x1, &y1);
+ parser->fill0style2 = parser->fill0style;
+ parser->fill1style2 = parser->fill1style;
+ parser->linestyle2 = parser->linestyle;
+ } else {
+ path1 = swfdec_sub_path_create (parser->subpaths, x1, y1);
+ }
+ if (type2 == SWFDEC_SHAPE_TYPE_CHANGE) {
+ path2 = swfdec_shape_parser_parse_morph_change (parser, bits2, &x2, &y2);
+ } else {
+ path2 = swfdec_sub_path_create (parser->subpaths2, x2, y2);
+ }
+ continue;
+ }
+ switch (type2) {
+ case SWFDEC_SHAPE_TYPE_LINE:
+ swfdec_shape_parser_parse_line (bits2, path2, &x2, &y2, type1 != SWFDEC_SHAPE_TYPE_LINE);
+ break;
+ case SWFDEC_SHAPE_TYPE_CURVE:
+ swfdec_shape_parser_parse_curve (bits2, path2, &x2, &y2);
+ break;
+ case SWFDEC_SHAPE_TYPE_END:
+ SWFDEC_ERROR ("morph shape ends too early, aborting");
+ goto out;
+ case SWFDEC_SHAPE_TYPE_CHANGE:
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+ switch (type1) {
+ case SWFDEC_SHAPE_TYPE_LINE:
+ swfdec_shape_parser_parse_line (bits1, path1, &x1, &y1, type2 != SWFDEC_SHAPE_TYPE_LINE);
+ break;
+ case SWFDEC_SHAPE_TYPE_CURVE:
+ swfdec_shape_parser_parse_curve (bits1, path1, &x1, &y1);
+ break;
+ case SWFDEC_SHAPE_TYPE_CHANGE:
+ case SWFDEC_SHAPE_TYPE_END:
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+ }
+out:
+ swfdec_shape_parser_end_path (parser, path1, path2, x1, y1, x2, y2);
+ swfdec_bits_getbits (bits1, 6);
+ swfdec_bits_syncbits (bits1);
+ if (swfdec_bits_getbits (bits2, 6) != 0) {
+ SWFDEC_ERROR ("end shapes are not finished when start shapes are");
+ }
+ swfdec_bits_syncbits (bits2);
+
+ swfdec_shape_parser_finish (parser);
+}
+
diff --git a/swfdec/swfdec_shape_parser.h b/swfdec/swfdec_shape_parser.h
new file mode 100644
index 0000000..9dccbf0
--- /dev/null
+++ b/swfdec/swfdec_shape_parser.h
@@ -0,0 +1,48 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_SHAPE_PARSER_H_
+#define _SWFDEC_SHAPE_PARSER_H_
+
+#include <libswfdec/swfdec_bits.h>
+#include <libswfdec/swfdec_draw.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _SwfdecShapeParser SwfdecShapeParser;
+typedef SwfdecDraw * (* SwfdecParseDrawFunc) (SwfdecBits *bits, gpointer *data);
+
+SwfdecShapeParser * swfdec_shape_parser_new (SwfdecParseDrawFunc parse_fill,
+ SwfdecParseDrawFunc parse_line,
+ gpointer data);
+GSList * swfdec_shape_parser_reset (SwfdecShapeParser * parser);
+GSList * swfdec_shape_parser_free (SwfdecShapeParser * parser);
+
+void swfdec_shape_parser_parse (SwfdecShapeParser * parser,
+ SwfdecBits * bits);
+void swfdec_shape_parser_parse_morph (SwfdecShapeParser * parser,
+ SwfdecBits * bits1,
+ SwfdecBits * bits2);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_shared_object.c b/swfdec/swfdec_shared_object.c
new file mode 100644
index 0000000..2377bd6
--- /dev/null
+++ b/swfdec/swfdec_shared_object.c
@@ -0,0 +1,82 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+// normal
+SWFDEC_AS_NATIVE (2106, 0, swfdec_shared_object_connect)
+void
+swfdec_shared_object_connect (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("SharedObject.connect");
+}
+
+SWFDEC_AS_NATIVE (2106, 1, swfdec_shared_object_send)
+void
+swfdec_shared_object_send (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("SharedObject.send");
+}
+
+SWFDEC_AS_NATIVE (2106, 2, swfdec_shared_object_flush)
+void
+swfdec_shared_object_flush (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("SharedObject.flush");
+}
+
+SWFDEC_AS_NATIVE (2106, 3, swfdec_shared_object_close)
+void
+swfdec_shared_object_close (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("SharedObject.close");
+}
+
+SWFDEC_AS_NATIVE (2106, 4, swfdec_shared_object_getSize)
+void
+swfdec_shared_object_getSize (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("SharedObject.getSize");
+}
+
+SWFDEC_AS_NATIVE (2106, 5, swfdec_shared_object_setFps)
+void
+swfdec_shared_object_setFps (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("SharedObject.setFps");
+}
+
+SWFDEC_AS_NATIVE (2106, 6, swfdec_shared_object_clear)
+void
+swfdec_shared_object_clear (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("SharedObject.clear");
+}
diff --git a/swfdec/swfdec_socket.c b/swfdec/swfdec_socket.c
new file mode 100644
index 0000000..723050c
--- /dev/null
+++ b/swfdec/swfdec_socket.c
@@ -0,0 +1,99 @@
+/* Swfdec
+ * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_socket.h"
+#include "swfdec_loader_internal.h"
+
+/*** GTK-DOC ***/
+
+/**
+ * SECTION:SwfdecSocket
+ * @title: SwfdecSocket
+ * @short_description: object used for network connections
+ *
+ * SwfdecSockets are used to implement TCP streams. These are for example used
+ * to implement RTMP support or the XMLSocket script class. Backends are
+ * supposed to provide an implementation for this, as by default this class is
+ * unimplemented. However, libswfdec-gtk or other convenience libraries provide
+ * a socket implementation by default.
+ *
+ * The socket implementation used by a #SwfdecPlayer can be set with the
+ * SwfdecPlayer:socket-type property.
+ */
+
+/**
+ * SwfdecSocket:
+ *
+ * This is the base object used for providing input. It is abstract, create a
+ * subclass to provide your own socket implementation. All members are
+ * considered private.
+ */
+
+/**
+ * SwfdecSocketClass:
+ * @create: Create a new socket for the given hostname and port. This function
+ * must return a new socket, returning %NULL is not allowed. If you
+ * encounter an error, create a new socket and call
+ * swfdec_stream_error() on it.
+ * @send: Called to send data down the given socket. This function will only be
+ * called when the socket is open. You get passed a reference to the
+ * buffer, so it is your responsibility to call swfdec_buffer_unref() on
+ * it when you are done with it.
+ *
+ * This is the socket class. When you create a subclass, you need to implement
+ * the functions listed above.
+ */
+
+/*** SWFDEC_SOCKET ***/
+
+G_DEFINE_ABSTRACT_TYPE (SwfdecSocket, swfdec_socket, SWFDEC_TYPE_STREAM)
+
+static void
+swfdec_socket_class_init (SwfdecSocketClass *klass)
+{
+}
+
+static void
+swfdec_socket_init (SwfdecSocket *socket)
+{
+}
+
+/**
+ * swfdec_socket_send:
+ * @sock: a #SwfdecSocket
+ * @buffer: data to send to the stream
+ *
+ * Pushes the given @buffer down the stream.
+ **/
+void
+swfdec_socket_send (SwfdecSocket *sock, SwfdecBuffer *buffer)
+{
+ SwfdecSocketClass *klass;
+
+ g_return_if_fail (SWFDEC_IS_SOCKET (sock));
+ g_return_if_fail (buffer != NULL);
+
+ klass = SWFDEC_SOCKET_GET_CLASS (sock);
+ klass->send (sock, buffer);
+}
+
diff --git a/swfdec/swfdec_socket.h b/swfdec/swfdec_socket.h
new file mode 100644
index 0000000..7e062ca
--- /dev/null
+++ b/swfdec/swfdec_socket.h
@@ -0,0 +1,58 @@
+/* Swfdec
+ * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_SOCKET_H_
+#define _SWFDEC_SOCKET_H_
+
+#include <glib-object.h>
+#include <libswfdec/swfdec_stream.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecSocket SwfdecSocket;
+typedef struct _SwfdecSocketClass SwfdecSocketClass;
+
+#define SWFDEC_TYPE_SOCKET (swfdec_socket_get_type())
+#define SWFDEC_IS_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SOCKET))
+#define SWFDEC_IS_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SOCKET))
+#define SWFDEC_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SOCKET, SwfdecSocket))
+#define SWFDEC_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SOCKET, SwfdecSocketClass))
+#define SWFDEC_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_SOCKET, SwfdecSocketClass))
+
+struct _SwfdecSocket
+{
+ SwfdecStream stream;
+};
+
+struct _SwfdecSocketClass
+{
+ SwfdecStreamClass stream_class;
+
+ SwfdecSocket * (* create) (const char * hostname,
+ guint port);
+
+ void (* send) (SwfdecSocket * socket,
+ SwfdecBuffer * buffer);
+};
+
+GType swfdec_socket_get_type (void);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_sound.c b/swfdec/swfdec_sound.c
new file mode 100644
index 0000000..cb1e97c
--- /dev/null
+++ b/swfdec/swfdec_sound.c
@@ -0,0 +1,558 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <string.h>
+
+#include "swfdec_audio_internal.h"
+#include "swfdec_sound.h"
+#include "swfdec_bits.h"
+#include "swfdec_buffer.h"
+#include "swfdec_button.h"
+#include "swfdec_debug.h"
+#include "swfdec_sprite.h"
+#include "swfdec_swf_decoder.h"
+
+G_DEFINE_TYPE (SwfdecSound, swfdec_sound, SWFDEC_TYPE_CACHED)
+
+static void
+swfdec_sound_unload (SwfdecCached *cached)
+{
+ SwfdecSound * sound = SWFDEC_SOUND (cached);
+
+ if (sound->decoded) {
+ swfdec_buffer_unref (sound->decoded);
+ sound->decoded = NULL;
+ }
+}
+
+static void
+swfdec_sound_dispose (GObject *object)
+{
+ SwfdecSound * sound = SWFDEC_SOUND (object);
+
+ if (sound->encoded)
+ swfdec_buffer_unref (sound->encoded);
+
+ G_OBJECT_CLASS (swfdec_sound_parent_class)->dispose (object);
+}
+
+static void
+swfdec_sound_class_init (SwfdecSoundClass * g_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+ SwfdecCachedClass *cached_class = SWFDEC_CACHED_CLASS (g_class);
+
+ object_class->dispose = swfdec_sound_dispose;
+
+ cached_class->unload = swfdec_sound_unload;
+}
+
+static void
+swfdec_sound_init (SwfdecSound * sound)
+{
+
+}
+
+int
+tag_func_sound_stream_block (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecSound *sound;
+ SwfdecBuffer *chunk;
+ int n_samples;
+ int skip;
+
+ sound = SWFDEC_SOUND (s->parse_sprite->frames[s->parse_sprite->parse_frame].sound_head);
+
+ if (!sound) {
+ SWFDEC_WARNING ("no streaming sound block");
+ return SWFDEC_STATUS_OK;
+ }
+
+ n_samples = swfdec_bits_get_u16 (&s->b);
+ if (sound->codec == SWFDEC_AUDIO_CODEC_MP3) {
+ skip = swfdec_bits_get_s16 (&s->b);
+ } else {
+ skip = 0;
+ }
+ if (swfdec_bits_left (&s->b) == 0) {
+ SWFDEC_DEBUG ("empty sound block n_samples=%d skip=%d", n_samples,
+ skip);
+ chunk = NULL;
+ return SWFDEC_STATUS_OK;
+ } else {
+ chunk = swfdec_bits_get_buffer (&s->b, -1);
+ if (chunk == NULL) {
+ SWFDEC_ERROR ("empty sound chunk");
+ return SWFDEC_STATUS_OK;
+ }
+ SWFDEC_LOG ("got a buffer with %u samples, %d skip and %"G_GSIZE_FORMAT" bytes mp3 data", n_samples, skip,
+ chunk->length);
+ /* use this to write out the stream data to stdout - nice way to get an mp3 file :) */
+ //write (1, (void *) chunk->data, chunk->length);
+ }
+
+ swfdec_sprite_add_sound_chunk (s->parse_sprite, s->parse_sprite->parse_frame, chunk, skip, n_samples);
+
+ return SWFDEC_STATUS_OK;
+}
+
+int
+tag_func_define_sound (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecBits *b = &s->b;
+ int id;
+ int n_samples;
+ SwfdecSound *sound;
+
+ id = swfdec_bits_get_u16 (b);
+ sound = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_SOUND);
+ if (!sound)
+ return SWFDEC_STATUS_OK;
+
+ sound->codec = swfdec_bits_getbits (b, 4);
+ SWFDEC_LOG (" codec: %u", sound->codec);
+ sound->format = swfdec_audio_format_parse (b);
+ SWFDEC_LOG (" format: %s", swfdec_audio_format_to_string (sound->format));
+ n_samples = swfdec_bits_get_u32 (b);
+ sound->n_samples = n_samples;
+
+ switch (sound->codec) {
+ case 0:
+ if (swfdec_audio_format_is_16bit (sound->format))
+ SWFDEC_WARNING ("undefined endianness for s16 sound");
+ /* just assume LE and hope it works (FIXME: want a switch for this?) */
+ sound->codec = SWFDEC_AUDIO_CODEC_UNCOMPRESSED;
+ /* fall through */
+ case 3:
+ sound->encoded = swfdec_bits_get_buffer (&s->b, -1);
+ break;
+ case 2:
+ sound->skip = swfdec_bits_get_u16 (b);
+ sound->encoded = swfdec_bits_get_buffer (&s->b, -1);
+ break;
+ case 1:
+ case 5:
+ case 6:
+ sound->encoded = swfdec_bits_get_buffer (&s->b, -1);
+ break;
+ default:
+ SWFDEC_WARNING ("unknown codec %d", sound->codec);
+ }
+ sound->n_samples *= swfdec_audio_format_get_granularity (sound->format);
+
+ return SWFDEC_STATUS_OK;
+}
+
+SwfdecBuffer *
+swfdec_sound_get_decoded (SwfdecSound *sound, SwfdecAudioFormat *format)
+{
+ gpointer decoder;
+ SwfdecBuffer *tmp;
+ SwfdecBufferQueue *queue;
+ guint sample_bytes;
+ guint n_samples;
+ guint depth;
+
+ g_return_val_if_fail (SWFDEC_IS_SOUND (sound), NULL);
+ g_return_val_if_fail (format != NULL, NULL);
+
+ if (sound->decoded) {
+ swfdec_cached_use (SWFDEC_CACHED (sound));
+ *format = sound->decoded_format;
+ return sound->decoded;
+ }
+ if (sound->encoded == NULL)
+ return NULL;
+
+ decoder = swfdec_audio_decoder_new (sound->codec, sound->format);
+ if (decoder == NULL)
+ return NULL;
+
+ swfdec_audio_decoder_push (decoder, sound->encoded);
+ swfdec_audio_decoder_push (decoder, NULL);
+ queue = swfdec_buffer_queue_new ();
+ while ((tmp = swfdec_audio_decoder_pull (decoder))) {
+ swfdec_buffer_queue_push (queue, tmp);
+ }
+ sound->decoded_format = swfdec_audio_decoder_get_format (decoder);
+ swfdec_audio_decoder_free (decoder);
+ depth = swfdec_buffer_queue_get_depth (queue);
+ if (depth == 0) {
+ SWFDEC_ERROR ("decoding didn't produce any data, bailing");
+ return NULL;
+ }
+ swfdec_cached_load (SWFDEC_CACHED (sound), depth);
+ tmp = swfdec_buffer_queue_pull (queue, depth);
+ swfdec_buffer_queue_unref (queue);
+
+ sample_bytes = swfdec_audio_format_get_bytes_per_sample (sound->decoded_format);
+ n_samples = sound->n_samples / swfdec_audio_format_get_granularity (sound->decoded_format);
+
+ SWFDEC_LOG ("after decoding, got %"G_GSIZE_FORMAT" samples, should get %u and skip %u",
+ tmp->length / sample_bytes, n_samples, sound->skip);
+ if (sound->skip) {
+ SwfdecBuffer *tmp2 = swfdec_buffer_new_subbuffer (tmp, sound->skip * sample_bytes,
+ tmp->length - sound->skip * sample_bytes);
+ swfdec_buffer_unref (tmp);
+ tmp = tmp2;
+ }
+ if (tmp->length > n_samples * sample_bytes) {
+ SwfdecBuffer *tmp2 = swfdec_buffer_new_subbuffer (tmp, 0, n_samples * sample_bytes);
+ SWFDEC_DEBUG ("%u samples in %u bytes should be available, but %"G_GSIZE_FORMAT" bytes are, cutting them off",
+ n_samples, n_samples * sample_bytes, tmp->length);
+ swfdec_buffer_unref (tmp);
+ tmp = tmp2;
+ } else if (tmp->length < n_samples * sample_bytes) {
+ /* we handle this case in swfdec_sound_render */
+ /* FIXME: this message is important when writing new codecs, so I made it a warning.
+ * It's probably not worth more than INFO for the usual case though */
+ SWFDEC_WARNING ("%u samples in %u bytes should be available, but only %"G_GSIZE_FORMAT" bytes are",
+ n_samples, n_samples * sample_bytes, tmp->length);
+ }
+ /* only assign here, the decoding code checks this variable */
+ sound->decoded = tmp;
+
+ *format = sound->decoded_format;
+ return sound->decoded;
+}
+
+int
+tag_func_sound_stream_head (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecBits *b = &s->b;
+ SwfdecAudioFormat playback;
+ guint playback_codec;
+ int n_samples;
+ int latency;
+ SwfdecSound *sound;
+
+ playback_codec = swfdec_bits_getbits (b, 4);
+ /* we don't care about playback suggestions */
+ playback = swfdec_audio_format_parse (b);
+ SWFDEC_LOG (" suggested playback format: %s", swfdec_audio_format_to_string (playback));
+
+ sound = g_object_new (SWFDEC_TYPE_SOUND, NULL);
+ sound->codec = swfdec_bits_getbits (b, 4);
+ sound->format = swfdec_audio_format_parse (b);
+ n_samples = swfdec_bits_get_u16 (b);
+ if (playback_codec != 0 && playback_codec != sound->codec) {
+ SWFDEC_FIXME ("playback codec %u doesn't match sound codec %u",
+ playback_codec, sound->codec);
+ }
+
+ if (s->parse_sprite->frames[s->parse_sprite->parse_frame].sound_head)
+ g_object_unref (s->parse_sprite->frames[s->parse_sprite->parse_frame].sound_head);
+ s->parse_sprite->frames[s->parse_sprite->parse_frame].sound_head = sound;
+
+ switch (sound->codec) {
+ case SWFDEC_AUDIO_CODEC_UNDEFINED:
+ if (swfdec_audio_format_is_16bit (sound->format)) {
+ SWFDEC_WARNING ("undefined endianness for s16 sound");
+ /* just assume LE and hope it works (FIXME: want a switch for this?) */
+ sound->codec = SWFDEC_AUDIO_CODEC_UNCOMPRESSED;
+ }
+ break;
+ case SWFDEC_AUDIO_CODEC_MP3:
+ /* latency seek */
+ latency = swfdec_bits_get_s16 (b);
+ break;
+ case SWFDEC_AUDIO_CODEC_ADPCM:
+ case SWFDEC_AUDIO_CODEC_UNCOMPRESSED:
+ case SWFDEC_AUDIO_CODEC_NELLYMOSER_8KHZ:
+ case SWFDEC_AUDIO_CODEC_NELLYMOSER:
+ break;
+ default:
+ SWFDEC_WARNING ("unknown codec %d", sound->codec);
+ sound->codec = SWFDEC_AUDIO_CODEC_UNDEFINED;
+ }
+
+ return SWFDEC_STATUS_OK;
+}
+
+void
+swfdec_sound_chunk_free (SwfdecSoundChunk *chunk)
+{
+ g_return_if_fail (chunk != NULL);
+
+ g_free (chunk->envelope);
+ g_free (chunk);
+}
+
+SwfdecSoundChunk *
+swfdec_sound_parse_chunk (SwfdecSwfDecoder *s, SwfdecBits *b, int id)
+{
+ int has_envelope;
+ int has_loops;
+ int has_out_point;
+ int has_in_point;
+ guint i, j;
+ SwfdecSound *sound;
+ SwfdecSoundChunk *chunk;
+
+ sound = swfdec_swf_decoder_get_character (s, id);
+ if (!SWFDEC_IS_SOUND (sound)) {
+ SWFDEC_ERROR ("given id %d does not reference a sound object", id);
+ return NULL;
+ }
+
+ chunk = g_new0 (SwfdecSoundChunk, 1);
+ chunk->sound = sound;
+ SWFDEC_DEBUG ("parsing sound chunk for sound %d", SWFDEC_CHARACTER (sound)->id);
+
+ swfdec_bits_getbits (b, 2);
+ chunk->stop = swfdec_bits_getbits (b, 1);
+ chunk->no_restart = swfdec_bits_getbits (b, 1);
+ has_envelope = swfdec_bits_getbits (b, 1);
+ has_loops = swfdec_bits_getbits (b, 1);
+ has_out_point = swfdec_bits_getbits (b, 1);
+ has_in_point = swfdec_bits_getbits (b, 1);
+ if (has_in_point) {
+ chunk->start_sample = swfdec_bits_get_u32 (b);
+ SWFDEC_LOG (" start_sample = %u", chunk->start_sample);
+ } else {
+ chunk->start_sample = 0;
+ }
+ if (has_out_point) {
+ chunk->stop_sample = swfdec_bits_get_u32 (b);
+ if (chunk->stop_sample == 0) {
+ SWFDEC_FIXME ("stop sample == 0???");
+ }
+ SWFDEC_LOG (" stop_sample = %u", chunk->stop_sample);
+ if (chunk->stop_sample <= chunk->start_sample) {
+ SWFDEC_ERROR ("stopping before starting? (start sample %u, stop sample %u)",
+ chunk->start_sample, chunk->stop_sample);
+ chunk->stop_sample = 0;
+ }
+ } else {
+ chunk->stop_sample = 0;
+ }
+ if (has_loops) {
+ chunk->loop_count = swfdec_bits_get_u16 (b);
+ if (chunk->loop_count == 0) {
+ SWFDEC_ERROR ("loop_count 0 not allowed, setting to 1");
+ chunk->loop_count = 1;
+ }
+ SWFDEC_LOG (" loop_count = %u", chunk->loop_count);
+ } else {
+ chunk->loop_count = 1;
+ }
+ if (has_envelope) {
+ chunk->n_envelopes = swfdec_bits_get_u8 (b);
+ chunk->envelope = g_new0 (SwfdecSoundEnvelope, chunk->n_envelopes);
+ SWFDEC_LOG (" n_envelopes = %u", chunk->n_envelopes);
+ }
+
+ for (i = 0; i < chunk->n_envelopes && swfdec_bits_left (b); i++) {
+ chunk->envelope[i].offset = swfdec_bits_get_u32 (b);
+ if (i > 0 && chunk->envelope[i-1].offset > chunk->envelope[i].offset) {
+ SWFDEC_ERROR ("unordered sound envelopes");
+ chunk->envelope[i].offset = chunk->envelope[i-1].offset;
+ }
+
+ for (j = 0; j < 2; j++) {
+ chunk->envelope[i].volume[j] = swfdec_bits_get_u16 (b);
+ if (chunk->envelope[i].volume[j] > 32768) {
+ SWFDEC_FIXME ("too big envelope volumes (%u > 32768) not handled correctly",
+ chunk->envelope[i].volume[j]);
+ chunk->envelope[i].volume[j] = 32768;
+ }
+ }
+
+ SWFDEC_LOG (" envelope = %u { %u, %u }", chunk->envelope[i].offset,
+ (guint) chunk->envelope[i].volume[0], (guint) chunk->envelope[i].volume[1]);
+ }
+
+ if (i < chunk->n_envelopes)
+ SWFDEC_ERROR ("out of bits when reading sound envelopes");
+
+ return chunk;
+}
+
+int
+tag_func_define_button_sound (SwfdecSwfDecoder * s, guint tag)
+{
+ guint i;
+ guint id;
+ SwfdecButton *button;
+
+ id = swfdec_bits_get_u16 (&s->b);
+ button = (SwfdecButton *) swfdec_swf_decoder_get_character (s, id);
+ if (!SWFDEC_IS_BUTTON (button)) {
+ SWFDEC_ERROR ("id %u is not a button", id);
+ return SWFDEC_STATUS_OK;
+ }
+ SWFDEC_LOG ("loading sound events for button %u", id);
+ for (i = 0; i < 4; i++) {
+ id = swfdec_bits_get_u16 (&s->b);
+ if (id) {
+ SWFDEC_LOG ("loading sound %u for button event %u", id, i);
+ if (button->sounds[i]) {
+ SWFDEC_ERROR ("need to delete previous sound for button %u's event %u",
+ SWFDEC_CHARACTER (button)->id, i);
+ swfdec_sound_chunk_free (button->sounds[i]);
+ }
+ button->sounds[i] = swfdec_sound_parse_chunk (s, &s->b, id);
+ }
+ }
+
+ return SWFDEC_STATUS_OK;
+}
+
+/**
+ * swfdec_sound_buffer_get_n_samples:
+ * @buffer: data to examine
+ * @format: format the data in @buffer is in
+ *
+ * Determines the number of samples inside @buffer that would be available if
+ * it were to be rendered using the default Flash format, 44100Hz.
+ *
+ * Returns: Number of samples contained in @buffer when rendered
+ **/
+guint
+swfdec_sound_buffer_get_n_samples (const SwfdecBuffer *buffer, SwfdecAudioFormat format)
+{
+ g_return_val_if_fail (buffer != NULL, 0);
+ g_return_val_if_fail (buffer->length % (2 * swfdec_audio_format_get_channels (format)) == 0, 0);
+
+ return buffer->length / (2 * swfdec_audio_format_get_channels (format)) *
+ swfdec_audio_format_get_granularity (format);
+}
+
+static void
+swfdec_sound_buffer_render_stereo (gint16 *dest, const gint16 *source, guint offset,
+ guint n_samples, guint rate)
+{
+ guint i, j;
+
+ source += 2 * (offset / rate);
+ offset %= rate;
+
+ if (offset) {
+ offset = MIN (rate - offset, n_samples);
+ for (i = 0; i < offset; i++) {
+ *dest++ = source[0];
+ *dest++ = source[1];
+ }
+ source += 2;
+ n_samples -= offset;
+ }
+ for (i = rate; i <= n_samples; i += rate) {
+ for (j = 0; j < rate; j++) {
+ *dest++ = source[0];
+ *dest++ = source[1];
+ }
+ source += 2;
+ }
+ n_samples -= i - rate;
+ g_assert (n_samples < rate);
+ for (i = 0; i < n_samples; i++) {
+ *dest++ = source[0];
+ *dest++ = source[1];
+ }
+}
+
+static void
+swfdec_sound_buffer_render_mono (gint16 *dest, const gint16 *source, guint offset,
+ guint n_samples, guint rate)
+{
+ guint i, j;
+
+ source += (offset / rate);
+ offset %= rate;
+
+ if (offset) {
+ offset = MIN (rate - offset, n_samples);
+ for (i = 0; i < offset; i++) {
+ *dest++ = *source;
+ *dest++ = *source;
+ }
+ source++;
+ n_samples -= offset;
+ }
+ for (i = rate; i <= n_samples; i += rate) {
+ for (j = 0; j < rate; j++) {
+ *dest++ = *source;
+ *dest++ = *source;
+ }
+ source++;
+ }
+ n_samples -= i - rate;
+ g_assert (n_samples < rate);
+ for (i = 0; i < n_samples; i++) {
+ *dest++ = *source;
+ *dest++ = *source;
+ }
+}
+
+/**
+ * swfdec_sound_render_buffer:
+ * @dest: target buffer to render to
+ * @source: source data to render
+ * @format: format of data in @source and @previous
+ * @previous: previous buffer or NULL for none. This is necessary for
+ * upsampling at buffer boundaries
+ * @offset: offset in 44100Hz samples into @source
+ * @n_samples: number of samples to render into @dest. If more data would be
+ * rendered than is available in @source, 0 samples are used instead.
+ *
+ * Adds data from @source into @dest
+ **/
+void
+swfdec_sound_buffer_render (gint16 *dest, const SwfdecBuffer *source,
+ SwfdecAudioFormat format, const SwfdecBuffer *previous,
+ guint offset, guint n_samples)
+{
+ guint channels = swfdec_audio_format_get_channels (format);
+ guint rate = swfdec_audio_format_get_granularity (format);
+ guint width = swfdec_audio_format_is_16bit (format) ? 2 : 1;
+ guint total_samples;
+ gint16 *fixme = NULL;
+
+ g_return_if_fail (dest != NULL);
+ g_return_if_fail (source != NULL);
+ g_return_if_fail (swfdec_sound_buffer_get_n_samples (source, format) > 0);
+ g_return_if_fail (previous == NULL || swfdec_sound_buffer_get_n_samples (previous, format) > 0);
+
+ total_samples = (source->length / channels / width) * rate;
+ SWFDEC_LOG ("rendering [%u %u) - total: %u samples", offset, n_samples, total_samples);
+ /* FIXME: warn about this? */
+ n_samples = MIN (n_samples, total_samples - offset);
+
+ if (width == 1) {
+ guint i;
+ /* FIXME: make this faster */
+ fixme = g_try_malloc (source->length * 2);
+ if (fixme == NULL)
+ return;
+ for (i = 0; i < source->length; i++) {
+ fixme[i] = (((gint16) source->data[i]) << 8) - 32768;
+ }
+ }
+ if (channels == 2) {
+ swfdec_sound_buffer_render_stereo (dest, (const void *) source->data, offset, n_samples, rate);
+ } else {
+ swfdec_sound_buffer_render_mono (dest, (const void *) source->data, offset, n_samples, rate);
+ }
+ g_free (fixme);
+}
+
diff --git a/swfdec/swfdec_sound.h b/swfdec/swfdec_sound.h
new file mode 100644
index 0000000..75e917e
--- /dev/null
+++ b/swfdec/swfdec_sound.h
@@ -0,0 +1,107 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_SOUND_H_
+#define _SWFDEC_SOUND_H_
+
+#include <libswfdec/swfdec_cached.h>
+#include <libswfdec/swfdec_codec_audio.h>
+#include <libswfdec/swfdec_swf_decoder.h>
+#include <libswfdec/swfdec_types.h>
+
+G_BEGIN_DECLS
+
+//typedef struct _SwfdecSoundChunk SwfdecSoundChunk;
+//typedef struct _SwfdecSound SwfdecSound;
+typedef struct _SwfdecSoundClass SwfdecSoundClass;
+typedef struct _SwfdecSoundEnvelope SwfdecSoundEnvelope;
+
+#define SWFDEC_TYPE_SOUND (swfdec_sound_get_type())
+#define SWFDEC_IS_SOUND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SOUND))
+#define SWFDEC_IS_SOUND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SOUND))
+#define SWFDEC_SOUND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SOUND, SwfdecSound))
+#define SWFDEC_SOUND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SOUND, SwfdecSoundClass))
+
+struct _SwfdecSoundEnvelope {
+ guint offset; /* offset in frames */
+ guint16 volume[2]; /* volume to use */
+};
+
+struct _SwfdecSoundChunk
+{
+ SwfdecSound * sound; /* sound to play */
+
+ int stop; /* stop the sample being played */
+ int no_restart; /* don't restart if already playing */
+
+ guint start_sample; /* sample at which to start playing */
+ guint stop_sample; /* first sample to not play anymore or 0 for playing all */
+ guint loop_count; /* amount of times this sample should be played back */
+ guint n_envelopes; /* amount of points in the envelope */
+ SwfdecSoundEnvelope * envelope; /* volume envelope or NULL if none */
+};
+
+struct _SwfdecSound
+{
+ SwfdecCached cached;
+
+ guint codec; /* codec in use */
+ SwfdecAudioFormat format; /* channel/rate/width information for codec */
+ guint n_samples; /* total number of samples when decoded to 44100kHz */
+ guint skip; /* samples to skip at start */
+ SwfdecBuffer * encoded; /* encoded data */
+
+ SwfdecAudioFormat decoded_format; /* format of decoded data */
+ SwfdecBuffer * decoded; /* decoded data */
+};
+
+struct _SwfdecSoundClass
+{
+ SwfdecCachedClass cached_class;
+};
+
+GType swfdec_sound_get_type (void);
+
+int tag_func_define_sound (SwfdecSwfDecoder * s, guint tag);
+int tag_func_sound_stream_block (SwfdecSwfDecoder * s, guint tag);
+int tag_func_sound_stream_head (SwfdecSwfDecoder * s, guint tag);
+int tag_func_start_sound (SwfdecSwfDecoder * s, guint tag);
+int tag_func_define_button_sound (SwfdecSwfDecoder * s, guint tag);
+
+SwfdecBuffer * swfdec_sound_get_decoded (SwfdecSound * sound,
+ SwfdecAudioFormat * format);
+void swfdec_sound_buffer_render (gint16 * dest,
+ const SwfdecBuffer * source,
+ SwfdecAudioFormat format,
+ const SwfdecBuffer * previous,
+ guint offset,
+ guint n_samples);
+guint swfdec_sound_buffer_get_n_samples (const SwfdecBuffer * buffer,
+ SwfdecAudioFormat format);
+
+SwfdecSoundChunk * swfdec_sound_parse_chunk (SwfdecSwfDecoder * s,
+ SwfdecBits * bits,
+ int id);
+void swfdec_sound_chunk_free (SwfdecSoundChunk * chunk);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_sound_object.c b/swfdec/swfdec_sound_object.c
new file mode 100644
index 0000000..7a17761
--- /dev/null
+++ b/swfdec/swfdec_sound_object.c
@@ -0,0 +1,340 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+#include "swfdec_sound_object.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_as_object.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_audio_event.h"
+#include "swfdec_debug.h"
+#include "swfdec_internal.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_resource.h"
+
+/*** SwfdecSoundObject ***/
+
+G_DEFINE_TYPE (SwfdecSoundObject, swfdec_sound_object, SWFDEC_TYPE_AS_OBJECT)
+
+static void
+swfdec_sound_object_mark (SwfdecAsObject *object)
+{
+ SwfdecSoundObject *sound = SWFDEC_SOUND_OBJECT (object);
+
+ if (sound->target != NULL)
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (sound->target));
+
+ SWFDEC_AS_OBJECT_CLASS (swfdec_sound_object_parent_class)->mark (object);
+}
+
+static void
+swfdec_sound_object_dispose (GObject *object)
+{
+ SwfdecSoundObject *sound = SWFDEC_SOUND_OBJECT (object);
+
+ if (sound->attached) {
+ g_object_unref (sound->attached);
+ sound->attached = NULL;
+ }
+
+ G_OBJECT_CLASS (swfdec_sound_object_parent_class)->dispose (object);
+}
+
+static void
+swfdec_sound_object_class_init (SwfdecSoundObjectClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
+
+ object_class->dispose = swfdec_sound_object_dispose;
+
+ asobject_class->mark = swfdec_sound_object_mark;
+}
+
+static void
+swfdec_sound_object_init (SwfdecSoundObject *sound)
+{
+}
+
+static SwfdecSound *
+swfdec_sound_object_get_sound (SwfdecSoundObject *sound, const char *name)
+{
+ if (sound->target == NULL)
+ return NULL;
+
+ return swfdec_resource_get_export (sound->target->resource, name);
+}
+
+/*** AS CODE ***/
+
+SWFDEC_AS_NATIVE (500, 0, swfdec_sound_object_getPan)
+void
+swfdec_sound_object_getPan (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Sound.getPan");
+}
+
+SWFDEC_AS_NATIVE (500, 1, swfdec_sound_object_getTransform)
+void
+swfdec_sound_object_getTransform (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Sound.getTransform");
+}
+
+SWFDEC_AS_NATIVE (500, 2, swfdec_sound_object_getVolume)
+void
+swfdec_sound_object_getVolume (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Sound.getVolume");
+}
+
+SWFDEC_AS_NATIVE (500, 3, swfdec_sound_object_setPan)
+void
+swfdec_sound_object_setPan (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Sound.setPan");
+}
+
+SWFDEC_AS_NATIVE (500, 4, swfdec_sound_object_setTransform)
+void
+swfdec_sound_object_setTransform (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Sound.setTransform");
+}
+
+SWFDEC_AS_NATIVE (500, 5, swfdec_sound_object_setVolume)
+void
+swfdec_sound_object_setVolume (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Sound.setVolume");
+}
+
+SWFDEC_AS_NATIVE (500, 9, swfdec_sound_object_getDuration)
+void
+swfdec_sound_object_getDuration (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Sound.getDuration");
+}
+
+SWFDEC_AS_NATIVE (500, 10, swfdec_sound_object_setDuration)
+void
+swfdec_sound_object_setDuration (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Sound.setDuration");
+}
+
+SWFDEC_AS_NATIVE (500, 11, swfdec_sound_object_getPosition)
+void
+swfdec_sound_object_getPosition (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Sound.getPosition");
+}
+
+SWFDEC_AS_NATIVE (500, 12, swfdec_sound_object_setPosition)
+void
+swfdec_sound_object_setPosition (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Sound.setPosition");
+}
+
+SWFDEC_AS_NATIVE (500, 13, swfdec_sound_object_loadSound)
+void
+swfdec_sound_object_loadSound (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Sound.loadSound");
+}
+
+SWFDEC_AS_NATIVE (500, 14, swfdec_sound_object_getBytesLoaded)
+void
+swfdec_sound_object_getBytesLoaded (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Sound.getBytesLoaded");
+}
+
+SWFDEC_AS_NATIVE (500, 15, swfdec_sound_object_getBytesTotal)
+void
+swfdec_sound_object_getBytesTotal (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Sound.getBytesTotal");
+}
+
+SWFDEC_AS_NATIVE (500, 18, swfdec_sound_object_get_checkPolicyFile)
+void
+swfdec_sound_object_get_checkPolicyFile (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Sound.checkPolicyFile (get)");
+}
+
+SWFDEC_AS_NATIVE (500, 19, swfdec_sound_object_set_checkPolicyFile)
+void
+swfdec_sound_object_set_checkPolicyFile (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Sound.checkPolicyFile (set)");
+}
+
+SWFDEC_AS_NATIVE (500, 16, swfdec_sound_object_areSoundsInaccessible)
+void
+swfdec_sound_object_areSoundsInaccessible (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Sound.areSoundsInaccessible");
+}
+
+SWFDEC_AS_NATIVE (500, 7, swfdec_sound_object_attachSound)
+void
+swfdec_sound_object_attachSound (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+ SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecSoundObject *sound;
+ const char *name;
+ SwfdecSound *new;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_SOUND_OBJECT, &sound, "s", &name);
+
+ new = swfdec_sound_object_get_sound (sound, name);
+ if (new) {
+ if (sound->attached)
+ g_object_unref (sound->attached);
+ sound->attached = g_object_ref (new);
+ }
+}
+
+SWFDEC_AS_NATIVE (500, 8, swfdec_sound_object_start)
+void
+swfdec_sound_object_start (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+ SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecSoundObject *sound;
+ double offset;
+ int loops;
+ SwfdecAudio *audio;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_SOUND_OBJECT, &sound, "|ni", &offset, &loops);
+
+ if (sound->attached == NULL) {
+ SWFDEC_INFO ("no sound attached when calling Sound.start()");
+ return;
+ }
+ if (argc < 2 || loops < 0)
+ loops = 1;
+ if (offset < 0 || !isfinite (offset))
+ offset = 0;
+
+ audio = swfdec_audio_event_new (SWFDEC_PLAYER (cx), sound->attached, offset / 44100, loops);
+ g_object_unref (audio);
+}
+
+typedef struct {
+ SwfdecMovie *movie;
+ SwfdecSound *sound;
+} RemoveData;
+
+static gboolean
+swfdec_sound_object_should_stop (SwfdecAudio *audio, gpointer datap)
+{
+ RemoveData *data = datap;
+ SwfdecAudioEvent *event;
+
+ if (!SWFDEC_IS_AUDIO_EVENT (audio))
+ return FALSE;
+ event = SWFDEC_AUDIO_EVENT (audio);
+ if (data->sound != NULL && event->sound != data->sound)
+ return FALSE;
+ /* FIXME: also check the movie is identical */
+ return TRUE;
+}
+
+SWFDEC_AS_NATIVE (500, 6, swfdec_sound_object_stop)
+void
+swfdec_sound_object_stop (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+ SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecSoundObject *sound;
+ const char *name;
+ RemoveData data;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_SOUND_OBJECT, &sound, "|s", &name);
+
+ if (sound->global) {
+ data.movie = NULL;
+ } else {
+ data.movie = sound->target;
+ }
+ if (argc > 0) {
+ data.sound = swfdec_sound_object_get_sound (sound, name);
+ if (data.sound == NULL)
+ return;
+ } else if (sound->attached) {
+ data.sound = sound->attached;
+ } else {
+ data.sound = NULL;
+ }
+ swfdec_player_stop_sounds (SWFDEC_PLAYER (cx), swfdec_sound_object_should_stop, &data);
+}
+
+SWFDEC_AS_CONSTRUCTOR (500, 16, swfdec_sound_object_construct, swfdec_sound_object_get_type)
+void
+swfdec_sound_object_construct (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+ SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecSoundObject *sound;
+ SwfdecPlayer *player;
+
+ if (!swfdec_as_context_is_constructing (cx))
+ return;
+
+ sound = SWFDEC_SOUND_OBJECT (object);
+ player = SWFDEC_PLAYER (cx);
+
+ if (argc == 0 || SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0])) {
+ sound->global = TRUE;
+ /* FIXME: what is the target for global sounds? Problem:
+ * We use the target in attachSound to look up the sound object to attach.
+ * But I'm not sure what is used for global sounds.
+ * So we just use a random one that looks good for now. */
+ sound->target = player->priv->roots->data;
+ } else {
+ sound->target = swfdec_player_get_movie_from_value (player, &argv[0]);
+ }
+}
+
diff --git a/swfdec/swfdec_sound_object.h b/swfdec/swfdec_sound_object.h
new file mode 100644
index 0000000..cdceaeb
--- /dev/null
+++ b/swfdec/swfdec_sound_object.h
@@ -0,0 +1,54 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_SOUND_OBJECT_H_
+#define _SWFDEC_SOUND_OBJECT_H_
+
+#include <libswfdec/swfdec_movie.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _SwfdecSoundObject SwfdecSoundObject;
+typedef struct _SwfdecSoundObjectClass SwfdecSoundObjectClass;
+
+#define SWFDEC_TYPE_SOUND_OBJECT (swfdec_sound_object_get_type())
+#define SWFDEC_IS_SOUND_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SOUND_OBJECT))
+#define SWFDEC_IS_SOUND_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SOUND_OBJECT))
+#define SWFDEC_SOUND_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SOUND_OBJECT, SwfdecSoundObject))
+#define SWFDEC_SOUND_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SOUND_OBJECT, SwfdecSoundObjectClass))
+#define SWFDEC_SOUND_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_SOUND_OBJECT, SwfdecSoundObjectClass))
+
+struct _SwfdecSoundObject {
+ SwfdecAsObject object;
+
+ SwfdecMovie * target; /* target movie or NULL on constructing error */
+ gboolean global; /* TRUE if handling global sound */
+ SwfdecSound * attached; /* sound that was attached */
+};
+
+struct _SwfdecSoundObjectClass {
+ SwfdecAsObjectClass object_class;
+};
+
+GType swfdec_sound_object_get_type (void);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_sprite.c b/swfdec/swfdec_sprite.c
new file mode 100644
index 0000000..f7bc576
--- /dev/null
+++ b/swfdec/swfdec_sprite.c
@@ -0,0 +1,217 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <string.h>
+
+#include "swfdec_sprite.h"
+#include "swfdec_debug.h"
+#include "swfdec_movie.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_script.h"
+#include "swfdec_sound.h"
+#include "swfdec_sprite_movie.h"
+#include "swfdec_swf_decoder.h"
+#include "swfdec_tag.h"
+
+G_DEFINE_TYPE (SwfdecSprite, swfdec_sprite, SWFDEC_TYPE_GRAPHIC)
+
+static void
+swfdec_sprite_dispose (GObject *object)
+{
+ SwfdecSprite * sprite = SWFDEC_SPRITE (object);
+ guint i;
+
+ if (sprite->frames) {
+ for (i = 0; i < sprite->n_frames; i++) {
+ g_free (sprite->frames[i].label);
+ if (sprite->frames[i].sound_head)
+ g_object_unref (sprite->frames[i].sound_head);
+ if (sprite->frames[i].sound_block) {
+ swfdec_buffer_unref (sprite->frames[i].sound_block);
+ }
+ g_slist_foreach (sprite->frames[i].sound, (GFunc) swfdec_sound_chunk_free, NULL);
+ g_slist_free (sprite->frames[i].sound);
+ }
+ g_free(sprite->frames);
+ }
+ for (i = 0; i < sprite->actions->len; i++) {
+ SwfdecSpriteAction *cur = &g_array_index (sprite->actions, SwfdecSpriteAction, i);
+ if (cur->buffer)
+ swfdec_buffer_unref (cur->buffer);
+ }
+ g_array_free (sprite->actions, TRUE);
+ sprite->actions = NULL;
+ if (sprite->init_action) {
+ swfdec_script_unref (sprite->init_action);
+ sprite->init_action = NULL;
+ }
+
+ G_OBJECT_CLASS (swfdec_sprite_parent_class)->dispose (object);
+}
+
+void
+swfdec_sprite_add_sound_chunk (SwfdecSprite * sprite, guint frame,
+ SwfdecBuffer * chunk, int skip, guint n_samples)
+{
+ g_assert (sprite->frames != NULL);
+ g_assert (chunk != NULL || n_samples == 0);
+
+ if (sprite->frames[frame].sound_head == NULL) {
+ SWFDEC_ERROR ("attempting to add a sound block without previous sound head");
+ swfdec_buffer_unref (chunk);
+ return;
+ }
+ if (sprite->frames[frame].sound_block) {
+ SWFDEC_ERROR ("attempting to add 2 sound blocks to one frame");
+ swfdec_buffer_unref (chunk);
+ return;
+ }
+ SWFDEC_LOG ("adding %u samples in %"G_GSIZE_FORMAT" bytes to frame %u", n_samples,
+ chunk ? chunk->length : 0, frame);
+ sprite->frames[frame].sound_skip = skip;
+ sprite->frames[frame].sound_block = chunk;
+ sprite->frames[frame].sound_samples = n_samples *
+ swfdec_audio_format_get_granularity (sprite->frames[frame].sound_head->format);
+}
+
+void
+swfdec_sprite_add_action (SwfdecSprite *sprite, guint tag, SwfdecBuffer *buffer)
+{
+ SwfdecSpriteAction action;
+
+ action.tag = tag;
+ action.buffer = buffer;
+ g_array_append_val (sprite->actions, action);
+}
+
+gboolean
+swfdec_sprite_get_action (SwfdecSprite *sprite, guint n, guint *tag, SwfdecBuffer **buffer)
+{
+ SwfdecSpriteAction *action;
+
+ g_return_val_if_fail (SWFDEC_IS_SPRITE (sprite), FALSE);
+ g_return_val_if_fail (tag != NULL, FALSE);
+ g_return_val_if_fail (buffer != NULL, FALSE);
+
+ if (n >= sprite->actions->len)
+ return FALSE;
+ action = &g_array_index (sprite->actions, SwfdecSpriteAction, n);
+ *tag = action->tag;
+ *buffer = action->buffer;
+ return TRUE;
+}
+
+int
+tag_func_set_background_color (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecPlayer *player = SWFDEC_DECODER (s)->player;
+ SwfdecPlayerPrivate *priv = player->priv;
+ SwfdecColor color = swfdec_bits_get_color (&s->b);
+
+ if (priv->bgcolor_set) {
+ /* only an INFO because it can be set by user, should be error if we check duplication of tag */
+ SWFDEC_INFO ("background color has been set to %X already, setting to %X ignored",
+ priv->bgcolor, color);
+ } else {
+ SWFDEC_LOG ("setting background color to %X", color);
+ /* can't use swfdec_player_set_background_color() here, because the player is locked and doesn't emit signals */
+ priv->bgcolor = color;
+ priv->bgcolor_set = TRUE;
+ priv->invalid_extents = priv->stage;
+ g_array_set_size (priv->invalidations, 1);
+ g_array_index (priv->invalidations, SwfdecRectangle, 0) = priv->stage;
+ g_object_notify (G_OBJECT (player), "background-color");
+ }
+
+ return SWFDEC_STATUS_OK;
+}
+
+static SwfdecMovie *
+swfdec_sprite_create_movie (SwfdecGraphic *graphic, gsize *size)
+{
+ SwfdecSpriteMovie *ret = g_object_new (SWFDEC_TYPE_SPRITE_MOVIE, NULL);
+
+ ret->sprite = SWFDEC_SPRITE (graphic);
+ ret->n_frames = ret->sprite->n_frames;
+ *size = sizeof (SwfdecSpriteMovie);
+
+ return SWFDEC_MOVIE (ret);
+}
+
+static void
+swfdec_sprite_class_init (SwfdecSpriteClass * g_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+ SwfdecGraphicClass *graphic_class = SWFDEC_GRAPHIC_CLASS (g_class);
+
+ object_class->dispose = swfdec_sprite_dispose;
+
+ graphic_class->create_movie = swfdec_sprite_create_movie;
+}
+
+static void
+swfdec_sprite_init (SwfdecSprite * sprite)
+{
+ sprite->actions = g_array_new (FALSE, FALSE, sizeof (SwfdecSpriteAction));
+}
+
+void
+swfdec_sprite_set_n_frames (SwfdecSprite *sprite, guint n_frames,
+ guint rate)
+{
+ guint i;
+
+ g_return_if_fail (SWFDEC_IS_SPRITE (sprite));
+ if (n_frames > 0) {
+ sprite->frames = g_new0 (SwfdecSpriteFrame, n_frames);
+ sprite->n_frames = n_frames;
+
+ if (rate > 0) {
+ for (i = 0; i < n_frames; i++) {
+ sprite->frames[i].sound_samples = 44100 * 256 / rate;
+ }
+ }
+ }
+
+ SWFDEC_LOG ("n_frames = %d", sprite->n_frames);
+}
+
+int
+swfdec_sprite_get_frame (SwfdecSprite *sprite, const char *label)
+{
+ guint i;
+
+ g_return_val_if_fail (SWFDEC_IS_SPRITE (sprite), -1);
+ g_return_val_if_fail (label != NULL, -1);
+
+ for (i = 0; i < SWFDEC_SPRITE (sprite)->n_frames; i++) {
+ SwfdecSpriteFrame *frame = &sprite->frames[i];
+ if (frame->label == NULL)
+ continue;
+ if (g_str_equal (frame->label, label))
+ return i;
+ }
+ return -1;
+}
+
diff --git a/swfdec/swfdec_sprite.h b/swfdec/swfdec_sprite.h
new file mode 100644
index 0000000..6c9d4b9
--- /dev/null
+++ b/swfdec/swfdec_sprite.h
@@ -0,0 +1,100 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_SPRITE_H_
+#define _SWFDEC_SPRITE_H_
+
+#include <libswfdec/swfdec_color.h>
+#include <libswfdec/swfdec_event.h>
+#include <libswfdec/swfdec_graphic.h>
+#include <libswfdec/swfdec_types.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecSpriteClass SwfdecSpriteClass;
+typedef struct _SwfdecSpriteAction SwfdecSpriteAction;
+typedef struct _SwfdecExport SwfdecExport;
+
+/* FIXME: It might make sense to event a SwfdecActionBuffer - a subclass of
+ * SwfdecBuffer that carries around a the tag.
+ * It might also make more sense to not parse the file into buffers at all
+ * and operate on the memory directly.
+ */
+struct _SwfdecSpriteAction {
+ guint tag; /* the data tag (see swfdec_tag.h) */
+ SwfdecBuffer * buffer; /* the buffer for this data (can be NULL) */
+};
+
+#define SWFDEC_TYPE_SPRITE (swfdec_sprite_get_type())
+#define SWFDEC_IS_SPRITE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SPRITE))
+#define SWFDEC_IS_SPRITE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SPRITE))
+#define SWFDEC_SPRITE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SPRITE, SwfdecSprite))
+#define SWFDEC_SPRITE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SPRITE, SwfdecSpriteClass))
+
+struct _SwfdecSpriteFrame
+{
+ char *label; /* name of the frame for "GotoLabel" */
+
+ /* sound */
+ SwfdecSound *sound_head; /* sound head for this frame */
+ int sound_skip; /* samples to skip - maybe even backwards */
+ SwfdecBuffer *sound_block; /* sound chunk to play here or NULL for none */
+ guint sound_samples; /* number of samples in this frame */
+ GSList *sound; /* list of SwfdecSoundChunk events to start playing here */
+};
+
+struct _SwfdecSprite
+{
+ SwfdecGraphic graphic;
+
+ SwfdecSpriteFrame * frames; /* the n_frames different frames */
+ guint n_frames; /* number of frames in this sprite */
+ SwfdecScript * init_action; /* action to run when initializing this sprite */
+ GArray * actions; /* SwfdecSpriteAction in execution order */
+
+ /* parse state */
+ guint parse_frame; /* frame we're currently parsing. == n_frames if done parsing */
+};
+
+struct _SwfdecSpriteClass
+{
+ SwfdecGraphicClass graphic_class;
+};
+
+GType swfdec_sprite_get_type (void);
+
+int tag_func_define_sprite (SwfdecSwfDecoder * s, guint tag);
+void swfdec_sprite_add_sound_chunk (SwfdecSprite * sprite, guint frame,
+ SwfdecBuffer * chunk, int skip, guint n_samples);
+void swfdec_sprite_set_n_frames (SwfdecSprite *sprite, guint n_frames, guint rate);
+void swfdec_sprite_add_action (SwfdecSprite * sprite, guint tag, SwfdecBuffer *buffer);
+gboolean swfdec_sprite_get_action (SwfdecSprite * sprite,
+ guint n,
+ guint * tag,
+ SwfdecBuffer ** buffer);
+int swfdec_sprite_get_frame (SwfdecSprite * sprite,
+ const char * label);
+
+int tag_func_set_background_color (SwfdecSwfDecoder * s, guint tag);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_sprite_movie.c b/swfdec/swfdec_sprite_movie.c
new file mode 100644
index 0000000..e014ece
--- /dev/null
+++ b/swfdec/swfdec_sprite_movie.c
@@ -0,0 +1,883 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <strings.h>
+
+#include "swfdec_sprite_movie.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_audio_event.h"
+#include "swfdec_audio_stream.h"
+#include "swfdec_debug.h"
+#include "swfdec_filter.h"
+#include "swfdec_graphic_movie.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_ringbuffer.h"
+#include "swfdec_script_internal.h"
+#include "swfdec_sprite.h"
+#include "swfdec_resource.h"
+#include "swfdec_tag.h"
+
+/*** SWFDEC_SPRITE_MOVIE ***/
+
+static gboolean
+swfdec_sprite_movie_remove_child (SwfdecMovie *movie, int depth)
+{
+ SwfdecMovie *child = swfdec_movie_find (movie, depth);
+
+ if (child == NULL)
+ return FALSE;
+
+ swfdec_movie_remove (child);
+ return TRUE;
+}
+
+static int
+swfdec_get_clipeventflags (SwfdecMovie *movie, SwfdecBits * bits)
+{
+ if (SWFDEC_SWF_DECODER (movie->resource->decoder)->version <= 5) {
+ return swfdec_bits_get_u16 (bits);
+ } else {
+ return swfdec_bits_get_u32 (bits);
+ }
+}
+
+static gboolean
+swfdec_sprite_movie_perform_old_place (SwfdecSpriteMovie *movie,
+ SwfdecBits *bits, guint tag)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
+ SwfdecMovie *mov = SWFDEC_MOVIE (movie);
+ SwfdecMovie *cur;
+ SwfdecSwfDecoder *dec;
+ int depth;
+ cairo_matrix_t transform;
+ gboolean has_ctrans;
+ SwfdecColorTransform ctrans;
+ guint id;
+ SwfdecGraphic *graphic;
+
+ dec = SWFDEC_SWF_DECODER (mov->resource->decoder);
+
+ SWFDEC_LOG ("performing PlaceObject on movie %s", mov->name);
+
+ id = swfdec_bits_get_u16 (bits);
+ SWFDEC_LOG (" id = %d", id);
+
+ depth = swfdec_bits_get_u16 (bits);
+ if (depth >= 16384) {
+ SWFDEC_FIXME ("depth of placement too high: %u >= 16384", depth);
+ }
+ SWFDEC_LOG (" depth = %d (=> %d)", depth, depth - 16384);
+ depth -= 16384;
+
+ swfdec_bits_get_matrix (bits, &transform, NULL);
+ SWFDEC_LOG (" matrix = { %g %g, %g %g } + { %g %g }",
+ transform.xx, transform.yx,
+ transform.xy, transform.yy,
+ transform.x0, transform.y0);
+
+ if (swfdec_bits_left (bits)) {
+ has_ctrans = TRUE;
+ swfdec_bits_get_color_transform (bits, &ctrans);
+ SWFDEC_LOG (" color transform = %d %d %d %d %d %d %d %d",
+ ctrans.ra, ctrans.rb,
+ ctrans.ga, ctrans.gb,
+ ctrans.ba, ctrans.bb,
+ ctrans.aa, ctrans.ab);
+ } else {
+ has_ctrans = FALSE;
+ }
+
+ /* 3) perform the actions depending on the set properties */
+ cur = swfdec_movie_find (mov, depth);
+ graphic = swfdec_swf_decoder_get_character (dec, id);
+
+ if (!SWFDEC_IS_GRAPHIC (graphic)) {
+ SWFDEC_FIXME ("character %u is not a graphic (does it even exist?), aborting", id);
+ return FALSE;
+ }
+
+ cur = swfdec_movie_new (player, depth, mov, mov->resource, graphic, NULL);
+ swfdec_movie_set_static_properties (cur, &transform,
+ has_ctrans ? &ctrans : NULL, -1, 0, 0, NULL);
+ swfdec_movie_queue_script (cur, SWFDEC_EVENT_INITIALIZE);
+ swfdec_movie_queue_script (cur, SWFDEC_EVENT_CONSTRUCT);
+ swfdec_movie_queue_script (cur, SWFDEC_EVENT_LOAD);
+ swfdec_movie_initialize (cur);
+
+ return TRUE;
+}
+
+
+static gboolean
+swfdec_sprite_movie_perform_place (SwfdecSpriteMovie *movie, SwfdecBits *bits, guint tag)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
+ SwfdecMovie *mov = SWFDEC_MOVIE (movie);
+ SwfdecMovie *cur;
+ SwfdecSwfDecoder *dec;
+ gboolean has_clip_actions;
+ gboolean has_clip_depth;
+ gboolean has_name;
+ gboolean has_ratio;
+ gboolean has_ctrans;
+ gboolean has_transform;
+ gboolean has_character;
+ gboolean move;
+ int depth;
+ gboolean cache;
+ gboolean has_blend_mode = 0;
+ gboolean has_filter = 0;
+ int clip_depth;
+ cairo_matrix_t transform;
+ SwfdecColorTransform ctrans;
+ guint ratio, id, version;
+ SwfdecEventList *events;
+ const char *name;
+ guint blend_mode;
+ SwfdecGraphic *graphic;
+
+ dec = SWFDEC_SWF_DECODER (mov->resource->decoder);
+ version = dec->version;
+
+ /* 1) check which stuff is set */
+ has_clip_actions = swfdec_bits_getbit (bits);
+ has_clip_depth = swfdec_bits_getbit (bits);
+ has_name = swfdec_bits_getbit (bits);
+ has_ratio = swfdec_bits_getbit (bits);
+ has_ctrans = swfdec_bits_getbit (bits);
+ has_transform = swfdec_bits_getbit (bits);
+ has_character = swfdec_bits_getbit (bits);
+ move = swfdec_bits_getbit (bits);
+
+ SWFDEC_LOG ("performing PlaceObject%d on movie %s", tag == SWFDEC_TAG_PLACEOBJECT2 ? 2 : 3, mov->name);
+ SWFDEC_LOG (" has_clip_actions = %d", has_clip_actions);
+ SWFDEC_LOG (" has_clip_depth = %d", has_clip_depth);
+ SWFDEC_LOG (" has_name = %d", has_name);
+ SWFDEC_LOG (" has_ratio = %d", has_ratio);
+ SWFDEC_LOG (" has_ctrans = %d", has_ctrans);
+ SWFDEC_LOG (" has_transform = %d", has_transform);
+ SWFDEC_LOG (" has_character = %d", has_character);
+ SWFDEC_LOG (" move = %d", move);
+
+ if (tag == SWFDEC_TAG_PLACEOBJECT3) {
+ swfdec_bits_getbits (bits, 5);
+ cache = swfdec_bits_getbit (bits);
+ has_blend_mode = swfdec_bits_getbit (bits);
+ has_filter = swfdec_bits_getbit (bits);
+ SWFDEC_LOG (" cache = %d", cache);
+ SWFDEC_LOG (" has filter = %d", has_filter);
+ SWFDEC_LOG (" has blend mode = %d", has_blend_mode);
+ }
+
+ /* 2) read all properties */
+ depth = swfdec_bits_get_u16 (bits);
+ if (depth >= 16384) {
+ SWFDEC_FIXME ("depth of placement too high: %u >= 16384", depth);
+ }
+ SWFDEC_LOG (" depth = %d (=> %d)", depth, depth - 16384);
+ depth -= 16384;
+ if (has_character) {
+ id = swfdec_bits_get_u16 (bits);
+ SWFDEC_LOG (" id = %d", id);
+ } else {
+ id = 0;
+ }
+
+ if (has_transform) {
+ swfdec_bits_get_matrix (bits, &transform, NULL);
+ SWFDEC_LOG (" matrix = { %g %g, %g %g } + { %g %g }",
+ transform.xx, transform.yx,
+ transform.xy, transform.yy,
+ transform.x0, transform.y0);
+ }
+ if (has_ctrans) {
+ swfdec_bits_get_color_transform (bits, &ctrans);
+ SWFDEC_LOG (" color transform = %d %d %d %d %d %d %d %d",
+ ctrans.ra, ctrans.rb,
+ ctrans.ga, ctrans.gb,
+ ctrans.ba, ctrans.bb,
+ ctrans.aa, ctrans.ab);
+ }
+
+ if (has_ratio) {
+ ratio = swfdec_bits_get_u16 (bits);
+ SWFDEC_LOG (" ratio = %d", ratio);
+ } else {
+ ratio = -1;
+ }
+
+ if (has_name) {
+ char *s = swfdec_bits_get_string (bits, version);
+ name = swfdec_as_context_give_string (SWFDEC_AS_CONTEXT (player), s);
+ SWFDEC_LOG (" name = %s", name);
+ } else {
+ name = NULL;
+ }
+
+ if (has_clip_depth) {
+ clip_depth = swfdec_bits_get_u16 (bits) - 16384;
+ SWFDEC_LOG (" clip_depth = %d (=> %d)", clip_depth + 16384, clip_depth);
+ } else {
+ clip_depth = 0;
+ }
+
+ if (has_filter) {
+ GSList *filters = swfdec_filter_parse (player, bits);
+ g_slist_free (filters);
+ }
+
+ if (has_blend_mode) {
+ blend_mode = swfdec_bits_get_u8 (bits);
+ SWFDEC_LOG (" blend mode = %u", blend_mode);
+ } else {
+ blend_mode = 0;
+ }
+
+ if (has_clip_actions) {
+ int reserved, clip_event_flags, event_flags, key_code;
+ char *script_name;
+
+ events = swfdec_event_list_new (player);
+ reserved = swfdec_bits_get_u16 (bits);
+ clip_event_flags = swfdec_get_clipeventflags (mov, bits);
+
+ if (name)
+ script_name = g_strdup (name);
+ else if (id)
+ script_name = g_strdup_printf ("Sprite%u", id);
+ else
+ script_name = g_strdup ("unknown");
+ while ((event_flags = swfdec_get_clipeventflags (mov, bits)) != 0) {
+ guint length = swfdec_bits_get_u32 (bits);
+ SwfdecBits action_bits;
+
+ swfdec_bits_init_bits (&action_bits, bits, length);
+ if (event_flags & (1<<SWFDEC_EVENT_KEY_PRESS))
+ key_code = swfdec_bits_get_u8 (&action_bits);
+ else
+ key_code = 0;
+
+ SWFDEC_INFO ("clip event with flags 0x%X, key code %d", event_flags, key_code);
+#define SWFDEC_UNIMPLEMENTED_EVENTS \
+ ((1<< SWFDEC_EVENT_DATA) | (1<<SWFDEC_EVENT_KEY_PRESS))
+ if (event_flags & SWFDEC_UNIMPLEMENTED_EVENTS) {
+ SWFDEC_ERROR ("using non-implemented clip events %u", event_flags & SWFDEC_UNIMPLEMENTED_EVENTS);
+ }
+ swfdec_event_list_parse (events, &action_bits, version,
+ event_flags, key_code, script_name);
+ if (swfdec_bits_left (&action_bits)) {
+ SWFDEC_ERROR ("not all action data was parsed: %u bytes left",
+ swfdec_bits_left (&action_bits));
+ }
+ }
+ g_free (script_name);
+ } else {
+ events = NULL;
+ }
+
+ /* 3) perform the actions depending on the set properties */
+ cur = swfdec_movie_find (mov, depth);
+ graphic = swfdec_swf_decoder_get_character (dec, id);
+ if (move) {
+ if (cur == NULL) {
+ SWFDEC_INFO ("no movie at depth %d, ignoring move command", depth);
+ goto out;
+ }
+ if (graphic) {
+ SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (cur);
+ if (klass->replace)
+ klass->replace (cur, graphic);
+ }
+ swfdec_movie_set_static_properties (cur, has_transform ? &transform : NULL,
+ has_ctrans ? &ctrans : NULL, ratio, clip_depth, blend_mode, events);
+ } else {
+ if (cur != NULL && version > 5) {
+ SWFDEC_INFO ("depth %d is already occupied by movie %s, not placing", depth, cur->name);
+ goto out;
+ }
+ if (!SWFDEC_IS_GRAPHIC (graphic)) {
+ SWFDEC_FIXME ("character %u is not a graphic (does it even exist?), aborting", id);
+ if (events)
+ swfdec_event_list_free (events);
+ return FALSE;
+ }
+ cur = swfdec_movie_new (player, depth, mov, mov->resource, graphic, name);
+ swfdec_movie_set_static_properties (cur, has_transform ? &transform : NULL,
+ has_ctrans ? &ctrans : NULL, ratio, clip_depth, blend_mode, events);
+ swfdec_movie_queue_script (cur, SWFDEC_EVENT_INITIALIZE);
+ swfdec_movie_queue_script (cur, SWFDEC_EVENT_CONSTRUCT);
+ swfdec_movie_queue_script (cur, SWFDEC_EVENT_LOAD);
+ swfdec_movie_initialize (cur);
+ }
+
+out:
+ if (events)
+ swfdec_event_list_free (events);
+ return TRUE;
+}
+
+static void
+swfdec_sprite_movie_start_sound (SwfdecMovie *movie, SwfdecBits *bits)
+{
+ SwfdecSoundChunk *chunk;
+ int id;
+
+ id = swfdec_bits_get_u16 (bits);
+ chunk = swfdec_sound_parse_chunk (SWFDEC_SWF_DECODER (movie->resource->decoder), bits, id);
+ if (chunk) {
+ SwfdecAudio *audio = swfdec_audio_event_new_from_chunk (SWFDEC_PLAYER (
+ SWFDEC_AS_OBJECT (movie)->context), chunk);
+ if (audio)
+ g_object_unref (audio);
+ }
+}
+
+static gboolean
+swfdec_sprite_movie_perform_one_action (SwfdecSpriteMovie *movie, guint tag, SwfdecBuffer *buffer,
+ gboolean skip_scripts, gboolean first_time)
+{
+ SwfdecMovie *mov = SWFDEC_MOVIE (movie);
+ SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (mov)->context);
+ SwfdecBits bits;
+
+ g_assert (mov->resource);
+ swfdec_bits_init (&bits, buffer);
+
+ SWFDEC_LOG ("%p: executing %uth tag %s in frame %u", movie, movie->next_action - 1,
+ swfdec_swf_decoder_get_tag_name (tag), movie->frame);
+ switch (tag) {
+ case SWFDEC_TAG_DOACTION:
+ SWFDEC_LOG ("SCRIPT action");
+ if (!skip_scripts) {
+ SwfdecScript *script = swfdec_swf_decoder_get_script (
+ SWFDEC_SWF_DECODER (mov->resource->decoder), buffer->data);
+ g_assert (script);
+ swfdec_player_add_action_script (player, mov, script, 2);
+ }
+ return TRUE;
+ case SWFDEC_TAG_PLACEOBJECT:
+ return swfdec_sprite_movie_perform_old_place (movie, &bits, tag);
+ case SWFDEC_TAG_PLACEOBJECT2:
+ case SWFDEC_TAG_PLACEOBJECT3:
+ return swfdec_sprite_movie_perform_place (movie, &bits, tag);
+ case SWFDEC_TAG_REMOVEOBJECT:
+ /* yes, this code is meant to be like this - the following u16 is the
+ * character id, that we don't care about, the rest is like RemoveObject2
+ */
+ swfdec_bits_get_u16 (&bits);
+ /* fall through */
+ case SWFDEC_TAG_REMOVEOBJECT2:
+ {
+ int depth = swfdec_bits_get_u16 (&bits);
+ SWFDEC_LOG ("REMOVE action: depth %d => %d", depth, depth - 16384);
+ depth -= 16384;
+ if (!swfdec_sprite_movie_remove_child (mov, depth))
+ SWFDEC_INFO ("could not remove, no child at depth %d", depth);
+ }
+ return TRUE;
+ case SWFDEC_TAG_STARTSOUND:
+ swfdec_sprite_movie_start_sound (mov, &bits);
+ return TRUE;
+ case SWFDEC_TAG_SHOWFRAME:
+ if (movie->frame < movie->n_frames) {
+ movie->frame++;
+ } else {
+ SWFDEC_ERROR ("too many ShowFrame tags");
+ }
+ return FALSE;
+ case SWFDEC_TAG_EXPORTASSETS:
+ {
+ SwfdecResource *resource = swfdec_movie_get_own_resource (mov);
+ guint i, count;
+
+ g_assert (resource); /* must hold, ExportAssets can only be in root movies */
+ if (!first_time)
+ return TRUE;
+ count = swfdec_bits_get_u16 (&bits);
+ SWFDEC_LOG ("exporting %u assets", count);
+ for (i = 0; i < count && swfdec_bits_left (&bits); i++) {
+ SwfdecSwfDecoder *s = SWFDEC_SWF_DECODER (resource->decoder);
+ guint id;
+ SwfdecCharacter *object;
+ char *name;
+
+ id = swfdec_bits_get_u16 (&bits);
+ object = swfdec_swf_decoder_get_character (s, id);
+ name = swfdec_bits_get_string (&bits, s->version);
+ if (object == NULL) {
+ SWFDEC_ERROR ("cannot export id %u as %s, id wasn't found", id, name);
+ } else if (name == NULL) {
+ SWFDEC_ERROR ("cannot export id %u, no name was given", id);
+ } else {
+ SWFDEC_LOG ("exporting %s %u as %s", G_OBJECT_TYPE_NAME (object), id, name);
+ swfdec_resource_add_export (resource, object, name);
+ }
+ g_free (name);
+ }
+ }
+ return TRUE;
+ case SWFDEC_TAG_DOINITACTION:
+ if (!first_time)
+ return TRUE;
+ if (!swfdec_movie_get_own_resource (mov)) {
+ SWFDEC_FIXME ("behavior of init actions in DefineSprite untested");
+ }
+ {
+ guint id;
+ SwfdecSprite *sprite;
+ char *name;
+
+ id = swfdec_bits_get_u16 (&bits);
+ SWFDEC_LOG ("InitAction");
+ SWFDEC_LOG (" id = %u", id);
+ sprite = swfdec_swf_decoder_get_character (SWFDEC_SWF_DECODER (mov->resource->decoder), id);
+ if (!SWFDEC_IS_SPRITE (sprite)) {
+ SWFDEC_ERROR ("character %u is not a sprite", id);
+ return TRUE;
+ }
+ if (sprite->init_action != NULL) {
+ SWFDEC_ERROR ("sprite %u already has an init action", id);
+ return TRUE;
+ }
+ name = g_strdup_printf ("InitAction %u", id);
+ sprite->init_action = swfdec_script_new_from_bits (&bits, name,
+ swfdec_movie_get_version (mov));
+ g_free (name);
+ if (sprite->init_action) {
+ swfdec_player_add_action_script (player, mov, sprite->init_action, 0);
+ }
+ }
+ return TRUE;
+ default:
+ g_assert_not_reached ();
+ return FALSE;
+ }
+}
+
+static gboolean
+swfdec_movie_is_compatible (SwfdecMovie *movie, SwfdecMovie *with)
+{
+ g_assert (movie->depth == with->depth);
+
+ if (movie->original_ratio != with->original_ratio)
+ return FALSE;
+
+ if (G_OBJECT_TYPE (movie) != G_OBJECT_TYPE (with))
+ return FALSE;
+
+ return TRUE;
+}
+
+static GList *
+my_g_list_split (GList *list, GList *split)
+{
+ GList *prev;
+
+ if (split == NULL)
+ return list;
+
+ prev = split->prev;
+ if (prev == NULL)
+ return NULL;
+ prev->next = NULL;
+ split->prev = NULL;
+ return list;
+}
+
+void
+swfdec_sprite_movie_goto (SwfdecSpriteMovie *movie, guint goto_frame)
+{
+ SwfdecMovie *mov;
+ SwfdecPlayer *player;
+ GList *old;
+ guint n;
+
+ g_return_if_fail (SWFDEC_IS_SPRITE_MOVIE (movie));
+
+ mov = SWFDEC_MOVIE (movie);
+ /* lots of things where we've got nothing to do */
+ if (goto_frame == 0 || goto_frame > movie->n_frames ||
+ movie->sprite == NULL || mov->state >= SWFDEC_MOVIE_STATE_REMOVED || goto_frame == movie->frame)
+ return;
+
+ if (goto_frame > movie->sprite->parse_frame) {
+ SWFDEC_WARNING ("jumping to not-yet-loaded frame %u (loaded: %u/%u)",
+ goto_frame, movie->sprite->parse_frame, movie->sprite->n_frames);
+ return;
+ }
+
+ player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
+ SWFDEC_LOG ("doing goto %u for %p %d", goto_frame, movie,
+ SWFDEC_CHARACTER (movie->sprite)->id);
+
+ SWFDEC_DEBUG ("performing goto %u -> %u for character %u",
+ movie->frame, goto_frame, SWFDEC_CHARACTER (movie->sprite)->id);
+ if (goto_frame < movie->frame) {
+ GList *walk;
+ movie->frame = 0;
+ for (walk = mov->list; walk &&
+ swfdec_depth_classify (SWFDEC_MOVIE (walk->data)->depth) != SWFDEC_DEPTH_CLASS_TIMELINE;
+ walk = walk->next) {
+ /* do nothing */
+ }
+ old = walk;
+ mov->list = my_g_list_split (mov->list, old);
+ for (walk = old; walk &&
+ swfdec_depth_classify (SWFDEC_MOVIE (walk->data)->depth) == SWFDEC_DEPTH_CLASS_TIMELINE;
+ walk = walk->next) {
+ /* do nothing */
+ }
+ old = my_g_list_split (old, walk);
+ mov->list = g_list_concat (mov->list, walk);
+ n = goto_frame;
+ movie->next_action = 0;
+ } else {
+ /* NB: this path is also taken on init */
+ old = NULL;
+ n = goto_frame - movie->frame;
+ }
+ while (n) {
+ guint tag;
+ gboolean first_time;
+ SwfdecBuffer *buffer;
+ if (!swfdec_sprite_get_action (movie->sprite, movie->next_action, &tag, &buffer))
+ break;
+ movie->next_action++;
+ if (movie->next_action > movie->max_action) {
+ first_time = TRUE;
+ movie->max_action = movie->next_action;
+ } else {
+ first_time = FALSE;
+ }
+ if (!swfdec_sprite_movie_perform_one_action (movie, tag, buffer, n > 1, first_time))
+ n--;
+ }
+ /* now try to copy eventual movies */
+ if (old) {
+ SwfdecMovie *prev, *cur;
+ GList *old_walk, *walk;
+ walk = mov->list;
+ old_walk = old;
+ if (!walk)
+ goto out;
+ cur = walk->data;
+ for (; old_walk; old_walk = old_walk->next) {
+ prev = old_walk->data;
+ while (cur->depth < prev->depth) {
+ walk = walk->next;
+ if (!walk)
+ goto out;
+ cur = walk->data;
+ }
+ if (cur->depth == prev->depth &&
+ swfdec_movie_is_compatible (prev, cur)) {
+ SwfdecMovieClass *klass = SWFDEC_MOVIE_GET_CLASS (prev);
+ walk->data = prev;
+ /* FIXME: This merging stuff probably needs to be improved a _lot_ */
+ if (klass->replace)
+ klass->replace (prev, cur->graphic);
+ swfdec_movie_set_static_properties (prev, &cur->original_transform,
+ &cur->original_ctrans, cur->original_ratio, cur->clip_depth,
+ cur->blend_mode, cur->events);
+ swfdec_movie_destroy (cur);
+ cur = prev;
+ continue;
+ }
+ swfdec_movie_remove (prev);
+ }
+out:
+ for (; old_walk; old_walk = old_walk->next) {
+ swfdec_movie_remove (old_walk->data);
+ }
+ g_list_free (old);
+ }
+}
+
+/*** MOVIE ***/
+
+G_DEFINE_TYPE (SwfdecSpriteMovie, swfdec_sprite_movie, SWFDEC_TYPE_MOVIE)
+
+static void
+swfdec_sprite_movie_dispose (GObject *object)
+{
+ SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (object);
+
+ g_assert (movie->sound_stream == NULL);
+
+ G_OBJECT_CLASS (swfdec_sprite_movie_parent_class)->dispose (object);
+}
+
+static void
+swfdec_sprite_movie_init_movie (SwfdecMovie *mov)
+{
+ SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov);
+
+ g_assert (movie->frame == (guint) -1);
+ movie->frame = 0;
+ swfdec_sprite_movie_goto (movie, 1);
+}
+
+static void
+swfdec_sprite_movie_add (SwfdecAsObject *object)
+{
+ SwfdecMovie *movie = SWFDEC_MOVIE (object);
+
+ if (movie->resource->sandbox)
+ swfdec_as_object_set_constructor (object, movie->resource->sandbox->MovieClip);
+
+ SWFDEC_AS_OBJECT_CLASS (swfdec_sprite_movie_parent_class)->add (object);
+}
+
+static void
+swfdec_sprite_movie_iterate (SwfdecMovie *mov)
+{
+ SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov);
+ SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (mov)->context);
+ guint goto_frame;
+
+ if (mov->state >= SWFDEC_MOVIE_STATE_REMOVED)
+ return;
+
+ if (movie->sprite && movie->frame == (guint) -1)
+ movie->frame = 0;
+
+ swfdec_player_add_action (player, mov, SWFDEC_EVENT_ENTER, 2);
+ if (movie->playing && movie->sprite != NULL) {
+ if (movie->frame == movie->n_frames)
+ goto_frame = 1;
+ else if (movie->sprite && movie->frame == movie->sprite->parse_frame)
+ goto_frame = movie->frame;
+ else
+ goto_frame = movie->frame + 1;
+ swfdec_sprite_movie_goto (movie, goto_frame);
+ }
+}
+
+/* FIXME: This function is a mess */
+static gboolean
+swfdec_sprite_movie_iterate_end (SwfdecMovie *mov)
+{
+ SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov);
+ SwfdecSpriteFrame *last;
+ SwfdecSpriteFrame *current;
+ SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (mov)->context);
+
+ if (!SWFDEC_MOVIE_CLASS (swfdec_sprite_movie_parent_class)->iterate_end (mov)) {
+ g_assert (movie->sound_stream == NULL);
+ return FALSE;
+ }
+
+ if (movie->sprite == NULL)
+ return TRUE;
+ g_assert (movie->frame <= movie->n_frames);
+ if (movie->frame == 0)
+ return TRUE;
+ current = &movie->sprite->frames[movie->frame - 1];
+
+ /* then do the streaming thing */
+ if (current->sound_head == NULL ||
+ !movie->playing) {
+ if (movie->sound_stream) {
+ swfdec_audio_remove (movie->sound_stream);
+ g_object_unref (movie->sound_stream);
+ movie->sound_stream = NULL;
+ }
+ goto exit;
+ }
+ if (movie->sound_stream == NULL && current->sound_block == NULL)
+ goto exit;
+ SWFDEC_LOG ("iterating audio (from %u to %u)", movie->sound_frame, movie->frame);
+ if (movie->sound_frame + 1 != movie->frame)
+ goto new_decoder;
+ if (movie->sound_frame == (guint) -1)
+ goto new_decoder;
+ if (current->sound_head && movie->sound_stream == NULL)
+ goto new_decoder;
+ last = &movie->sprite->frames[movie->sound_frame];
+ if (last->sound_head != current->sound_head)
+ goto new_decoder;
+exit:
+ movie->sound_frame = movie->frame;
+ return TRUE;
+
+new_decoder:
+ if (movie->sound_stream) {
+ swfdec_audio_remove (movie->sound_stream);
+ g_object_unref (movie->sound_stream);
+ movie->sound_stream = NULL;
+ }
+
+ if (current->sound_block) {
+ movie->sound_stream = swfdec_audio_stream_new (player,
+ movie->sprite, movie->frame - 1);
+ movie->sound_frame = movie->frame;
+ }
+ return TRUE;
+}
+
+static void
+swfdec_sprite_movie_finish_movie (SwfdecMovie *mov)
+{
+ SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov);
+ SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (mov)->context);
+
+ swfdec_player_remove_all_actions (player, mov);
+ if (movie->sound_stream) {
+ swfdec_audio_remove (movie->sound_stream);
+ g_object_unref (movie->sound_stream);
+ movie->sound_stream = NULL;
+ }
+}
+
+static void
+swfdec_sprite_movie_mark (SwfdecAsObject *object)
+{
+ GList *walk;
+
+ for (walk = SWFDEC_MOVIE (object)->list; walk; walk = walk->next) {
+ SwfdecAsObject *child = walk->data;
+ g_assert (child->properties != NULL);
+ swfdec_as_object_mark (child);
+ }
+
+ SWFDEC_AS_OBJECT_CLASS (swfdec_sprite_movie_parent_class)->mark (object);
+}
+
+static void
+swfdec_sprite_movie_class_init (SwfdecSpriteMovieClass * g_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+ SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (g_class);
+ SwfdecMovieClass *movie_class = SWFDEC_MOVIE_CLASS (g_class);
+
+ object_class->dispose = swfdec_sprite_movie_dispose;
+
+ asobject_class->add = swfdec_sprite_movie_add;
+ asobject_class->mark = swfdec_sprite_movie_mark;
+
+ movie_class->init_movie = swfdec_sprite_movie_init_movie;
+ movie_class->finish_movie = swfdec_sprite_movie_finish_movie;
+ movie_class->iterate_start = swfdec_sprite_movie_iterate;
+ movie_class->iterate_end = swfdec_sprite_movie_iterate_end;
+}
+
+static void
+swfdec_sprite_movie_init (SwfdecSpriteMovie * movie)
+{
+ movie->playing = TRUE;
+ movie->frame = (guint) -1;
+}
+
+/* cute little hack */
+extern void
+swfdec_sprite_movie_clear (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval);
+/**
+ * swfdec_sprite_movie_unload:
+ * @movie: a #SwfdecMovie
+ *
+ * Clears all contents from the given movie. This means deleting all
+ * variables and removing all children movie clips.
+ **/
+void
+swfdec_sprite_movie_unload (SwfdecSpriteMovie *movie)
+{
+ SwfdecMovie *mov;
+ SwfdecAsValue hack;
+
+ g_return_if_fail (SWFDEC_IS_SPRITE_MOVIE (movie));
+
+ mov = SWFDEC_MOVIE (movie);
+ swfdec_sprite_movie_clear (SWFDEC_AS_OBJECT (movie)->context,
+ SWFDEC_AS_OBJECT (movie), 0, NULL, &hack);
+ /* FIXME: destroy or unload? */
+ while (mov->list)
+ swfdec_movie_remove (mov->list->data);
+ swfdec_as_object_delete_all_variables (SWFDEC_AS_OBJECT (movie));
+ movie->frame = (guint) -1;
+ movie->n_frames = 0;
+ movie->next_action = 0;
+ movie->max_action = 0;
+ movie->sprite = NULL;
+ swfdec_movie_queue_update (SWFDEC_MOVIE (movie), SWFDEC_MOVIE_INVALID_EXTENTS);
+}
+
+/**
+ * swfdec_sprite_movie_get_frames_loaded:
+ * @movie: a #SwfdecSpriteMovie
+ *
+ * Computes the number of loaded frames as used by the _framesloaded property
+ * or the WaitForFrame actions. If the @movie is fully loaded, this is the
+ * amount of total frames of the sprite it displays, or 0 if it has no sprite.
+ * If the movie is not fully loaded, it is the amount of frames that are
+ * completely loaded minus one. Welcome to the world of Flash.
+ *
+ * Returns: The number of loaded frames as reported by ActionScript.
+ **/
+int
+swfdec_sprite_movie_get_frames_loaded (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) {
+ /* FIXME: can we set n_frames to 1 for movies without sprites instead? */
+ if (movie->sprite)
+ return movie->n_frames;
+ else
+ 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;
+}
+
+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) {
+ /* FIXME: can we set n_frames to 1 for movies without sprites instead? */
+ if (movie->sprite)
+ return movie->n_frames;
+ else
+ return 1;
+ }
+ dec = resource->decoder;
+ if (dec == NULL)
+ return 0;
+ return dec->frames_total;
+}
diff --git a/swfdec/swfdec_sprite_movie.h b/swfdec/swfdec_sprite_movie.h
new file mode 100644
index 0000000..093154d
--- /dev/null
+++ b/swfdec/swfdec_sprite_movie.h
@@ -0,0 +1,76 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_SPRITE_MOVIE_H_
+#define _SWFDEC_SPRITE_MOVIE_H_
+
+#include <libswfdec/swfdec_movie.h>
+#include <libswfdec/swfdec_audio.h>
+#include <libswfdec/swfdec_types.h>
+
+G_BEGIN_DECLS
+
+
+//typedef struct _SwfdecSpriteMovie SwfdecSpriteMovie;
+typedef struct _SwfdecSpriteMovieClass SwfdecSpriteMovieClass;
+
+#define SWFDEC_TYPE_SPRITE_MOVIE (swfdec_sprite_movie_get_type())
+#define SWFDEC_IS_SPRITE_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SPRITE_MOVIE))
+#define SWFDEC_IS_SPRITE_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SPRITE_MOVIE))
+#define SWFDEC_SPRITE_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SPRITE_MOVIE, SwfdecSpriteMovie))
+#define SWFDEC_SPRITE_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SPRITE_MOVIE, SwfdecSpriteMovieClass))
+
+struct _SwfdecSpriteMovie
+{
+ SwfdecMovie movie;
+
+ SwfdecSprite * sprite; /* displayed sprite */
+
+ /* frame information */
+ guint next_action; /* next action in sprite to perform */
+ guint max_action; /* next action in sprite tthat has never ben executed (used to detect first-time execution) */
+ guint frame; /* current frame or -1 if none */
+ guint n_frames; /* amount of frames */
+ gboolean playing; /* TRUE if the movie automatically advances */
+
+ /* color information */
+ SwfdecColor bg_color; /* background color (only used on main sprite) */
+
+ /* audio stream handling */
+ guint sound_frame; /* current sound frame */
+ SwfdecAudio * sound_stream; /* stream that currently plays */
+};
+
+struct _SwfdecSpriteMovieClass
+{
+ SwfdecMovieClass movie_class;
+};
+
+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);
+void swfdec_sprite_movie_unload (SwfdecSpriteMovie * movie);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_sprite_movie_as.c b/swfdec/swfdec_sprite_movie_as.c
new file mode 100644
index 0000000..03f2a21
--- /dev/null
+++ b/swfdec/swfdec_sprite_movie_as.c
@@ -0,0 +1,891 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_movie.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_bits.h"
+#include "swfdec_debug.h"
+#include "swfdec_decoder.h"
+#include "swfdec_internal.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_sprite.h"
+#include "swfdec_sprite_movie.h"
+#include "swfdec_swf_decoder.h"
+#include "swfdec_resource.h"
+#include "swfdec_utils.h"
+#include "swfdec_as_internal.h"
+
+SWFDEC_AS_NATIVE (900, 200, swfdec_sprite_movie_get_tabIndex)
+void
+swfdec_sprite_movie_get_tabIndex (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.tabIndex (get)");
+}
+
+SWFDEC_AS_NATIVE (900, 201, swfdec_sprite_movie_set_tabIndex)
+void
+swfdec_sprite_movie_set_tabIndex (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.tabIndex (set)");
+}
+
+SWFDEC_AS_NATIVE (900, 300, swfdec_sprite_movie_get__lockroot)
+void
+swfdec_sprite_movie_get__lockroot (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip._lockroot (get)");
+}
+
+SWFDEC_AS_NATIVE (900, 301, swfdec_sprite_movie_set__lockroot)
+void
+swfdec_sprite_movie_set__lockroot (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip._lockroot (set)");
+}
+
+SWFDEC_AS_NATIVE (900, 401, swfdec_sprite_movie_get_cacheAsBitmap)
+void
+swfdec_sprite_movie_get_cacheAsBitmap (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.cacheAsBitmap (get)");
+}
+
+SWFDEC_AS_NATIVE (900, 402, swfdec_sprite_movie_set_cacheAsBitmap)
+void
+swfdec_sprite_movie_set_cacheAsBitmap (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.cacheAsBitmap (set)");
+}
+
+SWFDEC_AS_NATIVE (900, 403, swfdec_sprite_movie_get_opaqueBackground)
+void
+swfdec_sprite_movie_get_opaqueBackground (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.opaqueBackground (get)");
+}
+
+SWFDEC_AS_NATIVE (900, 404, swfdec_sprite_movie_set_opaqueBackground)
+void
+swfdec_sprite_movie_set_opaqueBackground (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.opaqueBackground (set)");
+}
+
+SWFDEC_AS_NATIVE (900, 405, swfdec_sprite_movie_get_scrollRect)
+void
+swfdec_sprite_movie_get_scrollRect (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.scrollRect (get)");
+}
+
+SWFDEC_AS_NATIVE (900, 406, swfdec_sprite_movie_set_scrollRect)
+void
+swfdec_sprite_movie_set_scrollRect (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.scrollRect (set)");
+}
+
+SWFDEC_AS_NATIVE (900, 417, swfdec_sprite_movie_get_filters)
+void
+swfdec_sprite_movie_get_filters (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.filters (get)");
+}
+
+SWFDEC_AS_NATIVE (900, 418, swfdec_sprite_movie_set_filters)
+void
+swfdec_sprite_movie_set_filters (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.filters (set)");
+}
+
+SWFDEC_AS_NATIVE (900, 419, swfdec_sprite_movie_get_transform)
+void
+swfdec_sprite_movie_get_transform (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.transform (get)");
+}
+
+SWFDEC_AS_NATIVE (900, 420, swfdec_sprite_movie_set_transform)
+void
+swfdec_sprite_movie_set_transform (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.transform (set)");
+}
+
+static const char *blend_mode_names[] = {
+ SWFDEC_AS_STR_normal,
+ SWFDEC_AS_STR_layer,
+ SWFDEC_AS_STR_multiply,
+ SWFDEC_AS_STR_screen,
+ SWFDEC_AS_STR_lighten,
+ SWFDEC_AS_STR_darken,
+ SWFDEC_AS_STR_difference,
+ SWFDEC_AS_STR_add,
+ SWFDEC_AS_STR_subtract,
+ SWFDEC_AS_STR_invert,
+ SWFDEC_AS_STR_alpha,
+ SWFDEC_AS_STR_erase,
+ SWFDEC_AS_STR_overlay,
+ SWFDEC_AS_STR_hardlight
+};
+static const gsize num_blend_mode_names =
+ sizeof (blend_mode_names) / sizeof (blend_mode_names[0]);
+
+SWFDEC_AS_NATIVE (900, 500, swfdec_sprite_movie_get_blendMode)
+void
+swfdec_sprite_movie_get_blendMode (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "");
+
+ if (movie->blend_mode > 0 && movie->blend_mode <= num_blend_mode_names)
+ SWFDEC_AS_VALUE_SET_STRING (rval, blend_mode_names[movie->blend_mode - 1]);
+}
+
+SWFDEC_AS_NATIVE (900, 501, swfdec_sprite_movie_set_blendMode)
+void
+swfdec_sprite_movie_set_blendMode (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+ SwfdecAsValue val;
+ const char *str;
+ int blend_mode;
+ gsize i;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "v", &val);
+
+ if (SWFDEC_AS_VALUE_IS_NUMBER (&val)) {
+ blend_mode = SWFDEC_AS_VALUE_GET_NUMBER (&val);
+ } else if (SWFDEC_AS_VALUE_IS_STRING (&val)) {
+ blend_mode = 0;
+ str = SWFDEC_AS_VALUE_GET_STRING (&val);
+ for (i = 0; i < num_blend_mode_names; i++) {
+ if (str == blend_mode_names[i]) { // case-sensitive
+ blend_mode = i + 1;
+ break;
+ }
+ }
+ } else if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
+ blend_mode = 0;
+ } else {
+ blend_mode = 1;
+ }
+
+ if ((guint)blend_mode != movie->blend_mode) {
+ movie->blend_mode = blend_mode;
+ swfdec_movie_invalidate_last (movie);
+ }
+}
+
+SWFDEC_AS_NATIVE (900, 2, swfdec_sprite_movie_localToGlobal)
+void
+swfdec_sprite_movie_localToGlobal (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+ SwfdecAsObject *o;
+ SwfdecAsValue *xv, *yv;
+ double x, y;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "O", &o);
+
+ xv = swfdec_as_object_peek_variable (o, SWFDEC_AS_STR_x);
+ if (xv == NULL || !SWFDEC_AS_VALUE_IS_NUMBER (xv))
+ return;
+ yv = swfdec_as_object_peek_variable (o, SWFDEC_AS_STR_y);
+ if (yv == NULL || !SWFDEC_AS_VALUE_IS_NUMBER (yv))
+ return;
+
+ x = SWFDEC_AS_VALUE_GET_NUMBER (xv);
+ y = SWFDEC_AS_VALUE_GET_NUMBER (yv);
+ x = swfdec_as_double_to_integer (x * SWFDEC_TWIPS_SCALE_FACTOR);
+ y = swfdec_as_double_to_integer (y * SWFDEC_TWIPS_SCALE_FACTOR);
+ swfdec_movie_local_to_global (movie, &x, &y);
+ SWFDEC_AS_VALUE_SET_NUMBER (xv, SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) x));
+ SWFDEC_AS_VALUE_SET_NUMBER (yv, SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) y));
+}
+
+SWFDEC_AS_NATIVE (900, 3, swfdec_sprite_movie_globalToLocal)
+void
+swfdec_sprite_movie_globalToLocal (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+ SwfdecAsObject *o;
+ SwfdecAsValue *xv, *yv;
+ double x, y;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "O", &o);
+
+ xv = swfdec_as_object_peek_variable (o, SWFDEC_AS_STR_x);
+ if (xv == NULL || !SWFDEC_AS_VALUE_IS_NUMBER (xv))
+ return;
+ yv = swfdec_as_object_peek_variable (o, SWFDEC_AS_STR_y);
+ if (yv == NULL || !SWFDEC_AS_VALUE_IS_NUMBER (yv))
+ return;
+
+ x = SWFDEC_AS_VALUE_GET_NUMBER (xv);
+ y = SWFDEC_AS_VALUE_GET_NUMBER (yv);
+ x = swfdec_as_double_to_integer (x * SWFDEC_TWIPS_SCALE_FACTOR);
+ y = swfdec_as_double_to_integer (y * SWFDEC_TWIPS_SCALE_FACTOR);
+ swfdec_movie_global_to_local (movie, &x, &y);
+ SWFDEC_AS_VALUE_SET_NUMBER (xv, SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) x));
+ SWFDEC_AS_VALUE_SET_NUMBER (yv, SWFDEC_TWIPS_TO_DOUBLE ((SwfdecTwips) y));
+}
+
+SWFDEC_AS_NATIVE (900, 8, swfdec_sprite_movie_attachAudio)
+void
+swfdec_sprite_movie_attachAudio (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.attachAudio");
+}
+
+SWFDEC_AS_NATIVE (900, 9, swfdec_sprite_movie_attachVideo)
+void
+swfdec_sprite_movie_attachVideo (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.attachVideo");
+}
+
+SWFDEC_AS_NATIVE (900, 23, swfdec_sprite_movie_getInstanceAtDepth)
+void
+swfdec_sprite_movie_getInstanceAtDepth (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+ int depth;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "i", &depth);
+
+ // special case
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
+ return;
+
+ movie = swfdec_movie_find (movie, depth);
+ if (movie != NULL)
+ SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (movie));
+}
+
+SWFDEC_AS_NATIVE (900, 24, swfdec_sprite_movie_getSWFVersion)
+void
+swfdec_sprite_movie_getSWFVersion (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ if (object != NULL && SWFDEC_IS_MOVIE (object)) {
+ SWFDEC_AS_VALUE_SET_INT (rval,
+ swfdec_movie_get_version (SWFDEC_MOVIE (object)));
+ } else {
+ SWFDEC_AS_VALUE_SET_INT (rval, -1);
+ }
+}
+
+SWFDEC_AS_NATIVE (900, 25, swfdec_sprite_movie_attachBitmap)
+void
+swfdec_sprite_movie_attachBitmap (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.attachBitmap");
+}
+
+SWFDEC_AS_NATIVE (900, 26, swfdec_sprite_movie_getRect)
+void
+swfdec_sprite_movie_getRect (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("MovieClip.getRect");
+}
+
+SWFDEC_AS_NATIVE (900, 12, swfdec_sprite_movie_play)
+void
+swfdec_sprite_movie_play (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecSpriteMovie *movie;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_SPRITE_MOVIE, (gpointer)&movie, "");
+
+ movie->playing = TRUE;
+}
+
+SWFDEC_AS_NATIVE (900, 13, swfdec_sprite_movie_stop)
+void
+swfdec_sprite_movie_stop (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecSpriteMovie *movie;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_SPRITE_MOVIE, (gpointer)&movie, "");
+
+ movie->playing = FALSE;
+}
+
+SWFDEC_AS_NATIVE (900, 7, swfdec_sprite_movie_getBytesLoaded)
+void
+swfdec_sprite_movie_getBytesLoaded (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+ SwfdecResource *resource;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
+
+ resource = swfdec_movie_get_own_resource (movie);
+ if (resource && resource->decoder) {
+ SWFDEC_AS_VALUE_SET_INT (rval, resource->decoder->bytes_loaded);
+ } else {
+ SWFDEC_AS_VALUE_SET_INT (rval, 0);
+ }
+}
+
+SWFDEC_AS_NATIVE (900, 6, swfdec_sprite_movie_getBytesTotal)
+void
+swfdec_sprite_movie_getBytesTotal (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+ SwfdecResource *resource;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
+
+ resource = swfdec_movie_get_own_resource (movie);
+ if (resource) {
+ if (resource->decoder) {
+ SWFDEC_AS_VALUE_SET_INT (rval, resource->decoder->bytes_total);
+ } else {
+ SWFDEC_AS_VALUE_SET_INT (rval, -1);
+ }
+ } else {
+ SWFDEC_AS_VALUE_SET_INT (rval, 0);
+ }
+}
+
+SWFDEC_AS_NATIVE (900, 22, swfdec_sprite_movie_getNextHighestDepth)
+void
+swfdec_sprite_movie_getNextHighestDepth (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+ int depth;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
+
+ if (movie->list) {
+ depth = SWFDEC_MOVIE (g_list_last (movie->list)->data)->depth + 1;
+ if (depth < 0)
+ depth = 0;
+ } else {
+ depth = 0;
+ }
+ SWFDEC_AS_VALUE_SET_INT (rval, depth);
+}
+
+static void
+swfdec_sprite_movie_do_goto (SwfdecSpriteMovie *movie, SwfdecAsValue *target)
+{
+ int frame;
+
+ g_return_if_fail (SWFDEC_IS_SPRITE_MOVIE (movie));
+ g_return_if_fail (SWFDEC_IS_AS_VALUE (target));
+
+ if (SWFDEC_AS_VALUE_IS_STRING (target)) {
+ const char *label = SWFDEC_AS_VALUE_GET_STRING (target);
+ frame = swfdec_sprite_get_frame (movie->sprite, label);
+ /* FIXME: nonexisting frames? */
+ if (frame == -1)
+ return;
+ frame++;
+ } else {
+ frame = swfdec_as_value_to_integer (SWFDEC_AS_OBJECT (movie)->context, target);
+ }
+ /* FIXME: how to handle overflow? */
+ frame = CLAMP (frame, 1, (int) movie->n_frames);
+
+ swfdec_sprite_movie_goto (movie, frame);
+}
+
+SWFDEC_AS_NATIVE (900, 16, swfdec_sprite_movie_gotoAndPlay)
+void
+swfdec_sprite_movie_gotoAndPlay (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecSpriteMovie *movie;
+ SwfdecAsValue val;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_SPRITE_MOVIE, (gpointer)&movie, "v", &val);
+
+ swfdec_sprite_movie_do_goto (movie, &val);
+ movie->playing = TRUE;
+}
+
+SWFDEC_AS_NATIVE (900, 17, swfdec_sprite_movie_gotoAndStop)
+void
+swfdec_sprite_movie_gotoAndStop (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecSpriteMovie *movie;
+ SwfdecAsValue val;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_SPRITE_MOVIE, (gpointer)&movie, "v", &val);
+
+ swfdec_sprite_movie_do_goto (movie, &val);
+ movie->playing = FALSE;
+}
+
+SWFDEC_AS_NATIVE (900, 14, swfdec_sprite_movie_nextFrame)
+void
+swfdec_sprite_movie_nextFrame (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecSpriteMovie *movie;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_SPRITE_MOVIE, (gpointer)&movie, "");
+
+ swfdec_sprite_movie_goto (movie, movie->frame + 1);
+ movie->playing = FALSE;
+}
+
+SWFDEC_AS_NATIVE (900, 15, swfdec_sprite_movie_prevFrame)
+void
+swfdec_sprite_movie_prevFrame (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecSpriteMovie *movie;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_SPRITE_MOVIE, (gpointer)&movie, "");
+
+ swfdec_sprite_movie_goto (movie, movie->frame - 1);
+ movie->playing = FALSE;
+}
+
+SWFDEC_AS_NATIVE (900, 4, swfdec_sprite_movie_hitTest)
+void
+swfdec_sprite_movie_hitTest (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
+
+ if (argc == 1) {
+ SwfdecMovie *other;
+ SwfdecRect movie_rect, other_rect;
+
+ other = swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx), &argv[0]);
+ if (other == NULL) {
+ SWFDEC_AS_VALUE_SET_BOOLEAN (rval, FALSE);
+ return;
+ }
+ swfdec_movie_update (movie);
+ swfdec_movie_update (other);
+ movie_rect = movie->extents;
+ if (movie->parent)
+ swfdec_movie_rect_local_to_global (movie->parent, &movie_rect);
+ other_rect = other->extents;
+ if (other->parent)
+ swfdec_movie_rect_local_to_global (other->parent, &other_rect);
+ SWFDEC_AS_VALUE_SET_BOOLEAN (rval, swfdec_rect_intersect (NULL, &movie_rect, &other_rect));
+ } else if (argc >= 2) {
+ double x, y;
+ gboolean shape, ret;
+
+ x = swfdec_as_value_to_number (cx, &argv[0]) * SWFDEC_TWIPS_SCALE_FACTOR;
+ y = swfdec_as_value_to_number (cx, &argv[1]) * SWFDEC_TWIPS_SCALE_FACTOR;
+ shape = (argc >= 3 && swfdec_as_value_to_boolean (cx, &argv[2]));
+
+ swfdec_movie_global_to_local (movie, &x, &y);
+
+ if (shape) {
+ ret = swfdec_movie_contains (movie, x, y);
+ } else {
+ ret = swfdec_rect_contains (&movie->original_extents, x, y);
+ }
+ SWFDEC_AS_VALUE_SET_BOOLEAN (rval, ret);
+ }
+}
+
+SWFDEC_AS_NATIVE (900, 20, swfdec_sprite_movie_startDrag)
+void
+swfdec_sprite_movie_startDrag (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+ gboolean center = FALSE;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
+
+ if (argc > 0) {
+ center = swfdec_as_value_to_boolean (cx, &argv[0]);
+ }
+ if (argc >= 5) {
+ SwfdecRect rect;
+ rect.x0 = swfdec_as_value_to_number (cx, &argv[1]);
+ rect.y0 = swfdec_as_value_to_number (cx, &argv[2]);
+ rect.x1 = swfdec_as_value_to_number (cx, &argv[3]);
+ rect.y1 = swfdec_as_value_to_number (cx, &argv[4]);
+ swfdec_rect_scale (&rect, &rect, SWFDEC_TWIPS_SCALE_FACTOR);
+ swfdec_player_set_drag_movie (player, movie, center, &rect);
+ } else {
+ swfdec_player_set_drag_movie (player, movie, center, NULL);
+ }
+}
+
+SWFDEC_AS_NATIVE (900, 21, swfdec_sprite_movie_stopDrag)
+void
+swfdec_sprite_movie_stopDrag (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ // FIXME: Should this work when called on non-movie objects or not?
+
+ swfdec_player_set_drag_movie (SWFDEC_PLAYER (cx), NULL, FALSE, NULL);
+}
+
+SWFDEC_AS_NATIVE (900, 1, swfdec_sprite_movie_swapDepths)
+void
+swfdec_sprite_movie_swapDepths (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+ SwfdecMovie *other;
+ int depth;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
+
+ if (argc < 1)
+ return;
+
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[0])) {
+ other = (SwfdecMovie *) SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
+ if (!SWFDEC_IS_MOVIE (other) ||
+ other->parent != movie->parent)
+ return;
+ depth = other->depth;
+ } else {
+ depth = swfdec_as_value_to_integer (cx, &argv[0]);
+ if (movie->parent) {
+ other = swfdec_movie_find (movie->parent, depth);
+ } else {
+ // special case: if root movie: we won't swap just, but just set depth
+ other = NULL;
+ }
+ }
+ if (other)
+ swfdec_movie_set_depth (other, movie->depth);
+ swfdec_movie_set_depth (movie, depth);
+}
+
+SWFDEC_AS_NATIVE (901, 0, swfdec_sprite_movie_createEmptyMovieClip)
+void
+swfdec_sprite_movie_createEmptyMovieClip (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie, *parent;
+ int depth;
+ const char *name;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &parent, "si", &name, &depth);
+
+ movie = swfdec_movie_find (parent, depth);
+ if (movie)
+ swfdec_movie_remove (movie);
+ movie = swfdec_movie_new (SWFDEC_PLAYER (cx), depth, parent, parent->resource, NULL, name);
+ swfdec_movie_initialize (movie);
+ SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (movie));
+}
+
+static void
+swfdec_sprite_movie_copy_props (SwfdecMovie *target, SwfdecMovie *src)
+{
+ swfdec_movie_queue_update (target, SWFDEC_MOVIE_INVALID_MATRIX);
+ target->matrix = src->matrix;
+ target->color_transform = src->color_transform;
+}
+
+static gboolean
+swfdec_sprite_movie_foreach_copy_properties (SwfdecAsObject *object,
+ const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
+{
+ SwfdecAsObject *target = data;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (target), FALSE);
+
+ swfdec_as_object_set_variable (target, variable, value);
+
+ return TRUE;
+}
+
+static void
+swfdec_sprite_movie_init_from_object (SwfdecMovie *movie,
+ SwfdecAsObject *initObject)
+{
+ g_return_if_fail (SWFDEC_IS_MOVIE (movie));
+ g_return_if_fail (initObject == NULL || SWFDEC_IS_AS_OBJECT (initObject));
+
+ if (initObject != NULL) {
+ swfdec_as_object_foreach (initObject,
+ swfdec_sprite_movie_foreach_copy_properties, SWFDEC_AS_OBJECT (movie));
+ }
+
+ if (SWFDEC_IS_SPRITE_MOVIE (movie)) {
+ SwfdecSandbox *sandbox = movie->resource->sandbox;
+ swfdec_movie_queue_script (movie, SWFDEC_EVENT_INITIALIZE);
+ swfdec_movie_queue_script (movie, SWFDEC_EVENT_LOAD);
+ swfdec_sandbox_unuse (sandbox);
+ swfdec_movie_initialize (movie);
+ swfdec_movie_execute (movie, SWFDEC_EVENT_CONSTRUCT);
+ swfdec_sandbox_use (sandbox);
+ } else {
+ swfdec_movie_initialize (movie);
+ }
+}
+
+SWFDEC_AS_NATIVE (900, 0, swfdec_sprite_movie_attachMovie)
+void
+swfdec_sprite_movie_attachMovie (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+ SwfdecMovie *ret;
+ SwfdecAsObject *initObject;
+ const char *name, *export;
+ int depth;
+ SwfdecGraphic *sprite;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "ssi", &export, &name, &depth);
+
+ if (argc > 3 && SWFDEC_AS_VALUE_IS_OBJECT (&argv[3])) {
+ initObject = SWFDEC_AS_VALUE_GET_OBJECT ((&argv[3]));
+ } else {
+ initObject = NULL;
+ }
+ sprite = swfdec_resource_get_export (movie->resource, export);
+ if (!SWFDEC_IS_SPRITE (sprite)) {
+ if (sprite == NULL) {
+ SWFDEC_WARNING ("no symbol with name %s exported", export);
+ } else {
+ SWFDEC_WARNING ("can only use attachMovie with sprites");
+ }
+ return;
+ }
+ if (swfdec_depth_classify (depth) == SWFDEC_DEPTH_CLASS_EMPTY)
+ return;
+ ret = swfdec_movie_find (movie, depth);
+ if (ret)
+ swfdec_movie_remove (ret);
+ ret = swfdec_movie_new (SWFDEC_PLAYER (object->context), depth, movie, movie->resource, sprite, name);
+ SWFDEC_LOG ("attached %s (%u) as %s to depth %u", export, SWFDEC_CHARACTER (sprite)->id,
+ ret->name, ret->depth);
+ /* run init and construct */
+ swfdec_sprite_movie_init_from_object (ret, initObject);
+ SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (ret));
+}
+
+SWFDEC_AS_NATIVE (900, 18, swfdec_sprite_movie_duplicateMovieClip)
+void
+swfdec_sprite_movie_duplicateMovieClip (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+ SwfdecMovie *new;
+ const char *name;
+ int depth;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "si", &name, &depth);
+
+ if (swfdec_depth_classify (depth) == SWFDEC_DEPTH_CLASS_EMPTY)
+ return;
+ new = swfdec_movie_duplicate (movie, name, depth);
+ if (new == NULL)
+ return;
+ swfdec_sprite_movie_copy_props (new, movie);
+ SWFDEC_LOG ("duplicated %s as %s to depth %u", movie->name, new->name, new->depth);
+ SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (new));
+}
+
+SWFDEC_AS_NATIVE (900, 19, swfdec_sprite_movie_removeMovieClip)
+void
+swfdec_sprite_movie_removeMovieClip (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
+
+ if (swfdec_depth_classify (movie->depth) == SWFDEC_DEPTH_CLASS_DYNAMIC)
+ swfdec_movie_remove (movie);
+}
+
+SWFDEC_AS_NATIVE (900, 10, swfdec_sprite_movie_getDepth)
+void
+swfdec_sprite_movie_getDepth (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
+
+ SWFDEC_AS_VALUE_SET_INT (rval, movie->depth);
+}
+
+SWFDEC_AS_NATIVE (900, 5, swfdec_sprite_movie_getBounds)
+void
+swfdec_sprite_movie_getBounds (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ int x0, x1, y0, y1;
+ SwfdecAsValue val;
+ SwfdecAsObject *obj;
+ SwfdecMovie *movie;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
+
+ obj= swfdec_as_object_new_empty (cx);
+ if (obj== NULL)
+ return;
+
+ swfdec_movie_update (movie);
+ if (swfdec_rect_is_empty (&movie->extents)) {
+ x0 = x1 = y0 = y1 = 0x7FFFFFF;
+ } else {
+ SwfdecRect rect = movie->extents;
+ SwfdecMovie *other;
+
+ if (argc > 0) {
+ other =
+ swfdec_player_get_movie_from_value (SWFDEC_PLAYER (cx), &argv[0]);
+ if (!other)
+ return;
+ } else {
+ other = movie;
+ }
+
+ if (movie->parent)
+ swfdec_movie_rect_local_to_global (movie->parent, &rect);
+ swfdec_movie_rect_global_to_local ((other != NULL ? other : movie), &rect);
+
+ x0 = rect.x0;
+ y0 = rect.y0;
+ x1 = rect.x1;
+ y1 = rect.y1;
+ }
+ SWFDEC_AS_VALUE_SET_NUMBER (&val, SWFDEC_TWIPS_TO_DOUBLE (x0));
+ swfdec_as_object_set_variable (obj, SWFDEC_AS_STR_xMin, &val);
+ SWFDEC_AS_VALUE_SET_NUMBER (&val, SWFDEC_TWIPS_TO_DOUBLE (y0));
+ swfdec_as_object_set_variable (obj, SWFDEC_AS_STR_yMin, &val);
+ SWFDEC_AS_VALUE_SET_NUMBER (&val, SWFDEC_TWIPS_TO_DOUBLE (x1));
+ swfdec_as_object_set_variable (obj, SWFDEC_AS_STR_xMax, &val);
+ SWFDEC_AS_VALUE_SET_NUMBER (&val, SWFDEC_TWIPS_TO_DOUBLE (y1));
+ swfdec_as_object_set_variable (obj, SWFDEC_AS_STR_yMax, &val);
+
+ SWFDEC_AS_VALUE_SET_OBJECT (rval, obj);
+}
+
+SWFDEC_AS_NATIVE (900, 11, swfdec_sprite_movie_setMask)
+void
+swfdec_sprite_movie_setMask (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie, *mask;
+
+ /* yes, this works with regular movies */
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &movie, "O", &mask);
+
+ if (mask != NULL && !SWFDEC_IS_MOVIE (mask)) {
+ SWFDEC_FIXME ("mask is not a movie, what now?");
+ mask = NULL;
+ }
+ if (movie->masked_by)
+ movie->masked_by->mask_of = NULL;
+ if (movie->mask_of)
+ movie->mask_of->masked_by = NULL;
+ movie->masked_by = mask;
+ movie->mask_of = NULL;
+ if (movie->clip_depth) {
+ g_assert (movie->parent);
+ swfdec_movie_invalidate_last (movie->parent);
+ movie->clip_depth = 0;
+ } else {
+ swfdec_movie_invalidate_last (movie);
+ }
+ if (mask) {
+ if (mask->masked_by)
+ mask->masked_by->mask_of = NULL;
+ if (mask->mask_of)
+ mask->mask_of->masked_by = NULL;
+ mask->masked_by = NULL;
+ mask->mask_of = movie;
+ swfdec_movie_invalidate_last (mask);
+ if (mask->clip_depth) {
+ g_assert (mask->parent);
+ swfdec_movie_invalidate_last (mask->parent);
+ mask->clip_depth = 0;
+ } else {
+ swfdec_movie_invalidate_last (mask);
+ }
+ }
+}
+
+void
+swfdec_sprite_movie_init_context (SwfdecPlayer *player)
+{
+ SwfdecAsContext *context = SWFDEC_AS_CONTEXT (player);
+ SwfdecAsValue val;
+ SwfdecAsObject *proto, *movie;
+
+ movie = SWFDEC_AS_OBJECT (swfdec_as_object_add_function (context->global,
+ SWFDEC_AS_STR_MovieClip, 0, NULL, 0));
+ if (movie == NULL)
+ return;
+ SWFDEC_SANDBOX (context->global)->MovieClip = movie;
+ proto = swfdec_as_object_new (context);
+ if (!proto)
+ return;
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
+ swfdec_as_object_set_variable_and_flags (movie,
+ SWFDEC_AS_STR_prototype, &val, SWFDEC_AS_VARIABLE_HIDDEN |
+ SWFDEC_AS_VARIABLE_PERMANENT);
+};
diff --git a/swfdec/swfdec_stage_as.c b/swfdec/swfdec_stage_as.c
new file mode 100644
index 0000000..87ced97
--- /dev/null
+++ b/swfdec/swfdec_stage_as.c
@@ -0,0 +1,246 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include "swfdec_as_internal.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_player_internal.h"
+
+/*** AS CODE ***/
+
+SWFDEC_AS_NATIVE (666, 1, get_scaleMode)
+void
+get_scaleMode (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+
+ switch (player->priv->scale_mode) {
+ case SWFDEC_SCALE_SHOW_ALL:
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_showAll);
+ break;
+ case SWFDEC_SCALE_NO_BORDER:
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_noBorder);
+ break;
+ case SWFDEC_SCALE_EXACT_FIT:
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_exactFit);
+ break;
+ case SWFDEC_SCALE_NONE:
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_noScale);
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
+
+SWFDEC_AS_NATIVE (666, 2, set_scaleMode)
+void
+set_scaleMode (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+ const char *s;
+ SwfdecScaleMode mode;
+
+ if (argc == 0)
+ return;
+ s = swfdec_as_value_to_string (cx, &argv[0]);
+ if (g_ascii_strcasecmp (s, SWFDEC_AS_STR_noBorder) == 0) {
+ mode = SWFDEC_SCALE_NO_BORDER;
+ } else if (g_ascii_strcasecmp (s, SWFDEC_AS_STR_exactFit) == 0) {
+ mode = SWFDEC_SCALE_EXACT_FIT;
+ } else if (g_ascii_strcasecmp (s, SWFDEC_AS_STR_noScale) == 0) {
+ mode = SWFDEC_SCALE_NONE;
+ } else {
+ mode = SWFDEC_SCALE_SHOW_ALL;
+ }
+ swfdec_player_set_scale_mode (player, mode);
+}
+
+SWFDEC_AS_NATIVE (666, 3, get_align)
+void
+get_align (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+ SwfdecPlayerPrivate *priv = player->priv;
+ char s[5];
+ guint i = 0;
+
+ if (priv->align_flags & SWFDEC_ALIGN_FLAG_LEFT)
+ s[i++] = 'L';
+ if (priv->align_flags & SWFDEC_ALIGN_FLAG_TOP)
+ s[i++] = 'T';
+ if (priv->align_flags & SWFDEC_ALIGN_FLAG_RIGHT)
+ s[i++] = 'R';
+ if (priv->align_flags & SWFDEC_ALIGN_FLAG_BOTTOM)
+ s[i++] = 'B';
+ s[i] = 0;
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (cx, s));
+}
+
+SWFDEC_AS_NATIVE (666, 4, set_align)
+void
+set_align (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+ guint flags = 0;
+ const char *s;
+
+ if (argc == 0)
+ return;
+
+ s = swfdec_as_value_to_string (cx, &argv[0]);
+ if (strchr (s, 'l') || strchr (s, 'L'))
+ flags |= SWFDEC_ALIGN_FLAG_LEFT;
+ if (strchr (s, 't') || strchr (s, 'T'))
+ flags |= SWFDEC_ALIGN_FLAG_TOP;
+ if (strchr (s, 'r') || strchr (s, 'R'))
+ flags |= SWFDEC_ALIGN_FLAG_RIGHT;
+ if (strchr (s, 'b') || strchr (s, 'B'))
+ flags |= SWFDEC_ALIGN_FLAG_BOTTOM;
+
+ if (flags != player->priv->align_flags) {
+ player->priv->align_flags = flags;
+ g_object_notify (G_OBJECT (player), "alignment");
+ swfdec_player_update_scale (player);
+ }
+}
+
+SWFDEC_AS_NATIVE (666, 5, get_width)
+void
+get_width (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+
+ SWFDEC_AS_VALUE_SET_INT (ret, player->priv->internal_width);
+}
+
+SWFDEC_AS_NATIVE (666, 7, get_height)
+void
+get_height (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+
+ SWFDEC_AS_VALUE_SET_INT (ret, player->priv->internal_height);
+}
+
+/* FIXME: do this smarter */
+SWFDEC_AS_NATIVE (666, 6, set_width)
+void
+set_width (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+}
+
+SWFDEC_AS_NATIVE (666, 8, set_height)
+void
+set_height (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+}
+
+SWFDEC_AS_NATIVE (666, 9, swfdec_stage_get_showMenu)
+void
+swfdec_stage_get_showMenu (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Stage.showMenu (get)");
+}
+
+SWFDEC_AS_NATIVE (666, 10, swfdec_stage_set_showMenu)
+void
+swfdec_stage_set_showMenu (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Stage.showMenu (set)");
+}
+
+SWFDEC_AS_NATIVE (666, 11, swfdec_stage_get_displayState)
+void
+swfdec_stage_get_displayState (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Stage.displayState (get)");
+}
+
+SWFDEC_AS_NATIVE (666, 12, swfdec_stage_set_displayState)
+void
+swfdec_stage_set_displayState (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Stage.displayState (set)");
+}
+
+SWFDEC_AS_NATIVE (666, 100, swfdec_stage_get_fullScreenSourceRect)
+void
+swfdec_stage_get_fullScreenSourceRect (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Stage.fullScreenSourceRect (get)");
+}
+
+SWFDEC_AS_NATIVE (666, 101, swfdec_stage_set_fullScreenSourceRect)
+void
+swfdec_stage_set_fullScreenSourceRect (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Stage.fullScreenSourceRect (set)");
+}
+
+SWFDEC_AS_NATIVE (666, 102, swfdec_stage_get_fullScreenHeight)
+void
+swfdec_stage_get_fullScreenHeight (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Stage.fullScreenHeight (get)");
+}
+
+SWFDEC_AS_NATIVE (666, 103, swfdec_stage_set_fullScreenHeight)
+void
+swfdec_stage_set_fullScreenHeight (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Stage.fullScreenHeight (set)");
+}
+
+SWFDEC_AS_NATIVE (666, 104, swfdec_stage_get_fullScreenWidth)
+void
+swfdec_stage_get_fullScreenWidth (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Stage.fullScreenWidth (get)");
+}
+
+SWFDEC_AS_NATIVE (666, 105, swfdec_stage_set_fullScreenWidth)
+void
+swfdec_stage_set_fullScreenWidth (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Stage.fullScreenWidth (set)");
+}
diff --git a/swfdec/swfdec_stream.c b/swfdec/swfdec_stream.c
new file mode 100644
index 0000000..11be333
--- /dev/null
+++ b/swfdec/swfdec_stream.c
@@ -0,0 +1,427 @@
+/* Swfdec
+ * Copyright (C) 2006-2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include "swfdec_loader_internal.h"
+#include "swfdec_buffer.h"
+#include "swfdec_debug.h"
+#include "swfdec_stream_target.h"
+#include "swfdec_player_internal.h"
+
+/*** gtk-doc ***/
+
+/**
+ * SECTION:SwfdecStream
+ * @title: SwfdecStream
+ * @short_description: object used for input
+ *
+ * SwfdecStream is the base class used for communication inside Swfdec. If you
+ * are a UNIX developer, think of this class as the equivalent to a file
+ * descriptor. #SwfdecLoader and #SwfdecSocket are the subclasses supposed to
+ * be used for files or network sockets, respectively.
+ *
+ * This class provides the functions necessary to implement subclasses of
+ * streams. None of the functions described in this section should be used by
+ * anything but subclass implementations. Consider them "protected".
+ */
+
+/**
+ * SwfdecStream:
+ *
+ * This is the base object used for providing input. It is abstract, use a
+ * subclass to provide your input. All members are considered private.
+ */
+
+/**
+ * SwfdecStreamClass:
+ * @describe: Provide a string describing your string. Default implementations
+ * of this function exist for both the #SwfdecLoader and
+ * #SwfdecStream subclasses. They return the URL for the stream.
+ * @close: Called when Swfdec requests that the stream be closed. After this
+ * function was called, Swfdec will consider the stream finished and
+ * will not ever read data from it again.
+ *
+ * This is the base class used for providing input. You are supposed to create
+ * a subclass that fills in the function pointers mentioned above.
+ */
+
+/*** SwfdecStream ***/
+
+typedef enum {
+ SWFDEC_STREAM_STATE_CONNECTING = 0, /* stream is still in the process of establishing a connection */
+ SWFDEC_STREAM_STATE_OPEN, /* stream is open and data flow is happening */
+ SWFDEC_STREAM_STATE_CLOSED, /* loader has been closed */
+ SWFDEC_STREAM_STATE_ERROR /* loader is in error state */
+} SwfdecStreamState;
+
+struct _SwfdecStreamPrivate
+{
+ SwfdecPlayer * player; /* player to queue target notificaions in */
+ SwfdecStreamTarget * target; /* SwfdecStreamTarget that gets notified about loading progress */
+ SwfdecStreamState state; /* SwfdecStreamState the stream is currently in */
+ SwfdecStreamState processed_state;/* SwfdecStreamState the target knows about */
+ gboolean queued; /* TRUE if we have queued an action already */
+ char * error; /* error message if in error state or NULL */
+ SwfdecBufferQueue * queue; /* SwfdecBufferQueue managing the input buffers */
+};
+
+enum {
+ PROP_0,
+ PROP_ERROR,
+ PROP_OPEN,
+ PROP_EOF
+};
+
+G_DEFINE_ABSTRACT_TYPE (SwfdecStream, swfdec_stream, G_TYPE_OBJECT)
+
+static void
+swfdec_stream_get_property (GObject *object, guint param_id, GValue *value,
+ GParamSpec * pspec)
+{
+ SwfdecStreamPrivate *stream = SWFDEC_STREAM (object)->priv;
+
+ switch (param_id) {
+ case PROP_ERROR:
+ g_value_set_string (value, stream->error);
+ break;
+ case PROP_OPEN:
+ g_value_set_boolean (value, stream->state == SWFDEC_STREAM_STATE_OPEN);
+ break;
+ case PROP_EOF:
+ g_value_set_boolean (value, stream->state == SWFDEC_STREAM_STATE_CLOSED);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+swfdec_stream_set_property (GObject *object, guint param_id, const GValue *value,
+ GParamSpec *pspec)
+{
+ //SwfdecStream *stream = SWFDEC_STREAM (object);
+
+ switch (param_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+swfdec_stream_dispose (GObject *object)
+{
+ SwfdecStreamPrivate *stream = SWFDEC_STREAM (object)->priv;
+
+ /* targets are supposed to keep a reference around */
+ g_assert (stream->target == NULL);
+ if (stream->queue) {
+ swfdec_buffer_queue_unref (stream->queue);
+ stream->queue = NULL;
+ }
+ g_free (stream->error);
+ stream->error = NULL;
+
+ G_OBJECT_CLASS (swfdec_stream_parent_class)->dispose (object);
+}
+
+static void
+swfdec_stream_class_init (SwfdecStreamClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (SwfdecStreamPrivate));
+
+ object_class->dispose = swfdec_stream_dispose;
+ object_class->get_property = swfdec_stream_get_property;
+ object_class->set_property = swfdec_stream_set_property;
+
+ g_object_class_install_property (object_class, PROP_ERROR,
+ g_param_spec_string ("error", "error", "NULL when no error or string describing error",
+ NULL, G_PARAM_READABLE));
+ g_object_class_install_property (object_class, PROP_OPEN,
+ g_param_spec_boolean ("open", "open", "TRUE while data is flowing",
+ FALSE, G_PARAM_READABLE));
+ g_object_class_install_property (object_class, PROP_EOF,
+ g_param_spec_boolean ("eof", "eof", "TRUE when all data has been transmitted",
+ FALSE, G_PARAM_READABLE));
+}
+
+static void
+swfdec_stream_init (SwfdecStream *stream)
+{
+ SwfdecStreamPrivate *priv;
+
+ stream->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (stream, SWFDEC_TYPE_STREAM, SwfdecStreamPrivate);
+
+ priv->queue = swfdec_buffer_queue_new ();
+}
+
+/*** INTERNAL API ***/
+
+SwfdecBufferQueue *
+swfdec_stream_get_queue (SwfdecStream *stream)
+{
+ g_return_val_if_fail (SWFDEC_IS_STREAM (stream), NULL);
+
+ return stream->priv->queue;
+}
+
+static void
+swfdec_stream_process (gpointer streamp, gpointer unused)
+{
+ SwfdecStream *stream = streamp;
+ SwfdecStreamPrivate *priv = stream->priv;
+
+ g_assert (priv->target != NULL);
+
+ priv->queued = FALSE;
+ if (priv->state == priv->processed_state &&
+ priv->state != SWFDEC_STREAM_STATE_OPEN)
+ return;
+ g_assert (priv->processed_state != SWFDEC_STREAM_STATE_CLOSED);
+ g_object_ref (stream);
+ if (priv->state == SWFDEC_STREAM_STATE_ERROR) {
+ swfdec_stream_target_error (priv->target, stream);
+ } else {
+ while (priv->state != priv->processed_state) {
+ if (priv->processed_state == SWFDEC_STREAM_STATE_CONNECTING) {
+ priv->processed_state = SWFDEC_STREAM_STATE_OPEN;
+ swfdec_stream_target_open (priv->target, stream);
+ } else if (priv->processed_state == SWFDEC_STREAM_STATE_OPEN) {
+ swfdec_stream_target_parse (priv->target, stream);
+ priv->processed_state = SWFDEC_STREAM_STATE_CLOSED;
+ swfdec_stream_target_close (priv->target, stream);
+ }
+ }
+ if (priv->processed_state == SWFDEC_STREAM_STATE_OPEN) {
+ swfdec_stream_target_parse (priv->target, stream);
+ }
+ }
+ g_object_unref (stream);
+}
+
+static void
+swfdec_stream_queue_processing (SwfdecStream *stream)
+{
+ SwfdecStreamPrivate *priv = stream->priv;
+
+ if (priv->queued)
+ return;
+ priv->queued = TRUE;
+ if (priv->target) {
+ g_assert (priv->player);
+ swfdec_player_add_external_action (priv->player, stream,
+ swfdec_stream_process, NULL);
+ }
+}
+
+void
+swfdec_stream_close (SwfdecStream *stream)
+{
+ SwfdecStreamPrivate *priv;
+ SwfdecStreamClass *klass;
+
+ g_return_if_fail (SWFDEC_IS_STREAM (stream));
+
+ priv = stream->priv;
+ if (priv->state == SWFDEC_STREAM_STATE_ERROR &&
+ priv->state == SWFDEC_STREAM_STATE_CLOSED)
+ return;
+
+ klass = SWFDEC_STREAM_GET_CLASS (stream);
+
+ if (klass->close)
+ klass->close (stream);
+ priv->state = SWFDEC_STREAM_STATE_CLOSED;
+ priv->processed_state = SWFDEC_STREAM_STATE_CLOSED;
+}
+
+void
+swfdec_stream_set_target (SwfdecStream *stream, SwfdecStreamTarget *target)
+{
+ SwfdecStreamPrivate *priv;
+
+ g_return_if_fail (SWFDEC_IS_STREAM (stream));
+ if (target != NULL) {
+ g_return_if_fail (stream->priv->processed_state == SWFDEC_STREAM_STATE_CONNECTING);
+ g_return_if_fail (SWFDEC_IS_STREAM_TARGET (target));
+ }
+
+ priv = stream->priv;
+ if (priv->target) {
+ swfdec_player_remove_all_external_actions (priv->player, stream);
+ }
+ priv->queued = FALSE;
+ priv->target = target;
+ if (target) {
+ priv->player = swfdec_stream_target_get_player (target);
+ if (priv->state != SWFDEC_STREAM_STATE_CONNECTING)
+ swfdec_stream_queue_processing (stream);
+ } else {
+ priv->player = NULL;
+ }
+}
+
+/** PUBLIC API ***/
+
+/**
+ * swfdec_stream_describe:
+ * @stream: a #SwfdecStream
+ *
+ * Describes the stream in a simple string. This is mostly useful for debugging
+ * purposes.
+ *
+ * Returns: a constant string describing the stream
+ **/
+const char *
+swfdec_stream_describe (SwfdecStream *stream)
+{
+ SwfdecStreamClass *klass;
+
+ g_return_val_if_fail (SWFDEC_IS_STREAM (stream), NULL);
+
+ klass = SWFDEC_STREAM_GET_CLASS (stream);
+ g_return_val_if_fail (klass->describe, NULL);
+
+ return klass->describe (stream);
+}
+
+/**
+ * swfdec_stream_error:
+ * @stream: a #SwfdecStream
+ * @error: a printf-style string describing the error
+ * @...: arguments for the @error string
+ *
+ * Moves the stream in the error state if it wasn't before. A stream that is in
+ * the error state will not process any more data. Also, internal error
+ * handling scripts may be executed.
+ **/
+void
+swfdec_stream_error (SwfdecStream *stream, const char *error, ...)
+{
+ va_list args;
+
+ g_return_if_fail (SWFDEC_IS_STREAM (stream));
+ g_return_if_fail (error != NULL);
+
+ va_start (args, error);
+ swfdec_stream_errorv (stream, error, args);
+ va_end (args);
+}
+
+/**
+ * swfdec_stream_errorv:
+ * @stream: a #SwfdecStream
+ * @error: a printf-style error string
+ * @args: arguments for @error
+ *
+ * This function is the va_list alternative to swfdec_stream_error(). See that
+ * function for details.
+ **/
+void
+swfdec_stream_errorv (SwfdecStream *stream, const char *error, va_list args)
+{
+ SwfdecStreamPrivate *priv;
+ char *real_error;
+
+ g_return_if_fail (SWFDEC_IS_STREAM (stream));
+ g_return_if_fail (error != NULL);
+
+ real_error = g_strdup_vprintf (error, args);
+ priv = stream->priv;
+ if (priv->error) {
+ SWFDEC_ERROR ("another error in stream for %s: %s",
+ swfdec_stream_describe (stream), real_error);
+ g_free (real_error);
+ return;
+ }
+
+ SWFDEC_ERROR ("error in stream for %s: %s",
+ swfdec_stream_describe (stream), real_error);
+ priv->state = SWFDEC_STREAM_STATE_ERROR;
+ priv->error = real_error;
+ swfdec_stream_queue_processing (stream);
+}
+
+/**
+ * swfdec_stream_open:
+ * @stream: a #SwfdecStream
+ *
+ * Call this function when your stream opened the resulting file. For HTTP this
+ * is when having received the headers. You must call this function before
+ * swfdec_stream_push() can be called.
+ **/
+void
+swfdec_stream_open (SwfdecStream *stream)
+{
+ g_return_if_fail (SWFDEC_IS_STREAM (stream));
+ g_return_if_fail (stream->priv->state == SWFDEC_STREAM_STATE_CONNECTING);
+
+ stream->priv->state = SWFDEC_STREAM_STATE_OPEN;
+ g_object_notify (G_OBJECT (stream), "open");
+ swfdec_stream_queue_processing (stream);
+}
+
+/**
+ * swfdec_stream_push:
+ * @stream: a #SwfdecStream
+ * @buffer: new data to make available. The stream takes the reference
+ * to the buffer.
+ *
+ * Makes the data in @buffer available to @stream and processes it. The @stream
+ * must be open.
+ **/
+void
+swfdec_stream_push (SwfdecStream *stream, SwfdecBuffer *buffer)
+{
+ g_return_if_fail (SWFDEC_IS_STREAM (stream));
+ g_return_if_fail (stream->priv->state == SWFDEC_STREAM_STATE_OPEN);
+ g_return_if_fail (buffer != NULL);
+
+ swfdec_buffer_queue_push (stream->priv->queue, buffer);
+ /* FIXME */
+ if (SWFDEC_IS_LOADER (stream))
+ g_object_notify (G_OBJECT (stream), "loaded");
+ swfdec_stream_queue_processing (stream);
+}
+
+/**
+ * swfdec_stream_eof:
+ * @stream: a #SwfdecStream
+ *
+ * Indicates to @stream that no more data will follow. The stream must be open.
+ **/
+void
+swfdec_stream_eof (SwfdecStream *stream)
+{
+ g_return_if_fail (SWFDEC_IS_STREAM (stream));
+ g_return_if_fail (stream->priv->state == SWFDEC_STREAM_STATE_OPEN);
+
+ stream->priv->state = SWFDEC_STREAM_STATE_CLOSED;
+ g_object_notify (G_OBJECT (stream), "open");
+ g_object_notify (G_OBJECT (stream), "eof");
+ swfdec_stream_queue_processing (stream);
+}
+
diff --git a/swfdec/swfdec_stream.h b/swfdec/swfdec_stream.h
new file mode 100644
index 0000000..f1cb86c
--- /dev/null
+++ b/swfdec/swfdec_stream.h
@@ -0,0 +1,71 @@
+/* Swfdec
+ * Copyright (C) 2006-2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_STREAM_H_
+#define _SWFDEC_STREAM_H_
+
+#include <glib-object.h>
+#include <libswfdec/swfdec_buffer.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecStream SwfdecStream;
+typedef struct _SwfdecStreamClass SwfdecStreamClass;
+typedef struct _SwfdecStreamPrivate SwfdecStreamPrivate;
+
+#define SWFDEC_TYPE_STREAM (swfdec_stream_get_type())
+#define SWFDEC_IS_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_STREAM))
+#define SWFDEC_IS_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_STREAM))
+#define SWFDEC_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_STREAM, SwfdecStream))
+#define SWFDEC_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_STREAM, SwfdecStreamClass))
+#define SWFDEC_STREAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_STREAM, SwfdecStreamClass))
+
+struct _SwfdecStream
+{
+ GObject object;
+
+ /*< private >*/
+ SwfdecStreamPrivate * priv;
+};
+
+struct _SwfdecStreamClass
+{
+ GObjectClass object_class;
+
+ /* get a nice description string */
+ const char * (* describe) (SwfdecStream * stream);
+ /* close the stream. */
+ void (* close) (SwfdecStream * stream);
+};
+
+GType swfdec_stream_get_type (void);
+
+void swfdec_stream_open (SwfdecStream * stream);
+void swfdec_stream_push (SwfdecStream * stream,
+ SwfdecBuffer * buffer);
+void swfdec_stream_eof (SwfdecStream * stream);
+void swfdec_stream_error (SwfdecStream * stream,
+ const char * error,
+ ...) G_GNUC_PRINTF (2, 3);
+void swfdec_stream_errorv (SwfdecStream * stream,
+ const char * error,
+ va_list args);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_stream_target.c b/swfdec/swfdec_stream_target.c
new file mode 100644
index 0000000..a5d7184
--- /dev/null
+++ b/swfdec/swfdec_stream_target.c
@@ -0,0 +1,136 @@
+/* Swfdec
+ * Copyright (C) 2007-2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_stream_target.h"
+#include "swfdec_debug.h"
+#include "swfdec_loader_internal.h"
+#include "swfdec_player_internal.h"
+
+static void
+swfdec_stream_target_base_init (gpointer g_class)
+{
+ static gboolean initialized = FALSE;
+
+ if (G_UNLIKELY (!initialized)) {
+ initialized = TRUE;
+ }
+}
+
+GType
+swfdec_stream_target_get_type (void)
+{
+ static GType stream_target_type = 0;
+
+ if (!stream_target_type) {
+ static const GTypeInfo stream_target_info = {
+ sizeof (SwfdecStreamTargetInterface),
+ swfdec_stream_target_base_init,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ 0,
+ NULL,
+ };
+
+ stream_target_type = g_type_register_static (G_TYPE_INTERFACE,
+ "SwfdecStreamTarget", &stream_target_info, 0);
+ g_type_interface_add_prerequisite (stream_target_type, G_TYPE_OBJECT);
+ }
+
+ return stream_target_type;
+}
+
+SwfdecPlayer *
+swfdec_stream_target_get_player (SwfdecStreamTarget *target)
+{
+ SwfdecStreamTargetInterface *iface;
+
+ g_return_val_if_fail (SWFDEC_IS_STREAM_TARGET (target), NULL);
+
+ iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
+ g_assert (iface->get_player != NULL);
+ return iface->get_player (target);
+}
+
+void
+swfdec_stream_target_open (SwfdecStreamTarget *target, SwfdecStream *stream)
+{
+ SwfdecStreamTargetInterface *iface;
+
+ g_return_if_fail (SWFDEC_IS_STREAM_TARGET (target));
+ g_return_if_fail (SWFDEC_IS_STREAM (stream));
+
+ SWFDEC_LOG ("opening %s", swfdec_stream_describe (stream));
+
+ iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
+ if (iface->open)
+ iface->open (target, stream);
+}
+
+void
+swfdec_stream_target_parse (SwfdecStreamTarget *target, SwfdecStream *stream)
+{
+ SwfdecStreamTargetInterface *iface;
+
+ g_return_if_fail (SWFDEC_IS_STREAM_TARGET (target));
+ g_return_if_fail (SWFDEC_IS_STREAM (stream));
+
+ SWFDEC_LOG ("parsing %s", swfdec_stream_describe (stream));
+
+ iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
+ if (iface->parse)
+ iface->parse (target, stream);
+}
+
+void
+swfdec_stream_target_close (SwfdecStreamTarget *target, SwfdecStream *stream)
+{
+ SwfdecStreamTargetInterface *iface;
+
+ g_return_if_fail (SWFDEC_IS_STREAM_TARGET (target));
+ g_return_if_fail (SWFDEC_IS_STREAM (stream));
+
+ SWFDEC_LOG ("close on %s", swfdec_stream_describe (stream));
+
+ iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
+ if (iface->close)
+ iface->close (target, stream);
+}
+
+void
+swfdec_stream_target_error (SwfdecStreamTarget *target, SwfdecStream *stream)
+{
+ SwfdecStreamTargetInterface *iface;
+
+ g_return_if_fail (SWFDEC_IS_STREAM_TARGET (target));
+ g_return_if_fail (SWFDEC_IS_STREAM (stream));
+
+ SWFDEC_LOG ("error on %s", swfdec_stream_describe (stream));
+
+ iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
+ if (iface->error)
+ iface->error (target, stream);
+}
+
diff --git a/swfdec/swfdec_stream_target.h b/swfdec/swfdec_stream_target.h
new file mode 100644
index 0000000..42b8e16
--- /dev/null
+++ b/swfdec/swfdec_stream_target.h
@@ -0,0 +1,67 @@
+/* Swfdec
+ * Copyright (C) 2007-2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SWFDEC_STREAM_TARGET_H__
+#define __SWFDEC_STREAM_TARGET_H__
+
+#include <libswfdec/swfdec.h>
+
+G_BEGIN_DECLS
+
+
+#define SWFDEC_TYPE_STREAM_TARGET (swfdec_stream_target_get_type ())
+#define SWFDEC_STREAM_TARGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_STREAM_TARGET, SwfdecStreamTarget))
+#define SWFDEC_IS_STREAM_TARGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_STREAM_TARGET))
+#define SWFDEC_STREAM_TARGET_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), SWFDEC_TYPE_STREAM_TARGET, SwfdecStreamTargetInterface))
+
+typedef struct _SwfdecStreamTarget SwfdecStreamTarget; /* dummy object */
+typedef struct _SwfdecStreamTargetInterface SwfdecStreamTargetInterface;
+
+struct _SwfdecStreamTargetInterface {
+ GTypeInterface parent;
+
+ /* mandatory vfunc */
+ SwfdecPlayer * (* get_player) (SwfdecStreamTarget * target);
+ /* optional vfuncs */
+ void (* open) (SwfdecStreamTarget * target,
+ SwfdecStream * stream);
+ void (* parse) (SwfdecStreamTarget * target,
+ SwfdecStream * stream);
+ void (* close) (SwfdecStreamTarget * target,
+ SwfdecStream * stream);
+ void (* error) (SwfdecStreamTarget * target,
+ SwfdecStream * stream);
+};
+
+GType swfdec_stream_target_get_type (void) G_GNUC_CONST;
+
+SwfdecPlayer * swfdec_stream_target_get_player (SwfdecStreamTarget * target);
+void swfdec_stream_target_open (SwfdecStreamTarget * target,
+ SwfdecStream * stream);
+void swfdec_stream_target_parse (SwfdecStreamTarget * target,
+ SwfdecStream * stream);
+void swfdec_stream_target_close (SwfdecStreamTarget * target,
+ SwfdecStream * stream);
+void swfdec_stream_target_error (SwfdecStreamTarget * target,
+ SwfdecStream * stream);
+
+
+G_END_DECLS
+
+#endif /* __SWFDEC_STREAM_TARGET_H__ */
diff --git a/swfdec/swfdec_stroke.c b/swfdec/swfdec_stroke.c
new file mode 100644
index 0000000..f043727
--- /dev/null
+++ b/swfdec/swfdec_stroke.c
@@ -0,0 +1,361 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+
+#include "swfdec_stroke.h"
+#include "swfdec_bits.h"
+#include "swfdec_color.h"
+#include "swfdec_debug.h"
+#include "swfdec_decoder.h"
+#include "swfdec_path.h"
+
+#define MAX_ALIGN 10
+
+G_DEFINE_TYPE (SwfdecStroke, swfdec_stroke, SWFDEC_TYPE_DRAW);
+
+/* FIXME: This is wrong. Snapping only happens for vertical or horizontal lines.
+ * And the snapping shouldn't happen to the cr's device units, but to the
+ * Stage coordinate system.
+ * This would of course require this function to know that matrix... */
+static void
+swfdec_stroke_append_path_snapped (cairo_t *cr, const cairo_path_t *path)
+{
+ cairo_path_data_t *data;
+ double x, y;
+ int i;
+
+ data = path->data;
+ for (i = 0; i < path->num_data; i++) {
+ switch (data[i].header.type) {
+ case CAIRO_PATH_MOVE_TO:
+ i++;
+ x = data[i].point.x;
+ y = data[i].point.y;
+ cairo_user_to_device (cr, &x, &y);
+ x = rint (x - 0.5) + 0.5;
+ y = rint (y - 0.5) + 0.5;
+ cairo_device_to_user (cr, &x, &y);
+ /* FIXME: currently we need to clamp this due to extents */
+ x = CLAMP (x, data[i].point.x - MAX_ALIGN, data[i].point.x + MAX_ALIGN);
+ y = CLAMP (y, data[i].point.y - MAX_ALIGN, data[i].point.y + MAX_ALIGN);
+ cairo_move_to (cr, x, y);
+ break;
+ case CAIRO_PATH_LINE_TO:
+ i++;
+ x = data[i].point.x;
+ y = data[i].point.y;
+ cairo_user_to_device (cr, &x, &y);
+ x = rint (x - 0.5) + 0.5;
+ y = rint (y - 0.5) + 0.5;
+ cairo_device_to_user (cr, &x, &y);
+ /* FIXME: currently we need to clamp this due to extents */
+ x = CLAMP (x, data[i].point.x - MAX_ALIGN, data[i].point.x + MAX_ALIGN);
+ y = CLAMP (y, data[i].point.y - MAX_ALIGN, data[i].point.y + MAX_ALIGN);
+ cairo_line_to (cr, x, y);
+ break;
+ case CAIRO_PATH_CURVE_TO:
+ x = data[i+3].point.x;
+ y = data[i+3].point.y;
+ cairo_user_to_device (cr, &x, &y);
+ x = rint (x - 0.5) + 0.5;
+ y = rint (y - 0.5) + 0.5;
+ cairo_device_to_user (cr, &x, &y);
+ /* FIXME: currently we need to clamp this due to extents */
+ x = CLAMP (x, data[i+3].point.x - MAX_ALIGN, data[i+3].point.x + MAX_ALIGN);
+ y = CLAMP (y, data[i+3].point.y - MAX_ALIGN, data[i+3].point.y + MAX_ALIGN);
+ cairo_curve_to (cr, data[i+1].point.x, data[i+1].point.y,
+ data[i+2].point.x, data[i+2].point.y, x, y);
+ i += 3;
+ break;
+ case CAIRO_PATH_CLOSE_PATH:
+ /* doesn't exist in our code */
+ default:
+ g_assert_not_reached ();
+ }
+ }
+}
+
+static void
+swfdec_stroke_paint (SwfdecDraw *draw, cairo_t *cr, const SwfdecColorTransform *trans)
+{
+ SwfdecStroke *stroke = SWFDEC_STROKE (draw);
+ SwfdecColor color;
+
+ cairo_set_line_cap (cr, stroke->start_cap);
+ cairo_set_line_join (cr, stroke->join);
+ if (stroke->join == CAIRO_LINE_JOIN_MITER)
+ cairo_set_miter_limit (cr, stroke->miter_limit);
+
+ if (draw->snap)
+ swfdec_stroke_append_path_snapped (cr, &draw->path);
+ else
+ cairo_append_path (cr, &draw->path);
+
+ if (stroke->pattern) {
+ cairo_pattern_t *pattern = swfdec_pattern_get_pattern (stroke->pattern, trans);
+ cairo_set_source (cr, pattern);
+ cairo_pattern_destroy (pattern);
+ } else {
+ color = swfdec_color_apply_transform (stroke->start_color, trans);
+ swfdec_color_set_source (cr, color);
+ }
+ cairo_set_line_width (cr, MAX (stroke->start_width, SWFDEC_TWIPS_SCALE_FACTOR));
+ cairo_stroke (cr);
+}
+
+static void
+swfdec_stroke_morph (SwfdecDraw *dest, SwfdecDraw *source, guint ratio)
+{
+ SwfdecStroke *dstroke = SWFDEC_STROKE (dest);
+ SwfdecStroke *sstroke = SWFDEC_STROKE (source);
+
+ dstroke->start_color = swfdec_color_apply_morph (sstroke->start_color,
+ sstroke->end_color, ratio);
+ dstroke->start_width = (sstroke->start_width * ratio +
+ sstroke->end_width * (65535 - ratio)) / 65535;
+ if (sstroke->pattern) {
+ dstroke->pattern = SWFDEC_PATTERN (swfdec_draw_morph (
+ SWFDEC_DRAW (sstroke->pattern), ratio));
+ }
+ dstroke->start_cap = sstroke->start_cap;
+ dstroke->end_cap = sstroke->end_cap;
+ dstroke->join = sstroke->join;
+ dstroke->miter_limit = sstroke->miter_limit;
+ dstroke->no_vscale = sstroke->no_vscale;
+ dstroke->no_hscale = sstroke->no_hscale;
+ dstroke->no_close = sstroke->no_close;
+
+ SWFDEC_DRAW_CLASS (swfdec_stroke_parent_class)->morph (dest, source, ratio);
+}
+
+static void
+swfdec_stroke_compute_extents (SwfdecDraw *draw)
+{
+ guint width = SWFDEC_STROKE (draw)->start_width;
+
+ if (SWFDEC_STROKE (draw)->join != CAIRO_LINE_JOIN_ROUND) {
+ SWFDEC_FIXME ("work out extents computation for non-round line joins");
+ }
+ swfdec_path_get_extents (&draw->path, &draw->extents);
+ draw->extents.x0 -= width;
+ draw->extents.x1 += width;
+ draw->extents.y0 -= width;
+ draw->extents.y1 += width;
+}
+
+static gboolean
+swfdec_stroke_contains (SwfdecDraw *draw, cairo_t *cr, double x, double y)
+{
+ SwfdecStroke *stroke = SWFDEC_STROKE (draw);
+
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_set_line_cap (cr, stroke->start_cap);
+ cairo_set_line_join (cr, stroke->join);
+ if (stroke->join == CAIRO_LINE_JOIN_MITER)
+ cairo_set_miter_limit (cr, stroke->miter_limit);
+ cairo_set_line_width (cr, MAX (stroke->start_width, SWFDEC_TWIPS_SCALE_FACTOR));
+ /* FIXME: do snapping here? */
+ cairo_append_path (cr, &draw->path);
+ return cairo_in_stroke (cr, x, y);
+}
+
+static void
+swfdec_stroke_class_init (SwfdecStrokeClass *klass)
+{
+ SwfdecDrawClass *draw_class = SWFDEC_DRAW_CLASS (klass);
+
+ draw_class->morph = swfdec_stroke_morph;
+ draw_class->paint = swfdec_stroke_paint;
+ draw_class->compute_extents = swfdec_stroke_compute_extents;
+ draw_class->contains = swfdec_stroke_contains;
+}
+
+static void
+swfdec_stroke_init (SwfdecStroke *stroke)
+{
+ SwfdecDraw *draw = SWFDEC_DRAW (stroke);
+
+ draw->snap = TRUE;
+
+ stroke->start_cap = CAIRO_LINE_CAP_ROUND;
+ stroke->end_cap = CAIRO_LINE_CAP_ROUND;
+ stroke->join = CAIRO_LINE_JOIN_ROUND;
+}
+
+/*** EXPORTED API ***/
+
+SwfdecDraw *
+swfdec_stroke_parse (SwfdecBits *bits, SwfdecSwfDecoder *dec)
+{
+ SwfdecStroke *stroke = g_object_new (SWFDEC_TYPE_STROKE, NULL);
+
+ stroke->start_width = swfdec_bits_get_u16 (bits);
+ stroke->end_width = stroke->start_width;
+ stroke->start_color = swfdec_bits_get_color (bits);
+ stroke->end_color = stroke->start_color;
+ SWFDEC_LOG ("new stroke: width %u color %08x", stroke->start_width, stroke->start_color);
+
+ return SWFDEC_DRAW (stroke);
+}
+
+SwfdecDraw *
+swfdec_stroke_parse_rgba (SwfdecBits *bits, SwfdecSwfDecoder *dec)
+{
+ SwfdecStroke *stroke = g_object_new (SWFDEC_TYPE_STROKE, NULL);
+
+ stroke->start_width = swfdec_bits_get_u16 (bits);
+ stroke->end_width = stroke->start_width;
+ stroke->start_color = swfdec_bits_get_rgba (bits);
+ stroke->end_color = stroke->start_color;
+ SWFDEC_LOG ("new stroke: width %u color %08x", stroke->start_width, stroke->start_color);
+
+ return SWFDEC_DRAW (stroke);
+}
+
+SwfdecDraw *
+swfdec_stroke_parse_morph (SwfdecBits *bits, SwfdecSwfDecoder *dec)
+{
+ SwfdecStroke *stroke = g_object_new (SWFDEC_TYPE_STROKE, NULL);
+
+ stroke->start_width = swfdec_bits_get_u16 (bits);
+ stroke->end_width = swfdec_bits_get_u16 (bits);
+ stroke->start_color = swfdec_bits_get_rgba (bits);
+ stroke->end_color = swfdec_bits_get_rgba (bits);
+ SWFDEC_LOG ("new stroke: width %u => %u color %08X => %08X",
+ stroke->start_width, stroke->end_width,
+ stroke->start_color, stroke->end_color);
+
+ return SWFDEC_DRAW (stroke);
+}
+
+static cairo_line_cap_t
+swfdec_line_cap_get (guint cap)
+{
+ switch (cap) {
+ case 0:
+ return CAIRO_LINE_CAP_ROUND;
+ case 1:
+ return CAIRO_LINE_CAP_BUTT;
+ case 2:
+ return CAIRO_LINE_CAP_SQUARE;
+ default:
+ SWFDEC_ERROR ("invalid line cap value %u", cap);
+ return CAIRO_LINE_CAP_ROUND;
+ }
+}
+static cairo_line_join_t
+swfdec_line_join_get (guint join)
+{
+ switch (join) {
+ case 0:
+ return CAIRO_LINE_JOIN_ROUND;
+ case 1:
+ return CAIRO_LINE_JOIN_BEVEL;
+ case 2:
+ return CAIRO_LINE_JOIN_MITER;
+ default:
+ SWFDEC_ERROR ("invalid line join value %u", join);
+ return CAIRO_LINE_JOIN_ROUND;
+ }
+}
+
+static SwfdecDraw *
+swfdec_stroke_do_parse_extended (SwfdecBits *bits, SwfdecSwfDecoder *dec, gboolean morph)
+{
+ guint tmp;
+ gboolean has_pattern;
+ SwfdecStroke *stroke = g_object_new (SWFDEC_TYPE_STROKE, NULL);
+
+ stroke->start_width = swfdec_bits_get_u16 (bits);
+ if (morph) {
+ stroke->end_width = swfdec_bits_get_u16 (bits);
+ SWFDEC_LOG (" width: %u => %u", stroke->start_width, stroke->end_width);
+ } else {
+ stroke->end_width = stroke->start_width;
+ SWFDEC_LOG (" width: %u", stroke->start_width);
+ }
+ tmp = swfdec_bits_getbits (bits, 2);
+ SWFDEC_LOG (" start cap: %u", tmp);
+ stroke->start_cap = swfdec_line_cap_get (tmp);
+ tmp = swfdec_bits_getbits (bits, 2);
+ SWFDEC_LOG (" line join: %u", tmp);
+ stroke->join = swfdec_line_join_get (tmp);
+ has_pattern = swfdec_bits_getbit (bits);
+ SWFDEC_LOG (" has pattern: %d", has_pattern);
+ stroke->no_hscale = swfdec_bits_getbit (bits);
+ SWFDEC_LOG (" no hscale: %d", stroke->no_hscale);
+ stroke->no_vscale = swfdec_bits_getbit (bits);
+ SWFDEC_LOG (" no vscale: %d", stroke->no_vscale);
+ SWFDEC_DRAW (stroke)->snap = swfdec_bits_getbit (bits);
+ SWFDEC_LOG (" align pixels: %d", SWFDEC_DRAW (stroke)->snap);
+ tmp = swfdec_bits_getbits (bits, 5);
+ stroke->no_close = swfdec_bits_getbit (bits);
+ SWFDEC_LOG (" no close: %d", stroke->no_close);
+ tmp = swfdec_bits_getbits (bits, 2);
+ SWFDEC_LOG (" end cap: %u", tmp);
+ stroke->end_cap = swfdec_line_cap_get (tmp);
+ if (stroke->end_cap != stroke->start_cap) {
+ SWFDEC_WARNING ("FIXME: different caps on start and end of line are unsupported");
+ }
+ if (stroke->join == CAIRO_LINE_JOIN_MITER) {
+ stroke->miter_limit = swfdec_bits_get_u16 (bits);
+ SWFDEC_LOG (" miter limit: %u", stroke->miter_limit);
+ }
+ if (has_pattern) {
+ if (morph) {
+ stroke->pattern = SWFDEC_PATTERN (swfdec_pattern_parse_morph (bits, dec));
+ } else {
+ stroke->pattern = SWFDEC_PATTERN (swfdec_pattern_parse_rgba (bits, dec));
+ }
+ } else {
+ stroke->start_color = swfdec_bits_get_rgba (bits);
+ if (morph) {
+ stroke->end_color = swfdec_bits_get_rgba (bits);
+ SWFDEC_LOG (" color: #%08X", stroke->start_color);
+ } else {
+ stroke->end_color = stroke->start_color;
+ SWFDEC_LOG (" color: #%08X", stroke->start_color);
+ }
+ }
+
+ return SWFDEC_DRAW (stroke);
+}
+
+SwfdecDraw *
+swfdec_stroke_parse_extended (SwfdecBits *bits, SwfdecSwfDecoder *dec)
+{
+ g_return_val_if_fail (bits != NULL, NULL);
+ g_return_val_if_fail (SWFDEC_IS_SWF_DECODER (dec), NULL);
+
+ return swfdec_stroke_do_parse_extended (bits, dec, FALSE);
+}
+
+SwfdecDraw *
+swfdec_stroke_parse_morph_extended (SwfdecBits *bits, SwfdecSwfDecoder *dec)
+{
+ g_return_val_if_fail (bits != NULL, NULL);
+ g_return_val_if_fail (SWFDEC_IS_SWF_DECODER (dec), NULL);
+
+ return swfdec_stroke_do_parse_extended (bits, dec, TRUE);
+}
diff --git a/swfdec/swfdec_stroke.h b/swfdec/swfdec_stroke.h
new file mode 100644
index 0000000..8d1e7cd
--- /dev/null
+++ b/swfdec/swfdec_stroke.h
@@ -0,0 +1,76 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_STROKE_H_
+#define _SWFDEC_STROKE_H_
+
+#include <libswfdec/swfdec_pattern.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecStroke SwfdecStroke;
+typedef struct _SwfdecStrokeClass SwfdecStrokeClass;
+
+#define SWFDEC_TYPE_STROKE (swfdec_stroke_get_type())
+#define SWFDEC_IS_STROKE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_STROKE))
+#define SWFDEC_IS_STROKE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_STROKE))
+#define SWFDEC_STROKE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_STROKE, SwfdecStroke))
+#define SWFDEC_STROKE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_STROKE, SwfdecStrokeClass))
+#define SWFDEC_STROKE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_STROKE, SwfdecStrokeClass))
+
+struct _SwfdecStroke
+{
+ SwfdecDraw draw;
+
+ guint start_width; /* width of line */
+ SwfdecColor start_color; /* color to paint with */
+ guint end_width; /* width of line */
+ SwfdecColor end_color; /* color to paint with */
+ /* Flash 8 */
+ SwfdecPattern * pattern; /* pattern to use instead of color if not NULL */
+ cairo_line_cap_t start_cap;
+ cairo_line_cap_t end_cap;
+ cairo_line_join_t join;
+ guint miter_limit; /* only set when join = MITER */
+ gboolean no_vscale; /* don't scale line in vertical direction */
+ gboolean no_hscale; /* don't scale line in horizontal direction */
+ gboolean no_close; /* don't auto-close lines */
+};
+
+struct _SwfdecStrokeClass
+{
+ SwfdecDrawClass draw_class;
+};
+
+GType swfdec_stroke_get_type (void);
+
+SwfdecDraw * swfdec_stroke_parse (SwfdecBits * bits,
+ SwfdecSwfDecoder * dec);
+SwfdecDraw * swfdec_stroke_parse_rgba (SwfdecBits * bits,
+ SwfdecSwfDecoder * dec);
+SwfdecDraw * swfdec_stroke_parse_extended (SwfdecBits * bits,
+ SwfdecSwfDecoder * dec);
+SwfdecDraw * swfdec_stroke_parse_morph (SwfdecBits * bits,
+ SwfdecSwfDecoder * dec);
+SwfdecDraw * swfdec_stroke_parse_morph_extended (SwfdecBits * bits,
+ SwfdecSwfDecoder * dec);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_style_sheet.c b/swfdec/swfdec_style_sheet.c
new file mode 100644
index 0000000..847b199
--- /dev/null
+++ b/swfdec/swfdec_style_sheet.c
@@ -0,0 +1,366 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+
+#include "swfdec_style_sheet.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_as_array.h"
+#include "swfdec_as_object.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_text_format.h"
+#include "swfdec_text_field_movie.h"
+#include "swfdec_debug.h"
+#include "swfdec_internal.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_player_internal.h"
+
+enum {
+ UPDATE,
+ LAST_SIGNAL
+};
+
+G_DEFINE_TYPE (SwfdecStyleSheet, swfdec_style_sheet, SWFDEC_TYPE_AS_OBJECT)
+static guint signals[LAST_SIGNAL] = { 0, };
+
+static void
+swfdec_style_sheet_class_init (SwfdecStyleSheetClass *klass)
+{
+ signals[UPDATE] = g_signal_new ("update", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+}
+
+static void
+swfdec_style_sheet_init (SwfdecStyleSheet *style_sheet)
+{
+}
+
+// Note: This overwrites any old object with the same name
+static SwfdecAsObject *
+swfdec_style_sheet_get_selector_object (SwfdecAsObject *object,
+ const char *name)
+{
+ SwfdecAsValue val;
+ SwfdecAsObject *empty;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+
+ empty = swfdec_as_object_new_empty (object->context);
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, empty);
+ swfdec_as_object_unset_variable_flags (object, name,
+ SWFDEC_AS_VARIABLE_CONSTANT);
+ swfdec_as_object_set_variable (object, name, &val);
+
+ return empty;
+}
+
+static const char *
+swfdec_style_sheet_parse_selectors (SwfdecAsContext *cx, const char *p,
+ SwfdecAsObject *object, GPtrArray *selectors)
+{
+ const char *end;
+ const char *name;
+
+ g_return_val_if_fail (p != NULL && p != '\0' && !g_ascii_isspace (*p), NULL);
+ g_return_val_if_fail (SWFDEC_IS_AS_OBJECT (object), NULL);
+ g_return_val_if_fail (selectors != NULL, NULL);
+
+ p += strspn (p, " \t\r\n,");
+ if (*p == '{')
+ return NULL;
+
+ while (*p != '\0' && *p != '{') {
+ end = p + strcspn (p, " \t\r\n,{");
+ g_assert (end > p);
+
+ name = swfdec_as_context_give_string (cx, g_strndup (p, end - p));
+ g_ptr_array_add (selectors,
+ swfdec_style_sheet_get_selector_object (object, name));
+
+
+ p = end + strspn (end, " \t\r\n,");
+ if (*p != '{') {
+ // no , between selectors?
+ if (strchr (end, ',') == NULL || strchr (end, ',') > p)
+ return NULL;
+ }
+ }
+
+ if (*p != '{')
+ return NULL;
+
+ p++;
+ p = p + strspn (p, " \t\r\n");
+
+ // special case: don't allow empty declarations if not totally empty
+ if (*(p-1) != '{' && (*p == '\0' || *p == '}'))
+ return NULL;
+
+ return p;
+}
+
+static char *
+swfdec_style_sheet_convert_name (char *name)
+{
+ char *p;
+
+ p = name;
+ while ((p = strchr (p, '-')) != NULL && *(p + 1) != '\0') {
+ memmove (p, p + 1, strlen (p + 1) + 1); // include NULL-byte
+ *p = g_ascii_toupper (*p);
+ p++;
+ };
+
+ return name;
+}
+
+static const char *
+swfdec_style_sheet_parse_property (SwfdecAsContext *cx, const char *p,
+ const char **name, const char **value)
+{
+ const char *end;
+
+ *name = NULL;
+ *value = NULL;
+
+ g_return_val_if_fail (p != NULL && p != '\0' && !g_ascii_isspace (*p), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (value != NULL, NULL);
+
+ end = p + strcspn (p, ":;");
+ if (*end == '\0' || *end == ';')
+ return NULL;
+
+ *name = swfdec_as_context_give_string (cx,
+ swfdec_style_sheet_convert_name (g_strndup (p, end - p)));
+
+ end++;
+ p = end + strspn (end, " \t\r\n");
+ if (*p == '\0')
+ return NULL;
+ end = p + strcspn (p, ";}");
+ if (*end == '\0')
+ return NULL;
+
+ if (end == p) {
+ *value = SWFDEC_AS_STR_EMPTY;
+ } else {
+ *value = swfdec_as_context_give_string (cx, g_strndup (p, end - p));
+ }
+
+ if (*end == '}') {
+ p = end;
+ } else {
+ end++;
+ p = end + strspn (end, " \t\r\n");
+ }
+
+ return p;
+}
+
+static SwfdecAsObject *
+swfdec_style_sheet_parse (SwfdecAsContext *cx, const char *css)
+{
+ guint i;
+ const char *p;
+ SwfdecAsValue val;
+ SwfdecAsObject *object;
+ GPtrArray *selectors;
+
+ g_return_val_if_fail (css != NULL, FALSE);
+
+ object = swfdec_as_object_new_empty (cx);
+ selectors = g_ptr_array_new ();
+
+ p = css + strspn (css, " \t\r\n");
+ while (p != NULL && *p != '\0')
+ {
+ if (selectors->len == 0) {
+ p = swfdec_style_sheet_parse_selectors (cx, p, object, selectors);
+ } else {
+ if (*p == '}') {
+ g_ptr_array_set_size (selectors, 0);
+ p++;
+ p += strspn (p, " \t\r\n");
+ } else {
+ const char *name, *value;
+ p = swfdec_style_sheet_parse_property (cx, p, &name, &value);
+ if (p != NULL) {
+ for (i = 0; i < selectors->len; i++) {
+ SWFDEC_AS_VALUE_SET_STRING (&val, value);
+ swfdec_as_object_set_variable (
+ (SwfdecAsObject *)(selectors->pdata[i]), name, &val);
+ }
+ }
+ }
+ }
+ }
+
+ g_ptr_array_free (selectors, TRUE);
+ if (p == NULL)
+ return NULL;
+
+ return object;
+}
+
+SWFDEC_AS_NATIVE (113, 100, swfdec_style_sheet_update)
+void
+swfdec_style_sheet_update (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecStyleSheet *style;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_STYLESHEET, &style, "");
+
+ g_signal_emit (style, signals[UPDATE], 0);
+}
+
+SWFDEC_AS_NATIVE (113, 101, swfdec_style_sheet_parseCSSInternal)
+void
+swfdec_style_sheet_parseCSSInternal (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *rval)
+{
+ SwfdecAsObject *values;
+
+ if (argc < 1)
+ return;
+
+ values =
+ swfdec_style_sheet_parse (cx, swfdec_as_value_to_string (cx, &argv[0]));
+
+ if (values == NULL) {
+ SWFDEC_AS_VALUE_SET_NULL (rval);
+ } else {
+ SWFDEC_AS_VALUE_SET_OBJECT (rval, values);
+ }
+}
+
+SWFDEC_AS_NATIVE (113, 102, swfdec_style_sheet_parseCSSFontFamily)
+void
+swfdec_style_sheet_parseCSSFontFamily (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *rval)
+{
+ const char *name;
+
+ SWFDEC_AS_CHECK (0, NULL, "s", &name);
+
+ if (!g_ascii_strcasecmp (name, "mono")) {
+ SWFDEC_AS_VALUE_SET_STRING (rval, SWFDEC_AS_STR__typewriter);
+ } else if (!g_ascii_strcasecmp (name, "sans-serif")) {
+ SWFDEC_AS_VALUE_SET_STRING (rval, SWFDEC_AS_STR__sans);
+ } else if (!g_ascii_strcasecmp (name, "serif")) {
+ SWFDEC_AS_VALUE_SET_STRING (rval, SWFDEC_AS_STR__serif);
+ } else {
+ SWFDEC_AS_VALUE_SET_STRING (rval, name);
+ }
+}
+
+SWFDEC_AS_NATIVE (113, 103, swfdec_style_sheet_parseColor)
+void
+swfdec_style_sheet_parseColor (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ const char *value;
+ char *tail;
+ gint64 result;
+
+ SWFDEC_AS_VALUE_SET_NULL (rval);
+
+ SWFDEC_AS_CHECK (0, NULL, "s", &value);
+
+ if (strlen(value) != 7)
+ return;
+
+ if (value[0] != '#')
+ return;
+
+ result = g_ascii_strtoll (value + 1, &tail, 16);
+ if (*tail != '\0')
+ return;
+
+ SWFDEC_AS_VALUE_SET_INT (rval, result);
+}
+
+SWFDEC_AS_CONSTRUCTOR (113, 0, swfdec_style_sheet_construct, swfdec_style_sheet_get_type)
+void
+swfdec_style_sheet_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!swfdec_as_context_is_constructing (cx)) {
+ SWFDEC_FIXME ("What do we do if not constructing?");
+ return;
+ }
+
+ g_assert (SWFDEC_IS_STYLESHEET (object));
+}
+
+static SwfdecTextFormat *
+swfdec_style_sheet_get_format (SwfdecStyleSheet *style, const char *name)
+{
+ SwfdecAsObject *styles;
+ SwfdecAsValue val;
+
+ g_return_val_if_fail (SWFDEC_IS_STYLESHEET (style), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+
+ swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (style),
+ SWFDEC_AS_STR__styles, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return NULL;
+ styles = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+
+ swfdec_as_object_get_variable (styles, name, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return NULL;
+ if (!SWFDEC_IS_TEXT_FORMAT (SWFDEC_AS_VALUE_GET_OBJECT (&val)))
+ return NULL;
+
+ return SWFDEC_TEXT_FORMAT (SWFDEC_AS_VALUE_GET_OBJECT (&val));
+}
+
+SwfdecTextFormat *
+swfdec_style_sheet_get_tag_format (SwfdecStyleSheet *style, const char *name)
+{
+ return swfdec_style_sheet_get_format (style, name);
+}
+
+SwfdecTextFormat *
+swfdec_style_sheet_get_class_format (SwfdecStyleSheet *style, const char *name)
+{
+ char *name_full;
+
+ g_return_val_if_fail (SWFDEC_IS_STYLESHEET (style), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+
+ name_full = g_malloc (1 + strlen (name) + 1);
+ name_full[0] = '.';
+ memcpy (name_full + 1, name, strlen (name) + 1);
+
+ return swfdec_style_sheet_get_format (style, swfdec_as_context_give_string (
+ SWFDEC_AS_OBJECT (style)->context, name_full));
+}
diff --git a/swfdec/swfdec_style_sheet.h b/swfdec/swfdec_style_sheet.h
new file mode 100644
index 0000000..847d7f7
--- /dev/null
+++ b/swfdec/swfdec_style_sheet.h
@@ -0,0 +1,57 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_STYLESHEET_H_
+#define _SWFDEC_STYLESHEET_H_
+
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_types.h>
+#include <libswfdec/swfdec_script.h>
+#include <libswfdec/swfdec_text_format.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecStyleSheet SwfdecStyleSheet;
+typedef struct _SwfdecStyleSheetClass SwfdecStyleSheetClass;
+
+#define SWFDEC_TYPE_STYLESHEET (swfdec_style_sheet_get_type())
+#define SWFDEC_IS_STYLESHEET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_STYLESHEET))
+#define SWFDEC_IS_STYLESHEET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_STYLESHEET))
+#define SWFDEC_STYLESHEET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_STYLESHEET, SwfdecStyleSheet))
+#define SWFDEC_STYLESHEET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_STYLESHEET, SwfdecStyleSheetClass))
+#define SWFDEC_STYLESHEET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_STYLESHEET, SwfdecStyleSheetClass))
+
+struct _SwfdecStyleSheet {
+ SwfdecAsObject object;
+};
+
+struct _SwfdecStyleSheetClass {
+ SwfdecAsObjectClass object_class;
+};
+
+GType swfdec_style_sheet_get_type (void);
+
+SwfdecTextFormat *swfdec_style_sheet_get_tag_format (SwfdecStyleSheet * style,
+ const char * name);
+SwfdecTextFormat *swfdec_style_sheet_get_class_format (SwfdecStyleSheet * style,
+ const char * name);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_swf_decoder.c b/swfdec/swfdec_swf_decoder.c
new file mode 100644
index 0000000..5f3b2e0
--- /dev/null
+++ b/swfdec/swfdec_swf_decoder.c
@@ -0,0 +1,487 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <zlib.h>
+#include <math.h>
+#include <string.h>
+#include <stdlib.h>
+#include <liboil/liboil.h>
+
+#include "swfdec_swf_decoder.h"
+#include "swfdec.h"
+#include "swfdec_bits.h"
+#include "swfdec_cached.h"
+#include "swfdec_debug.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_script.h"
+#include "swfdec_script_internal.h"
+#include "swfdec_sprite.h"
+#include "swfdec_tag.h"
+
+enum {
+ SWFDEC_STATE_INIT1 = 0,
+ SWFDEC_STATE_INIT2,
+ SWFDEC_STATE_PARSE_FIRST_TAG,
+ SWFDEC_STATE_PARSE_TAG,
+ SWFDEC_STATE_EOF,
+};
+
+G_DEFINE_TYPE (SwfdecSwfDecoder, swfdec_swf_decoder, SWFDEC_TYPE_DECODER)
+
+static void
+swfdec_swf_decoder_dispose (GObject *object)
+{
+ SwfdecSwfDecoder *s = SWFDEC_SWF_DECODER (object);
+
+ g_hash_table_destroy (s->characters);
+ g_object_unref (s->main_sprite);
+ g_hash_table_destroy (s->scripts);
+
+ if (s->compressed)
+ inflateEnd (&s->z);
+ if (s->buffer) {
+ swfdec_buffer_unref (s->buffer);
+ s->buffer = NULL;
+ }
+
+ if (s->jpegtables) {
+ swfdec_buffer_unref (s->jpegtables);
+ }
+
+ g_free (s->password);
+
+ G_OBJECT_CLASS (swfdec_swf_decoder_parent_class)->dispose (object);
+}
+
+static void *
+zalloc (void *opaque, guint items, guint size)
+{
+ return g_malloc (items * size);
+}
+
+static void
+zfree (void *opaque, void *addr)
+{
+ g_free (addr);
+}
+
+static SwfdecBuffer *
+swfdec_buffer_merge (const SwfdecBuffer *front, const SwfdecBuffer *end)
+{
+ SwfdecBuffer *new;
+
+ g_return_val_if_fail (front != NULL, NULL);
+ g_return_val_if_fail (end != NULL, NULL);
+
+ new = swfdec_buffer_new_and_alloc (front->length + end->length);
+ if (front->length)
+ memcpy (new->data, front->data, front->length);
+ if (end->length)
+ memcpy (new->data + front->length, end->data, end->length);
+ return new;
+}
+
+static gboolean
+swfdec_swf_decoder_deflate (SwfdecSwfDecoder * s, SwfdecBuffer *buffer)
+{
+ int ret;
+ SwfdecDecoder *dec = SWFDEC_DECODER (s);
+
+ if (s->buffer == NULL) {
+ /* never written to */
+ g_assert (s->state == SWFDEC_STATE_INIT1);
+ s->buffer = buffer;
+ } else if (s->state == SWFDEC_STATE_INIT1) {
+ /* not initialized yet */
+ SwfdecBuffer *merge = swfdec_buffer_merge (s->buffer, buffer);
+ swfdec_buffer_unref (s->buffer);
+ swfdec_buffer_unref (buffer);
+ s->buffer = merge;
+ } else if (s->compressed) {
+ s->z.next_in = buffer->data;
+ s->z.avail_in = buffer->length;
+ ret = inflate (&s->z, Z_SYNC_FLUSH);
+ if (ret < Z_OK) {
+ SWFDEC_ERROR ("error uncompressing data: %s", s->z.msg);
+ return FALSE;
+ }
+
+ dec->bytes_loaded = s->z.total_out + 8;
+ swfdec_buffer_unref (buffer);
+ } else {
+ guint max = buffer->length;
+
+ if (dec->bytes_loaded + max > s->buffer->length) {
+ SWFDEC_WARNING ("%"G_GSIZE_FORMAT" bytes more than declared filesize",
+ dec->bytes_loaded + max - s->buffer->length);
+ max = s->buffer->length - dec->bytes_loaded;
+ }
+ memcpy (s->buffer->data + dec->bytes_loaded, buffer->data, max);
+ dec->bytes_loaded += max;
+ swfdec_buffer_unref (buffer);
+ }
+
+ return TRUE;
+}
+
+static gboolean
+swf_inflate_init (SwfdecSwfDecoder * s)
+{
+ z_stream *z;
+ int ret;
+ z = &s->z;
+ z->zalloc = zalloc;
+ z->zfree = zfree;
+ ret = inflateInit (z);
+ SWFDEC_DEBUG ("inflateInit returned %d", ret);
+
+ z->next_out = s->buffer->data + 8;
+ z->avail_out = s->buffer->length - 8;
+ z->opaque = NULL;
+ return TRUE;
+}
+
+static void
+swfdec_swf_decoder_init_bits (SwfdecSwfDecoder *dec, SwfdecBits *bits)
+{
+ swfdec_bits_init (bits, dec->buffer);
+ bits->end = bits->ptr + SWFDEC_DECODER (dec)->bytes_loaded;
+ bits->ptr += dec->bytes_parsed;
+ g_assert (bits->ptr <= bits->end);
+}
+
+static void
+swfdec_swf_decoder_flush_bits (SwfdecSwfDecoder *dec, SwfdecBits *bits)
+{
+ g_assert (bits->idx == 0);
+ g_assert (bits->buffer == dec->buffer);
+
+ dec->bytes_parsed = bits->ptr - dec->buffer->data;
+ g_assert (dec->bytes_parsed <= SWFDEC_DECODER (dec)->bytes_loaded);
+}
+
+static int
+swf_parse_header1 (SwfdecSwfDecoder * s)
+{
+ SwfdecDecoder *dec = SWFDEC_DECODER (s);
+ int sig1, sig2, sig3;
+ SwfdecBuffer *buffer, *rest;
+ SwfdecBits bits;
+ guint8 *data;
+
+ g_assert (s->buffer != NULL);
+ if (s->buffer->length <= 8) {
+ return SWFDEC_STATUS_NEEDBITS;
+ }
+
+ swfdec_bits_init (&bits, s->buffer);
+
+ sig1 = swfdec_bits_get_u8 (&bits);
+ sig2 = swfdec_bits_get_u8 (&bits);
+ sig3 = swfdec_bits_get_u8 (&bits);
+ if ((sig1 != 'F' && sig1 != 'C') || sig2 != 'W' || sig3 != 'S') {
+ return SWFDEC_STATUS_ERROR;
+ }
+
+ s->version = swfdec_bits_get_u8 (&bits);
+ dec->bytes_total = swfdec_bits_get_u32 (&bits);
+ if (dec->bytes_total <= 8) {
+ SWFDEC_ERROR ("Joke? Flash files need to be bigger than %u bytes", dec->bytes_total);
+ dec->bytes_total = 0;
+ return SWFDEC_STATUS_ERROR;
+ }
+ rest = swfdec_bits_get_buffer (&bits, -1);
+
+ data = g_try_malloc (dec->bytes_total);
+ if (data == NULL)
+ return SWFDEC_STATUS_ERROR;
+ buffer = swfdec_buffer_new_for_data (data, dec->bytes_total);
+ memcpy (buffer->data, s->buffer->data, 8);
+ swfdec_buffer_unref (s->buffer);
+ s->buffer = buffer;
+
+ s->compressed = (sig1 == 'C');
+ if (s->compressed) {
+ SWFDEC_DEBUG ("compressed");
+ if (!swf_inflate_init (s))
+ return SWFDEC_STATUS_ERROR;
+ } else {
+ SWFDEC_DEBUG ("not compressed");
+ }
+ SWFDEC_DECODER (s)->bytes_loaded = 8;
+ s->bytes_parsed = 8;
+ s->state = SWFDEC_STATE_INIT2;
+ swfdec_swf_decoder_deflate (s, rest);
+ dec->data_type = SWFDEC_LOADER_DATA_SWF;
+
+ return SWFDEC_STATUS_OK;
+}
+
+static int
+swf_parse_header2 (SwfdecSwfDecoder * s)
+{
+ guint n;
+ SwfdecRect rect;
+ SwfdecDecoder *dec = SWFDEC_DECODER (s);
+
+ swfdec_swf_decoder_init_bits (s, &s->b);
+ n = swfdec_bits_peekbits (&s->b, 5);
+ /* rect rate + total_frames */
+ n = ((5 + 4 * n + 7) / 8 + (2 + 2)) * 8;
+ if (swfdec_bits_left (&s->b) < n)
+ return SWFDEC_STATUS_NEEDBITS;
+
+ swfdec_bits_get_rect (&s->b, &rect);
+ if (rect.x0 != 0.0 || rect.y0 != 0.0)
+ SWFDEC_ERROR ("SWF window doesn't start at 0 0 but at %g %g", rect.x0, rect.y0);
+ SWFDEC_INFO ("SWF size: %g x %g pixels", rect.x1 / SWFDEC_TWIPS_SCALE_FACTOR,
+ rect.y1 / SWFDEC_TWIPS_SCALE_FACTOR);
+ dec->width = MAX (0, ceil (rect.x1 / SWFDEC_TWIPS_SCALE_FACTOR));
+ dec->height = MAX (0, ceil (rect.y1 / SWFDEC_TWIPS_SCALE_FACTOR));
+ swfdec_bits_syncbits (&s->b);
+ dec->rate = swfdec_bits_get_u16 (&s->b);
+ if (dec->rate == 0) {
+ SWFDEC_INFO ("rate is 0, setting to 65536");
+ dec->rate = 65536;
+ }
+ SWFDEC_LOG ("rate = %g", dec->rate / 256.0);
+ dec->frames_total = swfdec_bits_get_u16 (&s->b);
+ SWFDEC_LOG ("n_frames = %d", dec->frames_total);
+ swfdec_sprite_set_n_frames (s->main_sprite, dec->frames_total, dec->rate);
+
+ swfdec_swf_decoder_flush_bits (s, &s->b);
+
+ s->state = SWFDEC_STATE_PARSE_FIRST_TAG;
+ return SWFDEC_STATUS_INIT;
+}
+
+static SwfdecStatus
+swfdec_swf_decoder_parse_one (SwfdecSwfDecoder *s)
+{
+ int ret = SWFDEC_STATUS_OK;
+
+ s->b = s->parse;
+
+ switch (s->state) {
+ case SWFDEC_STATE_INIT1:
+ ret = swf_parse_header1 (s);
+ break;
+ case SWFDEC_STATE_INIT2:
+ ret = swf_parse_header2 (s);
+ break;
+ case SWFDEC_STATE_PARSE_FIRST_TAG:
+ case SWFDEC_STATE_PARSE_TAG:
+ {
+ guint header_length;
+ guint x;
+ SwfdecTagFunc func;
+ guint tag;
+ guint tag_len;
+ SwfdecBits bits;
+
+ /* we're parsing tags */
+ swfdec_swf_decoder_init_bits (s, &bits);
+ if (swfdec_bits_left (&bits) < 2 * 8)
+ return SWFDEC_STATUS_NEEDBITS;
+
+ x = swfdec_bits_get_u16 (&bits);
+ tag = (x >> 6) & 0x3ff;
+ SWFDEC_DEBUG ("tag %d %s", tag, swfdec_swf_decoder_get_tag_name (tag));
+ tag_len = x & 0x3f;
+ if (tag_len == 0x3f) {
+ if (swfdec_bits_left (&bits) < 4 * 8)
+ return SWFDEC_STATUS_NEEDBITS;
+
+ tag_len = swfdec_bits_get_u32 (&bits);
+ header_length = 6;
+ } else {
+ header_length = 2;
+ }
+
+ SWFDEC_INFO ("parsing at %d, tag %d %s, length %d",
+ s->bytes_parsed, tag,
+ swfdec_swf_decoder_get_tag_name (tag), tag_len);
+
+ if (swfdec_bits_left (&bits) / 8 < tag_len)
+ return SWFDEC_STATUS_NEEDBITS;
+
+ swfdec_bits_init_bits (&s->b, &bits, tag_len);
+ swfdec_swf_decoder_flush_bits (s, &bits);
+
+ func = swfdec_swf_decoder_get_tag_func (tag);
+ if (tag == 0) {
+ s->state = SWFDEC_STATE_EOF;
+ } else if ((swfdec_swf_decoder_get_tag_flag (tag) & SWFDEC_TAG_FIRST_ONLY)
+ && s->state == SWFDEC_STATE_PARSE_TAG) {
+ SWFDEC_WARNING ("tag %d %s must be first tag in file, ignoring",
+ tag, swfdec_swf_decoder_get_tag_name (tag));
+ } else if (func == NULL) {
+ SWFDEC_WARNING ("tag function not implemented for %d %s",
+ tag, swfdec_swf_decoder_get_tag_name (tag));
+ } else if (s->main_sprite->parse_frame < s->main_sprite->n_frames) {
+ s->parse_sprite = s->main_sprite;
+ ret = func (s, tag);
+ s->parse_sprite = NULL;
+
+ if (swfdec_bits_left (&s->b)) {
+ SWFDEC_WARNING
+ ("early finish (%d bytes) at %d, tag %d %s, length %d",
+ swfdec_bits_left (&s->b) / 8,
+ s->bytes_parsed, tag,
+ swfdec_swf_decoder_get_tag_name (tag), tag_len);
+ }
+ } else {
+ ret = SWFDEC_STATE_EOF;
+ SWFDEC_ERROR ("data after last frame");
+ }
+ s->state = SWFDEC_STATE_PARSE_TAG;
+
+ break;
+ }
+ case SWFDEC_STATE_EOF:
+ if (s->bytes_parsed < SWFDEC_DECODER (s)->bytes_loaded) {
+ SWFDEC_WARNING ("%u bytes after EOF", SWFDEC_DECODER (s)->bytes_loaded - s->bytes_parsed);
+ }
+ return SWFDEC_STATUS_EOF;
+ default:
+ g_assert_not_reached ();
+ }
+
+ /* copy state */
+ SWFDEC_DECODER (s)->frames_loaded = s->main_sprite->parse_frame;
+
+ return ret;
+}
+
+static SwfdecStatus
+swfdec_swf_decoder_parse (SwfdecDecoder *dec, SwfdecBuffer *buffer)
+{
+ SwfdecSwfDecoder *s = SWFDEC_SWF_DECODER (dec);
+ SwfdecStatus status = 0;
+
+ swfdec_swf_decoder_deflate (s, buffer);
+ do {
+ status |= swfdec_swf_decoder_parse_one (s);
+ } while ((status & (SWFDEC_STATUS_EOF | SWFDEC_STATUS_NEEDBITS | SWFDEC_STATUS_ERROR)) == 0);
+ return status;
+}
+
+static SwfdecStatus
+swfdec_swf_decoder_eof (SwfdecDecoder *dec)
+{
+ if (dec->bytes_loaded < dec->bytes_total) {
+ SWFDEC_ERROR ("only %u of %u bytes provided, broken transmission?",
+ dec->bytes_loaded, dec->bytes_total);
+ }
+
+ return 0;
+}
+
+static void
+swfdec_swf_decoder_class_init (SwfdecSwfDecoderClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+ SwfdecDecoderClass *decoder_class = SWFDEC_DECODER_CLASS (class);
+
+ object_class->dispose = swfdec_swf_decoder_dispose;
+
+ decoder_class->parse = swfdec_swf_decoder_parse;
+ decoder_class->eof = swfdec_swf_decoder_eof;
+}
+
+static void
+swfdec_swf_decoder_init (SwfdecSwfDecoder *s)
+{
+ s->main_sprite = g_object_new (SWFDEC_TYPE_SPRITE, NULL);
+
+ s->characters = g_hash_table_new_full (g_direct_hash, g_direct_equal,
+ NULL, g_object_unref);
+ s->scripts = g_hash_table_new_full (g_direct_hash, g_direct_equal,
+ NULL, (GDestroyNotify) swfdec_script_unref);
+}
+
+gpointer
+swfdec_swf_decoder_get_character (SwfdecSwfDecoder * s, guint id)
+{
+ g_return_val_if_fail (SWFDEC_IS_SWF_DECODER (s), NULL);
+
+ return g_hash_table_lookup (s->characters, GUINT_TO_POINTER (id));
+}
+
+/**
+ * swfdec_swf_decoder_create_character:
+ * @s: a #SwfdecDecoder
+ * @id: id of the character
+ * @type: the required type for the character
+ *
+ * Gets the character of the requested @type and with the given @id from @s.
+ * If there is already a different character with the given id, return NULL.
+ * If the character doesn't exist yet, create it.
+ *
+ * Returns: The requested character or NULL on failure;
+ **/
+gpointer
+swfdec_swf_decoder_create_character (SwfdecSwfDecoder * s, guint id, GType type)
+{
+ SwfdecCharacter *result;
+
+ g_return_val_if_fail (SWFDEC_IS_DECODER (s), NULL);
+ g_return_val_if_fail (g_type_is_a (type, SWFDEC_TYPE_CHARACTER), NULL);
+
+ SWFDEC_INFO (" id = %d", id);
+ result = swfdec_swf_decoder_get_character (s, id);
+ if (result) {
+ SWFDEC_WARNING ("character with id %d already exists", id);
+ return NULL;
+ }
+ result = g_object_new (type, NULL);
+ result->id = id;
+ g_hash_table_insert (s->characters, GUINT_TO_POINTER (id), result);
+ if (SWFDEC_IS_CACHED (result)) {
+ swfdec_cached_set_cache (SWFDEC_CACHED (result), SWFDEC_DECODER (s)->player->priv->cache);
+ }
+
+ return result;
+}
+
+void
+swfdec_swf_decoder_add_script (SwfdecSwfDecoder *s, SwfdecScript *script)
+{
+ g_return_if_fail (SWFDEC_IS_SWF_DECODER (s));
+ g_return_if_fail (script != NULL);
+ g_return_if_fail (script->buffer != NULL);
+
+ g_hash_table_insert (s->scripts, (gpointer) script->main, script);
+}
+
+SwfdecScript *
+swfdec_swf_decoder_get_script (SwfdecSwfDecoder *s, guint8 *data)
+{
+ g_return_val_if_fail (SWFDEC_IS_SWF_DECODER (s), NULL);
+ g_return_val_if_fail (data != NULL, NULL);
+
+ return g_hash_table_lookup (s->scripts, data);
+}
+
diff --git a/swfdec/swfdec_swf_decoder.h b/swfdec/swfdec_swf_decoder.h
new file mode 100644
index 0000000..dcd2e16
--- /dev/null
+++ b/swfdec/swfdec_swf_decoder.h
@@ -0,0 +1,98 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SWFDEC_SWF_DECODER_H__
+#define __SWFDEC_SWF_DECODER_H__
+
+#include <glib.h>
+#include <zlib.h>
+
+#include <libswfdec/swfdec_decoder.h>
+#include <libswfdec/swfdec_bits.h>
+#include <libswfdec/swfdec_types.h>
+#include <libswfdec/swfdec_rect.h>
+
+G_BEGIN_DECLS
+
+//typedef struct _SwfdecSwfDecoder SwfdecSwfDecoder;
+typedef struct _SwfdecSwfDecoderClass SwfdecSwfDecoderClass;
+typedef int (* SwfdecTagFunc) (SwfdecSwfDecoder *, guint);
+
+#define SWFDEC_TYPE_SWF_DECODER (swfdec_swf_decoder_get_type())
+#define SWFDEC_IS_SWF_DECODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SWF_DECODER))
+#define SWFDEC_IS_SWF_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SWF_DECODER))
+#define SWFDEC_SWF_DECODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SWF_DECODER, SwfdecSwfDecoder))
+#define SWFDEC_SWF_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SWF_DECODER, SwfdecSwfDecoderClass))
+#define SWFDEC_SWF_DECODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_SWF_DECODER, SwfdecSwfDecoderClass))
+
+struct _SwfdecSwfDecoder
+{
+ SwfdecDecoder decoder;
+
+ int version;
+
+ gboolean compressed; /* TRUE if this is a compressed flash file */
+ z_stream z; /* decompressor in use or uninitialized memory */
+ SwfdecBuffer * buffer; /* buffer containing uncompressed data */
+ guint bytes_parsed; /* number of bytes that have been processed by the parser */
+
+ int state; /* where we are in the top-level state engine */
+ SwfdecBits parse; /* where we are in global parsing */
+ SwfdecBits b; /* temporary state while parsing */
+
+ /* defined objects */
+ GHashTable * characters; /* list of all objects with an id (called characters) */
+ SwfdecSprite * main_sprite; /* the root sprite */
+ SwfdecSprite * parse_sprite; /* the sprite that parsed at the moment */
+ GHashTable * scripts; /* buffer -> script mapping for all scripts */
+
+ gboolean use_network; /* allow network or local access */
+ gboolean has_metadata; /* TRUE if this file contains metadata */
+ gboolean protection; /* TRUE is this file is protected and may not be edited */
+ char * password; /* MD5'd password to open for editing or NULL if may not be opened */
+
+ SwfdecBuffer * jpegtables; /* jpeg tables for DefineJPEG compressed jpeg files */
+};
+
+struct _SwfdecSwfDecoderClass {
+ SwfdecDecoderClass decoder_class;
+};
+
+GType swfdec_swf_decoder_get_type (void);
+
+gpointer swfdec_swf_decoder_get_character (SwfdecSwfDecoder * s,
+ guint id);
+gpointer swfdec_swf_decoder_create_character (SwfdecSwfDecoder * s,
+ guint id,
+ GType type);
+
+void swfdec_swf_decoder_add_script (SwfdecSwfDecoder * s,
+ SwfdecScript * script);
+SwfdecScript * swfdec_swf_decoder_get_script (SwfdecSwfDecoder * s,
+ guint8 * data);
+
+SwfdecTagFunc swfdec_swf_decoder_get_tag_func (int tag);
+const char *swfdec_swf_decoder_get_tag_name (int tag);
+int swfdec_swf_decoder_get_tag_flag (int tag);
+
+G_END_DECLS
+
+#endif
diff --git a/swfdec/swfdec_system.c b/swfdec/swfdec_system.c
new file mode 100644
index 0000000..00cdaf7
--- /dev/null
+++ b/swfdec/swfdec_system.c
@@ -0,0 +1,315 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_system.h"
+#include "swfdec_debug.h"
+
+/*** gtk-doc ***/
+
+/**
+ * SECTION:SwfdecSystem
+ * @title: SwfdecSystem
+ * @short_description: object holding system settings
+ * @see_also: SwfdecPlayer
+ *
+ * This object is used to provide information about the system Swfdec currently
+ * runs on.
+ *
+ * Almost all of this information can be categorized into three types:
+ * Information about the current playback engine like manufacturer or version,
+ * information about the current operating system and capabilities of the output
+ * capabilities of the System like screen size.
+ *
+ * The information provided by this object is used by the Actionscript
+ * System.capabilities.Query() function that is usually only run once during
+ * initialization of the Flash player. If you want to set custom properties and
+ * have them affect a running #SwfdecPlayer, you should change them before the
+ * player gets initialized.
+ *
+ * Note that the System.capabilites object in Flash provides more functionality
+ * than provided by this object. That information can be and is determined
+ * automatically by Swfdec.
+ */
+
+/**
+ * SwfdecSystem:
+ *
+ * This is the object used for holding information about the current system. See
+ * the introduction for details.
+ */
+
+/*** SwfdecSystem ***/
+
+enum {
+ PROP_0,
+ PROP_DEBUGGER,
+ PROP_MANUFACTURER,
+ PROP_SERVER_MANUFACTURER,
+ PROP_OS,
+ PROP_OS_TYPE,
+ PROP_PLAYER_TYPE,
+ PROP_VERSION,
+ PROP_LANGUAGE,
+ PROP_SCREEN_WIDTH,
+ PROP_SCREEN_HEIGHT,
+ PROP_PAR,
+ PROP_DPI,
+ PROP_COLOR_MODE,
+ PROP_UTC_OFFSET
+};
+
+G_DEFINE_TYPE (SwfdecSystem, swfdec_system, G_TYPE_OBJECT)
+
+static void
+swfdec_system_get_property (GObject *object, guint param_id, GValue *value,
+ GParamSpec * pspec)
+{
+ SwfdecSystem *system = SWFDEC_SYSTEM (object);
+
+ switch (param_id) {
+ case PROP_DEBUGGER:
+ g_value_set_boolean (value, system->debugger);
+ break;
+ case PROP_MANUFACTURER:
+ g_value_set_string (value, system->manufacturer);
+ break;
+ case PROP_SERVER_MANUFACTURER:
+ g_value_set_string (value, system->server_manufacturer);
+ break;
+ case PROP_OS:
+ g_value_set_string (value, system->os);
+ break;
+ case PROP_OS_TYPE:
+ g_value_set_string (value, system->os_type);
+ break;
+ case PROP_PLAYER_TYPE:
+ g_value_set_string (value, system->player_type);
+ break;
+ case PROP_VERSION:
+ g_value_set_string (value, system->version);
+ break;
+ case PROP_LANGUAGE:
+ g_value_set_string (value, system->language);
+ break;
+ case PROP_SCREEN_WIDTH:
+ g_value_set_uint (value, system->screen_width);
+ break;
+ case PROP_SCREEN_HEIGHT:
+ g_value_set_uint (value, system->screen_height);
+ break;
+ case PROP_PAR:
+ g_value_set_double (value, system->par);
+ break;
+ case PROP_DPI:
+ g_value_set_uint (value, system->dpi);
+ break;
+ case PROP_COLOR_MODE:
+ g_value_set_string (value, system->color_mode);
+ break;
+ case PROP_UTC_OFFSET:
+ g_value_set_int (value, system->utc_offset);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+swfdec_system_set_property (GObject *object, guint param_id, const GValue *value,
+ GParamSpec *pspec)
+{
+ SwfdecSystem *system = SWFDEC_SYSTEM (object);
+ char *s;
+
+ switch (param_id) {
+ case PROP_DEBUGGER:
+ system->debugger = g_value_get_boolean (value);
+ break;
+ case PROP_MANUFACTURER:
+ s = g_value_dup_string (value);
+ if (s) {
+ g_free (system->manufacturer);
+ system->manufacturer = s;
+ }
+ break;
+ case PROP_SERVER_MANUFACTURER:
+ s = g_value_dup_string (value);
+ if (s) {
+ g_free (system->server_manufacturer);
+ system->server_manufacturer = s;
+ }
+ break;
+ case PROP_OS:
+ s = g_value_dup_string (value);
+ if (s) {
+ g_free (system->os);
+ system->os = s;
+ }
+ break;
+ case PROP_OS_TYPE:
+ s = g_value_dup_string (value);
+ if (s) {
+ g_free (system->os_type);
+ system->os_type = s;
+ }
+ break;
+ case PROP_PLAYER_TYPE:
+ s = g_value_dup_string (value);
+ if (s) {
+ g_free (system->player_type);
+ system->player_type = s;
+ }
+ break;
+ case PROP_VERSION:
+ s = g_value_dup_string (value);
+ if (s) {
+ g_free (system->version);
+ system->version = s;
+ }
+ break;
+ case PROP_LANGUAGE:
+ s = g_value_dup_string (value);
+ if (s) {
+ g_free (system->language);
+ system->language = s;
+ }
+ break;
+ case PROP_SCREEN_WIDTH:
+ system->screen_width = g_value_get_uint (value);
+ break;
+ case PROP_SCREEN_HEIGHT:
+ system->screen_height = g_value_get_uint (value);
+ break;
+ case PROP_PAR:
+ system->par = g_value_get_double (value);
+ break;
+ case PROP_DPI:
+ system->dpi = g_value_get_uint (value);
+ break;
+ case PROP_COLOR_MODE:
+ s = g_value_dup_string (value);
+ if (s) {
+ g_free (system->color_mode);
+ system->color_mode = s;
+ }
+ break;
+ case PROP_UTC_OFFSET:
+ system->utc_offset = g_value_get_int (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+swfdec_system_finalize (GObject *object)
+{
+ SwfdecSystem *system = SWFDEC_SYSTEM (object);
+
+ g_free (system->manufacturer);
+ g_free (system->server_manufacturer);
+ g_free (system->os);
+ g_free (system->os_type);
+ g_free (system->player_type);
+ g_free (system->version);
+ g_free (system->language);
+ g_free (system->color_mode);
+
+ G_OBJECT_CLASS (swfdec_system_parent_class)->finalize (object);
+}
+
+static void
+swfdec_system_class_init (SwfdecSystemClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = swfdec_system_finalize;
+ object_class->get_property = swfdec_system_get_property;
+ object_class->set_property = swfdec_system_set_property;
+
+ g_object_class_install_property (object_class, PROP_DEBUGGER,
+ g_param_spec_boolean ("debugger", "debugger", "TRUE if this player is supposed to be a debugger",
+ FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_MANUFACTURER,
+ g_param_spec_string ("manufacturer", "manufacturer", "string describing the manufacturer of this system",
+ "Macromedia Windows", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_SERVER_MANUFACTURER,
+ g_param_spec_string ("server-manufacturer", "server-manufacturer", "manufacturer of this system as used in serverString",
+ "Adobe Windows", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_OS,
+ g_param_spec_string ("os", "os", "description of the operating system",
+ "Windows XP", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_OS_TYPE,
+ g_param_spec_string ("os-type", "os type", "the operating system type: WIN, LIN or MAC",
+ "WIN", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_PLAYER_TYPE,
+ g_param_spec_string ("player-type", "player type", "\"StandAlone\", \"External\", \"PlugIn\" or \"ActiveX\"",
+ "StandAlone", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_VERSION,
+ g_param_spec_string ("version", "version", "version string",
+ "WIN 9,0,100,0", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_LANGUAGE,
+ g_param_spec_string ("language", "language", "ISO 639-1 language code",
+ "en", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_SCREEN_WIDTH,
+ g_param_spec_uint ("screen-width", "screen width", "width of the screen in pixels",
+ 0, G_MAXUINT, 1024, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_SCREEN_HEIGHT,
+ g_param_spec_uint ("screen-height", "screen height", "height of the screen in pixels",
+ 0, G_MAXUINT, 768, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_PAR,
+ g_param_spec_double ("pixel-aspect-ratio", "pixel aspect ratio", "the screen's pixel aspect ratio",
+ G_MINDOUBLE, G_MAXDOUBLE, 1.0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_DPI,
+ g_param_spec_uint ("dpi", "dpi", "DPI setting of screen",
+ 0, G_MAXUINT, 96, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_COLOR_MODE,
+ g_param_spec_string ("color-mode", "color mode", "\"color\", \"gray\" or \"bw\"",
+ "color", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_UTC_OFFSET,
+ g_param_spec_int ("utc-offset", "utc offset",
+ "Difference between UTC and local timezone in minutes",
+ -12 * 60, 12 * 60, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+}
+
+static void
+swfdec_system_init (SwfdecSystem *system)
+{
+}
+
+/**
+ * swfdec_system_new:
+ *
+ * Creates a new #SwfdecSystem object using default settings. These settings are
+ * mirroring the most common settings used by a Flash player. Currently this is
+ * equivalent to a Flash player running on Windows XP.
+ *
+ * Returns: a new #SwfdecSystem object
+ **/
+SwfdecSystem *
+swfdec_system_new (void)
+{
+ return g_object_new (SWFDEC_TYPE_SYSTEM, NULL);
+}
diff --git a/swfdec/swfdec_system.h b/swfdec/swfdec_system.h
new file mode 100644
index 0000000..26c9647
--- /dev/null
+++ b/swfdec/swfdec_system.h
@@ -0,0 +1,76 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_SYSTEM_H_
+#define _SWFDEC_SYSTEM_H_
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecSystem SwfdecSystem;
+typedef struct _SwfdecSystemClass SwfdecSystemClass;
+
+#define SWFDEC_TYPE_SYSTEM (swfdec_system_get_type())
+#define SWFDEC_IS_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SYSTEM))
+#define SWFDEC_IS_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SYSTEM))
+#define SWFDEC_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SYSTEM, SwfdecSystem))
+#define SWFDEC_SYSTEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SYSTEM, SwfdecSystemClass))
+#define SWFDEC_SYSTEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_SYSTEM, SwfdecSystemClass))
+
+struct _SwfdecSystem
+{
+ GObject object;
+
+ /*< private >*/
+ /* player engine */
+ gboolean debugger; /* TRUE if this engine is debugging */
+ char * manufacturer; /* note that this includes OS information */
+ char * server_manufacturer; /* manufacturer as reported in serverString */
+ char * os; /* supposed to identify the operating system */
+ char * os_type; /* usually WIN, LIN or MAC */
+ char * player_type; /* "StandAlone", "External", "PlugIn" or "ActiveX" */
+ char * version; /* string of type "os_type MAJOR.MINOR.MACRO.MICRO" */
+
+ /* system */
+ char * language; /* ISO 639-1 language code */
+
+ /* screen */
+ guint screen_width; /* width of screen */
+ guint screen_height; /* height of screen */
+ double par; /* pixel aspect ratio */
+ guint dpi; /* dpi setting */
+ char * color_mode; /* "color", "gray" or "bw" */
+
+ /* date */
+ int utc_offset; /* difference between UTC and local timezeon in minutes */
+
+};
+
+struct _SwfdecSystemClass
+{
+ GObjectClass object_class;
+};
+
+GType swfdec_system_get_type (void);
+
+SwfdecSystem * swfdec_system_new (void);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_system_as.c b/swfdec/swfdec_system_as.c
new file mode 100644
index 0000000..0ba3f9e
--- /dev/null
+++ b/swfdec/swfdec_system_as.c
@@ -0,0 +1,347 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_string.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_codec_audio.h"
+#include "swfdec_debug.h"
+#include "swfdec_player_internal.h"
+
+SWFDEC_AS_NATIVE (1066, 0, swfdec_system_setClipboard)
+void
+swfdec_system_setClipboard (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("System.setClipboard (static)");
+}
+
+SWFDEC_AS_NATIVE (2107, 0, swfdec_system_showSettings)
+void
+swfdec_system_showSettings (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("System.showSettings (static)");
+}
+
+SWFDEC_AS_NATIVE (2107, 1, swfdec_system_get_exactSettings)
+void
+swfdec_system_get_exactSettings (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("System.exactSettings (static, get)");
+}
+
+SWFDEC_AS_NATIVE (2107, 2, swfdec_system_set_exactSettings)
+void
+swfdec_system_set_exactSettings (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("System.exactSettings (static, set)");
+}
+
+SWFDEC_AS_NATIVE (2107, 3, swfdec_system_get_useCodepage)
+void
+swfdec_system_get_useCodepage (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("System.useCodepage (static, get)");
+}
+
+SWFDEC_AS_NATIVE (2107, 4, swfdec_system_set_useCodepage)
+void
+swfdec_system_set_useCodepage (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("System.useCodepage (static, set)");
+}
+
+static void
+swfdec_system_has_audio (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ /* FIXME: allow setting this? */
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, TRUE);
+}
+
+static void
+swfdec_system_has_streaming_audio (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, TRUE);
+}
+
+static void
+swfdec_system_has_streaming_video (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ /* FIXME: check if video decoders got compiled in? */
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, TRUE);
+}
+
+static void
+swfdec_system_has_embedded_video (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ /* FIXME: what's this? */
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, TRUE);
+}
+
+static void
+swfdec_system_has_mp3 (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SwfdecAudioDecoder *dec = swfdec_audio_decoder_new (SWFDEC_AUDIO_CODEC_MP3,
+ swfdec_audio_format_new (44100, 2, TRUE));
+
+ if (dec) {
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, TRUE);
+ swfdec_audio_decoder_free (dec);
+ } else {
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
+ }
+}
+
+static void
+swfdec_system_has_audio_encoder (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
+}
+
+static void
+swfdec_system_has_video_encoder (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
+}
+
+static void
+swfdec_system_has_accessibility (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
+}
+
+static void
+swfdec_system_has_printing (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
+}
+
+static void
+swfdec_system_has_screen_broadcast (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
+}
+
+static void
+swfdec_system_has_screen_playback (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
+}
+
+static void
+swfdec_system_is_debugger (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, player->priv->system->debugger);
+}
+
+static void
+swfdec_system_version (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (
+ SWFDEC_AS_CONTEXT (player), player->priv->system->version));
+}
+
+static void
+swfdec_system_manufacturer (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (
+ SWFDEC_AS_CONTEXT (player), player->priv->system->manufacturer));
+}
+
+static void
+swfdec_system_screen_width (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_INT (ret, player->priv->system->screen_width);
+}
+
+static void
+swfdec_system_screen_height (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_INT (ret, player->priv->system->screen_height);
+}
+
+static void
+swfdec_system_screen_dpi (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_INT (ret, player->priv->system->dpi);
+}
+
+static void
+swfdec_system_screen_color (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (
+ SWFDEC_AS_CONTEXT (player), player->priv->system->color_mode));
+}
+
+static void
+swfdec_system_screen_par (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, player->priv->system->par);
+}
+
+static void
+swfdec_system_os (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (
+ SWFDEC_AS_CONTEXT (player), player->priv->system->os));
+}
+
+static void
+swfdec_system_language (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (
+ SWFDEC_AS_CONTEXT (player), player->priv->system->language));
+}
+
+static void
+swfdec_system_has_ime (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
+}
+
+static void
+swfdec_system_player_type (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (
+ SWFDEC_AS_CONTEXT (player), player->priv->system->player_type));
+}
+
+static void
+swfdec_system_av_disabled (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
+}
+
+static void
+swfdec_system_local_file_disabled (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
+}
+
+static void
+swfdec_system_windowless_disabled (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
+}
+
+static void
+swfdec_system_has_tls (SwfdecPlayer *player, SwfdecAsValue *ret)
+{
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
+}
+
+/* NB: ordered for the query string order */
+const struct {
+ const char * name;
+ const char * server_string;
+ void (* get) (SwfdecPlayer *player, SwfdecAsValue *ret);
+} queries[] = {
+ { SWFDEC_AS_STR_hasAudio, "A", swfdec_system_has_audio },
+ { SWFDEC_AS_STR_hasStreamingAudio, "SA", swfdec_system_has_streaming_audio },
+ { SWFDEC_AS_STR_hasStreamingVideo, "SV", swfdec_system_has_streaming_video },
+ { SWFDEC_AS_STR_hasEmbeddedVideo, "EV", swfdec_system_has_embedded_video },
+ { SWFDEC_AS_STR_hasMP3, "MP3", swfdec_system_has_mp3 },
+ { SWFDEC_AS_STR_hasAudioEncoder, "AE", swfdec_system_has_audio_encoder },
+ { SWFDEC_AS_STR_hasVideoEncoder, "VE", swfdec_system_has_video_encoder },
+ { SWFDEC_AS_STR_hasAccessibility, "ACC", swfdec_system_has_accessibility },
+ { SWFDEC_AS_STR_hasPrinting, "PR", swfdec_system_has_printing },
+ { SWFDEC_AS_STR_hasScreenPlayback, "SP", swfdec_system_has_screen_playback },
+ { SWFDEC_AS_STR_hasScreenBroadcast, "SB", swfdec_system_has_screen_broadcast },
+ { SWFDEC_AS_STR_isDebugger, "DEB", swfdec_system_is_debugger },
+ { SWFDEC_AS_STR_version, "V", swfdec_system_version },
+ { SWFDEC_AS_STR_manufacturer, NULL, swfdec_system_manufacturer },
+ { SWFDEC_AS_STR_screenResolutionX, "R", swfdec_system_screen_width },
+ { SWFDEC_AS_STR_screenResolutionY, NULL, swfdec_system_screen_height },
+ { SWFDEC_AS_STR_screenDPI, "DP", swfdec_system_screen_dpi },
+ { SWFDEC_AS_STR_screenColor, "COL", swfdec_system_screen_color },
+ { SWFDEC_AS_STR_pixelAspectRatio, NULL, swfdec_system_screen_par },
+ { SWFDEC_AS_STR_os, "OS", swfdec_system_os },
+ { SWFDEC_AS_STR_language, "L", swfdec_system_language },
+ { SWFDEC_AS_STR_hasIME, "IME", swfdec_system_has_ime },
+ { SWFDEC_AS_STR_playerType, "PT", swfdec_system_player_type },
+ { SWFDEC_AS_STR_avHardwareDisable, "AVD", swfdec_system_av_disabled },
+ { SWFDEC_AS_STR_localFileReadDisable, "LFD", swfdec_system_local_file_disabled },
+ { SWFDEC_AS_STR_windowlessDisable, "WD", swfdec_system_windowless_disabled },
+ { SWFDEC_AS_STR_hasTLS, "TLS", swfdec_system_has_tls },
+};
+
+SWFDEC_AS_NATIVE (11, 0, swfdec_system_query)
+void
+swfdec_system_query (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (cx);
+ SwfdecAsValue val;
+ guint i;
+ GString *server;
+
+ if (object == NULL) {
+ SWFDEC_WARNING ("no this object in Query()");
+ return;
+ }
+
+ server = g_string_new ("");
+ for (i = 0; i < G_N_ELEMENTS (queries); i++) {
+ queries[i].get (player, &val);
+ swfdec_as_object_set_variable (object, queries[i].name, &val);
+ if (queries[i].name == SWFDEC_AS_STR_screenResolutionY) {
+ g_string_append_printf (server, "x%d", (int) SWFDEC_AS_VALUE_GET_NUMBER (&val));
+ } else if (queries[i].name == SWFDEC_AS_STR_pixelAspectRatio) {
+ char buffer[10];
+ g_ascii_formatd (buffer, sizeof (buffer), "%.1f",
+ SWFDEC_AS_VALUE_GET_NUMBER (&val));
+ g_string_append (server, "&AR=");
+ g_string_append (server, buffer);
+ } else if (queries[i].name == SWFDEC_AS_STR_manufacturer) {
+ char *s = swfdec_as_string_escape (cx, player->priv->system->server_manufacturer);
+ g_string_append_printf (server, "&M=%s", s);
+ g_free (s);
+ } else {
+ g_assert (queries[i].server_string);
+ if (i > 0)
+ g_string_append_c (server, '&');
+ g_string_append (server, queries[i].server_string);
+ g_string_append_c (server, '=');
+ if (SWFDEC_AS_VALUE_IS_BOOLEAN (&val)) {
+ g_string_append_c (server, SWFDEC_AS_VALUE_GET_BOOLEAN (&val) ? 't' : 'f');
+ } else if (SWFDEC_AS_VALUE_IS_NUMBER (&val)) {
+ g_string_append_printf (server, "%d", (int) SWFDEC_AS_VALUE_GET_NUMBER (&val));
+ } else if (SWFDEC_AS_VALUE_IS_STRING (&val)) {
+ char *s = swfdec_as_string_escape (cx, SWFDEC_AS_VALUE_GET_STRING (&val));
+ g_string_append (server, s);
+ g_free (s);
+ } else {
+ g_assert_not_reached ();
+ }
+ }
+ }
+ SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_give_string (cx, g_string_free (server, FALSE)));
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_serverString, &val);
+}
+
diff --git a/swfdec/swfdec_system_ime.c b/swfdec/swfdec_system_ime.c
new file mode 100644
index 0000000..3506806
--- /dev/null
+++ b/swfdec/swfdec_system_ime.c
@@ -0,0 +1,79 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (13, 0, swfdec_system_ime_getEnabled)
+void
+swfdec_system_ime_getEnabled (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("System.IME.getEnabled (static)");
+}
+
+SWFDEC_AS_NATIVE (13, 1, swfdec_system_ime_setEnabled)
+void
+swfdec_system_ime_setEnabled (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("System.IME.setEnabled (static)");
+}
+
+SWFDEC_AS_NATIVE (13, 2, swfdec_system_ime_getCovnersionMode)
+void
+swfdec_system_ime_getCovnersionMode (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("System.IME.getCovnersionMode (static)");
+}
+
+SWFDEC_AS_NATIVE (13, 3, swfdec_system_ime_setConversionMode)
+void
+swfdec_system_ime_setConversionMode (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("System.IME.setConversionMode (static)");
+}
+
+SWFDEC_AS_NATIVE (13, 4, swfdec_system_ime_setCompositionString)
+void
+swfdec_system_ime_setCompositionString (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("System.IME.setCompositionString (static)");
+}
+
+SWFDEC_AS_NATIVE (13, 5, swfdec_system_ime_doConversion)
+void
+swfdec_system_ime_doConversion (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("System.IME.doConversion (static)");
+}
diff --git a/swfdec/swfdec_system_security.c b/swfdec/swfdec_system_security.c
new file mode 100644
index 0000000..284eea1
--- /dev/null
+++ b/swfdec/swfdec_system_security.c
@@ -0,0 +1,123 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_resource.h"
+#include "swfdec_player_internal.h"
+
+// properties
+SWFDEC_AS_NATIVE (12, 0, swfdec_system_security_allowDomain)
+void
+swfdec_system_security_allowDomain (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("System.security.allowDomain (static)");
+}
+
+SWFDEC_AS_NATIVE (12, 1, swfdec_system_security_allowInsecureDomain)
+void
+swfdec_system_security_allowInsecureDomain (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("System.security.allowInsecureDomain (static)");
+}
+
+SWFDEC_AS_NATIVE (12, 2, swfdec_system_security_loadPolicyFile)
+void
+swfdec_system_security_loadPolicyFile (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("System.security.loadPolicyFile (static)");
+}
+
+SWFDEC_AS_NATIVE (12, 3, swfdec_system_security_chooseLocalSwfPath)
+void
+swfdec_system_security_chooseLocalSwfPath (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("System.security.chooseLocalSwfPath (static)");
+}
+
+SWFDEC_AS_NATIVE (12, 4, swfdec_system_security_escapeDomain)
+void
+swfdec_system_security_escapeDomain (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("System.security.escapeDomain (static)");
+}
+
+SWFDEC_AS_NATIVE (12, 5, swfdec_system_security_get_sandboxType)
+void
+swfdec_system_security_get_sandboxType (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ switch (SWFDEC_SANDBOX (cx->global)->type) {
+ case SWFDEC_SANDBOX_REMOTE:
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_remote);
+ break;
+
+ case SWFDEC_SANDBOX_LOCAL_FILE:
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_localWithFile);
+ break;
+
+ case SWFDEC_SANDBOX_LOCAL_NETWORK:
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_localWithNetwork);
+ break;
+
+ case SWFDEC_SANDBOX_LOCAL_TRUSTED:
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_localTrusted);
+ break;
+
+ case SWFDEC_SANDBOX_NONE:
+ default:
+ g_return_if_reached ();
+ }
+}
+
+SWFDEC_AS_NATIVE (12, 6, swfdec_system_security_set_sandboxType)
+void
+swfdec_system_security_set_sandboxType (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ // read-only
+}
+
+// PolicyFileResolver
+
+SWFDEC_AS_NATIVE (15, 0, swfdec_system_security_policy_file_resolver_resolve)
+void
+swfdec_system_security_policy_file_resolver_resolve (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("System.security.PolicyFileResolver.resolve");
+}
diff --git a/swfdec/swfdec_tag.c b/swfdec/swfdec_tag.c
new file mode 100644
index 0000000..133f8b2
--- /dev/null
+++ b/swfdec/swfdec_tag.c
@@ -0,0 +1,628 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <zlib.h>
+#include <math.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "swfdec_tag.h"
+#include "swfdec_bits.h"
+#include "swfdec_button.h"
+#include "swfdec_debug.h"
+#include "swfdec_text_field.h"
+#include "swfdec_filter.h"
+#include "swfdec_font.h"
+#include "swfdec_image.h"
+#include "swfdec_morphshape.h"
+#include "swfdec_pattern.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_script_internal.h"
+#include "swfdec_shape.h"
+#include "swfdec_sound.h"
+#include "swfdec_sprite.h"
+#include "swfdec_text.h"
+#include "swfdec_video.h"
+
+static int
+tag_func_end (SwfdecSwfDecoder * s, guint tag)
+{
+ return SWFDEC_STATUS_OK;
+}
+
+static int
+tag_func_protect (SwfdecSwfDecoder * s, guint tag)
+{
+ if (s->protection) {
+ SWFDEC_INFO ("This file is really protected.");
+ g_free (s->password);
+ s->password = NULL;
+ }
+ s->protection = TRUE;
+ if (swfdec_bits_left (&s->b)) {
+ /* FIXME: What's this for? */
+ swfdec_bits_get_u16 (&s->b);
+ s->password = swfdec_bits_get_string (&s->b, s->version);
+ }
+ return SWFDEC_STATUS_OK;
+}
+
+static int
+tag_func_frame_label (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecSpriteFrame *frame = &s->parse_sprite->frames[s->parse_sprite->parse_frame];
+
+ if (frame->label) {
+ SWFDEC_WARNING ("frame %d already has a label (%s)", s->parse_sprite->parse_frame, frame->label);
+ g_free (frame->label);
+ }
+ frame->label = swfdec_bits_get_string (&s->b, s->version);
+ SWFDEC_LOG ("frame %d named %s", s->parse_sprite->parse_frame, frame->label);
+
+ return SWFDEC_STATUS_OK;
+}
+
+
+/* text */
+
+int
+tag_func_define_text (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecBits *bits = &s->b;
+ int id;
+ int n_glyph_bits;
+ int n_advance_bits;
+ SwfdecText *text = NULL;
+ SwfdecTextGlyph glyph = { 0 };
+
+ id = swfdec_bits_get_u16 (bits);
+ text = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_TEXT);
+ if (!text)
+ return SWFDEC_STATUS_OK;
+
+ glyph.color = 0xffffffff;
+
+ swfdec_bits_get_rect (bits, &SWFDEC_GRAPHIC (text)->extents);
+ swfdec_bits_get_matrix (bits, &text->transform, &text->transform_inverse);
+ swfdec_bits_syncbits (bits);
+ n_glyph_bits = swfdec_bits_get_u8 (bits);
+ n_advance_bits = swfdec_bits_get_u8 (bits);
+
+ //printf(" n_glyph_bits = %d\n", n_glyph_bits);
+ //printf(" n_advance_bits = %d\n", n_advance_bits);
+
+ while (swfdec_bits_peekbits (bits, 8) != 0) {
+ int type;
+
+ type = swfdec_bits_getbit (bits);
+ if (type == 0) {
+ /* glyph record */
+ int n_glyphs;
+ int i;
+
+ n_glyphs = swfdec_bits_getbits (bits, 7);
+ if (glyph.font == NULL)
+ SWFDEC_ERROR ("no font for %d glyphs", n_glyphs);
+ for (i = 0; i < n_glyphs; i++) {
+ glyph.glyph = swfdec_bits_getbits (bits, n_glyph_bits);
+
+ if (glyph.font != NULL)
+ g_array_append_val (text->glyphs, glyph);
+ glyph.x += swfdec_bits_getsbits (bits, n_advance_bits);
+ }
+ } else {
+ /* state change */
+ int reserved;
+ int has_font;
+ int has_color;
+ int has_y_offset;
+ int has_x_offset;
+
+ reserved = swfdec_bits_getbits (bits, 3);
+ has_font = swfdec_bits_getbit (bits);
+ has_color = swfdec_bits_getbit (bits);
+ has_y_offset = swfdec_bits_getbit (bits);
+ has_x_offset = swfdec_bits_getbit (bits);
+ if (has_font) {
+ glyph.font = swfdec_swf_decoder_get_character (s, swfdec_bits_get_u16 (bits));
+ //printf(" font = %d\n",font);
+ }
+ if (has_color) {
+ if (tag == SWFDEC_TAG_DEFINETEXT) {
+ glyph.color = swfdec_bits_get_color (bits);
+ } else {
+ glyph.color = swfdec_bits_get_rgba (bits);
+ }
+ //printf(" color = %08x\n",glyph.color);
+ }
+ if (has_x_offset) {
+ glyph.x = swfdec_bits_get_s16 (bits);
+ }
+ if (has_y_offset) {
+ glyph.y = swfdec_bits_get_s16 (bits);
+ }
+ if (has_font) {
+ glyph.height = swfdec_bits_get_u16 (bits);
+ }
+ }
+ swfdec_bits_syncbits (bits);
+ }
+ swfdec_bits_get_u8 (bits);
+
+ return SWFDEC_STATUS_OK;
+}
+
+int
+tag_func_define_sprite (SwfdecSwfDecoder * s, guint define_sprite_tag)
+{
+ SwfdecBits parse;
+ int id;
+ SwfdecSprite *sprite;
+ int ret;
+ guint tag = 1;
+
+ parse = s->b;
+
+ id = swfdec_bits_get_u16 (&parse);
+ sprite = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_SPRITE);
+ if (!sprite)
+ return SWFDEC_STATUS_OK;
+
+ SWFDEC_LOG (" ID: %d", id);
+
+ swfdec_sprite_set_n_frames (sprite, swfdec_bits_get_u16 (&parse), SWFDEC_DECODER (s)->rate);
+
+ s->parse_sprite = sprite;
+ while (swfdec_bits_left (&parse)) {
+ int x;
+ guint tag_len;
+ SwfdecTagFunc func;
+
+ x = swfdec_bits_get_u16 (&parse);
+ tag = (x >> 6) & 0x3ff;
+ tag_len = x & 0x3f;
+ if (tag_len == 0x3f) {
+ tag_len = swfdec_bits_get_u32 (&parse);
+ }
+ SWFDEC_INFO ("sprite parsing at %td, tag %d %s, length %d",
+ parse.buffer ? parse.ptr - parse.buffer->data : 0, tag,
+ swfdec_swf_decoder_get_tag_name (tag), tag_len);
+
+ if (tag_len == 0) {
+ swfdec_bits_init_data (&s->b, NULL, 0);
+ } else {
+ swfdec_bits_init_bits (&s->b, &parse, tag_len);
+ }
+
+ func = swfdec_swf_decoder_get_tag_func (tag);
+ if (tag == 0) {
+ break;
+ } else if (func == NULL) {
+ SWFDEC_WARNING ("tag function not implemented for %d %s",
+ tag, swfdec_swf_decoder_get_tag_name (tag));
+ } else if ((swfdec_swf_decoder_get_tag_flag (tag) & 1) == 0) {
+ SWFDEC_ERROR ("invalid tag %d %s during DefineSprite",
+ tag, swfdec_swf_decoder_get_tag_name (tag));
+ } else if (s->parse_sprite->parse_frame < s->parse_sprite->n_frames) {
+ ret = func (s, tag);
+
+ if (swfdec_bits_left (&s->b)) {
+ SWFDEC_WARNING ("early parse finish (%d bytes)",
+ swfdec_bits_left (&s->b) / 8);
+ }
+ } else {
+ SWFDEC_ERROR ("data after last frame");
+ }
+ }
+
+ /* sanity check the sprite */
+ if (s->parse_sprite->n_frames != s->parse_sprite->parse_frame) {
+ SWFDEC_INFO ("not enough frames in sprite %u (have %u, want %u), filling up with empty frames",
+ id, s->parse_sprite->parse_frame, s->parse_sprite->n_frames);
+ s->parse_sprite->parse_frame = s->parse_sprite->n_frames;
+ }
+
+ s->b = parse;
+ /* this assumes that no recursive DefineSprite happens and we check it doesn't */
+ s->parse_sprite = s->main_sprite;
+ SWFDEC_LOG ("done parsing this sprite");
+
+ return SWFDEC_STATUS_OK;
+}
+
+#if 0
+static int
+tag_func_define_button_2 (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecBits bits;
+ int id, reserved;
+ guint length;
+ SwfdecButton *button;
+ char *script_name;
+
+ id = swfdec_bits_get_u16 (&s->b);
+ button = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_BUTTON);
+ if (!button)
+ return SWFDEC_STATUS_OK;
+
+ SWFDEC_LOG (" ID: %d", id);
+
+ reserved = swfdec_bits_getbits (&s->b, 7);
+ button->menubutton = swfdec_bits_getbit (&s->b) ? TRUE : FALSE;
+ length = swfdec_bits_get_u16 (&s->b);
+
+ SWFDEC_LOG (" reserved = %d", reserved);
+ SWFDEC_LOG (" menu = %d", button->menubutton);
+ SWFDEC_LOG (" length of region = %d", length);
+
+ if (length)
+ swfdec_bits_init_bits (&bits, &s->b, length > 2 ? length - 2 : 0);
+ else
+ swfdec_bits_init_bits (&bits, &s->b, swfdec_bits_left (&s->b) / 8);
+ while (swfdec_bits_peek_u8 (&bits)) {
+ guint character;
+ guint depth;
+ guint states;
+ gboolean has_blend_mode, has_filters;
+ SwfdecContent *content;
+
+ if (s->version >= 8) {
+ reserved = swfdec_bits_getbits (&bits, 2);
+ has_blend_mode = swfdec_bits_getbit (&bits);
+ has_filters = swfdec_bits_getbit (&bits);
+ SWFDEC_LOG (" reserved = %d", reserved);
+ SWFDEC_LOG (" has_blend_mode = %d", has_blend_mode);
+ SWFDEC_LOG (" has_filters = %d", has_filters);
+ } else {
+ reserved = swfdec_bits_getbits (&bits, 4);
+ has_blend_mode = 0;
+ has_filters = 0;
+ SWFDEC_LOG (" reserved = %d", reserved);
+ }
+ states = swfdec_bits_getbits (&bits, 4);
+ character = swfdec_bits_get_u16 (&bits);
+ depth = swfdec_bits_get_u16 (&bits);
+
+ SWFDEC_LOG (" states: %s%s%s%scharacter=%u layer=%u",
+ states & (1 << SWFDEC_BUTTON_HIT) ? "HIT " : "",
+ states & (1 << SWFDEC_BUTTON_DOWN) ? "DOWN " : "",
+ states & (1 << SWFDEC_BUTTON_OVER) ? "OVER " : "",
+ states & (1 << SWFDEC_BUTTON_UP) ? "UP " : "",
+ character, depth);
+ content = swfdec_content_new (depth);
+
+ swfdec_bits_get_matrix (&bits, &content->transform, NULL);
+ content->has_transform = TRUE;
+ SWFDEC_LOG ("matrix: %g %g %g %g %g %g",
+ content->transform.xx, content->transform.yy,
+ content->transform.xy, content->transform.yx,
+ content->transform.x0, content->transform.y0);
+ swfdec_bits_get_color_transform (&bits, &content->color_transform);
+ content->has_color_transform = TRUE;
+
+ content->graphic = swfdec_swf_decoder_get_character (s, character);
+ if (has_blend_mode) {
+ content->blend_mode = swfdec_bits_get_u8 (&bits);
+ SWFDEC_LOG (" blend mode = %u", content->blend_mode);
+ }
+ if (has_filters) {
+ GSList *list = swfdec_filter_parse (SWFDEC_DECODER (s)->player, &bits);
+ g_slist_free (list);
+ }
+ if (!SWFDEC_IS_GRAPHIC (content->graphic)) {
+ SWFDEC_ERROR ("id %u does not reference a graphic, ignoring", character);
+ swfdec_content_free (content);
+ } else {
+ swfdec_button_append_content (button, states, content);
+ }
+ }
+ swfdec_bits_get_u8 (&bits);
+ if (swfdec_bits_left (&bits)) {
+ SWFDEC_WARNING ("%u bytes left when parsing button records", swfdec_bits_left (&bits) / 8);
+ }
+
+ script_name = g_strdup_printf ("Button%u", SWFDEC_CHARACTER (button)->id);
+ while (length != 0) {
+ guint condition, key;
+
+ length = swfdec_bits_get_u16 (&s->b);
+ if (length)
+ swfdec_bits_init_bits (&bits, &s->b, length > 2 ? length - 2 : 0);
+ else
+ swfdec_bits_init_bits (&bits, &s->b, swfdec_bits_left (&s->b) / 8);
+ condition = swfdec_bits_get_u16 (&bits);
+ key = condition >> 9;
+ condition &= 0x1FF;
+
+ SWFDEC_LOG (" length = %d", length);
+
+ if (button->events == NULL)
+ button->events = swfdec_event_list_new (SWFDEC_DECODER (s)->player);
+ SWFDEC_LOG (" new event for condition %u (key %u)", condition, key);
+ swfdec_event_list_parse (button->events, &bits, s->version, condition, key,
+ script_name);
+ if (swfdec_bits_left (&bits)) {
+ SWFDEC_WARNING ("%u bytes left after parsing script", swfdec_bits_left (&bits) / 8);
+ }
+ }
+ g_free (script_name);
+
+ return SWFDEC_STATUS_OK;
+}
+
+static int
+tag_func_define_button (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecBits *bits = &s->b;
+ int id;
+ SwfdecButton *button;
+ char *script_name;
+
+ id = swfdec_bits_get_u16 (bits);
+ button = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_BUTTON);
+ if (!button)
+ return SWFDEC_STATUS_OK;
+
+ SWFDEC_LOG (" ID: %d", id);
+
+ while (swfdec_bits_peek_u8 (bits)) {
+ int reserved;
+ guint character;
+ guint depth;
+ guint states;
+ SwfdecContent *content;
+
+ swfdec_bits_syncbits (bits);
+ reserved = swfdec_bits_getbits (bits, 4);
+ states = swfdec_bits_getbits (bits, 4);
+ character = swfdec_bits_get_u16 (bits);
+ depth = swfdec_bits_get_u16 (bits);
+
+ SWFDEC_LOG (" reserved = %d", reserved);
+ SWFDEC_LOG ("states: %s%s%s%scharacter=%u layer=%u",
+ states & (1 << SWFDEC_BUTTON_HIT) ? "HIT " : "",
+ states & (1 << SWFDEC_BUTTON_DOWN) ? "DOWN " : "",
+ states & (1 << SWFDEC_BUTTON_OVER) ? "OVER " : "",
+ states & (1 << SWFDEC_BUTTON_UP) ? "UP " : "",
+ character, depth);
+ content = swfdec_content_new (depth);
+
+ swfdec_bits_get_matrix (bits, &content->transform, NULL);
+ content->has_transform = TRUE;
+ SWFDEC_LOG ("matrix: %g %g %g %g %g %g",
+ content->transform.xx, content->transform.yy,
+ content->transform.xy, content->transform.yx,
+ content->transform.x0, content->transform.y0);
+
+ content->graphic = swfdec_swf_decoder_get_character (s, character);
+ if (!SWFDEC_IS_GRAPHIC (content->graphic)) {
+ SWFDEC_ERROR ("id %u does not reference a graphic, ignoring", character);
+ swfdec_content_free (content);
+ } else {
+ swfdec_button_append_content (button, states, content);
+ }
+ }
+ swfdec_bits_get_u8 (bits);
+
+ script_name = g_strdup_printf ("Button%u", SWFDEC_CHARACTER (button)->id);
+ button->events = swfdec_event_list_new (SWFDEC_DECODER (s)->player);
+ swfdec_event_list_parse (button->events, &s->b, s->version,
+ SWFDEC_BUTTON_OVER_UP_TO_OVER_DOWN, 0, script_name);
+ g_free (script_name);
+
+ return SWFDEC_STATUS_OK;
+}
+#endif
+
+static int
+tag_func_file_attributes (SwfdecSwfDecoder *s, guint tag)
+{
+ if (swfdec_bits_getbits (&s->b, 3))
+ SWFDEC_INFO ("reserved bits (1) aren't 0");
+ s->has_metadata = swfdec_bits_getbit (&s->b);
+ SWFDEC_LOG (" has metadata: %d", s->has_metadata);
+ if (swfdec_bits_getbits (&s->b, 3))
+ SWFDEC_INFO ("reserved bits (2) aren't 0");
+ s->use_network = swfdec_bits_getbit (&s->b);
+ SWFDEC_LOG (" use network: %d", s->use_network);
+ if (swfdec_bits_getbits (&s->b, 24))
+ SWFDEC_INFO ("reserved bits (3) aren't 0");
+ /* initialize default security if it wasn't initialized yet */
+
+ return SWFDEC_STATUS_OK;
+}
+
+static int
+tag_func_enqueue (SwfdecSwfDecoder *s, guint tag)
+{
+ SwfdecBuffer *buffer;
+
+ buffer = swfdec_bits_get_buffer (&s->b, -1);
+ SWFDEC_LOG ("queueing %s tag for sprite %u", swfdec_swf_decoder_get_tag_name (tag),
+ SWFDEC_CHARACTER (s->parse_sprite)->id);
+ swfdec_sprite_add_action (s->parse_sprite, tag, buffer);
+
+ return SWFDEC_STATUS_OK;
+}
+
+static int
+tag_func_show_frame (SwfdecSwfDecoder * s, guint tag)
+{
+ SWFDEC_DEBUG("show_frame %d of id %d", s->parse_sprite->parse_frame,
+ SWFDEC_CHARACTER (s->parse_sprite)->id);
+
+ s->parse_sprite->parse_frame++;
+ if (s->parse_sprite->parse_frame < s->parse_sprite->n_frames) {
+ SwfdecSpriteFrame *old = &s->parse_sprite->frames[s->parse_sprite->parse_frame - 1];
+ SwfdecSpriteFrame *new = &s->parse_sprite->frames[s->parse_sprite->parse_frame];
+ if (old->sound_head)
+ new->sound_head = g_object_ref (old->sound_head);
+ }
+ tag_func_enqueue (s, tag);
+
+ return SWFDEC_STATUS_IMAGE;
+}
+
+static int
+tag_func_do_action (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecScript *script;
+ SwfdecBits bits;
+ char *name;
+
+ name = g_strdup_printf ("Sprite%u_Frame%u", SWFDEC_CHARACTER (s->parse_sprite)->id,
+ s->parse_sprite->parse_frame);
+ bits = s->b;
+ script = swfdec_script_new_from_bits (&bits, name, s->version);
+ g_free (name);
+ if (script) {
+ swfdec_swf_decoder_add_script (s, script);
+ tag_func_enqueue (s, tag);
+ }
+
+ return SWFDEC_STATUS_OK;
+}
+
+struct tag_func_struct
+{
+ const char *name;
+ SwfdecTagFunc func;
+ int flag;
+};
+static struct tag_func_struct tag_funcs[] = {
+ [SWFDEC_TAG_END] = {"End", tag_func_end, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_SHOWFRAME] = {"ShowFrame", tag_func_show_frame, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_DEFINESHAPE] = {"DefineShape", tag_define_shape, 0},
+ [SWFDEC_TAG_FREECHARACTER] = {"FreeCharacter", NULL, 0},
+ [SWFDEC_TAG_PLACEOBJECT] = {"PlaceObject", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_REMOVEOBJECT] = {"RemoveObject", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_DEFINEBITSJPEG] = {"DefineBitsJPEG", tag_func_define_bits_jpeg, 0},
+ [SWFDEC_TAG_DEFINEBUTTON] = {"DefineButton", tag_func_define_button, 0},
+ [SWFDEC_TAG_JPEGTABLES] = {"JPEGTables", swfdec_image_jpegtables, 0},
+ [SWFDEC_TAG_SETBACKGROUNDCOLOR] =
+ {"SetBackgroundColor", tag_func_set_background_color, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_DEFINEFONT] = {"DefineFont", tag_func_define_font, 0},
+ [SWFDEC_TAG_DEFINETEXT] = {"DefineText", tag_func_define_text, 0},
+ [SWFDEC_TAG_DOACTION] = {"DoAction", tag_func_do_action, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_DEFINEFONTINFO] = {"DefineFontInfo", tag_func_define_font_info, 0},
+ [SWFDEC_TAG_DEFINESOUND] = {"DefineSound", tag_func_define_sound, 0},
+ [SWFDEC_TAG_STARTSOUND] = {"StartSound", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_DEFINEBUTTONSOUND] =
+ {"DefineButtonSound", tag_func_define_button_sound, 0},
+ [SWFDEC_TAG_SOUNDSTREAMHEAD] = {"SoundStreamHead", tag_func_sound_stream_head, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_SOUNDSTREAMBLOCK] = {"SoundStreamBlock", tag_func_sound_stream_block, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_DEFINEBITSLOSSLESS] =
+ {"DefineBitsLossless", tag_func_define_bits_lossless, 0},
+ [SWFDEC_TAG_DEFINEBITSJPEG2] = {"DefineBitsJPEG2", tag_func_define_bits_jpeg_2, 0},
+ [SWFDEC_TAG_DEFINESHAPE2] = {"DefineShape2", tag_define_shape, 0},
+ [SWFDEC_TAG_DEFINEBUTTONCXFORM] = {"DefineButtonCXForm", NULL, 0},
+ [SWFDEC_TAG_PROTECT] = {"Protect", tag_func_protect, 0},
+ [SWFDEC_TAG_PLACEOBJECT2] = {"PlaceObject2", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_REMOVEOBJECT2] = {"RemoveObject2", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_DEFINESHAPE3] = {"DefineShape3", tag_define_shape_3, 0},
+ [SWFDEC_TAG_DEFINETEXT2] = {"DefineText2", tag_func_define_text, 0},
+ [SWFDEC_TAG_DEFINEBUTTON2] = {"DefineButton2", tag_func_define_button_2, 0},
+ [SWFDEC_TAG_DEFINEBITSJPEG3] = {"DefineBitsJPEG3", tag_func_define_bits_jpeg_3, 0},
+ [SWFDEC_TAG_DEFINEBITSLOSSLESS2] =
+ {"DefineBitsLossless2", tag_func_define_bits_lossless_2, 0},
+ [SWFDEC_TAG_DEFINEEDITTEXT] = {"DefineEditText", tag_func_define_edit_text, 0},
+ [SWFDEC_TAG_DEFINEMOVIE] = {"DefineMovie", NULL, 0},
+ [SWFDEC_TAG_DEFINESPRITE] = {"DefineSprite", tag_func_define_sprite, 0},
+ [SWFDEC_TAG_NAMECHARACTER] = {"NameCharacter", NULL, 0},
+ [SWFDEC_TAG_SERIALNUMBER] = {"SerialNumber", NULL, 0},
+ [SWFDEC_TAG_GENERATORTEXT] = {"GeneratorText", NULL, 0},
+ [SWFDEC_TAG_FRAMELABEL] = {"FrameLabel", tag_func_frame_label, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_SOUNDSTREAMHEAD2] = {"SoundStreamHead2", tag_func_sound_stream_head, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_DEFINEMORPHSHAPE] =
+ {"DefineMorphShape", tag_define_morph_shape, 0},
+ [SWFDEC_TAG_DEFINEFONT2] = {"DefineFont2", tag_func_define_font_2, 0},
+ [SWFDEC_TAG_TEMPLATECOMMAND] = {"TemplateCommand", NULL, 0},
+ [SWFDEC_TAG_GENERATOR3] = {"Generator3", NULL, 0},
+ [SWFDEC_TAG_EXTERNALFONT] = {"ExternalFont", NULL, 0},
+ [SWFDEC_TAG_EXPORTASSETS] = {"ExportAssets", tag_func_enqueue, 0},
+ [SWFDEC_TAG_IMPORTASSETS] = {"ImportAssets", NULL, 0},
+ [SWFDEC_TAG_ENABLEDEBUGGER] = {"EnableDebugger", NULL, 0},
+ [SWFDEC_TAG_DOINITACTION] = {"DoInitAction", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_DEFINEVIDEOSTREAM] = {"DefineVideoStream", tag_func_define_video, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_VIDEOFRAME] = {"VideoFrame", tag_func_video_frame, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_DEFINEFONTINFO2] = {"DefineFontInfo2", tag_func_define_font_info, 0},
+ [SWFDEC_TAG_DEBUGID] = {"DebugID", NULL, 0},
+ [SWFDEC_TAG_ENABLEDEBUGGER2] = {"EnableDebugger2", NULL, 0},
+ [SWFDEC_TAG_SCRIPTLIMITS] = {"ScriptLimits", NULL, 0},
+ [SWFDEC_TAG_SETTABINDEX] = {"SetTabIndex", NULL, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_FILEATTRIBUTES] = {"FileAttributes", tag_func_file_attributes, SWFDEC_TAG_FIRST_ONLY },
+ [SWFDEC_TAG_PLACEOBJECT3] = {"PlaceObject3", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_IMPORTASSETS2] = {"ImportAssets2", NULL, 0},
+ [SWFDEC_TAG_DEFINEFONTALIGNZONES] = {"DefineFontAlignZones", NULL, 0},
+ [SWFDEC_TAG_CSMTEXTSETTINGS] = {"CSMTextSettings", NULL, 0},
+ [SWFDEC_TAG_DEFINEFONT3] = {"DefineFont3", tag_func_define_font_3, 0},
+ [SWFDEC_TAG_AVM2DECL] = {"AVM2Decl", NULL, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_METADATA] = {"Metadata", NULL, 0},
+ [SWFDEC_TAG_DEFINESCALINGGRID] = {"DefineScalingGrid", NULL, 0},
+ [SWFDEC_TAG_AVM2ACTION] = {"AVM2Action", NULL, SWFDEC_TAG_DEFINE_SPRITE },
+ [SWFDEC_TAG_DEFINESHAPE4] = {"DefineShape4", tag_define_shape_4, 0},
+ [SWFDEC_TAG_DEFINEMORPHSHAPE2] = {"DefineMorphShape2", NULL, 0},
+ [SWFDEC_TAG_PRIVATE_IMAGE] = { "PrivateImage", NULL, 0},
+ [SWFDEC_TAG_DEFINESCENEDATA] = { "DefineSceneData", NULL, 0},
+ [SWFDEC_TAG_DEFINEBINARYDATA] = { "DefineBinaryData", NULL, 0},
+ [SWFDEC_TAG_DEFINEFONTNAME] = { "DefineFontName", NULL, 0},
+ [SWFDEC_TAG_STARTSOUND2] = {"StartSound2", NULL, SWFDEC_TAG_DEFINE_SPRITE }
+};
+
+static const int n_tag_funcs = sizeof (tag_funcs) / sizeof (tag_funcs[0]);
+
+const char *
+swfdec_swf_decoder_get_tag_name (int tag)
+{
+ if (tag >= 0 && tag < n_tag_funcs) {
+ if (tag_funcs[tag].name) {
+ return tag_funcs[tag].name;
+ }
+ }
+
+ return "unknown";
+}
+
+SwfdecTagFunc
+swfdec_swf_decoder_get_tag_func (int tag)
+{
+ if (tag >= 0 && tag < n_tag_funcs) {
+ if (tag_funcs[tag].func) {
+ return tag_funcs[tag].func;
+ }
+ }
+
+ return NULL;
+}
+
+int
+swfdec_swf_decoder_get_tag_flag (int tag)
+{
+ if (tag >= 0 && tag < n_tag_funcs) {
+ return tag_funcs[tag].flag;
+ }
+
+ return 0;
+}
diff --git a/swfdec/swfdec_tag.h b/swfdec/swfdec_tag.h
new file mode 100644
index 0000000..cee23ce
--- /dev/null
+++ b/swfdec/swfdec_tag.h
@@ -0,0 +1,121 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006-2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __LIBSWFDEC_TAGS_H__
+#define __LIBSWFDEC_TAGS_H__
+
+typedef enum {
+ SWFDEC_TAG_END = 0,
+ SWFDEC_TAG_SHOWFRAME = 1,
+ SWFDEC_TAG_DEFINESHAPE = 2,
+ SWFDEC_TAG_FREECHARACTER = 3,
+ SWFDEC_TAG_PLACEOBJECT = 4,
+ SWFDEC_TAG_REMOVEOBJECT = 5,
+ SWFDEC_TAG_DEFINEBITSJPEG = 6,
+ SWFDEC_TAG_DEFINEBUTTON = 7,
+ SWFDEC_TAG_JPEGTABLES = 8,
+ SWFDEC_TAG_SETBACKGROUNDCOLOR = 9,
+ SWFDEC_TAG_DEFINEFONT = 10,
+ SWFDEC_TAG_DEFINETEXT = 11,
+ SWFDEC_TAG_DOACTION = 12,
+ SWFDEC_TAG_DEFINEFONTINFO = 13,
+ SWFDEC_TAG_DEFINESOUND = 14, /* Event sound tags. */
+ SWFDEC_TAG_STARTSOUND = 15,
+ SWFDEC_TAG_DEFINEBUTTONSOUND = 17,
+ SWFDEC_TAG_SOUNDSTREAMHEAD = 18,
+ SWFDEC_TAG_SOUNDSTREAMBLOCK = 19,
+ SWFDEC_TAG_DEFINEBITSLOSSLESS = 20, /* A bitmap using lossless zlib compression. */
+ SWFDEC_TAG_DEFINEBITSJPEG2 = 21, /* A bitmap using an internal JPEG compression table. */
+ SWFDEC_TAG_DEFINESHAPE2 = 22,
+ SWFDEC_TAG_DEFINEBUTTONCXFORM = 23,
+ SWFDEC_TAG_PROTECT = 24, /* This file should not be importable for editing. */
+ SWFDEC_TAG_PLACEOBJECT2 = 26, /* The new style place w/ alpha color transform and name. */
+ SWFDEC_TAG_REMOVEOBJECT2 = 28, /* A more compact remove object that omits the character tag (just depth). */
+ SWFDEC_TAG_DEFINESHAPE3 = 32, /* A shape V3 includes alpha values. */
+ SWFDEC_TAG_DEFINETEXT2 = 33, /* A text V2 includes alpha values. */
+ SWFDEC_TAG_DEFINEBUTTON2 = 34, /* A button V2 includes color transform, alpha and multiple actions */
+ SWFDEC_TAG_DEFINEBITSJPEG3 = 35, /* A JPEG bitmap with alpha info. */
+ SWFDEC_TAG_DEFINEBITSLOSSLESS2 = 36, /* A lossless bitmap with alpha info. */
+ SWFDEC_TAG_DEFINEEDITTEXT = 37,
+ SWFDEC_TAG_DEFINEMOVIE = 38,
+ SWFDEC_TAG_DEFINESPRITE = 39, /* Define a sequence of tags that describe the behavior of a sprite. */
+ SWFDEC_TAG_NAMECHARACTER = 40, /* Name a character definition, character id and a string, (used for buttons, bitmaps, sprites and sounds). */
+ SWFDEC_TAG_SERIALNUMBER = 41,
+ SWFDEC_TAG_GENERATORTEXT = 42, /* contains an id */
+ SWFDEC_TAG_FRAMELABEL = 43, /* A string label for the current frame. */
+ SWFDEC_TAG_SOUNDSTREAMHEAD2 = 45, /* For lossless streaming sound, should not have needed this... */
+ SWFDEC_TAG_DEFINEMORPHSHAPE = 46, /* A morph shape definition */
+ SWFDEC_TAG_DEFINEFONT2 = 48,
+ SWFDEC_TAG_TEMPLATECOMMAND = 49,
+ SWFDEC_TAG_GENERATOR3 = 51,
+ SWFDEC_TAG_EXTERNALFONT = 52,
+ SWFDEC_TAG_EXPORTASSETS = 56,
+ SWFDEC_TAG_IMPORTASSETS = 57,
+ SWFDEC_TAG_ENABLEDEBUGGER = 58,
+ SWFDEC_TAG_DOINITACTION = 59,
+ SWFDEC_TAG_DEFINEVIDEOSTREAM = 60,
+ SWFDEC_TAG_VIDEOFRAME = 61,
+ SWFDEC_TAG_DEFINEFONTINFO2 = 62,
+ SWFDEC_TAG_DEBUGID = 63,
+ SWFDEC_TAG_ENABLEDEBUGGER2 = 64,
+ SWFDEC_TAG_SCRIPTLIMITS = 65,
+ SWFDEC_TAG_SETTABINDEX = 66,
+#if 0
+ /* magic tags that seem to be similar to FILEATTRIBUTES */
+ SWFDEC_TAG_ = 67,
+ SWFDEC_TAG_ = 68,
+#endif
+ SWFDEC_TAG_FILEATTRIBUTES = 69,
+ SWFDEC_TAG_PLACEOBJECT3 = 70,
+ SWFDEC_TAG_IMPORTASSETS2 = 71,
+#if 0
+ /* seems similar to SWFDEC_TAG_AVM2DECL */
+ SWFDEC_TAG_ = 72, /* allowed with DefineSprite */
+#endif
+ SWFDEC_TAG_DEFINEFONTALIGNZONES = 73,
+ SWFDEC_TAG_CSMTEXTSETTINGS = 74,
+ SWFDEC_TAG_DEFINEFONT3 = 75,
+ SWFDEC_TAG_AVM2DECL = 76,
+ SWFDEC_TAG_METADATA = 77,
+ SWFDEC_TAG_DEFINESCALINGGRID = 78,
+#if 0
+ /* more magic tags that seem to be similar to FILEATTRIBUTES */
+ SWFDEC_TAG_ = 80,
+ SWFDEC_TAG_ = 81,
+#endif
+ SWFDEC_TAG_AVM2ACTION = 82,
+ SWFDEC_TAG_DEFINESHAPE4 = 83,
+ SWFDEC_TAG_DEFINEMORPHSHAPE2 = 84,
+ SWFDEC_TAG_PRIVATE_IMAGE = 85,
+ SWFDEC_TAG_DEFINESCENEDATA = 86,
+ SWFDEC_TAG_DEFINEBINARYDATA = 87,
+ SWFDEC_TAG_DEFINEFONTNAME = 88,
+ SWFDEC_TAG_STARTSOUND2 = 89
+} SwfdecTag;
+
+typedef enum {
+ /* tag is allowe inside DefineSprite */
+ SWFDEC_TAG_DEFINE_SPRITE = (1 << 0),
+ /* tag must be first tag */
+ SWFDEC_TAG_FIRST_ONLY = (1 << 1)
+} SwfdecTagFlag;
+
+#endif
diff --git a/swfdec/swfdec_text.c b/swfdec/swfdec_text.c
new file mode 100644
index 0000000..9205ea8
--- /dev/null
+++ b/swfdec/swfdec_text.c
@@ -0,0 +1,133 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_text.h"
+#include "swfdec_debug.h"
+#include "swfdec_draw.h"
+#include "swfdec_font.h"
+#include "swfdec_swf_decoder.h"
+
+G_DEFINE_TYPE (SwfdecText, swfdec_text, SWFDEC_TYPE_GRAPHIC)
+
+static gboolean
+swfdec_text_mouse_in (SwfdecGraphic *graphic, double x, double y)
+{
+ guint i;
+ SwfdecText *text = SWFDEC_TEXT (graphic);
+
+ cairo_matrix_transform_point (&text->transform_inverse, &x, &y);
+ for (i = 0; i < text->glyphs->len; i++) {
+ SwfdecTextGlyph *glyph;
+ SwfdecDraw *draw;
+ double tmpx, tmpy;
+
+ glyph = &g_array_index (text->glyphs, SwfdecTextGlyph, i);
+ draw = swfdec_font_get_glyph (glyph->font, glyph->glyph);
+ if (draw == NULL)
+ continue;
+ tmpx = x - glyph->x;
+ tmpy = y - glyph->y;
+ tmpx = tmpx * glyph->font->scale_factor / glyph->height;
+ tmpy = tmpy * glyph->font->scale_factor / glyph->height;
+ if (swfdec_draw_contains (draw, tmpx, tmpy))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static void
+swfdec_text_render (SwfdecGraphic *graphic, cairo_t *cr,
+ const SwfdecColorTransform *trans, const SwfdecRect *inval)
+{
+ guint i;
+ SwfdecColor color;
+ SwfdecText *text = SWFDEC_TEXT (graphic);
+ SwfdecColorTransform force_color;
+ SwfdecRect rect, inval_moved;
+
+ cairo_transform (cr, &text->transform);
+ /* scale by bounds */
+ swfdec_rect_transform (&inval_moved, inval, &text->transform_inverse);
+ for (i = 0; i < text->glyphs->len; i++) {
+ SwfdecTextGlyph *glyph;
+ SwfdecDraw *draw;
+ cairo_matrix_t pos;
+
+ glyph = &g_array_index (text->glyphs, SwfdecTextGlyph, i);
+
+ draw = swfdec_font_get_glyph (glyph->font, glyph->glyph);
+ if (draw == NULL) {
+ SWFDEC_INFO ("failed getting glyph %d, maybe an empty glyph?", glyph->glyph);
+ continue;
+ }
+
+ cairo_matrix_init_translate (&pos,
+ glyph->x, glyph->y);
+ cairo_matrix_scale (&pos,
+ (double) glyph->height / glyph->font->scale_factor,
+ (double) glyph->height / glyph->font->scale_factor);
+ cairo_save (cr);
+ cairo_transform (cr, &pos);
+ if (!cairo_matrix_invert (&pos)) {
+ swfdec_rect_transform (&rect, &inval_moved, &pos);
+ color = swfdec_color_apply_transform (glyph->color, trans);
+ swfdec_color_transform_init_color (&force_color, color);
+ swfdec_draw_paint (draw, cr, &force_color);
+ } else {
+ SWFDEC_ERROR ("non-invertible matrix!");
+ }
+ cairo_restore (cr);
+ }
+}
+
+static void
+swfdec_text_dispose (GObject *object)
+{
+ SwfdecText * text = SWFDEC_TEXT (object);
+
+ g_array_free (text->glyphs, TRUE);
+
+ G_OBJECT_CLASS (swfdec_text_parent_class)->dispose (object);
+}
+
+static void
+swfdec_text_class_init (SwfdecTextClass * g_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+ SwfdecGraphicClass *graphic_class = SWFDEC_GRAPHIC_CLASS (g_class);
+
+ object_class->dispose = swfdec_text_dispose;
+
+ graphic_class->render = swfdec_text_render;
+ graphic_class->mouse_in = swfdec_text_mouse_in;
+}
+
+static void
+swfdec_text_init (SwfdecText * text)
+{
+ text->glyphs = g_array_new (FALSE, TRUE, sizeof (SwfdecTextGlyph));
+ cairo_matrix_init_identity (&text->transform);
+}
+
diff --git a/swfdec/swfdec_text.h b/swfdec/swfdec_text.h
new file mode 100644
index 0000000..a590470
--- /dev/null
+++ b/swfdec/swfdec_text.h
@@ -0,0 +1,67 @@
+/* Swfdec
+ * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
+ * 2005-2006 Eric Anholt <eric at anholt.net>
+ * 2006 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_TEXT_H_
+#define _SWFDEC_TEXT_H_
+
+#include <libswfdec/swfdec_graphic.h>
+#include <libswfdec/swfdec_color.h>
+
+G_BEGIN_DECLS
+//typedef struct _SwfdecText SwfdecText;
+typedef struct _SwfdecTextClass SwfdecTextClass;
+
+typedef struct _SwfdecTextGlyph SwfdecTextGlyph;
+
+#define SWFDEC_TYPE_TEXT (swfdec_text_get_type())
+#define SWFDEC_IS_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_TEXT))
+#define SWFDEC_IS_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_TEXT))
+#define SWFDEC_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_TEXT, SwfdecText))
+#define SWFDEC_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_TEXT, SwfdecTextClass))
+
+struct _SwfdecTextGlyph {
+ int x;
+ int y;
+ int glyph;
+ SwfdecFont * font;
+ int height;
+ SwfdecColor color;
+};
+
+struct _SwfdecText {
+ SwfdecGraphic graphic;
+
+ GArray * glyphs;
+ cairo_matrix_t transform;
+ cairo_matrix_t transform_inverse;
+};
+
+struct _SwfdecTextClass {
+ SwfdecGraphicClass graphic_class;
+};
+
+GType swfdec_text_get_type (void);
+
+int tag_func_define_text (SwfdecSwfDecoder * s, guint tag);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_text_field.c b/swfdec/swfdec_text_field.c
new file mode 100644
index 0000000..91af056
--- /dev/null
+++ b/swfdec/swfdec_text_field.c
@@ -0,0 +1,198 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+
+#include "swfdec_text_field.h"
+#include "swfdec_debug.h"
+#include "swfdec_text_field_movie.h"
+#include "swfdec_font.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_swf_decoder.h"
+
+G_DEFINE_TYPE (SwfdecTextField, swfdec_text_field, SWFDEC_TYPE_GRAPHIC)
+
+static gboolean
+swfdec_text_field_mouse_in (SwfdecGraphic *graphic, double x, double y)
+{
+ return swfdec_rect_contains (&graphic->extents, x, y);
+}
+
+static SwfdecMovie *
+swfdec_text_field_create_movie (SwfdecGraphic *graphic, gsize *size)
+{
+ SwfdecTextField *text = SWFDEC_TEXT_FIELD (graphic);
+ SwfdecTextFieldMovie *ret =
+ g_object_new (SWFDEC_TYPE_TEXT_FIELD_MOVIE, NULL);
+
+ ret->text = text;
+
+ *size = sizeof (SwfdecTextFieldMovie);
+
+ return SWFDEC_MOVIE (ret);
+}
+
+static void
+swfdec_text_field_dispose (GObject *object)
+{
+ SwfdecTextField *text = SWFDEC_TEXT_FIELD (object);
+
+ if (text->input != NULL) {
+ g_free (text->input);
+ text->input = NULL;
+ }
+ if (text->variable != NULL) {
+ g_free (text->variable);
+ text->variable = NULL;
+ }
+ if (text->font != NULL) {
+ g_free (text->font);
+ text->font = NULL;
+ }
+
+ G_OBJECT_CLASS (swfdec_text_field_parent_class)->dispose (object);
+}
+
+static void
+swfdec_text_field_class_init (SwfdecTextFieldClass * g_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+ SwfdecGraphicClass *graphic_class = SWFDEC_GRAPHIC_CLASS (g_class);
+
+ object_class->dispose = swfdec_text_field_dispose;
+ graphic_class->create_movie = swfdec_text_field_create_movie;
+ graphic_class->mouse_in = swfdec_text_field_mouse_in;
+}
+
+static void
+swfdec_text_field_init (SwfdecTextField * text)
+{
+}
+
+int
+tag_func_define_edit_text (SwfdecSwfDecoder * s, guint tag)
+{
+ SwfdecTextField *text;
+ guint id;
+ int reserved;
+ gboolean has_font, has_color, has_max_length, has_layout, has_text;
+ SwfdecBits *b = &s->b;
+
+ id = swfdec_bits_get_u16 (b);
+ SWFDEC_LOG (" id = %u", id);
+ text = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_TEXT_FIELD);
+ if (text == NULL)
+ return SWFDEC_STATUS_OK;
+
+ swfdec_bits_get_rect (b, &SWFDEC_GRAPHIC (text)->extents);
+ SWFDEC_LOG (" extents: %g %g %g %g",
+ SWFDEC_GRAPHIC (text)->extents.x0, SWFDEC_GRAPHIC (text)->extents.y0,
+ SWFDEC_GRAPHIC (text)->extents.x1, SWFDEC_GRAPHIC (text)->extents.y1);
+ swfdec_bits_syncbits (b);
+
+ has_text = swfdec_bits_getbit (b);
+ text->word_wrap = swfdec_bits_getbit (b);
+ text->multiline = swfdec_bits_getbit (b);
+ text->password = swfdec_bits_getbit (b);
+ text->editable = !swfdec_bits_getbit (b);
+ has_color = swfdec_bits_getbit (b);
+ has_max_length = swfdec_bits_getbit (b);
+ has_font = swfdec_bits_getbit (b);
+ reserved = swfdec_bits_getbit (b);
+ text->auto_size =
+ (swfdec_bits_getbit (b) ? SWFDEC_AUTO_SIZE_LEFT : SWFDEC_AUTO_SIZE_NONE);
+ has_layout = swfdec_bits_getbit (b);
+ text->selectable = !swfdec_bits_getbit (b);
+ text->background = text->border = swfdec_bits_getbit (b);
+ reserved = swfdec_bits_getbit (b);
+ text->html = swfdec_bits_getbit (b);
+ text->embed_fonts = swfdec_bits_getbit (b);
+ if (text->embed_fonts)
+ SWFDEC_FIXME ("Using embed fonts in TextField is not supported");
+
+ if (has_font) {
+ SwfdecCharacter *font;
+
+ id = swfdec_bits_get_u16 (b);
+ font = swfdec_swf_decoder_get_character (s, id);
+ if (SWFDEC_IS_FONT (font)) {
+ SWFDEC_LOG (" font = %u", id);
+ text->font = g_strdup (SWFDEC_FONT (font)->name);
+ } else {
+ SWFDEC_ERROR ("id %u does not specify a font", id);
+ }
+ text->size = swfdec_bits_get_u16 (b);
+ SWFDEC_LOG (" size = %u", text->size);
+ }
+
+ if (has_color) {
+ text->color = swfdec_bits_get_rgba (b);
+ SWFDEC_LOG (" color = %u", text->color);
+ } else {
+ SWFDEC_WARNING ("FIXME: figure out default color");
+ text->color = SWFDEC_COLOR_COMBINE (255, 255, 255, 0);
+ }
+
+ if (has_max_length) {
+ text->max_chars = swfdec_bits_get_u16 (b);
+ } else {
+ text->max_chars = 0;
+ }
+
+ if (has_layout) {
+ guint align = swfdec_bits_get_u8 (b);
+ switch (align) {
+ case 0:
+ text->align = SWFDEC_TEXT_ALIGN_LEFT;
+ break;
+ case 1:
+ text->align = SWFDEC_TEXT_ALIGN_RIGHT;
+ break;
+ case 2:
+ text->align = SWFDEC_TEXT_ALIGN_CENTER;
+ break;
+ case 3:
+ text->align = SWFDEC_TEXT_ALIGN_JUSTIFY;
+ break;
+ default:
+ SWFDEC_ERROR ("undefined align value %u", align);
+ break;
+ }
+ text->left_margin = swfdec_bits_get_u16 (b);
+ text->right_margin = swfdec_bits_get_u16 (b);
+ text->indent = swfdec_bits_get_u16 (b);
+ text->leading = swfdec_bits_get_s16 (b);
+ }
+
+ text->variable = swfdec_bits_get_string (b, s->version);
+ if (text->variable && *text->variable == 0) {
+ g_free (text->variable);
+ text->variable = NULL;
+ }
+
+ if (has_text)
+ text->input = swfdec_bits_get_string (b, s->version);
+
+ return SWFDEC_STATUS_OK;
+}
diff --git a/swfdec/swfdec_text_field.h b/swfdec/swfdec_text_field.h
new file mode 100644
index 0000000..a321a1c
--- /dev/null
+++ b/swfdec/swfdec_text_field.h
@@ -0,0 +1,93 @@
+/* Swfdec
+ * Copyright (C) 2006-2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_TEXT_FIELD_H_
+#define _SWFDEC_TEXT_FIELD_H_
+
+#include <pango/pango.h>
+#include <libswfdec/swfdec_types.h>
+#include <libswfdec/swfdec_color.h>
+#include <libswfdec/swfdec_graphic.h>
+#include <libswfdec/swfdec_player.h>
+#include <libswfdec/swfdec_text_format.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecTextField SwfdecTextField;
+typedef struct _SwfdecTextFieldClass SwfdecTextFieldClass;
+
+#define SWFDEC_TYPE_TEXT_FIELD (swfdec_text_field_get_type())
+#define SWFDEC_IS_TEXT_FIELD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_TEXT_FIELD))
+#define SWFDEC_IS_TEXT_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_TEXT_FIELD))
+#define SWFDEC_TEXT_FIELD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_TEXT_FIELD, SwfdecTextField))
+#define SWFDEC_TEXT_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_TEXT_FIELD, SwfdecTextFieldClass))
+
+typedef enum {
+ SWFDEC_AUTO_SIZE_NONE,
+ SWFDEC_AUTO_SIZE_LEFT,
+ SWFDEC_AUTO_SIZE_RIGHT,
+ SWFDEC_AUTO_SIZE_CENTER
+} SwfdecAutoSize;
+
+struct _SwfdecTextField
+{
+ SwfdecGraphic graphic;
+
+ gboolean html;
+
+ gboolean editable;
+ gboolean password;
+ int max_chars;
+ gboolean selectable;
+
+ gboolean embed_fonts;
+
+ gboolean word_wrap;
+ gboolean multiline;
+ SwfdecAutoSize auto_size;
+
+ gboolean border;
+ gboolean background;
+
+ /* only to be passed to the movie object */
+ char * input;
+ char * variable;
+ char * font;
+ guint size;
+ SwfdecColor color;
+ SwfdecTextAlign align;
+ guint left_margin;
+ guint right_margin;
+ guint indent;
+ int leading;
+};
+
+struct _SwfdecTextFieldClass
+{
+ SwfdecGraphicClass graphic_class;
+};
+
+GType swfdec_text_field_get_type (void);
+
+int tag_func_define_edit_text (SwfdecSwfDecoder * s,
+ guint tag);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_text_field_movie.c b/swfdec/swfdec_text_field_movie.c
new file mode 100644
index 0000000..84a4001
--- /dev/null
+++ b/swfdec/swfdec_text_field_movie.c
@@ -0,0 +1,1627 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include <math.h>
+#include <pango/pangocairo.h>
+
+#include "swfdec_text_field_movie.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_as_interpret.h"
+#include "swfdec_debug.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_resource.h"
+#include "swfdec_sandbox.h"
+#include "swfdec_text_format.h"
+#include "swfdec_xml.h"
+
+G_DEFINE_TYPE (SwfdecTextFieldMovie, swfdec_text_field_movie, SWFDEC_TYPE_MOVIE)
+
+#define EXTRA_MARGIN 2
+#define BULLET_MARGIN 36
+
+static void
+swfdec_text_field_movie_update_extents (SwfdecMovie *movie,
+ SwfdecRect *extents)
+{
+ swfdec_rect_union (extents, extents,
+ &SWFDEC_GRAPHIC (SWFDEC_TEXT_FIELD_MOVIE (movie)->text)->extents);
+}
+
+static void
+swfdec_text_field_movie_invalidate (SwfdecMovie *movie, const cairo_matrix_t *matrix, gboolean last)
+{
+ SwfdecRect rect;
+
+ swfdec_rect_transform (&rect,
+ &SWFDEC_GRAPHIC (SWFDEC_TEXT_FIELD_MOVIE (movie)->text)->extents, matrix);
+ swfdec_player_invalidate (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), &rect);
+}
+
+static void
+swfdec_text_field_movie_ensure_asterisks (SwfdecTextFieldMovie *text,
+ guint length)
+{
+ g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
+
+ if (text->asterisks_length >= length)
+ return;
+
+ if (text->asterisks != NULL)
+ g_free (text->asterisks);
+
+ text->asterisks = g_malloc (length + 1);
+ memset (text->asterisks, '*', length);
+ text->asterisks[length] = 0;
+ text->asterisks_length = length;
+}
+
+static void
+swfdec_text_paragraph_add_attribute (SwfdecParagraph *paragraph,
+ PangoAttribute *attr)
+{
+ paragraph->attrs = g_slist_prepend (paragraph->attrs, attr);
+}
+
+static void
+swfdec_text_paragraph_add_block (SwfdecParagraph *paragraph, int index_,
+ SwfdecTextFormat *format)
+{
+ gint32 length, i;
+ SwfdecBlock *block;
+ SwfdecAsValue val;
+
+ block = g_new0 (SwfdecBlock, 1);
+
+ block->index_ = index_;
+
+ switch (format->align) {
+ case SWFDEC_TEXT_ALIGN_LEFT:
+ block->align = PANGO_ALIGN_LEFT;
+ block->justify = FALSE;
+ break;
+ case SWFDEC_TEXT_ALIGN_RIGHT:
+ block->align = PANGO_ALIGN_RIGHT;
+ block->justify = FALSE;
+ break;
+ case SWFDEC_TEXT_ALIGN_CENTER:
+ block->align = PANGO_ALIGN_CENTER;
+ block->justify = FALSE;
+ break;
+ case SWFDEC_TEXT_ALIGN_JUSTIFY:
+ block->align = PANGO_ALIGN_LEFT;
+ block->justify = TRUE;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ block->leading = format->leading * 20 * PANGO_SCALE;
+ block->block_indent = format->block_indent * 20;
+ block->left_margin = format->left_margin * 20;
+ block->right_margin = format->right_margin * 20;
+
+ if (format->tab_stops != NULL) {
+ length = swfdec_as_array_get_length (format->tab_stops);
+ block->tab_stops = pango_tab_array_new (length, TRUE);
+ for (i = 0; i < length; i++) {
+ swfdec_as_array_get_value (format->tab_stops, i, &val);
+ g_assert (SWFDEC_AS_VALUE_IS_NUMBER (&val));
+ pango_tab_array_set_tab (block->tab_stops, i, PANGO_TAB_LEFT,
+ SWFDEC_AS_VALUE_GET_NUMBER (&val) * 20);
+ }
+ } else {
+ block->tab_stops = NULL;
+ }
+
+ paragraph->blocks = g_slist_prepend (paragraph->blocks, block);
+}
+
+static void
+swfdec_text_field_movie_generate_paragraph (SwfdecTextFieldMovie *text,
+ SwfdecParagraph *paragraph, guint start_index, guint length)
+{
+ SwfdecTextFormat *format, *format_prev;
+ guint index_;
+ GSList *iter;
+ PangoAttribute *attr_bold, *attr_color, *attr_font, *attr_italic,
+ *attr_letter_spacing, *attr_size, *attr_underline;
+ // TODO: kerning, display
+
+ g_assert (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
+ g_assert (paragraph != NULL);
+ g_assert (start_index + length <= text->input->len);
+
+ paragraph->index_ = start_index;
+ paragraph->length = length;
+ if (text->input->str[start_index + length - 1] == '\n' ||
+ text->input->str[start_index + length - 1] == '\r') {
+ paragraph->newline = TRUE;
+ } else {
+ paragraph->newline = FALSE;
+ }
+
+ paragraph->blocks = NULL;
+ paragraph->attrs = NULL;
+
+ g_assert (text->formats != NULL);
+ for (iter = text->formats; iter->next != NULL &&
+ ((SwfdecFormatIndex *)(iter->next->data))->index_ <= start_index;
+ iter = iter->next);
+
+ index_ = start_index;
+ format = ((SwfdecFormatIndex *)(iter->data))->format;
+
+ // Paragraph formats
+ paragraph->bullet = format->bullet;
+ paragraph->indent = format->indent * 20 * PANGO_SCALE;
+
+ // Add new block
+ swfdec_text_paragraph_add_block (paragraph, 0, format);
+
+ // Open attributes
+ attr_bold = pango_attr_weight_new (
+ (format->bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL));
+ attr_bold->start_index = 0;
+
+ attr_color = pango_attr_foreground_new (SWFDEC_COLOR_R (format->color) * 255,
+ SWFDEC_COLOR_G (format->color) * 255,
+ SWFDEC_COLOR_B (format->color) * 255);
+ attr_color->start_index = 0;
+
+ // FIXME: embed fonts
+ attr_font = pango_attr_family_new (format->font);
+ attr_font->start_index = 0;
+
+ attr_italic = pango_attr_style_new (
+ (format->italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL));
+ attr_italic->start_index = 0;
+
+ attr_letter_spacing = pango_attr_letter_spacing_new (
+ format->letter_spacing * 20 * PANGO_SCALE);
+ attr_letter_spacing->start_index = 0;
+
+ attr_size =
+ pango_attr_size_new_absolute (MAX (format->size, 1) * 20 * PANGO_SCALE);
+ attr_size->start_index = 0;
+
+ attr_underline = pango_attr_underline_new (
+ (format->underline ? PANGO_UNDERLINE_SINGLE : PANGO_UNDERLINE_NONE));
+ attr_underline->start_index = 0;
+
+ for (iter = iter->next;
+ iter != NULL &&
+ ((SwfdecFormatIndex *)(iter->data))->index_ < start_index + length;
+ iter = iter->next)
+ {
+ format_prev = format;
+ index_ = ((SwfdecFormatIndex *)(iter->data))->index_;
+ format = ((SwfdecFormatIndex *)(iter->data))->format;
+
+ // Add new block if necessary
+ if (format_prev->align != format->align ||
+ format_prev->bullet != format->bullet ||
+ format_prev->indent != format->indent ||
+ format_prev->leading != format->leading ||
+ format_prev->block_indent != format->block_indent ||
+ format_prev->left_margin != format->left_margin)
+ {
+ swfdec_text_paragraph_add_block (paragraph, index_ - start_index,
+ format);
+ }
+
+ // Change attributes if necessary
+ if (format_prev->bold != format->bold) {
+ attr_bold->end_index = index_ - start_index;
+ swfdec_text_paragraph_add_attribute (paragraph, attr_bold);
+
+ attr_bold = pango_attr_weight_new (
+ (format->bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL));
+ attr_bold->start_index = index_ - start_index;
+ }
+
+ if (format_prev->color != format->color) {
+ attr_color->end_index = index_ - start_index;
+ swfdec_text_paragraph_add_attribute (paragraph, attr_color);
+
+ attr_color = pango_attr_foreground_new (
+ SWFDEC_COLOR_R (format->color) * 255,
+ SWFDEC_COLOR_G (format->color) * 255,
+ SWFDEC_COLOR_B (format->color) * 255);
+ attr_color->start_index = index_ - start_index;
+ }
+
+ if (format_prev->font != format->font) {
+ attr_font->end_index = index_ - start_index;
+ swfdec_text_paragraph_add_attribute (paragraph, attr_font);
+
+ // FIXME: embed fonts
+ attr_font = pango_attr_family_new (format->font);
+ attr_font->start_index = index_ - start_index;
+ }
+
+ if (format_prev->italic != format->italic) {
+ attr_italic->end_index = index_ - start_index;
+ swfdec_text_paragraph_add_attribute (paragraph, attr_italic);
+
+ attr_italic = pango_attr_style_new (
+ (format->italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL));
+ attr_italic->start_index = index_ - start_index;
+ }
+
+ if (format_prev->letter_spacing != format->letter_spacing) {
+ attr_letter_spacing->end_index = index_ - start_index;
+ swfdec_text_paragraph_add_attribute (paragraph, attr_letter_spacing);
+
+ attr_letter_spacing = pango_attr_letter_spacing_new (
+ format->letter_spacing * 20 * PANGO_SCALE);
+ attr_letter_spacing->start_index = index_ - start_index;
+ }
+
+ if (format_prev->size != format->size) {
+ attr_size->end_index = index_ - start_index;
+ swfdec_text_paragraph_add_attribute (paragraph, attr_size);
+
+ attr_size = pango_attr_size_new_absolute (
+ MAX (1, format->size) * 20 * PANGO_SCALE);
+ attr_size->start_index = index_ - start_index;
+ }
+
+ if (format_prev->underline != format->underline) {
+ attr_underline->end_index = index_ - start_index;
+ swfdec_text_paragraph_add_attribute (paragraph, attr_underline);
+
+ attr_underline = pango_attr_underline_new (
+ (format->underline ? PANGO_UNDERLINE_SINGLE : PANGO_UNDERLINE_NONE));
+ attr_underline->start_index = index_ - start_index;
+ }
+ }
+
+ // Close attributes
+ attr_bold->end_index = length;
+ swfdec_text_paragraph_add_attribute (paragraph, attr_bold);
+ attr_bold = NULL;
+
+ attr_color->end_index = length;
+ swfdec_text_paragraph_add_attribute (paragraph, attr_color);
+ attr_color = NULL;
+
+ attr_font->end_index = length;
+ swfdec_text_paragraph_add_attribute (paragraph, attr_font);
+ attr_font = NULL;
+
+ attr_italic->end_index = length;
+ swfdec_text_paragraph_add_attribute (paragraph, attr_italic);
+ attr_italic = NULL;
+
+ attr_letter_spacing->end_index = length;
+ swfdec_text_paragraph_add_attribute (paragraph, attr_letter_spacing);
+ attr_letter_spacing = NULL;
+
+ attr_size->end_index = length;
+ swfdec_text_paragraph_add_attribute (paragraph, attr_size);
+ attr_size = NULL;
+
+ attr_underline->end_index = length;
+ swfdec_text_paragraph_add_attribute (paragraph, attr_underline);
+ attr_underline = NULL;
+
+ // reverse blocks since we use prepend to add them
+ paragraph->blocks = g_slist_reverse (paragraph->blocks);
+}
+
+static SwfdecParagraph *
+swfdec_text_field_movie_get_paragraphs (SwfdecTextFieldMovie *text, int *num)
+{
+ GArray *paragraphs;
+ SwfdecParagraph paragraph;
+ const char *p, *end;
+ guint max_length;
+
+ g_assert (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
+
+ paragraphs = g_array_new (TRUE, TRUE, sizeof (SwfdecParagraph));
+
+ max_length = 0;
+ p = text->input->str;
+ while (*p != '\0')
+ {
+ end = strpbrk (p, "\r\n");
+ if (end == NULL) {
+ end = strchr (p, '\0');
+ } else {
+ end++;
+ }
+
+ if ((guint) (end - p) > max_length)
+ max_length = end - p;
+
+ swfdec_text_field_movie_generate_paragraph (text, ¶graph,
+ p - text->input->str, end - p);
+ paragraphs = g_array_append_val (paragraphs, paragraph);
+
+ p = end;
+ }
+
+ if (num != NULL)
+ *num = paragraphs->len;
+
+ if (text->text->password)
+ swfdec_text_field_movie_ensure_asterisks (text, max_length);
+
+ return (SwfdecParagraph *) (void *) g_array_free (paragraphs, FALSE);
+}
+
+static void
+swfdec_text_field_movie_free_paragraphs (SwfdecParagraph *paragraphs)
+{
+ GSList *iter;
+ int i;
+
+ g_return_if_fail (paragraphs != NULL);
+
+ for (i = 0; paragraphs[i].blocks != NULL; i++)
+ {
+ for (iter = paragraphs[i].blocks; iter != NULL; iter = iter->next) {
+ if (((SwfdecBlock *)(iter->data))->tab_stops)
+ pango_tab_array_free (((SwfdecBlock *)(iter->data))->tab_stops);
+ g_free (iter->data);
+ }
+ g_slist_free (paragraphs[i].blocks);
+
+ for (iter = paragraphs[i].attrs; iter != NULL; iter = iter->next) {
+ pango_attribute_destroy ((PangoAttribute *)(iter->data));
+ }
+ g_slist_free (paragraphs[i].attrs);
+ }
+ g_free (paragraphs);
+}
+
+/*
+ * Rendering
+ */
+static PangoAttrList *
+swfdec_text_field_movie_paragraph_get_attr_list (
+ const SwfdecParagraph *paragraph, guint index_,
+ const SwfdecColorTransform *trans)
+{
+ PangoAttrList *attr_list;
+ GSList *iter;
+
+ attr_list = pango_attr_list_new ();
+
+ for (iter = paragraph->attrs; iter != NULL; iter = iter->next)
+ {
+ PangoAttribute *attr;
+
+ if (((PangoAttribute *)iter->data)->end_index <= index_)
+ continue;
+
+ attr = pango_attribute_copy ((PangoAttribute *)iter->data);
+
+ if (attr->klass->type == PANGO_ATTR_FOREGROUND && trans != NULL &&
+ !swfdec_color_transform_is_identity (trans))
+ {
+ SwfdecColor color;
+ PangoColor color_p;
+
+ color_p = ((PangoAttrColor *)attr)->color;
+
+ color = SWFDEC_COLOR_COMBINE (color_p.red >> 8, color_p.green >> 8,
+ color_p.blue >> 8, 255);
+ color = swfdec_color_apply_transform (color, trans);
+
+ color_p.red = SWFDEC_COLOR_R (color) << 8;
+ color_p.green = SWFDEC_COLOR_G (color) << 8;
+ color_p.blue = SWFDEC_COLOR_B (color) << 8;
+ }
+
+ attr->start_index =
+ (attr->start_index > index_ ? attr->start_index - index_ : 0);
+ attr->end_index = attr->end_index - index_;
+ pango_attr_list_insert (attr_list, attr);
+ }
+
+ return attr_list;
+}
+
+static int
+swfdec_text_field_movie_layout_get_last_line_baseline (PangoLayout *playout)
+{
+ int baseline;
+ PangoLayoutIter *iter;
+
+ g_return_val_if_fail (playout != NULL, 0);
+
+ iter = pango_layout_get_iter (playout);
+ while (!pango_layout_iter_at_last_line (iter))
+ pango_layout_iter_next_line (iter);
+
+ baseline = pango_layout_iter_get_baseline (iter) / PANGO_SCALE;
+
+ pango_layout_iter_free (iter);
+
+ return baseline;
+}
+
+static void
+swfdec_text_field_movie_attr_list_get_ascent_descent (PangoAttrList *attr_list,
+ guint pos, int *ascent, int *descent)
+{
+ PangoAttrIterator *attr_iter;
+ PangoFontDescription *desc;
+ PangoFontMap *fontmap;
+ PangoFont *font;
+ PangoFontMetrics *metrics;
+ PangoContext *pcontext;
+ int end;
+
+ if (ascent != NULL)
+ *ascent = 0;
+ if (descent != NULL)
+ *descent = 0;
+
+ g_return_if_fail (attr_list != NULL);
+
+ attr_iter = pango_attr_list_get_iterator (attr_list);
+ pango_attr_iterator_range (attr_iter, NULL, &end);
+ while ((guint)end < pos && pango_attr_iterator_next (attr_iter)) {
+ pango_attr_iterator_range (attr_iter, NULL, &end);
+ }
+ desc = pango_font_description_new ();
+ pango_attr_iterator_get_font (attr_iter, desc, NULL, NULL);
+ fontmap = pango_cairo_font_map_get_default ();
+ pcontext =
+ pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fontmap));
+ font = pango_font_map_load_font (fontmap, pcontext, desc);
+ metrics = pango_font_get_metrics (font, NULL);
+
+ if (ascent != NULL)
+ *ascent = pango_font_metrics_get_ascent (metrics) / PANGO_SCALE;
+ if (descent != NULL)
+ *descent = pango_font_metrics_get_descent (metrics) / PANGO_SCALE;
+
+ g_object_unref (pcontext);
+ pango_font_metrics_unref (metrics);
+ pango_font_description_free (desc);
+ pango_attr_iterator_destroy (attr_iter);
+}
+
+static SwfdecLayout *
+swfdec_text_field_movie_get_layouts (SwfdecTextFieldMovie *text, int *num,
+ cairo_t *cr, const SwfdecParagraph *paragraphs,
+ const SwfdecColorTransform *trans)
+{
+ GArray *layouts;
+ guint i;
+ SwfdecParagraph *paragraphs_free;
+
+ g_assert (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
+
+ if (cr == NULL)
+ cr = text->cr;
+
+ if (paragraphs == NULL) {
+ paragraphs_free = swfdec_text_field_movie_get_paragraphs (text, NULL);
+ paragraphs = paragraphs_free;
+ } else {
+ paragraphs_free = NULL;
+ }
+
+ layouts = g_array_new (TRUE, TRUE, sizeof (SwfdecLayout));
+
+ for (i = 0; paragraphs[i].blocks != NULL; i++)
+ {
+ GSList *iter;
+ guint skip;
+
+ skip = 0;
+ for (iter = paragraphs[i].blocks; iter != NULL; iter = iter->next)
+ {
+ SwfdecLayout layout;
+ PangoLayout *playout;
+ PangoAttrList *attr_list;
+ SwfdecBlock *block;
+ int width;
+ guint length;
+ gboolean end_of_paragraph;
+
+ block = (SwfdecBlock *)iter->data;
+ if (iter->next != NULL) {
+ length =
+ ((SwfdecBlock *)(iter->next->data))->index_ - block->index_;
+ } else {
+ length = paragraphs[i].length - block->index_;
+ if (paragraphs[i].newline)
+ length -= 1;
+ }
+
+ if (skip > length) {
+ skip -= length;
+ continue;
+ }
+
+ // create layout
+ playout = layout.layout = pango_cairo_create_layout (cr);
+
+ // set rendering position
+ layout.offset_x = block->left_margin + block->block_indent;
+ if (paragraphs[i].bullet)
+ layout.offset_x += SWFDEC_DOUBLE_TO_TWIPS (BULLET_MARGIN);
+
+ width = SWFDEC_MOVIE (text)->original_extents.x1 -
+ SWFDEC_MOVIE (text)->original_extents.x0 - block->right_margin -
+ layout.offset_x;
+
+ if (block->index_ == 0 && paragraphs[i].indent < 0) {
+ // limit negative indent to not go over leftMargin + blockIndent
+ int indent = MAX (paragraphs[i].indent / PANGO_SCALE,
+ -(block->left_margin + block->block_indent));
+ layout.offset_x += indent;
+ width += -indent;
+ }
+
+ if (text->text->word_wrap) {
+ pango_layout_set_wrap (playout, PANGO_WRAP_WORD_CHAR);
+ pango_layout_set_width (playout, width * PANGO_SCALE);
+ pango_layout_set_alignment (playout, block->align);
+ pango_layout_set_justify (playout, block->justify);
+ } else {
+ pango_layout_set_width (playout, -1);
+ }
+
+ // set paragraph styles
+ if (block->index_ == 0) {
+ pango_layout_set_indent (playout, paragraphs[i].indent);
+ layout.bullet = paragraphs[i].bullet;
+ } else {
+ pango_layout_set_indent (playout, 0);
+ layout.bullet = FALSE;
+ }
+
+ // set block styles
+ pango_layout_set_spacing (playout, block->leading);
+ if (block->tab_stops != NULL)
+ pango_layout_set_tabs (playout, block->tab_stops);
+
+ // set text attributes
+ attr_list = swfdec_text_field_movie_paragraph_get_attr_list (
+ ¶graphs[i], block->index_ + skip, trans);
+ pango_layout_set_attributes (playout, attr_list);
+
+ if (text->text->password) {
+ pango_layout_set_text (playout, text->asterisks, paragraphs[i].length -
+ block->index_ - skip - (paragraphs[i].newline ? 1 : 0));
+ } else {
+ pango_layout_set_text (playout,
+ text->input->str + paragraphs[i].index_ + block->index_ + skip,
+ paragraphs[i].length - block->index_ - skip -
+ (paragraphs[i].newline ? 1 : 0));
+ }
+
+ end_of_paragraph = TRUE;
+ if (iter->next != NULL && text->text->word_wrap)
+ {
+ PangoLayoutLine *line;
+ int line_num;
+ guint skip_new;
+
+ pango_layout_index_to_line_x (playout, length - skip, FALSE, &line_num,
+ NULL);
+ if (line_num < pango_layout_get_line_count (playout) - 1) {
+ end_of_paragraph = FALSE;
+ line = pango_layout_get_line_readonly (playout, line_num);
+ skip_new = line->start_index + line->length - (length - skip);
+ pango_layout_set_text (playout,
+ text->input->str + paragraphs[i].index_ + block->index_ + skip,
+ length - skip + skip_new);
+ skip = skip_new;
+ }
+ }
+ else
+ {
+ if (!text->text->word_wrap && block->align != PANGO_ALIGN_LEFT) {
+ int line_width;
+ pango_layout_get_pixel_size (playout, &line_width, 0);
+ if (line_width < width) {
+ if (block->align == PANGO_ALIGN_RIGHT) {
+ layout.offset_x += width - line_width;
+ } else if (block->align == PANGO_ALIGN_CENTER) {
+ layout.offset_x += (width - line_width) / 2;
+ } else {
+ g_assert_not_reached ();
+ }
+ }
+ }
+
+ skip = 0;
+ }
+
+ pango_layout_get_pixel_size (playout, &layout.width, &layout.height);
+ layout.width += layout.offset_x + block->right_margin;
+ layout.last_line_offset_y = 0;
+
+ // figure out if we need to add extra height because of the size of the
+ // line break character
+ if (end_of_paragraph && paragraphs[i].newline)
+ {
+ int ascent, descent;
+
+ swfdec_text_field_movie_attr_list_get_ascent_descent (attr_list,
+ paragraphs[i].length - block->index_ - skip, &ascent, &descent);
+
+ if (ascent + descent > layout.height) {
+ int baseline =
+ swfdec_text_field_movie_layout_get_last_line_baseline (playout);
+ layout.last_line_offset_y = ascent - baseline;
+ layout.height = ascent + descent;
+ }
+ }
+
+ pango_attr_list_unref (attr_list);
+
+ // add leading to last line too
+ layout.height += block->leading / PANGO_SCALE;
+
+ layouts = g_array_append_val (layouts, layout);
+
+ if (!text->text->word_wrap)
+ break;
+ }
+ }
+
+ if (paragraphs_free != NULL) {
+ swfdec_text_field_movie_free_paragraphs (paragraphs_free);
+ paragraphs_free = NULL;
+ paragraphs = NULL;
+ }
+
+ if (num != NULL)
+ *num = layouts->len;
+
+ return (SwfdecLayout *) (void *) g_array_free (layouts, FALSE);
+}
+
+static void
+swfdec_text_field_movie_free_layouts (SwfdecLayout *layouts)
+{
+ int i;
+
+ g_return_if_fail (layouts != NULL);
+
+ for (i = 0; layouts[i].layout != NULL; i++) {
+ g_object_unref (layouts[i].layout);
+ }
+
+ g_free (layouts);
+}
+
+static void
+swfdec_text_field_movie_render (SwfdecMovie *movie, cairo_t *cr,
+ const SwfdecColorTransform *trans, const SwfdecRect *inval)
+{
+ SwfdecTextFieldMovie *text_movie;
+ SwfdecTextField *text;
+ SwfdecLayout *layouts;
+ SwfdecRect limit;
+ SwfdecColor color;
+ SwfdecParagraph *paragraphs;
+ int i, y, x, linenum;
+ gboolean first;
+
+ g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (movie));
+ g_return_if_fail (cr != NULL);
+ g_return_if_fail (trans != NULL);
+ g_return_if_fail (inval != NULL);
+
+ /* textfields don't mask */
+ if (swfdec_color_transform_is_mask (trans))
+ return;
+
+ text_movie = SWFDEC_TEXT_FIELD_MOVIE (movie);
+ text = SWFDEC_TEXT_FIELD (movie->graphic);
+
+ paragraphs = swfdec_text_field_movie_get_paragraphs (text_movie, NULL);
+
+ swfdec_rect_intersect (&limit, &movie->original_extents, inval);
+
+ cairo_rectangle (cr, limit.x0, limit.y0, limit.x1 - limit.x0,
+ limit.y1 - limit.y0);
+ cairo_clip (cr);
+
+ if (text->background) {
+ cairo_rectangle (cr, limit.x0, limit.y0, limit.x1 - limit.x0,
+ limit.y1 - limit.y0);
+ color = swfdec_color_apply_transform (text_movie->background_color, trans);
+ // always use full alpha
+ swfdec_color_set_source (cr, color | SWFDEC_COLOR_COMBINE (0, 0, 0, 255));
+ cairo_fill (cr);
+ }
+
+ if (text->border) {
+ // FIXME: border should be partly outside the extents and should not be
+ // scaled, but always be 1 pixel width
+ cairo_rectangle (cr, movie->original_extents.x0 +
+ SWFDEC_DOUBLE_TO_TWIPS (1), movie->original_extents.y0,
+ movie->original_extents.x1 - movie->original_extents.x0 -
+ SWFDEC_DOUBLE_TO_TWIPS (1), movie->original_extents.y1 -
+ movie->original_extents.y0 - SWFDEC_DOUBLE_TO_TWIPS (1));
+ color = swfdec_color_apply_transform (text_movie->border_color, trans);
+ // always use full alpha
+ swfdec_color_set_source (cr, color | SWFDEC_COLOR_COMBINE (0, 0, 0, 255));
+ cairo_set_line_width (cr, SWFDEC_DOUBLE_TO_TWIPS (1));
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+ cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
+ cairo_stroke (cr);
+ }
+
+ layouts = swfdec_text_field_movie_get_layouts (text_movie, NULL, cr,
+ paragraphs, trans);
+
+ first = TRUE;
+ linenum = 0;
+ x = movie->original_extents.x0 + EXTRA_MARGIN +
+ MIN (text_movie->hscroll, text_movie->hscroll_max);
+ y = movie->original_extents.y0 + EXTRA_MARGIN;
+
+ for (i = 0; layouts[i].layout != NULL && y < limit.y1; i++)
+ {
+ SwfdecLayout *layout = &layouts[i];
+ PangoLayoutIter *iter_line;
+ PangoLayoutLine *line;
+ PangoRectangle rect;
+ int skipped;
+
+ iter_line = pango_layout_get_iter (layout->layout);
+
+ if (layout->bullet && linenum + 1 >=
+ MIN (text_movie->scroll, text_movie->scroll_max)) {
+ PangoColor color_p;
+ PangoAttribute *attr;
+ PangoAttrIterator *attr_iter;
+
+ pango_layout_iter_get_line_extents (iter_line, NULL, &rect);
+ pango_extents_to_pixels (NULL, &rect);
+
+ cairo_new_sub_path (cr);
+
+ // get current color
+ attr_iter = pango_attr_list_get_iterator (
+ pango_layout_get_attributes (layout->layout));
+ attr = pango_attr_iterator_get (attr_iter, PANGO_ATTR_FOREGROUND);
+ color_p = ((PangoAttrColor *)attr)->color;
+ color = SWFDEC_COLOR_COMBINE (color_p.red >> 8, color_p.green >> 8,
+ color_p.blue >> 8, 255);
+ color = swfdec_color_apply_transform (color, trans);
+ pango_attr_iterator_destroy (attr_iter);
+
+ swfdec_color_set_source (cr, color);
+
+ cairo_arc (cr, x + layout->offset_x +
+ pango_layout_get_indent (layout->layout) -
+ SWFDEC_DOUBLE_TO_TWIPS (BULLET_MARGIN) / 2,
+ y + rect.height / 2, rect.height / 8, 20, 2 * M_PI);
+ cairo_fill (cr);
+ }
+
+ skipped = 0;
+ do {
+ if (++linenum < MIN (text_movie->scroll, text_movie->scroll_max))
+ continue;
+
+ pango_layout_iter_get_line_extents (iter_line, NULL, &rect);
+ pango_extents_to_pixels (NULL, &rect);
+
+ if (linenum == MIN (text_movie->scroll, text_movie->scroll_max))
+ skipped = rect.y;
+
+ if (!first && y + rect.y + rect.height > movie->original_extents.y1)
+ break;
+
+ first = FALSE;
+
+ if (y + rect.y > limit.y1)
+ break;
+
+ if (y + rect.y + rect.height < limit.y0 ||
+ x + layout->offset_x + rect.x > limit.x1 ||
+ x + layout->offset_x + rect.x + rect.width < limit.x0)
+ continue;
+
+ cairo_move_to (cr, x, y);
+
+ if (pango_layout_iter_at_last_line (iter_line))
+ cairo_rel_move_to (cr, 0, layout->last_line_offset_y);
+ cairo_rel_move_to (cr, layout->offset_x + rect.x,
+ pango_layout_iter_get_baseline (iter_line) / PANGO_SCALE - skipped);
+
+ line = pango_layout_iter_get_line_readonly (iter_line);
+ pango_cairo_show_layout_line (cr, line);
+ } while (pango_layout_iter_next_line (iter_line));
+
+ if (linenum >= MIN (text_movie->scroll, text_movie->scroll_max)) {
+ y += layout->height - skipped;
+ skipped = 0;
+ }
+
+ pango_layout_iter_free (iter_line);
+ }
+
+ swfdec_text_field_movie_free_layouts (layouts);
+
+ swfdec_text_field_movie_free_paragraphs (paragraphs);
+}
+
+void
+swfdec_text_field_movie_update_scroll (SwfdecTextFieldMovie *text,
+ gboolean check_limits)
+{
+ SwfdecLayout *layouts;
+ int i, num, y, visible, all, height;
+ double width, width_max;
+
+ g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
+
+ layouts = swfdec_text_field_movie_get_layouts (text, &num, NULL, NULL, NULL);
+
+ width = SWFDEC_MOVIE (text)->original_extents.x1 -
+ SWFDEC_MOVIE (text)->original_extents.x0;
+ height = SWFDEC_MOVIE (text)->original_extents.y1 -
+ SWFDEC_MOVIE (text)->original_extents.y0;
+
+ width_max = width;
+ y = 0;
+ all = 0;
+ visible = 0;
+
+ for (i = num - 1; i >= 0; i--)
+ {
+ SwfdecLayout *layout = &layouts[i];
+ PangoLayoutIter *iter_line;
+ PangoRectangle rect;
+
+ if (layouts[i].width > width_max)
+ width_max = layouts[i].width;
+
+ y += layout->height;
+
+ iter_line = pango_layout_get_iter (layout->layout);
+
+ do {
+ pango_layout_iter_get_line_extents (iter_line, NULL, &rect);
+ pango_extents_to_pixels (NULL, &rect);
+
+ if (y - rect.y <= height)
+ visible++;
+
+ all++;
+ } while (pango_layout_iter_next_line (iter_line));
+
+ pango_layout_iter_free (iter_line);
+ }
+
+ swfdec_text_field_movie_free_layouts (layouts);
+ layouts = NULL;
+
+ if (text->scroll_max != all - visible + 1) {
+ text->scroll_max = all - visible + 1;
+ text->scroll_changed = TRUE;
+ }
+ if (text->hscroll_max != SWFDEC_TWIPS_TO_DOUBLE (width_max - width)) {
+ text->hscroll_max = SWFDEC_TWIPS_TO_DOUBLE (width_max - width);
+ text->scroll_changed = TRUE;
+ }
+
+ if (check_limits) {
+ if (text->scroll != CLAMP(text->scroll, 1, text->scroll_max)) {
+ text->scroll = CLAMP(text->scroll, 1, text->scroll_max);
+ text->scroll_changed = TRUE;
+ }
+ if (text->scroll_bottom != text->scroll + (visible > 0 ? visible - 1 : 0))
+ {
+ text->scroll_bottom = text->scroll + (visible > 0 ? visible - 1 : 0);
+ text->scroll_changed = TRUE;
+ }
+ if (text->hscroll != CLAMP(text->hscroll, 0, text->hscroll_max)) {
+ text->hscroll = CLAMP(text->hscroll, 0, text->hscroll_max);
+ text->scroll_changed = TRUE;
+ }
+ } else {
+ if (text->scroll_bottom < text->scroll ||
+ text->scroll_bottom > text->scroll_max + visible - 1) {
+ text->scroll_bottom = text->scroll;
+ text->scroll_changed = TRUE;
+ }
+ }
+}
+
+void
+swfdec_text_field_movie_get_text_size (SwfdecTextFieldMovie *text, int *width,
+ int *height)
+{
+ SwfdecLayout *layouts;
+ int i;
+
+ if (width != NULL)
+ *width = 0;
+ if (height != NULL)
+ *height = 0;
+
+ g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
+ g_return_if_fail (width != NULL || height != NULL);
+
+ layouts = swfdec_text_field_movie_get_layouts (text, NULL, NULL, NULL, NULL);
+
+ for (i = 0; layouts[i].layout != NULL; i++) {
+ if (!text->text->word_wrap) {
+ if (width != NULL && layouts[i].width > *width)
+ *width = layouts[i].width;
+ }
+
+ if (height != NULL)
+ *height += layouts[i].height;
+ }
+
+ // align to get integer amount after TWIPS_TO_DOUBLE
+ if (width != NULL && *width % SWFDEC_TWIPS_SCALE_FACTOR != 0)
+ *width += SWFDEC_TWIPS_SCALE_FACTOR - *width % SWFDEC_TWIPS_SCALE_FACTOR;
+ if (height != NULL && *height % SWFDEC_TWIPS_SCALE_FACTOR != 0)
+ *height += SWFDEC_TWIPS_SCALE_FACTOR - *height % SWFDEC_TWIPS_SCALE_FACTOR;
+
+ swfdec_text_field_movie_free_layouts (layouts);
+}
+
+gboolean
+swfdec_text_field_movie_auto_size (SwfdecTextFieldMovie *text)
+{
+ SwfdecGraphic *graphic;
+ int height, width, diff;
+
+ g_return_val_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text), FALSE);
+
+ graphic = SWFDEC_GRAPHIC (text->text);
+
+ if (text->text->auto_size == SWFDEC_AUTO_SIZE_NONE)
+ return FALSE;
+
+ swfdec_text_field_movie_get_text_size (text, &width, &height);
+ width += SWFDEC_DOUBLE_TO_TWIPS (2 * EXTRA_MARGIN);
+ height += SWFDEC_DOUBLE_TO_TWIPS (2 * EXTRA_MARGIN);
+
+ if ((text->text->word_wrap ||
+ graphic->extents.x1 - graphic->extents.x0 == width) &&
+ graphic->extents.y1 - graphic->extents.y0 == height)
+ return FALSE;
+
+ swfdec_movie_invalidate_next (SWFDEC_MOVIE (text));
+
+ if (!text->text->word_wrap && graphic->extents.x1 -
+ graphic->extents.x0 != width)
+ {
+ switch (text->text->auto_size) {
+ case SWFDEC_AUTO_SIZE_LEFT:
+ graphic->extents.x1 = graphic->extents.x0 + width;
+ break;
+ case SWFDEC_AUTO_SIZE_RIGHT:
+ graphic->extents.x0 = graphic->extents.x1 - width;
+ break;
+ case SWFDEC_AUTO_SIZE_CENTER:
+ diff = (graphic->extents.x1 - graphic->extents.x0) - width;
+ graphic->extents.x0 += floor (diff / 2.0);
+ graphic->extents.x1 = graphic->extents.x0 + width;
+ break;
+ case SWFDEC_AUTO_SIZE_NONE:
+ default:
+ g_return_val_if_reached (FALSE);
+ }
+ }
+
+ if (graphic->extents.y1 - graphic->extents.y0 != height)
+ {
+ graphic->extents.y1 = graphic->extents.y0 + height;
+ }
+
+ swfdec_movie_queue_update (SWFDEC_MOVIE (text),
+ SWFDEC_MOVIE_INVALID_EXTENTS);
+
+ return TRUE;
+}
+
+static void
+swfdec_text_field_movie_dispose (GObject *object)
+{
+ SwfdecTextFieldMovie *text;
+ GSList *iter;
+
+ text = SWFDEC_TEXT_FIELD_MOVIE (object);
+
+ if (text->asterisks != NULL) {
+ g_free (text->asterisks);
+ text->asterisks = NULL;
+ text->asterisks_length = 0;
+ }
+
+ if (SWFDEC_IS_STYLESHEET (text->style_sheet)) {
+ g_signal_handlers_disconnect_matched (text->style_sheet,
+ G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, text);
+ g_object_remove_weak_pointer (G_OBJECT (text->style_sheet),
+ (gpointer) &text->style_sheet);
+ }
+ text->style_sheet = NULL;
+
+ for (iter = text->formats; iter != NULL; iter = iter->next) {
+ g_free (text->formats->data);
+ text->formats->data = NULL;
+ }
+ g_slist_free (text->formats);
+ text->formats = NULL;
+
+ g_string_free (text->input, TRUE);
+ text->input = NULL;
+
+ cairo_destroy (text->cr);
+ text->cr = NULL;
+ cairo_surface_destroy (text->surface);
+ text->surface = NULL;
+
+ G_OBJECT_CLASS (swfdec_text_field_movie_parent_class)->dispose (object);
+}
+
+static void
+swfdec_text_field_movie_mark (SwfdecAsObject *object)
+{
+ SwfdecTextFieldMovie *text;
+ GSList *iter;
+
+ text = SWFDEC_TEXT_FIELD_MOVIE (object);
+
+ if (text->variable != NULL)
+ swfdec_as_string_mark (text->variable);
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (text->format_new));
+ for (iter = text->formats; iter != NULL; iter = iter->next) {
+ swfdec_as_object_mark (
+ SWFDEC_AS_OBJECT (((SwfdecFormatIndex *)(iter->data))->format));
+ }
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (text->format_new));
+ if (text->style_sheet != NULL)
+ swfdec_as_object_mark (text->style_sheet);
+ if (text->style_sheet_input != NULL)
+ swfdec_as_string_mark (text->style_sheet_input);
+ if (text->restrict_ != NULL)
+ swfdec_as_string_mark (text->restrict_);
+
+ SWFDEC_AS_OBJECT_CLASS (swfdec_text_field_movie_parent_class)->mark (object);
+}
+
+static void
+swfdec_text_field_movie_init_movie (SwfdecMovie *movie)
+{
+ SwfdecTextFieldMovie *text = SWFDEC_TEXT_FIELD_MOVIE (movie);
+ SwfdecAsContext *cx;
+ SwfdecAsValue val;
+ gboolean needs_unuse;
+
+ needs_unuse = swfdec_sandbox_try_use (movie->resource->sandbox);
+
+ cx = SWFDEC_AS_OBJECT (movie)->context;
+
+ swfdec_text_field_movie_init_properties (cx);
+
+ swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_TextField, &val);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
+ swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (movie),
+ SWFDEC_AS_VALUE_GET_OBJECT (&val));
+ }
+
+ // listen self
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (movie));
+ swfdec_as_object_call (SWFDEC_AS_OBJECT (movie), SWFDEC_AS_STR_addListener,
+ 1, &val, NULL);
+
+ // format
+ text->format_new =
+ SWFDEC_TEXT_FORMAT (swfdec_text_format_new_no_properties (cx));
+ if (!text->format_new)
+ goto out;
+
+ swfdec_text_format_set_defaults (text->format_new);
+ text->format_new->color = text->text->color;
+ text->format_new->align = text->text->align;
+ if (text->text->font != NULL) {
+ text->format_new->font =
+ swfdec_as_context_get_string (cx, text->text->font);
+ }
+ text->format_new->size = text->text->size / 20;
+ text->format_new->left_margin = text->text->left_margin / 20;
+ text->format_new->right_margin = text->text->right_margin / 20;
+ text->format_new->indent = text->text->indent / 20;
+ text->format_new->leading = text->text->leading / 20;
+
+ text->border_color = SWFDEC_COLOR_COMBINE (0, 0, 0, 0);
+ text->background_color = SWFDEC_COLOR_COMBINE (255, 255, 255, 0);
+
+ // text
+ if (text->text->input != NULL) {
+ swfdec_text_field_movie_set_text (text,
+ swfdec_as_context_get_string (cx, text->text->input),
+ text->text->html);
+ } else {
+ swfdec_text_field_movie_set_text (text, SWFDEC_AS_STR_EMPTY,
+ text->text->html);
+ }
+
+ // variable
+ if (text->text->variable != NULL) {
+ swfdec_text_field_movie_set_listen_variable (text,
+ swfdec_as_context_get_string (cx, text->text->variable));
+ }
+
+out:
+ if (needs_unuse)
+ swfdec_sandbox_unuse (movie->resource->sandbox);
+}
+
+static void
+swfdec_text_field_movie_finish_movie (SwfdecMovie *movie)
+{
+ SwfdecTextFieldMovie *text = SWFDEC_TEXT_FIELD_MOVIE (movie);
+
+ swfdec_text_field_movie_set_listen_variable (text, NULL);
+}
+
+static void
+swfdec_text_field_movie_iterate (SwfdecMovie *movie)
+{
+ SwfdecTextFieldMovie *text = SWFDEC_TEXT_FIELD_MOVIE (movie);
+
+ if (text->scroll_changed) {
+ SwfdecAsValue argv[2];
+
+ SWFDEC_FIXME ("I'm pretty sure this is swfdec_player_add_action()'d");
+ SWFDEC_AS_VALUE_SET_STRING (&argv[0], SWFDEC_AS_STR_onScroller);
+ SWFDEC_AS_VALUE_SET_OBJECT (&argv[1], SWFDEC_AS_OBJECT (movie));
+ swfdec_sandbox_use (movie->resource->sandbox);
+ swfdec_as_object_call (SWFDEC_AS_OBJECT (movie),
+ SWFDEC_AS_STR_broadcastMessage, 2, argv, NULL);
+ swfdec_sandbox_unuse (movie->resource->sandbox);
+
+ /* FIXME: unset this before or after emitting the event? */
+ text->scroll_changed = FALSE;
+ }
+}
+
+static void
+swfdec_text_field_movie_class_init (SwfdecTextFieldMovieClass * g_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+ SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (g_class);
+ SwfdecMovieClass *movie_class = SWFDEC_MOVIE_CLASS (g_class);
+
+ object_class->dispose = swfdec_text_field_movie_dispose;
+
+ asobject_class->mark = swfdec_text_field_movie_mark;
+
+ movie_class->init_movie = swfdec_text_field_movie_init_movie;
+ movie_class->finish_movie = swfdec_text_field_movie_finish_movie;
+ movie_class->iterate_start = swfdec_text_field_movie_iterate;
+ movie_class->update_extents = swfdec_text_field_movie_update_extents;
+ movie_class->render = swfdec_text_field_movie_render;
+ movie_class->invalidate = swfdec_text_field_movie_invalidate;
+}
+
+static void
+swfdec_text_field_movie_init (SwfdecTextFieldMovie *text)
+{
+ text->surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
+ text->cr = cairo_create (text->surface);
+
+ text->input = g_string_new ("");
+ text->scroll = 1;
+ text->mouse_wheel_enabled = TRUE;
+}
+
+void
+swfdec_text_field_movie_set_text_format (SwfdecTextFieldMovie *text,
+ SwfdecTextFormat *format, guint start_index, guint end_index)
+{
+ SwfdecFormatIndex *findex, *findex_new, *findex_prev;
+ guint findex_end_index;
+ GSList *iter, *next;
+
+ g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
+ g_return_if_fail (SWFDEC_IS_TEXT_FORMAT (format));
+ g_return_if_fail (start_index < end_index);
+ g_return_if_fail (end_index <= text->input->len);
+
+ g_assert (text->formats != NULL);
+ g_assert (text->formats->data != NULL);
+ g_assert (((SwfdecFormatIndex *)text->formats->data)->index_ == 0);
+
+ findex = NULL;
+ for (iter = text->formats; iter != NULL &&
+ ((SwfdecFormatIndex *)iter->data)->index_ < end_index;
+ iter = next)
+ {
+ findex_prev = findex;
+ next = iter->next;
+ findex = iter->data;
+ if (iter->next != NULL) {
+ findex_end_index =
+ ((SwfdecFormatIndex *)iter->next->data)->index_;
+ } else {
+ findex_end_index = text->input->len;
+ }
+
+ if (findex_end_index <= start_index)
+ continue;
+
+ if (swfdec_text_format_equal_or_undefined (findex->format, format))
+ continue;
+
+ if (findex_end_index > end_index) {
+ findex_new = g_new (SwfdecFormatIndex, 1);
+ findex_new->index_ = end_index;
+ findex_new->format = swfdec_text_format_copy (findex->format);
+ if (findex_new->format == NULL) {
+ g_free (findex_new);
+ break;
+ }
+
+ iter = g_slist_insert (iter, findex_new, 1);
+ }
+
+ if (findex->index_ < start_index) {
+ findex_new = g_new (SwfdecFormatIndex, 1);
+ findex_new->index_ = start_index;
+ findex_new->format = swfdec_text_format_copy (findex->format);
+ if (findex_new->format == NULL) {
+ g_free (findex_new);
+ break;
+ }
+ swfdec_text_format_add (findex_new->format, format);
+
+ iter = g_slist_insert (iter, findex_new, 1);
+ findex = findex_new;
+ } else {
+ swfdec_text_format_add (findex->format, format);
+
+ // if current format now equals previous one, remove current
+ if (findex_prev != NULL &&
+ swfdec_text_format_equal (findex->format, findex_prev->format)) {
+ text->formats = g_slist_remove (text->formats, findex);
+ findex = findex_prev;
+ }
+ }
+
+ // if current format now equals the next one, remove current
+ if (findex_end_index <= end_index && next != NULL &&
+ swfdec_text_format_equal (findex->format,
+ ((SwfdecFormatIndex *)next->data)->format))
+ {
+ ((SwfdecFormatIndex *)next->data)->index_ = findex->index_;
+ text->formats = g_slist_remove (text->formats, findex);
+ findex = findex_prev;
+ }
+ }
+}
+
+SwfdecTextFormat *
+swfdec_text_field_movie_get_text_format (SwfdecTextFieldMovie *text,
+ guint start_index, guint end_index)
+{
+ SwfdecTextFormat *format;
+ GSList *iter;
+
+ g_assert (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
+ g_assert (start_index < end_index);
+ g_assert (end_index <= text->input->len);
+
+ g_assert (text->formats != NULL);
+ g_assert (text->formats->data != NULL);
+ g_assert (((SwfdecFormatIndex *)text->formats->data)->index_ == 0);
+
+ format = NULL;
+ for (iter = text->formats; iter != NULL &&
+ ((SwfdecFormatIndex *)iter->data)->index_ < end_index;
+ iter = iter->next)
+ {
+ if (iter->next != NULL &&
+ ((SwfdecFormatIndex *)iter->next->data)->index_ <= start_index)
+ continue;
+
+ if (format == NULL) {
+ swfdec_text_format_init_properties (SWFDEC_AS_OBJECT (text)->context);
+ format =
+ swfdec_text_format_copy (((SwfdecFormatIndex *)iter->data)->format);
+ } else {
+ swfdec_text_format_remove_different (format,
+ ((SwfdecFormatIndex *)iter->data)->format);
+ }
+ }
+
+ return format;
+}
+
+static void
+swfdec_text_field_movie_parse_listen_variable (SwfdecTextFieldMovie *text,
+ const char *variable, SwfdecAsObject **object, const char **name)
+{
+ SwfdecAsContext *cx;
+ SwfdecAsObject *parent;
+ const char *p1, *p2;
+
+ g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
+ g_return_if_fail (variable != NULL);
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (name != NULL);
+
+ *object = NULL;
+ *name = NULL;
+
+ if (SWFDEC_MOVIE (text)->parent == NULL)
+ return;
+
+ g_assert (SWFDEC_IS_AS_OBJECT (SWFDEC_MOVIE (text)->parent));
+ cx = SWFDEC_AS_OBJECT (text)->context;
+ parent = SWFDEC_AS_OBJECT (SWFDEC_MOVIE (text)->parent);
+
+ p1 = strrchr (variable, '.');
+ p2 = strrchr (variable, ':');
+ if (p1 == NULL && p2 == NULL) {
+ *object = parent;
+ *name = variable;
+ } else {
+ if (p1 == NULL || (p2 != NULL && p2 > p1))
+ p1 = p2;
+ if (strlen (p1) == 1)
+ return;
+ *object = swfdec_action_lookup_object (cx, parent, variable, p1);
+ if (*object == NULL)
+ return;
+ *name = swfdec_as_context_get_string (cx, p1 + 1);
+ }
+}
+
+void
+swfdec_text_field_movie_set_listen_variable_text (SwfdecTextFieldMovie *text,
+ const char *value)
+{
+ SwfdecAsObject *object;
+ const char *name;
+
+ g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
+ g_return_if_fail (text->variable != NULL);
+ g_return_if_fail (value != NULL);
+
+ swfdec_text_field_movie_parse_listen_variable (text, text->variable,
+ &object, &name);
+ if (object != NULL) {
+ SwfdecAsValue val;
+ SWFDEC_AS_VALUE_SET_STRING (&val, value);
+ swfdec_as_object_set_variable (object, name, &val);
+ }
+}
+
+static void
+swfdec_text_field_movie_variable_listener_callback (SwfdecAsObject *object,
+ const char *name, const SwfdecAsValue *val)
+{
+ SwfdecTextFieldMovie *text;
+
+ g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (object));
+
+ text = SWFDEC_TEXT_FIELD_MOVIE (object);
+ swfdec_text_field_movie_set_text (text,
+ swfdec_as_value_to_string (object->context, val), text->text->html);
+}
+
+void
+swfdec_text_field_movie_set_listen_variable (SwfdecTextFieldMovie *text,
+ const char *value)
+{
+ SwfdecAsObject *object;
+ const char *name;
+
+ // FIXME: case-insensitive when v < 7?
+ if (text->variable == value)
+ return;
+
+ if (text->variable != NULL) {
+ swfdec_text_field_movie_parse_listen_variable (text, text->variable,
+ &object, &name);
+ if (object != NULL && SWFDEC_IS_MOVIE (object)) {
+ swfdec_movie_remove_variable_listener (SWFDEC_MOVIE (object),
+ SWFDEC_AS_OBJECT (text), name,
+ swfdec_text_field_movie_variable_listener_callback);
+ }
+ }
+
+ text->variable = value;
+
+ if (value != NULL) {
+ SwfdecAsValue val;
+
+ swfdec_text_field_movie_parse_listen_variable (text, value, &object,
+ &name);
+ if (object != NULL && swfdec_as_object_get_variable (object, name, &val)) {
+ swfdec_text_field_movie_set_text (text,
+ swfdec_as_value_to_string (SWFDEC_AS_OBJECT (text)->context, &val),
+ text->text->html);
+ }
+ if (object != NULL && SWFDEC_IS_MOVIE (object)) {
+ swfdec_movie_add_variable_listener (SWFDEC_MOVIE (object),
+ SWFDEC_AS_OBJECT (text), name,
+ swfdec_text_field_movie_variable_listener_callback);
+ }
+ }
+}
+
+const char *
+swfdec_text_field_movie_get_text (SwfdecTextFieldMovie *text)
+{
+ char *str, *p;
+
+ str = g_strdup (text->input->str);
+
+ // if input was orginally html, remove all \r
+ if (text->input_html) {
+ p = str;
+ while ((p = strchr (p, '\r')) != NULL) {
+ memmove (p, p + 1, strlen (p));
+ }
+ }
+
+ // change all \n to \r
+ p = str;
+ while ((p = strchr (p, '\n')) != NULL) {
+ *p = '\r';
+ }
+
+ return swfdec_as_context_give_string (SWFDEC_AS_OBJECT (text)->context, str);
+}
+
+void
+swfdec_text_field_movie_replace_text (SwfdecTextFieldMovie *text,
+ guint start_index, guint end_index, const char *str)
+{
+ SwfdecFormatIndex *findex;
+ GSList *iter, *prev;
+ gboolean first;
+
+ g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
+ g_return_if_fail (end_index <= text->input->len);
+ g_return_if_fail (start_index <= end_index);
+ g_return_if_fail (str != NULL);
+
+ /* if there was a style sheet set when setting the text, modifications are
+ * not allowed */
+ if (text->style_sheet_input)
+ return;
+
+ first = TRUE;
+ prev = NULL;
+ for (iter = text->formats; iter != NULL; iter = iter->next)
+ {
+ findex = iter->data;
+
+ if (findex->index_ >= start_index) {
+ if (end_index == text->input->len ||(iter->next != NULL &&
+ ((SwfdecFormatIndex *)iter->next->data)->index_ <= end_index))
+ {
+ g_free (iter->data);
+ text->formats = g_slist_remove (text->formats, iter->data);
+ iter = (prev != NULL ? prev : text->formats);
+ }
+ else
+ {
+ findex->index_ += strlen (str) - (end_index - start_index);
+ if (first) {
+ findex->index_ -= strlen (str);
+ first = FALSE;
+ }
+ }
+ }
+ prev = iter;
+ }
+
+ if (end_index == text->input->len) {
+ if (SWFDEC_AS_OBJECT (text)->context->version < 8) {
+ SWFDEC_FIXME ("replaceText to the end of the TextField might use wrong text format on version 7");
+ }
+ findex = g_new0 (SwfdecFormatIndex, 1);
+ findex->index_ = start_index;
+ findex->format = swfdec_text_format_copy (
+ ((SwfdecFormatIndex *)text->formats->data)->format);
+ text->formats = g_slist_append (text->formats, findex);
+ }
+
+ text->input = g_string_erase (text->input, start_index,
+ end_index - start_index);
+ text->input = g_string_insert (text->input, start_index, str);
+
+ swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
+ swfdec_text_field_movie_auto_size (text);
+ swfdec_text_field_movie_update_scroll (text, TRUE);
+}
+
+void
+swfdec_text_field_movie_set_text (SwfdecTextFieldMovie *text, const char *str,
+ gboolean html)
+{
+ SwfdecFormatIndex *block;
+ GSList *iter;
+
+ g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
+ g_return_if_fail (str != NULL);
+
+ if (text->format_new == NULL) {
+ text->input = g_string_truncate (text->input, 0);
+ return;
+ }
+
+ // remove old formatting info
+ iter = text->formats;
+ while (iter) {
+ g_free (iter->data);
+ iter = g_slist_next (iter);
+ }
+ g_slist_free (text->formats);
+ text->formats = NULL;
+
+ // add the default style
+ if (html && SWFDEC_AS_OBJECT (text)->context->version < 8)
+ swfdec_text_format_set_defaults (text->format_new);
+ block = g_new (SwfdecFormatIndex, 1);
+ block->index_ = 0;
+ g_assert (SWFDEC_IS_TEXT_FORMAT (text->format_new));
+ block->format = swfdec_text_format_copy (text->format_new);
+ if (block->format == NULL) {
+ g_free (block);
+ text->input = g_string_truncate (text->input, 0);
+ return;
+ }
+ text->formats = g_slist_prepend (text->formats, block);
+
+ text->input_html = html;
+
+ if (SWFDEC_AS_OBJECT (text)->context->version >= 7 &&
+ text->style_sheet != NULL)
+ {
+ text->style_sheet_input = str;
+ swfdec_text_field_movie_html_parse (text, str);
+ }
+ else
+ {
+ text->style_sheet_input = NULL;
+ if (html) {
+ swfdec_text_field_movie_html_parse (text, str);
+ } else {
+ text->input = g_string_assign (text->input, str);
+ }
+ }
+
+ swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
+ swfdec_text_field_movie_auto_size (text);
+ swfdec_text_field_movie_update_scroll (text, TRUE);
+}
diff --git a/swfdec/swfdec_text_field_movie.h b/swfdec/swfdec_text_field_movie.h
new file mode 100644
index 0000000..8d719d3
--- /dev/null
+++ b/swfdec/swfdec_text_field_movie.h
@@ -0,0 +1,160 @@
+/* Swfdec
+ * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_TEXT_FIELD_MOVIE_H_
+#define _SWFDEC_TEXT_FIELD_MOVIE_H_
+
+#include <libswfdec/swfdec_movie.h>
+#include <libswfdec/swfdec_text_field.h>
+#include <libswfdec/swfdec_style_sheet.h>
+#include <libswfdec/swfdec_text_format.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _SwfdecTextFieldMovie SwfdecTextFieldMovie;
+typedef struct _SwfdecTextFieldMovieClass SwfdecTextFieldMovieClass;
+
+#define SWFDEC_TYPE_TEXT_FIELD_MOVIE (swfdec_text_field_movie_get_type())
+#define SWFDEC_IS_TEXT_FIELD_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_TEXT_FIELD_MOVIE))
+#define SWFDEC_IS_TEXT_FIELD_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_TEXT_FIELD_MOVIE))
+#define SWFDEC_TEXT_FIELD_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_TEXT_FIELD_MOVIE, SwfdecTextFieldMovie))
+#define SWFDEC_TEXT_FIELD_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_TEXT_FIELD_MOVIE, SwfdecTextFieldMovieClass))
+
+typedef struct {
+ PangoLayout * layout;
+ int offset_x;
+ int last_line_offset_y;
+ int height;
+ int width;
+ gboolean bullet;
+} SwfdecLayout;
+
+typedef struct {
+ guint index_;
+
+ PangoAlignment align;
+ gboolean justify;
+ int leading;
+ int block_indent;
+ int left_margin;
+ int right_margin;
+ PangoTabArray * tab_stops;
+} SwfdecBlock;
+
+typedef struct {
+ guint index_;
+ guint length;
+ gboolean newline; // ends in newline
+
+ gboolean bullet;
+ int indent;
+
+ GSList * blocks; // SwfdecBlock
+ GSList * attrs; // PangoAttribute
+} SwfdecParagraph;
+
+typedef struct {
+ guint index_;
+ SwfdecTextFormat * format;
+} SwfdecFormatIndex;
+
+struct _SwfdecTextFieldMovie {
+ SwfdecMovie movie;
+
+ SwfdecTextField * text; /* the text_field object we render */
+
+ GString * input;
+ char * asterisks; /* bunch of asterisks that we display when password mode is enabled */
+ guint asterisks_length;
+ gboolean input_html; /* whether orginal input was given as HTML */
+
+ const char * variable;
+
+ SwfdecTextFormat * format_new;
+ GSList * formats;
+
+ gboolean condense_white;
+ gboolean embed_fonts;
+
+ SwfdecAsObject * style_sheet;
+ const char * style_sheet_input; /* saved input, so it can be used to apply stylesheet again */
+
+ gboolean scroll_changed; /* if any of the scroll attributes have changed and we haven't fired the event yet */
+ int scroll;
+ int scroll_max;
+ int scroll_bottom;
+ int hscroll;
+ int hscroll_max;
+ gboolean mouse_wheel_enabled;
+
+ const char * restrict_;
+
+ SwfdecColor border_color;
+ SwfdecColor background_color;
+
+ // FIXME: Temporary using image surface, until there is a way to get cairo_t
+ // outside the rendering functions
+ cairo_surface_t * surface;
+ cairo_t * cr;
+};
+
+struct _SwfdecTextFieldMovieClass {
+ SwfdecMovieClass movie_class;
+};
+
+GType swfdec_text_field_movie_get_type (void);
+
+void swfdec_text_field_movie_set_text (SwfdecTextFieldMovie * movie,
+ const char * str,
+ gboolean html);
+void swfdec_text_field_movie_get_text_size (SwfdecTextFieldMovie * text,
+ int * width,
+ int * height);
+gboolean swfdec_text_field_movie_auto_size (SwfdecTextFieldMovie * text);
+void swfdec_text_field_movie_update_scroll (SwfdecTextFieldMovie * text,
+ gboolean check_limits);
+void swfdec_text_field_movie_set_text_format (SwfdecTextFieldMovie * text,
+ SwfdecTextFormat * format,
+ guint start_index,
+ guint end_index);
+SwfdecTextFormat *swfdec_text_field_movie_get_text_format (SwfdecTextFieldMovie * text,
+ guint start_index,
+ guint end_index);
+const char * swfdec_text_field_movie_get_text (SwfdecTextFieldMovie * text);
+void swfdec_text_field_movie_set_listen_variable (SwfdecTextFieldMovie * text,
+ const char * value);
+void swfdec_text_field_movie_set_listen_variable_text (SwfdecTextFieldMovie *text,
+ const char * value);
+void swfdec_text_field_movie_replace_text (SwfdecTextFieldMovie * text,
+ guint start_index,
+ guint end_index,
+ const char * str);
+
+/* implemented in swfdec_text_field_movie_as.c */
+void swfdec_text_field_movie_init_properties (SwfdecAsContext * cx);
+
+/* implemented in swfdec_html_parser.c */
+void swfdec_text_field_movie_html_parse (SwfdecTextFieldMovie * text,
+ const char * str);
+const char * swfdec_text_field_movie_get_html_text (SwfdecTextFieldMovie * text);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_text_field_movie_as.c b/swfdec/swfdec_text_field_movie_as.c
new file mode 100644
index 0000000..7e34120
--- /dev/null
+++ b/swfdec/swfdec_text_field_movie_as.c
@@ -0,0 +1,1539 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include <pango/pangocairo.h>
+
+#include "swfdec_text_field.h"
+#include "swfdec_text_field_movie.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_context.h"
+#include "swfdec_as_object.h"
+#include "swfdec_as_frame_internal.h"
+#include "swfdec_internal.h"
+#include "swfdec_player_internal.h"
+
+static SwfdecColor
+swfdec_text_field_movie_int_to_color (SwfdecAsContext *cx, int value)
+{
+ if (value < 0) {
+ value = (0xffffff + 1) + value % (0xffffff + 1);
+ } else {
+ value = value % (0xffffff + 1);
+ }
+
+ return SWFDEC_COLOR_COMBINE (value >> 16 & 0xff, value >> 8 & 0xff,
+ value & 0xff, 0);
+}
+
+// does nothing but calls valueOf
+static void
+swfdec_text_field_movie_set_readonly (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ if (argc > 0)
+ swfdec_as_value_to_number (cx, &argv[0]);
+}
+
+/*
+ * Native properties: Text
+ */
+static void
+swfdec_text_field_movie_do_get_text (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_text_field_movie_get_text (text));
+}
+
+static void
+swfdec_text_field_movie_do_set_text (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ const char *value;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "s", &value);
+
+ swfdec_text_field_movie_set_text (text, value, FALSE);
+
+ if (text->variable != NULL) {
+ if (text->text->html) {
+ swfdec_text_field_movie_set_listen_variable_text (text,
+ swfdec_text_field_movie_get_html_text (text));
+ } else {
+ swfdec_text_field_movie_set_listen_variable_text (text,
+ swfdec_text_field_movie_get_text (text));
+ }
+ }
+}
+
+static void
+swfdec_text_field_movie_get_html (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->text->html);
+}
+
+static void
+swfdec_text_field_movie_set_html (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ gboolean value;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
+
+ swfdec_as_value_to_number (cx, &argv[0]);
+
+ text->text->html = value;
+
+ // FIXME: resize? invalidate?
+}
+
+static void
+swfdec_text_field_movie_get_htmlText (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ if (text->style_sheet_input) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, text->style_sheet_input);
+ } else if (text->text->html) {
+ SWFDEC_AS_VALUE_SET_STRING (ret,
+ swfdec_text_field_movie_get_html_text (text));
+ } else {
+ SWFDEC_AS_VALUE_SET_STRING (ret,
+ swfdec_text_field_movie_get_text (text));
+ }
+}
+
+static void
+swfdec_text_field_movie_set_htmlText (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ const char *value;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "s", &value);
+
+ swfdec_text_field_movie_set_text (text, value, text->text->html);
+
+ if (text->variable != NULL) {
+ if (text->text->html) {
+ swfdec_text_field_movie_set_listen_variable_text (text,
+ swfdec_text_field_movie_get_html_text (text));
+ } else {
+ swfdec_text_field_movie_set_listen_variable_text (text,
+ swfdec_text_field_movie_get_text (text));
+ }
+ }
+}
+
+static void
+swfdec_text_field_movie_get_length (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ SWFDEC_AS_VALUE_SET_INT (ret, g_utf8_strlen (text->input->str, -1));
+}
+
+/*
+ * Native properties: Input
+ */
+static void
+swfdec_text_field_movie_get_condenseWhite (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->condense_white);
+}
+
+static void
+swfdec_text_field_movie_set_condenseWhite (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ gboolean value;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
+
+ swfdec_as_value_to_number (cx, &argv[0]);
+
+ text->condense_white = value;
+}
+
+static void
+swfdec_text_field_movie_get_maxChars (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ if (text->text->max_chars != 0) {
+ SWFDEC_AS_VALUE_SET_INT (ret, text->text->max_chars);
+ } else {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ }
+}
+
+static void
+swfdec_text_field_movie_set_maxChars (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ if (argc < 1)
+ return;
+
+ swfdec_as_value_to_number (cx, &argv[0]);
+ text->text->max_chars = swfdec_as_value_to_integer (cx, &argv[0]);
+}
+
+static void
+swfdec_text_field_movie_get_multiline (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->text->multiline);
+}
+
+static void
+swfdec_text_field_movie_set_multiline (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ gboolean value;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
+
+ swfdec_as_value_to_number (cx, &argv[0]);
+
+ text->text->multiline = value;
+}
+
+static void
+swfdec_text_field_movie_get_restrict (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ if (text->restrict_ != NULL) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, text->restrict_);
+ } else {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ }
+}
+
+static void
+swfdec_text_field_movie_set_restrict (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ const char *value;
+
+ if (argc > 0)
+ swfdec_as_value_to_number (cx, &argv[0]);
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "s", &value);
+
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]) ||
+ SWFDEC_AS_VALUE_IS_NULL (&argv[0])) {
+ text->restrict_ = NULL;
+ } else {
+ text->restrict_ = value;
+ }
+}
+
+static void
+swfdec_text_field_movie_get_selectable (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->text->selectable);
+}
+
+static void
+swfdec_text_field_movie_set_selectable (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ gboolean value;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
+
+ swfdec_as_value_to_number (cx, &argv[0]);
+
+ text->text->selectable = value;
+
+ // FIXME: invalidate
+}
+
+static void
+swfdec_text_field_movie_do_get_type (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ if (text->text->editable) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_input);
+ } else {
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_dynamic);
+ }
+}
+
+static void
+swfdec_text_field_movie_do_set_type (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ const char *value;
+
+ if (argc > 0)
+ swfdec_as_value_to_number (cx, &argv[0]);
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "s", &value);
+
+ if (!g_strcasecmp (value, SWFDEC_AS_STR_input)) {
+ text->text->editable = TRUE;
+ } else if (!g_strcasecmp (value, SWFDEC_AS_STR_dynamic)) {
+ text->text->editable = FALSE;
+ }
+
+ // FIXME: invalidate
+}
+
+static void
+swfdec_text_field_movie_do_get_variable (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ if (text->variable) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, text->variable);
+ } else {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ }
+}
+
+static void
+swfdec_text_field_movie_do_set_variable (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ const char *value;
+
+ if (argc > 0)
+ swfdec_as_value_to_number (cx, &argv[0]);
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "s", &value);
+
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]) ||
+ SWFDEC_AS_VALUE_IS_NULL (&argv[0]) || value == SWFDEC_AS_STR_EMPTY) {
+ value = NULL;
+ }
+
+ swfdec_text_field_movie_set_listen_variable (text, value);
+}
+
+/*
+ * Native properties: Info
+ */
+static void
+swfdec_text_field_movie_get_textHeight (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ int height;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ swfdec_text_field_movie_get_text_size (text, NULL, &height);
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, SWFDEC_TWIPS_TO_DOUBLE (height));
+}
+
+static void
+swfdec_text_field_movie_get_textWidth (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ int width;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ swfdec_text_field_movie_get_text_size (text, &width, NULL);
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, SWFDEC_TWIPS_TO_DOUBLE (width));
+}
+
+/*
+ * Native properties: Background & border
+ */
+static void
+swfdec_text_field_movie_get_background (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->text->background);
+}
+
+static void
+swfdec_text_field_movie_set_background (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ gboolean value;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
+
+ swfdec_as_value_to_number (cx, &argv[0]);
+
+ if (text->text->background != value) {
+ text->text->background = value;
+ swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
+ }
+}
+
+static void
+swfdec_text_field_movie_get_backgroundColor (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret,
+ SWFDEC_COLOR_R (text->background_color) << 16 |
+ SWFDEC_COLOR_G (text->background_color) << 8 |
+ SWFDEC_COLOR_B (text->background_color));
+}
+
+static void
+swfdec_text_field_movie_set_backgroundColor (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ int value;
+ SwfdecColor color;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "i", &value);
+
+ color = swfdec_text_field_movie_int_to_color (cx, value);
+ if (text->background_color != color) {
+ text->background_color = color;
+ swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
+ }
+}
+
+static void
+swfdec_text_field_movie_get_border (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->text->border);
+}
+
+static void
+swfdec_text_field_movie_set_border (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ gboolean value;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
+
+ swfdec_as_value_to_number (cx, &argv[0]);
+
+ if (text->text->border != value) {
+ text->text->border = value;
+ swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
+ }
+}
+
+static void
+swfdec_text_field_movie_get_borderColor (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret,
+ SWFDEC_COLOR_R (text->border_color) << 16 |
+ SWFDEC_COLOR_G (text->border_color) << 8 |
+ SWFDEC_COLOR_B (text->border_color));
+}
+
+static void
+swfdec_text_field_movie_set_borderColor (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ int value;
+ SwfdecColor color;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "i", &value);
+
+ color = swfdec_text_field_movie_int_to_color (cx, value);
+ if (text->border_color != color) {
+ text->border_color = color;
+ swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
+ }
+}
+
+/*
+ * Native properties: Scrolling
+ */
+static void
+swfdec_text_field_movie_get_bottomScroll (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, text->scroll_bottom);
+}
+
+static void
+swfdec_text_field_movie_do_get_hscroll (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, text->hscroll);
+}
+
+static void
+swfdec_text_field_movie_do_set_hscroll (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ int value;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "i", &value);
+
+ value = CLAMP (value, 0, text->hscroll_max);
+ if (value != text->hscroll) {
+ text->hscroll = value;
+ text->scroll_changed = TRUE;
+ swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
+ }
+}
+
+static void
+swfdec_text_field_movie_get_maxhscroll (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ if (!text->text->word_wrap) {
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, text->hscroll_max);
+ } else {
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, 0);
+ }
+}
+
+static void
+swfdec_text_field_movie_get_maxscroll (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, text->scroll_max);
+}
+
+static void
+swfdec_text_field_movie_get_mouseWheelEnabled (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->mouse_wheel_enabled);
+}
+
+static void
+swfdec_text_field_movie_set_mouseWheelEnabled (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ gboolean value;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
+
+ swfdec_as_value_to_number (cx, &argv[0]);
+
+ text->mouse_wheel_enabled = value;
+}
+
+static void
+swfdec_text_field_movie_do_get_scroll (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, text->scroll);
+}
+
+static void
+swfdec_text_field_movie_do_set_scroll (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ int value;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "i", &value);
+
+ value = CLAMP (value, 1, text->scroll_max);
+ if (value != text->scroll) {
+ text->scroll_bottom += value - text->scroll;
+ text->scroll = value;
+ text->scroll_changed = TRUE;
+ swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
+ }
+}
+
+/*
+ * Native properties: Display
+ */
+static void
+swfdec_text_field_movie_get_autoSize (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ switch (text->text->auto_size) {
+ case SWFDEC_AUTO_SIZE_NONE:
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_none);
+ break;
+ case SWFDEC_AUTO_SIZE_LEFT:
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_left);
+ break;
+ case SWFDEC_AUTO_SIZE_RIGHT:
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_right);
+ break;
+ case SWFDEC_AUTO_SIZE_CENTER:
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_center);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+}
+
+static void
+swfdec_text_field_movie_set_autoSize (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ SwfdecAutoSize old;
+ const char *s;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ if (argc < 1)
+ return;
+
+ if (SWFDEC_AS_VALUE_IS_BOOLEAN (&argv[0])) {
+ if (SWFDEC_AS_VALUE_GET_BOOLEAN (&argv[0])) {
+ text->text->auto_size = SWFDEC_AUTO_SIZE_LEFT;
+ } else {
+ text->text->auto_size = SWFDEC_AUTO_SIZE_NONE;
+ }
+ return;
+ }
+
+ swfdec_as_value_to_number (cx, &argv[0]);
+ s = swfdec_as_value_to_string (cx, &argv[0]);
+
+ old = text->text->auto_size;
+ if (!g_ascii_strcasecmp (s, "none")) {
+ text->text->auto_size = SWFDEC_AUTO_SIZE_NONE;
+ } else if (!g_ascii_strcasecmp (s, "left")) {
+ text->text->auto_size = SWFDEC_AUTO_SIZE_LEFT;
+ } else if (!g_ascii_strcasecmp (s, "right")) {
+ text->text->auto_size = SWFDEC_AUTO_SIZE_RIGHT;
+ } else if (!g_ascii_strcasecmp (s, "center")) {
+ text->text->auto_size = SWFDEC_AUTO_SIZE_CENTER;
+ }
+
+ if (text->text->auto_size != old) {
+ swfdec_text_field_movie_auto_size (text);
+ // FIXME: fix scrolling
+ }
+}
+
+static void
+swfdec_text_field_movie_get_password (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->text->password);
+}
+
+static void
+swfdec_text_field_movie_set_password (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ gboolean value;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
+
+ swfdec_as_value_to_number (cx, &argv[0]);
+
+ if (text->text->password != value) {
+ text->text->password = value;
+ if (!value && text->asterisks != NULL) {
+ g_free (text->asterisks);
+ text->asterisks = NULL;
+ text->asterisks_length = 0;
+ }
+ swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
+ }
+}
+
+static void
+swfdec_text_field_movie_get_wordWrap (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->text->word_wrap);
+}
+
+static void
+swfdec_text_field_movie_set_wordWrap (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ gboolean value;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
+
+ swfdec_as_value_to_number (cx, &argv[0]);
+
+ if (text->text->word_wrap != value) {
+ text->text->word_wrap = value;
+ swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
+ swfdec_text_field_movie_auto_size (text);
+ // special case: don't set scrolling
+ }
+}
+
+/*
+ * Native properties: Format
+ */
+static void
+swfdec_text_field_movie_get_embedFonts (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, text->text->embed_fonts);
+}
+
+static void
+swfdec_text_field_movie_set_embedFonts (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ gboolean value;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "b", &value);
+
+ swfdec_as_value_to_number (cx, &argv[0]);
+
+ if (!text->text->embed_fonts && value)
+ SWFDEC_FIXME ("Using embed fonts in TextField not supported");
+
+ text->text->embed_fonts = value;
+
+ // FIXME: resize
+}
+
+static void
+swfdec_text_field_movie_get_styleSheet (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ if (text->style_sheet != NULL) {
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (text->style_sheet));
+ } else {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (ret);
+ }
+}
+
+static void
+swfdec_text_field_movie_style_sheet_update (SwfdecTextFieldMovie *text)
+{
+ if (text->style_sheet_input)
+ swfdec_text_field_movie_set_text (text, text->style_sheet_input, TRUE);
+}
+
+static void
+swfdec_text_field_movie_set_styleSheet (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ SwfdecAsObject *value;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ if (argc < 1)
+ return;
+
+ swfdec_as_value_to_number (cx, &argv[0]);
+
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[0])) {
+ value = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
+ if (SWFDEC_IS_MOVIE (value))
+ value = NULL;
+ } else {
+ value = NULL;
+ }
+
+ if (text->style_sheet == value)
+ return;
+
+ if (text->style_sheet != NULL && SWFDEC_IS_STYLESHEET (text->style_sheet)) {
+ g_signal_handlers_disconnect_by_func (text->style_sheet,
+ swfdec_text_field_movie_style_sheet_update, text);
+ g_object_remove_weak_pointer (G_OBJECT (text->style_sheet),
+ (gpointer) &text->style_sheet);
+ }
+
+ text->style_sheet = value;
+
+ if (SWFDEC_IS_STYLESHEET (value)) {
+ g_signal_connect_swapped (value, "update",
+ G_CALLBACK (swfdec_text_field_movie_style_sheet_update), text);
+ g_object_add_weak_pointer (G_OBJECT (text->style_sheet),
+ (gpointer) &text->style_sheet);
+
+ swfdec_text_field_movie_style_sheet_update (text);
+ }
+}
+
+static void
+swfdec_text_field_movie_get_textColor (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, text->format_new->color);
+}
+
+// This doesn't work the same way as TextFormat's color setting
+static void
+swfdec_text_field_movie_set_textColor (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ int value;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "i", &value);
+
+ text->format_new->color = swfdec_text_field_movie_int_to_color (cx, value);
+}
+
+SWFDEC_AS_NATIVE (104, 300, swfdec_text_field_movie_get_gridFitType)
+void
+swfdec_text_field_movie_get_gridFitType (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextField.gridFitType (get)");
+}
+
+SWFDEC_AS_NATIVE (104, 301, swfdec_text_field_movie_set_gridFitType)
+void
+swfdec_text_field_movie_set_gridFitType (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextField.gridFitType (set)");
+}
+
+SWFDEC_AS_NATIVE (104, 302, swfdec_text_field_movie_get_antiAliasType)
+void
+swfdec_text_field_movie_get_antiAliasType (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextField.antiAliasType (get)");
+}
+
+SWFDEC_AS_NATIVE (104, 303, swfdec_text_field_movie_set_antiAliasType)
+void
+swfdec_text_field_movie_set_antiAliasType (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextField.antiAliasType (set)");
+}
+
+SWFDEC_AS_NATIVE (104, 304, swfdec_text_field_movie_get_thickness)
+void
+swfdec_text_field_movie_get_thickness (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextField.thickness (get)");
+}
+
+SWFDEC_AS_NATIVE (104, 305, swfdec_text_field_movie_set_thickness)
+void
+swfdec_text_field_movie_set_thickness (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextField.thickness (set)");
+}
+
+SWFDEC_AS_NATIVE (104, 306, swfdec_text_field_movie_get_sharpness)
+void
+swfdec_text_field_movie_get_sharpness (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextField.sharpness (get)");
+}
+
+SWFDEC_AS_NATIVE (104, 307, swfdec_text_field_movie_set_sharpness)
+void
+swfdec_text_field_movie_set_sharpness (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextField.sharpness (set)");
+}
+
+SWFDEC_AS_NATIVE (104, 308, swfdec_text_field_movie_get_filters)
+void
+swfdec_text_field_movie_get_filters (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextField.filters (get)");
+}
+
+SWFDEC_AS_NATIVE (104, 309, swfdec_text_field_movie_set_filters)
+void
+swfdec_text_field_movie_set_filters (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextField.filters (set)");
+}
+
+/*
+ * Native functions
+ */
+SWFDEC_AS_NATIVE (104, 104, swfdec_text_field_movie_getNewTextFormat)
+void
+swfdec_text_field_movie_getNewTextFormat (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ swfdec_text_format_init_properties (cx);
+
+ SWFDEC_AS_VALUE_SET_OBJECT (ret,
+ SWFDEC_AS_OBJECT (swfdec_text_format_copy (text->format_new)));
+}
+
+SWFDEC_AS_NATIVE (104, 105, swfdec_text_field_movie_setNewTextFormat)
+void
+swfdec_text_field_movie_setNewTextFormat (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ SwfdecAsObject *obj;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "o", &obj);
+
+ if (!SWFDEC_IS_TEXT_FORMAT (obj))
+ return;
+
+ swfdec_text_format_add (text->format_new, SWFDEC_TEXT_FORMAT (obj));
+}
+
+SWFDEC_AS_NATIVE (104, 102, swfdec_text_field_movie_setTextFormat)
+void
+swfdec_text_field_movie_setTextFormat (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ SwfdecTextFormat *format;
+ int val, start_index, end_index;
+ guint i;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ if (argc < 1)
+ return;
+
+ i = 0;
+ if (argc <= i + 1) {
+ start_index = 0;
+ end_index = g_utf8_strlen (text->input->str, -1);
+ } else {
+ start_index = val = swfdec_as_value_to_integer (cx, &argv[i++]);
+ start_index = CLAMP (start_index, 0, g_utf8_strlen (text->input->str, -1));
+ if (argc <= i + 1) {
+ if (val < 0) { // fail
+ start_index = end_index = 0;
+ } else{
+ end_index = start_index + 1;
+ }
+ } else {
+ end_index = swfdec_as_value_to_integer (cx, &argv[i++]);
+ }
+ end_index =
+ CLAMP (end_index, start_index, g_utf8_strlen (text->input->str, -1));
+ }
+ if (start_index == end_index)
+ return;
+
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[i]))
+ return;
+ if (!SWFDEC_IS_TEXT_FORMAT (SWFDEC_AS_VALUE_GET_OBJECT (&argv[i])))
+ return;
+
+ format = SWFDEC_TEXT_FORMAT (SWFDEC_AS_VALUE_GET_OBJECT (&argv[i]));
+
+ swfdec_text_field_movie_set_text_format (text, format,
+ g_utf8_offset_to_pointer (text->input->str, start_index) -
+ text->input->str,
+ g_utf8_offset_to_pointer (text->input->str, end_index) -
+ text->input->str);
+
+ swfdec_movie_invalidate_last (SWFDEC_MOVIE (text));
+ swfdec_text_field_movie_auto_size (text);
+ // special case: update the max values, not the current values
+ swfdec_text_field_movie_update_scroll (text, FALSE);
+}
+
+SWFDEC_AS_NATIVE (104, 101, swfdec_text_field_movie_getTextFormat)
+void
+swfdec_text_field_movie_getTextFormat (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ SwfdecTextFormat *format;
+ int val, start_index, end_index;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ if (argc == 0) {
+ start_index = 0;
+ end_index = g_utf8_strlen (text->input->str, -1);
+ } else {
+ start_index = val = swfdec_as_value_to_integer (cx, &argv[0]);
+ start_index = CLAMP (start_index, 0, g_utf8_strlen (text->input->str, -1));
+ if (argc == 1) {
+ if (val < 0) { // fail
+ start_index = end_index = 0;
+ } else{
+ end_index = start_index + 1;
+ }
+ } else {
+ end_index = swfdec_as_value_to_integer (cx, &argv[1]);
+ }
+ end_index =
+ CLAMP (end_index, start_index, g_utf8_strlen (text->input->str, -1));
+ }
+
+ if (start_index == end_index) {
+ format = SWFDEC_TEXT_FORMAT (swfdec_text_format_new (cx));
+ } else {
+ format = swfdec_text_field_movie_get_text_format (text,
+ g_utf8_offset_to_pointer (text->input->str, start_index) -
+ text->input->str,
+ g_utf8_offset_to_pointer (text->input->str, end_index) -
+ text->input->str);
+ }
+
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (format));
+}
+
+SWFDEC_AS_NATIVE (104, 100, swfdec_text_field_movie_replaceSel)
+void
+swfdec_text_field_movie_replaceSel (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextField.replaceSel");
+}
+
+SWFDEC_AS_NATIVE (104, 107, swfdec_text_field_movie_replaceText)
+void
+swfdec_text_field_movie_replaceText (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFieldMovie *text;
+ int start_index, end_index;
+ const char *str;
+
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "iis", &start_index,
+ &end_index, &str);
+
+ if (start_index < 0)
+ return;
+ if (end_index < start_index)
+ return;
+
+ start_index = MIN (start_index, g_utf8_strlen (text->input->str, -1));
+ end_index = MIN (end_index, g_utf8_strlen (text->input->str, -1));
+
+ swfdec_text_field_movie_replace_text (text,
+ g_utf8_offset_to_pointer (text->input->str, start_index) -
+ text->input->str,
+ g_utf8_offset_to_pointer (text->input->str, end_index) -
+ text->input->str, str);
+}
+
+// static
+SWFDEC_AS_NATIVE (104, 201, swfdec_text_field_movie_getFontList)
+void
+swfdec_text_field_movie_getFontList (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecAsArray *array;
+ SwfdecAsValue val;
+ PangoFontFamily **families;
+ int i, n_families;
+
+ pango_font_map_list_families (pango_cairo_font_map_get_default (),
+ &families, &n_families);
+
+ array = SWFDEC_AS_ARRAY (swfdec_as_array_new (cx));
+ for (i = 0; i < n_families; i++) {
+ SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_get_string (cx,
+ pango_font_family_get_name (families[i])));
+ swfdec_as_array_push (array, &val);
+ }
+ SWFDEC_AS_VALUE_SET_STRING (&val, SWFDEC_AS_STR_Sans);
+ swfdec_as_array_push (array, &val);
+ SWFDEC_AS_VALUE_SET_STRING (&val, SWFDEC_AS_STR_Serif);
+ swfdec_as_array_push (array, &val);
+ SWFDEC_AS_VALUE_SET_STRING (&val, SWFDEC_AS_STR_Monospace);
+ swfdec_as_array_push (array, &val);
+
+ g_free (families);
+
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (array));
+}
+
+SWFDEC_AS_NATIVE (104, 106, swfdec_text_field_movie_getDepth)
+void
+swfdec_text_field_movie_getDepth (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecTextFieldMovie *text;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ SWFDEC_AS_VALUE_SET_INT (rval, SWFDEC_MOVIE (text)->depth);
+}
+
+SWFDEC_AS_NATIVE (104, 103, swfdec_text_field_movie_removeTextField)
+void
+swfdec_text_field_movie_removeTextField (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *rval)
+{
+ SwfdecTextFieldMovie *text;
+ SwfdecMovie *movie;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE, &text, "");
+
+ movie = SWFDEC_MOVIE (text);
+ if (swfdec_depth_classify (movie->depth) == SWFDEC_DEPTH_CLASS_DYNAMIC)
+ swfdec_movie_remove (movie);
+}
+
+/*
+ * Creating TextFields
+ */
+SWFDEC_AS_NATIVE (104, 200, swfdec_text_field_movie_createTextField)
+void
+swfdec_text_field_movie_createTextField (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *rval)
+{
+ SwfdecMovie *movie, *parent;
+ SwfdecTextField *edittext;
+ int depth, x, y, width, height;
+ const char *name;
+ SwfdecAsFunction *fun;
+ SwfdecAsValue val;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, &parent, "siiiii", &name, &depth, &x, &y, &width, &height);
+
+ edittext = g_object_new (SWFDEC_TYPE_TEXT_FIELD, NULL);
+ edittext->html = FALSE;
+ edittext->editable = FALSE;
+ edittext->password = FALSE;
+ edittext->selectable = TRUE;
+ edittext->font = NULL; // FIXME
+ edittext->word_wrap = FALSE;
+ edittext->multiline = FALSE;
+ edittext->auto_size = SWFDEC_AUTO_SIZE_NONE;
+ edittext->border = FALSE;
+ edittext->size = 240; // FIXME: Correct?
+
+ edittext->input = NULL;
+ edittext->variable = NULL;
+ edittext->color = 0;
+ edittext->align = SWFDEC_TEXT_ALIGN_LEFT;
+ edittext->left_margin = 0;
+ edittext->right_margin = 0;
+ edittext->indent = 0;
+ edittext->leading = 0;
+
+ SWFDEC_GRAPHIC (edittext)->extents.x0 = SWFDEC_DOUBLE_TO_TWIPS (x);
+ SWFDEC_GRAPHIC (edittext)->extents.x1 =
+ SWFDEC_GRAPHIC (edittext)->extents.x0 + SWFDEC_DOUBLE_TO_TWIPS (width);
+ SWFDEC_GRAPHIC (edittext)->extents.y0 = SWFDEC_DOUBLE_TO_TWIPS (y);
+ SWFDEC_GRAPHIC (edittext)->extents.y1 =
+ SWFDEC_GRAPHIC (edittext)->extents.y0 + SWFDEC_DOUBLE_TO_TWIPS (height);
+
+ movie = swfdec_movie_find (parent, depth);
+ if (movie)
+ swfdec_movie_remove (movie);
+
+ movie = swfdec_movie_new (SWFDEC_PLAYER (cx), depth, parent, parent->resource,
+ SWFDEC_GRAPHIC (edittext), name);
+ g_assert (SWFDEC_IS_TEXT_FIELD_MOVIE (movie));
+ g_object_unref (edittext);
+ swfdec_movie_initialize (movie);
+ swfdec_movie_update (movie);
+
+ swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_TextField, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return;
+ fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (&val);
+ if (!SWFDEC_IS_AS_FUNCTION (fun))
+ return;
+
+ /* set initial variables */
+ if (swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (fun),
+ SWFDEC_AS_STR_prototype, &val)) {
+ swfdec_as_object_set_variable_and_flags (SWFDEC_AS_OBJECT (movie),
+ SWFDEC_AS_STR___proto__, &val,
+ SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+ }
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (fun));
+ if (cx->version < 7) {
+ swfdec_as_object_set_variable_and_flags (SWFDEC_AS_OBJECT (movie),
+ SWFDEC_AS_STR_constructor, &val, SWFDEC_AS_VARIABLE_HIDDEN);
+ }
+ swfdec_as_object_set_variable_and_flags (SWFDEC_AS_OBJECT (movie),
+ SWFDEC_AS_STR___constructor__, &val,
+ SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_VERSION_6_UP);
+
+ swfdec_as_function_call (fun, SWFDEC_AS_OBJECT (movie), 0, NULL, rval);
+ cx->frame->construct = TRUE;
+ swfdec_as_context_run (cx);
+}
+
+void
+swfdec_text_field_movie_init_properties (SwfdecAsContext *cx)
+{
+ SwfdecAsValue val;
+ SwfdecAsObject *object, *proto;
+
+ // FIXME: We should only initialize if the prototype Object has not been
+ // initialized by any object's constructor with native properties
+ // (TextField, TextFormat, XML, XMLNode at least)
+
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (cx));
+
+ swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_TextField, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return;
+ object = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+ swfdec_as_object_get_variable (object, SWFDEC_AS_STR_prototype, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return;
+ proto = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+
+ // text
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_text,
+ swfdec_text_field_movie_do_get_text,
+ swfdec_text_field_movie_do_set_text);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_html,
+ swfdec_text_field_movie_get_html, swfdec_text_field_movie_set_html);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_htmlText,
+ swfdec_text_field_movie_get_htmlText,
+ swfdec_text_field_movie_set_htmlText);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_length,
+ swfdec_text_field_movie_get_length,
+ swfdec_text_field_movie_set_readonly);
+
+ // input
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_condenseWhite,
+ swfdec_text_field_movie_get_condenseWhite,
+ swfdec_text_field_movie_set_condenseWhite);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_maxChars,
+ swfdec_text_field_movie_get_maxChars,
+ swfdec_text_field_movie_set_maxChars);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_multiline,
+ swfdec_text_field_movie_get_multiline,
+ swfdec_text_field_movie_set_multiline);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_restrict,
+ swfdec_text_field_movie_get_restrict,
+ swfdec_text_field_movie_set_restrict);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_selectable,
+ swfdec_text_field_movie_get_selectable,
+ swfdec_text_field_movie_set_selectable);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_type,
+ swfdec_text_field_movie_do_get_type,
+ swfdec_text_field_movie_do_set_type);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_variable,
+ swfdec_text_field_movie_do_get_variable,
+ swfdec_text_field_movie_do_set_variable);
+
+ // info
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_textHeight,
+ swfdec_text_field_movie_get_textHeight,
+ swfdec_text_field_movie_set_readonly);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_textWidth,
+ swfdec_text_field_movie_get_textWidth,
+ swfdec_text_field_movie_set_readonly);
+
+ // border & background
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_background,
+ swfdec_text_field_movie_get_background,
+ swfdec_text_field_movie_set_background);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_backgroundColor,
+ swfdec_text_field_movie_get_backgroundColor,
+ swfdec_text_field_movie_set_backgroundColor);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_border,
+ swfdec_text_field_movie_get_border, swfdec_text_field_movie_set_border);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_borderColor,
+ swfdec_text_field_movie_get_borderColor,
+ swfdec_text_field_movie_set_borderColor);
+
+ // scrolling
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_bottomScroll,
+ swfdec_text_field_movie_get_bottomScroll,
+ swfdec_text_field_movie_set_readonly);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_hscroll,
+ swfdec_text_field_movie_do_get_hscroll,
+ swfdec_text_field_movie_do_set_hscroll);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_maxhscroll,
+ swfdec_text_field_movie_get_maxhscroll,
+ swfdec_text_field_movie_set_readonly);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_maxscroll,
+ swfdec_text_field_movie_get_maxscroll,
+ swfdec_text_field_movie_set_readonly);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_mouseWheelEnabled,
+ swfdec_text_field_movie_get_mouseWheelEnabled,
+ swfdec_text_field_movie_set_mouseWheelEnabled);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_scroll,
+ swfdec_text_field_movie_do_get_scroll,
+ swfdec_text_field_movie_do_set_scroll);
+
+ // display
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_autoSize,
+ swfdec_text_field_movie_get_autoSize,
+ swfdec_text_field_movie_set_autoSize);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_password,
+ swfdec_text_field_movie_get_password,
+ swfdec_text_field_movie_set_password);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_wordWrap,
+ swfdec_text_field_movie_get_wordWrap,
+ swfdec_text_field_movie_set_wordWrap);
+
+ // format
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_embedFonts,
+ swfdec_text_field_movie_get_embedFonts,
+ swfdec_text_field_movie_set_embedFonts);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_styleSheet,
+ swfdec_text_field_movie_get_styleSheet,
+ swfdec_text_field_movie_set_styleSheet);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_textColor,
+ swfdec_text_field_movie_get_textColor,
+ swfdec_text_field_movie_set_textColor);
+
+ // TODO: menu, tabEnabled, tabIndex
+
+ // Version 8 properties have ASnative numbers:
+ // gridFitType, antiAliasType, thickness, sharpness and filters
+}
+
+SWFDEC_AS_NATIVE (104, 0, swfdec_text_field_movie_construct)
+void
+swfdec_text_field_movie_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!cx->frame->construct) {
+ SwfdecAsValue val;
+ if (!swfdec_as_context_use_mem (cx, sizeof (SwfdecAsObject)))
+ return;
+ object = g_object_new (SWFDEC_TYPE_AS_OBJECT, NULL);
+ swfdec_as_object_add (object, cx, sizeof (SwfdecAsObject));
+ swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_TextField, &val);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
+ swfdec_as_object_set_constructor (object,
+ SWFDEC_AS_VALUE_GET_OBJECT (&val));
+ } else {
+ SWFDEC_INFO ("\"TextField\" is not an object");
+ }
+ }
+
+ swfdec_text_field_movie_init_properties (cx);
+
+ // FIXME: do object.addListener (object);
+
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
+}
diff --git a/swfdec/swfdec_text_field_movie_html.c b/swfdec/swfdec_text_field_movie_html.c
new file mode 100644
index 0000000..b0aa94f
--- /dev/null
+++ b/swfdec/swfdec_text_field_movie_html.c
@@ -0,0 +1,777 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "swfdec_text_field_movie.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_style_sheet.h"
+#include "swfdec_xml.h"
+#include "swfdec_debug.h"
+
+/*
+ * Parsing
+ */
+typedef struct {
+ const char * name;
+ int name_length;
+ guint index;
+ guint end_index;
+ SwfdecTextFormat *format;
+} ParserTag;
+
+typedef struct {
+ SwfdecAsContext *cx;
+ gboolean multiline;
+ gboolean condense_white;
+ SwfdecStyleSheet *style_sheet;
+ GString * text;
+ GSList * tags_open;
+ GSList * tags_closed;
+} ParserData;
+
+static void
+swfdec_text_field_movie_html_parse_close_tag (ParserData *data, ParserTag *tag)
+{
+ g_return_if_fail (data != NULL);
+ g_return_if_fail (tag != NULL);
+
+ if (data->multiline &&
+ ((tag->name_length == 1 && !g_strncasecmp (tag->name, "p", 1)) ||
+ (tag->name_length == 2 && !g_strncasecmp (tag->name, "li", 2))))
+ {
+ GSList *iter;
+
+ for (iter = data->tags_closed; iter != NULL; iter = iter->next) {
+ ParserTag *f = iter->data;
+ if (f->end_index < tag->index)
+ break;
+ if (f->name_length == 4 && !g_strncasecmp (f->name, "font", 4)) {
+ ParserTag *n = g_new0 (ParserTag, 1);
+ n->name = f->name;
+ n->name_length = f->name_length;
+ n->index = data->text->len;
+ n->end_index = n->index + 1;
+ if (f->format != NULL) {
+ n->format = swfdec_text_format_copy (f->format);
+ } else {
+ n->format = NULL;
+ }
+ data->tags_closed = g_slist_prepend (data->tags_closed, n);
+ break;
+ }
+ }
+ data->text = g_string_append_c (data->text, '\n');
+ }
+
+ tag->end_index = data->text->len;
+
+ data->tags_open = g_slist_remove (data->tags_open, tag);
+ data->tags_closed = g_slist_prepend (data->tags_closed, tag);
+}
+
+static const char *
+swfdec_text_field_movie_html_parse_comment (ParserData *data, const char *p)
+{
+ const char *end;
+
+ g_return_val_if_fail (data != NULL, NULL);
+ g_return_val_if_fail (p != NULL, NULL);
+ g_return_val_if_fail (strncmp (p, "<!--", strlen ("<!--")) == 0, NULL);
+
+ end = strstr (p + strlen ("<!--"), "-->");
+ if (end != NULL)
+ end += strlen("-->");
+
+ // return NULL if no end found
+ return end;
+}
+
+static void
+swfdec_text_field_movie_html_tag_set_attribute (ParserData *data,
+ ParserTag *tag, const char *name, int name_length, const char *value,
+ int value_length)
+{
+ SwfdecAsValue val;
+ SwfdecAsObject *object;
+
+ g_return_if_fail (data != NULL);
+ g_return_if_fail (tag != NULL);
+ g_return_if_fail (name != NULL);
+ g_return_if_fail (name_length >= 0);
+ g_return_if_fail (value != NULL);
+ g_return_if_fail (value_length >= 0);
+
+ if (!tag->format)
+ return;
+
+ object = SWFDEC_AS_OBJECT (tag->format);
+ SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_give_string (
+ object->context, g_strndup (value, value_length)));
+
+ if (tag->name_length == 10 && !g_strncasecmp (tag->name, "textformat", 10))
+ {
+ if (name_length == 10 && !g_strncasecmp (name, "leftmargin", 10))
+ {
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_leftMargin, &val);
+ }
+ else if (name_length == 11 && !g_strncasecmp (name, "rightmargin", 11))
+ {
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_rightMargin, &val);
+ }
+ else if (name_length == 6 && !g_strncasecmp (name, "indent", 6))
+ {
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_indent, &val);
+ }
+ else if (name_length == 11 && !g_strncasecmp (name, "blockindent", 11))
+ {
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_blockIndent, &val);
+ }
+ else if (name_length == 8 && !g_strncasecmp (name, "tabstops", 8))
+ {
+ // FIXME
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_tabStops, &val);
+ }
+ }
+ else if (tag->name_length == 1 && !g_strncasecmp (tag->name, "p", 1))
+ {
+ if (name_length == 5 && !g_strncasecmp (name, "align", 5))
+ {
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_align, &val);
+ }
+ }
+ else if (tag->name_length == 4 && !g_strncasecmp (tag->name, "font", 4))
+ {
+ if (name_length == 4 && !g_strncasecmp (name, "face", 4))
+ {
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_font, &val);
+ }
+ else if (name_length == 4 && !g_strncasecmp (name, "size", 4))
+ {
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_size, &val);
+ }
+ else if (name_length == 5 && !g_strncasecmp (name, "color", 5))
+ {
+ SwfdecAsValue val_number;
+
+ if (value_length != 7 || *value != '#') {
+ SWFDEC_AS_VALUE_SET_NUMBER (&val_number, 0);
+ } else {
+ int number;
+ char *tail;
+
+ number = g_ascii_strtoll (value + 1, &tail, 16);
+ if (tail != value + 7)
+ number = 0;
+ SWFDEC_AS_VALUE_SET_NUMBER (&val_number, number);
+ }
+
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_color, &val_number);
+ }
+ else if (name_length == 13 && !g_strncasecmp (name, "letterspacing", 13))
+ {
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_letterSpacing,
+ &val);
+ }
+ // special case: Don't parse kerning
+ }
+ else if (tag->name_length == 1 && !g_strncasecmp (tag->name, "a", 1))
+ {
+ if (name_length == 4 && !g_strncasecmp (name, "href", 4))
+ {
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_url, &val);
+ }
+ else if (name_length == 6 && !g_strncasecmp (name, "target", 6))
+ {
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_target, &val);
+ }
+ }
+
+ if (data->style_sheet &&
+ ((tag->name_length == 2 && !g_strncasecmp (tag->name, "li", 2)) ||
+ (tag->name_length == 4 && !g_strncasecmp (tag->name, "span", 4)) ||
+ (tag->name_length == 1 && !g_strncasecmp (tag->name, "p", 1))))
+ {
+ if (name_length == 5 && !g_strncasecmp (name, "class", 5)) {
+ SwfdecTextFormat *format = swfdec_style_sheet_get_class_format (
+ data->style_sheet, swfdec_as_context_give_string (data->cx,
+ g_strndup (value, value_length)));
+ if (format != NULL)
+ swfdec_text_format_add (tag->format, format);
+ }
+ }
+}
+
+static const char *
+swfdec_text_field_movie_html_parse_attribute (ParserData *data, ParserTag *tag,
+ const char *p)
+{
+ const char *end, *name, *value;
+ int name_length, value_length;
+
+ g_return_val_if_fail (data != NULL, NULL);
+ g_return_val_if_fail (tag != NULL, NULL);
+ g_return_val_if_fail ((*p != '>' && *p != '\0'), NULL);
+
+ end = p + strcspn (p, "=> \r\n\t");
+ if (end - p <= 0)
+ return NULL; // Correct?
+
+ name = p;
+ name_length = end - p;
+
+ p = end + strspn (end, " \r\n\t");
+ if (*p != '=')
+ return NULL; // FIXME: Correct?
+ p = p + 1;
+ p = p + strspn (p, " \r\n\t");
+
+ if (*p != '"' && *p != '\'')
+ return NULL; // FIXME: Correct?
+
+ end = p + 1;
+ do {
+ end = strchr (end, *p);
+ } while (end != NULL && *(end - 1) == '\\');
+
+ if (end == NULL)
+ return NULL; // FIXME: Correct?
+
+ value = p + 1;
+ value_length = end - (p + 1);
+
+ if (tag != NULL) {
+ swfdec_text_field_movie_html_tag_set_attribute (data, tag, name,
+ name_length, value, value_length);
+ }
+
+ g_return_val_if_fail (end + 1 > p, NULL);
+
+ return end + 1;
+}
+
+static const char *
+swfdec_text_field_movie_html_parse_tag (ParserData *data, const char *p)
+{
+ ParserTag *tag;
+ const char *name, *end;
+ int name_length;
+ gboolean close;
+
+ g_return_val_if_fail (data != NULL, NULL);
+ g_return_val_if_fail (p != NULL, NULL);
+ g_return_val_if_fail (*p == '<', NULL);
+
+ p++;
+
+ // closing tag or opening tag?
+ if (*p == '/') {
+ close = TRUE;
+ p++;
+ } else {
+ close = FALSE;
+ }
+
+ // find the end of the name
+ end = p + strcspn (p, "> \r\n\t");
+
+ if (*end == '\0')
+ return NULL;
+
+ // don't count trailing / as part of the name if it's followed by >
+ // we still act like it's a normal opening tag even if it has /
+ if (*end == '>' && *(end - 1) == '/')
+ end = end - 1;
+
+ if (end == p) // empty name
+ return NULL;
+
+ name = p;
+ name_length = end - p;
+
+ if (close)
+ {
+ if (data->tags_open != NULL) {
+ tag = data->tags_open->data;
+ if (name_length == tag->name_length &&
+ !g_strncasecmp (name, tag->name, name_length))
+ swfdec_text_field_movie_html_parse_close_tag (data, tag);
+ }
+
+ end = strchr (end, '>');
+ if (end != NULL)
+ end += 1;
+ }
+ else
+ {
+ SwfdecAsObject *object;
+ SwfdecAsValue val;
+
+ if (data->multiline) {
+ if (name_length == 2 && !g_strncasecmp (name, "br", 2))
+ {
+ data->text = g_string_append_c (data->text, '\n');
+ }
+ else if ((name_length == 1 && !g_strncasecmp (name, "p", 1)) ||
+ (name_length == 2 && !g_strncasecmp (name, "li", 2)) ||
+ (name_length == 2 && !g_strncasecmp (name, "br", 2)))
+ {
+ GSList *iter;
+
+ for (iter = data->tags_open; iter != NULL; iter = iter->next) {
+ ParserTag *f = iter->data;
+ if ((f->name_length == 1 && !g_strncasecmp (f->name, "p", 1)) ||
+ (f->name_length == 2 && !g_strncasecmp (f->name, "li", 2))) {
+ data->text = g_string_append_c (data->text, '\n');
+ break;
+ }
+ }
+ }
+ }
+
+ tag = g_new0 (ParserTag, 1);
+ tag->name = name;
+ tag->name_length = name_length;
+ tag->format = SWFDEC_TEXT_FORMAT (swfdec_text_format_new (data->cx));
+ tag->index = data->text->len;
+
+ data->tags_open = g_slist_prepend (data->tags_open, tag);
+
+ // set format based on tag
+ if (tag->format != NULL) {
+ object = SWFDEC_AS_OBJECT (tag->format);
+ SWFDEC_AS_VALUE_SET_BOOLEAN (&val, TRUE);
+
+ if (tag->name_length == 2 && !g_strncasecmp (tag->name, "li", 2)) {
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_bullet, &val);
+ } else if (tag->name_length == 1 && !g_strncasecmp (tag->name, "b", 1)) {
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_bold, &val);
+ } else if (tag->name_length == 1 && !g_strncasecmp (tag->name, "i", 1)) {
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_italic, &val);
+ } else if (tag->name_length == 1 && !g_strncasecmp (tag->name, "u", 1)) {
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_underline, &val);
+ }
+ else if (tag->name_length == 3 && !g_strncasecmp (tag->name, "img", 3))
+ {
+ SWFDEC_FIXME ("IMG tag support for TextField's HTML input missing");
+ }
+ }
+
+ if (data->style_sheet &&
+ ((tag->name_length == 2 && !g_strncasecmp (tag->name, "li", 2)) ||
+ (tag->name_length == 1 && !g_strncasecmp (tag->name, "p", 1)))) {
+ SwfdecTextFormat *format = swfdec_style_sheet_get_tag_format (
+ data->style_sheet, swfdec_as_context_give_string (data->cx,
+ g_strndup (tag->name, tag->name_length)));
+ if (format != NULL)
+ swfdec_text_format_add (tag->format, format);
+ }
+
+ // parse attributes
+ end = end + strspn (end, " \r\n\t");
+ while (*end != '\0' && *end != '>' && (*end != '/' || *(end + 1) != '>')) {
+ end = swfdec_text_field_movie_html_parse_attribute (data, tag, end);
+ if (end == NULL)
+ break;
+ end = end + strspn (end, " \r\n\t");
+ }
+ if (end != NULL) {
+ if (*end == '/')
+ end += 1;
+ if (*end == '>')
+ end += 1;
+ }
+ }
+
+ return end;
+}
+
+static const char *
+swfdec_text_field_movie_html_parse_text (ParserData *data, const char *p)
+{
+ const char *end;
+ char *unescaped;
+
+ g_return_val_if_fail (data != NULL, NULL);
+ g_return_val_if_fail (p != NULL, NULL);
+ g_return_val_if_fail (*p != '\0' && *p != '<', NULL);
+
+ // get the text
+ // if condense_white: all whitespace blocks are converted to a single space
+ while (*p != '\0' && *p != '<') {
+ if (data->condense_white) {
+ end = p + strcspn (p, "< \n\r\t");
+ } else {
+ end = strchr (p, '<');
+ if (end == NULL)
+ end = strchr (p, '\0');
+ }
+
+ unescaped = swfdec_xml_unescape_len (data->cx, p, end - p, TRUE);
+ data->text = g_string_append (data->text, unescaped);
+ g_free (unescaped);
+
+ if (data->condense_white && g_ascii_isspace (*end)) {
+ data->text = g_string_append_c (data->text, ' ');
+ p = end + strspn (end, " \n\r\t");
+ } else {
+ p = end;
+ }
+ }
+
+ return p;
+}
+
+void
+swfdec_text_field_movie_html_parse (SwfdecTextFieldMovie *text, const char *str)
+{
+ ParserData data;
+ const char *p;
+
+ g_return_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text));
+ g_return_if_fail (str != NULL);
+
+ text->input = g_string_assign (text->input, "");
+
+ data.cx = SWFDEC_AS_OBJECT (text)->context;
+ data.multiline = (data.cx->version < 7 || text->text->multiline);
+ data.condense_white = text->condense_white;
+ if (text->style_sheet != NULL && SWFDEC_IS_STYLESHEET (text->style_sheet)) {
+ data.style_sheet = SWFDEC_STYLESHEET (text->style_sheet);
+ } else {
+ data.style_sheet = NULL;
+ }
+ data.text = text->input;
+ data.tags_open = NULL;
+ data.tags_closed = NULL;
+
+ p = str;
+ while (p != NULL && *p != '\0') {
+ if (*p == '<') {
+ if (strncmp (p + 1, "!--", strlen ("!--")) == 0) {
+ p = swfdec_text_field_movie_html_parse_comment (&data, p);
+ } else {
+ p = swfdec_text_field_movie_html_parse_tag (&data, p);
+ }
+ } else {
+ p = swfdec_text_field_movie_html_parse_text (&data, p);
+ }
+ }
+
+ // close remaining tags
+ while (data.tags_open != NULL) {
+ swfdec_text_field_movie_html_parse_close_tag (&data,
+ (ParserTag *)data.tags_open->data);
+ }
+
+ // add parsed styles
+ while (data.tags_closed != NULL) {
+ ParserTag *tag = (ParserTag *)data.tags_closed->data;
+
+ if (tag->index != tag->end_index && tag->format != NULL) {
+ swfdec_text_field_movie_set_text_format (text, tag->format, tag->index,
+ tag->end_index);
+ }
+
+ g_free (tag);
+ data.tags_closed = g_slist_remove (data.tags_closed, tag);
+ }
+}
+
+/*
+ * Generating
+ */
+static const char *
+swfdec_text_field_movie_html_text_align_to_string (SwfdecTextAlign align)
+{
+ switch (align) {
+ case SWFDEC_TEXT_ALIGN_LEFT:
+ return "LEFT";
+ case SWFDEC_TEXT_ALIGN_RIGHT:
+ return "RIGHT";
+ case SWFDEC_TEXT_ALIGN_CENTER:
+ return "CENTER";
+ case SWFDEC_TEXT_ALIGN_JUSTIFY:
+ return "JUSTIFY";
+ default:
+ g_assert_not_reached ();
+ return "";
+ }
+}
+
+/*
+ * Order of tags:
+ * TEXTFORMAT / P or LI / FONT / A / B / I / U
+ *
+ * Order of attributes:
+ * TEXTFORMAT:
+ * LEFTMARGIN / RIGHTMARGIN / INDENT / LEADING / BLOCKINDENT / TABSTOPS
+ * P: ALIGN
+ * LI: none
+ * FONT: FACE / SIZE / COLOR / LETTERSPACING / KERNING
+ * A: HREF / TARGET
+ * B: none
+ * I: none
+ * U: none
+ */
+static GString *
+swfdec_text_field_movie_html_text_append_paragraph (SwfdecTextFieldMovie *text,
+ GString *string, guint start_index, guint end_index)
+{
+ SwfdecTextFormat *format, *format_prev, *format_font;
+ GSList *iter, *fonts, *iter_font;
+ guint index_, index_prev;
+ gboolean textformat, bullet, font = FALSE;
+ char *escaped;
+
+ g_return_val_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text), string);
+ g_return_val_if_fail (string != NULL, string);
+ g_return_val_if_fail (start_index <= end_index, string);
+
+ g_return_val_if_fail (text->formats != NULL, string);
+ for (iter = text->formats; iter->next != NULL &&
+ ((SwfdecFormatIndex *)(iter->next->data))->index_ <= start_index;
+ iter = iter->next);
+
+ index_ = start_index;
+ format = ((SwfdecFormatIndex *)(iter->data))->format;
+
+ if (format->left_margin != 0 || format->right_margin != 0 ||
+ format->indent != 0 || format->leading != 0 ||
+ format->block_indent != 0 ||
+ swfdec_as_array_get_length (format->tab_stops) > 0)
+ {
+ string = g_string_append (string, "<TEXTFORMAT");
+ if (format->left_margin) {
+ g_string_append_printf (string, " LEFTMARGIN=\"%i\"",
+ format->left_margin);
+ }
+ if (format->right_margin) {
+ g_string_append_printf (string, " RIGHTMARGIN=\"%i\"",
+ format->right_margin);
+ }
+ if (format->indent)
+ g_string_append_printf (string, " INDENT=\"%i\"", format->indent);
+ if (format->leading)
+ g_string_append_printf (string, " LEADING=\"%i\"", format->leading);
+ if (format->block_indent) {
+ g_string_append_printf (string, " BLOCKINDENT=\"%i\"",
+ format->block_indent);
+ }
+ if (swfdec_as_array_get_length (format->tab_stops) > 0) {
+ SwfdecAsValue val;
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (format->tab_stops));
+ g_string_append_printf (string, " TABSTOPS=\"%s\"",
+ swfdec_as_value_to_string (SWFDEC_AS_OBJECT
+ (format->tab_stops)->context, &val));
+ }
+ string = g_string_append (string, ">");
+
+ textformat = TRUE;
+ }
+ else
+ {
+ textformat = FALSE;
+ }
+
+ if (format->bullet) {
+ string = g_string_append (string, "<LI>");
+ bullet = TRUE;
+ } else {
+ g_string_append_printf (string, "<P ALIGN=\"%s\">",
+ swfdec_text_field_movie_html_text_align_to_string (format->align));
+ bullet = FALSE;
+ }
+
+ // note we don't escape format->font, even thought it can have evil chars
+ g_string_append_printf (string, "<FONT FACE=\"%s\" SIZE=\"%i\" COLOR=\"#%06X\" LETTERSPACING=\"%i\" KERNING=\"%i\">",
+ format->font, format->size, format->color, (int)format->letter_spacing,
+ (format->kerning ? 1 : 0));
+ fonts = g_slist_prepend (NULL, format);
+
+ if (format->url != SWFDEC_AS_STR_EMPTY)
+ g_string_append_printf (string, "<A HREF=\"%s\" TARGET=\"%s\">",
+ format->url, format->target);
+ if (format->bold)
+ string = g_string_append (string, "<B>");
+ if (format->italic)
+ string = g_string_append (string, "<I>");
+ if (format->underline)
+ string = g_string_append (string, "<U>");
+
+ // special case: use <= instead of < to add some extra markup
+ for (iter = iter->next;
+ iter != NULL && ((SwfdecFormatIndex *)(iter->data))->index_ <= end_index;
+ iter = iter->next)
+ {
+ index_prev = index_;
+ format_prev = format;
+ index_ = ((SwfdecFormatIndex *)(iter->data))->index_;
+ format = ((SwfdecFormatIndex *)(iter->data))->format;
+
+ escaped = swfdec_xml_escape_len (text->input->str + index_prev,
+ index_ - index_prev);
+ string = g_string_append (string, escaped);
+ g_free (escaped);
+ escaped = NULL;
+
+ // Figure out what tags need to be rewritten
+ if (format->font != format_prev->font ||
+ format->size != format_prev->size ||
+ format->color != format_prev->color ||
+ (int)format->letter_spacing != (int)format_prev->letter_spacing ||
+ format->kerning != format_prev->kerning) {
+ font = TRUE;
+ } else if (format->url == format_prev->url &&
+ format->target == format_prev->target &&
+ format->bold == format_prev->bold &&
+ format->italic == format_prev->italic &&
+ format->underline == format_prev->underline) {
+ continue;
+ }
+
+ // Close tags
+ for (iter_font = fonts; iter_font != NULL; iter_font = iter_font->next)
+ {
+ format_font = (SwfdecTextFormat *)iter_font->data;
+ if (format->font == format_font->font &&
+ format->size == format_font->size &&
+ format->color == format_font->color &&
+ (int)format->letter_spacing == (int)format_font->letter_spacing &&
+ format->kerning == format_font->kerning) {
+ break;
+ }
+ }
+ if (format_prev->underline)
+ string = g_string_append (string, "</U>");
+ if (format_prev->italic)
+ string = g_string_append (string, "</I>");
+ if (format_prev->bold)
+ string = g_string_append (string, "</B>");
+ if (format_prev->url != SWFDEC_AS_STR_EMPTY)
+ string = g_string_append (string, "</A>");
+ if (iter_font != NULL) {
+ while (fonts != iter_font) {
+ string = g_string_append (string, "</FONT>");
+ fonts = g_slist_remove (fonts, fonts->data);
+ }
+ }
+
+ // Open tags
+ format_font = (SwfdecTextFormat *)fonts->data;
+ if (font && (format->font != format_font->font ||
+ format->size != format_font->size ||
+ format->color != format_font->color ||
+ (int)format->letter_spacing != (int)format_font->letter_spacing ||
+ format->kerning != format_font->kerning))
+ {
+ fonts = g_slist_prepend (fonts, format);
+
+ string = g_string_append (string, "<FONT");
+ // note we don't escape format->font, even thought it can have evil chars
+ if (format->font != format_font->font)
+ g_string_append_printf (string, " FACE=\"%s\"", format->font);
+ if (format->size != format_font->size)
+ g_string_append_printf (string, " SIZE=\"%i\"", format->size);
+ if (format->color != format_font->color)
+ g_string_append_printf (string, " COLOR=\"#%06X\"", format->color);
+ if ((int)format->letter_spacing != (int)format_font->letter_spacing) {
+ g_string_append_printf (string, " LETTERSPACING=\"%i\"",
+ (int)format->letter_spacing);
+ }
+ if (format->kerning != format_font->kerning) {
+ g_string_append_printf (string, " KERNING=\"%i\"",
+ (format->kerning ? 1 : 0));
+ }
+ string = g_string_append (string, ">");
+ }
+ if (format->url != SWFDEC_AS_STR_EMPTY) {
+ g_string_append_printf (string, "<A HREF=\"%s\" TARGET=\"%s\">",
+ format->url, format->target);
+ }
+ if (format->bold)
+ string = g_string_append (string, "<B>");
+ if (format->italic)
+ string = g_string_append (string, "<I>");
+ if (format->underline)
+ string = g_string_append (string, "<U>");
+ }
+
+ escaped = swfdec_xml_escape_len (text->input->str + index_,
+ end_index - index_);
+ string = g_string_append (string, escaped);
+ g_free (escaped);
+
+ if (format->underline)
+ string = g_string_append (string, "</U>");
+ if (format->italic)
+ string = g_string_append (string, "</I>");
+ if (format->bold)
+ string = g_string_append (string, "</B>");
+ if (format->url != SWFDEC_AS_STR_EMPTY)
+ string = g_string_append (string, "</A>");
+ for (iter = fonts; iter != NULL; iter = iter->next)
+ string = g_string_append (string, "</FONT>");
+ g_slist_free (fonts);
+ if (bullet) {
+ string = g_string_append (string, "</LI>");
+ } else {
+ string = g_string_append (string, "</P>");
+ }
+ if (textformat)
+ string = g_string_append (string, "</TEXTFORMAT>");
+
+ return string;
+}
+
+const char *
+swfdec_text_field_movie_get_html_text (SwfdecTextFieldMovie *text)
+{
+ const char *p, *end;
+ GString *string;
+
+ g_return_val_if_fail (SWFDEC_IS_TEXT_FIELD_MOVIE (text),
+ SWFDEC_AS_STR_EMPTY);
+
+ if (text->input == NULL)
+ return SWFDEC_AS_STR_EMPTY;
+
+ string = g_string_new ("");
+
+ p = text->input->str;
+ while (*p != '\0') {
+ end = strpbrk (p, "\r\n");
+ if (end == NULL)
+ end = strchr (p, '\0');
+
+ string = swfdec_text_field_movie_html_text_append_paragraph (text, string,
+ p - text->input->str, end - text->input->str);
+
+ p = end;
+ if (*p != '\0') p++;
+ }
+
+ return swfdec_as_context_give_string (SWFDEC_AS_OBJECT (text)->context,
+ g_string_free (string, FALSE));
+}
diff --git a/swfdec/swfdec_text_format.c b/swfdec/swfdec_text_format.c
new file mode 100644
index 0000000..79e82ee
--- /dev/null
+++ b/swfdec/swfdec_text_format.c
@@ -0,0 +1,1274 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+#include <string.h>
+
+#include "swfdec_text_format.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_as_array.h"
+#include "swfdec_as_object.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_internal.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_player_internal.h"
+
+G_DEFINE_TYPE (SwfdecTextFormat, swfdec_text_format, SWFDEC_TYPE_AS_OBJECT)
+
+typedef enum {
+ PROP_ALIGN = 0,
+ PROP_BLOCK_INDENT,
+ PROP_BOLD,
+ PROP_BULLET,
+ PROP_COLOR,
+ PROP_DISPLAY,
+ PROP_FONT,
+ PROP_INDENT,
+ PROP_ITALIC,
+ PROP_KERNING,
+ PROP_LEADING,
+ PROP_LEFT_MARGIN,
+ PROP_LETTER_SPACING,
+ PROP_RIGHT_MARGIN,
+ PROP_SIZE,
+ PROP_TAB_STOPS,
+ PROP_TARGET,
+ PROP_UNDERLINE,
+ PROP_URL,
+ PROP_TOTAL
+} FormatProp;
+
+static int property_offsets[] = {
+ G_STRUCT_OFFSET (SwfdecTextFormat, align),
+ G_STRUCT_OFFSET (SwfdecTextFormat, block_indent),
+ G_STRUCT_OFFSET (SwfdecTextFormat, bold),
+ G_STRUCT_OFFSET (SwfdecTextFormat, bullet),
+ G_STRUCT_OFFSET (SwfdecTextFormat, color),
+ G_STRUCT_OFFSET (SwfdecTextFormat, display),
+ G_STRUCT_OFFSET (SwfdecTextFormat, font),
+ G_STRUCT_OFFSET (SwfdecTextFormat, indent),
+ G_STRUCT_OFFSET (SwfdecTextFormat, italic),
+ G_STRUCT_OFFSET (SwfdecTextFormat, kerning),
+ G_STRUCT_OFFSET (SwfdecTextFormat, leading),
+ G_STRUCT_OFFSET (SwfdecTextFormat, left_margin),
+ G_STRUCT_OFFSET (SwfdecTextFormat, letter_spacing),
+ G_STRUCT_OFFSET (SwfdecTextFormat, right_margin),
+ G_STRUCT_OFFSET (SwfdecTextFormat, size),
+ G_STRUCT_OFFSET (SwfdecTextFormat, tab_stops),
+ G_STRUCT_OFFSET (SwfdecTextFormat, target),
+ G_STRUCT_OFFSET (SwfdecTextFormat, underline),
+ G_STRUCT_OFFSET (SwfdecTextFormat, url)
+};
+
+static void
+swfdec_text_format_do_mark (SwfdecAsObject *object)
+{
+ SwfdecTextFormat *format = SWFDEC_TEXT_FORMAT (object);
+
+ if (format->font != NULL)
+ swfdec_as_string_mark (format->font);
+ if (format->tab_stops != NULL)
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (format->tab_stops));
+ if (format->target != NULL)
+ swfdec_as_string_mark (format->target);
+ if (format->url != NULL)
+ swfdec_as_string_mark (format->url);
+
+ SWFDEC_AS_OBJECT_CLASS (swfdec_text_format_parent_class)->mark (object);
+}
+
+static void
+swfdec_text_format_class_init (SwfdecTextFormatClass *klass)
+{
+ SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
+
+ asobject_class->mark = swfdec_text_format_do_mark;
+}
+
+static void
+swfdec_text_format_init (SwfdecTextFormat *text_format)
+{
+}
+
+static gboolean
+swfdec_text_format_is_set (const SwfdecTextFormat *format, FormatProp property)
+{
+ return (format->values_set & (1 << property));
+}
+
+static void
+swfdec_text_format_mark_set (SwfdecTextFormat *format,
+ FormatProp property)
+{
+ format->values_set |= (1 << property);
+}
+
+static void
+swfdec_text_format_mark_unset (SwfdecTextFormat *format,
+ FormatProp property)
+{
+ format->values_set &= ~(1 << property);
+}
+
+static void
+swfdec_text_format_get_string (SwfdecAsObject *object,
+ FormatProp property, SwfdecAsValue *ret)
+{
+ SwfdecTextFormat *format;
+
+ if (!SWFDEC_IS_TEXT_FORMAT (object))
+ return;
+ format = SWFDEC_TEXT_FORMAT (object);
+
+ if (!swfdec_text_format_is_set (format, property)) {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ return;
+ }
+
+ SWFDEC_AS_VALUE_SET_STRING (ret,
+ G_STRUCT_MEMBER (const char *, format, property_offsets[property]));
+}
+
+static void
+swfdec_text_format_set_string (SwfdecAsObject *object,
+ FormatProp property, guint argc, SwfdecAsValue *argv)
+{
+ SwfdecTextFormat *format;
+ const char *s;
+
+ if (!SWFDEC_IS_TEXT_FORMAT (object))
+ return;
+ format = SWFDEC_TEXT_FORMAT (object);
+
+ if (argc < 1)
+ return;
+
+ swfdec_as_value_to_integer (object->context, &argv[0]);
+ swfdec_as_value_to_number (object->context, &argv[0]);
+ s = swfdec_as_value_to_string (object->context, &argv[0]);
+
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]) ||
+ SWFDEC_AS_VALUE_IS_NULL (&argv[0])) {
+ G_STRUCT_MEMBER (const char *, format, property_offsets[property]) = NULL;
+ swfdec_text_format_mark_unset (format, property);
+ } else {
+ G_STRUCT_MEMBER (const char *, format, property_offsets[property]) = s;
+ swfdec_text_format_mark_set (format, property);
+ }
+}
+
+static void
+swfdec_text_format_get_boolean (SwfdecAsObject *object,
+ FormatProp property, SwfdecAsValue *ret)
+{
+ SwfdecTextFormat *format;
+
+ if (!SWFDEC_IS_TEXT_FORMAT (object))
+ return;
+ format = SWFDEC_TEXT_FORMAT (object);
+
+ if (!swfdec_text_format_is_set (format, property)) {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ return;
+ }
+
+ if (G_STRUCT_MEMBER (gboolean, format, property_offsets[property])) {
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, TRUE);
+ } else {
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
+ }
+}
+
+static void
+swfdec_text_format_set_boolean (SwfdecAsObject *object,
+ FormatProp property, guint argc, SwfdecAsValue *argv)
+{
+ SwfdecTextFormat *format;
+
+ if (!SWFDEC_IS_TEXT_FORMAT (object))
+ return;
+ format = SWFDEC_TEXT_FORMAT (object);
+
+ if (argc < 1)
+ return;
+
+ swfdec_as_value_to_integer (object->context, &argv[0]);
+ swfdec_as_value_to_number (object->context, &argv[0]);
+ swfdec_as_value_to_string (object->context, &argv[0]);
+
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]) ||
+ SWFDEC_AS_VALUE_IS_NULL (&argv[0])) {
+ swfdec_text_format_mark_unset (format, property);
+ } else {
+ G_STRUCT_MEMBER (gboolean, format, property_offsets[property]) =
+ swfdec_as_value_to_boolean (object->context, &argv[0]);
+ swfdec_text_format_mark_set (format, property);
+ }
+}
+
+static void
+swfdec_text_format_get_integer (SwfdecAsObject *object,
+ FormatProp property, SwfdecAsValue *ret)
+{
+ SwfdecTextFormat *format;
+
+ if (!SWFDEC_IS_TEXT_FORMAT (object))
+ return;
+ format = SWFDEC_TEXT_FORMAT (object);
+
+ if (!swfdec_text_format_is_set (format, property)) {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ return;
+ }
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret,
+ (double)G_STRUCT_MEMBER (int, format, property_offsets[property]));
+}
+
+static int
+swfdec_text_format_value_to_integer (SwfdecAsContext *cx, SwfdecAsValue *val,
+ gboolean allow_negative)
+{
+ double d;
+ int n;
+
+ n = swfdec_as_value_to_integer (cx, val);
+ d = swfdec_as_value_to_number (cx, val);
+ swfdec_as_value_to_string (cx, val);
+
+ if (cx->version >= 8) {
+ if (isnan (d))
+ return (allow_negative ? G_MININT32 : 0);
+
+ if (!isfinite (d)) {
+ if (d > 0) {
+ return G_MININT32;
+ } else {
+ return (allow_negative ? G_MININT32 : 0);
+ }
+ }
+ if (d > (double)G_MAXINT32)
+ return G_MININT32;
+
+ n = (int)d;
+ if (!allow_negative && n < 0) {
+ return 0;
+ } else {
+ return n;
+ }
+ } else {
+ if (!allow_negative && n < 0) {
+ return 0;
+ } else {
+ return n;
+ }
+ }
+}
+
+static void
+swfdec_text_format_set_integer (SwfdecAsObject *object,
+ FormatProp property, guint argc, SwfdecAsValue *argv,
+ gboolean allow_negative)
+{
+ SwfdecTextFormat *format;
+
+ if (!SWFDEC_IS_TEXT_FORMAT (object))
+ return;
+ format = SWFDEC_TEXT_FORMAT (object);
+
+ if (argc < 1)
+ return;
+
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]) ||
+ SWFDEC_AS_VALUE_IS_NULL (&argv[0])) {
+ swfdec_text_format_mark_unset (format, property);
+ } else {
+ G_STRUCT_MEMBER (int, format, property_offsets[property]) =
+ swfdec_text_format_value_to_integer (object->context, &argv[0],
+ allow_negative);
+ swfdec_text_format_mark_set (format, property);
+ }
+}
+
+static void
+swfdec_text_format_do_get_align (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecTextFormat *format;
+
+ if (!SWFDEC_IS_TEXT_FORMAT (object))
+ return;
+ format = SWFDEC_TEXT_FORMAT (object);
+
+ if (!swfdec_text_format_is_set (format, PROP_ALIGN)) {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ return;
+ }
+
+ switch (format->align) {
+ case SWFDEC_TEXT_ALIGN_LEFT:
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_left);
+ break;
+ case SWFDEC_TEXT_ALIGN_RIGHT:
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_right);
+ break;
+ case SWFDEC_TEXT_ALIGN_CENTER:
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_center);
+ break;
+ case SWFDEC_TEXT_ALIGN_JUSTIFY:
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_justify);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+}
+
+static void
+swfdec_text_format_do_set_align (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecTextFormat *format;
+ const char *s;
+
+ if (!SWFDEC_IS_TEXT_FORMAT (object))
+ return;
+ format = SWFDEC_TEXT_FORMAT (object);
+
+ if (argc < 1)
+ return;
+
+ swfdec_as_value_to_integer (cx, &argv[0]);
+ swfdec_as_value_to_number (cx, &argv[0]);
+ s = swfdec_as_value_to_string (cx, &argv[0]);
+
+ if (!g_ascii_strcasecmp (s, "left")) {
+ format->align = SWFDEC_TEXT_ALIGN_LEFT;
+ swfdec_text_format_mark_set (format, PROP_ALIGN);
+ } else if (!g_ascii_strcasecmp (s, "right")) {
+ format->align = SWFDEC_TEXT_ALIGN_RIGHT;
+ swfdec_text_format_mark_set (format, PROP_ALIGN);
+ } else if (!g_ascii_strcasecmp (s, "center")) {
+ format->align = SWFDEC_TEXT_ALIGN_CENTER;
+ swfdec_text_format_mark_set (format, PROP_ALIGN);
+ } else if (!g_ascii_strcasecmp (s, "justify")) {
+ format->align = SWFDEC_TEXT_ALIGN_JUSTIFY;
+ swfdec_text_format_mark_set (format, PROP_ALIGN);
+ }
+}
+
+static void
+swfdec_text_format_do_get_block_indent (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ swfdec_text_format_get_integer (object, PROP_BLOCK_INDENT, ret);
+}
+
+static void
+swfdec_text_format_do_set_block_indent (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ swfdec_text_format_set_integer (object, PROP_BLOCK_INDENT, argc, argv,
+ cx->version >= 8);
+}
+
+static void
+swfdec_text_format_do_get_bold (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_get_boolean (object, PROP_BOLD, ret);
+}
+
+static void
+swfdec_text_format_do_set_bold (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_set_boolean (object, PROP_BOLD, argc, argv);
+}
+
+static void
+swfdec_text_format_do_get_bullet (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_get_boolean (object, PROP_BULLET, ret);
+}
+
+static void
+swfdec_text_format_do_set_bullet (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_set_boolean (object, PROP_BULLET, argc, argv);
+}
+
+static void
+swfdec_text_format_do_get_color (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecTextFormat *format;
+
+ if (!SWFDEC_IS_TEXT_FORMAT (object))
+ return;
+ format = SWFDEC_TEXT_FORMAT (object);
+
+ if (!swfdec_text_format_is_set (format, PROP_COLOR)) {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ return;
+ }
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, format->color);
+}
+
+static void
+swfdec_text_format_do_set_color (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecTextFormat *format;
+
+ if (!SWFDEC_IS_TEXT_FORMAT (object))
+ return;
+ format = SWFDEC_TEXT_FORMAT (object);
+
+ if (argc < 1)
+ return;
+
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]) ||
+ SWFDEC_AS_VALUE_IS_NULL (&argv[0])) {
+ swfdec_text_format_mark_unset (format, PROP_COLOR);
+ } else {
+ format->color = (unsigned) swfdec_as_value_to_integer (cx, &argv[0]);
+ swfdec_as_value_to_integer (cx, &argv[0]);
+ swfdec_as_value_to_string (cx, &argv[0]);
+
+ swfdec_text_format_mark_set (format, PROP_COLOR);
+ }
+}
+
+static void
+swfdec_text_format_do_get_display (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecTextFormat *format;
+
+ if (!SWFDEC_IS_TEXT_FORMAT (object))
+ return;
+ format = SWFDEC_TEXT_FORMAT (object);
+
+ if (!swfdec_text_format_is_set (format, PROP_DISPLAY))
+ {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ return;
+ }
+
+ switch (format->display) {
+ case SWFDEC_TEXT_DISPLAY_NONE:
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_none);
+ break;
+ case SWFDEC_TEXT_DISPLAY_INLINE:
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_inline);
+ break;
+ case SWFDEC_TEXT_DISPLAY_BLOCK:
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_block);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+}
+
+static void
+swfdec_text_format_do_set_display (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecTextFormat *format;
+ const char *s;
+
+ if (!SWFDEC_IS_TEXT_FORMAT (object))
+ return;
+ format = SWFDEC_TEXT_FORMAT (object);
+
+ swfdec_as_value_to_integer (cx, &argv[0]);
+ swfdec_as_value_to_number (cx, &argv[0]);
+ swfdec_as_value_to_string (cx, &argv[0]);
+ s = swfdec_as_value_to_string (cx, &argv[0]); // oh yes, let's call it twice
+
+ if (!g_ascii_strcasecmp (s, "none")) {
+ format->display = SWFDEC_TEXT_DISPLAY_NONE;
+ } else if (!g_ascii_strcasecmp (s, "inline")) {
+ format->display = SWFDEC_TEXT_DISPLAY_INLINE;
+ } else {
+ format->display = SWFDEC_TEXT_DISPLAY_BLOCK;
+ }
+
+ swfdec_text_format_mark_set (format, PROP_DISPLAY);
+}
+
+static void
+swfdec_text_format_do_get_font (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_get_string (object, PROP_FONT, ret);
+}
+
+static void
+swfdec_text_format_do_set_font (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_set_string (object, PROP_FONT, argc, argv);
+}
+
+static void
+swfdec_text_format_do_get_indent (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_get_integer (object, PROP_INDENT, ret);
+}
+
+static void
+swfdec_text_format_do_set_indent (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_set_integer (object, PROP_INDENT, argc, argv,
+ cx->version >= 8);
+}
+
+static void
+swfdec_text_format_do_get_italic (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_get_boolean (object, PROP_ITALIC, ret);
+}
+
+static void
+swfdec_text_format_do_set_italic (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_set_boolean (object, PROP_ITALIC, argc, argv);
+}
+
+static void
+swfdec_text_format_do_get_kerning (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_get_boolean (object, PROP_KERNING, ret);
+}
+
+static void
+swfdec_text_format_do_set_kerning (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_set_boolean (object, PROP_KERNING, argc, argv);
+}
+
+static void
+swfdec_text_format_do_get_leading (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_get_integer (object, PROP_LEADING, ret);
+}
+
+static void
+swfdec_text_format_do_set_leading (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_set_integer (object, PROP_LEADING, argc, argv,
+ cx->version >= 8);
+}
+
+static void
+swfdec_text_format_do_get_left_margin (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ swfdec_text_format_get_integer (object, PROP_LEFT_MARGIN, ret);
+}
+
+static void
+swfdec_text_format_do_set_left_margin (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ swfdec_text_format_set_integer (object, PROP_LEFT_MARGIN, argc, argv, FALSE);
+}
+
+static void
+swfdec_text_format_do_get_letter_spacing (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFormat *format;
+
+ if (!SWFDEC_IS_TEXT_FORMAT (object))
+ return;
+ format = SWFDEC_TEXT_FORMAT (object);
+
+ if (!swfdec_text_format_is_set (format, PROP_LETTER_SPACING)) {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ return;
+ }
+
+ SWFDEC_AS_VALUE_SET_NUMBER (ret, format->letter_spacing);
+}
+
+static void
+swfdec_text_format_do_set_letter_spacing (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFormat *format;
+ double d;
+
+ if (!SWFDEC_IS_TEXT_FORMAT (object))
+ return;
+ format = SWFDEC_TEXT_FORMAT (object);
+
+ if (argc < 1)
+ return;
+
+ swfdec_as_value_to_integer (cx, &argv[0]);
+ d = swfdec_as_value_to_number (cx, &argv[0]);
+ swfdec_as_value_to_string (cx, &argv[0]);
+
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]) ||
+ SWFDEC_AS_VALUE_IS_NULL (&argv[0]))
+ {
+ swfdec_text_format_mark_unset (format,
+ PROP_LETTER_SPACING);
+ }
+ else
+ {
+ format->letter_spacing = d;
+ swfdec_text_format_mark_set (format,
+ PROP_LETTER_SPACING);
+ }
+}
+
+static void
+swfdec_text_format_do_get_right_margin (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ swfdec_text_format_get_integer (object, PROP_RIGHT_MARGIN, ret);
+}
+
+static void
+swfdec_text_format_do_set_right_margin (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ swfdec_text_format_set_integer (object, PROP_RIGHT_MARGIN, argc, argv,
+ FALSE);
+}
+
+static void
+swfdec_text_format_do_get_size (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_get_integer (object, PROP_SIZE, ret);
+}
+
+static void
+swfdec_text_format_do_set_size (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_set_integer (object, PROP_SIZE, argc, argv, TRUE);
+}
+
+static void
+swfdec_text_format_do_get_tab_stops (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFormat *format;
+
+ if (!SWFDEC_IS_TEXT_FORMAT (object))
+ return;
+ format = SWFDEC_TEXT_FORMAT (object);
+
+ if (!swfdec_text_format_is_set (format, PROP_TAB_STOPS)) {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ return;
+ }
+
+ g_return_if_fail (SWFDEC_IS_AS_OBJECT (format->tab_stops));
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (format->tab_stops));
+}
+
+static void
+swfdec_text_format_do_set_tab_stops (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SwfdecTextFormat *format;
+
+ if (!SWFDEC_IS_TEXT_FORMAT (object))
+ return;
+ format = SWFDEC_TEXT_FORMAT (object);
+
+ if (argc < 1)
+ return;
+
+ swfdec_as_value_to_integer (cx, &argv[0]);
+ swfdec_as_value_to_number (cx, &argv[0]);
+ swfdec_as_value_to_string (cx, &argv[0]);
+
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]) ||
+ SWFDEC_AS_VALUE_IS_NULL (&argv[0]))
+ {
+ format->tab_stops = NULL;
+ swfdec_text_format_mark_unset (format, PROP_TAB_STOPS);
+ }
+ else if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]) &&
+ SWFDEC_IS_AS_ARRAY (SWFDEC_AS_VALUE_GET_OBJECT (&argv[0])))
+ {
+ SwfdecAsArray *array;
+ SwfdecAsValue val;
+ gint32 len, i;
+ int n;
+
+ array = SWFDEC_AS_ARRAY (SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]));
+ len = swfdec_as_array_get_length (array);
+
+ if (!swfdec_text_format_is_set (format, PROP_TAB_STOPS)) {
+ // special case, if we have null and array is empty, keep it at null
+ if (len == 0)
+ return;
+ format->tab_stops = SWFDEC_AS_ARRAY (swfdec_as_array_new (cx));
+ if (!format->tab_stops)
+ return;
+ swfdec_text_format_mark_set (format, PROP_TAB_STOPS);
+ }
+
+ swfdec_as_array_set_length (format->tab_stops, 0);
+ for (i = 0; i < len; i++) {
+ swfdec_as_array_get_value (array, i, &val);
+ n = swfdec_text_format_value_to_integer (cx, &val, TRUE);
+ SWFDEC_AS_VALUE_SET_INT (&val, n);
+ swfdec_as_array_set_value (format->tab_stops, i, &val);
+ }
+ }
+ else if (SWFDEC_AS_VALUE_IS_STRING (&argv[0]))
+ {
+ gsize i, len;
+ SwfdecAsValue val;
+
+ len = strlen (SWFDEC_AS_VALUE_GET_STRING (&argv[0]));
+
+ // special case: empty strings mean null
+ if (len == 0) {
+ format->tab_stops = NULL;
+ swfdec_text_format_mark_unset (format,
+ PROP_TAB_STOPS);
+ } else {
+ format->tab_stops = SWFDEC_AS_ARRAY (swfdec_as_array_new (cx));
+ if (format->tab_stops != NULL) {
+ swfdec_text_format_mark_set (format, PROP_TAB_STOPS);
+ if (cx->version >= 8) {
+ SWFDEC_AS_VALUE_SET_INT (&val, -2147483648);
+ } else {
+ SWFDEC_AS_VALUE_SET_INT (&val, 0);
+ }
+ for (i = 0; i < len; i++) {
+ swfdec_as_array_push (format->tab_stops, &val);
+ }
+ } else {
+ swfdec_text_format_mark_unset (format, PROP_TAB_STOPS);
+ }
+ }
+ }
+ else if (swfdec_text_format_is_set (format, PROP_TAB_STOPS))
+ {
+ swfdec_as_array_set_length (format->tab_stops, 0);
+ swfdec_text_format_mark_set (format, PROP_TAB_STOPS);
+ }
+}
+
+static void
+swfdec_text_format_do_get_target (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_get_string (object, PROP_TARGET, ret);
+}
+
+static void
+swfdec_text_format_do_set_target (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_set_string (object, PROP_TARGET, argc, argv);
+}
+
+static void
+swfdec_text_format_do_get_underline (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ swfdec_text_format_get_boolean (object, PROP_UNDERLINE, ret);
+}
+
+static void
+swfdec_text_format_do_set_underline (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ swfdec_text_format_set_boolean (object, PROP_UNDERLINE, argc, argv);
+}
+
+static void
+swfdec_text_format_do_get_url (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_get_string (object, PROP_URL, ret);
+}
+
+static void
+swfdec_text_format_do_set_url (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ swfdec_text_format_set_string (object, PROP_URL, argc, argv);
+}
+
+static void
+swfdec_text_format_getTextExtent (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextFormat.getTextExtent");
+}
+
+void
+swfdec_text_format_add (SwfdecTextFormat *format, const SwfdecTextFormat *from)
+{
+ g_return_if_fail (SWFDEC_IS_TEXT_FORMAT (format));
+ g_return_if_fail (SWFDEC_IS_TEXT_FORMAT (from));
+
+ if (swfdec_text_format_is_set (from, PROP_ALIGN))
+ format->align = from->align;
+ if (swfdec_text_format_is_set (from, PROP_BLOCK_INDENT))
+ format->block_indent = from->block_indent;
+ if (swfdec_text_format_is_set (from, PROP_BOLD))
+ format->bold = from->bold;
+ if (swfdec_text_format_is_set (from, PROP_BULLET))
+ format->bullet = from->bullet;
+ if (swfdec_text_format_is_set (from, PROP_COLOR))
+ format->color = from->color;
+ if (swfdec_text_format_is_set (from, PROP_DISPLAY))
+ format->display = from->display;
+ if (swfdec_text_format_is_set (from, PROP_FONT))
+ format->font = from->font;
+ if (swfdec_text_format_is_set (from, PROP_INDENT))
+ format->indent = from->indent;
+ if (swfdec_text_format_is_set (from, PROP_ITALIC))
+ format->italic = from->italic ;
+ if (swfdec_text_format_is_set (from, PROP_KERNING))
+ format->kerning = from->kerning;
+ if (swfdec_text_format_is_set (from, PROP_LEADING))
+ format->leading = from->leading;
+ if (swfdec_text_format_is_set (from, PROP_LEFT_MARGIN))
+ format->left_margin = from->left_margin;
+ if (swfdec_text_format_is_set (from, PROP_LETTER_SPACING))
+ format->letter_spacing = from->letter_spacing;
+ if (swfdec_text_format_is_set (from, PROP_RIGHT_MARGIN))
+ format->right_margin = from->right_margin;
+ if (swfdec_text_format_is_set (from, PROP_SIZE))
+ format->size = from->size;
+ if (swfdec_text_format_is_set (from, PROP_TAB_STOPS))
+ format->tab_stops = from->tab_stops;
+ if (swfdec_text_format_is_set (from, PROP_TARGET))
+ format->target = from->target;
+ if (swfdec_text_format_is_set (from, PROP_UNDERLINE))
+ format->underline = from->underline;
+ if (swfdec_text_format_is_set (from, PROP_URL))
+ format->url = from->url;
+
+ format->values_set |= from->values_set;
+}
+
+void
+swfdec_text_format_remove_different (SwfdecTextFormat *format,
+ const SwfdecTextFormat *from)
+{
+ int set;
+
+ g_return_if_fail (SWFDEC_IS_TEXT_FORMAT (format));
+ g_return_if_fail (SWFDEC_IS_TEXT_FORMAT (from));
+
+ set = format->values_set & from->values_set;
+
+ if (set & (1 << PROP_ALIGN) && format->align != from->align)
+ set &= ~(1 << PROP_ALIGN);
+ if (set & (1 << PROP_BLOCK_INDENT) &&
+ format->block_indent != from->block_indent) {
+ set &= ~(1 << PROP_BLOCK_INDENT);
+ }
+ if (set & (1 << PROP_BOLD) && format->bold != from->bold)
+ set &= ~(1 << PROP_BOLD);
+ if (set & (1 << PROP_BULLET) && format->bullet != from->bullet)
+ set &= ~(1 << PROP_BULLET);
+ if (set & (1 << PROP_COLOR) && format->color != from->color)
+ set &= ~(1 << PROP_COLOR);
+ if (set & (1 << PROP_DISPLAY) && format->display != from->display)
+ set &= ~(1 << PROP_DISPLAY);
+ if (set & (1 << PROP_FONT) && format->font != from->font)
+ set &= ~(1 << PROP_FONT);
+ if (set & (1 << PROP_INDENT) && format->indent != from->indent)
+ set &= ~(1 << PROP_INDENT);
+ if (set & (1 << PROP_ITALIC) && format->italic != from->italic)
+ set &= ~(1 << PROP_ITALIC);
+ if (set & (1 << PROP_KERNING) && format->kerning != from->kerning)
+ set &= ~(1 << PROP_KERNING);
+ if (set & (1 << PROP_LEADING) && format->leading != from->leading)
+ set &= ~(1 << PROP_LEADING);
+ if (set & (1 << PROP_LEFT_MARGIN) &&
+ format->left_margin != from->left_margin) {
+ set &= ~(1 << PROP_LEFT_MARGIN);
+ }
+ if (set & (1 << PROP_LETTER_SPACING) &&
+ format->letter_spacing != from->letter_spacing) {
+ set &= ~(1 << PROP_LETTER_SPACING);
+ }
+ if (set & (1 << PROP_RIGHT_MARGIN) &&
+ format->right_margin != from->right_margin) {
+ set &= ~(1 << PROP_RIGHT_MARGIN);
+ }
+ if (set & (1 << PROP_SIZE) && format->size != from->size)
+ set &= ~(1 << PROP_SIZE);
+ if (set & (1 << PROP_TAB_STOPS) && format->tab_stops != from->tab_stops)
+ set &= ~(1 << PROP_TAB_STOPS);
+ if (set & (1 << PROP_TARGET) && format->target != from->target)
+ set &= ~(1 << PROP_TARGET);
+ if (set & (1 << PROP_UNDERLINE) && format->underline != from->underline)
+ set &= ~(1 << PROP_UNDERLINE);
+ if (set & (1 << PROP_URL) && format->url != from->url)
+ set &= ~(1 << PROP_URL);
+
+ format->values_set = set;
+}
+
+gboolean
+swfdec_text_format_equal_or_undefined (const SwfdecTextFormat *a,
+ const SwfdecTextFormat *b)
+{
+ int set;
+
+ set = a->values_set & b->values_set;
+
+ g_return_val_if_fail (SWFDEC_IS_TEXT_FORMAT (a), FALSE);
+ g_return_val_if_fail (SWFDEC_IS_TEXT_FORMAT (b), FALSE);
+
+ if (set & (1 << PROP_ALIGN) && a->align != b->align)
+ return FALSE;
+ if (set & (1 << PROP_BLOCK_INDENT) && a->block_indent != b->block_indent)
+ return FALSE;
+ if (set & (1 << PROP_BOLD) && a->bold != b->bold)
+ return FALSE;
+ if (set & (1 << PROP_BULLET) && a->bullet != b->bullet)
+ return FALSE;
+ if (set & (1 << PROP_COLOR) && a->color != b->color)
+ return FALSE;
+ if (set & (1 << PROP_DISPLAY) && a->display != b->display)
+ return FALSE;
+ if (set & (1 << PROP_FONT) && a->font != b->font)
+ return FALSE;
+ if (set & (1 << PROP_INDENT) && a->indent != b->indent)
+ return FALSE;
+ if (set & (1 << PROP_ITALIC) && a->italic != b->italic)
+ return FALSE;
+ if (set & (1 << PROP_KERNING) && a->kerning != b->kerning)
+ return FALSE;
+ if (set & (1 << PROP_LEADING) && a->leading != b->leading)
+ return FALSE;
+ if (set & (1 << PROP_LEFT_MARGIN) && a->left_margin != b->left_margin)
+ return FALSE;
+ if (set & (1 << PROP_LETTER_SPACING) &&
+ a->letter_spacing != b->letter_spacing) {
+ return FALSE;
+ }
+ if (set & (1 << PROP_RIGHT_MARGIN) && a->right_margin != b->right_margin)
+ return FALSE;
+ if (set & (1 << PROP_SIZE) && a->size != b->size)
+ return FALSE;
+ if (set & (1 << PROP_TAB_STOPS) && a->tab_stops != b->tab_stops)
+ return FALSE;
+ if (set & (1 << PROP_TARGET) && a->target != b->target)
+ return FALSE;
+ if (set & (1 << PROP_UNDERLINE) && a->underline != b->underline)
+ return FALSE;
+ if (set & (1 << PROP_URL) && a->url != b->url)
+ return FALSE;
+
+ return TRUE;
+}
+
+gboolean
+swfdec_text_format_equal (const SwfdecTextFormat *a, const SwfdecTextFormat *b)
+{
+ g_return_val_if_fail (SWFDEC_IS_TEXT_FORMAT (a), FALSE);
+ g_return_val_if_fail (SWFDEC_IS_TEXT_FORMAT (b), FALSE);
+
+ if (a->values_set != b->values_set)
+ return FALSE;
+
+ return swfdec_text_format_equal_or_undefined (a, b);
+}
+
+void
+swfdec_text_format_set_defaults (SwfdecTextFormat *format)
+{
+ format->align = SWFDEC_TEXT_ALIGN_LEFT;
+ format->block_indent = 0;
+ format->bold = FALSE;
+ format->bullet = FALSE;
+ format->color = 0;
+ format->display = SWFDEC_TEXT_DISPLAY_BLOCK;
+ format->font = SWFDEC_AS_STR_Times_New_Roman;
+ format->indent = 0;
+ format->italic = FALSE;
+ format->kerning = FALSE;
+ format->leading = 0;
+ format->left_margin = 0;
+ format->letter_spacing = 0;
+ format->right_margin = 0;
+ format->size = 12;
+ format->tab_stops =
+ SWFDEC_AS_ARRAY (swfdec_as_array_new (SWFDEC_AS_OBJECT (format)->context));
+ format->target = SWFDEC_AS_STR_EMPTY;
+ format->url = SWFDEC_AS_STR_EMPTY;
+ format->underline = FALSE;
+
+ format->values_set = (1 << PROP_TOTAL) - 1;
+
+ if (SWFDEC_AS_OBJECT (format)->context->version < 8) {
+ swfdec_text_format_mark_unset (format, PROP_KERNING);
+ swfdec_text_format_mark_unset (format, PROP_LETTER_SPACING);
+ }
+}
+
+static void
+swfdec_text_format_clear (SwfdecTextFormat *format)
+{
+ format->font = NULL;
+ format->target = NULL;
+ format->tab_stops = NULL;
+ format->url = NULL;
+ format->values_set = 0;
+
+ format->display = SWFDEC_TEXT_DISPLAY_BLOCK;
+ swfdec_text_format_mark_set (format, PROP_DISPLAY);
+}
+
+void
+swfdec_text_format_init_properties (SwfdecAsContext *cx)
+{
+ SwfdecAsValue val;
+ SwfdecAsObject *proto;
+
+ // FIXME: We should only initialize if the prototype Object has not been
+ // initialized by any object's constructor with native properties
+ // (TextField, TextFormat, XML, XMLNode at least)
+
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (cx));
+
+ swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_TextFormat, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return;
+ proto = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+ swfdec_as_object_get_variable (proto, SWFDEC_AS_STR_prototype, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return;
+ proto = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_align,
+ swfdec_text_format_do_get_align, swfdec_text_format_do_set_align);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_blockIndent,
+ swfdec_text_format_do_get_block_indent,
+ swfdec_text_format_do_set_block_indent);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_bold,
+ swfdec_text_format_do_get_bold, swfdec_text_format_do_set_bold);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_bullet,
+ swfdec_text_format_do_get_bullet, swfdec_text_format_do_set_bullet);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_color,
+ swfdec_text_format_do_get_color, swfdec_text_format_do_set_color);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_display,
+ swfdec_text_format_do_get_display, swfdec_text_format_do_set_display);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_font,
+ swfdec_text_format_do_get_font, swfdec_text_format_do_set_font);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_indent,
+ swfdec_text_format_do_get_indent, swfdec_text_format_do_set_indent);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_italic,
+ swfdec_text_format_do_get_italic, swfdec_text_format_do_set_italic);
+ if (cx->version >= 8) {
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_kerning,
+ swfdec_text_format_do_get_kerning, swfdec_text_format_do_set_kerning);
+ }
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_leading,
+ swfdec_text_format_do_get_leading, swfdec_text_format_do_set_leading);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_leftMargin,
+ swfdec_text_format_do_get_left_margin,
+ swfdec_text_format_do_set_left_margin);
+ if (cx->version >= 8) {
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_letterSpacing,
+ swfdec_text_format_do_get_letter_spacing,
+ swfdec_text_format_do_set_letter_spacing);
+ }
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_rightMargin,
+ swfdec_text_format_do_get_right_margin,
+ swfdec_text_format_do_set_right_margin);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_size,
+ swfdec_text_format_do_get_size, swfdec_text_format_do_set_size);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_tabStops,
+ swfdec_text_format_do_get_tab_stops,
+ swfdec_text_format_do_set_tab_stops);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_target,
+ swfdec_text_format_do_get_target, swfdec_text_format_do_set_target);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_underline,
+ swfdec_text_format_do_get_underline,
+ swfdec_text_format_do_set_underline);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_url,
+ swfdec_text_format_do_get_url, swfdec_text_format_do_set_url);
+}
+
+SWFDEC_AS_CONSTRUCTOR (110, 0, swfdec_text_format_construct, swfdec_text_format_get_type)
+void
+swfdec_text_format_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ static const char *arguments[] = {
+ SWFDEC_AS_STR_font,
+ SWFDEC_AS_STR_size,
+ SWFDEC_AS_STR_color,
+ SWFDEC_AS_STR_bold,
+ SWFDEC_AS_STR_italic,
+ SWFDEC_AS_STR_underline,
+ SWFDEC_AS_STR_url,
+ SWFDEC_AS_STR_target,
+ SWFDEC_AS_STR_align,
+ SWFDEC_AS_STR_leftMargin,
+ SWFDEC_AS_STR_rightMargin,
+ SWFDEC_AS_STR_indent,
+ SWFDEC_AS_STR_leading,
+ NULL
+ };
+ SwfdecAsFunction *function;
+ SwfdecAsObject *tmp;
+ SwfdecAsValue val;
+ guint i;
+
+ if (!swfdec_as_context_is_constructing (cx)) {
+ SWFDEC_FIXME ("What do we do if not constructing?");
+ return;
+ }
+
+ g_assert (SWFDEC_IS_TEXT_FORMAT (object));
+
+ swfdec_text_format_init_properties (cx);
+
+ swfdec_text_format_clear (SWFDEC_TEXT_FORMAT (object));
+
+ // FIXME: Need better way to create function without prototype/constructor
+ tmp = cx->Function;
+ cx->Function = NULL;
+ function = swfdec_as_native_function_new (cx, SWFDEC_AS_STR_getTextExtent,
+ swfdec_text_format_getTextExtent, 0, NULL);
+ cx->Function = tmp;
+ if (function != NULL) {
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (function));
+ swfdec_as_object_set_variable (object, SWFDEC_AS_STR_getTextExtent, &val);
+ }
+
+ for (i = 0; i < argc && arguments[i] != NULL; i++) {
+ swfdec_as_object_set_variable (object, arguments[i], &argv[i]);
+ }
+}
+
+SwfdecTextFormat *
+swfdec_text_format_copy (const SwfdecTextFormat *copy_from)
+{
+ SwfdecAsObject *object_to;
+ SwfdecTextFormat *copy_to;
+
+ g_return_val_if_fail (SWFDEC_IS_TEXT_FORMAT (copy_from), NULL);
+
+ object_to = swfdec_text_format_new_no_properties (
+ SWFDEC_AS_OBJECT (copy_from)->context);
+ if (object_to == NULL)
+ return NULL;
+ copy_to = SWFDEC_TEXT_FORMAT (object_to);
+
+ copy_to->align = copy_from->align;
+ copy_to->block_indent = copy_from->block_indent;
+ copy_to->bold = copy_from->bold;
+ copy_to->bullet = copy_from->bullet;
+ copy_to->color = copy_from->color;
+ copy_to->display = copy_from->display;
+ copy_to->font = copy_from->font;
+ copy_to->indent = copy_from->indent;
+ copy_to->italic = copy_from->italic ;
+ copy_to->kerning = copy_from->kerning;
+ copy_to->leading = copy_from->leading;
+ copy_to->left_margin = copy_from->left_margin;
+ copy_to->letter_spacing = copy_from->letter_spacing;
+ copy_to->right_margin = copy_from->right_margin;
+ copy_to->size = copy_from->size;
+ copy_to->tab_stops = copy_from->tab_stops;
+ copy_to->target = copy_from->target;
+ copy_to->underline = copy_from->underline;
+ copy_to->url = copy_from->url;
+ copy_to->values_set = copy_from->values_set;
+
+ return copy_to;
+}
+
+SwfdecAsObject *
+swfdec_text_format_new_no_properties (SwfdecAsContext *context)
+{
+ SwfdecAsObject *ret;
+ SwfdecAsValue val;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
+
+ if (!swfdec_as_context_use_mem (context, sizeof (SwfdecTextFormat)))
+ return NULL;
+
+ ret = g_object_new (SWFDEC_TYPE_TEXT_FORMAT, NULL);
+ swfdec_as_object_add (ret, context, sizeof (SwfdecTextFormat));
+
+ swfdec_text_format_clear (SWFDEC_TEXT_FORMAT (ret));
+
+ swfdec_as_object_get_variable (context->global, SWFDEC_AS_STR_TextFormat,
+ &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return ret;
+ swfdec_as_object_set_constructor (ret, SWFDEC_AS_VALUE_GET_OBJECT (&val));
+
+ return ret;
+}
+
+SwfdecAsObject *
+swfdec_text_format_new (SwfdecAsContext *context)
+{
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
+
+ swfdec_text_format_init_properties (context);
+
+ return swfdec_text_format_new_no_properties (context);
+}
diff --git a/swfdec/swfdec_text_format.h b/swfdec/swfdec_text_format.h
new file mode 100644
index 0000000..77dddb4
--- /dev/null
+++ b/swfdec/swfdec_text_format.h
@@ -0,0 +1,101 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_TEXT_FORMAT_H_
+#define _SWFDEC_TEXT_FORMAT_H_
+
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_as_array.h>
+#include <libswfdec/swfdec_types.h>
+#include <libswfdec/swfdec_script.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecTextFormat SwfdecTextFormat;
+typedef struct _SwfdecTextFormatClass SwfdecTextFormatClass;
+
+#define SWFDEC_TYPE_TEXT_FORMAT (swfdec_text_format_get_type())
+#define SWFDEC_IS_TEXT_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_TEXT_FORMAT))
+#define SWFDEC_IS_TEXT_FORMAT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_TEXT_FORMAT))
+#define SWFDEC_TEXT_FORMAT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_TEXT_FORMAT, SwfdecTextFormat))
+#define SWFDEC_TEXT_FORMAT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_TEXT_FORMAT, SwfdecTextFormatClass))
+#define SWFDEC_TEXT_FORMAT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_TEXT_FORMAT, SwfdecTextFormatClass))
+
+typedef enum {
+ SWFDEC_TEXT_ALIGN_LEFT,
+ SWFDEC_TEXT_ALIGN_RIGHT,
+ SWFDEC_TEXT_ALIGN_CENTER,
+ SWFDEC_TEXT_ALIGN_JUSTIFY
+} SwfdecTextAlign;
+
+typedef enum {
+ SWFDEC_TEXT_DISPLAY_NONE,
+ SWFDEC_TEXT_DISPLAY_INLINE,
+ SWFDEC_TEXT_DISPLAY_BLOCK,
+} SwfdecTextDisplay;
+
+struct _SwfdecTextFormat {
+ SwfdecAsObject object;
+
+ SwfdecTextAlign align;
+ int block_indent;
+ gboolean bold;
+ gboolean bullet;
+ SwfdecColor color;
+ SwfdecTextDisplay display;
+ const char * font;
+ int indent;
+ gboolean italic;
+ gboolean kerning;
+ int leading;
+ int left_margin;
+ double letter_spacing; // number or null
+ int right_margin;
+ int size;
+ SwfdecAsArray * tab_stops;
+ const char * target;
+ gboolean underline;
+ const char * url;
+
+ int values_set;
+};
+
+struct _SwfdecTextFormatClass {
+ SwfdecAsObjectClass object_class;
+};
+
+GType swfdec_text_format_get_type (void);
+
+SwfdecAsObject * swfdec_text_format_new (SwfdecAsContext * context);
+SwfdecAsObject * swfdec_text_format_new_no_properties (SwfdecAsContext * context);
+void swfdec_text_format_set_defaults (SwfdecTextFormat * format);
+SwfdecTextFormat * swfdec_text_format_copy (const SwfdecTextFormat *copy_from);
+void swfdec_text_format_add (SwfdecTextFormat * format,
+ const SwfdecTextFormat *from);
+gboolean swfdec_text_format_equal (const SwfdecTextFormat *a,
+ const SwfdecTextFormat *b);
+gboolean swfdec_text_format_equal_or_undefined (const SwfdecTextFormat *a,
+ const SwfdecTextFormat *b);
+void swfdec_text_format_remove_different (SwfdecTextFormat * format,
+ const SwfdecTextFormat * from);
+void swfdec_text_format_init_properties (SwfdecAsContext * cx);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_text_renderer.c b/swfdec/swfdec_text_renderer.c
new file mode 100644
index 0000000..4a709b5
--- /dev/null
+++ b/swfdec/swfdec_text_renderer.c
@@ -0,0 +1,94 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (2150, 1, swfdec_text_renderer_setAdvancedAntialiasingTable)
+void
+swfdec_text_renderer_setAdvancedAntialiasingTable (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextRenderer.setAdvancedAntialiasingTable (static)");
+}
+
+SWFDEC_AS_NATIVE (2150, 2, swfdec_text_renderer_get_antiAliasType)
+void
+swfdec_text_renderer_get_antiAliasType (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextRenderer.antiAliasType (static, get, not-really-named)");
+}
+
+SWFDEC_AS_NATIVE (2150, 3, swfdec_text_renderer_set_antiAliasType)
+void
+swfdec_text_renderer_set_antiAliasType (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextRenderer.antiAliasType (static, set, not-really-named)");
+}
+
+SWFDEC_AS_NATIVE (2150, 4, swfdec_text_renderer_get_maxLevel)
+void
+swfdec_text_renderer_get_maxLevel (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextRenderer.maxLevel (static, get)");
+}
+
+SWFDEC_AS_NATIVE (2150, 5, swfdec_text_renderer_set_maxLevel)
+void
+swfdec_text_renderer_set_maxLevel (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextRenderer.maxLevel (static, set)");
+}
+
+SWFDEC_AS_NATIVE (2150, 10, swfdec_text_renderer_get_displayMode)
+void
+swfdec_text_renderer_get_displayMode (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextRenderer.displayMode (static, get)");
+}
+
+SWFDEC_AS_NATIVE (2150, 11, swfdec_text_renderer_set_displayMode)
+void
+swfdec_text_renderer_set_displayMode (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextRenderer.displayMode (static, set)");
+}
+
+SWFDEC_AS_NATIVE (2150, 0, swfdec_text_renderer_construct)
+void
+swfdec_text_renderer_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextRenderer");
+}
diff --git a/swfdec/swfdec_text_snapshot.c b/swfdec/swfdec_text_snapshot.c
new file mode 100644
index 0000000..4eae6a4
--- /dev/null
+++ b/swfdec/swfdec_text_snapshot.c
@@ -0,0 +1,109 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+SWFDEC_AS_NATIVE (1067, 1, swfdec_text_snapshot_getCount)
+void
+swfdec_text_snapshot_getCount (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextSnapshot.getCount");
+}
+
+SWFDEC_AS_NATIVE (1067, 2, swfdec_text_snapshot_setSelected)
+void
+swfdec_text_snapshot_setSelected (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextSnapshot.setSelected");
+}
+
+SWFDEC_AS_NATIVE (1067, 3, swfdec_text_snapshot_getSelected)
+void
+swfdec_text_snapshot_getSelected (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextSnapshot.getSelected");
+}
+
+SWFDEC_AS_NATIVE (1067, 4, swfdec_text_snapshot_getText)
+void
+swfdec_text_snapshot_getText (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextSnapshot.getText");
+}
+
+SWFDEC_AS_NATIVE (1067, 5, swfdec_text_snapshot_getSelectedText)
+void
+swfdec_text_snapshot_getSelectedText (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextSnapshot.getSelectedText");
+}
+
+SWFDEC_AS_NATIVE (1067, 6, swfdec_text_snapshot_hitTestTextNearPos)
+void
+swfdec_text_snapshot_hitTestTextNearPos (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextSnapshot.hitTestTextNearPos");
+}
+
+SWFDEC_AS_NATIVE (1067, 7, swfdec_text_snapshot_findText)
+void
+swfdec_text_snapshot_findText (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextSnapshot.findText");
+}
+
+SWFDEC_AS_NATIVE (1067, 8, swfdec_text_snapshot_setSelectColor)
+void
+swfdec_text_snapshot_setSelectColor (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextSnapshot.setSelectColor");
+}
+
+SWFDEC_AS_NATIVE (1067, 9, swfdec_text_snapshot_getTextRunInfo)
+void
+swfdec_text_snapshot_getTextRunInfo (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextSnapshot.getTextRunInfo");
+}
+
+SWFDEC_AS_NATIVE (1067, 0, swfdec_text_snapshot_construct)
+void
+swfdec_text_snapshot_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("TextSnapshot");
+}
diff --git a/swfdec/swfdec_transform.c b/swfdec/swfdec_transform.c
new file mode 100644
index 0000000..87fa99e
--- /dev/null
+++ b/swfdec/swfdec_transform.c
@@ -0,0 +1,121 @@
+/* Swfdec
+ * Copyright (C) 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_as_internal.h"
+#include "swfdec_debug.h"
+
+// properties
+SWFDEC_AS_NATIVE (1106, 101, swfdec_transform_get_matrix)
+void
+swfdec_transform_get_matrix (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Transform.matrix (get)");
+}
+
+SWFDEC_AS_NATIVE (1106, 102, swfdec_transform_set_matrix)
+void
+swfdec_transform_set_matrix (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Transform.matrix (set)");
+}
+
+SWFDEC_AS_NATIVE (1106, 103, swfdec_transform_get_concatenatedMatrix)
+void
+swfdec_transform_get_concatenatedMatrix (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Transform.concatenatedMatrix (get)");
+}
+
+SWFDEC_AS_NATIVE (1106, 104, swfdec_transform_set_concatenatedMatrix)
+void
+swfdec_transform_set_concatenatedMatrix (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Transform.concatenatedMatrix (set)");
+}
+
+SWFDEC_AS_NATIVE (1106, 105, swfdec_transform_get_colorTransform)
+void
+swfdec_transform_get_colorTransform (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Transform.colorTransform (get)");
+}
+
+SWFDEC_AS_NATIVE (1106, 106, swfdec_transform_set_colorTransform)
+void
+swfdec_transform_set_colorTransform (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Transform.colorTransform (set)");
+}
+
+SWFDEC_AS_NATIVE (1106, 107, swfdec_transform_get_concatenatedColorTransform)
+void
+swfdec_transform_get_concatenatedColorTransform (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Transform.concatenatedColorTransform (get)");
+}
+
+SWFDEC_AS_NATIVE (1106, 108, swfdec_transform_set_concatenatedColorTransform)
+void
+swfdec_transform_set_concatenatedColorTransform (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv,
+ SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Transform.concatenatedColorTransform (set)");
+}
+
+SWFDEC_AS_NATIVE (1106, 109, swfdec_transform_get_pixelBounds)
+void
+swfdec_transform_get_pixelBounds (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Transform.pixelBounds (get)");
+}
+
+SWFDEC_AS_NATIVE (1106, 110, swfdec_transform_set_pixelBounds)
+void
+swfdec_transform_set_pixelBounds (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Transform.pixelBounds (set)");
+}
+
+// constructor
+SWFDEC_AS_NATIVE (1106, 0, swfdec_transform_construct)
+void
+swfdec_transform_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("Transform");
+}
diff --git a/swfdec/swfdec_types.h b/swfdec/swfdec_types.h
new file mode 100644
index 0000000..d484396
--- /dev/null
+++ b/swfdec/swfdec_types.h
@@ -0,0 +1,63 @@
+
+#ifndef _SWFDEC_TYPES_H_
+#define _SWFDEC_TYPES_H_
+
+#include <glib-object.h>
+#include <cairo.h>
+
+/* Pixel value in the same colorspace as cairo - endian-dependant ARGB.
+ * The alpha pixel must be present */
+typedef guint SwfdecColor;
+
+/* audio is 44100Hz, framerate is multiple of 256Hz, FLV timestamps are 1000Hz
+ * This is a multiple of all these numbers, so we can be always accurate
+ */
+#define SWFDEC_TICKS_PER_SECOND G_GUINT64_CONSTANT (44100 * 256 * 10)
+typedef guint64 SwfdecTick;
+#define SWFDEC_MSECS_TO_TICKS(msecs) ((SwfdecTick) (msecs) * (SWFDEC_TICKS_PER_SECOND / 1000))
+#define SWFDEC_TICKS_TO_MSECS(ticks) ((ticks) / (SWFDEC_TICKS_PER_SECOND / 1000))
+#define SWFDEC_SAMPLES_TO_TICKS(msecs) ((SwfdecTick) (msecs) * (SWFDEC_TICKS_PER_SECOND / 44100))
+#define SWFDEC_TICKS_TO_SAMPLES(ticks) ((ticks) / (SWFDEC_TICKS_PER_SECOND / 44100))
+
+#define SWFDEC_TWIPS_SCALE_FACTOR 20
+typedef int SwfdecTwips;
+#define SWFDEC_TWIPS_TO_DOUBLE(t) ((t) * (1.0 / SWFDEC_TWIPS_SCALE_FACTOR))
+#define SWFDEC_DOUBLE_TO_TWIPS(d) ((SwfdecTwips)((d) * SWFDEC_TWIPS_SCALE_FACTOR))
+
+#define SWFDEC_FIXED_SCALE_FACTOR 65536
+typedef int SwfdecFixed;
+#define SWFDEC_FIXED_TO_DOUBLE(f) ((f) * (1.0 / SWFDEC_FIXED_SCALE_FACTOR))
+#define SWFDEC_DOUBLE_TO_FIXED(d) ((SwfdecFixed)((d) * SWFDEC_FIXED_SCALE_FACTOR))
+#define SWFDEC_FIXED_TO_INT(f) ((f) / SWFDEC_FIXED_SCALE_FACTOR)
+#define SWFDEC_INT_TO_FIXED(i) ((i) * SWFDEC_FIXED_SCALE_FACTOR)
+
+typedef struct _SwfdecButton SwfdecButton;
+typedef struct _SwfdecCache SwfdecCache;
+typedef struct _SwfdecCacheHandle SwfdecCacheHandle;
+typedef struct _SwfdecCharacter SwfdecCharacter;
+typedef struct _SwfdecColorTransform SwfdecColorTransform;
+typedef struct _SwfdecDecoder SwfdecDecoder;
+typedef struct _SwfdecDraw SwfdecDraw;
+typedef struct _SwfdecEventList SwfdecEventList;
+typedef struct _SwfdecFilter SwfdecFilter;
+typedef struct _SwfdecFont SwfdecFont;
+typedef struct _SwfdecGraphic SwfdecGraphic;
+typedef struct _SwfdecImage SwfdecImage;
+typedef struct _SwfdecListener SwfdecListener;
+typedef struct _SwfdecMovie SwfdecMovie;
+typedef struct _SwfdecMovieClipLoader SwfdecMovieClipLoader;
+typedef struct _SwfdecShape SwfdecShape;
+typedef struct _SwfdecShapeVec SwfdecShapeVec;
+typedef struct _SwfdecRect SwfdecRect;
+typedef struct _SwfdecResource SwfdecResource;
+typedef struct _SwfdecRootSprite SwfdecRootSprite;
+typedef struct _SwfdecScriptable SwfdecScriptable;
+typedef struct _SwfdecSound SwfdecSound;
+typedef struct _SwfdecSoundChunk SwfdecSoundChunk;
+typedef struct _SwfdecSprite SwfdecSprite;
+typedef struct _SwfdecSpriteFrame SwfdecSpriteFrame;
+typedef struct _SwfdecSpriteMovie SwfdecSpriteMovie;
+typedef struct _SwfdecSwfDecoder SwfdecSwfDecoder;
+typedef struct _SwfdecText SwfdecText;
+
+#endif
diff --git a/swfdec/swfdec_url.c b/swfdec/swfdec_url.c
new file mode 100644
index 0000000..c81b5a2
--- /dev/null
+++ b/swfdec/swfdec_url.c
@@ -0,0 +1,709 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "swfdec_url.h"
+#include "swfdec_debug.h"
+
+/**
+ * SECTION:SwfdecURL
+ * @title: SwfdecURL
+ * @short_description: URL handling in Swfdec
+ *
+ * SwfdecURL is Swfdec's way of handling URLs. You probably don't need to mess
+ * with this type unless you want to write a #SwfdecLoader. In that case you
+ * will want to use swfdec_loader_get_url() to get its url and then use the
+ * functions in this section to access it.
+ *
+ * @see_also: #SwfdecLoader
+ */
+
+/**
+ * SwfdecURL:
+ *
+ * this is the structure used for URLs. It is a boxed type to glib's type system
+ * and it is not reference counted. It is also a static struct in that it cannot
+ * be modified after creation.
+ */
+
+struct _SwfdecURL {
+ char * url; /* the complete url */
+ char * protocol; /* lowercase, http, file, rtmp, ... */
+ char * host; /* lowercase, can be NULL for files */
+ guint port; /* can be 0 */
+ char * path; /* can be NULL for root path */
+ char * query; /* can be NULL */
+};
+
+GType
+swfdec_url_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type)
+ type = g_boxed_type_register_static ("SwfdecURL",
+ (GBoxedCopyFunc) swfdec_url_copy, (GBoxedFreeFunc) swfdec_url_free);
+
+ return type;
+}
+
+static void *
+swfdec_memrchr (const void *s, int c, size_t n)
+{
+ void *cur, *next;
+
+ cur = memchr (s, c, n);
+ if (cur == NULL)
+ return NULL;
+ while ((next = memchr (cur, c, n)))
+ cur = next;
+ return cur;
+}
+
+/**
+ * swfdec_url_new:
+ * @string: a full-qualified URL encoded in UTF-8
+ *
+ * Parses the given string into a URL for use in swfdec.
+ *
+ * Returns: a new #SwfdecURL
+ **/
+SwfdecURL *
+swfdec_url_new (const char *string)
+{
+ SwfdecURL *url;
+ char *s;
+
+ g_return_val_if_fail (string != NULL, NULL);
+
+ /* FIXME: error checking? */
+ SWFDEC_DEBUG ("new url: %s", string);
+ url = g_slice_new0 (SwfdecURL);
+ url->url = g_strdup (string);
+ s = strstr (string, "://");
+ if (s == NULL) {
+ SWFDEC_INFO ("URL %s has no protocol", string);
+ return url;
+ }
+ url->protocol = g_utf8_strdown (string, s - string);
+ string = s + 3;
+ s = strchr (string, '/');
+ if (s == NULL) {
+ url->host = g_ascii_strdown (string, -1);
+ return url;
+ }
+ if (s != string) {
+ char *colon = swfdec_memrchr (string, ':', s - string);
+ if (colon) {
+ url->port = strtoul (colon + 1, &colon, 10);
+ url->host = g_ascii_strdown (string, colon - string);
+ } else {
+ url->host = g_ascii_strdown (string, s - string);
+ }
+ }
+ string = s + 1;
+ s = strchr (string, '?');
+ if (s == NULL) {
+ url->path = *string ? g_strdup (string) : NULL;
+ return url;
+ }
+ url->path = g_strndup (string, s - string);
+ s++;
+ if (*s)
+ url->query = g_strdup (s);
+ return url;
+}
+
+/**
+ * swfdec_url_new_components:
+ * @protocol: protocol to use
+ * @hostname: hostname or IP address or %NULL
+ * @port: port number or 0. Must be 0 if no hostname is given
+ * @path: a path or %NULL
+ * @query: the query string or %NULL
+ *
+ * Creates a new URL from the given components.
+ *
+ * Returns: a new url pointing to the url from the given components
+ **/
+SwfdecURL *
+swfdec_url_new_components (const char *protocol, const char *hostname,
+ guint port, const char *path, const char *query)
+{
+ GString *str;
+ SwfdecURL *url;
+
+ g_return_val_if_fail (protocol != NULL, NULL);
+ g_return_val_if_fail (hostname != NULL || port == 0, NULL);
+ g_return_val_if_fail (port < 65536, NULL);
+
+ url = g_slice_new0 (SwfdecURL);
+ str = g_string_new ("");
+
+ /* protocol */
+ url->protocol = g_ascii_strdown (protocol, -1);
+ g_string_append (str, url->protocol);
+ g_string_append (str, "://");
+
+ /* hostname + port */
+ if (hostname) {
+ url->host = g_ascii_strdown (hostname, -1);
+ url->port = port;
+ g_string_append (str, url->host);
+ if (port) {
+ g_string_append_printf (str, ":%u", port);
+ }
+ }
+ g_string_append (str, "/");
+
+ /* path */
+ if (path) {
+ url->path = g_strdup (path);
+ g_string_append (str, path);
+ }
+
+ /* query string */
+ if (query) {
+ url->query = g_strdup (query);
+ g_string_append (str, "?");
+ g_string_append (str, query);
+ }
+
+ url->url = g_string_free (str, FALSE);
+ return url;
+}
+
+static gboolean
+swfdec_url_path_to_parent_path (char *path)
+{
+ char *last = strrchr (path, '/');
+
+ if (last == NULL)
+ return FALSE;
+
+ if (last[1] == '\0') {
+ last[0] = '\0';
+ return swfdec_url_path_to_parent_path (path);
+ }
+
+ *last = '\0';
+ return TRUE;
+}
+
+/**
+ * swfdec_url_new_parent:
+ * @url: a #SwfdecURL
+ *
+ * Creates a new url that is the parent of @url. If the given @url has no
+ * parent, a copy of itself is returned.
+ *
+ * Returns: a new url pointing to the parent of @url or %NULL on failure.
+ **/
+SwfdecURL *
+swfdec_url_new_parent (const SwfdecURL *url)
+{
+ char *path;
+ SwfdecURL *ret;
+
+ path = g_strdup (url->path);
+ swfdec_url_path_to_parent_path (path);
+ ret = swfdec_url_new_components (url->protocol, url->host, url->port,
+ path, NULL);
+ g_free (path);
+ return ret;
+}
+
+/**
+ * swfdec_url_new_relative:
+ * @url: a #SwfdecURL
+ * @string: a relative or absolute URL path
+ *
+ * Parses @string into a new URL. If the given @string is a relative URL, it
+ * uses @url to resolve it to an absolute url; @url must already contain a
+ * directory path.
+ *
+ * Returns: a new #SwfdecURL or %NULL if an error was detected.
+ **/
+SwfdecURL *
+swfdec_url_new_relative (const SwfdecURL *url, const char *string)
+{
+ SwfdecURL *ret;
+ char *path, *query;
+
+ g_return_val_if_fail (url != NULL, NULL);
+ g_return_val_if_fail (string != NULL, NULL);
+
+ /* check for full-qualified URL */
+ if (strstr (string, "://"))
+ return swfdec_url_new (string);
+
+ if (string[0] == '/') {
+ /* absolute URL */
+ string++;
+ query = strchr (string, '?');
+ if (query == NULL) {
+ path = *string ? g_strdup (string) : NULL;
+ } else {
+ path = g_strndup (string, query - string);
+ query = g_strdup (query + 1);
+ }
+ } else {
+ /* relative URL */
+ char *cur = g_strdup (url->path);
+ while (g_str_has_prefix (string, "../")) {
+ if (!swfdec_url_path_to_parent_path (cur)) {
+ g_free (cur);
+ return NULL;
+ }
+ string += 3;
+ }
+ if (strstr (string, "/../")) {
+ g_free (cur);
+ return NULL;
+ }
+ path = g_strconcat (cur, "/", string, NULL);
+ g_free (cur);
+ cur = path;
+ query = strchr (cur, '?');
+ if (query == NULL) {
+ path = *string ? g_strdup (cur) : NULL;
+ } else {
+ path = g_strndup (cur, query - cur);
+ query = g_strdup (query + 1);
+ }
+ g_free (cur);
+ }
+ ret = swfdec_url_new_components (url->protocol, url->host, url->port,
+ path, query);
+ g_free (path);
+ g_free (query);
+ return ret;
+}
+
+/**
+ * swfdec_url_copy:
+ * @url: a #SwfdecURL
+ *
+ * copies the given url.
+ *
+ * Returns: a new #SwfdecURL
+ **/
+SwfdecURL *
+swfdec_url_copy (const SwfdecURL *url)
+{
+ SwfdecURL *copy;
+
+ g_return_val_if_fail (url != NULL, NULL);
+
+ copy = g_slice_new0 (SwfdecURL);
+ copy->url = g_strdup (url->url);
+ copy->protocol = g_strdup (url->protocol);
+ copy->host = g_strdup (url->host);
+ copy->port = url->port;
+ copy->path = g_strdup (url->path);
+ copy->query = g_strdup (url->query);
+
+ return copy;
+}
+
+/**
+ * swfdec_url_free:
+ * @url: a #SwfdecURL
+ *
+ * Frees the URL and its associated ressources.
+ **/
+void
+swfdec_url_free (SwfdecURL *url)
+{
+ g_return_if_fail (url != NULL);
+
+ g_free (url->url);
+ g_free (url->protocol);
+ g_free (url->host);
+ g_free (url->path);
+ g_free (url->query);
+ g_slice_free (SwfdecURL, url);
+}
+
+/**
+ * swfdec_url_get_url:
+ * @url: a #SwfdecURL
+ *
+ * Gets the whole URL.
+ *
+ * Returns: the complete URL as string
+ **/
+const char *
+swfdec_url_get_url (const SwfdecURL *url)
+{
+ g_return_val_if_fail (url != NULL, NULL);
+
+ return url->url;
+}
+
+/**
+ * swfdec_url_get_protocol:
+ * @url: a #SwfdecURL
+ *
+ * Gets the protocol used by this URL, such as "http" or "file".
+ *
+ * Returns: the protocol used or "error" if the URL is broken
+ **/
+const char *
+swfdec_url_get_protocol (const SwfdecURL *url)
+{
+ g_return_val_if_fail (url != NULL, NULL);
+
+ if (url->protocol)
+ return url->protocol;
+ else
+ return "error";
+}
+
+/**
+ * swfdec_url_has_protocol:
+ * @url: a url
+ * @protocol: protocol name to check for
+ *
+ * Checks if the given @url references the given @protocol
+ *
+ * Returns: %TRUE if both protocols match, %FALSE otherwise
+ **/
+gboolean
+swfdec_url_has_protocol (const SwfdecURL *url, const char *protocol)
+{
+ g_return_val_if_fail (url != NULL, FALSE);
+ g_return_val_if_fail (protocol != NULL, FALSE);
+
+ return g_str_equal (url->protocol, protocol);
+}
+
+/**
+ * swfdec_url_get_host:
+ * @url: a #SwfdecURL
+ *
+ * Gets the host for @url as a lower case string.
+ *
+ * Returns: the host or %NULL if none (typically for file URLs).
+ **/
+const char *
+swfdec_url_get_host (const SwfdecURL *url)
+{
+ g_return_val_if_fail (url != NULL, NULL);
+
+ return url->host;
+}
+
+/**
+ * swfdec_url_get_port:
+ * @url: a #SwfdecURL
+ *
+ * Gets the port number specified by the given @url. If the @url does not
+ * specify a port number, 0 will be returned.
+ *
+ * Returns: the specified port or 0 if none was given.
+ **/
+guint
+swfdec_url_get_port (const SwfdecURL *url)
+{
+ g_return_val_if_fail (url != NULL, 0);
+
+ return url->port;
+}
+
+/**
+ * swfdec_url_get_path:
+ * @url: a #SwfdecURL
+ *
+ * Gets the path associated with @url. If it contains no path, %NULL is
+ * returned.
+ * <note>The returned path does not start with a slash. So in particular for
+ * files, you want to prepend the slash yourself.</note>
+ *
+ * Returns: the path or %NULL if none
+ **/
+const char *
+swfdec_url_get_path (const SwfdecURL *url)
+{
+ g_return_val_if_fail (url != NULL, NULL);
+
+ return url->path;
+}
+
+/**
+ * swfdec_url_get_query:
+ * @url: a #SwfdecURL
+ *
+ * Gets the query string associated with @url. If the URL does not have a query
+ * string, %NULL is returned.
+ *
+ * Returns: Query string or %NULL
+ **/
+const char *
+swfdec_url_get_query (const SwfdecURL *url)
+{
+ g_return_val_if_fail (url != NULL, NULL);
+
+ return url->query;
+}
+
+/**
+ * swfdec_url_is_parent:
+ * @parent: the supposed parent url
+ * @child: the supposed child url
+ *
+ * Checks if the given @parent url is a parent url of the given @child url. The
+ * algorithm used is the same as checking policy files if hey apply. If @parent
+ * equals @child, %TRUE is returned. This function does not compare query
+ * strings.
+ *
+ * Returns: %TRUE if @parent is a parent of @child, %FALSE otherwise.
+ **/
+gboolean
+swfdec_url_is_parent (const SwfdecURL *parent, const SwfdecURL *child)
+{
+ gsize len;
+
+ g_return_val_if_fail (parent != NULL, FALSE);
+ g_return_val_if_fail (child != NULL, FALSE);
+
+ if (!g_str_equal (parent->protocol, child->protocol))
+ return FALSE;
+ if (parent->host == NULL) {
+ if (child->host != NULL)
+ return FALSE;
+ } else {
+ if (child->host == NULL || !g_str_equal (parent->host, child->host))
+ return FALSE;
+ }
+ if (parent->port != child->port)
+ return FALSE;
+ if (parent->path == NULL)
+ return TRUE;
+ if (child->path == NULL)
+ return TRUE;
+ len = strlen (parent->path);
+ if (strncmp (parent->path, child->path, len) != 0)
+ return FALSE;
+ return child->path[len] == '\0' || child->path[len] == '/';
+}
+
+/**
+ * swfdec_url_is_local:
+ * @url: the url to check
+ *
+ * Checks if the given @url references a local resource. Local resources are
+ * treated differently by Flash, since they get a higher degree of trust.
+ *
+ * Returns: %TRUE if the given url is local.
+ **/
+gboolean
+swfdec_url_is_local (const SwfdecURL *url)
+{
+ g_return_val_if_fail (url != NULL, FALSE);
+
+ /* FIXME: If we ever support gnome-vfs, this might become tricky */
+ return swfdec_url_has_protocol (url, "file");
+}
+
+/**
+ * swfdec_url_equal:
+ * @a: a #SwfdecURL
+ * @b: a #SwfdecURL
+ *
+ * Compares the 2 given URLs for equality. 2 URLs are considered equal, when
+ * they point to the same resource. This function is intended to be
+ * used together with swfdec_url_hash() in a #GHashtable.
+ *
+ * Returns: %TRUE if the 2 given urls point to the same resource, %FALSE
+ * otherwise.
+ **/
+gboolean
+swfdec_url_equal (gconstpointer a, gconstpointer b)
+{
+ const SwfdecURL *urla = a;
+ const SwfdecURL *urlb = b;
+
+ if (!swfdec_url_has_protocol (urla, urlb->protocol))
+ return FALSE;
+
+ if (urla->host == NULL) {
+ if (urlb->host != NULL)
+ return FALSE;
+ } else {
+ if (urlb->host == NULL ||
+ !g_str_equal (urla->host, urlb->host))
+ return FALSE;
+ }
+
+ if (urla->port != urlb->port)
+ return FALSE;
+
+ if (urla->path == NULL) {
+ if (urlb->path != NULL)
+ return FALSE;
+ } else {
+ if (urlb->path == NULL ||
+ !g_str_equal (urla->path, urlb->path))
+ return FALSE;
+ }
+
+ /* FIXME: include query strings? */
+ if (urla->query == NULL) {
+ if (urlb->query != NULL)
+ return FALSE;
+ } else {
+ if (urlb->query == NULL ||
+ !g_str_equal (urla->query, urlb->query))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/**
+ * swfdec_url_hash:
+ * @url: a #SwfdecURL
+ *
+ * Creates a hash value for the given @url. This function is intended to be
+ * used together with swfdec_url_equal() in a #GHashtable.
+ *
+ * Returns: a hash value
+ **/
+guint
+swfdec_url_hash (gconstpointer url)
+{
+ const SwfdecURL *u = url;
+ guint ret;
+
+ /* random hash function, feel free to improve it */
+ ret = g_str_hash (u->protocol);
+ if (u->host)
+ ret ^= g_str_hash (u->host);
+ ret ^= u->port;
+ if (u->path)
+ ret ^= g_str_hash (u->path);
+ /* queries aren't used often in hashed urls, so ignore them */
+ return ret;
+}
+
+/**
+ * swfdec_url_path_is_relative:
+ * @path: a string used to specify a url
+ *
+ * Checks if the given URL is relative or absolute.
+ *
+ * Returns: %TRUE if the path is a relative path, %FALSE if it is absolute
+ **/
+gboolean
+swfdec_url_path_is_relative (const char *path)
+{
+ g_return_val_if_fail (path != NULL, FALSE);
+
+ return strstr (path, "://") == NULL;
+}
+
+/**
+ * swfdec_url_new_from_input:
+ * @input: the input povided
+ *
+ * Tries to guess the right URL from the given @input. This function is meant
+ * as a utility function helping to convert user input (like command line
+ * arguments) to a URL without requiring the full URL.
+ *
+ * Returns: a new url best matching the given @input.
+ **/
+SwfdecURL *
+swfdec_url_new_from_input (const char *input)
+{
+ SwfdecURL *url;
+ char *url_string;
+
+ g_return_val_if_fail (input != NULL, NULL);
+
+ /* if it's a full URL, return it */
+ if (!swfdec_url_path_is_relative (input) &&
+ (url = swfdec_url_new (input)))
+ return url;
+
+ if (g_path_is_absolute (input)) {
+ url_string = g_strconcat ("file://", input, NULL);
+ } else {
+ char *absolute, *cur;
+ cur = g_get_current_dir ();
+ absolute = g_build_filename (cur, input, NULL);
+ g_free (cur);
+ url_string = g_strconcat ("file://", absolute, NULL);
+ g_free (absolute);
+ }
+
+ url = swfdec_url_new (url_string);
+ g_free (url_string);
+ g_return_val_if_fail (url != NULL, NULL);
+ return url;
+}
+
+/**
+ * swfdec_url_format_for_display:
+ * @url: the url to display
+ *
+ * Creates a string suitable to display the given @url. An example for using
+ * this function is to identify a currently playing Flash URL. Use
+ * swfdec_player_get_url() to query the player's URL and then use this function
+ * to get a displayable string.
+ *
+ * Returns: A new string containig a short description for this URL. g_free()
+ * after use.
+ **/
+char *
+swfdec_url_format_for_display (const SwfdecURL *url)
+{
+ GString *str;
+
+ g_return_val_if_fail (url != NULL, NULL);
+
+ if (swfdec_url_is_local (url)) {
+ const char *slash;
+
+ if (url->path == NULL)
+ return g_strdup ("/");
+ slash = strrchr (url->path, '/');
+ if (slash && slash[1] != '\0') {
+ return g_strdup (slash + 1);
+ } else {
+ return g_strdup (url->path);
+ }
+ }
+ str = g_string_new (url->protocol);
+ g_string_append (str, "://");
+ if (url->host)
+ g_string_append (str, url->host);
+ g_string_append (str, "/");
+ if (url->path)
+ g_string_append (str, url->path);
+
+ return g_string_free (str, FALSE);
+}
+
diff --git a/swfdec/swfdec_url.h b/swfdec/swfdec_url.h
new file mode 100644
index 0000000..a7d8c13
--- /dev/null
+++ b/swfdec/swfdec_url.h
@@ -0,0 +1,69 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#include <glib-object.h>
+
+#ifndef _SWFDEC_URL_H_
+#define _SWFDEC_URL_H_
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecURL SwfdecURL;
+
+#define SWFDEC_TYPE_URL swfdec_url_get_type()
+GType swfdec_url_get_type (void) G_GNUC_CONST;
+
+SwfdecURL * swfdec_url_new (const char * string);
+SwfdecURL * swfdec_url_new_components (const char * protocol,
+ const char * hostname,
+ guint port,
+ const char * path,
+ const char * query);
+SwfdecURL * swfdec_url_new_parent (const SwfdecURL * url);
+SwfdecURL * swfdec_url_new_relative (const SwfdecURL * url,
+ const char * string);
+SwfdecURL * swfdec_url_new_from_input (const char * input);
+SwfdecURL * swfdec_url_copy (const SwfdecURL * url);
+void swfdec_url_free (SwfdecURL * url);
+
+const char * swfdec_url_get_url (const SwfdecURL * url);
+const char * swfdec_url_get_protocol (const SwfdecURL * url);
+const char * swfdec_url_get_host (const SwfdecURL * url);
+guint swfdec_url_get_port (const SwfdecURL * url);
+const char * swfdec_url_get_path (const SwfdecURL * url);
+const char * swfdec_url_get_query (const SwfdecURL * url);
+char * swfdec_url_format_for_display (const SwfdecURL * url);
+
+gboolean swfdec_url_has_protocol (const SwfdecURL * url,
+ const char * protocol);
+
+gboolean swfdec_url_is_parent (const SwfdecURL * parent,
+ const SwfdecURL * child);
+gboolean swfdec_url_is_local (const SwfdecURL * url);
+
+gboolean swfdec_url_equal (gconstpointer a,
+ gconstpointer b);
+guint swfdec_url_hash (gconstpointer url);
+
+gboolean swfdec_url_path_is_relative (const char * path);
+
+
+G_END_DECLS
+
+#endif
diff --git a/swfdec/swfdec_utils.c b/swfdec/swfdec_utils.c
new file mode 100644
index 0000000..a6dc0db
--- /dev/null
+++ b/swfdec/swfdec_utils.c
@@ -0,0 +1,74 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+
+#include "swfdec_utils.h"
+
+gboolean
+swfdec_str_case_equal (gconstpointer v1, gconstpointer v2)
+{
+ const char *s1 = v1;
+ const char *s2 = v2;
+
+ return g_ascii_strcasecmp (s1, s2) == 0;
+}
+
+guint
+swfdec_str_case_hash (gconstpointer v)
+{
+ const signed char *p;
+ guint32 h = 0;
+
+ for (p = v; *p != '\0'; p++)
+ h = (h << 5) - h + (*p & 0xDF);
+
+ return h;
+}
+
+int
+swfdec_strcmp (guint version, const char *s1, const char *s2)
+{
+ g_return_val_if_fail (s1 != NULL, 0);
+ g_return_val_if_fail (s2 != NULL, 0);
+
+ if (version < 7) {
+ return g_ascii_strcasecmp (s1, s2);
+ } else {
+ return strcmp (s1, s2);
+ }
+}
+
+int
+swfdec_strncmp (guint version, const char *s1, const char *s2, guint n)
+{
+ g_return_val_if_fail (s1 != NULL, 0);
+ g_return_val_if_fail (s2 != NULL, 0);
+
+ if (version < 7) {
+ return g_ascii_strncasecmp (s1, s2, n);
+ } else {
+ return strncmp (s1, s2, n);
+ }
+}
+
diff --git a/swfdec/swfdec_utils.h b/swfdec/swfdec_utils.h
new file mode 100644
index 0000000..fc57a5d
--- /dev/null
+++ b/swfdec/swfdec_utils.h
@@ -0,0 +1,40 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#include <glib.h>
+
+#ifndef _SWFDEC_UTILS_H_
+#define _SWFDEC_UTILS_H_
+
+
+gboolean swfdec_str_case_equal (gconstpointer v1,
+ gconstpointer v2);
+guint swfdec_str_case_hash (gconstpointer v);
+
+int swfdec_strcmp (guint version,
+ const char * s1,
+ const char * s2);
+int swfdec_strncmp (guint version,
+ const char * s1,
+ const char * s2,
+ guint n);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_video.c b/swfdec/swfdec_video.c
new file mode 100644
index 0000000..7ff8d8f
--- /dev/null
+++ b/swfdec/swfdec_video.c
@@ -0,0 +1,302 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+
+#include "swfdec_video.h"
+#include "swfdec_debug.h"
+#include "swfdec_font.h"
+#include "swfdec_swf_decoder.h"
+#include "swfdec_video_movie.h"
+
+typedef struct {
+ guint frame;
+ SwfdecBuffer * buffer;
+} SwfdecVideoTag;
+
+static int
+swfdec_video_compare_frame (gconstpointer a, gconstpointer b)
+{
+ return (int) *((const guint *) a) - *((const guint *) b);
+}
+
+static SwfdecBuffer *
+swfdec_video_find_frame (SwfdecVideo *video, guint frame)
+{
+ SwfdecVideoTag tmp = { frame, NULL };
+ SwfdecVideoTag *tag;
+
+ if (video->images->len == 0)
+ return NULL;
+
+ tag = bsearch (&tmp, video->images->data, video->images->len,
+ sizeof (SwfdecVideoTag), swfdec_video_compare_frame);
+
+ return tag ? tag->buffer : NULL;
+}
+
+/*** INPUT FOR MOVIE ***/
+
+typedef struct {
+ SwfdecVideoMovieInput input;
+ SwfdecVideoMovie * movie;
+ SwfdecVideo * video;
+ gpointer decoder;
+ guint current_frame;
+ cairo_surface_t * surface;
+} SwfdecVideoInput;
+
+static void
+swfdec_video_input_set_ratio (SwfdecVideoMovieInput *input_, SwfdecVideoMovie *movie)
+{
+ SwfdecVideoInput *input = (SwfdecVideoInput *) input_;
+ guint ratio = SWFDEC_MOVIE (movie)->original_ratio;
+ SwfdecBuffer *buffer;
+
+ if (input->decoder == NULL)
+ return;
+ ratio++;
+ if (ratio > input->video->n_frames) {
+ SWFDEC_ERROR ("ratio %u too big: only %u frames", ratio, input->video->n_frames);
+ ratio = input->video->n_frames - 1;
+ }
+ if (ratio < input->current_frame) {
+ /* FIXME: need to reset decoder here? */
+ input->current_frame = 0;
+ }
+
+ while (input->current_frame < ratio) {
+ buffer = swfdec_video_find_frame (input->video, input->current_frame);
+ if (buffer == NULL) {
+ SWFDEC_INFO ("no buffer for frame %u", input->current_frame);
+ } else {
+ if (input->surface)
+ cairo_surface_destroy (input->surface);
+ input->surface = swfdec_video_decoder_decode (input->decoder, buffer);
+ if (input->surface == NULL)
+ return;
+ if (input->video->width < (guint) cairo_image_surface_get_width (input->surface) ||
+ input->video->height < (guint) cairo_image_surface_get_height (input->surface)) {
+ static cairo_user_data_key_t key;
+ cairo_surface_t *old = input->surface;
+ input->surface = cairo_image_surface_create_for_data (
+ cairo_image_surface_get_data (old), cairo_image_surface_get_format (old),
+ input->video->width, input->video->height,
+ cairo_image_surface_get_stride (old));
+ cairo_surface_set_user_data (input->surface, &key, old,
+ (cairo_destroy_func_t) cairo_surface_destroy);
+ }
+ }
+ input->current_frame++;
+ }
+}
+
+static void
+swfdec_video_input_connect (SwfdecVideoMovieInput *input_, SwfdecVideoMovie *movie)
+{
+ SwfdecVideoInput *input = (SwfdecVideoInput *) input_;
+
+ g_assert (input->movie == NULL);
+ input->movie = movie;
+}
+
+static void
+swfdec_video_input_disconnect (SwfdecVideoMovieInput *input_, SwfdecVideoMovie *movie)
+{
+ SwfdecVideoInput *input = (SwfdecVideoInput *) input_;
+
+ g_assert (input->movie == movie);
+ if (input->decoder)
+ swfdec_video_decoder_free (input->decoder);
+ if (input->surface)
+ cairo_surface_destroy (input->surface);
+ g_object_unref (input->video);
+ g_slice_free (SwfdecVideoInput, input);
+}
+
+static cairo_surface_t *
+swfdec_video_input_get_image (SwfdecVideoMovieInput *input_)
+{
+ SwfdecVideoInput *input = (SwfdecVideoInput *) input_;
+
+ return input->surface;
+}
+
+static SwfdecVideoMovieInput *
+swfdec_video_input_new (SwfdecVideo *video)
+{
+ SwfdecVideoInput *input;
+
+ if (video->n_frames == 0)
+ return NULL;
+ input = g_slice_new0 (SwfdecVideoInput);
+ input->decoder = swfdec_video_decoder_new (video->format);
+ if (input->decoder == NULL) {
+ g_slice_free (SwfdecVideoInput, input);
+ return NULL;
+ }
+ input->input.connect = swfdec_video_input_connect;
+ input->input.disconnect = swfdec_video_input_disconnect;
+ input->input.set_ratio = swfdec_video_input_set_ratio;
+ input->input.get_image = swfdec_video_input_get_image;
+ g_object_ref (video);
+ input->video = video;
+ input->current_frame = (guint) -1;
+ return &input->input;
+}
+
+/*** SWFDEC_VIDEO ***/
+
+G_DEFINE_TYPE (SwfdecVideo, swfdec_video, SWFDEC_TYPE_GRAPHIC)
+
+static SwfdecMovie *
+swfdec_video_create_movie (SwfdecGraphic *graphic, gsize *size)
+{
+ SwfdecVideo *video = SWFDEC_VIDEO (graphic);
+ SwfdecVideoMovie *movie = g_object_new (SWFDEC_TYPE_VIDEO_MOVIE, NULL);
+ SwfdecVideoMovieInput *input = swfdec_video_input_new (video);
+
+ movie->video = SWFDEC_VIDEO (graphic);
+ g_object_ref (graphic);
+ if (input)
+ swfdec_video_movie_set_input (movie, input);
+ *size = sizeof (SwfdecVideoMovie);
+ return SWFDEC_MOVIE (movie);
+}
+
+static void
+swfdec_video_dispose (GObject *object)
+{
+ SwfdecVideo * video = SWFDEC_VIDEO (object);
+ guint i;
+
+ for (i = 0; i < video->images->len; i++) {
+ swfdec_buffer_unref (g_array_index (video->images, SwfdecVideoTag, i).buffer);
+ }
+ g_array_free (video->images, TRUE);
+ G_OBJECT_CLASS (swfdec_video_parent_class)->dispose (object);
+}
+
+static void
+swfdec_video_class_init (SwfdecVideoClass * g_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+ SwfdecGraphicClass *graphic_class = SWFDEC_GRAPHIC_CLASS (g_class);
+
+ object_class->dispose = swfdec_video_dispose;
+
+ graphic_class->create_movie = swfdec_video_create_movie;
+}
+
+static void
+swfdec_video_init (SwfdecVideo * video)
+{
+ video->images = g_array_new (FALSE, FALSE, sizeof (SwfdecVideoTag));
+}
+
+int
+tag_func_define_video (SwfdecSwfDecoder *s, guint tag)
+{
+ SwfdecVideo *video;
+ guint id;
+ SwfdecBits *bits = &s->b;
+ int smoothing, deblocking;
+
+ id = swfdec_bits_get_u16 (bits);
+ video = swfdec_swf_decoder_create_character (s, id, SWFDEC_TYPE_VIDEO);
+ if (!video)
+ return SWFDEC_STATUS_OK;
+
+ video->n_frames = swfdec_bits_get_u16 (bits);
+ video->width = swfdec_bits_get_u16 (bits);
+ video->height = swfdec_bits_get_u16 (bits);
+ swfdec_bits_getbits (bits, 4);
+ deblocking = swfdec_bits_getbits (bits, 3);
+ smoothing = swfdec_bits_getbit (bits);
+ video->format = swfdec_bits_get_u8 (bits);
+ SWFDEC_LOG (" frames: %u", video->n_frames);
+ SWFDEC_LOG (" size: %ux%u", video->width, video->height);
+ SWFDEC_LOG (" deblocking: %d", deblocking);
+ SWFDEC_LOG (" smoothing: %d", smoothing);
+ SWFDEC_LOG (" format: %d", (int) video->format);
+ return SWFDEC_STATUS_OK;
+}
+
+int
+tag_func_video_frame (SwfdecSwfDecoder *s, guint unused_tag)
+{
+ SwfdecVideo *video;
+ guint id;
+ SwfdecVideoTag tag;
+
+ id = swfdec_bits_get_u16 (&s->b);
+ video = (SwfdecVideo *) swfdec_swf_decoder_get_character (s, id);
+ if (!SWFDEC_IS_VIDEO (video)) {
+ SWFDEC_ERROR ("id %u does not reference a video object", id);
+ return SWFDEC_STATUS_OK;
+ }
+ tag.frame = swfdec_bits_get_u16 (&s->b);
+ if (tag.frame >= video->n_frames) {
+ SWFDEC_ERROR ("frame %u out of range %u", tag.frame, video->n_frames);
+ return SWFDEC_STATUS_OK;
+ }
+ /* it seems flash video saves keyframe + format in every frame -
+ * at least libflv + ming does that and Flash Player plays it.
+ */
+ if (video->format == SWFDEC_VIDEO_CODEC_SCREEN) {
+#if 0
+ keyframe = swfdec_bits_get_bits (&s->b, 4);
+ format = swfdec_bits_get_bits (&s->b, 4);
+#endif
+ swfdec_bits_get_u8 (&s->b);
+ }
+ tag.buffer = swfdec_bits_get_buffer (&s->b, -1);
+ if (tag.buffer == NULL) {
+ SWFDEC_WARNING ("no buffer, ignoring");
+ return SWFDEC_STATUS_OK;
+ }
+ if (video->images->len == 0) {
+ g_array_append_val (video->images, tag);
+ } else if (g_array_index (video->images, SwfdecVideoTag, video->images->len - 1).frame < tag.frame) {
+ g_array_append_val (video->images, tag);
+ } else {
+ guint i;
+ SWFDEC_WARNING ("frame not in ascending order (last is %u, this is %u)",
+ g_array_index (video->images, SwfdecVideoTag, video->images->len - 1).frame, tag.frame);
+ for (i = 0; i < video->images->len; i++) {
+ SwfdecVideoTag *cur = &g_array_index (video->images, SwfdecVideoTag, i);
+ if (cur->frame < tag.frame)
+ continue;
+ if (cur->frame == tag.frame) {
+ SWFDEC_ERROR ("duplicate frame id %u", cur->frame);
+ continue;
+ }
+ g_array_insert_val (video->images, i, tag);
+ break;
+ }
+ if (i >= video->images->len)
+ g_array_append_val (video->images, tag);
+ }
+ return SWFDEC_STATUS_OK;
+}
+
diff --git a/swfdec/swfdec_video.h b/swfdec/swfdec_video.h
new file mode 100644
index 0000000..585c726
--- /dev/null
+++ b/swfdec/swfdec_video.h
@@ -0,0 +1,61 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_VIDEO_H_
+#define _SWFDEC_VIDEO_H_
+
+#include <libswfdec/swfdec_graphic.h>
+#include <libswfdec/swfdec_codec_video.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecVideo SwfdecVideo;
+typedef struct _SwfdecVideoClass SwfdecVideoClass;
+
+#define SWFDEC_TYPE_VIDEO (swfdec_video_get_type())
+#define SWFDEC_IS_VIDEO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_VIDEO))
+#define SWFDEC_IS_VIDEO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_VIDEO))
+#define SWFDEC_VIDEO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_VIDEO, SwfdecVideo))
+#define SWFDEC_VIDEO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_VIDEO, SwfdecVideoClass))
+
+struct _SwfdecVideo {
+ SwfdecGraphic graphic;
+
+ guint width; /* width in pixels */
+ guint height; /* height in pixels */
+ guint n_frames; /* length of movie */
+ GArray * images; /* actual images of the movie */
+
+ guint format; /* format in use */
+};
+
+struct _SwfdecVideoClass {
+ SwfdecGraphicClass graphic_class;
+};
+
+GType swfdec_video_get_type (void);
+
+int tag_func_define_video (SwfdecSwfDecoder * s,
+ guint tag);
+int tag_func_video_frame (SwfdecSwfDecoder * s,
+ guint tag);
+
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_video_movie.c b/swfdec/swfdec_video_movie.c
new file mode 100644
index 0000000..b77379a
--- /dev/null
+++ b/swfdec/swfdec_video_movie.c
@@ -0,0 +1,197 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_video_movie.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_resource.h"
+
+G_DEFINE_TYPE (SwfdecVideoMovie, swfdec_video_movie, SWFDEC_TYPE_MOVIE)
+
+static void
+swfdec_video_movie_update_extents (SwfdecMovie *movie,
+ SwfdecRect *extents)
+{
+ SwfdecVideoMovie *video = SWFDEC_VIDEO_MOVIE (movie);
+ SwfdecRect rect = { 0, 0,
+ SWFDEC_TWIPS_SCALE_FACTOR * video->video->width,
+ SWFDEC_TWIPS_SCALE_FACTOR * video->video->height };
+
+ swfdec_rect_union (extents, extents, &rect);
+}
+
+static void
+swfdec_video_movie_update_image (SwfdecVideoMovie *movie)
+{
+ if (!movie->needs_update)
+ return;
+
+ if (movie->input != NULL) {
+ if (movie->input->set_ratio)
+ movie->input->set_ratio (movie->input, movie);
+
+ if (movie->image)
+ cairo_surface_destroy (movie->image);
+ movie->image = movie->input->get_image (movie->input);
+ if (movie->image)
+ cairo_surface_reference (movie->image);
+ }
+ movie->needs_update = FALSE;
+}
+
+static void
+swfdec_video_movie_render (SwfdecMovie *mov, cairo_t *cr,
+ const SwfdecColorTransform *trans, const SwfdecRect *inval)
+{
+ SwfdecVideoMovie *movie = SWFDEC_VIDEO_MOVIE (mov);
+
+ swfdec_video_movie_update_image (movie);
+ if (movie->image == NULL)
+ return;
+
+ cairo_scale (cr,
+ (mov->original_extents.x1 - mov->original_extents.x0)
+ / cairo_image_surface_get_width (movie->image),
+ (mov->original_extents.y1 - mov->original_extents.y0)
+ / cairo_image_surface_get_height (movie->image));
+ cairo_set_source_surface (cr, movie->image, 0.0, 0.0);
+ cairo_paint (cr);
+}
+
+static void
+swfdec_video_movie_unset_input (SwfdecVideoMovie *movie)
+{
+ if (movie->input == NULL)
+ return;
+
+ if (movie->input->disconnect)
+ movie->input->disconnect (movie->input, movie);
+ movie->input = NULL;
+ swfdec_video_movie_update_image (movie);
+}
+
+static void
+swfdec_video_movie_dispose (GObject *object)
+{
+ SwfdecVideoMovie *movie = SWFDEC_VIDEO_MOVIE (object);
+
+ swfdec_video_movie_unset_input (movie);
+ g_object_unref (movie->video);
+ if (movie->image) {
+ cairo_surface_destroy (movie->image);
+ movie->image = NULL;
+ }
+
+ G_OBJECT_CLASS (swfdec_video_movie_parent_class)->dispose (object);
+}
+
+static void
+swfdec_video_movie_set_ratio (SwfdecMovie *movie)
+{
+ SwfdecVideoMovie *video = SWFDEC_VIDEO_MOVIE (movie);
+
+ if (video->input->set_ratio) {
+ video->needs_update = TRUE;
+ swfdec_movie_invalidate_last (movie);
+ }
+}
+
+static void
+swfdec_video_movie_invalidate (SwfdecMovie *movie, const cairo_matrix_t *matrix, gboolean last)
+{
+ SwfdecVideoMovie *video = SWFDEC_VIDEO_MOVIE (movie);
+ SwfdecRect rect = { 0, 0,
+ SWFDEC_TWIPS_SCALE_FACTOR * video->video->width,
+ SWFDEC_TWIPS_SCALE_FACTOR * video->video->height };
+
+ swfdec_rect_transform (&rect, &rect, matrix);
+ swfdec_player_invalidate (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), &rect);
+}
+
+static void
+swfdec_video_movie_init_movie (SwfdecMovie *movie)
+{
+ swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (movie), movie->resource->sandbox->Video);
+}
+
+static void
+swfdec_video_movie_class_init (SwfdecVideoMovieClass * g_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+ SwfdecMovieClass *movie_class = SWFDEC_MOVIE_CLASS (g_class);
+
+ object_class->dispose = swfdec_video_movie_dispose;
+
+ movie_class->update_extents = swfdec_video_movie_update_extents;
+ movie_class->render = swfdec_video_movie_render;
+ movie_class->invalidate = swfdec_video_movie_invalidate;
+ movie_class->init_movie = swfdec_video_movie_init_movie;
+ movie_class->set_ratio = swfdec_video_movie_set_ratio;
+}
+
+static void
+swfdec_video_movie_init (SwfdecVideoMovie * video_movie)
+{
+}
+
+void
+swfdec_video_movie_set_input (SwfdecVideoMovie *movie, SwfdecVideoMovieInput *input)
+{
+ g_return_if_fail (SWFDEC_IS_VIDEO_MOVIE (movie));
+
+ swfdec_video_movie_unset_input (movie);
+ movie->input = input;
+ if (input == NULL)
+ return;
+ if (movie->input->set_ratio) {
+ swfdec_movie_invalidate_last (SWFDEC_MOVIE (movie));
+ }
+ movie->needs_update = TRUE;
+ if (input->connect)
+ input->connect (input, movie);
+}
+
+void
+swfdec_video_movie_clear (SwfdecVideoMovie *movie)
+{
+ g_return_if_fail (SWFDEC_IS_VIDEO_MOVIE (movie));
+
+ if (movie->image) {
+ cairo_surface_destroy (movie->image);
+ movie->image = NULL;
+ }
+ swfdec_movie_invalidate_last (SWFDEC_MOVIE (movie));
+}
+
+void
+swfdec_video_movie_new_image (SwfdecVideoMovie *movie)
+{
+ g_return_if_fail (SWFDEC_IS_VIDEO_MOVIE (movie));
+
+ if (movie->image) {
+ cairo_surface_destroy (movie->image);
+ movie->image = NULL;
+ }
+ movie->needs_update = TRUE;
+ swfdec_movie_invalidate_last (SWFDEC_MOVIE (movie));
+}
+
diff --git a/swfdec/swfdec_video_movie.h b/swfdec/swfdec_video_movie.h
new file mode 100644
index 0000000..958bc49
--- /dev/null
+++ b/swfdec/swfdec_video_movie.h
@@ -0,0 +1,77 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_VIDEO_MOVIE_H_
+#define _SWFDEC_VIDEO_MOVIE_H_
+
+#include <glib-object.h>
+#include <libswfdec/swfdec_movie.h>
+#include <libswfdec/swfdec_video.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _SwfdecVideoMovie SwfdecVideoMovie;
+typedef struct _SwfdecVideoMovieClass SwfdecVideoMovieClass;
+typedef struct _SwfdecVideoMovieInput SwfdecVideoMovieInput;
+
+#define SWFDEC_TYPE_VIDEO_MOVIE (swfdec_video_movie_get_type())
+#define SWFDEC_IS_VIDEO_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_VIDEO_MOVIE))
+#define SWFDEC_IS_VIDEO_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_VIDEO_MOVIE))
+#define SWFDEC_VIDEO_MOVIE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_VIDEO_MOVIE, SwfdecVideoMovie))
+#define SWFDEC_VIDEO_MOVIE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_VIDEO_MOVIE, SwfdecVideoMovieClass))
+
+/* FIXME: make an interface? */
+struct _SwfdecVideoMovieInput {
+ /* connect to movie */
+ void (* connect) (SwfdecVideoMovieInput *input,
+ SwfdecVideoMovie * movie);
+ /* called when input is unset */
+ void (* disconnect) (SwfdecVideoMovieInput *input,
+ SwfdecVideoMovie * movie);
+ /* called when movie ratio changed */
+ void (* set_ratio) (SwfdecVideoMovieInput *input,
+ SwfdecVideoMovie * movie);
+ /* called to request the current image */
+ cairo_surface_t * (* get_image) (SwfdecVideoMovieInput *input);
+};
+
+struct _SwfdecVideoMovie {
+ SwfdecMovie movie;
+
+ SwfdecVideo * video; /* video we play back */
+ SwfdecVideoMovieInput *input; /* where we take the input from */
+ gboolean needs_update; /* TRUE if we should call set_ratio and get_image */
+ cairo_surface_t * image; /* currently displayed image */
+};
+
+struct _SwfdecVideoMovieClass {
+ SwfdecMovieClass movie_class;
+};
+
+GType swfdec_video_movie_get_type (void);
+
+void swfdec_video_movie_set_input (SwfdecVideoMovie * movie,
+ SwfdecVideoMovieInput *input);
+void swfdec_video_movie_clear (SwfdecVideoMovie * movie);
+/* API for SwfdecVideoMovieInput */
+void swfdec_video_movie_new_image (SwfdecVideoMovie * movie);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_video_movie_as.c b/swfdec/swfdec_video_movie_as.c
new file mode 100644
index 0000000..ecc7a28
--- /dev/null
+++ b/swfdec/swfdec_video_movie_as.c
@@ -0,0 +1,94 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_video.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_internal.h"
+#include "swfdec_net_stream.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_sandbox.h"
+
+SWFDEC_AS_NATIVE (667, 1, swfdec_video_attach_video)
+void
+swfdec_video_attach_video (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecVideoMovie *video;
+ SwfdecAsObject *stream;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_VIDEO_MOVIE, &video, "O", &stream);
+
+ if (stream == NULL || !SWFDEC_IS_NET_STREAM (stream)) {
+ SWFDEC_WARNING ("calling attachVideo without a NetStream object");
+ swfdec_video_movie_set_input (video, NULL);
+ return;
+ }
+
+ swfdec_video_movie_set_input (video, &SWFDEC_NET_STREAM (stream)->input);
+}
+
+SWFDEC_AS_NATIVE (667, 2, swfdec_video_clear)
+void
+swfdec_video_clear (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+ SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecVideoMovie *video;
+
+ SWFDEC_AS_CHECK (SWFDEC_TYPE_VIDEO_MOVIE, &video, "");
+
+ swfdec_video_movie_clear (video);
+}
+
+void
+swfdec_video_movie_init_context (SwfdecPlayer *player)
+{
+ SwfdecAsContext *context;
+ SwfdecAsObject *video, *proto;
+ SwfdecAsValue val;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+ context = SWFDEC_AS_CONTEXT (player);
+ video = SWFDEC_AS_OBJECT (swfdec_as_object_add_function (context->global,
+ SWFDEC_AS_STR_Video, 0, NULL, 0));
+ if (video == NULL)
+ return;
+ SWFDEC_SANDBOX (context->global)->Video = video;
+ proto = swfdec_as_object_new_empty (context);
+ if (proto == NULL)
+ return;
+ /* set the right properties on the Video object */
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
+ swfdec_as_object_set_variable_and_flags (video, SWFDEC_AS_STR_prototype, &val,
+ SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+ /* set the right properties on the Video.prototype object */
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, video);
+ swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor,
+ &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object_prototype);
+ swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR___proto__, &val,
+ SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);
+}
+
diff --git a/swfdec/swfdec_xml.c b/swfdec/swfdec_xml.c
new file mode 100644
index 0000000..e5331c6
--- /dev/null
+++ b/swfdec/swfdec_xml.c
@@ -0,0 +1,940 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+#include <string.h>
+
+#include "swfdec_xml.h"
+#include "swfdec_xml_node.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_as_array.h"
+#include "swfdec_as_object.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_internal.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_player_internal.h"
+
+G_DEFINE_TYPE (SwfdecXml, swfdec_xml, SWFDEC_TYPE_XML_NODE)
+
+static void
+swfdec_xml_do_mark (SwfdecAsObject *object)
+{
+ SwfdecXml *xml = SWFDEC_XML (object);
+
+ if (xml->xml_decl != NULL)
+ swfdec_as_string_mark (xml->xml_decl);
+ if (xml->doc_type_decl != NULL)
+ swfdec_as_string_mark (xml->doc_type_decl);
+
+ SWFDEC_AS_OBJECT_CLASS (swfdec_xml_parent_class)->mark (object);
+}
+
+static void
+swfdec_xml_class_init (SwfdecXmlClass *klass)
+{
+ SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
+
+ asobject_class->mark = swfdec_xml_do_mark;
+}
+
+static void
+swfdec_xml_init (SwfdecXml *xml)
+{
+}
+
+typedef struct {
+ const char character;
+ const char *escaped;
+} EntityConversion;
+
+static EntityConversion xml_entities[] = {
+ { '&', "&" },
+ { '"', """ },
+ { '\'', "'" },
+ { '<', "<" },
+ { '>', ">" },
+ { '\xa0', " " },
+ { '\0', NULL }
+};
+
+char *
+swfdec_xml_escape_len (const char *orginal, gssize length)
+{
+ int i;
+ const char *p, *start;
+ GString *string;
+
+ string = g_string_new ("");
+
+ // Note: we don't escape non-breaking space to
+ p = start = orginal;
+ while (*(p += strcspn (p, "&<>\"'")) != '\0' && p - orginal < length) {
+ string = g_string_append_len (string, start, p - start);
+
+ // escape it
+ for (i = 0; xml_entities[i].escaped != NULL; i++) {
+ if (xml_entities[i].character == *p) {
+ string = g_string_append (string, xml_entities[i].escaped);
+ break;
+ }
+ }
+ g_assert (xml_entities[i].escaped != NULL);
+
+ p++;
+ start = p;
+ }
+ string = g_string_append_len (string, start, length - (start - orginal));
+
+ return g_string_free (string, FALSE);
+}
+
+char *
+swfdec_xml_escape (const char *orginal)
+{
+ return swfdec_xml_escape_len (orginal, strlen (orginal));
+}
+
+char *
+swfdec_xml_unescape_len (SwfdecAsContext *cx, const char *orginal,
+ gssize length, gboolean unescape_nbsp)
+{
+ int i;
+ const char *p, *start, *end;
+ GString *string;
+
+ string = g_string_new ("");
+
+ p = start = orginal;
+ end = orginal + length;
+ while ((p = memchr (p, '&', end - p)) != NULL) {
+ string = g_string_append_len (string, start, p - start);
+
+ for (i = 0; xml_entities[i].escaped != NULL; i++) {
+ if (!g_ascii_strncasecmp (p, xml_entities[i].escaped,
+ strlen (xml_entities[i].escaped))) {
+ // FIXME: Do this cleaner
+ if (xml_entities[i].character == '\xa0') {
+ if (unescape_nbsp)
+ string = g_string_append_c (string, '\xc2');
+ else
+ continue;
+ }
+ string = g_string_append_c (string, xml_entities[i].character);
+ p += strlen (xml_entities[i].escaped);
+ break;
+ }
+ }
+ if (xml_entities[i].escaped == NULL) {
+ string = g_string_append_c (string, '&');
+ p++;
+ }
+
+ start = p;
+ }
+ string = g_string_append_len (string, start, length - (start - orginal));
+
+ return g_string_free (string, FALSE);
+}
+
+char *
+swfdec_xml_unescape (SwfdecAsContext *cx, const char *orginal)
+{
+ return swfdec_xml_unescape_len (cx, orginal, strlen (orginal), TRUE);
+}
+
+// this is never declared, only available as ASnative (100, 5)
+SWFDEC_AS_NATIVE (100, 5, swfdec_xml_do_escape)
+void
+swfdec_xml_do_escape (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ char *escaped;
+
+ if (argc < 1)
+ return;
+
+ escaped = swfdec_xml_escape (swfdec_as_value_to_string (cx, &argv[0]));
+ SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_give_string (cx, escaped));
+}
+
+static void
+swfdec_xml_get_ignoreWhite (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_XML (object))
+ return;
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, SWFDEC_XML (object)->ignore_white);
+}
+
+static void
+swfdec_xml_set_ignoreWhite (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_XML (object))
+ return;
+
+ if (argc < 1)
+ return;
+
+ // special case
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
+ return;
+
+ // special case, call toString of objects
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]))
+ swfdec_as_value_to_string (cx, &argv[0]);
+
+ SWFDEC_XML (object)->ignore_white =
+ swfdec_as_value_to_boolean (cx, &argv[0]);
+}
+
+static void
+swfdec_xml_get_xmlDecl (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_XML (object))
+ return;
+
+ if (SWFDEC_XML (object)->xml_decl != NULL) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_XML (object)->xml_decl);
+ } else {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (ret);
+ }
+}
+
+static void
+swfdec_xml_set_xmlDecl (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_XML (object))
+ return;
+
+ if (argc < 1)
+ return;
+
+ // special case
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
+ return;
+
+ SWFDEC_XML (object)->xml_decl = swfdec_as_value_to_string (cx, &argv[0]);
+}
+
+static void
+swfdec_xml_get_docTypeDecl (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_XML (object))
+ return;
+
+ if (SWFDEC_XML (object)->doc_type_decl != NULL) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_XML (object)->doc_type_decl);
+ } else {
+ SWFDEC_AS_VALUE_SET_UNDEFINED (ret);
+ }
+}
+
+static void
+swfdec_xml_set_docTypeDecl (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_XML (object))
+ return;
+
+ if (argc < 1)
+ return;
+
+ // special case
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
+ return;
+
+ SWFDEC_XML (object)->doc_type_decl =
+ swfdec_as_value_to_string (cx, &argv[0]);
+}
+
+static void
+swfdec_xml_get_contentType (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_XML (object))
+ return;
+
+ *ret = SWFDEC_XML (object)->content_type;
+}
+
+static void
+swfdec_xml_set_contentType (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_XML (object))
+ return;
+
+ if (argc < 1)
+ return;
+
+ // special case
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
+ return;
+
+ SWFDEC_XML (object)->content_type = argv[0];
+}
+
+static void
+swfdec_xml_get_loaded (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_XML (object))
+ return;
+
+ *ret = SWFDEC_XML (object)->loaded;
+}
+
+static void
+swfdec_xml_set_loaded (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_XML (object))
+ return;
+
+ if (argc < 1)
+ return;
+
+ // special case, call toString of objects
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]))
+ swfdec_as_value_to_string (cx, &argv[0]);
+
+ // special case
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
+ return;
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (&SWFDEC_XML (object)->loaded,
+ swfdec_as_value_to_boolean (cx, &argv[0]));
+}
+
+static void
+swfdec_xml_get_status (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_XML (object))
+ return;
+
+ SWFDEC_AS_VALUE_SET_INT (ret, SWFDEC_XML (object)->status);
+}
+
+static void
+swfdec_xml_set_status (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ double d;
+
+ if (!SWFDEC_IS_XML (object))
+ return;
+
+ if (argc < 1)
+ return;
+
+ swfdec_as_value_to_string (cx, &argv[0]);
+ d = swfdec_as_value_to_number (cx, &argv[0]);
+ if (!isfinite (d))
+ SWFDEC_XML (object)->status = 0;
+ else
+ SWFDEC_XML (object)->status = d;
+}
+
+static const char *
+swfdec_xml_parse_xmlDecl (SwfdecXml *xml, SwfdecXmlNode *node, const char *p)
+{
+ const char *end;
+ GString *string;
+
+ g_assert (p != NULL);
+ g_return_val_if_fail (g_ascii_strncasecmp (p, "<?xml", strlen ("<?xml")) == 0,
+ strchr (p, '\0'));
+ g_return_val_if_fail (SWFDEC_IS_XML (xml), strchr (p, '\0'));
+
+ end = strstr (p, "?>");
+ if (end == NULL) {
+ xml->status = XML_PARSE_STATUS_XMLDECL_NOT_TERMINATED;
+ return strchr (p, '\0');
+ }
+
+ end += strlen ("?>");
+
+ string = g_string_new ((xml->xml_decl != NULL ? xml->xml_decl : ""));
+ string = g_string_append_len (string, p, end - p);
+ xml->xml_decl = swfdec_as_context_give_string (
+ SWFDEC_AS_OBJECT (xml)->context, g_string_free (string, FALSE));
+
+ // in version 5 parsing xmlDecl or docType always adds undefined element to
+ // the childNodes array
+ if (SWFDEC_AS_OBJECT (xml)->context->version < 6)
+ SWFDEC_FIXME ("Need to add undefined element to childNodes array");
+
+ g_return_val_if_fail (end > p, strchr (p, '\0'));
+
+ return end;
+}
+
+static const char *
+swfdec_xml_parse_docTypeDecl (SwfdecXml *xml, SwfdecXmlNode *node,
+ const char *p)
+{
+ const char *end;
+ int open;
+
+ g_assert (p != NULL);
+ g_return_val_if_fail (
+ g_ascii_strncasecmp (p, "<!DOCTYPE", strlen ("<!DOCTYPE")) == 0,
+ strchr (p, '\0'));
+ g_return_val_if_fail (SWFDEC_IS_XML (xml), strchr (p, '\0'));
+
+ end = p + 1;
+ open = 1;
+ do {
+ end += strcspn (end, "<>");
+ if (*end == '<') {
+ open++;
+ end++;
+ } else if (*end == '>') {
+ open--;
+ end++;
+ }
+ } while (*end != '\0' && open > 0);
+
+ if (*end == '\0') {
+ xml->status = XML_PARSE_STATUS_DOCTYPEDECL_NOT_TERMINATED;
+ } else {
+ xml->doc_type_decl = swfdec_as_context_give_string (
+ SWFDEC_AS_OBJECT (xml)->context, g_strndup (p, end - p));
+
+ // in version 5 parsing xmlDecl or docType always adds undefined element to
+ // the childNodes array
+ if (SWFDEC_AS_OBJECT (xml)->context->version < 6)
+ SWFDEC_FIXME ("Need to add undefined element to childNodes array");
+ }
+
+ g_return_val_if_fail (end > p, strchr (p, '\0'));
+
+ return end;
+}
+
+static const char *
+swfdec_xml_parse_comment (SwfdecXml *xml, const char *p)
+{
+ const char *end;
+
+ g_assert (p != NULL);
+ g_return_val_if_fail (strncmp (p, "<!--", strlen ("<!--")) == 0,
+ strchr (p, '\0'));
+ g_return_val_if_fail (SWFDEC_IS_XML (xml), strchr (p, '\0'));
+
+ end = strstr (p, "-->");
+
+ if (end == NULL) {
+ xml->status = XML_PARSE_STATUS_COMMENT_NOT_TERMINATED;
+ return strchr (p, '\0');
+ }
+
+ end += strlen("-->");
+
+ g_return_val_if_fail (end > p, strchr (p, '\0'));
+
+ return end;
+}
+
+static void
+swfdec_xml_add_id_map (SwfdecXml *xml, SwfdecXmlNode *node, const char *id)
+{
+ SwfdecAsObject *object;
+ SwfdecAsValue val;
+
+ g_return_if_fail (SWFDEC_IS_XML (xml));
+ g_return_if_fail (SWFDEC_IS_XML_NODE (xml));
+ g_return_if_fail (id != NULL && id != SWFDEC_AS_STR_EMPTY);
+
+ if (SWFDEC_AS_OBJECT (xml)->context->version >= 8) {
+ if (swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (xml),
+ SWFDEC_AS_STR_idMap, &val)) {
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
+ object = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+ } else {
+ return;
+ }
+ } else {
+ object = swfdec_as_object_new_empty (SWFDEC_AS_OBJECT (xml)->context);
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, object);
+ swfdec_as_object_set_variable (SWFDEC_AS_OBJECT (xml),
+ SWFDEC_AS_STR_idMap, &val);
+ }
+ } else {
+ object = SWFDEC_AS_OBJECT (xml);
+ }
+
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (node));
+ swfdec_as_object_set_variable (object, id, &val);
+}
+
+static const char *
+swfdec_xml_parse_attribute (SwfdecXml *xml, SwfdecXmlNode *node, const char *p)
+{
+ SwfdecAsValue val;
+ const char *end, *name;
+ char *text;
+
+ g_return_val_if_fail (SWFDEC_IS_XML (xml), strchr (p, '\0'));
+ g_return_val_if_fail (SWFDEC_IS_XML_NODE (node), strchr (p, '\0'));
+ g_return_val_if_fail ((*p != '>' && *p != '\0'), p);
+
+ end = p + strcspn (p, "=> \r\n\t");
+ if (end - p <= 0) {
+ xml->status = XML_PARSE_STATUS_ELEMENT_MALFORMED;
+ return strchr (p, '\0');
+ }
+
+ text = g_strndup (p, end - p);
+ name = swfdec_as_context_give_string (SWFDEC_AS_OBJECT (node)->context,
+ swfdec_xml_unescape (SWFDEC_AS_OBJECT (xml)->context, text));
+ g_free (text);
+
+ p = end + strspn (end, " \r\n\t");
+ if (*p != '=') {
+ xml->status = XML_PARSE_STATUS_ELEMENT_MALFORMED;
+ return strchr (p, '\0');
+ }
+ p = p + 1 + strspn (p + 1, " \r\n\t");
+
+ if (*p != '"' && *p != '\'') {
+ xml->status = XML_PARSE_STATUS_ELEMENT_MALFORMED;
+ return strchr (p, '\0');
+ }
+
+ end = p + 1;
+ do {
+ end = strchr (end, *p);
+ } while (end != NULL && *(end - 1) == '\\');
+
+ if (end == NULL) {
+ xml->status = XML_PARSE_STATUS_ATTRIBUTE_NOT_TERMINATED;
+ return strchr (p, '\0');
+ }
+
+ if (!swfdec_as_object_get_variable (node->attributes, name, NULL)) {
+ char *unescaped;
+ const char *value;
+
+ unescaped = swfdec_xml_unescape_len (SWFDEC_AS_OBJECT (xml)->context,
+ p + 1, end - (p + 1), TRUE);
+ value = swfdec_as_context_give_string (SWFDEC_AS_OBJECT (node)->context,
+ unescaped);
+ SWFDEC_AS_VALUE_SET_STRING (&val, value);
+
+ swfdec_as_object_set_variable (node->attributes, name, &val);
+ }
+
+ g_return_val_if_fail (end + 1 > p, strchr (p, '\0'));
+
+ return end + 1;
+}
+
+static const char *
+swfdec_xml_parse_tag (SwfdecXml *xml, SwfdecXmlNode **node, const char *p)
+{
+ SwfdecAsObject *object;
+ SwfdecXmlNode *child = NULL; // surpress warning
+ char *name;
+ const char *end;
+ gboolean close;
+
+ g_assert (p != NULL);
+ g_return_val_if_fail (*p == '<', strchr (p, '\0'));
+ g_return_val_if_fail (SWFDEC_IS_XML (xml), strchr (p, '\0'));
+
+ object = SWFDEC_AS_OBJECT (xml);
+
+ // closing tag or opening tag?
+ if (*(p + 1) == '/') {
+ close = TRUE;
+ p++;
+ } else {
+ close = FALSE;
+ }
+
+ // find the end of the name
+ end = p + strcspn (p, "> \r\n\t");
+
+ // don't count trailing / as part of the name if it's followed by >
+ // note we do this for close tags also, so <test/ ></test/> doesn't work
+ if (*end == '>' && *(end - 1) == '/')
+ end = end - 1;
+
+ if (end - (p + 1) <= 0 || *end == '\0') {
+ xml->status = XML_PARSE_STATUS_ELEMENT_MALFORMED;
+ return strchr (p, '\0');
+ }
+
+ name = g_strndup (p + 1 , end - (p + 1));
+
+ // create the new element
+ if (!close) {
+ child = swfdec_xml_node_new_no_properties (
+ SWFDEC_AS_OBJECT (*node)->context, SWFDEC_XML_NODE_ELEMENT,
+ swfdec_as_context_give_string (SWFDEC_AS_OBJECT (*node)->context,
+ name));
+ if (child == NULL)
+ return strchr (p, '\0');
+ }
+
+ if (close) {
+ end = strchr (end, '>');
+ if (end == NULL)
+ end = strchr (p, '\0');
+ } else {
+ end = end + strspn (end, " \r\n\t");
+ while (*end != '\0' && *end != '>' && (*end != '/' || *(end + 1) != '>')) {
+ end = swfdec_xml_parse_attribute (xml, child, end);
+ end = end + strspn (end, " \r\n\t");
+ }
+ if (*end == '/')
+ end += 1;
+ }
+
+ if (*end == '\0') {
+ if (xml->status == XML_PARSE_STATUS_OK)
+ xml->status = XML_PARSE_STATUS_ELEMENT_MALFORMED;
+ if (close)
+ g_free (name);
+ return end;
+ }
+
+ if (close) {
+ if ((*node)->parent != NULL && !g_ascii_strcasecmp ((*node)->name, name))
+ {
+ *node = (*node)->parent;
+ }
+ else // error
+ {
+ SwfdecXmlNode *iter = *node;
+ while (iter != NULL && (iter->name == NULL || g_ascii_strcasecmp (iter->name, name))) {
+ iter = iter->parent;
+ }
+ if (iter != NULL) {
+ xml->status = XML_PARSE_STATUS_TAG_NOT_CLOSED;
+ } else {
+ xml->status = XML_PARSE_STATUS_TAG_MISMATCH;
+ }
+ }
+ g_free (name);
+ } else {
+ const char *id;
+
+ swfdec_xml_node_appendChild (*node, child);
+
+ id = swfdec_xml_node_get_attribute (child, SWFDEC_AS_STR_id);
+ if (id != NULL)
+ swfdec_xml_add_id_map (xml, child, id);
+
+ if (*(end - 1) != '/')
+ *node = child;
+ }
+
+ end += 1;
+
+ g_return_val_if_fail (end > p, strchr (p, '\0'));
+
+ return end;
+}
+
+static const char *
+swfdec_xml_parse_text (SwfdecXml *xml, SwfdecXmlNode *node,
+ const char *p, gboolean ignore_white)
+{
+ SwfdecXmlNode *child;
+ const char *end;
+ char *text, *unescaped;
+
+ g_assert (p != NULL);
+ g_return_val_if_fail (*p != '\0', p);
+ g_return_val_if_fail (SWFDEC_IS_XML (xml), strchr (p, '\0'));
+
+ end = strchr (p, '<');
+ if (end == NULL)
+ end = strchr (p, '\0');
+
+ if (!ignore_white || strspn (p, " \t\r\n") < (gsize)(end - p))
+ {
+ text = g_strndup (p, end - p);
+ unescaped = swfdec_xml_unescape (SWFDEC_AS_OBJECT (xml)->context, text);
+ g_free (text);
+ child = swfdec_xml_node_new_no_properties (
+ SWFDEC_AS_OBJECT (node)->context, SWFDEC_XML_NODE_TEXT,
+ swfdec_as_context_give_string (SWFDEC_AS_OBJECT (xml)->context,
+ unescaped));
+ if (child == NULL)
+ return strchr (p, '\0');
+ swfdec_xml_node_appendChild (node, child);
+ }
+
+ g_return_val_if_fail (end > p, strchr (p, '\0'));
+
+ return end;
+}
+
+static void
+swfdec_xml_parseXML (SwfdecXml *xml, const char *value)
+{
+ SwfdecAsObject *object;
+ SwfdecXmlNode *node;
+ const char *p;
+ gboolean ignore_white;
+
+ g_return_if_fail (SWFDEC_IS_XML (xml));
+ g_return_if_fail (value != NULL);
+
+ object = SWFDEC_AS_OBJECT (xml);
+
+ swfdec_xml_node_removeChildren (SWFDEC_XML_NODE (xml));
+ xml->xml_decl = NULL;
+ xml->doc_type_decl = NULL;
+ xml->status = XML_PARSE_STATUS_OK;
+
+ p = value;
+ node = SWFDEC_XML_NODE (xml);
+
+ // special case: we only use the ignoreWhite set at the start
+ ignore_white = xml->ignore_white;
+
+ while (xml->status == XML_PARSE_STATUS_OK && *p != '\0') {
+ if (*p == '<') {
+ if (g_ascii_strncasecmp (p + 1, "?xml", strlen ("?xml")) == 0) {
+ p = swfdec_xml_parse_xmlDecl (xml, node, p);
+ } else if (g_ascii_strncasecmp (p + 1, "!DOCTYPE", strlen ("!DOCTYPE")) == 0) {
+ p = swfdec_xml_parse_docTypeDecl (xml, node, p);
+ } else if (strncmp (p + 1, "!--", strlen ("!--")) == 0) {
+ p = swfdec_xml_parse_comment (xml, p);
+ } else {
+ p = swfdec_xml_parse_tag (xml, &node, p);
+ }
+ } else {
+ p = swfdec_xml_parse_text (xml, node, p, ignore_white);
+ }
+ g_assert (p != NULL);
+ }
+
+ if (xml->status == XML_PARSE_STATUS_OK && node != SWFDEC_XML_NODE (xml))
+ xml->status = XML_PARSE_STATUS_TAG_NOT_CLOSED;
+}
+
+// this is an old XML parsing function that is only available trough the
+// ASnative code
+SWFDEC_AS_NATIVE (300, 0, swfdec_xml_do_oldParseXML)
+void
+swfdec_xml_do_oldParseXML (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SWFDEC_STUB ("XML.oldParseXML (not-really-named)");
+}
+
+SWFDEC_AS_NATIVE (253, 12, swfdec_xml_do_parseXML)
+void
+swfdec_xml_do_parseXML (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
+ SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ if (!SWFDEC_IS_XML (object))
+ return;
+
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ if (argc < 1)
+ return;
+
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
+ return;
+
+ swfdec_xml_parseXML (SWFDEC_XML (object),
+ swfdec_as_value_to_string (cx, &argv[0]));
+}
+
+SWFDEC_AS_NATIVE (253, 10, swfdec_xml_createElement)
+void
+swfdec_xml_createElement (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecXmlNode *node;
+
+ if (!SWFDEC_IS_XML (object))
+ return;
+
+ if (argc < 1)
+ return;
+
+ // special case
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
+ return;
+
+ node = swfdec_xml_node_new (cx, SWFDEC_XML_NODE_ELEMENT,
+ swfdec_as_value_to_string (cx, &argv[0]));
+ if (node == NULL)
+ return;
+
+ SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (node));
+}
+
+SWFDEC_AS_NATIVE (253, 11, swfdec_xml_createTextNode)
+void
+swfdec_xml_createTextNode (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecXmlNode *node;
+
+ if (!SWFDEC_IS_XML (object))
+ return;
+
+ if (argc < 1)
+ return;
+
+ // special case
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
+ return;
+
+ node = swfdec_xml_node_new (cx, SWFDEC_XML_NODE_TEXT,
+ swfdec_as_value_to_string (cx, &argv[0]));
+ if (node == NULL)
+ return;
+
+ SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (node));
+}
+
+static void
+swfdec_xml_init_properties (SwfdecAsContext *cx)
+{
+ SwfdecAsValue val;
+ SwfdecAsObject *xml, *proto;
+
+ // FIXME: We should only initialize if the prototype Object has not been
+ // initialized by any object's constructor with native properties
+ // (TextField, TextFormat, XML, XMLNode at least)
+
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (cx));
+
+ swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_XML, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return;
+ xml = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+
+ swfdec_as_object_get_variable (xml, SWFDEC_AS_STR_prototype, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return;
+ proto = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_ignoreWhite,
+ swfdec_xml_get_ignoreWhite, swfdec_xml_set_ignoreWhite);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_status,
+ swfdec_xml_get_status, swfdec_xml_set_status);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_xmlDecl,
+ swfdec_xml_get_xmlDecl, swfdec_xml_set_xmlDecl);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_docTypeDecl,
+ swfdec_xml_get_docTypeDecl, swfdec_xml_set_docTypeDecl);
+
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_contentType,
+ swfdec_xml_get_contentType, swfdec_xml_set_contentType);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_loaded,
+ swfdec_xml_get_loaded, swfdec_xml_set_loaded);
+}
+
+SWFDEC_AS_CONSTRUCTOR (253, 9, swfdec_xml_construct, swfdec_xml_get_type)
+void
+swfdec_xml_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!swfdec_as_context_is_constructing (cx))
+ return;
+
+ g_assert (SWFDEC_IS_XML (object));
+
+ swfdec_xml_init_properties (cx);
+
+ swfdec_xml_node_init_values (SWFDEC_XML_NODE (object),
+ SWFDEC_XML_NODE_ELEMENT, SWFDEC_AS_STR_EMPTY);
+
+ SWFDEC_AS_VALUE_SET_STRING (&SWFDEC_XML (object)->content_type,
+ SWFDEC_AS_STR_application_x_www_form_urlencoded);
+
+ SWFDEC_XML_NODE (object)->name = NULL;
+
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ if (argc >= 1 && !SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0])) {
+ swfdec_xml_parseXML (SWFDEC_XML (object),
+ swfdec_as_value_to_string (cx, &argv[0]));
+ }
+}
+
+SwfdecXml *
+swfdec_xml_new_no_properties (SwfdecAsContext *context, const char *str,
+ gboolean ignore_white)
+{
+ SwfdecAsValue val;
+ SwfdecXml *xml;
+ guint size;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
+
+ size = sizeof (SwfdecXml);
+ if (!swfdec_as_context_use_mem (context, size))
+ return NULL;
+ xml = g_object_new (SWFDEC_TYPE_XML, NULL);
+ swfdec_as_object_add (SWFDEC_AS_OBJECT (xml), context, size);
+ swfdec_as_object_get_variable (context->global, SWFDEC_AS_STR_XML, &val);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
+ swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (xml),
+ SWFDEC_AS_VALUE_GET_OBJECT (&val));
+ }
+
+ xml->ignore_white = ignore_white;
+
+ swfdec_xml_node_init_values (SWFDEC_XML_NODE (xml),
+ SWFDEC_XML_NODE_ELEMENT, SWFDEC_AS_STR_EMPTY);
+
+ SWFDEC_AS_VALUE_SET_STRING (&xml->content_type,
+ SWFDEC_AS_STR_application_x_www_form_urlencoded);
+
+ if (str != NULL)
+ swfdec_xml_parseXML (xml, str);
+
+ return xml;
+}
+
+SwfdecXml *
+swfdec_xml_new (SwfdecAsContext *context, const char *str,
+ gboolean ignore_white)
+{
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
+
+ swfdec_xml_init_properties (context);
+
+ return swfdec_xml_new_no_properties (context, str, ignore_white);
+}
diff --git a/swfdec/swfdec_xml.h b/swfdec/swfdec_xml.h
new file mode 100644
index 0000000..3be92d5
--- /dev/null
+++ b/swfdec/swfdec_xml.h
@@ -0,0 +1,90 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_XML_H_
+#define _SWFDEC_XML_H_
+
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_types.h>
+#include <libswfdec/swfdec_script.h>
+#include <libswfdec/swfdec_xml_node.h>
+
+G_BEGIN_DECLS
+
+typedef struct _SwfdecXml SwfdecXml;
+typedef struct _SwfdecXmlClass SwfdecXmlClass;
+
+#define SWFDEC_TYPE_XML (swfdec_xml_get_type())
+#define SWFDEC_IS_XML(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_XML))
+#define SWFDEC_IS_XML_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_XML))
+#define SWFDEC_XML(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_XML, SwfdecXml))
+#define SWFDEC_XML_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_XML, SwfdecXmlClass))
+#define SWFDEC_XML_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_XML, SwfdecXmlClass))
+
+typedef enum {
+ XML_PARSE_STATUS_OK = 0,
+ XML_PARSE_STATUS_CDATA_NOT_TERMINATED = -2,
+ XML_PARSE_STATUS_XMLDECL_NOT_TERMINATED = -3,
+ XML_PARSE_STATUS_DOCTYPEDECL_NOT_TERMINATED = -4,
+ XML_PARSE_STATUS_COMMENT_NOT_TERMINATED = -5,
+ XML_PARSE_STATUS_ELEMENT_MALFORMED = -6,
+ XML_PARSE_STATUS_OUT_OF_MEMORY = -7,
+ XML_PARSE_STATUS_ATTRIBUTE_NOT_TERMINATED = -8,
+ XML_PARSE_STATUS_TAG_NOT_CLOSED = -9, // FIXME are the two correct?
+ XML_PARSE_STATUS_TAG_MISMATCH = -10
+} SwfdecXmlParseStatus;
+
+struct _SwfdecXml {
+ SwfdecXmlNode xml_node;
+
+ gboolean ignore_white;
+ int status;
+ const char *xml_decl;
+ const char *doc_type_decl;
+
+ SwfdecAsValue content_type;
+ SwfdecAsValue loaded;
+};
+
+struct _SwfdecXmlClass {
+ SwfdecXmlNodeClass xml_node_class;
+};
+
+GType swfdec_xml_get_type (void);
+
+char * swfdec_xml_escape (const char * orginal);
+char * swfdec_xml_escape_len (const char * orginal,
+ gssize length);
+char * swfdec_xml_unescape (SwfdecAsContext * cx,
+ const char * orginal);
+char * swfdec_xml_unescape_len (SwfdecAsContext * cx,
+ const char * orginal,
+ gssize length,
+ gboolean unescape_nbsp);
+
+SwfdecXml * swfdec_xml_new (SwfdecAsContext * context,
+ const char * str,
+ gboolean ignore_white);
+SwfdecXml * swfdec_xml_new_no_properties (SwfdecAsContext * context,
+ const char * str,
+ gboolean ignore_white);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_xml_node.c b/swfdec/swfdec_xml_node.c
new file mode 100644
index 0000000..b0d35aa
--- /dev/null
+++ b/swfdec/swfdec_xml_node.c
@@ -0,0 +1,1113 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+
+#include "swfdec_xml_node.h"
+#include "swfdec_xml.h"
+#include "swfdec_as_array.h"
+#include "swfdec_as_native_function.h"
+#include "swfdec_as_object.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_debug.h"
+#include "swfdec_internal.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_load_object.h"
+#include "swfdec_player_internal.h"
+
+G_DEFINE_TYPE (SwfdecXmlNode, swfdec_xml_node, SWFDEC_TYPE_AS_OBJECT)
+
+static void
+swfdec_xml_node_do_mark (SwfdecAsObject *object)
+{
+ SwfdecXmlNode *node = SWFDEC_XML_NODE (object);
+
+ if (node->name != NULL)
+ swfdec_as_string_mark (node->name);
+ if (node->value != NULL)
+ swfdec_as_string_mark (node->value);
+ if (node->parent != NULL)
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (node->parent));
+ if (node->children != NULL)
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (node->children));
+ if (node->attributes != NULL)
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (node->attributes));
+ if (node->child_nodes != NULL)
+ swfdec_as_object_mark (SWFDEC_AS_OBJECT (node->child_nodes));
+
+ SWFDEC_AS_OBJECT_CLASS (swfdec_xml_node_parent_class)->mark (object);
+}
+
+static void
+swfdec_xml_node_class_init (SwfdecXmlNodeClass *klass)
+{
+ SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (klass);
+
+ asobject_class->mark = swfdec_xml_node_do_mark;
+}
+
+static void
+swfdec_xml_node_init (SwfdecXmlNode *xml_node)
+{
+}
+
+/*** AS CODE ***/
+
+gint32
+swfdec_xml_node_num_children (SwfdecXmlNode *node)
+{
+ g_return_val_if_fail (SWFDEC_IS_VALID_XML_NODE (node), 0);
+
+ return swfdec_as_array_get_length (node->children);
+}
+
+SwfdecXmlNode *
+swfdec_xml_node_get_child (SwfdecXmlNode *node, gint32 index_)
+{
+ SwfdecAsValue val;
+
+ g_return_val_if_fail (SWFDEC_IS_VALID_XML_NODE (node), NULL);
+ g_return_val_if_fail (index_ >= 0, NULL);
+
+ if (index_ >= swfdec_xml_node_num_children (node))
+ return NULL;
+
+ swfdec_as_array_get_value (node->children, index_, &val);
+
+ g_return_val_if_fail (SWFDEC_AS_VALUE_IS_OBJECT (&val), NULL);
+ g_return_val_if_fail (SWFDEC_IS_VALID_XML_NODE (
+ SWFDEC_AS_VALUE_GET_OBJECT (&val)), NULL);
+
+ return SWFDEC_XML_NODE (SWFDEC_AS_VALUE_GET_OBJECT (&val));
+}
+
+static gint32
+swfdec_xml_node_index_of_child (SwfdecXmlNode *node, SwfdecXmlNode *child)
+{
+ gint32 num, i;
+
+ g_return_val_if_fail (SWFDEC_IS_VALID_XML_NODE (node), -1);
+ g_return_val_if_fail (SWFDEC_IS_VALID_XML_NODE (child), -1);
+
+ num = swfdec_xml_node_num_children (node);
+ for (i = 0; i < num; i++) {
+ if (swfdec_xml_node_get_child (node, i) == child)
+ return i;
+ }
+
+ return -1;
+}
+
+static void
+swfdec_xml_node_update_child_nodes (SwfdecXmlNode *node)
+{
+ SwfdecAsValue val;
+ SwfdecAsValue *vals;
+ gint32 num, i;
+
+ g_return_if_fail (SWFDEC_IS_VALID_XML_NODE (node));
+
+ // remove old
+ SWFDEC_AS_VALUE_SET_INT (&val, 0);
+ swfdec_as_object_set_variable (SWFDEC_AS_OBJECT (node->child_nodes),
+ SWFDEC_AS_STR_length, &val);
+
+ // add everything
+ num = swfdec_xml_node_num_children (node);
+ vals = g_malloc (sizeof (SwfdecAsValue) * num);
+ for (i = 0; i < num; i++) {
+ SWFDEC_AS_VALUE_SET_OBJECT (&vals[i],
+ SWFDEC_AS_OBJECT (swfdec_xml_node_get_child (node, i)));
+ }
+ swfdec_as_array_append_with_flags (node->child_nodes, num, vals,
+ SWFDEC_AS_VARIABLE_CONSTANT);
+ g_free (vals);
+}
+
+const char *
+swfdec_xml_node_get_attribute (SwfdecXmlNode *node, const char *name)
+{
+ SwfdecAsValue val;
+
+ g_return_val_if_fail (SWFDEC_IS_VALID_XML_NODE (node), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+
+ if (swfdec_as_object_get_variable (node->attributes, name, &val)) {
+ return swfdec_as_value_to_string (SWFDEC_AS_OBJECT (node)->context, &val);
+ } else {
+ return NULL;
+ }
+}
+
+static const char *
+swfdec_xml_node_getNamespaceForPrefix (SwfdecXmlNode *node, const char *prefix)
+{
+ const char *var;
+ SwfdecAsValue val;
+
+ g_return_val_if_fail (SWFDEC_IS_VALID_XML_NODE (node), NULL);
+
+ if (prefix == NULL || strlen (prefix) == 0) {
+ var = swfdec_as_context_get_string (SWFDEC_AS_OBJECT (node)->context,
+ "xmlns");
+ } else {
+ var = swfdec_as_context_give_string (SWFDEC_AS_OBJECT (node)->context,
+ g_strconcat ("xmlns:", prefix, NULL));
+ }
+
+ do {
+ swfdec_as_object_get_variable (node->attributes, var, &val);
+ if (!SWFDEC_AS_VALUE_IS_UNDEFINED (&val)) {
+ return swfdec_as_value_to_string (SWFDEC_AS_OBJECT (node)->context, &val);
+ }
+ node = node->parent;
+ } while (node != NULL);
+
+ return NULL;
+}
+
+typedef struct {
+ const char *namespace;
+ const char *variable;
+} ForeachFindNamespaceData;
+
+static gboolean
+swfdec_xml_node_foreach_find_namespace (SwfdecAsObject *object,
+ const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
+{
+ const char *uri;
+ ForeachFindNamespaceData *fdata = data;
+
+ // check whether it's namespace variable (xmlns or xmlns:*)
+ if (strlen (variable) < strlen("xmlns"))
+ return TRUE;
+
+ if (g_ascii_strncasecmp (variable, "xmlns", strlen("xmlns")))
+ return TRUE;
+
+ if (variable[strlen("xmlns")] != '\0' && variable[strlen("xmlns")] != ':')
+ return TRUE;
+
+ // ok, now check if the uri is the one we are searching for
+ uri = swfdec_as_value_to_string (object->context, value);
+ if (!g_ascii_strcasecmp (uri, fdata->namespace)) {
+ fdata->variable = variable;
+ return FALSE;
+ } else {
+ return TRUE;
+ }
+}
+
+static const char *
+swfdec_xml_node_getPrefixForNamespace (SwfdecXmlNode *node,
+ const char *namespace)
+{
+ ForeachFindNamespaceData fdata;
+
+ g_return_val_if_fail (SWFDEC_IS_VALID_XML_NODE (node), NULL);
+ g_return_val_if_fail (namespace != NULL, NULL);
+
+ fdata.namespace = namespace;
+ fdata.variable = NULL;
+
+ do {
+ swfdec_as_object_foreach (node->attributes,
+ swfdec_xml_node_foreach_find_namespace, &fdata);
+ node = node->parent;
+ } while (node != NULL && fdata.variable == NULL);
+
+ if (fdata.variable != NULL) {
+ const char *p;
+
+ p = strchr (fdata.variable, ':');
+ if (p == NULL || *(p + 1) == '\0')
+ return SWFDEC_AS_STR_EMPTY;
+
+ return swfdec_as_context_get_string (SWFDEC_AS_OBJECT (node)->context,
+ p + 1);
+ } else {
+ return NULL;
+ }
+}
+
+static void
+swfdec_xml_node_get_nodeType (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ SWFDEC_AS_VALUE_SET_INT (ret, SWFDEC_XML_NODE (object)->type);
+}
+
+static void
+swfdec_xml_node_get_nodeValue (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ if (SWFDEC_XML_NODE (object)->value != NULL) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_XML_NODE (object)->value);
+ } else {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ }
+}
+
+static void
+swfdec_xml_node_set_nodeValue (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *value;
+
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ if (argc < 1)
+ return;
+
+ value = swfdec_as_value_to_string (cx, &argv[0]);
+
+ SWFDEC_XML_NODE (object)->value = value;
+ SWFDEC_AS_VALUE_SET_STRING (ret, value);
+}
+
+static void
+swfdec_xml_node_get_nodeName (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ if (SWFDEC_XML_NODE (object)->name != NULL) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_XML_NODE (object)->name);
+ } else {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ }
+}
+
+static void
+swfdec_xml_node_set_nodeName (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *name;
+
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ if (argc < 1)
+ return;
+
+ // special case
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]))
+ return;
+
+ name = swfdec_as_value_to_string (cx, &argv[0]);
+
+ SWFDEC_XML_NODE (object)->name = name;
+ SWFDEC_AS_VALUE_SET_STRING (ret, name);
+}
+
+static const char *
+swfdec_xml_node_get_prefix (SwfdecXmlNode *node)
+{
+ const char *p;
+
+ g_return_val_if_fail (SWFDEC_IS_VALID_XML_NODE (node), NULL);
+
+ if (node->name == NULL)
+ return NULL;
+
+ p = strchr (node->name, ':');
+ if (p == NULL || *(p + 1) == '\0')
+ return NULL;
+
+ return swfdec_as_context_give_string (SWFDEC_AS_OBJECT (node)->context,
+ g_strndup (node->name, p - node->name));
+}
+
+static void
+swfdec_xml_node_do_get_prefix (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *prefix;
+
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ if (SWFDEC_XML_NODE (object)->name == NULL) {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ return;
+ }
+
+ prefix = swfdec_xml_node_get_prefix (SWFDEC_XML_NODE (object));
+ if (prefix != NULL) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, prefix);
+ } else {
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_EMPTY);
+ }
+}
+
+static void
+swfdec_xml_node_get_localName (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *p, *name;
+
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ if (SWFDEC_XML_NODE (object)->name == NULL) {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ return;
+ }
+
+ name = SWFDEC_XML_NODE (object)->name;
+ p = strchr (name, ':');
+ if (p == NULL || *(p + 1) == '\0') {
+ SWFDEC_AS_VALUE_SET_STRING (ret, name);
+ return;
+ }
+ p++;
+
+ SWFDEC_AS_VALUE_SET_STRING (ret,
+ swfdec_as_context_give_string (cx, g_strdup (p)));
+}
+
+static void
+swfdec_xml_node_get_namespaceURI (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *uri;
+
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ if (SWFDEC_XML_NODE (object)->name == NULL) {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ return;
+ }
+
+ uri = swfdec_xml_node_getNamespaceForPrefix (SWFDEC_XML_NODE (object),
+ swfdec_xml_node_get_prefix (SWFDEC_XML_NODE (object)));
+ if (uri != NULL) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, uri);
+ } else {
+ SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_EMPTY);
+ }
+}
+
+static void
+swfdec_xml_node_get_attributes (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_XML_NODE (object)->attributes);
+}
+
+static void
+swfdec_xml_node_get_parentNode (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ if (SWFDEC_XML_NODE (object)->parent != NULL) {
+ SWFDEC_AS_VALUE_SET_OBJECT (ret,
+ SWFDEC_AS_OBJECT (SWFDEC_XML_NODE (object)->parent));
+ } else {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ }
+}
+
+static SwfdecXmlNode *
+swfdec_xml_node_previousSibling (SwfdecXmlNode *node)
+{
+ gint32 i;
+
+ if (node->parent == NULL)
+ return NULL;
+
+ i = swfdec_xml_node_index_of_child (node->parent, node);
+ g_assert (i >= 0);
+
+ if (i <= 0)
+ return NULL;
+
+ return swfdec_xml_node_get_child (node->parent, i - 1);
+}
+
+static void
+swfdec_xml_node_get_previousSibling (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecXmlNode *sibling;
+
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ sibling = swfdec_xml_node_previousSibling (SWFDEC_XML_NODE (object));
+ if (sibling != NULL) {
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (sibling));
+ } else {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ }
+}
+
+static SwfdecXmlNode *
+swfdec_xml_node_nextSibling (SwfdecXmlNode *node)
+{
+ gint32 i;
+
+ if (node->parent == NULL)
+ return NULL;
+
+ i = swfdec_xml_node_index_of_child (node->parent, node);
+ g_assert (i >= 0);
+
+ return swfdec_xml_node_get_child (node->parent, i + 1);
+}
+
+static void
+swfdec_xml_node_get_nextSibling (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecXmlNode *sibling;
+
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ sibling = swfdec_xml_node_nextSibling (SWFDEC_XML_NODE (object));
+ if (sibling != NULL) {
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (sibling));
+ } else {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ }
+}
+
+static void
+swfdec_xml_node_get_firstChild (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecXmlNode *child;
+
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ child = swfdec_xml_node_get_child (SWFDEC_XML_NODE (object), 0);
+ if (child != NULL) {
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (child));
+ } else {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ }
+}
+
+static void
+swfdec_xml_node_get_lastChild (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ gint32 num;
+ SwfdecXmlNode *child;
+
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ num = swfdec_xml_node_num_children (SWFDEC_XML_NODE (object));
+ if (num == 0) {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ return;
+ }
+
+ child = swfdec_xml_node_get_child (SWFDEC_XML_NODE (object), num - 1);
+ g_assert (child != NULL);
+
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (child));
+}
+
+static void
+swfdec_xml_node_get_childNodes (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ SWFDEC_AS_VALUE_SET_OBJECT (ret,
+ SWFDEC_AS_OBJECT (SWFDEC_XML_NODE (object)->child_nodes));
+}
+
+SWFDEC_AS_NATIVE (253, 7, swfdec_xml_node_do_getNamespaceForPrefix)
+void
+swfdec_xml_node_do_getNamespaceForPrefix (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *namespace;
+
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ if (argc < 1) {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ return;
+ }
+
+ namespace = swfdec_xml_node_getNamespaceForPrefix (SWFDEC_XML_NODE (object),
+ swfdec_as_value_to_string (cx, &argv[0]));
+
+ if (namespace != NULL) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, namespace);
+ } else {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ }
+}
+
+SWFDEC_AS_NATIVE (253, 8, swfdec_xml_node_do_getPrefixForNamespace)
+void
+swfdec_xml_node_do_getPrefixForNamespace (SwfdecAsContext *cx,
+ SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *prefix;
+
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ if (argc < 1) {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ return;
+ }
+
+ prefix = swfdec_xml_node_getPrefixForNamespace (SWFDEC_XML_NODE (object),
+ swfdec_as_value_to_string (cx, &argv[0]));
+
+ if (prefix != NULL) {
+ SWFDEC_AS_VALUE_SET_STRING (ret, prefix);
+ } else {
+ SWFDEC_AS_VALUE_SET_NULL (ret);
+ }
+}
+
+static gboolean
+swfdec_xml_node_foreach_copy_attributes (SwfdecAsObject *object,
+ const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
+{
+ SwfdecAsObject *target = data;
+ swfdec_as_object_set_variable (target, variable, value);
+ return TRUE;
+}
+
+static void
+swfdec_xml_node_copy_attributes (SwfdecXmlNode *node, SwfdecXmlNode *target)
+{
+ swfdec_as_object_foreach (node->attributes,
+ swfdec_xml_node_foreach_copy_attributes, target->attributes);
+}
+
+static SwfdecXmlNode *
+swfdec_xml_node_clone (SwfdecAsContext *cx, SwfdecXmlNode *node, gboolean deep)
+{
+ SwfdecXmlNode *new;
+
+ g_assert (SWFDEC_IS_AS_CONTEXT (cx));
+ g_assert (SWFDEC_IS_VALID_XML_NODE (node));
+
+ new = swfdec_xml_node_new (cx, SWFDEC_XML_NODE_ELEMENT, SWFDEC_AS_STR_EMPTY);
+ if (new == NULL)
+ return NULL;
+
+ new->valid = TRUE;
+ new->type = node->type;
+ new->name = node->name;
+ new->value = node->value;
+
+ swfdec_xml_node_copy_attributes (node, new);
+
+ if (deep) {
+ SwfdecAsValue val;
+ SwfdecXmlNode *child, *child_new;
+ gint32 num, i;
+
+ num = swfdec_xml_node_num_children (node);
+
+ for (i = 0; i < num; i++) {
+ child = swfdec_xml_node_get_child (node, i);
+ child_new = swfdec_xml_node_clone (cx, child, TRUE);
+ if (child_new == NULL)
+ return NULL;
+ child_new->parent = new;
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (child_new));
+ swfdec_as_array_push (new->children, &val);
+ }
+
+ swfdec_xml_node_update_child_nodes (new);
+ }
+
+ return new;
+}
+
+SWFDEC_AS_NATIVE (253, 1, swfdec_xml_node_cloneNode)
+void
+swfdec_xml_node_cloneNode (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ gboolean deep;
+ SwfdecXmlNode *new;
+
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ if (argc >= 1) {
+ deep = swfdec_as_value_to_boolean (cx, &argv[0]);
+ } else {
+ deep = FALSE;
+ }
+
+ new = swfdec_xml_node_clone (cx, SWFDEC_XML_NODE (object), deep);
+ if (new == NULL)
+ return;
+
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, SWFDEC_AS_OBJECT (new));
+}
+
+void
+swfdec_xml_node_removeNode (SwfdecXmlNode *node)
+{
+ gint32 i;
+
+ g_return_if_fail (SWFDEC_IS_VALID_XML_NODE (node));
+
+ if (node->parent == NULL)
+ return;
+
+ i = swfdec_xml_node_index_of_child (node->parent, node);
+ g_assert (i >= 0);
+
+ swfdec_as_array_remove (node->parent->children, i);
+ swfdec_xml_node_update_child_nodes (node->parent);
+ node->parent = NULL;
+}
+
+SWFDEC_AS_NATIVE (253, 2, swfdec_xml_node_do_removeNode)
+void
+swfdec_xml_node_do_removeNode (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ swfdec_xml_node_removeNode (SWFDEC_XML_NODE (object));
+}
+
+void
+swfdec_xml_node_removeChildren (SwfdecXmlNode *node)
+{
+ gint32 num, i;
+
+ g_return_if_fail (SWFDEC_IS_VALID_XML_NODE (node));
+
+ num = swfdec_xml_node_num_children (node);
+
+ for (i = 0; i < num; i++) {
+ swfdec_xml_node_removeNode (swfdec_xml_node_get_child (node, 0));
+ }
+}
+
+static void
+swfdec_xml_node_insertAt (SwfdecXmlNode *node, SwfdecXmlNode *child, gint32 ind)
+{
+ SwfdecAsValue val;
+
+ g_assert (SWFDEC_IS_VALID_XML_NODE (node));
+ g_assert (SWFDEC_IS_VALID_XML_NODE (child));
+ g_assert (ind >= 0);
+
+ if (SWFDEC_AS_OBJECT (node)->context->version >= 8) {
+ SwfdecXmlNode *parent = node;
+ while (parent != NULL) {
+ if (parent == child)
+ return;
+ parent = parent->parent;
+ }
+ }
+
+ // remove the previous parent of the child
+ swfdec_xml_node_removeNode (child);
+
+ // insert child to node's child_nodes array
+ SWFDEC_AS_VALUE_SET_OBJECT (&val, SWFDEC_AS_OBJECT (child));
+ swfdec_as_array_insert (node->children, ind, &val);
+ swfdec_xml_node_update_child_nodes (node);
+
+ // set node as parent of child
+ child->parent = node;
+}
+
+SWFDEC_AS_NATIVE (253, 3, swfdec_xml_node_insertBefore)
+void
+swfdec_xml_node_insertBefore (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ gint32 i;
+ SwfdecAsObject *child, *point;
+
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ if (argc < 2)
+ return;
+
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]))
+ return;
+
+ child = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
+ if (!SWFDEC_IS_VALID_XML_NODE (child))
+ return;
+
+ // special case
+ if (swfdec_xml_node_index_of_child (SWFDEC_XML_NODE (object),
+ SWFDEC_XML_NODE (child)) != -1)
+ return;
+
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[1]))
+ return;
+
+ point = SWFDEC_AS_VALUE_GET_OBJECT (&argv[1]);
+ if (!SWFDEC_IS_VALID_XML_NODE (point))
+ return;
+
+ i = swfdec_xml_node_index_of_child (SWFDEC_XML_NODE (object),
+ SWFDEC_XML_NODE (point));
+
+ if (i != -1) {
+ swfdec_xml_node_insertAt (SWFDEC_XML_NODE (object),
+ SWFDEC_XML_NODE (child), i);
+ }
+}
+
+void
+swfdec_xml_node_appendChild (SwfdecXmlNode *node, SwfdecXmlNode *child)
+{
+ g_return_if_fail (SWFDEC_IS_VALID_XML_NODE (node));
+ g_return_if_fail (SWFDEC_IS_VALID_XML_NODE (child));
+ g_return_if_fail (node->children != NULL);
+
+ swfdec_xml_node_insertAt (node, child,
+ swfdec_as_array_get_length (node->children));
+}
+
+SWFDEC_AS_NATIVE (253, 4, swfdec_xml_node_do_appendChild)
+void
+swfdec_xml_node_do_appendChild (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SwfdecAsObject *child;
+
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ if (argc < 1)
+ return;
+
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]))
+ return;
+
+ child = SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]);
+ if (!SWFDEC_IS_VALID_XML_NODE (child))
+ return;
+
+ // special case
+ if (swfdec_xml_node_index_of_child (SWFDEC_XML_NODE (object),
+ SWFDEC_XML_NODE (child)) != -1)
+ return;
+
+ swfdec_xml_node_appendChild (SWFDEC_XML_NODE (object),
+ SWFDEC_XML_NODE (child));
+}
+
+SWFDEC_AS_NATIVE (253, 5, swfdec_xml_node_hasChildNodes)
+void
+swfdec_xml_node_hasChildNodes (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ if (swfdec_xml_node_num_children (SWFDEC_XML_NODE (object)) > 0) {
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, TRUE);
+ } else {
+ SWFDEC_AS_VALUE_SET_BOOLEAN (ret, FALSE);
+ }
+}
+
+static gboolean
+swfdec_xml_node_foreach_string_append_attribute (SwfdecAsObject *object,
+ const char *variable, SwfdecAsValue *value, guint flags, gpointer data)
+{
+ GString *string = *(GString **)data;
+ char *escaped;
+
+ string = g_string_append (string, " ");
+ string = g_string_append (string, variable);
+ string = g_string_append (string, "=\"");
+ escaped =
+ swfdec_xml_escape (swfdec_as_value_to_string (object->context, value));
+ string = g_string_append (string, escaped);
+ g_free (escaped);
+ string = g_string_append (string, "\"");
+
+ return TRUE;
+}
+
+static const char *
+swfdec_xml_node_toString (SwfdecXmlNode *node)
+{
+ GString *string;
+ SwfdecAsObject *object;
+
+ g_assert (SWFDEC_IS_VALID_XML_NODE (node));
+
+ object = SWFDEC_AS_OBJECT (node);
+
+ string = g_string_new ("");
+ if (SWFDEC_IS_XML (node)) {
+ if (SWFDEC_XML (node)->xml_decl != NULL)
+ string = g_string_append (string, SWFDEC_XML (node)->xml_decl);
+ if (SWFDEC_XML (node)->doc_type_decl != NULL)
+ string = g_string_append (string, SWFDEC_XML (node)->doc_type_decl);
+ }
+
+ switch (node->type) {
+ case SWFDEC_XML_NODE_ELEMENT:
+ {
+ SwfdecXmlNode *child;
+ gint32 i, num;
+ gboolean visible;
+
+ if (node->name == NULL) {
+ visible = FALSE;
+ } else {
+ visible = TRUE;
+ }
+
+ if (visible) {
+ string = g_string_append (string, "<");
+ string = g_string_append (string, node->name);
+
+ swfdec_as_object_foreach (node->attributes,
+ swfdec_xml_node_foreach_string_append_attribute, &string);
+ }
+
+ num = swfdec_xml_node_num_children (node);
+
+ if (num > 0) {
+ if (visible)
+ string = g_string_append (string, ">");
+
+ for (i = 0; i < num; i++) {
+ child = swfdec_xml_node_get_child (node, i);
+ g_assert (child != NULL);
+ string = g_string_append (string, swfdec_xml_node_toString (child));
+ }
+
+ if (visible) {
+ string = g_string_append (string, "</");
+ string = g_string_append (string, node->name);
+ string = g_string_append (string, ">");
+ }
+ } else {
+ if (visible)
+ string = g_string_append (string, " />");
+ }
+
+ break;
+ }
+ case SWFDEC_XML_NODE_TEXT:
+ default:
+ {
+ char *escaped = swfdec_xml_escape (node->value);
+ string = g_string_append (string, escaped);
+ g_free (escaped);
+ break;
+ }
+ }
+
+ return swfdec_as_context_give_string (object->context,
+ g_string_free (string, FALSE));
+}
+
+SWFDEC_AS_NATIVE (253, 6, swfdec_xml_node_do_toString)
+void
+swfdec_xml_node_do_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!SWFDEC_IS_VALID_XML_NODE (object))
+ return;
+
+ SWFDEC_AS_VALUE_SET_STRING (ret,
+ swfdec_xml_node_toString (SWFDEC_XML_NODE (object)));
+}
+
+void
+swfdec_xml_node_init_values (SwfdecXmlNode *node, int type, const char* value)
+{
+ SwfdecAsObject *object;
+
+ g_return_if_fail (SWFDEC_IS_XML_NODE (node));
+ g_return_if_fail (value != NULL);
+
+ object = SWFDEC_AS_OBJECT (node);
+
+ node->valid = TRUE;
+ node->parent = NULL;
+ node->children = SWFDEC_AS_ARRAY (swfdec_as_array_new (object->context));
+ node->attributes = swfdec_as_object_new_empty (object->context);
+ node->type = type;
+ if (node->type == SWFDEC_XML_NODE_ELEMENT) {
+ node->name = value;
+ } else {
+ node->value = value;
+ }
+
+ node->child_nodes = SWFDEC_AS_ARRAY (swfdec_as_array_new (object->context));
+
+ if (node->children == NULL || node->attributes == NULL ||
+ node->child_nodes == NULL) {
+ node->valid = FALSE;
+ }
+}
+
+static void
+swfdec_xml_node_init_properties (SwfdecAsContext *cx)
+{
+ SwfdecAsValue val;
+ SwfdecAsObject *node, *proto;
+
+ // FIXME: We should only initialize if the prototype Object has not been
+ // initialized by any object's constructor with native properties
+ // (TextField, TextFormat, XML, XMLNode at least)
+
+ g_return_if_fail (SWFDEC_IS_AS_CONTEXT (cx));
+
+ swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_XMLNode, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return;
+ node = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+
+ swfdec_as_object_get_variable (node, SWFDEC_AS_STR_prototype, &val);
+ if (!SWFDEC_AS_VALUE_IS_OBJECT (&val))
+ return;
+ proto = SWFDEC_AS_VALUE_GET_OBJECT (&val);
+
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_nodeType,
+ swfdec_xml_node_get_nodeType, NULL);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_nodeValue,
+ swfdec_xml_node_get_nodeValue, swfdec_xml_node_set_nodeValue);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_nodeName,
+ swfdec_xml_node_get_nodeName, swfdec_xml_node_set_nodeName);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_prefix,
+ swfdec_xml_node_do_get_prefix, NULL);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_localName,
+ swfdec_xml_node_get_localName, NULL);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_namespaceURI,
+ swfdec_xml_node_get_namespaceURI, NULL);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_attributes,
+ swfdec_xml_node_get_attributes, NULL);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_parentNode,
+ swfdec_xml_node_get_parentNode, NULL);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_previousSibling,
+ swfdec_xml_node_get_previousSibling, NULL);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_nextSibling,
+ swfdec_xml_node_get_nextSibling, NULL);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_firstChild,
+ swfdec_xml_node_get_firstChild, NULL);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_lastChild,
+ swfdec_xml_node_get_lastChild, NULL);
+ swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_childNodes,
+ swfdec_xml_node_get_childNodes, NULL);
+}
+
+SwfdecXmlNode *
+swfdec_xml_node_new_no_properties (SwfdecAsContext *context,
+ SwfdecXmlNodeType type, const char* value)
+{
+ SwfdecAsValue val;
+ SwfdecXmlNode *node;
+ guint size;
+
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
+ g_return_val_if_fail (value != NULL, NULL);
+
+ size = sizeof (SwfdecXmlNode);
+ if (!swfdec_as_context_use_mem (context, size))
+ return NULL;
+ node = g_object_new (SWFDEC_TYPE_XML_NODE, NULL);
+ swfdec_as_object_add (SWFDEC_AS_OBJECT (node), context, size);
+ swfdec_as_object_get_variable (context->global, SWFDEC_AS_STR_XMLNode, &val);
+ if (SWFDEC_AS_VALUE_IS_OBJECT (&val)) {
+ swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (node),
+ SWFDEC_AS_VALUE_GET_OBJECT (&val));
+ }
+
+ swfdec_xml_node_init_values (node, type, value);
+
+ return node;
+}
+
+SwfdecXmlNode *
+swfdec_xml_node_new (SwfdecAsContext *context, SwfdecXmlNodeType type,
+ const char* value)
+{
+ g_return_val_if_fail (SWFDEC_IS_AS_CONTEXT (context), NULL);
+
+ swfdec_xml_node_init_properties (context);
+
+ return swfdec_xml_node_new_no_properties (context, type, value);
+}
+
+SWFDEC_AS_CONSTRUCTOR (253, 0, swfdec_xml_node_construct, swfdec_xml_node_get_type)
+void
+swfdec_xml_node_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ if (!swfdec_as_context_is_constructing (cx))
+ return;
+
+ g_assert (SWFDEC_IS_XML_NODE (object));
+
+ if (argc < 2)
+ return;
+
+ // special case
+ if (SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[0]) ||
+ SWFDEC_AS_VALUE_IS_UNDEFINED (&argv[1]))
+ return;
+
+ swfdec_xml_node_init_properties (cx);
+
+ swfdec_xml_node_init_values (SWFDEC_XML_NODE (object),
+ swfdec_as_value_to_integer (cx, &argv[0]),
+ swfdec_as_value_to_string (cx, &argv[1]));
+
+ SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
+}
diff --git a/swfdec/swfdec_xml_node.h b/swfdec/swfdec_xml_node.h
new file mode 100644
index 0000000..7135613
--- /dev/null
+++ b/swfdec/swfdec_xml_node.h
@@ -0,0 +1,103 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ * 2007 Pekka Lampila <pekka.lampila at iki.fi>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_XML_NODE_H_
+#define _SWFDEC_XML_NODE_H_
+
+#include <libswfdec/swfdec_as_object.h>
+#include <libswfdec/swfdec_types.h>
+#include <libswfdec/swfdec_script.h>
+#include <libswfdec/swfdec_player.h>
+
+G_BEGIN_DECLS
+
+typedef enum {
+ SWFDEC_XML_NODE_ELEMENT = 1,
+ SWFDEC_XML_NODE_ATTRIBUTE = 2,
+ SWFDEC_XML_NODE_TEXT = 3,
+ SWFDEC_XML_NODE_CDATA_SECTION = 4,
+ SWFDEC_XML_NODE_ENTITY_REFERENCE = 5,
+ SWFDEC_XML_NODE_ENTITY = 6,
+ SWFDEC_XML_NODE_PROCESSING_INSTRUCTION = 7,
+ SWFDEC_XML_NODE_COMMENT = 8,
+ SWFDEC_XML_NODE_DOCUMENT = 9,
+ SWFDEC_XML_NODE_DOCUMENT_TYPE = 10,
+ SWFDEC_XML_NODE_DOCUMENT_FRAGMENT = 11,
+ SWFDEC_XML_NODE_NOTATION = 12,
+} SwfdecXmlNodeType;
+
+typedef struct _SwfdecXmlNode SwfdecXmlNode;
+typedef struct _SwfdecXmlNodeClass SwfdecXmlNodeClass;
+
+#define SWFDEC_TYPE_XML_NODE (swfdec_xml_node_get_type())
+#define SWFDEC_IS_XML_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_XML_NODE))
+#define SWFDEC_IS_XML_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_XML_NODE))
+#define SWFDEC_XML_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_XML_NODE, SwfdecXmlNode))
+#define SWFDEC_XML_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_XML_NODE, SwfdecXmlNodeClass))
+#define SWFDEC_XML_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_XML_NODE, SwfdecXmlNodeClass))
+
+#define SWFDEC_IS_VALID_XML_NODE(obj) (SWFDEC_IS_XML_NODE (obj) && SWFDEC_XML_NODE (obj)->valid)
+
+struct _SwfdecXmlNode {
+ SwfdecAsObject object;
+
+ gboolean valid;
+
+ guint type; // SwfdecXmlNodeType
+ const char *name; // for type == element
+ const char *value; // for type != element
+
+ SwfdecXmlNode *parent;
+ SwfdecAsArray *children;
+ SwfdecAsObject *attributes;
+
+ // visible trough childNodes property, if modified by the user directly, the
+ // changes are not visible in children and will get overwritten by next
+ // internal change
+ SwfdecAsArray *child_nodes;
+};
+
+struct _SwfdecXmlNodeClass {
+ SwfdecAsObjectClass object_class;
+};
+
+GType swfdec_xml_node_get_type (void);
+
+SwfdecXmlNode * swfdec_xml_node_new (SwfdecAsContext * context,
+ SwfdecXmlNodeType type,
+ const char * value);
+SwfdecXmlNode * swfdec_xml_node_new_no_properties (SwfdecAsContext * context,
+ SwfdecXmlNodeType type,
+ const char * value);
+void swfdec_xml_node_removeNode (SwfdecXmlNode * node);
+void swfdec_xml_node_appendChild (SwfdecXmlNode * node,
+ SwfdecXmlNode * child);
+void swfdec_xml_node_removeChildren (SwfdecXmlNode * node);
+void swfdec_xml_node_init_values (SwfdecXmlNode * node,
+ int type,
+ const char * value);
+gint32 swfdec_xml_node_num_children (SwfdecXmlNode * node);
+SwfdecXmlNode * swfdec_xml_node_get_child (SwfdecXmlNode * node,
+ gint32 index_);
+const char * swfdec_xml_node_get_attribute (SwfdecXmlNode * node,
+ const char * name);
+
+G_END_DECLS
+#endif
diff --git a/swfdec/swfdec_xml_socket.c b/swfdec/swfdec_xml_socket.c
new file mode 100644
index 0000000..886a042
--- /dev/null
+++ b/swfdec/swfdec_xml_socket.c
@@ -0,0 +1,245 @@
+/* Swfdec
+ * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+
+#include "swfdec_xml_socket.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_buffer.h"
+#include "swfdec_debug.h"
+#include "swfdec_loader_internal.h"
+#include "swfdec_movie.h"
+#include "swfdec_player_internal.h"
+
+static GQuark xml_socket_quark = 0;
+
+static void
+swfdec_xml_socket_ensure_closed (SwfdecXmlSocket *xml)
+{
+ gpointer cur;
+
+ if (xml->socket == NULL)
+ return;
+
+ swfdec_stream_set_target (SWFDEC_STREAM (xml->socket), NULL);
+ g_object_unref (xml->socket);
+ xml->socket = NULL;
+
+ swfdec_player_unroot (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (xml)->context), xml);
+ cur = g_object_get_qdata (G_OBJECT (xml->target), xml_socket_quark);
+ if (cur != xml)
+ g_object_set_qdata (G_OBJECT (xml->target), xml_socket_quark, cur);
+ xml->target = NULL;
+}
+
+/*** SWFDEC_STREAM_TARGET ***/
+
+static SwfdecPlayer *
+swfdec_xml_socket_stream_target_get_player (SwfdecStreamTarget *target)
+{
+ return SWFDEC_PLAYER (SWFDEC_AS_OBJECT (target)->context);
+}
+
+static void
+swfdec_xml_socket_stream_target_error (SwfdecStreamTarget *target,
+ SwfdecStream *stream)
+{
+ SwfdecXmlSocket *xml = SWFDEC_XML_SOCKET (target);
+
+ if (xml->open) {
+ SWFDEC_FIXME ("is onClose emitted on error?");
+ swfdec_as_object_call (xml->target, SWFDEC_AS_STR_onClose, 0, NULL, NULL);
+ } else {
+ SwfdecAsValue value;
+
+ SWFDEC_AS_VALUE_SET_BOOLEAN (&value, FALSE);
+ swfdec_as_object_call (xml->target, SWFDEC_AS_STR_onConnect, 1, &value, NULL);
+ }
+
+ swfdec_xml_socket_ensure_closed (xml);
+}
+
+static void
+swfdec_xml_socket_stream_target_parse (SwfdecStreamTarget *target,
+ SwfdecStream *stream)
+{
+ SwfdecXmlSocket *xml = SWFDEC_XML_SOCKET (target);
+ SwfdecBufferQueue *queue;
+ SwfdecBuffer *buffer;
+ gsize len;
+
+ /* parse until next 0 byte or take everything */
+ queue = swfdec_stream_get_queue (stream);
+ while ((buffer = swfdec_buffer_queue_peek_buffer (queue))) {
+ guchar *nul = memchr (buffer->data, 0, buffer->length);
+
+ len = nul ? (gsize) (nul - buffer->data + 1) : buffer->length;
+ g_assert (len > 0);
+ swfdec_buffer_unref (buffer);
+ buffer = swfdec_buffer_queue_pull (queue, len);
+ swfdec_buffer_queue_push (xml->queue, buffer);
+ if (nul) {
+ len = swfdec_buffer_queue_get_depth (xml->queue);
+ g_assert (len > 0);
+ buffer = swfdec_buffer_queue_pull (xml->queue, len);
+ if (!g_utf8_validate ((char *) buffer->data, len, NULL)) {
+ SWFDEC_FIXME ("invalid utf8 sent through socket, what now?");
+ } else {
+ SwfdecAsValue val;
+
+ SWFDEC_AS_VALUE_SET_STRING (&val, swfdec_as_context_get_string (
+ SWFDEC_AS_OBJECT (xml)->context, (char *) buffer->data));
+ swfdec_as_object_call (xml->target, SWFDEC_AS_STR_onData, 1, &val, NULL);
+ }
+ }
+ }
+}
+
+static void
+swfdec_xml_socket_stream_target_close (SwfdecStreamTarget *target,
+ SwfdecStream *stream)
+{
+ SwfdecXmlSocket *xml = SWFDEC_XML_SOCKET (target);
+
+ if (swfdec_buffer_queue_get_depth (xml->queue)) {
+ SWFDEC_FIXME ("data left in socket, what now?");
+ }
+
+ swfdec_as_object_call (xml->target, SWFDEC_AS_STR_onClose, 0, NULL, NULL);
+
+ swfdec_xml_socket_ensure_closed (xml);
+}
+
+static void
+swfdec_xml_socket_stream_target_init (SwfdecStreamTargetInterface *iface)
+{
+ iface->get_player = swfdec_xml_socket_stream_target_get_player;
+ iface->parse = swfdec_xml_socket_stream_target_parse;
+ iface->close = swfdec_xml_socket_stream_target_close;
+ iface->error = swfdec_xml_socket_stream_target_error;
+}
+
+/*** SWFDEC_XML_SOCKET ***/
+
+G_DEFINE_TYPE_WITH_CODE (SwfdecXmlSocket, swfdec_xml_socket, SWFDEC_TYPE_AS_OBJECT,
+ G_IMPLEMENT_INTERFACE (SWFDEC_TYPE_STREAM_TARGET, swfdec_xml_socket_stream_target_init))
+
+static void
+swfdec_xml_socket_mark (SwfdecAsObject *object)
+{
+ swfdec_as_object_mark (SWFDEC_XML_SOCKET (object)->target);
+
+ SWFDEC_AS_OBJECT_CLASS (swfdec_xml_socket_parent_class)->mark (object);
+}
+
+static void
+swfdec_xml_socket_dispose (GObject *object)
+{
+ SwfdecXmlSocket *xml = SWFDEC_XML_SOCKET (object);
+
+ swfdec_xml_socket_ensure_closed (xml);
+ if (xml->queue) {
+ swfdec_buffer_queue_unref (xml->queue);
+ xml->queue = NULL;
+ }
+
+ G_OBJECT_CLASS (swfdec_xml_socket_parent_class)->dispose (object);
+}
+
+static void
+swfdec_xml_socket_class_init (SwfdecXmlSocketClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ SwfdecAsObjectClass *as_object_class = SWFDEC_AS_OBJECT_CLASS (klass);
+
+ object_class->dispose = swfdec_xml_socket_dispose;
+
+ as_object_class->mark = swfdec_xml_socket_mark;
+}
+
+static void
+swfdec_xml_socket_init (SwfdecXmlSocket *xml)
+{
+ xml->queue = swfdec_buffer_queue_new ();
+}
+
+static SwfdecXmlSocket *
+swfdec_xml_socket_create (SwfdecAsObject *target, const char *hostname, guint port)
+{
+ SwfdecAsContext *cx = target->context;
+ SwfdecXmlSocket *xml;
+ SwfdecSocket *sock;
+
+ if (!swfdec_as_context_use_mem (cx, sizeof (SwfdecXmlSocket)))
+ return NULL;
+
+ SWFDEC_FIXME ("implement security checks please");
+ sock = swfdec_player_create_socket (SWFDEC_PLAYER (cx), hostname, port);
+ if (sock == NULL)
+ return NULL;
+
+ xml = g_object_new (SWFDEC_TYPE_XML_SOCKET, NULL);
+ swfdec_as_object_add (SWFDEC_AS_OBJECT (xml), cx, sizeof (SwfdecXmlSocket));
+ swfdec_player_root (SWFDEC_PLAYER (cx), xml, (GFunc) swfdec_as_object_mark);
+
+ xml->target = target;
+ xml->socket = sock;
+
+ return xml;
+}
+
+/*** AS CODE ***/
+
+SWFDEC_AS_NATIVE (400, 0, swfdec_xml_socket_connect)
+void
+swfdec_xml_socket_connect (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ const char *host;
+ int port;
+
+ SWFDEC_AS_CHECK (0, NULL, "si", &host, &port);
+
+ if (SWFDEC_IS_MOVIE (object) || object == NULL)
+ return;
+
+ swfdec_xml_socket_create (object, host, port);
+ SWFDEC_STUB ("XMLSocket.connect");
+}
+
+SWFDEC_AS_NATIVE (400, 1, swfdec_xml_socket_send)
+void
+swfdec_xml_socket_send (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("XMLSocket.send");
+}
+
+SWFDEC_AS_NATIVE (400, 2, swfdec_xml_socket_close)
+void
+swfdec_xml_socket_close (SwfdecAsContext *cx, SwfdecAsObject *object,
+ guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
+{
+ SWFDEC_STUB ("XMLSocket.close");
+}
diff --git a/swfdec/swfdec_xml_socket.h b/swfdec/swfdec_xml_socket.h
new file mode 100644
index 0000000..95f19c2
--- /dev/null
+++ b/swfdec/swfdec_xml_socket.h
@@ -0,0 +1,56 @@
+/* Swfdec
+ * Copyright (C) 2008 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef _SWFDEC_XML_SOCKET_H_
+#define _SWFDEC_XML_SOCKET_H_
+
+#include <libswfdec/swfdec.h>
+#include <libswfdec/swfdec_as_object.h>
+
+G_BEGIN_DECLS
+
+
+typedef struct _SwfdecXmlSocket SwfdecXmlSocket;
+typedef struct _SwfdecXmlSocketClass SwfdecXmlSocketClass;
+
+#define SWFDEC_TYPE_XML_SOCKET (swfdec_xml_socket_get_type())
+#define SWFDEC_IS_XML_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_XML_SOCKET))
+#define SWFDEC_IS_XML_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_XML_SOCKET))
+#define SWFDEC_XML_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_XML_SOCKET, SwfdecXmlSocket))
+#define SWFDEC_XML_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_XML_SOCKET, SwfdecXmlSocketClass))
+#define SWFDEC_XML_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWFDEC_TYPE_XML_SOCKET, SwfdecXmlSocketClass))
+
+struct _SwfdecXmlSocket {
+ SwfdecAsObject object;
+
+ SwfdecSocket * socket; /* the socket in use */
+ gboolean open; /* the socket has been opened already */
+ SwfdecBufferQueue * queue; /* everything that belongs to the same string */
+ SwfdecAsObject * target; /* target object we call out to */
+};
+
+struct _SwfdecXmlSocketClass {
+ SwfdecAsObjectClass object_class;
+};
+
+GType swfdec_xml_socket_get_type (void);
+
+
+G_END_DECLS
+#endif
commit f007813dd9ad48ac3290422eaabba3173284f4c5
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jan 24 12:53:36 2008 +0100
rework loader API - breaks swfdec and swfdec-gtk API
This is the implementation of this discusion:
<Company> i'm thinking about the SwfdecLoader API
<Company> i want to make it work like the SwfdecSocket API
<Company> i.e. set a GType on the SwfdecPlayer and then the player instantiates objects itself
<Company> so you don't call set_loader on the player but set_url
<Company> and then the player instantiates a loader from the type that's set on it
<Company> problem: lots of API changes
<Company> problem 2: i'm not sure error handling works properly, in particular the "This is not a Flash file" error
<Company> good thing 1: we can abstract loaders away completely
<Company> good thing 2: the API should work with the url resolving madness
<Company> good thing 3: we'd have a consistent API for customizable objects
<Company> good thing 4: customizable objects don't affect people that don't care at all
<Medra> 4 > 2
swfdec-mozilla and swfdec-gnome now probably won't compile
diff --git a/libswfdec-gtk/swfdec_gtk_loader.c b/libswfdec-gtk/swfdec_gtk_loader.c
index 6013730..375ca60 100644
--- a/libswfdec-gtk/swfdec_gtk_loader.c
+++ b/libswfdec-gtk/swfdec_gtk_loader.c
@@ -138,33 +138,29 @@ swfdec_gtk_loader_dispose (GObject *object)
}
static void
-swfdec_gtk_loader_load (SwfdecLoader *loader, SwfdecLoader *parent,
+swfdec_gtk_loader_load (SwfdecLoader *loader, SwfdecPlayer *player,
const char *url_string, SwfdecLoaderRequest request, SwfdecBuffer *buffer)
{
SwfdecURL *url;
- if (parent) {
- SwfdecURL *parent_url = swfdec_url_new_parent (swfdec_loader_get_url (parent));
- url = swfdec_url_new_relative (parent_url, url_string);
- swfdec_url_free (parent_url);
+ if (swfdec_url_path_is_relative (url_string)) {
+ url = swfdec_url_new_relative (swfdec_player_get_base_url (player), url_string);
} else {
url = swfdec_url_new (url_string);
}
if (url == NULL) {
- //swfdec_stream_error (loader, "invalid URL %s", url_string);
- swfdec_stream_error (SWFDEC_STREAM (loader), "invalid URL");
+ swfdec_stream_error (SWFDEC_STREAM (loader), "invalid URL %s", url_string);
return;
};
if (!swfdec_url_has_protocol (url, "http") &&
!swfdec_url_has_protocol (url, "https")) {
- SWFDEC_LOADER_CLASS (swfdec_gtk_loader_parent_class)->load (loader,
- parent, url_string, request, buffer);
+ SWFDEC_LOADER_CLASS (swfdec_gtk_loader_parent_class)->load (loader, player,
+ url_string, request, buffer);
} else {
SwfdecGtkLoader *gtk = SWFDEC_GTK_LOADER (loader);
SwfdecGtkLoaderClass *klass = SWFDEC_GTK_LOADER_GET_CLASS (gtk);
- swfdec_loader_set_url (loader, swfdec_url_get_url (url));
gtk->message = soup_message_new (request == SWFDEC_LOADER_REQUEST_POST ? "POST" : "GET",
swfdec_url_get_url (url));
soup_message_set_flags (gtk->message, SOUP_MESSAGE_OVERWRITE_CHUNKS);
@@ -219,27 +215,3 @@ swfdec_gtk_loader_init (SwfdecGtkLoader *gtk_loader)
{
}
-/**
- * swfdec_gtk_loader_new:
- * @uri: The location of the file to open
- *
- * Creates a new loader for the given URI. The uri must be a valid UTF-8-encoded
- * URL.
- *
- * Returns: a new #SwfdecGtkLoader
- **/
-SwfdecLoader *
-swfdec_gtk_loader_new (const char *uri)
-{
- SwfdecLoader *loader;
- SwfdecURL *url;
-
- g_return_val_if_fail (uri != NULL, NULL);
-
- url = swfdec_url_new (uri);
- loader = g_object_new (SWFDEC_TYPE_GTK_LOADER, NULL);
- swfdec_gtk_loader_load (loader, NULL, swfdec_url_get_url (url), SWFDEC_LOADER_REQUEST_DEFAULT, NULL);
- /* END HACK */
- swfdec_url_free (url);
- return loader;
-}
diff --git a/libswfdec-gtk/swfdec_gtk_loader.h b/libswfdec-gtk/swfdec_gtk_loader.h
index 09a3558..ccae174 100644
--- a/libswfdec-gtk/swfdec_gtk_loader.h
+++ b/libswfdec-gtk/swfdec_gtk_loader.h
@@ -37,8 +37,6 @@ typedef struct _SwfdecGtkLoaderClass SwfdecGtkLoaderClass;
GType swfdec_gtk_loader_get_type (void);
-SwfdecLoader * swfdec_gtk_loader_new (const char * uri);
-
G_END_DECLS
#endif
diff --git a/libswfdec-gtk/swfdec_gtk_player.c b/libswfdec-gtk/swfdec_gtk_player.c
index e9b8cd4..6d0a0a3 100644
--- a/libswfdec-gtk/swfdec_gtk_player.c
+++ b/libswfdec-gtk/swfdec_gtk_player.c
@@ -174,40 +174,12 @@ swfdec_gtk_player_new (SwfdecAsDebugger *debugger)
swfdec_init ();
player = g_object_new (SWFDEC_TYPE_GTK_PLAYER,
- "socket-type", SWFDEC_TYPE_GTK_SOCKET,
+ "loader-type", SWFDEC_TYPE_GTK_LOADER, "socket-type", SWFDEC_TYPE_GTK_SOCKET,
"debugger", debugger, NULL);
return player;
}
-/**
- * swfdec_gtk_player_new_from_uri:
- * @uri: URI to play
- *
- * Create a player to play back the given URI. If compiled with gnome-vfs
- * support, it will use gnome-vfs to resolve the given URI. Note that there
- * is no way to figure out if the referenced URI really references a file that
- * Swfdec can play back. If you need this, you should use #SwfdecGtkLoader
- * directly and use its error property.
- * This function calls swfdec_init () for you if it wasn't called before.
- *
- * Returns: a new player.
- **/
-SwfdecPlayer *
-swfdec_gtk_player_new_from_uri (const char *uri)
-{
- SwfdecLoader *loader;
- SwfdecPlayer *player;
-
- g_return_val_if_fail (uri != NULL, NULL);
-
- player = swfdec_gtk_player_new (NULL);
- loader = swfdec_gtk_loader_new (uri);
- swfdec_player_set_loader (player, loader);
-
- return player;
-}
-
static void
swfdec_gtk_player_update_audio (SwfdecGtkPlayer *player)
{
diff --git a/libswfdec-gtk/swfdec_gtk_player.h b/libswfdec-gtk/swfdec_gtk_player.h
index a8a9b30..3ff77bf 100644
--- a/libswfdec-gtk/swfdec_gtk_player.h
+++ b/libswfdec-gtk/swfdec_gtk_player.h
@@ -37,7 +37,6 @@ typedef struct _SwfdecGtkPlayerClass SwfdecGtkPlayerClass;
GType swfdec_gtk_player_get_type (void);
SwfdecPlayer * swfdec_gtk_player_new (SwfdecAsDebugger * debugger);
-SwfdecPlayer * swfdec_gtk_player_new_from_uri (const char * uri);
void swfdec_gtk_player_set_playing (SwfdecGtkPlayer * player,
gboolean playing);
diff --git a/libswfdec/swfdec_decoder.h b/libswfdec/swfdec_decoder.h
index 7a93276..3a58015 100644
--- a/libswfdec/swfdec_decoder.h
+++ b/libswfdec/swfdec_decoder.h
@@ -22,6 +22,7 @@
#include <glib-object.h>
#include <libswfdec/swfdec_buffer.h>
+#include <libswfdec/swfdec_loader.h>
#include <libswfdec/swfdec_player.h>
#include <libswfdec/swfdec_types.h>
diff --git a/libswfdec/swfdec_file_loader.c b/libswfdec/swfdec_file_loader.c
index 625f5fa..178601a 100644
--- a/libswfdec/swfdec_file_loader.c
+++ b/libswfdec/swfdec_file_loader.c
@@ -38,7 +38,7 @@
G_DEFINE_TYPE (SwfdecFileLoader, swfdec_file_loader, SWFDEC_TYPE_LOADER)
static void
-swfdec_file_loader_load (SwfdecLoader *loader, SwfdecLoader *parent,
+swfdec_file_loader_load (SwfdecLoader *loader, SwfdecPlayer *player,
const char *url_string, SwfdecLoaderRequest request, SwfdecBuffer *buffer)
{
SwfdecStream *stream = SWFDEC_STREAM (loader);
@@ -46,10 +46,8 @@ swfdec_file_loader_load (SwfdecLoader *loader, SwfdecLoader *parent,
char *real;
SwfdecURL *url;
- if (parent) {
- SwfdecURL *parent_url = swfdec_url_new_parent (swfdec_loader_get_url (parent));
- url = swfdec_url_new_relative (parent_url, url_string);
- swfdec_url_free (parent_url);
+ if (swfdec_url_path_is_relative (url_string)) {
+ url = swfdec_url_new_relative (swfdec_player_get_base_url (player), url_string);
} else {
url = swfdec_url_new (url_string);
}
@@ -98,51 +96,3 @@ swfdec_file_loader_init (SwfdecFileLoader *loader)
{
}
-/**
- * swfdec_file_loader_new:
- * @filename: name of the file to load
- *
- * Creates a new loader for local files. If an error occurred, the loader will
- * be in error.
- *
- * Returns: a new loader
- **/
-SwfdecLoader *
-swfdec_file_loader_new (const char *filename)
-{
- SwfdecBuffer *buf;
- SwfdecLoader *loader;
- SwfdecStream *stream;
- GError *error = NULL;
- char *url_string;
-
- g_return_val_if_fail (filename != NULL, NULL);
-
- buf = swfdec_buffer_new_from_file (filename, &error);
-
- if (g_path_is_absolute (filename)) {
- url_string = g_strconcat ("file://", filename, NULL);
- } else {
- char *abs, *cur;
- cur = g_get_current_dir ();
- abs = g_build_filename (cur, filename, NULL);
- g_free (cur);
- url_string = g_strconcat ("file://", abs, NULL);
- g_free (abs);
- }
-
- loader = g_object_new (SWFDEC_TYPE_FILE_LOADER, NULL);
- swfdec_loader_set_url (loader, url_string);
- stream = SWFDEC_STREAM (loader);
- if (buf == NULL) {
- swfdec_stream_error (stream, "%s", error->message);
- g_error_free (error);
- } else {
- swfdec_loader_set_size (loader, buf->length);
- swfdec_stream_open (stream);
- swfdec_stream_push (stream, buf);
- swfdec_stream_eof (stream);
- }
- return loader;
-}
-
diff --git a/libswfdec/swfdec_file_loader.h b/libswfdec/swfdec_file_loader.h
index b378a2a..facd8c5 100644
--- a/libswfdec/swfdec_file_loader.h
+++ b/libswfdec/swfdec_file_loader.h
@@ -46,7 +46,6 @@ struct _SwfdecFileLoaderClass
GType swfdec_file_loader_get_type (void);
-SwfdecLoader * swfdec_file_loader_new (const char * filename);
G_END_DECLS
diff --git a/libswfdec/swfdec_loader.c b/libswfdec/swfdec_loader.c
index e907e59..9868eac 100644
--- a/libswfdec/swfdec_loader.c
+++ b/libswfdec/swfdec_loader.c
@@ -203,77 +203,9 @@ swfdec_loader_init (SwfdecLoader *loader)
loader->size = -1;
}
-/*** INTERNAL API ***/
-
-SwfdecLoader *
-swfdec_loader_load (SwfdecLoader *loader, const char *url,
- SwfdecLoaderRequest request, SwfdecBuffer *buffer)
-{
- SwfdecLoader *ret;
- SwfdecLoaderClass *klass;
-
- g_return_val_if_fail (SWFDEC_IS_LOADER (loader), NULL);
- g_return_val_if_fail (url != NULL, NULL);
-
- klass = SWFDEC_LOADER_GET_CLASS (loader);
- g_return_val_if_fail (klass->load != NULL, NULL);
- ret = g_object_new (G_OBJECT_CLASS_TYPE (klass), NULL);
- klass->load (ret, loader, url, request, buffer);
- g_return_val_if_fail (loader->url != NULL, ret);
- return ret;
-}
-
/** PUBLIC API ***/
/**
- * swfdec_loader_get_filename:
- * @loader: a #SwfdecLoader
- *
- * Gets the suggested filename to use for this loader. This may be of interest
- * when displaying information about the file that is played back.
- *
- * Returns: A string in the glib filename encoding that contains the filename
- * for this loader. g_free() after use.
- **/
-char *
-swfdec_loader_get_filename (SwfdecLoader *loader)
-{
- const SwfdecURL *url;
- const char *path, *ext;
- char *ret = NULL;
-
- g_return_val_if_fail (SWFDEC_IS_LOADER (loader), NULL);
-
- url = swfdec_loader_get_url (loader);
- path = swfdec_url_get_path (url);
- if (path) {
- char *s = strrchr (path, '/');
- if (s)
- path = s + 1;
- if (path[0] == 0)
- path = NULL;
- }
- if (path)
- ret = g_filename_from_utf8 (path, -1, NULL, NULL, NULL);
- if (ret == NULL)
- ret = g_strdup ("unknown");
-
- ext = swfdec_loader_data_type_get_extension (loader->data_type);
- if (*ext) {
- char *dot = strrchr (ret, '.');
- char *real;
- guint len = dot ? strlen (dot) : G_MAXUINT;
- if (len <= 5)
- *dot = '\0';
- real = g_strdup_printf ("%s.%s", ret, ext);
- g_free (ret);
- ret = real;
- }
-
- return ret;
-}
-
-/**
* swfdec_loader_set_url:
* @loader: the loader to update
* @url: string specifying the new URL. The url must be a valid absolute URL.
diff --git a/libswfdec/swfdec_loader.h b/libswfdec/swfdec_loader.h
index 59bb0e8..3d0ebff 100644
--- a/libswfdec/swfdec_loader.h
+++ b/libswfdec/swfdec_loader.h
@@ -22,6 +22,7 @@
#include <glib-object.h>
#include <libswfdec/swfdec_buffer.h>
+#include <libswfdec/swfdec_player.h>
#include <libswfdec/swfdec_stream.h>
#include <libswfdec/swfdec_url.h>
@@ -69,7 +70,7 @@ struct _SwfdecLoaderClass
SwfdecStreamClass stream_class;
void (* load) (SwfdecLoader * loader,
- SwfdecLoader * parent,
+ SwfdecPlayer * player,
const char * url,
SwfdecLoaderRequest request,
SwfdecBuffer * buffer);
@@ -85,7 +86,6 @@ void swfdec_loader_set_size (SwfdecLoader * loader,
gulong size);
glong 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 --git a/libswfdec/swfdec_loader_internal.h b/libswfdec/swfdec_loader_internal.h
index c979fe4..c19ba9f 100644
--- a/libswfdec/swfdec_loader_internal.h
+++ b/libswfdec/swfdec_loader_internal.h
@@ -33,10 +33,6 @@ void swfdec_stream_set_target (SwfdecStream * stream,
SwfdecStreamTarget * target);
/* swfdec_loader.c */
-SwfdecLoader * swfdec_loader_load (SwfdecLoader * loader,
- const char * url,
- SwfdecLoaderRequest request,
- SwfdecBuffer * buffer);
void swfdec_loader_set_data_type (SwfdecLoader * loader,
SwfdecLoaderDataType type);
char * swfdec_loader_get_text (SwfdecLoader * loader,
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index bf096f4..5b996ef 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -619,9 +619,11 @@ enum {
PROP_SCRIPTING,
PROP_SYSTEM,
PROP_MAX_RUNTIME,
+ PROP_LOADER_TYPE,
PROP_SOCKET_TYPE,
PROP_BASE_URL,
- PROP_URL
+ PROP_URL,
+ PROP_VARIABLES
};
G_DEFINE_TYPE (SwfdecPlayer, swfdec_player, SWFDEC_TYPE_AS_CONTEXT)
@@ -735,19 +737,21 @@ swfdec_player_get_property (GObject *object, guint param_id, GValue *value,
case PROP_MAX_RUNTIME:
g_value_set_ulong (value, priv->max_runtime);
break;
+ case PROP_LOADER_TYPE:
+ g_value_set_gtype (value, priv->loader_type);
+ break;
case PROP_SOCKET_TYPE:
g_value_set_gtype (value, priv->socket_type);
break;
case PROP_URL:
- if (priv->resource) {
- g_value_set_boxed (value, swfdec_loader_get_url (priv->resource->loader));
- } else {
- g_value_set_boxed (value, NULL);
- }
+ g_value_set_boxed (value, priv->url);
break;
case PROP_BASE_URL:
g_value_set_boxed (value, priv->base_url);
break;
+ case PROP_VARIABLES:
+ g_value_set_string (value, priv->variables);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -865,9 +869,22 @@ swfdec_player_set_property (GObject *object, guint param_id, const GValue *value
case PROP_MAX_RUNTIME:
swfdec_player_set_maximum_runtime (player, g_value_get_ulong (value));
break;
+ case PROP_LOADER_TYPE:
+ g_return_if_fail (G_TYPE_IS_INSTANTIATABLE (g_value_get_gtype (value)));
+ priv->loader_type = g_value_get_gtype (value);
+ break;
case PROP_SOCKET_TYPE:
priv->socket_type = g_value_get_gtype (value);
break;
+ case PROP_URL:
+ swfdec_player_set_url (player, g_value_get_boxed (value));
+ break;
+ case PROP_BASE_URL:
+ swfdec_player_set_base_url (player, g_value_get_boxed (value));
+ break;
+ case PROP_VARIABLES:
+ swfdec_player_set_variables (player, g_value_get_boxed (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -947,6 +964,12 @@ swfdec_player_dispose (GObject *object)
swfdec_url_free (priv->base_url);
priv->base_url = NULL;
}
+ if (priv->url) {
+ swfdec_url_free (priv->url);
+ priv->url = NULL;
+ }
+ g_free (priv->variables);
+ priv->variables = NULL;
}
static void
@@ -1628,15 +1651,21 @@ swfdec_player_class_init (SwfdecPlayerClass *klass)
g_object_class_install_property (object_class, PROP_MAX_RUNTIME,
g_param_spec_ulong ("max-runtime", "maximum runtime", "maximum time in msecs scripts may run in the player before aborting",
0, G_MAXULONG, 10 * 1000, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_LOADER_TYPE,
+ g_param_spec_gtype ("loader-type", "loader type", "type to use for creating loaders",
+ SWFDEC_TYPE_LOADER, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_SOCKET_TYPE,
- g_param_spec_gtype ("socket type", "socket type", "type to use for creating sockets",
- SWFDEC_TYPE_SOCKET, G_PARAM_READWRITE));
+ g_param_spec_gtype ("socket-type", "socket type", "type to use for creating sockets",
+ SWFDEC_TYPE_SOCKET, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_URL,
g_param_spec_boxed ("url", "url", "URL of resource currently played back or NULL if not set",
SWFDEC_TYPE_URL, G_PARAM_READABLE));
g_object_class_install_property (object_class, PROP_BASE_URL,
g_param_spec_boxed ("base-url", "base url", "base URL for creating new resource or NULL if not set yet",
SWFDEC_TYPE_URL, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_VARIABLES,
+ g_param_spec_string ("variables", "variables", "variables to use when setting the URL",
+ NULL, G_PARAM_READWRITE));
/**
* SwfdecPlayer::invalidate:
@@ -2118,8 +2147,10 @@ swfdec_player_create_socket (SwfdecPlayer *player, const char *hostname, guint p
g_return_val_if_fail (hostname != NULL, NULL);
g_return_val_if_fail (port > 0, NULL);
- if (player->priv->socket_type == 0)
+ if (!G_TYPE_IS_INSTANTIATABLE (player->priv->socket_type)) {
+ SWFDEC_INFO ("can't create socket, no socket type set.");
return NULL;
+ }
klass = g_type_class_ref (player->priv->socket_type);
sock = klass->create (hostname, port);
g_type_class_unref (klass);
@@ -2144,10 +2175,18 @@ SwfdecLoader *
swfdec_player_load (SwfdecPlayer *player, const char *url,
SwfdecLoaderRequest request, SwfdecBuffer *buffer)
{
+ SwfdecLoader *loader;
+ SwfdecLoaderClass *klass;
+
g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
g_return_val_if_fail (url != NULL, NULL);
- return swfdec_loader_load (player->priv->resource->loader, url, request, buffer);
+ loader = g_object_new (player->priv->loader_type, NULL);
+ klass = SWFDEC_LOADER_GET_CLASS (loader);
+ g_return_val_if_fail (klass->load != NULL, NULL);
+ klass->load (loader, player, url, request, buffer);
+
+ return loader;
}
/** PUBLIC API ***/
@@ -2173,6 +2212,7 @@ swfdec_player_new (SwfdecAsDebugger *debugger)
swfdec_init ();
player = g_object_new (SWFDEC_TYPE_PLAYER, "random-seed", 0,
+ "loader-type", SWFDEC_TYPE_FILE_LOADER, "socket-type", SWFDEC_TYPE_SOCKET,
"max-runtime", 0,
"debugger", debugger, NULL);
/* FIXME: make this a property or something and don't set it here */
@@ -2182,89 +2222,6 @@ swfdec_player_new (SwfdecAsDebugger *debugger)
}
/**
- * swfdec_player_set_loader:
- * @player: a #SwfdecPlayer
- * @loader: the loader to use for this player. Takes ownership of the given loader.
- *
- * Sets the loader for the main data. This function only works if no loader has
- * been set on @player yet.
- * For details, see swfdec_player_set_loader_with_variables().
- **/
-void
-swfdec_player_set_loader (SwfdecPlayer *player, SwfdecLoader *loader)
-{
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (player->priv->roots == NULL);
- g_return_if_fail (SWFDEC_IS_LOADER (loader));
-
- swfdec_player_set_loader_with_variables (player, loader, NULL);
-}
-
-/**
- * swfdec_player_set_loader_with_variables:
- * @player: a #SwfdecPlayer
- * @loader: the loader to use for this player. Takes ownership of the given loader.
- * @variables: a string that is checked to be in 'application/x-www-form-urlencoded'
- * syntax describing the arguments to set on the new player or NULL for
- * none.
- *
- * Sets the loader for the main data. This function only works if no loader has
- * been set on @player yet.
- * If the @variables are set and validate, they will be set as properties on the
- * root movie.
- **/
-void
-swfdec_player_set_loader_with_variables (SwfdecPlayer *player, SwfdecLoader *loader,
- const char *variables)
-{
- SwfdecPlayerPrivate *priv;
- SwfdecMovie *movie;
-
- g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (player->priv->resource == NULL);
- g_return_if_fail (SWFDEC_IS_LOADER (loader));
-
- g_object_freeze_notify (G_OBJECT (player));
- priv = player->priv;
- priv->resource = swfdec_resource_new (player, loader, variables);
- if (priv->base_url == NULL) {
- priv->base_url = swfdec_url_new_parent (swfdec_loader_get_url (loader));
- g_object_notify (G_OBJECT (player), "base-url");
- }
- movie = swfdec_movie_new (player, -16384, NULL, priv->resource, NULL, SWFDEC_AS_STR__level0);
- movie->name = SWFDEC_AS_STR_EMPTY;
- g_object_unref (loader);
- g_object_notify (G_OBJECT (player), "url");
- g_object_thaw_notify (G_OBJECT (player));
-}
-
-/**
- * swfdec_player_new_from_file:
- * @filename: name of the file to play
- *
- * Creates a player to play back the given file. If the file does not
- * exist or another error occurs, the player will be in an error state and not
- * be initialized.
- * This function calls swfdec_init () for you if it wasn't called before.
- *
- * Returns: a new player
- **/
-SwfdecPlayer *
-swfdec_player_new_from_file (const char *filename)
-{
- SwfdecLoader *loader;
- SwfdecPlayer *player;
-
- g_return_val_if_fail (filename != NULL, NULL);
-
- loader = swfdec_file_loader_new (filename);
- player = swfdec_player_new (NULL);
- swfdec_player_set_loader (player, loader);
-
- return player;
-}
-
-/**
* swfdec_init:
*
* Initializes the Swfdec library.
@@ -2925,6 +2882,55 @@ swfdec_player_set_scripting (SwfdecPlayer *player, SwfdecPlayerScripting *script
}
/**
+ * swfdec_player_get_base_url:
+ * @player: a #SwfdecPlayer
+ *
+ * Gets the base URL that this player uses when resolving a relative URL. It is
+ * automatically set to the parent directory of the currently played back
+ * resource, but can be changed using swfdec_player_set_base_url(). When no
+ * resource has been set on the @player yet, %NULL is returned.
+ *
+ * Returns: the base #SwfdecURL for resolving relative links or %NULL
+ **/
+const SwfdecURL *
+swfdec_player_get_base_url (SwfdecPlayer *player)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+
+ return player->priv->base_url;
+}
+
+/**
+ * swfdec_player_set_base_url:
+ * @player: a #SwfdecPlayer
+ * @url: a #SwfdecURL or %NULL to reset to defaults
+ *
+ * Sets the URL that will be used for resolving realtive links inside the
+ * @player.
+ **/
+void
+swfdec_player_set_base_url (SwfdecPlayer *player, const SwfdecURL *url)
+{
+ SwfdecPlayerPrivate *priv;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+ priv = player->priv;
+ if (priv->base_url)
+ swfdec_url_free (priv->base_url);
+ if (url == NULL) {
+ if (priv->url) {
+ priv->base_url = swfdec_url_new_parent (priv->url);
+ } else {
+ priv->base_url = NULL;
+ }
+ } else {
+ priv->base_url = swfdec_url_copy (url);
+ }
+ g_object_notify (G_OBJECT (player), "base-url");
+}
+
+/**
* swfdec_player_get_url:
* @player: a #SwfdecPlayer
*
@@ -2945,44 +2951,80 @@ swfdec_player_get_url (SwfdecPlayer *player)
}
/**
- * swfdec_player_get_base_url:
+ * swfdec_player_set_url:
* @player: a #SwfdecPlayer
+ * @url: the url for the initial reference in this player
*
- * Gets the base URL that this player uses when resolving a relative URL. It is
- * automatically set to the parent directory of the currently played back
- * resource, but can be changed using swfdec_player_set_base_url(). When no
- * resource has been set on the @player yet, %NULL is returned.
+ * Sets the @url for the main data. This function may only be called once.
+ **/
+void
+swfdec_player_set_url (SwfdecPlayer *player, const SwfdecURL *url)
+{
+ SwfdecPlayerPrivate *priv;
+ SwfdecLoader *loader;
+ SwfdecMovie *movie;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (player->priv->url == NULL);
+ g_return_if_fail (url != NULL);
+
+ g_object_freeze_notify (G_OBJECT (player));
+ priv = player->priv;
+ priv->url = swfdec_url_copy (url);
+ loader = swfdec_player_load (player, swfdec_url_get_url (url),
+ SWFDEC_LOADER_REQUEST_DEFAULT, NULL);
+ priv->resource = swfdec_resource_new (player, loader, priv->variables);
+ if (priv->base_url == NULL) {
+ priv->base_url = swfdec_url_new_parent (swfdec_loader_get_url (loader));
+ g_object_notify (G_OBJECT (player), "base-url");
+ }
+ movie = swfdec_movie_new (player, -16384, NULL, priv->resource, NULL, SWFDEC_AS_STR__level0);
+ movie->name = SWFDEC_AS_STR_EMPTY;
+ g_object_unref (loader);
+ g_object_notify (G_OBJECT (player), "url");
+ g_object_thaw_notify (G_OBJECT (player));
+}
+
+/**
+ * swfdec_player_get_variables:
+ * @player: a #SwfdecPlayer
*
- * Returns: the base #SwfdecURL for resolving relative links or %NULL
+ * Gets the initial variables for this player. See swfdec_player_set_variables()
+ * for details about variables.
+ *
+ * Returns: a string represetation of the current variables or %NULL if none are
+ * set on the @player.
**/
-const SwfdecURL *
-swfdec_player_get_base_url (SwfdecPlayer *player)
+const char *
+swfdec_player_get_variables (SwfdecPlayer *player)
{
g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
- return player->priv->base_url;
+ return player->priv->variables;
}
/**
- * swfdec_player_set_base_url:
+ * swfdec_player_set_variables:
* @player: a #SwfdecPlayer
- * @url: a #SwfdecURL
+ * @variables: a string that is checked to be in 'application/x-www-form-urlencoded'
+ * syntax describing the arguments to set on the new player or NULL for
+ * none.
*
- * Sets the URL that will be used for resolving realtive links inside the
- * @player.
+ * Sets the loader for the main data. This function may only be called if
+ * swfdec_player_set_url() has not been called yet.
+ * If the @variables are set and validate, they will be set as properties on the
+ * root movie.
**/
void
-swfdec_player_set_base_url (SwfdecPlayer *player, const SwfdecURL *url)
+swfdec_player_set_variables (SwfdecPlayer *player, const char *variables)
{
SwfdecPlayerPrivate *priv;
g_return_if_fail (SWFDEC_IS_PLAYER (player));
- g_return_if_fail (url != NULL);
+ g_return_if_fail (player->priv->url == NULL);
- priv = player->priv;
- if (priv->base_url)
- swfdec_url_free (priv->base_url);
- priv->base_url = swfdec_url_copy (url);
- g_object_notify (G_OBJECT (player), "base-url");
+ g_free (priv->variables);
+ priv->variables = g_strdup (variables);
+ g_object_notify (G_OBJECT (player), "variables");
}
diff --git a/libswfdec/swfdec_player.h b/libswfdec/swfdec_player.h
index 04ce994..b3ec5f5 100644
--- a/libswfdec/swfdec_player.h
+++ b/libswfdec/swfdec_player.h
@@ -24,7 +24,7 @@
#include <cairo.h>
#include <libswfdec/swfdec_as_context.h>
#include <libswfdec/swfdec_as_types.h>
-#include <libswfdec/swfdec_loader.h>
+#include <libswfdec/swfdec_url.h>
G_BEGIN_DECLS
@@ -96,13 +96,6 @@ void swfdec_init (void);
GType swfdec_player_get_type (void);
SwfdecPlayer * swfdec_player_new (SwfdecAsDebugger * debugger);
-SwfdecPlayer * swfdec_player_new_from_file (const char * filename);
-void swfdec_player_set_loader (SwfdecPlayer * player,
- SwfdecLoader * loader);
-void swfdec_player_set_loader_with_variables
- (SwfdecPlayer * player,
- SwfdecLoader * loader,
- const char * variables);
gboolean swfdec_player_is_initialized (SwfdecPlayer * player);
glong swfdec_player_get_next_event (SwfdecPlayer * player);
@@ -134,10 +127,15 @@ void swfdec_player_set_maximum_runtime
gulong msecs);
const SwfdecURL *
swfdec_player_get_url (SwfdecPlayer * player);
+void swfdec_player_set_url (SwfdecPlayer * player,
+ const SwfdecURL * url);
const SwfdecURL *
- swfdec_player_get_base_url (SwfdecPlayer * player);
-void swfdec_player_set_base_url (SwfdecPlayer * player,
+ swfdec_player_get_base_url (SwfdecPlayer * player);
+void swfdec_player_set_base_url (SwfdecPlayer * player,
const SwfdecURL * url);
+const char* swfdec_player_get_variables (SwfdecPlayer * player);
+void swfdec_player_set_variables (SwfdecPlayer * player,
+ const char * variables);
SwfdecPlayerScripting *
swfdec_player_get_scripting (SwfdecPlayer * player);
void swfdec_player_set_scripting (SwfdecPlayer * player,
diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h
index c53a9f6..a38b957 100644
--- a/libswfdec/swfdec_player_internal.h
+++ b/libswfdec/swfdec_player_internal.h
@@ -24,6 +24,7 @@
#include <libswfdec/swfdec_audio.h>
#include <libswfdec/swfdec_event.h>
#include <libswfdec/swfdec_function_list.h>
+#include <libswfdec/swfdec_loader.h>
#include <libswfdec/swfdec_player_scripting.h>
#include <libswfdec/swfdec_rect.h>
#include <libswfdec/swfdec_ringbuffer.h>
@@ -67,9 +68,12 @@ struct _SwfdecPlayerPrivate
gboolean bgcolor_set; /* TRUE if the background color has been set */
SwfdecColor bgcolor; /* background color */
SwfdecResource * resource; /* initial resource loaded */
- SwfdecURL * base_url; /* base url or NULL if no loader set yet */
+ char * variables; /* variables to set on the player */
+ SwfdecURL * url; /* url or NULL if not set yet */
+ SwfdecURL * base_url; /* base url or NULL if not set yet */
SwfdecPlayerScripting *scripting; /* scripting object */
GHashTable * scripting_callbacks; /* GC string => SwfdecAsFunction mapping of script callbacks */
+ GType loader_type; /* type to use for creating sockets */
GType socket_type; /* type to use for creating sockets */
/* stage properties */
guint internal_width; /* width used by the scripting engine */
diff --git a/libswfdec/swfdec_url.c b/libswfdec/swfdec_url.c
index 6e16761..c81b5a2 100644
--- a/libswfdec/swfdec_url.c
+++ b/libswfdec/swfdec_url.c
@@ -624,3 +624,86 @@ swfdec_url_path_is_relative (const char *path)
return strstr (path, "://") == NULL;
}
+
+/**
+ * swfdec_url_new_from_input:
+ * @input: the input povided
+ *
+ * Tries to guess the right URL from the given @input. This function is meant
+ * as a utility function helping to convert user input (like command line
+ * arguments) to a URL without requiring the full URL.
+ *
+ * Returns: a new url best matching the given @input.
+ **/
+SwfdecURL *
+swfdec_url_new_from_input (const char *input)
+{
+ SwfdecURL *url;
+ char *url_string;
+
+ g_return_val_if_fail (input != NULL, NULL);
+
+ /* if it's a full URL, return it */
+ if (!swfdec_url_path_is_relative (input) &&
+ (url = swfdec_url_new (input)))
+ return url;
+
+ if (g_path_is_absolute (input)) {
+ url_string = g_strconcat ("file://", input, NULL);
+ } else {
+ char *absolute, *cur;
+ cur = g_get_current_dir ();
+ absolute = g_build_filename (cur, input, NULL);
+ g_free (cur);
+ url_string = g_strconcat ("file://", absolute, NULL);
+ g_free (absolute);
+ }
+
+ url = swfdec_url_new (url_string);
+ g_free (url_string);
+ g_return_val_if_fail (url != NULL, NULL);
+ return url;
+}
+
+/**
+ * swfdec_url_format_for_display:
+ * @url: the url to display
+ *
+ * Creates a string suitable to display the given @url. An example for using
+ * this function is to identify a currently playing Flash URL. Use
+ * swfdec_player_get_url() to query the player's URL and then use this function
+ * to get a displayable string.
+ *
+ * Returns: A new string containig a short description for this URL. g_free()
+ * after use.
+ **/
+char *
+swfdec_url_format_for_display (const SwfdecURL *url)
+{
+ GString *str;
+
+ g_return_val_if_fail (url != NULL, NULL);
+
+ if (swfdec_url_is_local (url)) {
+ const char *slash;
+
+ if (url->path == NULL)
+ return g_strdup ("/");
+ slash = strrchr (url->path, '/');
+ if (slash && slash[1] != '\0') {
+ return g_strdup (slash + 1);
+ } else {
+ return g_strdup (url->path);
+ }
+ }
+ str = g_string_new (url->protocol);
+ g_string_append (str, "://");
+ if (url->host)
+ g_string_append (str, url->host);
+ g_string_append (str, "/");
+ if (url->path)
+ g_string_append (str, url->path);
+
+ return g_string_free (str, FALSE);
+}
+
diff --git a/libswfdec/swfdec_url.h b/libswfdec/swfdec_url.h
index 155b0af..a7d8c13 100644
--- a/libswfdec/swfdec_url.h
+++ b/libswfdec/swfdec_url.h
@@ -38,6 +38,7 @@ SwfdecURL * swfdec_url_new_components (const char * protocol,
SwfdecURL * swfdec_url_new_parent (const SwfdecURL * url);
SwfdecURL * swfdec_url_new_relative (const SwfdecURL * url,
const char * string);
+SwfdecURL * swfdec_url_new_from_input (const char * input);
SwfdecURL * swfdec_url_copy (const SwfdecURL * url);
void swfdec_url_free (SwfdecURL * url);
@@ -47,6 +48,7 @@ const char * swfdec_url_get_host (const SwfdecURL * url);
guint swfdec_url_get_port (const SwfdecURL * url);
const char * swfdec_url_get_path (const SwfdecURL * url);
const char * swfdec_url_get_query (const SwfdecURL * url);
+char * swfdec_url_format_for_display (const SwfdecURL * url);
gboolean swfdec_url_has_protocol (const SwfdecURL * url,
const char * protocol);
diff --git a/player/swfplay.c b/player/swfplay.c
index a21586e..7f98bbe 100644
--- a/player/swfplay.c
+++ b/player/swfplay.c
@@ -29,12 +29,10 @@
static GMainLoop *loop = NULL;
static void
-set_title (GtkWindow *window, const char *filename)
+set_title (GtkWindow *window, const SwfdecURL *url)
{
- char *name = g_filename_display_basename (filename);
- char *title = g_strdup_printf ("%s : Swfplay", name);
+ char *title = swfdec_url_format_for_display (url);
- g_free (name);
gtk_window_set_title (window, title);
g_free (title);
}
@@ -75,41 +73,19 @@ print_trace (SwfdecPlayer *player, const char *message, gpointer unused)
g_print ("%s\n", message);
}
-static char *
-sanitize_url (const char *s)
-{
- SwfdecURL *url;
-
- url = swfdec_url_new (s);
- if (g_str_equal (swfdec_url_get_protocol (url), "error")) {
- char *dir, *full;
- swfdec_url_free (url);
- if (g_path_is_absolute (s))
- return g_strconcat ("file://", s, NULL);
- dir = g_get_current_dir ();
- full = g_strconcat ("file://", dir, G_DIR_SEPARATOR_S, s, NULL);
- g_free (dir);
- return full;
- } else {
- swfdec_url_free (url);
- return g_strdup (s);
- }
-}
-
int
main (int argc, char *argv[])
{
int speed = 100;
int max_runtime = 0;
- SwfdecLoader *loader;
SwfdecPlayer *player;
GError *error = NULL;
gboolean use_image = FALSE, no_sound = FALSE;
gboolean trace = FALSE, no_scripts = FALSE;
gboolean redraws = FALSE, gc = FALSE;
char *variables = NULL;
- char *s;
GtkWidget *window;
+ SwfdecURL *url;
GOptionEntry options[] = {
{ "always-gc", 'g', 0, G_OPTION_ARG_NONE, &gc, "run the garbage collector as often as possible", NULL },
@@ -144,16 +120,6 @@ main (int argc, char *argv[])
return 1;
}
- s = sanitize_url (argv[1]);
- loader = swfdec_gtk_loader_new (s);
- g_free (s);
- g_object_get (loader, "error", &s, NULL);
- if (s) {
- g_printerr ("Couldn't open file \"%s\": %s\n", argv[1], s);
- g_object_unref (loader);
- g_free (s);
- return 1;
- }
loop = g_main_loop_new (NULL, TRUE);
player = swfdec_gtk_player_new (NULL);
/* this allows the player to continue fine when running in gdb */
@@ -169,14 +135,18 @@ main (int argc, char *argv[])
swfdec_gtk_player_set_audio_enabled (SWFDEC_GTK_PLAYER (player), FALSE);
window = view_swf (player, use_image);
- set_title (GTK_WINDOW (window), argv[1]);
if (redraws)
gdk_window_set_debug_updates (TRUE);
if (!no_scripts)
g_signal_connect (player, "fscommand", G_CALLBACK (do_fscommand), window);
- swfdec_player_set_loader_with_variables (player, loader, variables);
+ if (variables != NULL)
+ swfdec_player_set_variables (player, variables);
+ url = swfdec_url_new_from_input (argv[1]);
+ swfdec_player_set_url (player, url);
+ set_title (GTK_WINDOW (window), url);
+ swfdec_url_free (url);
swfdec_gtk_player_set_playing (SWFDEC_GTK_PLAYER (player), TRUE);
diff --git a/test/sound/sound.c b/test/sound/sound.c
index 5715ce7..332ca12 100644
--- a/test/sound/sound.c
+++ b/test/sound/sound.c
@@ -202,9 +202,10 @@ render_all_streams (SwfdecPlayer *player, guint msecs, guint n_samples, TestData
static gboolean
run_test (const char *filename)
{
- SwfdecLoader *loader;
+ SwfdecURL *url;
SwfdecPlayer *player = NULL;
- guint i, msecs;
+ guint i;
+ long msecs;
GError *error = NULL;
char *dirname, *basename;
const char *name;
@@ -232,24 +233,20 @@ run_test (const char *filename)
g_free (dirname);
g_free (basename);
- loader = swfdec_file_loader_new (filename);
- g_object_get (loader, "error", &basename, NULL);
- if (basename) {
- g_print (" ERROR: %s\n", basename);
- g_object_unref (loader);
- g_free (basename);
- goto error;
- }
player = swfdec_player_new (NULL);
+ url = swfdec_url_new_from_input (filename);
g_signal_connect (player, "audio-added", G_CALLBACK (audio_added), &data);
g_signal_connect (player, "audio-removed", G_CALLBACK (audio_removed), &data);
g_signal_connect (player, "advance", G_CALLBACK (render_all_streams), &data);
- swfdec_player_set_loader (player, loader);
+ swfdec_player_set_url (player, url);
+ swfdec_url_free (url);
for (i = 0; i < 10; i++) {
data.current_frame++;
data.current_frame_audio = 0;
msecs = swfdec_player_get_next_event (player);
+ if (msecs < 0)
+ goto error;
swfdec_player_advance (player, msecs);
}
g_object_unref (player);
diff --git a/test/swfdec_test_test.c b/test/swfdec_test_test.c
index 46fa6a6..d5de83c 100644
--- a/test/swfdec_test_test.c
+++ b/test/swfdec_test_test.c
@@ -226,13 +226,18 @@ swfdec_test_test_fscommand (SwfdecPlayer *player, const char *command,
static gboolean
swfdec_test_test_ensure_player (SwfdecTestTest *test)
{
+ SwfdecURL *url;
+
if (test->filename == NULL)
return FALSE;
if (test->player)
return TRUE;
g_assert (test->player_quit == FALSE);
- test->player = swfdec_player_new_from_file (test->filename);
+ test->player = swfdec_player_new (NULL);
+ url = swfdec_url_new_from_input (test->filename);
+ swfdec_player_set_url (test->player, url);
+ swfdec_url_free (url);
g_signal_connect (test->player, "fscommand", G_CALLBACK (swfdec_test_test_fscommand), test);
g_signal_connect (test->player, "trace", G_CALLBACK (swfdec_test_test_trace_cb), test);
return TRUE;
diff --git a/tools/crashfinder.c b/tools/crashfinder.c
index addf1da..5840862 100644
--- a/tools/crashfinder.c
+++ b/tools/crashfinder.c
@@ -30,7 +30,7 @@ main (int argc, char **argv)
GOptionContext *context;
GError *err;
SwfdecPlayer *player;
- SwfdecLoader *loader;
+ SwfdecURL *url;
guint i;
cairo_surface_t *surface;
cairo_t *cr;
@@ -93,26 +93,16 @@ main (int argc, char **argv)
for (i = 0; i < g_strv_length (filenames); i++)
{
glong played, advance, elapsed;
- char *error;
g_print ("Running: %s\n", filenames[i]);
// start timer
timer = g_timer_new ();
- // create player
- loader = swfdec_file_loader_new (filenames[i]);
player = swfdec_player_new (NULL);
-
- g_object_get (loader, "error", &error, NULL);
- if (error) {
- g_printerr ("Error loading %s: %s\n", filenames[i], error);
- g_object_unref (loader);
- g_free (error);
- continue;
- }
-
- swfdec_player_set_loader (player, loader);
+ url = swfdec_url_new_from_input (argv[1]);
+ swfdec_player_set_url (player, url);
+ swfdec_url_free (url);
// loop until we have played what we wanted, or timelimit is hit
played = 0;
diff --git a/tools/dump.c b/tools/dump.c
index c8c1e1f..0ab7d59 100644
--- a/tools/dump.c
+++ b/tools/dump.c
@@ -386,6 +386,7 @@ main (int argc, char *argv[])
};
GOptionContext *ctx;
GList *list = NULL;
+ SwfdecURL *url;
ctx = g_option_context_new ("");
g_option_context_add_main_entries (ctx, options, "options");
@@ -404,7 +405,10 @@ main (int argc, char *argv[])
return 0;
}
- player = swfdec_player_new_from_file (argv[1]);
+ player = swfdec_player_new (NULL);
+ url = swfdec_url_new_from_input (argv[1]);
+ swfdec_player_set_url (player, url);
+ swfdec_url_free (url);
/* FIXME: HACK! */
swfdec_player_advance (player, 0);
if (!swfdec_player_is_initialized (player)) {
diff --git a/tools/swfdec-extract.c b/tools/swfdec-extract.c
index 3edfd25..2c72f3b 100644
--- a/tools/swfdec-extract.c
+++ b/tools/swfdec-extract.c
@@ -250,6 +250,7 @@ main (int argc, char *argv[])
int ret = 0;
SwfdecPlayer *player;
glong id;
+ SwfdecURL *url;
swfdec_init ();
@@ -258,7 +259,10 @@ main (int argc, char *argv[])
return 0;
}
- player = swfdec_player_new_from_file (argv[1]);
+ player = swfdec_player_new (NULL);
+ url = swfdec_url_new_from_input (argv[1]);
+ swfdec_player_set_url (player, url);
+ swfdec_url_free (url);
/* FIXME: HACK! */
swfdec_player_advance (player, 0);
if (!SWFDEC_IS_SPRITE_MOVIE (player->priv->roots->data)) {
diff --git a/vivified/core/vivi_application.c b/vivified/core/vivi_application.c
index 40051aa..ab41662 100644
--- a/vivified/core/vivi_application.c
+++ b/vivified/core/vivi_application.c
@@ -302,11 +302,13 @@ vivi_application_check (ViviApplication *app)
app->playback_state = VIVI_APPLICATION_STOPPED;
vivi_application_check (app);
} else {
- SwfdecLoader *loader;
+ SwfdecURL *url;
app->player_inited = TRUE;
- loader = swfdec_file_loader_new (app->filename);
- swfdec_player_set_loader_with_variables (app->player, loader, app->variables);
+ swfdec_player_set_variables (app->player, app->variables);
+ url = swfdec_url_new_from_input (app->filename);
+ swfdec_player_set_url (app->player, url);
+ swfdec_url_free (url);
}
}
}
commit 2b6ddca7b2ff30b7107ac3952892c206d56f38c5
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jan 24 12:46:47 2008 +0100
fix test
diff --git a/test/various/gc.c b/test/various/gc.c
index ebc87a8..cb21202 100644
--- a/test/various/gc.c
+++ b/test/various/gc.c
@@ -40,7 +40,7 @@ check_strings (void)
SwfdecAsContext *context;
context = g_object_new (SWFDEC_TYPE_AS_CONTEXT, NULL);
- swfdec_as_context_startup (context, 7);
+ swfdec_as_context_startup (context);
s = swfdec_as_context_get_string (context, "hi mom");
if (!g_str_equal (s, "hi mom")) {
@@ -61,7 +61,7 @@ check_objects (void)
gpointer check = GUINT_TO_POINTER (-1); /* NOT NULL */
context = g_object_new (SWFDEC_TYPE_AS_CONTEXT, NULL);
- swfdec_as_context_startup (context, 7);
+ swfdec_as_context_startup (context);
g_assert (check != NULL);
object = swfdec_as_object_new (context);
@@ -96,7 +96,7 @@ check_object_variables (void)
SwfdecAsValue v1, v2;
context = g_object_new (SWFDEC_TYPE_AS_CONTEXT, NULL);
- swfdec_as_context_startup (context, 7);
+ swfdec_as_context_startup (context);
g_assert (check != NULL);
o = swfdec_as_object_new (context);
commit 25991c8b0397343d6584bbbd1032d91ba66e729f
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Jan 24 10:14:46 2008 +0100
make swfdec_stream_error use a printf-style error message
diff --git a/libswfdec-gtk/swfdec_gtk_loader.c b/libswfdec-gtk/swfdec_gtk_loader.c
index 71f6b6f..6013730 100644
--- a/libswfdec-gtk/swfdec_gtk_loader.c
+++ b/libswfdec-gtk/swfdec_gtk_loader.c
@@ -118,9 +118,7 @@ swfdec_gtk_loader_finished (SoupMessage *msg, gpointer loader)
swfdec_gtk_loader_ensure_open (loader);
swfdec_stream_eof (loader);
} else {
- char *s = g_strdup_printf ("%u %s", msg->status_code, msg->reason_phrase);
- swfdec_stream_error (loader, s);
- g_free (s);
+ swfdec_stream_error (loader, "%u %s", msg->status_code, msg->reason_phrase);
}
}
diff --git a/libswfdec/swfdec_file_loader.c b/libswfdec/swfdec_file_loader.c
index b632f15..625f5fa 100644
--- a/libswfdec/swfdec_file_loader.c
+++ b/libswfdec/swfdec_file_loader.c
@@ -54,8 +54,8 @@ swfdec_file_loader_load (SwfdecLoader *loader, SwfdecLoader *parent,
url = swfdec_url_new (url_string);
}
if (url == NULL) {
- //swfdec_stream_error (stream, "%s is an invalid URL", url_string);
- swfdec_stream_error (stream, "invalid URL");
+ swfdec_stream_error (stream, "%s is an invalid URL", url_string);
+ return;
}
swfdec_loader_set_url (loader, swfdec_url_get_url (url));
if (!g_str_equal (swfdec_url_get_protocol (url), "file")) {
@@ -74,7 +74,7 @@ swfdec_file_loader_load (SwfdecLoader *loader, SwfdecLoader *parent,
buffer = swfdec_buffer_new_from_file (real, &error);
g_free (real);
if (buffer == NULL) {
- swfdec_stream_error (stream, error->message);
+ swfdec_stream_error (stream, "%s", error->message);
g_error_free (error);
} else {
swfdec_loader_set_size (loader, buffer->length);
@@ -135,7 +135,7 @@ swfdec_file_loader_new (const char *filename)
swfdec_loader_set_url (loader, url_string);
stream = SWFDEC_STREAM (loader);
if (buf == NULL) {
- swfdec_stream_error (stream, error->message);
+ swfdec_stream_error (stream, "%s", error->message);
g_error_free (error);
} else {
swfdec_loader_set_size (loader, buf->length);
diff --git a/libswfdec/swfdec_stream.c b/libswfdec/swfdec_stream.c
index 545d0c9..11be333 100644
--- a/libswfdec/swfdec_stream.c
+++ b/libswfdec/swfdec_stream.c
@@ -311,29 +311,57 @@ swfdec_stream_describe (SwfdecStream *stream)
/**
* swfdec_stream_error:
* @stream: a #SwfdecStream
- * @error: a string describing the error
+ * @error: a printf-style string describing the error
+ * @...: arguments for the @error string
*
* Moves the stream in the error state if it wasn't before. A stream that is in
* the error state will not process any more data. Also, internal error
* handling scripts may be executed.
**/
void
-swfdec_stream_error (SwfdecStream *stream, const char *error)
+swfdec_stream_error (SwfdecStream *stream, const char *error, ...)
+{
+ va_list args;
+
+ g_return_if_fail (SWFDEC_IS_STREAM (stream));
+ g_return_if_fail (error != NULL);
+
+ va_start (args, error);
+ swfdec_stream_errorv (stream, error, args);
+ va_end (args);
+}
+
+/**
+ * swfdec_stream_errorv:
+ * @stream: a #SwfdecStream
+ * @error: a printf-style error string
+ * @args: arguments for @error
+ *
+ * This function is the va_list alternative to swfdec_stream_error(). See that
+ * function for details.
+ **/
+void
+swfdec_stream_errorv (SwfdecStream *stream, const char *error, va_list args)
{
SwfdecStreamPrivate *priv;
+ char *real_error;
g_return_if_fail (SWFDEC_IS_STREAM (stream));
g_return_if_fail (error != NULL);
+ real_error = g_strdup_vprintf (error, args);
priv = stream->priv;
if (priv->error) {
- SWFDEC_ERROR ("another error in stream for %s: %s", swfdec_stream_describe (stream), error);
+ SWFDEC_ERROR ("another error in stream for %s: %s",
+ swfdec_stream_describe (stream), real_error);
+ g_free (real_error);
return;
}
- SWFDEC_ERROR ("error in stream for %s: %s", swfdec_stream_describe (stream), error);
+ SWFDEC_ERROR ("error in stream for %s: %s",
+ swfdec_stream_describe (stream), real_error);
priv->state = SWFDEC_STREAM_STATE_ERROR;
- priv->error = g_strdup (error);
+ priv->error = real_error;
swfdec_stream_queue_processing (stream);
}
diff --git a/libswfdec/swfdec_stream.h b/libswfdec/swfdec_stream.h
index 2e87a50..f1cb86c 100644
--- a/libswfdec/swfdec_stream.h
+++ b/libswfdec/swfdec_stream.h
@@ -61,13 +61,11 @@ void swfdec_stream_push (SwfdecStream * stream,
SwfdecBuffer * buffer);
void swfdec_stream_eof (SwfdecStream * stream);
void swfdec_stream_error (SwfdecStream * stream,
- const char * error);
-#if 0
+ const char * error,
...) G_GNUC_PRINTF (2, 3);
void swfdec_stream_errorv (SwfdecStream * stream,
const char * error,
va_list args);
-#endif
G_END_DECLS
#endif
commit 08e0e3ebeff7463737ce5349f14be75a118a0895
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Jan 23 21:42:26 2008 +0100
rework SwfdecLoader->load yet again
It seems we need to pass the relative URL to the loader, yay!
diff --git a/libswfdec-gtk/swfdec_gtk_loader.c b/libswfdec-gtk/swfdec_gtk_loader.c
index 26823cc..71f6b6f 100644
--- a/libswfdec-gtk/swfdec_gtk_loader.c
+++ b/libswfdec-gtk/swfdec_gtk_loader.c
@@ -140,18 +140,33 @@ swfdec_gtk_loader_dispose (GObject *object)
}
static void
-swfdec_gtk_loader_load (SwfdecLoader *loader, SwfdecLoader *parent,
- SwfdecLoaderRequest request, SwfdecBuffer *buffer)
+swfdec_gtk_loader_load (SwfdecLoader *loader, SwfdecLoader *parent,
+ const char *url_string, SwfdecLoaderRequest request, SwfdecBuffer *buffer)
{
- const SwfdecURL *url = swfdec_loader_get_url (loader);
+ SwfdecURL *url;
+
+ if (parent) {
+ SwfdecURL *parent_url = swfdec_url_new_parent (swfdec_loader_get_url (parent));
+ url = swfdec_url_new_relative (parent_url, url_string);
+ swfdec_url_free (parent_url);
+ } else {
+ url = swfdec_url_new (url_string);
+ }
- if (g_ascii_strcasecmp (swfdec_url_get_protocol (url), "http") != 0 &&
- g_ascii_strcasecmp (swfdec_url_get_protocol (url), "https") != 0) {
- SWFDEC_LOADER_CLASS (swfdec_gtk_loader_parent_class)->load (loader, parent, request, buffer);
+ if (url == NULL) {
+ //swfdec_stream_error (loader, "invalid URL %s", url_string);
+ swfdec_stream_error (SWFDEC_STREAM (loader), "invalid URL");
+ return;
+ };
+ if (!swfdec_url_has_protocol (url, "http") &&
+ !swfdec_url_has_protocol (url, "https")) {
+ SWFDEC_LOADER_CLASS (swfdec_gtk_loader_parent_class)->load (loader,
+ parent, url_string, request, buffer);
} else {
SwfdecGtkLoader *gtk = SWFDEC_GTK_LOADER (loader);
SwfdecGtkLoaderClass *klass = SWFDEC_GTK_LOADER_GET_CLASS (gtk);
+ swfdec_loader_set_url (loader, swfdec_url_get_url (url));
gtk->message = soup_message_new (request == SWFDEC_LOADER_REQUEST_POST ? "POST" : "GET",
swfdec_url_get_url (url));
soup_message_set_flags (gtk->message, SOUP_MESSAGE_OVERWRITE_CHUNKS);
@@ -163,6 +178,7 @@ swfdec_gtk_loader_load (SwfdecLoader *loader, SwfdecLoader *parent,
g_object_ref (gtk->message);
soup_session_queue_message (klass->session, gtk->message, NULL, NULL);
}
+ swfdec_url_free (url);
}
static void
@@ -223,8 +239,9 @@ swfdec_gtk_loader_new (const char *uri)
g_return_val_if_fail (uri != NULL, NULL);
url = swfdec_url_new (uri);
- loader = g_object_new (SWFDEC_TYPE_GTK_LOADER, "url", url, NULL);
+ loader = g_object_new (SWFDEC_TYPE_GTK_LOADER, NULL);
+ swfdec_gtk_loader_load (loader, NULL, swfdec_url_get_url (url), SWFDEC_LOADER_REQUEST_DEFAULT, NULL);
+ /* END HACK */
swfdec_url_free (url);
- swfdec_gtk_loader_load (loader, NULL, SWFDEC_LOADER_REQUEST_DEFAULT, NULL);
return loader;
}
diff --git a/libswfdec/swfdec_file_loader.c b/libswfdec/swfdec_file_loader.c
index a393185..b632f15 100644
--- a/libswfdec/swfdec_file_loader.c
+++ b/libswfdec/swfdec_file_loader.c
@@ -39,20 +39,33 @@ G_DEFINE_TYPE (SwfdecFileLoader, swfdec_file_loader, SWFDEC_TYPE_LOADER)
static void
swfdec_file_loader_load (SwfdecLoader *loader, SwfdecLoader *parent,
- SwfdecLoaderRequest request, SwfdecBuffer *buffer)
+ const char *url_string, SwfdecLoaderRequest request, SwfdecBuffer *buffer)
{
SwfdecStream *stream = SWFDEC_STREAM (loader);
- const SwfdecURL *url;
GError *error = NULL;
char *real;
+ SwfdecURL *url;
- url = swfdec_loader_get_url (loader);
+ if (parent) {
+ SwfdecURL *parent_url = swfdec_url_new_parent (swfdec_loader_get_url (parent));
+ url = swfdec_url_new_relative (parent_url, url_string);
+ swfdec_url_free (parent_url);
+ } else {
+ url = swfdec_url_new (url_string);
+ }
+ if (url == NULL) {
+ //swfdec_stream_error (stream, "%s is an invalid URL", url_string);
+ swfdec_stream_error (stream, "invalid URL");
+ }
+ swfdec_loader_set_url (loader, swfdec_url_get_url (url));
if (!g_str_equal (swfdec_url_get_protocol (url), "file")) {
swfdec_stream_error (stream, "Don't know how to handle this protocol");
+ swfdec_url_free (url);
return;
}
if (swfdec_url_get_host (url)) {
swfdec_stream_error (stream, "filenames cannot have hostnames");
+ swfdec_url_free (url);
return;
}
@@ -69,6 +82,7 @@ swfdec_file_loader_load (SwfdecLoader *loader, SwfdecLoader *parent,
swfdec_stream_push (stream, buffer);
swfdec_stream_eof (stream);
}
+ swfdec_url_free (url);
}
static void
@@ -101,7 +115,6 @@ swfdec_file_loader_new (const char *filename)
SwfdecStream *stream;
GError *error = NULL;
char *url_string;
- SwfdecURL *url;
g_return_val_if_fail (filename != NULL, NULL);
@@ -118,11 +131,9 @@ swfdec_file_loader_new (const char *filename)
g_free (abs);
}
- url = swfdec_url_new (url_string);
- g_free (url_string);
- loader = g_object_new (SWFDEC_TYPE_FILE_LOADER, "url", url, NULL);
+ loader = g_object_new (SWFDEC_TYPE_FILE_LOADER, NULL);
+ swfdec_loader_set_url (loader, url_string);
stream = SWFDEC_STREAM (loader);
- swfdec_url_free (url);
if (buf == NULL) {
swfdec_stream_error (stream, error->message);
g_error_free (error);
diff --git a/libswfdec/swfdec_load_object.c b/libswfdec/swfdec_load_object.c
index b8e4ef5..0e6e58d 100644
--- a/libswfdec/swfdec_load_object.c
+++ b/libswfdec/swfdec_load_object.c
@@ -154,7 +154,7 @@ swfdec_load_object_init (SwfdecLoadObject *load_object)
}
static void
-swfdec_load_object_load (SwfdecPlayer *player, const SwfdecURL *url, gboolean allow, gpointer obj)
+swfdec_load_object_load (SwfdecPlayer *player, gboolean allow, gpointer obj)
{
SwfdecLoadObject *load = SWFDEC_LOAD_OBJECT (obj);
@@ -167,7 +167,7 @@ swfdec_load_object_load (SwfdecPlayer *player, const SwfdecURL *url, gboolean al
return;
}
- load->loader = swfdec_loader_load (player->priv->resource->loader, url, load->request, load->buffer);
+ load->loader = swfdec_player_load (player, load->url, load->request, load->buffer);
swfdec_stream_set_target (SWFDEC_STREAM (load->loader), SWFDEC_STREAM_TARGET (load));
swfdec_loader_set_data_type (load->loader, SWFDEC_LOADER_DATA_TEXT);
@@ -181,10 +181,14 @@ swfdec_load_object_request (gpointer objectp, gpointer playerp)
SwfdecPlayer *player = SWFDEC_PLAYER (playerp);
SwfdecURL *url;
+ if (swfdec_url_path_is_relative (load->url)) {
+ swfdec_load_object_load (player, TRUE, load);
+ return;
+ }
/* FIXME: or is this relative to the player? */
url = swfdec_player_create_url (player, load->url);
if (url == NULL) {
- swfdec_load_object_load (player, NULL, FALSE, load);
+ swfdec_load_object_load (player, FALSE, load);
return;
}
switch (load->sandbox->type) {
@@ -192,7 +196,7 @@ swfdec_load_object_request (gpointer objectp, gpointer playerp)
case SWFDEC_SANDBOX_LOCAL_NETWORK:
case SWFDEC_SANDBOX_LOCAL_TRUSTED:
if (swfdec_url_is_local (url)) {
- swfdec_load_object_load (player, url, swfdec_url_is_local (url), load);
+ swfdec_load_object_load (player, swfdec_url_is_local (url), load);
} else {
SwfdecURL *load_url = swfdec_url_new_components (
swfdec_url_get_protocol (url), swfdec_url_get_host (url),
@@ -203,7 +207,7 @@ swfdec_load_object_request (gpointer objectp, gpointer playerp)
}
break;
case SWFDEC_SANDBOX_LOCAL_FILE:
- swfdec_load_object_load (player, url, swfdec_url_is_local (url), load);
+ swfdec_load_object_load (player, swfdec_url_is_local (url), load);
break;
case SWFDEC_SANDBOX_NONE:
default:
diff --git a/libswfdec/swfdec_loader.c b/libswfdec/swfdec_loader.c
index acf6944..e907e59 100644
--- a/libswfdec/swfdec_loader.c
+++ b/libswfdec/swfdec_loader.c
@@ -105,7 +105,13 @@ G_DEFINE_ABSTRACT_TYPE (SwfdecLoader, swfdec_loader, SWFDEC_TYPE_STREAM)
static const char *
swfdec_loader_describe (SwfdecStream *stream)
{
- return swfdec_url_get_url (SWFDEC_LOADER (stream)->url);
+ const SwfdecURL *url = SWFDEC_LOADER (stream)->url;
+
+ if (url) {
+ return swfdec_url_get_url (url);
+ } else {
+ return "unknown url";
+ }
}
static void
@@ -144,13 +150,6 @@ swfdec_loader_set_property (GObject *object, guint param_id, const GValue *value
if (loader->size == -1 && g_value_get_long (value) >= 0)
swfdec_loader_set_size (loader, g_value_get_long (value));
break;
- case PROP_URL:
- loader->url = g_value_dup_boxed (value);
- if (loader->url == NULL) {
- g_warning ("must set a valid URL");
- loader->url = swfdec_url_new ("");
- }
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -191,7 +190,7 @@ swfdec_loader_class_init (SwfdecLoaderClass *klass)
0, G_MAXULONG, 0, G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_URL,
g_param_spec_boxed ("url", "url", "URL for this file",
- SWFDEC_TYPE_URL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ SWFDEC_TYPE_URL, G_PARAM_READABLE));
stream_class->describe = swfdec_loader_describe;
}
@@ -207,7 +206,7 @@ swfdec_loader_init (SwfdecLoader *loader)
/*** INTERNAL API ***/
SwfdecLoader *
-swfdec_loader_load (SwfdecLoader *loader, const SwfdecURL *url,
+swfdec_loader_load (SwfdecLoader *loader, const char *url,
SwfdecLoaderRequest request, SwfdecBuffer *buffer)
{
SwfdecLoader *ret;
@@ -218,8 +217,9 @@ swfdec_loader_load (SwfdecLoader *loader, const SwfdecURL *url,
klass = SWFDEC_LOADER_GET_CLASS (loader);
g_return_val_if_fail (klass->load != NULL, NULL);
- ret = g_object_new (G_OBJECT_CLASS_TYPE (klass), "url", url, NULL);
- klass->load (ret, loader, request, buffer);
+ ret = g_object_new (G_OBJECT_CLASS_TYPE (klass), NULL);
+ klass->load (ret, loader, url, request, buffer);
+ g_return_val_if_fail (loader->url != NULL, ret);
return ret;
}
@@ -281,17 +281,21 @@ swfdec_loader_get_filename (SwfdecLoader *loader)
* Updates the url of the given @loader to point to the new @url. This is useful
* whe encountering HTTP redirects, as the loader is supposed to reference the
* final URL after all rdirections.
- * This function may not be called after calling swfdec_loader_open().
+ * This function may only be called once and must have been called before
+ * calling swfdec_stream_open() on @loader.
**/
void
swfdec_loader_set_url (SwfdecLoader *loader, const char *url)
{
+ SwfdecURL *real;
+
g_return_if_fail (SWFDEC_IS_LOADER (loader));
+ g_return_if_fail (loader->url == NULL);
g_return_if_fail (url != NULL);
- /* g_return_if_fail (LOADER_IS_NOT_OPEN_YET) */
- swfdec_url_free (loader->url);
- loader->url = swfdec_url_new (url);
+ real = swfdec_url_new (url);
+ g_return_if_fail (real != NULL);
+ loader->url = real;
}
/**
@@ -301,7 +305,8 @@ swfdec_loader_set_url (SwfdecLoader *loader, const char *url)
* Gets the url this loader is handling. This is mostly useful for writing
* subclasses of #SwfdecLoader.
*
- * Returns: a #SwfdecURL describing @loader.
+ * Returns: a #SwfdecURL describing @loader or %NULL if the @url is not known
+ * yet.
**/
const SwfdecURL *
swfdec_loader_get_url (SwfdecLoader *loader)
diff --git a/libswfdec/swfdec_loader.h b/libswfdec/swfdec_loader.h
index e22cabd..59bb0e8 100644
--- a/libswfdec/swfdec_loader.h
+++ b/libswfdec/swfdec_loader.h
@@ -58,7 +58,7 @@ struct _SwfdecLoader
{
SwfdecStream stream;
- /*< private >*/
+ /*< protected >*/
SwfdecURL * url; /* the URL for this loader in UTF-8 - must be set on creation */
glong size; /* number of bytes in stream or -1 if unknown */
SwfdecLoaderDataType data_type; /* type this stream is in (identified by swfdec) */
@@ -68,9 +68,9 @@ struct _SwfdecLoaderClass
{
SwfdecStreamClass stream_class;
- /* initialize the loader. The URL will be set already. */
void (* load) (SwfdecLoader * loader,
SwfdecLoader * parent,
+ const char * url,
SwfdecLoaderRequest request,
SwfdecBuffer * buffer);
};
diff --git a/libswfdec/swfdec_loader_internal.h b/libswfdec/swfdec_loader_internal.h
index bb7bf67..c979fe4 100644
--- a/libswfdec/swfdec_loader_internal.h
+++ b/libswfdec/swfdec_loader_internal.h
@@ -34,7 +34,7 @@ void swfdec_stream_set_target (SwfdecStream * stream,
/* swfdec_loader.c */
SwfdecLoader * swfdec_loader_load (SwfdecLoader * loader,
- const SwfdecURL * url,
+ const char * url,
SwfdecLoaderRequest request,
SwfdecBuffer * buffer);
void swfdec_loader_set_data_type (SwfdecLoader * loader,
diff --git a/libswfdec/swfdec_net_stream.c b/libswfdec/swfdec_net_stream.c
index 080cd32..a8ec140 100644
--- a/libswfdec/swfdec_net_stream.c
+++ b/libswfdec/swfdec_net_stream.c
@@ -372,6 +372,8 @@ swfdec_net_stream_dispose (GObject *object)
}
swfdec_net_stream_set_loader (stream, NULL);
g_assert (stream->movies == NULL);
+ g_free (stream->requested_url);
+ stream->requested_url = NULL;
G_OBJECT_CLASS (swfdec_net_stream_parent_class)->dispose (object);
}
@@ -478,21 +480,23 @@ swfdec_net_stream_new (SwfdecNetConnection *conn)
}
static void
-swfdec_net_stream_load (SwfdecPlayer *player, const SwfdecURL *url, gboolean allowed, gpointer streamp)
+swfdec_net_stream_load (SwfdecPlayer *player, gboolean allowed, gpointer streamp)
{
SwfdecNetStream *stream = streamp;
SwfdecLoader *loader;
if (allowed) {
- loader = swfdec_loader_load (player->priv->resource->loader, url,
+ loader = swfdec_player_load (player, stream->requested_url,
SWFDEC_LOADER_REQUEST_DEFAULT, NULL);
swfdec_net_stream_set_loader (stream, loader);
g_object_unref (loader);
} else {
SWFDEC_WARNING ("SECURITY: no access to %s from NetStream",
- url ? swfdec_url_get_url (url) : "invalid URL");
+ stream->requested_url);
stream->sandbox = NULL;
}
+ g_free (stream->requested_url);
+ stream->requested_url = NULL;
}
void
@@ -507,19 +511,29 @@ swfdec_net_stream_set_url (SwfdecNetStream *stream, SwfdecSandbox *sandbox, cons
cx = SWFDEC_AS_OBJECT (stream)->context;
player = SWFDEC_PLAYER (cx);
+
+ if (stream->requested_url != NULL) {
+ SWFDEC_FIXME ("can't load %s - already loading %s, what now?",
+ url_string, stream->requested_url);
+ return;
+ }
+ stream->requested_url = g_strdup (url_string);
+ stream->sandbox = sandbox;
+ if (swfdec_url_path_is_relative (url_string)) {
+ swfdec_net_stream_load (player, TRUE, stream);
+ return;
+ }
url = swfdec_player_create_url (player, url_string);
if (url == NULL) {
- swfdec_net_stream_load (player, NULL, FALSE, stream);
+ swfdec_net_stream_load (player, FALSE, stream);
return;
}
-
- stream->sandbox = sandbox;
if (swfdec_url_is_local (url)) {
- swfdec_net_stream_load (player, url, TRUE, stream);
+ swfdec_net_stream_load (player, TRUE, stream);
} else {
switch (sandbox->type) {
case SWFDEC_SANDBOX_REMOTE:
- swfdec_net_stream_load (player, url, TRUE, stream);
+ swfdec_net_stream_load (player, TRUE, stream);
break;
case SWFDEC_SANDBOX_LOCAL_NETWORK:
case SWFDEC_SANDBOX_LOCAL_TRUSTED:
@@ -533,7 +547,7 @@ swfdec_net_stream_set_url (SwfdecNetStream *stream, SwfdecSandbox *sandbox, cons
}
break;
case SWFDEC_SANDBOX_LOCAL_FILE:
- swfdec_net_stream_load (player, url, FALSE, stream);
+ swfdec_net_stream_load (player, FALSE, stream);
break;
case SWFDEC_SANDBOX_NONE:
default:
diff --git a/libswfdec/swfdec_net_stream.h b/libswfdec/swfdec_net_stream.h
index 60a74cd..943c834 100644
--- a/libswfdec/swfdec_net_stream.h
+++ b/libswfdec/swfdec_net_stream.h
@@ -46,6 +46,7 @@ struct _SwfdecNetStream
SwfdecAsObject object;
SwfdecNetConnection * conn; /* connection used for opening streams */
+ char * requested_url; /* URL we have requested that isn't loaded yet */
SwfdecLoader * loader; /* input stream */
SwfdecSandbox * sandbox; /* sandbox to emit events in */
SwfdecFlvDecoder * flvdecoder; /* flv decoder */
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index 8cf835f..bf096f4 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -2141,12 +2141,11 @@ swfdec_player_create_url (SwfdecPlayer *player, const char *string)
}
SwfdecLoader *
-swfdec_player_load (SwfdecPlayer *player, const SwfdecURL *url,
+swfdec_player_load (SwfdecPlayer *player, const char *url,
SwfdecLoaderRequest request, SwfdecBuffer *buffer)
{
g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
g_return_val_if_fail (url != NULL, NULL);
- g_return_val_if_fail (buffer != NULL, NULL);
return swfdec_loader_load (player->priv->resource->loader, url, request, buffer);
}
diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h
index 15ed76e..c53a9f6 100644
--- a/libswfdec/swfdec_player_internal.h
+++ b/libswfdec/swfdec_player_internal.h
@@ -41,7 +41,7 @@ typedef enum {
typedef void (* SwfdecActionFunc) (gpointer object, gpointer data);
typedef gboolean (* SwfdecAudioRemoveFunc) (SwfdecAudio *audio, gpointer data);
-typedef void (* SwfdecPolicyFunc) (SwfdecPlayer *player, const SwfdecURL *url, gboolean allow, gpointer data);
+typedef void (* SwfdecPolicyFunc) (SwfdecPlayer *player, gboolean allow, gpointer data);
typedef struct _SwfdecTimeout SwfdecTimeout;
struct _SwfdecTimeout {
@@ -166,7 +166,7 @@ void swfdec_player_perform_actions (SwfdecPlayer * player);
SwfdecURL * swfdec_player_create_url (SwfdecPlayer * player,
const char * string);
SwfdecLoader * swfdec_player_load (SwfdecPlayer * player,
- const SwfdecURL * url,
+ const char * url,
SwfdecLoaderRequest request,
SwfdecBuffer * buffer);
SwfdecAsObject *swfdec_player_get_export_class (SwfdecPlayer * player,
diff --git a/libswfdec/swfdec_policy_file.c b/libswfdec/swfdec_policy_file.c
index b2d1450..80fd599 100644
--- a/libswfdec/swfdec_policy_file.c
+++ b/libswfdec/swfdec_policy_file.c
@@ -146,7 +146,7 @@ swfdec_policy_file_finished_loading (SwfdecPolicyFile *file, const char *text)
for (walk = file->requests; walk; walk = walk->next) {
SwfdecPolicyFileRequest *request = walk->data;
gboolean allow = swfdec_player_allow_now (file->player, request->url);
- request->func (file->player, request->url, allow, request->data);
+ request->func (file->player, allow, request->data);
swfdec_policy_file_request_free (request);
}
g_slist_free (file->requests);
@@ -249,8 +249,8 @@ swfdec_policy_file_new (SwfdecPlayer *player, const SwfdecURL *url)
if (swfdec_url_has_protocol (url, "xmlsocket")) {
SWFDEC_FIXME ("implement xmlsocket: protocol");
} else {
- file->stream = SWFDEC_STREAM (swfdec_loader_load (player->priv->resource->loader,
- url, SWFDEC_LOADER_REQUEST_DEFAULT, NULL));
+ file->stream = SWFDEC_STREAM (swfdec_player_load (player,
+ swfdec_url_get_url (url), SWFDEC_LOADER_REQUEST_DEFAULT, NULL));
swfdec_stream_set_target (file->stream, SWFDEC_STREAM_TARGET (file));
}
player->priv->loading_policy_files =
@@ -328,7 +328,7 @@ swfdec_player_allow_or_load (SwfdecPlayer *player, const SwfdecURL *url,
g_return_if_fail (func);
if (swfdec_player_allow_now (player, url)) {
- func (player, url, TRUE, data);
+ func (player, TRUE, data);
return;
}
if (load_url)
@@ -336,7 +336,7 @@ swfdec_player_allow_or_load (SwfdecPlayer *player, const SwfdecURL *url,
priv = player->priv;
if (priv->loading_policy_files == NULL) {
- func (player, url, FALSE, data);
+ func (player, FALSE, data);
return;
}
request = g_slice_new (SwfdecPolicyFileRequest);
diff --git a/libswfdec/swfdec_resource.c b/libswfdec/swfdec_resource.c
index 5670dce..2ea802f 100644
--- a/libswfdec/swfdec_resource.c
+++ b/libswfdec/swfdec_resource.c
@@ -525,7 +525,7 @@ swfdec_resource_load_mark (gpointer loadp, gpointer playerp)
}
static void
-swfdec_resource_do_load (SwfdecPlayer *player, const SwfdecURL *url, gboolean allowed, gpointer loadp)
+swfdec_resource_do_load (SwfdecPlayer *player, gboolean allowed, gpointer loadp)
{
SwfdecResourceLoad *load = loadp;
SwfdecResource *resource;
@@ -552,8 +552,7 @@ swfdec_resource_do_load (SwfdecPlayer *player, const SwfdecURL *url, gboolean al
}
swfdec_player_root (player, resource, (GFunc) swfdec_as_object_mark);
- loader = swfdec_loader_load (player->priv->resource->loader,
- url, load->request, load->buffer);
+ loader = swfdec_player_load (player, load-> url, load->request, load->buffer);
swfdec_resource_set_loader (resource, loader);
g_object_unref (loader);
}
@@ -593,14 +592,18 @@ swfdec_resource_load_request (gpointer loadp, gpointer playerp)
return;
}
+ if (swfdec_url_path_is_relative (load->url)) {
+ swfdec_resource_do_load (player, TRUE, load);
+ return;
+ }
url = swfdec_player_create_url (player, load->url);
if (url == NULL) {
- swfdec_resource_do_load (player, NULL, FALSE, load);
+ swfdec_resource_do_load (player, FALSE, load);
return;
}
switch (load->sandbox->type) {
case SWFDEC_SANDBOX_REMOTE:
- swfdec_resource_do_load (player, url, !swfdec_url_is_local (url), load);
+ swfdec_resource_do_load (player, !swfdec_url_is_local (url), load);
break;
case SWFDEC_SANDBOX_LOCAL_NETWORK:
case SWFDEC_SANDBOX_LOCAL_TRUSTED:
@@ -608,10 +611,10 @@ swfdec_resource_load_request (gpointer loadp, gpointer playerp)
SWFDEC_FIXME ("Adobe claims you need to be allowed by policy files now, "
"we don't check that though");
}
- swfdec_resource_do_load (player, url, TRUE, load);
+ swfdec_resource_do_load (player, TRUE, load);
break;
case SWFDEC_SANDBOX_LOCAL_FILE:
- swfdec_resource_do_load (player, url, swfdec_url_is_local (url), load);
+ swfdec_resource_do_load (player, swfdec_url_is_local (url), load);
break;
case SWFDEC_SANDBOX_NONE:
default:
diff --git a/libswfdec/swfdec_stream.h b/libswfdec/swfdec_stream.h
index f971886..2e87a50 100644
--- a/libswfdec/swfdec_stream.h
+++ b/libswfdec/swfdec_stream.h
@@ -62,7 +62,12 @@ void swfdec_stream_push (SwfdecStream * stream,
void swfdec_stream_eof (SwfdecStream * stream);
void swfdec_stream_error (SwfdecStream * stream,
const char * error);
-
+#if 0
+ ...) G_GNUC_PRINTF (2, 3);
+void swfdec_stream_errorv (SwfdecStream * stream,
+ const char * error,
+ va_list args);
+#endif
G_END_DECLS
#endif
diff --git a/libswfdec/swfdec_url.c b/libswfdec/swfdec_url.c
index f22f179..6e16761 100644
--- a/libswfdec/swfdec_url.c
+++ b/libswfdec/swfdec_url.c
@@ -609,3 +609,18 @@ swfdec_url_hash (gconstpointer url)
return ret;
}
+/**
+ * swfdec_url_path_is_relative:
+ * @path: a string used to specify a url
+ *
+ * Checks if the given URL is relative or absolute.
+ *
+ * Returns: %TRUE if the path is a relative path, %FALSE if it is absolute
+ **/
+gboolean
+swfdec_url_path_is_relative (const char *path)
+{
+ g_return_val_if_fail (path != NULL, FALSE);
+
+ return strstr (path, "://") == NULL;
+}
diff --git a/libswfdec/swfdec_url.h b/libswfdec/swfdec_url.h
index 36a0dab..155b0af 100644
--- a/libswfdec/swfdec_url.h
+++ b/libswfdec/swfdec_url.h
@@ -58,6 +58,8 @@ gboolean swfdec_url_is_local (const SwfdecURL * url);
gboolean swfdec_url_equal (gconstpointer a,
gconstpointer b);
guint swfdec_url_hash (gconstpointer url);
+
+gboolean swfdec_url_path_is_relative (const char * path);
G_END_DECLS
commit 59b95ed4887b59a2ebd119c6098b00cd5204e044
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Jan 23 11:56:30 2008 +0100
rework URL handling
- add swfdec_player_create_url() for creating (possibly realtive) urls
- add swfdec_player_load() as a shortcut to calling swfdec_loader_load() with
player->priv->resource->loader
- rework url creation code, in particular swfdec_url_new_relative() to be closer
to what Flash does
- update relevant code to use new APIs
diff --git a/libswfdec/swfdec_load_object.c b/libswfdec/swfdec_load_object.c
index 33c4e4b..b8e4ef5 100644
--- a/libswfdec/swfdec_load_object.c
+++ b/libswfdec/swfdec_load_object.c
@@ -162,8 +162,6 @@ swfdec_load_object_load (SwfdecPlayer *player, const SwfdecURL *url, gboolean al
SWFDEC_WARNING ("SECURITY: no access to %s from %s",
load->url, swfdec_url_get_url (load->sandbox->url));
- /* FIXME: call finish? */
-
/* unroot */
swfdec_player_unroot (player, load);
return;
@@ -184,7 +182,11 @@ swfdec_load_object_request (gpointer objectp, gpointer playerp)
SwfdecURL *url;
/* FIXME: or is this relative to the player? */
- url = swfdec_url_new_relative (swfdec_loader_get_url (player->priv->resource->loader), load->url);
+ url = swfdec_player_create_url (player, load->url);
+ if (url == NULL) {
+ swfdec_load_object_load (player, NULL, FALSE, load);
+ return;
+ }
switch (load->sandbox->type) {
case SWFDEC_SANDBOX_REMOTE:
case SWFDEC_SANDBOX_LOCAL_NETWORK:
diff --git a/libswfdec/swfdec_net_stream.c b/libswfdec/swfdec_net_stream.c
index fd6e2a9..080cd32 100644
--- a/libswfdec/swfdec_net_stream.c
+++ b/libswfdec/swfdec_net_stream.c
@@ -490,7 +490,7 @@ swfdec_net_stream_load (SwfdecPlayer *player, const SwfdecURL *url, gboolean all
g_object_unref (loader);
} else {
SWFDEC_WARNING ("SECURITY: no access to %s from NetStream",
- swfdec_url_get_url (url));
+ url ? swfdec_url_get_url (url) : "invalid URL");
stream->sandbox = NULL;
}
}
@@ -507,8 +507,12 @@ swfdec_net_stream_set_url (SwfdecNetStream *stream, SwfdecSandbox *sandbox, cons
cx = SWFDEC_AS_OBJECT (stream)->context;
player = SWFDEC_PLAYER (cx);
- url = swfdec_url_new_relative (swfdec_loader_get_url (player->priv->resource->loader), url_string);
- g_return_if_fail (url != NULL);
+ url = swfdec_player_create_url (player, url_string);
+ if (url == NULL) {
+ swfdec_net_stream_load (player, NULL, FALSE, stream);
+ return;
+ }
+
stream->sandbox = sandbox;
if (swfdec_url_is_local (url)) {
swfdec_net_stream_load (player, url, TRUE, stream);
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index d75768a..8cf835f 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -2127,6 +2127,30 @@ swfdec_player_create_socket (SwfdecPlayer *player, const char *hostname, guint p
return sock;
}
+SwfdecURL *
+swfdec_player_create_url (SwfdecPlayer *player, const char *string)
+{
+ SwfdecURL *url;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (string != NULL, NULL);
+
+ url = swfdec_url_new_relative (player->priv->base_url, string);
+ /* FIXME: check that we don't go below base for local urls */
+ return url;
+}
+
+SwfdecLoader *
+swfdec_player_load (SwfdecPlayer *player, const SwfdecURL *url,
+ SwfdecLoaderRequest request, SwfdecBuffer *buffer)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (url != NULL, NULL);
+ g_return_val_if_fail (buffer != NULL, NULL);
+
+ return swfdec_loader_load (player->priv->resource->loader, url, request, buffer);
+}
+
/** PUBLIC API ***/
/**
diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h
index af4313d..15ed76e 100644
--- a/libswfdec/swfdec_player_internal.h
+++ b/libswfdec/swfdec_player_internal.h
@@ -163,6 +163,12 @@ void swfdec_player_perform_actions (SwfdecPlayer * player);
swfdec_function_list_remove (&(player)->priv->rooted, (data))
#define swfdec_player_request_resource(player, request_func, data, destroy_notify) \
swfdec_function_list_add (&(player)->priv->resource_requests, (request_func), (data), (destroy_notify))
+SwfdecURL * swfdec_player_create_url (SwfdecPlayer * player,
+ const char * string);
+SwfdecLoader * swfdec_player_load (SwfdecPlayer * player,
+ const SwfdecURL * url,
+ SwfdecLoaderRequest request,
+ SwfdecBuffer * buffer);
SwfdecAsObject *swfdec_player_get_export_class (SwfdecPlayer * player,
const char * name);
void swfdec_player_set_export_class (SwfdecPlayer * player,
diff --git a/libswfdec/swfdec_resource.c b/libswfdec/swfdec_resource.c
index 26b9511..5670dce 100644
--- a/libswfdec/swfdec_resource.c
+++ b/libswfdec/swfdec_resource.c
@@ -593,7 +593,11 @@ swfdec_resource_load_request (gpointer loadp, gpointer playerp)
return;
}
- url = swfdec_url_new_relative (swfdec_loader_get_url (player->priv->resource->loader), load->url);
+ url = swfdec_player_create_url (player, load->url);
+ if (url == NULL) {
+ swfdec_resource_do_load (player, NULL, FALSE, load);
+ return;
+ }
switch (load->sandbox->type) {
case SWFDEC_SANDBOX_REMOTE:
swfdec_resource_do_load (player, url, !swfdec_url_is_local (url), load);
diff --git a/libswfdec/swfdec_url.c b/libswfdec/swfdec_url.c
index 6243f75..f22f179 100644
--- a/libswfdec/swfdec_url.c
+++ b/libswfdec/swfdec_url.c
@@ -152,45 +152,87 @@ SwfdecURL *
swfdec_url_new_components (const char *protocol, const char *hostname,
guint port, const char *path, const char *query)
{
- GString *url;
- SwfdecURL *result;
+ GString *str;
+ SwfdecURL *url;
g_return_val_if_fail (protocol != NULL, NULL);
g_return_val_if_fail (hostname != NULL || port == 0, NULL);
g_return_val_if_fail (port < 65536, NULL);
- url = g_string_new (protocol);
- g_string_append (url, "://");
+ url = g_slice_new0 (SwfdecURL);
+ str = g_string_new ("");
+
+ /* protocol */
+ url->protocol = g_ascii_strdown (protocol, -1);
+ g_string_append (str, url->protocol);
+ g_string_append (str, "://");
+
+ /* hostname + port */
if (hostname) {
- g_string_append (url, hostname);
+ url->host = g_ascii_strdown (hostname, -1);
+ url->port = port;
+ g_string_append (str, url->host);
if (port) {
- g_string_append_printf (url, ":%u", port);
+ g_string_append_printf (str, ":%u", port);
}
}
- g_string_append (url, "/");
- if (path)
- g_string_append (url, path);
+ g_string_append (str, "/");
+
+ /* path */
+ if (path) {
+ url->path = g_strdup (path);
+ g_string_append (str, path);
+ }
+
+ /* query string */
if (query) {
- g_string_append (url, "?");
- g_string_append (url, query);
+ url->query = g_strdup (query);
+ g_string_append (str, "?");
+ g_string_append (str, query);
+ }
+
+ url->url = g_string_free (str, FALSE);
+ return url;
+}
+
+static gboolean
+swfdec_url_path_to_parent_path (char *path)
+{
+ char *last = strrchr (path, '/');
+
+ if (last == NULL)
+ return FALSE;
+
+ if (last[1] == '\0') {
+ last[0] = '\0';
+ return swfdec_url_path_to_parent_path (path);
}
- result = swfdec_url_new (url->str);
- g_string_free (url, TRUE);
- return result;
+
+ *last = '\0';
+ return TRUE;
}
/**
* swfdec_url_new_parent:
* @url: a #SwfdecURL
*
- * Creates a new url that is the parent of @url.
+ * Creates a new url that is the parent of @url. If the given @url has no
+ * parent, a copy of itself is returned.
*
- * Returns: a new url pointing to the parent of @url.
+ * Returns: a new url pointing to the parent of @url or %NULL on failure.
**/
SwfdecURL *
swfdec_url_new_parent (const SwfdecURL *url)
{
- return swfdec_url_new_relative (url, "");
+ char *path;
+ SwfdecURL *ret;
+
+ path = g_strdup (url->path);
+ swfdec_url_path_to_parent_path (path);
+ ret = swfdec_url_new_components (url->protocol, url->host, url->port,
+ path, NULL);
+ g_free (path);
+ return ret;
}
/**
@@ -199,7 +241,8 @@ swfdec_url_new_parent (const SwfdecURL *url)
* @string: a relative or absolute URL path
*
* Parses @string into a new URL. If the given @string is a relative URL, it
- * uses @url to resolve it to an absolute url.
+ * uses @url to resolve it to an absolute url; @url must already contain a
+ * directory path.
*
* Returns: a new #SwfdecURL or %NULL if an error was detected.
**/
@@ -207,40 +250,55 @@ SwfdecURL *
swfdec_url_new_relative (const SwfdecURL *url, const char *string)
{
SwfdecURL *ret;
- GString *str;
+ char *path, *query;
g_return_val_if_fail (url != NULL, NULL);
g_return_val_if_fail (string != NULL, NULL);
- if (strstr (string, "://")) {
- /* full-qualified URL */
+ /* check for full-qualified URL */
+ if (strstr (string, "://"))
return swfdec_url_new (string);
- }
- str = g_string_new (url->protocol);
- g_string_append (str, "://");
- if (url->host)
- g_string_append (str, url->host);
- if (string[0] == '/' && !swfdec_url_has_protocol (url, "file")) {
+
+ if (string[0] == '/') {
/* absolute URL */
- g_string_append (str, string);
+ string++;
+ query = strchr (string, '?');
+ if (query == NULL) {
+ path = *string ? g_strdup (string) : NULL;
+ } else {
+ path = g_strndup (string, query - string);
+ query = g_strdup (query + 1);
+ }
} else {
/* relative URL */
- g_string_append (str, "/");
- if (url->path == NULL) {
- g_string_append (str, string);
- } else {
- char *slash;
- slash = strrchr (url->path, '/');
- if (slash == NULL) {
- g_string_append (str, string);
- } else {
- g_string_append_len (str, url->path, slash - url->path + 1); /* append '/', too */
- g_string_append (str, string);
+ char *cur = g_strdup (url->path);
+ while (g_str_has_prefix (string, "../")) {
+ if (!swfdec_url_path_to_parent_path (cur)) {
+ g_free (cur);
+ return NULL;
}
+ string += 3;
+ }
+ if (strstr (string, "/../")) {
+ g_free (cur);
+ return NULL;
+ }
+ path = g_strconcat (cur, "/", string, NULL);
+ g_free (cur);
+ cur = path;
+ query = strchr (cur, '?');
+ if (query == NULL) {
+ path = *string ? g_strdup (cur) : NULL;
+ } else {
+ path = g_strndup (cur, query - cur);
+ query = g_strdup (query + 1);
}
+ g_free (cur);
}
- ret = swfdec_url_new (str->str);
- g_string_free (str, TRUE);
+ ret = swfdec_url_new_components (url->protocol, url->host, url->port,
+ path, query);
+ g_free (path);
+ g_free (query);
return ret;
}
commit 6981ba9ff690e07dfbda300f4c1b1eb2f2901421
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Jan 22 15:01:44 2008 +0100
add API for getting/setting URL and base URL on a SwfdecPlayer
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index 57c9334..d75768a 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -619,7 +619,9 @@ enum {
PROP_SCRIPTING,
PROP_SYSTEM,
PROP_MAX_RUNTIME,
- PROP_SOCKET_TYPE
+ PROP_SOCKET_TYPE,
+ PROP_BASE_URL,
+ PROP_URL
};
G_DEFINE_TYPE (SwfdecPlayer, swfdec_player, SWFDEC_TYPE_AS_CONTEXT)
@@ -736,6 +738,16 @@ swfdec_player_get_property (GObject *object, guint param_id, GValue *value,
case PROP_SOCKET_TYPE:
g_value_set_gtype (value, priv->socket_type);
break;
+ case PROP_URL:
+ if (priv->resource) {
+ g_value_set_boxed (value, swfdec_loader_get_url (priv->resource->loader));
+ } else {
+ g_value_set_boxed (value, NULL);
+ }
+ break;
+ case PROP_BASE_URL:
+ g_value_set_boxed (value, priv->base_url);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -931,6 +943,10 @@ swfdec_player_dispose (GObject *object)
g_timer_destroy (priv->runtime);
priv->runtime = NULL;
}
+ if (priv->base_url) {
+ swfdec_url_free (priv->base_url);
+ priv->base_url = NULL;
+ }
}
static void
@@ -1615,6 +1631,12 @@ swfdec_player_class_init (SwfdecPlayerClass *klass)
g_object_class_install_property (object_class, PROP_SOCKET_TYPE,
g_param_spec_gtype ("socket type", "socket type", "type to use for creating sockets",
SWFDEC_TYPE_SOCKET, G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_URL,
+ g_param_spec_boxed ("url", "url", "URL of resource currently played back or NULL if not set",
+ SWFDEC_TYPE_URL, G_PARAM_READABLE));
+ g_object_class_install_property (object_class, PROP_BASE_URL,
+ g_param_spec_boxed ("base-url", "base url", "base URL for creating new resource or NULL if not set yet",
+ SWFDEC_TYPE_URL, G_PARAM_READWRITE));
/**
* SwfdecPlayer::invalidate:
@@ -2179,11 +2201,18 @@ swfdec_player_set_loader_with_variables (SwfdecPlayer *player, SwfdecLoader *loa
g_return_if_fail (player->priv->resource == NULL);
g_return_if_fail (SWFDEC_IS_LOADER (loader));
+ g_object_freeze_notify (G_OBJECT (player));
priv = player->priv;
priv->resource = swfdec_resource_new (player, loader, variables);
+ if (priv->base_url == NULL) {
+ priv->base_url = swfdec_url_new_parent (swfdec_loader_get_url (loader));
+ g_object_notify (G_OBJECT (player), "base-url");
+ }
movie = swfdec_movie_new (player, -16384, NULL, priv->resource, NULL, SWFDEC_AS_STR__level0);
movie->name = SWFDEC_AS_STR_EMPTY;
g_object_unref (loader);
+ g_object_notify (G_OBJECT (player), "url");
+ g_object_thaw_notify (G_OBJECT (player));
}
/**
@@ -2871,3 +2900,66 @@ swfdec_player_set_scripting (SwfdecPlayer *player, SwfdecPlayerScripting *script
priv->scripting = g_object_ref (scripting);
g_object_notify (G_OBJECT (player), "scripting");
}
+
+/**
+ * swfdec_player_get_url:
+ * @player: a #SwfdecPlayer
+ *
+ * Gets the URL of the resource that is currently played back. If no URL has
+ * been set on the @player yet, %NULL is returned.
+ *
+ * Returns: the #SwfdecURL currently played back or %NULL
+ **/
+const SwfdecURL *
+swfdec_player_get_url (SwfdecPlayer *player)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+
+ if (player->priv->resource == NULL)
+ return NULL;
+
+ return swfdec_loader_get_url (player->priv->resource->loader);
+}
+
+/**
+ * swfdec_player_get_base_url:
+ * @player: a #SwfdecPlayer
+ *
+ * Gets the base URL that this player uses when resolving a relative URL. It is
+ * automatically set to the parent directory of the currently played back
+ * resource, but can be changed using swfdec_player_set_base_url(). When no
+ * resource has been set on the @player yet, %NULL is returned.
+ *
+ * Returns: the base #SwfdecURL for resolving relative links or %NULL
+ **/
+const SwfdecURL *
+swfdec_player_get_base_url (SwfdecPlayer *player)
+{
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+
+ return player->priv->base_url;
+}
+
+/**
+ * swfdec_player_set_base_url:
+ * @player: a #SwfdecPlayer
+ * @url: a #SwfdecURL
+ *
+ * Sets the URL that will be used for resolving realtive links inside the
+ * @player.
+ **/
+void
+swfdec_player_set_base_url (SwfdecPlayer *player, const SwfdecURL *url)
+{
+ SwfdecPlayerPrivate *priv;
+
+ g_return_if_fail (SWFDEC_IS_PLAYER (player));
+ g_return_if_fail (url != NULL);
+
+ priv = player->priv;
+ if (priv->base_url)
+ swfdec_url_free (priv->base_url);
+ priv->base_url = swfdec_url_copy (url);
+ g_object_notify (G_OBJECT (player), "base-url");
+}
+
diff --git a/libswfdec/swfdec_player.h b/libswfdec/swfdec_player.h
index 2dd1f27..04ce994 100644
--- a/libswfdec/swfdec_player.h
+++ b/libswfdec/swfdec_player.h
@@ -128,13 +128,19 @@ SwfdecAlignment swfdec_player_get_alignment (SwfdecPlayer * player);
void swfdec_player_set_alignment (SwfdecPlayer * player,
SwfdecAlignment align);
gulong swfdec_player_get_maximum_runtime
- (SwfdecPlayer * player);
+ (SwfdecPlayer * player);
void swfdec_player_set_maximum_runtime
- (SwfdecPlayer * player,
- gulong msecs);
+ (SwfdecPlayer * player,
+ gulong msecs);
+const SwfdecURL *
+ swfdec_player_get_url (SwfdecPlayer * player);
+const SwfdecURL *
+ swfdec_player_get_base_url (SwfdecPlayer * player);
+void swfdec_player_set_base_url (SwfdecPlayer * player,
+ const SwfdecURL * url);
SwfdecPlayerScripting *
- swfdec_player_get_scripting (SwfdecPlayer * player);
-void swfdec_player_set_scripting (SwfdecPlayer * player,
+ swfdec_player_get_scripting (SwfdecPlayer * player);
+void swfdec_player_set_scripting (SwfdecPlayer * player,
SwfdecPlayerScripting *scripting);
void swfdec_player_render (SwfdecPlayer * player,
diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h
index 889a1ee..af4313d 100644
--- a/libswfdec/swfdec_player_internal.h
+++ b/libswfdec/swfdec_player_internal.h
@@ -67,6 +67,7 @@ struct _SwfdecPlayerPrivate
gboolean bgcolor_set; /* TRUE if the background color has been set */
SwfdecColor bgcolor; /* background color */
SwfdecResource * resource; /* initial resource loaded */
+ SwfdecURL * base_url; /* base url or NULL if no loader set yet */
SwfdecPlayerScripting *scripting; /* scripting object */
GHashTable * scripting_callbacks; /* GC string => SwfdecAsFunction mapping of script callbacks */
GType socket_type; /* type to use for creating sockets */
More information about the Swfdec-commits
mailing list