Files
itgmania212121/stepmania/src/arch/MovieTexture/MovieTexture_FFMpeg.h
T

100 lines
2.4 KiB
C++
Raw Normal View History

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"
#include "SDL_mutex.h"
2003-09-02 04:19:02 +00:00
#define SUPPORT_MOVIETEXTURE_FFMPEG
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-08-29 04:34:10 +00:00
namespace avcodec
{
2003-09-02 04:01:01 +00:00
#if defined(_WIN32)
#include "ffmpeg/include/ffmpeg/avformat.h"
#else
2003-09-01 06:39:08 +00:00
#include <ffmpeg/avformat.h>
2003-09-02 04:01:01 +00:00
#endif
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:
avcodec::AVFormatContext *m_fctx;
avcodec::AVStream *m_stream;
/* The time the movie is actually at: */
float m_Position;
float m_Rate;
bool m_ImageWaiting;
bool m_bLoop;
/*
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.
*
* PLAYING_ONE: The decoder thread will decode one frame, post the
* m_FrameDecoded semaphore and change to the PAUSE_DECODER state.
* This is only used by Create().
*/
enum State { DECODER_QUIT, PAUSE_DECODER, PLAYING, PLAYING_ONE } m_State;
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
SDL_sem *m_BufferFinished, *m_OneFrameDecoded;
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-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 CheckFrame();
void StartThread();
void StopThread();
};
/*
Copyright (c) 2003 by the person(s) listed below. All rights reserved.
Glenn Maynard
*/
#endif