Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

MovieTexture_FFMpeg.h

Go to the documentation of this file.
00001 #ifndef RAGEMOVIETEXTURE_FFMPEG_H 00002 #define RAGEMOVIETEXTURE_FFMPEG_H 00003 00004 #include "MovieTexture.h" 00005 00006 #include "RageDisplay.h" 00007 #include "RageTexture.h" 00008 #include "RageThreads.h" 00009 #include "RageTimer.h" 00010 00011 /* Fix a compile problem in gcc 3.2: */ 00012 #if defined(HAVE_INTTYPES_H) 00013 #include <inttypes.h> 00014 #endif 00015 00016 class FFMpeg_Helper; 00017 00018 class MovieTexture_FFMpeg: public RageMovieTexture 00019 { 00020 public: 00021 MovieTexture_FFMpeg( RageTextureID ID ); 00022 virtual ~MovieTexture_FFMpeg(); 00023 CString Init(); 00024 00025 /* only called by RageTextureManager::InvalidateTextures */ 00026 void Invalidate() { m_uTexHandle = 0; } 00027 void Update(float fDeltaTime); 00028 00029 virtual void Reload(); 00030 00031 virtual void SetPosition( float fSeconds ); 00032 virtual void DecodeSeconds( float fSeconds ); 00033 virtual void SetPlaybackRate( float fRate ) { m_Rate=fRate; } 00034 void SetLooping(bool looping=true) { m_bLoop = looping; } 00035 unsigned GetTexHandle() const { return m_uTexHandle; } 00036 00037 static void RegisterProtocols(); 00038 00039 private: 00040 FFMpeg_Helper *decoder; 00041 00042 /* The time the movie is actually at: */ 00043 float m_Rate; 00044 enum { 00045 FRAME_NONE, /* no frame available; call GetFrame to get one */ 00046 FRAME_DECODED, /* frame decoded; call ConvertFrame */ 00047 FRAME_WAITING /* frame converted and waiting to be uploaded */ 00048 } m_ImageWaiting; 00049 bool m_bLoop; 00050 bool m_bWantRewind; 00051 bool m_bThreaded; 00052 00053 /* 00054 * Only the main thread can change m_State. 00055 * 00056 * DECODER_QUIT: The decoder thread is not running. We should only 00057 * be in this state internally; when we return after a call, we should 00058 * never be in this state. Start the thread before returning. 00059 * 00060 * PAUSE_DECODER: The decoder thread is idle. 00061 * 00062 * PLAYING: The decoder thread is running. 00063 */ 00064 enum State { DECODER_QUIT, DECODER_RUNNING } m_State; 00065 00066 unsigned m_uTexHandle; 00067 00068 RageSurface *m_img; 00069 int m_AVTexfmt; /* AVPixelFormat_t of m_img */ 00070 00071 RageSemaphore m_BufferFinished; 00072 00073 RageTimer m_Timer; 00074 float m_Clock; 00075 bool m_FrameSkipMode; 00076 00077 static int DecoderThread_start(void *p) { ((MovieTexture_FFMpeg *)(p))->DecoderThread(); return 0; } 00078 void DecoderThread(); 00079 RageThread m_DecoderThread; 00080 00081 void ConvertFrame(); 00082 void UpdateFrame(); 00083 00084 CString CreateDecoder(); 00085 void CreateTexture(); 00086 void DestroyDecoder(); 00087 void DestroyTexture(); 00088 void StartThread(); 00089 void StopThread(); 00090 00091 bool DecodeFrame(); 00092 float CheckFrameTime(); 00093 void DiscardFrame(); 00094 }; 00095 00096 #endif 00097 00098 /* 00099 * (c) 2003-2004 Glenn Maynard 00100 * All rights reserved. 00101 * 00102 * Permission is hereby granted, free of charge, to any person obtaining a 00103 * copy of this software and associated documentation files (the 00104 * "Software"), to deal in the Software without restriction, including 00105 * without limitation the rights to use, copy, modify, merge, publish, 00106 * distribute, and/or sell copies of the Software, and to permit persons to 00107 * whom the Software is furnished to do so, provided that the above 00108 * copyright notice(s) and this permission notice appear in all copies of 00109 * the Software and that both the above copyright notice(s) and this 00110 * permission notice appear in supporting documentation. 00111 * 00112 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00113 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00114 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00115 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00116 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00117 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00118 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00119 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00120 * PERFORMANCE OF THIS SOFTWARE. 00121 */

Generated on Thu Jan 27 20:57:25 2005 for StepMania by doxygen 1.3.7