2.8 branch: THis change brings the quicktime plugin up to date with current svn head trunk. Revisions merged from trunk in the commit include: 9769, 9932, 10788, 10891, 11019, and 11035.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
#include <osg/GL>
|
||||
#include <osg/Endian>
|
||||
#include <osg/Image>
|
||||
#include <osgDB/FileNameUtils>
|
||||
|
||||
#include "MovieData.h"
|
||||
@@ -28,7 +29,6 @@ MovieData::~MovieData()
|
||||
if (_gw) DisposeGWorld(_gw);
|
||||
|
||||
if (_movie) {
|
||||
CloseMovieFile(_resref);
|
||||
DisposeMovie(_movie);
|
||||
}
|
||||
}
|
||||
@@ -38,23 +38,71 @@ MovieData::~MovieData()
|
||||
|
||||
void MovieData::load(osg::Image* image, std::string afilename, float startTime)
|
||||
{
|
||||
Rect bounds;
|
||||
std::string filename = afilename;
|
||||
if (!osgDB::isFileNameNativeStyle(filename))
|
||||
filename = osgDB::convertFileNameToNativeStyle(filename);
|
||||
|
||||
osg::notify(osg::INFO) << "MovieData :: opening movie '" << filename << "'" << std::endl;
|
||||
bool isUrl( osgDB::containsServerAddress(afilename) );
|
||||
|
||||
OSStatus err = MakeMovieFromPath(filename.c_str(), &_movie, _resref);
|
||||
if (err !=0) {
|
||||
_fError = true;
|
||||
osg::notify(osg::FATAL) << " MovieData :: MakeMovieFromPath failed with err " << err << std::endl;
|
||||
return;
|
||||
std::string filename = afilename;
|
||||
if (!isUrl) {
|
||||
if (!osgDB::isFileNameNativeStyle(filename))
|
||||
filename = osgDB::convertFileNameToNativeStyle(filename);
|
||||
}
|
||||
|
||||
image->setFileName(filename);
|
||||
|
||||
|
||||
QTNewMoviePropertyElement newMovieProperties[2];
|
||||
CFStringRef movieLocation = CFStringCreateWithCString(NULL, filename.c_str(), kCFStringEncodingUTF8);
|
||||
CFURLRef movieURL(NULL);
|
||||
Boolean trueValue = true;
|
||||
|
||||
newMovieProperties[0].propClass = kQTPropertyClass_DataLocation;
|
||||
if (!isUrl)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
newMovieProperties[0].propID = kQTDataLocationPropertyID_CFStringPosixPath;
|
||||
#else
|
||||
newMovieProperties[0].propID = kQTDataLocationPropertyID_CFStringWindowsPath;
|
||||
#endif
|
||||
|
||||
newMovieProperties[0].propValueSize = sizeof(CFStringRef);
|
||||
newMovieProperties[0].propValueAddress = &movieLocation;
|
||||
}
|
||||
else
|
||||
{
|
||||
movieURL = CFURLCreateWithString(kCFAllocatorDefault, movieLocation, NULL);
|
||||
|
||||
newMovieProperties[0].propID = kQTDataLocationPropertyID_CFURL;
|
||||
newMovieProperties[0].propValueSize = sizeof(movieURL);
|
||||
newMovieProperties[0].propValueAddress = (void*)&movieURL;
|
||||
}
|
||||
|
||||
GetMovieBox(_movie, &bounds);
|
||||
_checkMovieError("Can't get movie box\n");
|
||||
// make movie active
|
||||
newMovieProperties[1].propClass = kQTPropertyClass_NewMovieProperty;
|
||||
newMovieProperties[1].propID = kQTNewMoviePropertyID_Active;
|
||||
newMovieProperties[1].propValueSize = sizeof(trueValue);
|
||||
newMovieProperties[1].propValueAddress = &trueValue;
|
||||
|
||||
// Instantiate the Movie
|
||||
OSStatus status = NewMovieFromProperties(2, newMovieProperties, 0, NULL, &_movie);
|
||||
CFRelease(movieLocation);
|
||||
if (movieURL) CFRelease(movieURL);
|
||||
|
||||
if (status !=0) {
|
||||
_fError = true;
|
||||
osg::notify(osg::FATAL) << " MovieData :: NewMovieFromProperties failed with err " << status<< std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Rect bounds;
|
||||
|
||||
#ifdef __APPLE__
|
||||
GetRegionBounds(GetMovieBoundsRgn(_movie), &bounds);
|
||||
#else
|
||||
bounds = (*GetMovieBoundsRgn(_movie))->rgnBBox;
|
||||
#endif
|
||||
|
||||
_checkMovieError("Can't get movie bounds\n");
|
||||
|
||||
OffsetRect(&bounds, -bounds.left, -bounds.top);
|
||||
SetMovieBox(_movie, &bounds);
|
||||
_checkMovieError("Can't set movie box\n");
|
||||
@@ -116,7 +164,7 @@ void MovieData::_initImage(osg::Image* image)
|
||||
|
||||
image->setImage(_textureWidth,_textureHeight,1,
|
||||
(GLint) GL_RGBA8,
|
||||
(GLenum)GL_BGRA_EXT,
|
||||
(GLenum)GL_BGRA,
|
||||
internalFormat,
|
||||
(unsigned char*) buffer,osg::Image::NO_DELETE,4);
|
||||
|
||||
|
||||
@@ -99,7 +99,6 @@
|
||||
|
||||
protected:
|
||||
char* _pointer;
|
||||
short _resref;
|
||||
Movie _movie;
|
||||
GWorldPtr _gw;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "QTUtils.h"
|
||||
|
||||
#include <osgDB/FileNameUtils>
|
||||
#include <osg/Image>
|
||||
|
||||
|
||||
/** small exception class bundling a error-message */
|
||||
@@ -151,7 +152,7 @@ unsigned char* QuicktimeImportExport::prepareBufferForQuicktime(unsigned char* b
|
||||
boffset = 2;
|
||||
break;
|
||||
|
||||
case GL_BGRA_EXT:
|
||||
case GL_BGRA:
|
||||
aoffset = 0;
|
||||
roffset = 1;
|
||||
goffset = 2;
|
||||
|
||||
@@ -6,59 +6,3 @@
|
||||
* Copyright (c) 2002 digital mind. All rights reserved.
|
||||
*
|
||||
*/
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/Referenced>
|
||||
#include <osg/Notify>
|
||||
#include "QTUtils.h"
|
||||
#include "osgDB/Registry"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// MakeFSSPecFromPath
|
||||
// wandelt einen Posix-Pfad in ein FSSpec um.
|
||||
// ---------------------------------------------------------------------------
|
||||
OSStatus MakeFSSpecFromPath(const char* path, FSSpec* spec) {
|
||||
#ifdef __APPLE__
|
||||
OSStatus err;
|
||||
FSRef fsref;
|
||||
Boolean isdir;
|
||||
/*
|
||||
FSPathMakeRef is only available in Carbon. It takes a POSIX path and
|
||||
tries to convert it into a MacOS FSRef object.
|
||||
We don't want folders, only files, so we'll fail here if we got a
|
||||
directory.
|
||||
*/
|
||||
err = FSPathMakeRef((const UInt8*)path, &fsref, &isdir);
|
||||
if (err!=0) return err;
|
||||
if (isdir) return 1;
|
||||
// Ditto
|
||||
err = FSGetCatalogInfo(&fsref, kFSCatInfoNone, NULL, NULL, spec, NULL);
|
||||
return err;
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// MakeMovieFromPath
|
||||
// ---------------------------------------------------------------------------
|
||||
OSStatus MakeMovieFromPath(const char* path, Movie* movie, short& resref) {
|
||||
OSStatus err;
|
||||
FSSpec spec;
|
||||
#ifdef __APPLE__
|
||||
MakeFSSpecFromPath(path, &spec);
|
||||
#else
|
||||
err = NativePathNameToFSSpec((char*)path, &spec, 0 /* flags */);
|
||||
#endif
|
||||
err = OpenMovieFile(&spec, &resref, fsRdPerm);
|
||||
if (err!=0) return err;
|
||||
err = NewMovieFromFile(movie, resref, NULL, NULL, 0, NULL);
|
||||
if (err==0) err=GetMoviesError();
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -50,11 +50,6 @@
|
||||
|
||||
#endif
|
||||
|
||||
/** constructs an FSSpec out of an path */
|
||||
OSStatus MakeFSSpecFromPath(const char* path, FSSpec* spec);
|
||||
|
||||
/** opens a movie from a path */
|
||||
OSStatus MakeMovieFromPath(const char* path, Movie* movie, short& resref);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <cstdlib>
|
||||
|
||||
#include <osg/Notify>
|
||||
#include <osg/Image>
|
||||
#include <osg/Timer>
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/Referenced>
|
||||
@@ -113,7 +114,7 @@ void QuicktimeLiveImageStream::createImage()
|
||||
GL_UNSIGNED_INT_8_8_8_8;
|
||||
|
||||
setImage(m_videoRectWidth,m_videoRectHeight,1,
|
||||
(GLint) GL_RGBA8, (GLenum)GL_BGRA_EXT, internalFormat,
|
||||
(GLint) GL_RGBA8, (GLenum)GL_BGRA, internalFormat,
|
||||
(unsigned char*)buffer,osg::Image::NO_DELETE,4);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
|
||||
|
||||
|
||||
ReaderWriterQT::ReaderWriterQT()
|
||||
ReaderWriterQT()
|
||||
{
|
||||
|
||||
registerQtReader();
|
||||
@@ -131,11 +131,15 @@ public:
|
||||
supportsExtension("m4v","Movie format");
|
||||
supportsExtension("dv","Movie format");
|
||||
supportsExtension("avi","Movie format");
|
||||
supportsExtension("sdp","RTSP Movie format");
|
||||
supportsExtension("flv","Movie format");
|
||||
supportsExtension("swf","Movie format");
|
||||
supportsExtension("3gp","Mobile movie format");
|
||||
|
||||
supportsExtension("live","Live video streaming");
|
||||
|
||||
supportsProtocol("http", "streaming media per http");
|
||||
supportsProtocol("rtsp", "streaming media per rtsp");
|
||||
|
||||
#ifdef QT_HANDLE_IMAGES_ALSO
|
||||
supportsExtension("jpg","jpg image format");
|
||||
@@ -151,7 +155,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
ReaderWriterQT::~ReaderWriterQT()
|
||||
~ReaderWriterQT()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -167,6 +171,7 @@ public:
|
||||
osgDB::equalCaseInsensitive(extension,"m4v") ||
|
||||
osgDB::equalCaseInsensitive(extension,"dv") ||
|
||||
osgDB::equalCaseInsensitive(extension,"avi") ||
|
||||
osgDB::equalCaseInsensitive(extension,"sdp") ||
|
||||
osgDB::equalCaseInsensitive(extension,"flv") ||
|
||||
osgDB::equalCaseInsensitive(extension,"swf") ||
|
||||
osgDB::equalCaseInsensitive(extension,"3gp");
|
||||
@@ -294,9 +299,10 @@ public:
|
||||
}
|
||||
|
||||
// Not an encoded "live" psuedo file - so check a real file exists
|
||||
std::string fileName = osgDB::findDataFile( file, options);
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
// only find the file if it isn't a URL
|
||||
std::string fileName = file;
|
||||
|
||||
|
||||
// Note from Riccardo Corsi
|
||||
// Quicktime initialization is done here, when a media is found
|
||||
// and before any image or movie is loaded.
|
||||
@@ -308,6 +314,12 @@ public:
|
||||
// if the file is a movie file then load as an ImageStream.
|
||||
if (acceptsMovieExtension(ext))
|
||||
{
|
||||
// quicktime supports playing movies from URLs
|
||||
if (!osgDB::containsServerAddress(fileName)) {
|
||||
fileName = osgDB::findDataFile( file, options);
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
// note from Robert Osfield when integrating, we should probably have so
|
||||
// error handling mechanism here. Possibly move the load from
|
||||
// the constructor to a seperate load method, and have a valid
|
||||
@@ -321,7 +333,13 @@ public:
|
||||
|
||||
return moov;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// no live-video, no movie-file, so try to load as an image
|
||||
|
||||
fileName = osgDB::findDataFile( file, options);
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
QuicktimeImportExport importer;
|
||||
|
||||
std::ifstream is;
|
||||
|
||||
Reference in New Issue
Block a user