Analysis
The second iteration of this task is about integrating the java/c++ flash communication using the Native Bridge created in this task http://sophie2.org/trac/wiki/GROUP_WRAPPERS_R0. In the revision only video frames will be transfered including sounds and interactive flash will be subject of future iterations.
Overview
Integrate the demo using the commonly created interface for native wrappers.
Task requirements
Make it possible to integrate flash movies in Sophie2. The task itself is not about integrating flash but providing an interface to do so.
Task result
An interface for getting frames from a flash movie using the native wrapper returned.
Implementation idea
Create a class hierarchy to handle commands and responses in both c++ and java parts. Use the common native bridge implementation to transfer the commands and responses between the java and c++ parts. Use the result of the previous revision in the implementation.
Related
GROUP_WRAPPERS_R0
FLASH_CONTENT_BASIC_R1
How to demo
Insert an image into a sophie2 page that is a frame of flash movie.
Design
Build an hierarchy on both the Java and C++ parts using the common design described in GROUP_WRAPPERS_R0. In the C++ part:
- Add folder flash_utils in the src/ directory with four files in it - flash_player.h, flash_player.cpp cairo_handler.h and cairo_handler.cpp. The first two defining a class to handle a SwfdecPlayer object and the second two - a class to encapsulate operations on cairo objects
- Add class FlashException inheriting JavaMessageException
- Add class FlashPlayer
- Add class CairoHandler
- Create two files flash_messages.cpp and flash_messages.h in the commands folder in the src/ directory.
- Add class FlashBridge inheriting JavaBridge
- Add class OpenCommand that represents a command to open new flash file
- Add class SetSizeCommand that represents a command to edit the flash player size
- Add class GetSizeCommand that represents a command to get the current flash player size
- Add class GetFlashFrameCommand that represents a command to get the current frame's pixel data
- Add class FlashFrameResponse that represents the result of a successful GetFlashFrameCommand
- Add class FlashSizeResponse that represents the result of a successful SetSizeCommand
- Add two enumerations FlashCommandIds and FlashResponseIds(their names are self-explanatory)
In the Java part:
- Add new values in the ResponseIds and CommandIds enumerations created in GROUP_WRAPPERS_R0
- Add classes GetFlashSizeCommand, GetFlashFrameCommand, SetFlashSizeCommand and OpenFlashCommand inheriting the interface Command.
- Add classes FlashFrameResponse and FlashSizeResponse inheriting the interface Response
- Create class FlashNativeBridge inheriting NativeBridge
Java part class diagram:
There is nothing to test in this revision of the task.
Here is a link to some source code:
http://sophie2.org/trac/browser/branches/private/ivo/Wrapper
Implementation
The implementation can be found here:
java part
c++ part
Testing
One should build the c++ part using the command make flashBridge in the root directory for the c++ part. After that the in the java part in FlashMovieTest the open command should be pointed to a swf file and in the FlashNativeBridge the get executable string value should be pointed to the c++ executable. Then run the demo and observe.
Comments
(Write comments for this or later revisions here.)