Changeset 9932
- Timestamp:
- 03/13/09 16:56:19 (4 years ago)
- Location:
- OpenSceneGraph/trunk/src/osgPlugins/quicktime
- Files:
-
- 5 modified
-
MovieData.cpp (modified) (2 diffs)
-
MovieData.h (modified) (1 diff)
-
QTUtils.cpp (modified) (1 diff)
-
QTUtils.h (modified) (1 diff)
-
ReaderWriterQT.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/quicktime/MovieData.cpp
r8792 r9932 29 29 30 30 if (_movie) { 31 CloseMovieFile(_resref);32 31 DisposeMovie(_movie); 33 32 } … … 39 38 void MovieData::load(osg::Image* image, std::string afilename, float startTime) 40 39 { 40 bool isUrl( osgDB::containsServerAddress(afilename) ); 41 42 std::string filename = afilename; 43 if (!isUrl) { 44 if (!osgDB::isFileNameNativeStyle(filename)) 45 filename = osgDB::convertFileNameToNativeStyle(filename); 46 } 47 48 image->setFileName(filename); 49 50 51 QTNewMoviePropertyElement newMovieProperties[2]; 52 CFStringRef movieLocation = CFStringCreateWithCString(NULL, filename.c_str(), kCFStringEncodingUTF8); 53 CFURLRef movieURL(NULL); 54 Boolean trueValue = true; 55 56 newMovieProperties[0].propClass = kQTPropertyClass_DataLocation; 57 if (!isUrl) 58 { 59 #ifdef __APPLE__ 60 newMovieProperties[0].propID = kQTDataLocationPropertyID_CFStringPosixPath; 61 #else 62 newMovieProperties[0].propID = kQTDataLocationPropertyID_CFStringWindowsPath; 63 #endif 64 65 newMovieProperties[0].propValueSize = sizeof(CFStringRef); 66 newMovieProperties[0].propValueAddress = &movieLocation; 67 } 68 else 69 { 70 movieURL = CFURLCreateWithString(kCFAllocatorDefault, movieLocation, NULL); 71 72 newMovieProperties[0].propID = kQTDataLocationPropertyID_CFURL; 73 newMovieProperties[0].propValueSize = sizeof(movieURL); 74 newMovieProperties[0].propValueAddress = (void*)&movieURL; 75 } 76 77 // make movie active 78 newMovieProperties[1].propClass = kQTPropertyClass_NewMovieProperty; 79 newMovieProperties[1].propID = kQTNewMoviePropertyID_Active; 80 newMovieProperties[1].propValueSize = sizeof(trueValue); 81 newMovieProperties[1].propValueAddress = &trueValue; 82 83 // Instantiate the Movie 84 OSStatus status = NewMovieFromProperties(2, newMovieProperties, 0, NULL, &_movie); 85 CFRelease(movieLocation); 86 if (movieURL) CFRelease(movieURL); 87 88 if (status !=0) { 89 _fError = true; 90 osg::notify(osg::FATAL) << " MovieData :: NewMovieFromProperties failed with err " << status<< std::endl; 91 return; 92 } 93 94 41 95 Rect bounds; 42 std::string filename = afilename; 43 if (!osgDB::isFileNameNativeStyle(filename)) 44 filename = osgDB::convertFileNameToNativeStyle(filename); 45 46 osg::notify(osg::INFO) << "MovieData :: opening movie '" << filename << "'" << std::endl; 47 48 OSStatus err = MakeMovieFromPath(filename.c_str(), &_movie, _resref); 49 if (err !=0) { 50 _fError = true; 51 osg::notify(osg::FATAL) << " MovieData :: MakeMovieFromPath failed with err " << err << std::endl; 52 return; 53 } 54 96 55 97 GetMovieBox(_movie, &bounds); 56 98 _checkMovieError("Can't get movie box\n"); -
OpenSceneGraph/trunk/src/osgPlugins/quicktime/MovieData.h
r8792 r9932 100 100 protected: 101 101 char* _pointer; 102 short _resref;103 102 Movie _movie; 104 103 GWorldPtr _gw; -
OpenSceneGraph/trunk/src/osgPlugins/quicktime/QTUtils.cpp
r9769 r9932 7 7 * 8 8 */ 9 #include <osg/ref_ptr>10 #include <osg/Referenced>11 #include <osg/Notify>12 #include "QTUtils.h"13 #include "osgDB/Registry"14 15 16 using namespace std;17 18 19 // ---------------------------------------------------------------------------20 // MakeFSSPecFromPath21 // wandelt einen Posix-Pfad in ein FSSpec um.22 // ---------------------------------------------------------------------------23 OSStatus MakeFSSpecFromPath(const char* path, FSSpec* spec) {24 #ifdef __APPLE__25 OSStatus err;26 FSRef fsref;27 Boolean isdir;28 /*29 FSPathMakeRef is only available in Carbon. It takes a POSIX path and30 tries to convert it into a MacOS FSRef object.31 We don't want folders, only files, so we'll fail here if we got a32 directory.33 */34 err = FSPathMakeRef((const UInt8*)path, &fsref, &isdir);35 if (err!=0) return err;36 if (isdir) return 1;37 // Ditto38 err = FSGetCatalogInfo(&fsref, kFSCatInfoNone, NULL, NULL, spec, NULL);39 return err;40 #else41 return -1;42 #endif43 }44 45 // ---------------------------------------------------------------------------46 // MakeMovieFromPath47 // ---------------------------------------------------------------------------48 OSStatus MakeMovieFromPath(const char* path, Movie* movie, short& resref) {49 OSStatus err;50 FSSpec spec;51 #ifdef __APPLE__52 MakeFSSpecFromPath(path, &spec);53 #else54 err = NativePathNameToFSSpec((char*)path, &spec, 0 /* flags */);55 #endif56 err = OpenMovieFile(&spec, &resref, fsRdPerm);57 if (err!=0) return err;58 err = NewMovieFromFile(movie, resref, NULL, NULL, 0, NULL);59 if (err==0) err=GetMoviesError();60 return err;61 }62 63 64 -
OpenSceneGraph/trunk/src/osgPlugins/quicktime/QTUtils.h
r9769 r9932 51 51 #endif 52 52 53 /** constructs an FSSpec out of an path */54 OSStatus MakeFSSpecFromPath(const char* path, FSSpec* spec);55 56 /** opens a movie from a path */57 OSStatus MakeMovieFromPath(const char* path, Movie* movie, short& resref);58 53 59 54 -
OpenSceneGraph/trunk/src/osgPlugins/quicktime/ReaderWriterQT.cpp
r9769 r9932 132 132 supportsExtension("dv","Movie format"); 133 133 supportsExtension("avi","Movie format"); 134 supportsExtension("sdp","RTSP Movie format"); 134 135 supportsExtension("flv","Movie format"); 135 136 supportsExtension("swf","Movie format"); … … 137 138 138 139 supportsExtension("live","Live video streaming"); 140 141 supportsProtocol("http", "streaming media per http"); 142 supportsProtocol("rtsp", "streaming media per rtsp"); 139 143 140 144 #ifdef QT_HANDLE_IMAGES_ALSO … … 168 172 osgDB::equalCaseInsensitive(extension,"dv") || 169 173 osgDB::equalCaseInsensitive(extension,"avi") || 174 osgDB::equalCaseInsensitive(extension,"sdp") || 170 175 osgDB::equalCaseInsensitive(extension,"flv") || 171 176 osgDB::equalCaseInsensitive(extension,"swf") || … … 295 300 296 301 // Not an encoded "live" psuedo file - so check a real file exists 297 std::string fileName = osgDB::findDataFile( file, options); 298 if (fileName.empty()) return ReadResult::FILE_NOT_FOUND; 299 302 // only find the file if it isn't a URL 303 std::string fileName = file; 304 305 300 306 // Note from Riccardo Corsi 301 307 // Quicktime initialization is done here, when a media is found … … 309 315 if (acceptsMovieExtension(ext)) 310 316 { 317 // quicktime supports playing movies from URLs 318 if (!osgDB::containsServerAddress(fileName)) { 319 fileName = osgDB::findDataFile( file, options); 320 if (fileName.empty()) return ReadResult::FILE_NOT_FOUND; 321 } 322 311 323 // note from Robert Osfield when integrating, we should probably have so 312 324 // error handling mechanism here. Possibly move the load from … … 322 334 return moov; 323 335 } 324 336 337 338 // no live-video, no movie-file, so try to load as an image 339 340 fileName = osgDB::findDataFile( file, options); 341 if (fileName.empty()) return ReadResult::FILE_NOT_FOUND; 342 325 343 QuicktimeImportExport importer; 326 344
