2003-09-02 04:19:02 +00:00
|
|
|
#ifndef RAGEMOVIETEXTURE_FFMPEG_H
|
|
|
|
|
#define RAGEMOVIETEXTURE_FFMPEG_H
|
2003-08-29 04:34:10 +00:00
|
|
|
|
|
|
|
|
#include "MovieTexture.h"
|
|
|
|
|
|
|
|
|
|
#include "RageDisplay.h"
|
|
|
|
|
#include "RageTexture.h"
|
|
|
|
|
#include "RageThreads.h"
|
2004-04-02 23:00:29 +00:00
|
|
|
#include "RageTimer.h"
|
2003-08-29 04:34:10 +00:00
|
|
|
|
|
|
|
|
#include "SDL_mutex.h"
|
|
|
|
|
|
2003-09-02 19:30:20 +00:00
|
|
|
/* Fix a compile problem in gcc 3.2: */
|
|
|
|
|
#if defined(HAVE_INTTYPES_H)
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-09-03 02:18:39 +00:00
|
|
|
class FFMpeg_Helper;
|
2003-08-29 04:34:10 +00:00
|
|
|
|
2003-09-02 04:01:01 +00:00
|
|
|
class MovieTexture_FFMpeg: public RageMovieTexture
|
2003-08-29 04:34:10 +00:00
|
|
|
{
|
|
|
|
|
public:
|
2003-09-02 04:01:01 +00:00
|
|
|
MovieTexture_FFMpeg( RageTextureID ID );
|
|
|
|
|
virtual ~MovieTexture_FFMpeg();
|
2003-08-29 04:34:10 +00:00
|
|
|
/* only called by RageTextureManager::InvalidateTextures */
|
|
|
|
|
void Invalidate() { m_uTexHandle = 0; }
|
|
|
|
|
void Update(float fDeltaTime);
|
|
|
|
|
|
|
|
|
|
virtual void Reload();
|
|
|
|
|
|
|
|
|
|
virtual void Play();
|
|
|
|
|
virtual void Pause();
|
|
|
|
|
virtual void SetPosition( float fSeconds );
|
|
|
|
|
virtual void SetPlaybackRate( float fRate ) { m_Rate=fRate; }
|
|
|
|
|
virtual bool IsPlaying() const { return m_State == PLAYING; }
|
|
|
|
|
void SetLooping(bool looping=true) { m_bLoop = looping; }
|
2003-09-02 07:47:37 +00:00
|
|
|
unsigned GetTexHandle() const { return m_uTexHandle; }
|
2003-08-29 04:34:10 +00:00
|
|
|
|
|
|
|
|
private:
|
2003-09-03 02:18:39 +00:00
|
|
|
FFMpeg_Helper *decoder;
|
2003-08-29 04:34:10 +00:00
|
|
|
|
|
|
|
|
/* The time the movie is actually at: */
|
|
|
|
|
float m_Rate;
|
|
|
|
|
bool m_ImageWaiting;
|
|
|
|
|
bool m_bLoop;
|
2003-09-03 02:18:39 +00:00
|
|
|
bool m_bWantRewind;
|
2003-08-29 04:34:10 +00:00
|
|
|
|
|
|
|
|
/*
|
2003-09-02 07:47:37 +00:00
|
|
|
* Only the main thread can change m_State.
|
2003-08-29 04:34:10 +00:00
|
|
|
*
|
2003-09-02 07:47:37 +00:00
|
|
|
* DECODER_QUIT: The decoder thread is not running. We should only
|
2003-08-29 04:34:10 +00:00
|
|
|
* be in this state internally; when we return after a call, we should
|
|
|
|
|
* never be in this state. Start the thread before returning.
|
|
|
|
|
*
|
|
|
|
|
* PAUSE_DECODER: The decoder thread is idle.
|
|
|
|
|
*
|
|
|
|
|
* PLAYING: The decoder thread is running.
|
|
|
|
|
*/
|
2003-09-03 02:18:39 +00:00
|
|
|
enum State { DECODER_QUIT, PAUSE_DECODER, PLAYING } m_State;
|
2003-08-29 04:34:10 +00:00
|
|
|
|
|
|
|
|
unsigned m_uTexHandle;
|
|
|
|
|
|
|
|
|
|
SDL_Surface *m_img;
|
2003-09-02 07:47:37 +00:00
|
|
|
int m_AVTexfmt; /* AVPixelFormat_t of m_img */
|
2003-08-29 04:34:10 +00:00
|
|
|
|
2003-09-03 02:18:39 +00:00
|
|
|
SDL_sem *m_BufferFinished;
|
2003-08-29 04:34:10 +00:00
|
|
|
|
2004-04-02 23:00:29 +00:00
|
|
|
RageTimer m_Timer;
|
|
|
|
|
float m_Clock;
|
|
|
|
|
bool m_FrameSkipMode;
|
|
|
|
|
|
2003-09-02 04:01:01 +00:00
|
|
|
static int DecoderThread_start(void *p) { ((MovieTexture_FFMpeg *)(p))->DecoderThread(); return 0; }
|
2003-08-29 04:34:10 +00:00
|
|
|
void DecoderThread();
|
|
|
|
|
RageThread m_DecoderThread;
|
|
|
|
|
|
2003-09-03 02:18:39 +00:00
|
|
|
void ConvertFrame();
|
|
|
|
|
void UpdateFrame();
|
|
|
|
|
|
2003-09-02 06:08:02 +00:00
|
|
|
void CreateDecoder();
|
2003-08-29 04:34:10 +00:00
|
|
|
void CreateTexture();
|
2003-09-02 06:08:02 +00:00
|
|
|
void DestroyDecoder();
|
|
|
|
|
void DestroyTexture();
|
2003-08-29 04:34:10 +00:00
|
|
|
void StartThread();
|
|
|
|
|
void StopThread();
|
2004-04-02 23:00:29 +00:00
|
|
|
bool RunDecode();
|
2003-08-29 04:34:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Copyright (c) 2003 by the person(s) listed below. All rights reserved.
|
|
|
|
|
Glenn Maynard
|
|
|
|
|
*/
|
|
|
|
|
#endif
|