mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 11:19:10 +00:00
Do not play if we don't know the codec
This commit is contained in:
@ -48,6 +48,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
# include <vpx/vp8dx.h>
|
# include <vpx/vp8dx.h>
|
||||||
# define iface (vpx_codec_vp9_dx())
|
# define iface (vpx_codec_vp9_dx())
|
||||||
# include <opus.h>
|
# include <opus.h>
|
||||||
|
|
||||||
|
# define WEBM_CODECID_VP9 "V_VP9"
|
||||||
|
# define WEBM_CODECID_OPUS "A_OPUS"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "plGImage/plMipmap.h"
|
#include "plGImage/plMipmap.h"
|
||||||
@ -94,6 +97,7 @@ public:
|
|||||||
if(vpx_codec_dec_init(&instance->codec, iface, nullptr, 0))
|
if(vpx_codec_dec_init(&instance->codec, iface, nullptr, 0))
|
||||||
{
|
{
|
||||||
hsAssert(false, vpx_codec_error_detail(&instance->codec));
|
hsAssert(false, vpx_codec_error_detail(&instance->codec));
|
||||||
|
delete instance;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
@ -320,6 +324,12 @@ bool plMoviePlayer::Start()
|
|||||||
hsAssert(fVideoTrack, "nil video track -- expect bad things to happen!");
|
hsAssert(fVideoTrack, "nil video track -- expect bad things to happen!");
|
||||||
|
|
||||||
// Initialize VPX
|
// Initialize VPX
|
||||||
|
const mkvparser::VideoTrack* video = static_cast<const mkvparser::VideoTrack*>(fVideoTrack->GetTrack());
|
||||||
|
if (strcmp(video->GetCodecId(), WEBM_CODECID_VP9) != 0)
|
||||||
|
{
|
||||||
|
hsAssert(false, "Not a VP9 video track!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (VPX* vpx = VPX::Create())
|
if (VPX* vpx = VPX::Create())
|
||||||
fVpx.reset(vpx);
|
fVpx.reset(vpx);
|
||||||
else
|
else
|
||||||
@ -327,7 +337,6 @@ bool plMoviePlayer::Start()
|
|||||||
|
|
||||||
// Need to figure out scaling based on pipe size.
|
// Need to figure out scaling based on pipe size.
|
||||||
plPlateManager& plateMgr = plPlateManager::Instance();
|
plPlateManager& plateMgr = plPlateManager::Instance();
|
||||||
const mkvparser::VideoTrack* video = static_cast<const mkvparser::VideoTrack*>(fVideoTrack->GetTrack());
|
|
||||||
float plateWidth = video->GetWidth() * fScale.fX;
|
float plateWidth = video->GetWidth() * fScale.fX;
|
||||||
float plateHeight = video->GetHeight() * fScale.fY;
|
float plateHeight = video->GetHeight() * fScale.fY;
|
||||||
if (plateWidth > plateMgr.GetPipeWidth() || plateHeight > plateMgr.GetPipeHeight())
|
if (plateWidth > plateMgr.GetPipeWidth() || plateHeight > plateMgr.GetPipeHeight())
|
||||||
@ -340,7 +349,7 @@ bool plMoviePlayer::Start()
|
|||||||
plateMgr.SetPlatePixelSize(fPlate, plateWidth, plateHeight);
|
plateMgr.SetPlatePixelSize(fPlate, plateWidth, plateHeight);
|
||||||
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()), false);
|
||||||
|
|
||||||
//initialize opus
|
// Fetch audio track information
|
||||||
const mkvparser::AudioTrack* audio = static_cast<const mkvparser::AudioTrack*>(fAudioTrack->GetTrack());
|
const mkvparser::AudioTrack* audio = static_cast<const mkvparser::AudioTrack*>(fAudioTrack->GetTrack());
|
||||||
plWAVHeader header;
|
plWAVHeader header;
|
||||||
header.fFormatTag = plWAVHeader::kPCMFormatTag;
|
header.fFormatTag = plWAVHeader::kPCMFormatTag;
|
||||||
@ -350,6 +359,13 @@ bool plMoviePlayer::Start()
|
|||||||
header.fBlockAlign = header.fNumChannels * header.fBitsPerSample / 8;
|
header.fBlockAlign = header.fNumChannels * header.fBitsPerSample / 8;
|
||||||
header.fAvgBytesPerSec = header.fNumSamplesPerSec * header.fBlockAlign;
|
header.fAvgBytesPerSec = header.fNumSamplesPerSec * header.fBlockAlign;
|
||||||
fAudioSound.reset(new plWin32VideoSound(header));
|
fAudioSound.reset(new plWin32VideoSound(header));
|
||||||
|
|
||||||
|
// Initialize Opus
|
||||||
|
if (strcmp(audio->GetCodecId(), WEBM_CODECID_OPUS) != 0)
|
||||||
|
{
|
||||||
|
hsAssert(false, "Not an Opus audio track!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
int error;
|
int error;
|
||||||
fOpusDecoder = opus_decoder_create(48000, audio->GetChannels(), &error);
|
fOpusDecoder = opus_decoder_create(48000, audio->GetChannels(), &error);
|
||||||
if (error != OPUS_OK)
|
if (error != OPUS_OK)
|
||||||
|
Reference in New Issue
Block a user