openmw-tes3coop/apps/openmw/mwrender/videoplayer.hpp

138 lines
2.6 KiB
C++
Raw Normal View History

2012-09-25 00:35:50 +00:00
#ifndef MWRENDER_VIDEOPLAYER_H
#define MWRENDER_VIDEOPLAYER_H
//#ifdef OPENMW_USE_FFMPEG
#include <string>
#include <OgreDataStream.h>
#include <OgreTexture.h>
2012-09-25 00:54:29 +00:00
#include <OgreTimer.h>
2012-09-25 00:35:50 +00:00
namespace Ogre
{
class Rectangle2D;
class SceneManager;
class TextureUnitState;
}
struct AVFormatContext;
struct AVCodecContext;
struct AVCodec;
2012-12-03 15:44:41 +00:00
struct AVStream;
2012-09-25 00:35:50 +00:00
struct AVFrame;
struct SwsContext;
struct AVPacket;
struct AVPacketList;
2012-09-25 00:35:50 +00:00
namespace MWRender
{
/// A simple queue used to queue raw audio and video data.
class AVPacketQueue
{
public:
AVPacketQueue();
int put(AVPacket* pkt);
int get(AVPacket* pkt, int block);
bool isEmpty() const { return mNumPackets == 0; }
int getNumPackets() const { return mNumPackets; }
int getSize() const { return mSize; }
private:
AVPacketList* mFirstPacket;
AVPacketList* mLastPacket;
int mNumPackets;
int mSize;
};
2012-09-25 00:35:50 +00:00
class VideoPlayer
{
public:
VideoPlayer(Ogre::SceneManager* sceneMgr);
~VideoPlayer();
void play (const std::string& resourceName);
void update();
private:
Ogre::Rectangle2D* mRectangle;
Ogre::TextureUnitState* mTextureUnit;
Ogre::DataStreamPtr mStream;
Ogre::TexturePtr mVideoTexture;
private:
AVFormatContext* mAvContext;
2012-09-25 00:54:29 +00:00
Ogre::Timer mTimer;
2012-09-25 00:35:50 +00:00
AVCodec* mVideoCodec;
2012-12-03 15:44:41 +00:00
AVCodec* mAudioCodec;
AVStream* mVideoStream;
AVStream* mAudioStream;
int mVideoStreamId; ///< ID of the first video stream
int mAudioStreamId; ///< ID of the first audio stream
2012-09-25 00:35:50 +00:00
AVFrame* mRawFrame;
AVFrame* mRGBAFrame;
SwsContext* mSwsContext;
2012-12-03 15:44:41 +00:00
double mClock;
double mVideoClock;
double mAudioClock;
2012-09-25 00:54:29 +00:00
AVPacketQueue mVideoPacketQueue;
AVPacketQueue mAudioPacketQueue;
2012-09-25 00:35:50 +00:00
void close();
void deleteContext();
void throwError(int error);
bool addToBuffer(); ///< try to add the next audio or video packet into the queue.
void decodeNextVideoFrame(); ///< decode the next video frame in the queue and display it.
2012-09-25 00:35:50 +00:00
};
}
//#else
/*
// If FFMPEG not available, dummy implentation that does nothing
namespace MWRender
{
class VideoPlayer
{
public:
VideoPlayer(Ogre::SceneManager* sceneMgr){}
void play (const std::string& resourceName) {}
void update() {}
};
}
*/
//#endif
#endif