|
|
@ -171,9 +171,11 @@ plMoviePlayer::plMoviePlayer() : |
|
|
|
fPlate(nullptr), |
|
|
|
fPlate(nullptr), |
|
|
|
fTexture(nullptr), |
|
|
|
fTexture(nullptr), |
|
|
|
fReader(nullptr), |
|
|
|
fReader(nullptr), |
|
|
|
fStartTime(0), |
|
|
|
fMovieTime(0), |
|
|
|
|
|
|
|
fLastFrameTime(0), |
|
|
|
fPosition(hsPoint2()), |
|
|
|
fPosition(hsPoint2()), |
|
|
|
fPlaying(false), |
|
|
|
fPlaying(false), |
|
|
|
|
|
|
|
fPaused(false), |
|
|
|
fOpusDecoder(nullptr) |
|
|
|
fOpusDecoder(nullptr) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fScale.Set(1.0f, 1.0f); |
|
|
|
fScale.Set(1.0f, 1.0f); |
|
|
@ -195,11 +197,6 @@ plMoviePlayer::~plMoviePlayer() |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int64_t plMoviePlayer::GetMovieTime() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return (int64_t)hsTimer::GetMilliSeconds() - fStartTime; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool plMoviePlayer::IOpenMovie() |
|
|
|
bool plMoviePlayer::IOpenMovie() |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef VIDEO_AVAILABLE |
|
|
|
#ifdef VIDEO_AVAILABLE |
|
|
@ -285,6 +282,7 @@ void plMoviePlayer::IProcessVideoFrame(const std::vector<blkbuf_t>& frames) |
|
|
|
// Flush new data to the device
|
|
|
|
// Flush new data to the device
|
|
|
|
if (fTexture->GetDeviceRef()) |
|
|
|
if (fTexture->GetDeviceRef()) |
|
|
|
fTexture->GetDeviceRef()->SetDirty(true); |
|
|
|
fTexture->GetDeviceRef()->SetDirty(true); |
|
|
|
|
|
|
|
fPlate->SetVisible(true); |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
@ -334,8 +332,7 @@ bool plMoviePlayer::Start() |
|
|
|
float height = (static_cast<float>(video->GetHeight()) / static_cast<float>(plateMgr.GetPipeHeight())) * fScale.fY; |
|
|
|
float height = (static_cast<float>(video->GetHeight()) / static_cast<float>(plateMgr.GetPipeHeight())) * fScale.fY; |
|
|
|
|
|
|
|
|
|
|
|
plateMgr.CreatePlate(&fPlate, fPosition.fX, fPosition.fY, width, height); |
|
|
|
plateMgr.CreatePlate(&fPlate, fPosition.fX, fPosition.fY, width, height); |
|
|
|
fPlate->SetVisible(true); |
|
|
|
fTexture = fPlate->CreateMaterial(static_cast<uint32_t>(video->GetWidth()), static_cast<uint32_t>(video->GetHeight()), false); |
|
|
|
fTexture = fPlate->CreateMaterial(static_cast<uint32_t>(video->GetWidth()), static_cast<uint32_t>(video->GetHeight()), nullptr); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//initialize opus
|
|
|
|
//initialize opus
|
|
|
|
const mkvparser::AudioTrack* audio = static_cast<const mkvparser::AudioTrack*>(fAudioTrack->GetTrack()); |
|
|
|
const mkvparser::AudioTrack* audio = static_cast<const mkvparser::AudioTrack*>(fAudioTrack->GetTrack()); |
|
|
@ -352,6 +349,7 @@ bool plMoviePlayer::Start() |
|
|
|
if (error != OPUS_OK) |
|
|
|
if (error != OPUS_OK) |
|
|
|
hsAssert(false, "Error occured initalizing opus"); |
|
|
|
hsAssert(false, "Error occured initalizing opus"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fLastFrameTime = static_cast<int64_t>(hsTimer::GetMilliSeconds()); |
|
|
|
fPlaying = true; |
|
|
|
fPlaying = true; |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -365,25 +363,28 @@ bool plMoviePlayer::NextFrame() |
|
|
|
if (!fPlaying) |
|
|
|
if (!fPlaying) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int64_t frameTime = static_cast<int64_t>(hsTimer::GetMilliSeconds()); |
|
|
|
|
|
|
|
int64_t frameTimeDelta = frameTime - fLastFrameTime; |
|
|
|
|
|
|
|
fLastFrameTime = frameTime; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fPaused) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
#ifdef VIDEO_AVAILABLE |
|
|
|
#ifdef VIDEO_AVAILABLE |
|
|
|
// Get our current timecode
|
|
|
|
// Get our current timecode
|
|
|
|
int64_t movieTime = 0; |
|
|
|
fMovieTime += frameTimeDelta; |
|
|
|
if (fStartTime == 0) |
|
|
|
|
|
|
|
fStartTime = static_cast<int64_t>(hsTimer::GetMilliSeconds()); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
movieTime = GetMovieTime(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<blkbuf_t> audio; |
|
|
|
std::vector<blkbuf_t> audio; |
|
|
|
std::vector<blkbuf_t> video; |
|
|
|
std::vector<blkbuf_t> video; |
|
|
|
uint8_t tracksWithData = 0; |
|
|
|
uint8_t tracksWithData = 0; |
|
|
|
if (fAudioTrack) |
|
|
|
if (fAudioTrack) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (fAudioTrack->GetFrames(fReader, movieTime, audio)) |
|
|
|
if (fAudioTrack->GetFrames(fReader, fMovieTime, audio)) |
|
|
|
tracksWithData++; |
|
|
|
tracksWithData++; |
|
|
|
} |
|
|
|
} |
|
|
|
if (fVideoTrack) |
|
|
|
if (fVideoTrack) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (fVideoTrack->GetFrames(fReader, movieTime, video)) |
|
|
|
if (fVideoTrack->GetFrames(fReader, fMovieTime, video)) |
|
|
|
tracksWithData++; |
|
|
|
tracksWithData++; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!tracksWithData) |
|
|
|
if (!tracksWithData) |
|
|
@ -402,11 +403,22 @@ bool plMoviePlayer::NextFrame() |
|
|
|
#endif // VIDEO_AVAILABLE
|
|
|
|
#endif // VIDEO_AVAILABLE
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool plMoviePlayer::Pause(bool on) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!fPlaying) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fPaused = on; |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool plMoviePlayer::Stop() |
|
|
|
bool plMoviePlayer::Stop() |
|
|
|
{ |
|
|
|
{ |
|
|
|
fPlaying = false; |
|
|
|
fPlaying = false; |
|
|
|
if (fAudioSound) |
|
|
|
if (fAudioSound) |
|
|
|
fAudioSound->Stop(); |
|
|
|
fAudioSound->Stop(); |
|
|
|
|
|
|
|
if (fPlate) |
|
|
|
|
|
|
|
fPlate->SetVisible(false); |
|
|
|
for (int i = 0; i < fCallbacks.size(); i++) |
|
|
|
for (int i = 0; i < fCallbacks.size(); i++) |
|
|
|
fCallbacks[i]->Send(); |
|
|
|
fCallbacks[i]->Send(); |
|
|
|
fCallbacks.clear(); |
|
|
|
fCallbacks.clear(); |
|
|
|