Show
Ignore:
Timestamp:
03/13/09 16:56:19 (4 years ago)
Author:
robert
Message:

From Stephan Huber, clean up of Quicktime plugin

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgPlugins/quicktime/MovieData.cpp

    r8792 r9932  
    2929 
    3030    if (_movie) { 
    31         CloseMovieFile(_resref); 
    3231        DisposeMovie(_movie); 
    3332    } 
     
    3938void MovieData::load(osg::Image* image, std::string afilename, float startTime) 
    4039{ 
     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     
    4195    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  
    5597    GetMovieBox(_movie, &bounds); 
    5698    _checkMovieError("Can't get movie box\n");