forked from teamnwah/openmw-tes3coop
added video timing
This commit is contained in:
parent
73c69e8eda
commit
05eb307bfb
3 changed files with 19 additions and 1 deletions
|
@ -372,6 +372,7 @@ void WindowManager::updateVisible()
|
||||||
MyGUI::PointerManager::getInstance().setVisible(false);
|
MyGUI::PointerManager::getInstance().setVisible(false);
|
||||||
break;
|
break;
|
||||||
case GM_Video:
|
case GM_Video:
|
||||||
|
MyGUI::PointerManager::getInstance().setVisible(false);
|
||||||
mHud->setVisible(false);
|
mHud->setVisible(false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -109,6 +109,7 @@ namespace MWRender
|
||||||
|
|
||||||
mVideoStreamId = -1;
|
mVideoStreamId = -1;
|
||||||
mEOF = false;
|
mEOF = false;
|
||||||
|
mDisplayedFrameCount = 0;
|
||||||
|
|
||||||
// if something is already playing, close it
|
// if something is already playing, close it
|
||||||
if (mAvContext)
|
if (mAvContext)
|
||||||
|
@ -236,6 +237,8 @@ namespace MWRender
|
||||||
|
|
||||||
mTextureUnit->setTextureName ("VideoTexture");
|
mTextureUnit->setTextureName ("VideoTexture");
|
||||||
|
|
||||||
|
mTimer.reset();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoPlayer::throwError(int error)
|
void VideoPlayer::throwError(int error)
|
||||||
|
@ -309,6 +312,14 @@ namespace MWRender
|
||||||
if (!mAvContext)
|
if (!mAvContext)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Time elapsed since the video started
|
||||||
|
float realTime = mTimer.getMilliseconds ()/1000.f;
|
||||||
|
|
||||||
|
// Here is the time we're at in the video
|
||||||
|
float movieTime = mDisplayedFrameCount * mWantedFrameTime;
|
||||||
|
|
||||||
|
if (movieTime >= realTime)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!mVideoPacketQueue.size() && mEOF)
|
if (!mVideoPacketQueue.size() && mEOF)
|
||||||
close();
|
close();
|
||||||
|
@ -353,10 +364,11 @@ namespace MWRender
|
||||||
Ogre::PixelBox pb(mVideoCodecContext->width, mVideoCodecContext->height, 1, Ogre::PF_BYTE_RGBA, mRGBAFrame->data[0]);
|
Ogre::PixelBox pb(mVideoCodecContext->width, mVideoCodecContext->height, 1, Ogre::PF_BYTE_RGBA, mRGBAFrame->data[0]);
|
||||||
pixelBuffer->blitFromMemory(pb);
|
pixelBuffer->blitFromMemory(pb);
|
||||||
|
|
||||||
//m_displayedFrameCount++;
|
|
||||||
av_free_packet(mVideoPacketQueue.front());
|
av_free_packet(mVideoPacketQueue.front());
|
||||||
av_free(mVideoPacketQueue.front());
|
av_free(mVideoPacketQueue.front());
|
||||||
mVideoPacketQueue.pop();
|
mVideoPacketQueue.pop();
|
||||||
|
|
||||||
|
++mDisplayedFrameCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoPlayer::close ()
|
void VideoPlayer::close ()
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include <OgreDataStream.h>
|
#include <OgreDataStream.h>
|
||||||
#include <OgreTexture.h>
|
#include <OgreTexture.h>
|
||||||
|
#include <OgreTimer.h>
|
||||||
|
|
||||||
namespace Ogre
|
namespace Ogre
|
||||||
{
|
{
|
||||||
|
@ -53,6 +54,8 @@ namespace MWRender
|
||||||
|
|
||||||
bool mEOF;
|
bool mEOF;
|
||||||
|
|
||||||
|
Ogre::Timer mTimer;
|
||||||
|
|
||||||
// VIDEO
|
// VIDEO
|
||||||
AVCodecContext* mVideoCodecContext;
|
AVCodecContext* mVideoCodecContext;
|
||||||
AVCodec* mVideoCodec;
|
AVCodec* mVideoCodec;
|
||||||
|
@ -64,6 +67,8 @@ namespace MWRender
|
||||||
float mDecodingTime;
|
float mDecodingTime;
|
||||||
std::queue <AVPacket *> mVideoPacketQueue;
|
std::queue <AVPacket *> mVideoPacketQueue;
|
||||||
|
|
||||||
|
int mDisplayedFrameCount;
|
||||||
|
|
||||||
|
|
||||||
bool readFrameAndQueue();
|
bool readFrameAndQueue();
|
||||||
bool saveFrame(AVPacket* frame);
|
bool saveFrame(AVPacket* frame);
|
||||||
|
|
Loading…
Reference in a new issue