make MovieTexture act more like other drivers: MovieTexture itself
is a factory for RageTexture objects, not a RageTexture itself. The actual RageTexture objects don't need to be exposed in the headers (DShow still does it for DShow_Helpers), so we don't need to expose the headers of the movie API to user code. (We could also eliminate reconstructing the factory driver each time we make a movie, but there's no real reason to currently.)
This commit is contained in:
@@ -57,14 +57,10 @@ bool RageMovieTexture::GetFourCC( RString fn, RString &handler, RString &type )
|
|||||||
#undef HANDLE_ERROR
|
#undef HANDLE_ERROR
|
||||||
}
|
}
|
||||||
|
|
||||||
map<istring, CreateMovieTextureFn> *RegisterMovieTexture::g_pRegistrees = NULL;
|
static DriverList g_pRegistrees;
|
||||||
RegisterMovieTexture::RegisterMovieTexture( const istring &sName, CreateMovieTextureFn pfn )
|
RegisterMovieTextureDriver::RegisterMovieTextureDriver( const istring &sName, CreateRageDriverFn pfn )
|
||||||
{
|
{
|
||||||
if( g_pRegistrees == NULL )
|
g_pRegistrees.Add( sName, pfn );
|
||||||
g_pRegistrees = new map<istring, CreateMovieTextureFn>;
|
|
||||||
|
|
||||||
ASSERT( g_pRegistrees->find(sName) == g_pRegistrees->end() );
|
|
||||||
(*g_pRegistrees)[sName] = pfn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper for MakeRageMovieTexture()
|
// Helper for MakeRageMovieTexture()
|
||||||
@@ -100,17 +96,22 @@ RageMovieTexture *MakeRageMovieTexture( RageTextureID ID )
|
|||||||
FOREACH_CONST( RString, DriversToTry, Driver )
|
FOREACH_CONST( RString, DriversToTry, Driver )
|
||||||
{
|
{
|
||||||
LOG->Trace( "Initializing driver: %s", Driver->c_str() );
|
LOG->Trace( "Initializing driver: %s", Driver->c_str() );
|
||||||
map<istring, CreateMovieTextureFn>::const_iterator iter = RegisterMovieTexture::g_pRegistrees->find( istring(*Driver) );
|
RageDriver *pDriverBase = g_pRegistrees.Create( *Driver );
|
||||||
|
|
||||||
if( iter == RegisterMovieTexture::g_pRegistrees->end() )
|
if( pDriverBase == NULL )
|
||||||
{
|
{
|
||||||
LOG->Trace( "Unknown movie driver name: %s", Driver->c_str() );
|
LOG->Trace( "Unknown movie driver name: %s", Driver->c_str() );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ret = (iter->second)( ID );
|
|
||||||
DEBUG_ASSERT( ret );
|
RageMovieTextureDriver *pDriver = dynamic_cast<RageMovieTextureDriver *>( pDriverBase );
|
||||||
const RString sError = ret->Init();
|
ASSERT( pDriver );
|
||||||
if( sError != "" )
|
|
||||||
|
RString sError;
|
||||||
|
ret = pDriver->Create( ID, sError );
|
||||||
|
delete pDriver;
|
||||||
|
|
||||||
|
if( ret == NULL )
|
||||||
{
|
{
|
||||||
LOG->Info( "Couldn't load driver %s: %s", Driver->c_str(), sError.c_str() );
|
LOG->Info( "Couldn't load driver %s: %s", Driver->c_str(), sError.c_str() );
|
||||||
SAFE_DELETE( ret );
|
SAFE_DELETE( ret );
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define MOVIE_TEXTURE_H
|
#define MOVIE_TEXTURE_H
|
||||||
|
|
||||||
#include "RageTexture.h"
|
#include "RageTexture.h"
|
||||||
|
#include "arch/RageDriver.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
class RageMovieTexture : public RageTexture
|
class RageMovieTexture : public RageTexture
|
||||||
@@ -9,7 +10,6 @@ class RageMovieTexture : public RageTexture
|
|||||||
public:
|
public:
|
||||||
RageMovieTexture( RageTextureID ID ): RageTexture(ID) { }
|
RageMovieTexture( RageTextureID ID ): RageTexture(ID) { }
|
||||||
virtual ~RageMovieTexture() { }
|
virtual ~RageMovieTexture() { }
|
||||||
virtual RString Init() { return RString(); }
|
|
||||||
virtual void Update( float fDeltaTime ) { }
|
virtual void Update( float fDeltaTime ) { }
|
||||||
|
|
||||||
virtual void Reload() = 0;
|
virtual void Reload() = 0;
|
||||||
@@ -23,15 +23,19 @@ public:
|
|||||||
static bool GetFourCC( RString fn, RString &handler, RString &type );
|
static bool GetFourCC( RString fn, RString &handler, RString &type );
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef RageMovieTexture *(*CreateMovieTextureFn)( RageTextureID );
|
class RageMovieTextureDriver: public RageDriver
|
||||||
struct RegisterMovieTexture
|
|
||||||
{
|
{
|
||||||
static map<istring, CreateMovieTextureFn> *g_pRegistrees;
|
public:
|
||||||
RegisterMovieTexture( const istring &sName, CreateMovieTextureFn );
|
virtual ~RageMovieTextureDriver() { }
|
||||||
|
virtual RageMovieTexture *Create( RageTextureID ID, RString &sError ) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RegisterMovieTextureDriver
|
||||||
|
{
|
||||||
|
RegisterMovieTextureDriver( const istring &sName, CreateRageDriverFn );
|
||||||
};
|
};
|
||||||
#define REGISTER_MOVIE_TEXTURE_CLASS( name ) \
|
#define REGISTER_MOVIE_TEXTURE_CLASS( name ) \
|
||||||
static RageMovieTexture *Create##name( RageTextureID ID ) { return new MovieTexture_##name( ID ); } \
|
static RegisterMovieTextureDriver register_##name( #name, CreateClass<RageMovieTextureDriver_##name, RageDriver> )
|
||||||
static RegisterMovieTexture register_##className( #name, Create##name )
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,15 @@
|
|||||||
#pragma comment(lib, "vfw32.lib")
|
#pragma comment(lib, "vfw32.lib")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
RageMovieTexture *RageMovieTextureDriver_DShow::Create( RageTextureID ID, RString &sError )
|
||||||
|
{
|
||||||
|
MovieTexture_DShow *pRet = new MovieTexture_DShow( ID );
|
||||||
|
sError = pRet->Init();
|
||||||
|
if( !sError.empty() )
|
||||||
|
SAFE_DELETE( pRet );
|
||||||
|
return pRet;
|
||||||
|
}
|
||||||
|
|
||||||
REGISTER_MOVIE_TEXTURE_CLASS( DShow );
|
REGISTER_MOVIE_TEXTURE_CLASS( DShow );
|
||||||
|
|
||||||
static RString FourCCToString( int fcc )
|
static RString FourCCToString( int fcc )
|
||||||
|
|||||||
@@ -71,6 +71,12 @@ private:
|
|||||||
bool m_bPlaying;
|
bool m_bPlaying;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class RageMovieTextureDriver_DShow: public RageMovieTextureDriver
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual RageMovieTexture *Create( RageTextureID ID, RString &sError );
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
|
||||||
REGISTER_MOVIE_TEXTURE_CLASS( FFMpeg );
|
|
||||||
|
|
||||||
namespace avcodec
|
namespace avcodec
|
||||||
{
|
{
|
||||||
#include <ffmpeg/avformat.h>
|
#include <ffmpeg/avformat.h>
|
||||||
@@ -129,6 +127,15 @@ static int FindCompatibleAVFormat( bool bHighColor )
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class MovieTexture_FFMpeg: public MovieTexture_Generic
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MovieTexture_FFMpeg( RageTextureID ID );
|
||||||
|
|
||||||
|
static void RegisterProtocols();
|
||||||
|
static RageSurface *AVCodecCreateCompatibleSurface( int iTextureWidth, int iTextureHeight, bool bPreferHighColor, int &iAVTexfmt );
|
||||||
|
};
|
||||||
|
|
||||||
RageSurface *MovieTexture_FFMpeg::AVCodecCreateCompatibleSurface( int iTextureWidth, int iTextureHeight, bool bPreferHighColor, int &iAVTexfmt )
|
RageSurface *MovieTexture_FFMpeg::AVCodecCreateCompatibleSurface( int iTextureWidth, int iTextureHeight, bool bPreferHighColor, int &iAVTexfmt )
|
||||||
{
|
{
|
||||||
FixLilEndian();
|
FixLilEndian();
|
||||||
@@ -599,6 +606,17 @@ MovieTexture_FFMpeg::MovieTexture_FFMpeg( RageTextureID ID ):
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RageMovieTexture *RageMovieTextureDriver_FFMpeg::Create( RageTextureID ID, RString &sError )
|
||||||
|
{
|
||||||
|
MovieTexture_FFMpeg *pRet = new MovieTexture_FFMpeg( ID );
|
||||||
|
sError = pRet->Init();
|
||||||
|
if( !sError.empty() )
|
||||||
|
SAFE_DELETE( pRet );
|
||||||
|
return pRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
REGISTER_MOVIE_TEXTURE_CLASS( FFMpeg );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2003-2005 Glenn Maynard
|
* (c) 2003-2005 Glenn Maynard
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -5,13 +5,10 @@
|
|||||||
|
|
||||||
#include "MovieTexture_Generic.h"
|
#include "MovieTexture_Generic.h"
|
||||||
|
|
||||||
class MovieTexture_FFMpeg: public MovieTexture_Generic
|
class RageMovieTextureDriver_FFMpeg: public RageMovieTextureDriver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MovieTexture_FFMpeg( RageTextureID ID );
|
virtual RageMovieTexture *Create( RageTextureID ID, RString &sError );
|
||||||
|
|
||||||
static void RegisterProtocols();
|
|
||||||
static RageSurface *AVCodecCreateCompatibleSurface( int iTextureWidth, int iTextureHeight, bool bPreferHighColor, int &iAVTexfmt );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,7 +6,24 @@
|
|||||||
#include "MovieTexture_Null.h"
|
#include "MovieTexture_Null.h"
|
||||||
#include "RageSurface.h"
|
#include "RageSurface.h"
|
||||||
|
|
||||||
REGISTER_MOVIE_TEXTURE_CLASS( Null );
|
class MovieTexture_Null : public RageMovieTexture {
|
||||||
|
public:
|
||||||
|
MovieTexture_Null(RageTextureID ID);
|
||||||
|
virtual ~MovieTexture_Null();
|
||||||
|
void Invalidate() { texHandle = 0; }
|
||||||
|
unsigned GetTexHandle() const { return texHandle; }
|
||||||
|
void Update(float delta) { }
|
||||||
|
void Reload() { }
|
||||||
|
void SetPosition(float seconds) { }
|
||||||
|
void SetPlaybackRate(float rate) { }
|
||||||
|
void SetLooping(bool looping=true) { loop = looping; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool playing;
|
||||||
|
bool loop;
|
||||||
|
unsigned texHandle;
|
||||||
|
};
|
||||||
|
|
||||||
MovieTexture_Null::MovieTexture_Null(RageTextureID ID) : RageMovieTexture(ID)
|
MovieTexture_Null::MovieTexture_Null(RageTextureID ID) : RageMovieTexture(ID)
|
||||||
{
|
{
|
||||||
LOG->Trace("MovieTexture_Null::MovieTexture_Null(ID)");
|
LOG->Trace("MovieTexture_Null::MovieTexture_Null(ID)");
|
||||||
@@ -47,6 +64,13 @@ MovieTexture_Null::~MovieTexture_Null()
|
|||||||
DISPLAY->DeleteTexture( texHandle );
|
DISPLAY->DeleteTexture( texHandle );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
REGISTER_MOVIE_TEXTURE_CLASS( Null );
|
||||||
|
|
||||||
|
RageMovieTexture *RageMovieTextureDriver_Null::Create( RageTextureID ID, RString &sError )
|
||||||
|
{
|
||||||
|
return new MovieTexture_Null( ID );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2003 Steve Checkoway
|
* (c) 2003 Steve Checkoway
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -10,24 +10,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "MovieTexture.h"
|
#include "MovieTexture.h"
|
||||||
#include "RageTexture.h"
|
|
||||||
|
|
||||||
class MovieTexture_Null : public RageMovieTexture {
|
class RageMovieTextureDriver_Null: public RageMovieTextureDriver
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
MovieTexture_Null(RageTextureID ID);
|
virtual RageMovieTexture *Create( RageTextureID ID, RString &sError );
|
||||||
virtual ~MovieTexture_Null();
|
|
||||||
void Invalidate() { texHandle = 0; }
|
|
||||||
unsigned GetTexHandle() const { return texHandle; }
|
|
||||||
void Update(float delta) { }
|
|
||||||
void Reload() { }
|
|
||||||
void SetPosition(float seconds) { }
|
|
||||||
void SetPlaybackRate(float rate) { }
|
|
||||||
void SetLooping(bool looping=true) { loop = looping; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool playing;
|
|
||||||
bool loop;
|
|
||||||
unsigned texHandle;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "MovieTexture_FFMpeg.h" /* for AVCodecCreateCompatibleSurface */
|
#include "MovieTexture_FFMpeg.h" /* for AVCodecCreateCompatibleSurface */
|
||||||
|
|
||||||
REGISTER_MOVIE_TEXTURE_CLASS( Theora );
|
|
||||||
|
|
||||||
namespace avcodec
|
namespace avcodec
|
||||||
{
|
{
|
||||||
#include <ffmpeg/avcodec.h> /* for avcodec::img_convert */
|
#include <ffmpeg/avcodec.h> /* for avcodec::img_convert */
|
||||||
@@ -699,11 +697,28 @@ void MovieDecoder_Theora::Close()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
class MovieTexture_Theora: public MovieTexture_Generic
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MovieTexture_Theora( RageTextureID ID );
|
||||||
|
};
|
||||||
|
|
||||||
MovieTexture_Theora::MovieTexture_Theora( RageTextureID ID ):
|
MovieTexture_Theora::MovieTexture_Theora( RageTextureID ID ):
|
||||||
MovieTexture_Generic( ID, new MovieDecoder_Theora )
|
MovieTexture_Generic( ID, new MovieDecoder_Theora )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RageMovieTexture *RageMovieTextureDriver_Theora::Create( RageTextureID ID, RString &sError )
|
||||||
|
{
|
||||||
|
MovieTexture_Theora *pRet = new MovieTexture_Theora( ID );
|
||||||
|
sError = pRet->Init();
|
||||||
|
if( !sError.empty() )
|
||||||
|
SAFE_DELETE( pRet );
|
||||||
|
return pRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
REGISTER_MOVIE_TEXTURE_CLASS( Theora );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2005 Glenn Maynard
|
* (c) 2005 Glenn Maynard
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
|
|
||||||
#include "MovieTexture_Generic.h"
|
#include "MovieTexture_Generic.h"
|
||||||
|
|
||||||
class MovieTexture_Theora: public MovieTexture_Generic
|
class RageMovieTextureDriver_Theora: public RageMovieTextureDriver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MovieTexture_Theora( RageTextureID ID );
|
virtual RageMovieTexture *Create( RageTextureID ID, RString &sError );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user