[haiku-development] Re: Alternatives to plug-in sniffing

  • From: Stephan Assmus <superstippi@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 18 Aug 2010 12:59:27 +0200

Hi,

Am 18.08.2010 12:26, schrieb François Revol:
Le 18 août 2010 à 03:16, Christopher Humphries a écrit :
I had some problems with the sniffing functions in the media plug-ins.

I realise that for streaming to work properly the plug-ins need to be
adapted to make do with a BDataIO when the data isn’t seekable, but it’s
still a problem when only a small chunk of data is available.

Asking each plug-in to sniff the data works on files, where seeking is a
simple matter, but for live streams, seeking is tricky. If the file is
small, seeking in the saved data can work, but bulkier content, e.g., HD
video and DVD data, takes up several gigabytes.

In my opinion, it would be much easier to optionally be able to directly ask
for a certain plug-in, using the device API (libdvdnav can return accurate
format data) or the media MIME type, and avoid the format sniffing.

In BeOS the extractor addons were passed a BDataIO but they dynamic_cast them 
to BPositionIO to Seek() them back to 0 after sniffing...

Not a good solution IMHO, and not possible for streaming anyway. I've thought a bit about that and our PluginManager should support a special internal BDataIO class, which the calling code wraps around actual BDataIO objects, but not if it can dynamic_cast them to BPositionIO. The PluginManager would check for the special BDataIO internal type in the sniffing code, and use it's special interface to reset the buffered data to the beginning. It would also reset it after sniffing, so decoding happens from the stream start. This would be transparent to the BDataIO object which is used as a source, all it ever sees is a single Read(), as if this was the first read for decoding (which it will be after the sniffing is done). Plugins can then avoid dynamic casting to a BPositionIO at least in the sniffing phase, if they only need the initial buffer, and fail only the seeking during decoding if the source is not a BPositionIO. This change would still work with all existing plugins, but remove the limitation from the PluginManager and plugins can be fixed later.

It should also be possible to use dynamic_cast to check for a subtype and use 
this one to check for properties (mime type...) instead of checking the data 
itself.

like
BStreamingIO *s = dynamic_cast<BStreamingIO *>io;
if (s) {
        BString mime;
        s->GetMime(&mime);
        if (mime == "video/mpeg-ts") {
                ...
        }
}

Dano had those MetaData calls added on BDataIO that mapped to Read/WriteAttr() 
for BFile which allowed to get the BEOS:TYPE attribute this way, maybe we 
should also do it alike.

Perhaps, though it does seem somewhat misplaced.

Best regards,
-Stephan

Other related posts: