Xine extension

From Gnash Project Wiki

Jump to: navigation, search



Someone has asked if it was possible to use Gnash as/with a DVD player using libxine. The purpose is to use xine for DVD and video control, but use Gnash to popup control menus for things like brightness, etxxx for a settop box. Here is what has been established so far.

So far two solutions has been suggested:

  • Use two different processes, with the xine player in the background, and playing gnash in transparent mode with no window borders, on top of it. This requires an control-extension to pass instructions to the xine-process or a normal XMLSocket-based controller. We'd use xine's broadcast option to stream the video, and the normal Xine remote protocol to control the player.
  • Use libxine directly from within gnash. As in the first option this requires an control-extension, and additionally we need to handle the video output inside gnash.

Extraction of video frames

An extension to extract video frames should work similar to the current NetStream AS class (perhaps extend the current NetStream?), and be used sort of like this:

dvdplayer = new XineExt();
video.attachVideo(dvdplayer); // "video" is a Flash video stream object"dvd://")

Since libxine is a gui-oriented lib, it normally draws a decoded video-frame in a given sdl/gtk/whatever canvas, but since gnash doesn't work like that, we'll have to create a new video output driver for libxine, which can give/pass/stream the video to gnash. Either by using callbacks directly into gnash, or by streaming the video data to gnash.

Since we would like RGB-frames, it has been suggested that we look at the xshm output driver because it also uses RGB. When looking for what to put in the driver, start from xine_plugin_info[].

For audio, we could either let xine output directly to the sound device, or again create a new output driver. The former would be preferred, since it is simpler...

Controlling libxine

Controlling libxine is a bit tricky, since we need a way to tell libxine what we are doing, such as clicking the mouse and pressing keys.

One way could be to create a xml frontend to libxine, which would let us control libxine using gnash's actionscript xml, and get information about the current playback back, such as subtitle options, movie duration etc. and build menus and buttons in SWF using that information. How exactly this xml-frontend should be made, and how big at task it is, is yet unknown.

Another way the frontend would be controlled would be via a remote control unit. Xine does have it's own support for LIRC based devices, but now that Gnash has it's own, we should use that for remote control events. This is a common way people would want to control their DVD player.

Proposed solution #1

Here a solution is presented. This one is using XML for controlling xine and streaming video the gnash.

SWF movie requirements

Since the solution is to be used in a set-top box (or similar), we can make some assumptions which can make it easier to implement:

A mouse-like pointer device is not likely to be used, only a remote control. This means that we don't need to worry about turning DVD-menus and buttons into flash-buttons, but instead can operate with two "layers" in the DVD-playing SWF. The first layer is the flash-movie where we can control stuff like subtitles, language etc. The second layer is the DVD-interface controlling DVD-menus (scene selection etc). When the flash-movie-layer is active we don't send key-events to xine (but will send setting changes), and when the DVD-interface is active we will send key-events (up, down, enter, etc.). Switching from the DVD-interface to the flash-movie-interface would happen when pressing a non-simple button on the remote (like subtitles). Switching back would be done when leaving the flash-generated menu.

We could of course just go all the way instead of making shortcuts like this...

Xine requirements

We need to implement a frontend sending and receiving XML, which will control what xine does, and tell the SWF movie about possible settings, so that it can build the menus.

We also need to implement a new video driver, which will stream the raw RGB video in a way that gnash can connect and read it. (If anyone knows how to do this please add details.)

Information about how to hack/extend xine can found here

Gnash requirements

We need to make gnash capable of reading raw RGB streams (see above). This can most likely be done by modifying NetStream.

Proposed solution #2

Xine supports a --broadcast-port= option, that has it streaming video to another instantiation of xine that is running in slave mode. If the stream is in some format gnash can "understand" we can use it instead of making a custom video-out driver also streaming. The exact protocol of the stream needs to be identified, so we can read the stream. After some early testing with xine one issue is that when navigating DVD-menus, the slave doesn't see the marking of objects change, which could mean that the broadcast feature isn't useful in our case.

Xine has a --network option, this allows remote control through a network client, which can be used to control playback, playlists, seeking, and navigating dvd-menus. It does not seem to support extracting information about subtitles, chapters and other thing, which could be nice for and an advanced DVD-player. An extension to communicate with the server could be based on xine-remote.

If these 2 features could be combined (and perhaps tweaked/optimized a bit) a gnash-based DVD-player would not be too far away.

Proposed solution #3

In this solution we create an xine extension in gnash which will be a xine-frontend, with no need to communicate through XML or network. This would allow us to use all the nice features of xine, and could allow the use of a video driver with video-image-callbacks directly into gnash (via the extension).