From Stephan Huber, "attached you'll find a zip containing some bug-fixes and some refactored + new code.

* ZeroConfDevice does now return FILE_NOT_HANDLED instead of FILE_NOT_FOUND
* present3D supports multiple devices per env-var P3D_DEVICE, separate multiple device with a space

I refactored parts the p3d-plugin, the curl-plugin and parts of Registry and ReaderWriter. Currently the p3d-plugin tries to open all remote files with the help of the curl-plugin.

I added a new method to Registry called getReaderWriterForProtocolAndExtension. which will return a ReaderWriter which is capable in handling the remote file for the given protocol and extension. If no readerwriter is found for the given extension, a list is built of all readerwriters supporting the given protocol and this list is checked for support of wildcards (extension = "*"). If anything matches it get returned.

I added this principle also to the Registry, so now it's possible to register a generic ReaderWriter which can handle all filetypes for a given protocol, similar what curl is doing. All you have to do is to load the plugin at startup. The curl-fallback is still in place.

With these changes it is now possible to reference a movie inside a presentation without a server-address, read the presentation (with curl) and stream the movie with the correct plugin (e.g. QTKit)

"
This commit is contained in:
Robert Osfield
2012-12-07 19:05:47 +00:00
parent e64d5e5eca
commit 22868bce4f
9 changed files with 68 additions and 15 deletions

View File

@@ -176,7 +176,7 @@ class ReaderWriterZeroConf : public osgDB::ReaderWriter
}
}
return ReadResult::FILE_NOT_FOUND;
return ReadResult::FILE_NOT_HANDLED;
}
private:

View File

@@ -375,6 +375,10 @@ osgDB::ReaderWriter::ReadResult EasyCurl::processResponse(CURLcode res, const st
ReaderWriterCURL::ReaderWriterCURL()
{
supportsProtocol("http","Read from http port using libcurl.");
supportsProtocol("https","Read from https port using libcurl.");
supportsProtocol("ftp","Read from ftp port using libcurl.");
supportsProtocol("ftps","Read from ftps port using libcurl.");
supportsExtension("curl","Psuedo file extension, used to select curl plugin.");
supportsExtension("*","Passes all read files to other plugins to handle actual model loading.");
supportsOption("OSG_CURL_PROXY","Specify the http proxy.");

View File

@@ -104,11 +104,6 @@ class ReaderWriterCURL : public osgDB::ReaderWriter
virtual const char* className() const { return "HTTP Protocol Model Reader"; }
virtual bool acceptsExtension(const std::string& extension) const
{
return osgDB::equalCaseInsensitive(extension,"curl");
}
virtual bool fileExists(const std::string& filename, const osgDB::Options* options) const;
virtual ReadResult openArchive(const std::string& fileName,ArchiveStatus status, unsigned int , const Options* options) const

View File

@@ -2142,7 +2142,12 @@ class MyReadFileCallback : public virtual osgDB::ReadFileCallback
OSG_INFO<<"Trying server file "<<filename<<std::endl;
osgDB::ReaderWriter::ReadResult result;
osgDB::ReaderWriter* rw = osgDB::Registry::instance()->getReaderWriterForExtension("curl");
// get a specific readerwriter capable of handling the protocol and extension, will return a registered fallback readerwriter for extension '*'
osgDB::ReaderWriter* rw = osgDB::Registry::instance()->getReaderWriterForProtocolAndExtension(
osgDB::getServerProtocol(filename),
osgDB::getFileExtension(filename));
if (!rw) return osgDB::ReaderWriter::ReadResult::FILE_NOT_HANDLED;
switch(type)