mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 11:19:10 +00:00
Choose tracks based on language, if possible
This commit is contained in:
@ -53,15 +53,16 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
# define WEBM_CODECID_OPUS "A_OPUS"
|
# define WEBM_CODECID_OPUS "A_OPUS"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "hsResMgr.h"
|
||||||
|
#include "hsTimer.h"
|
||||||
|
#include "plAudio/plWin32VideoSound.h"
|
||||||
#include "plGImage/plMipmap.h"
|
#include "plGImage/plMipmap.h"
|
||||||
#include "pnKeyedObject/plUoid.h"
|
#include "pnKeyedObject/plUoid.h"
|
||||||
#include "plPipeline/hsGDeviceRef.h"
|
#include "plPipeline/hsGDeviceRef.h"
|
||||||
#include "plPipeline/plPlates.h"
|
#include "plPipeline/plPlates.h"
|
||||||
#include "plPlanarImage.h"
|
#include "plResMgr/plLocalization.h"
|
||||||
#include "hsResMgr.h"
|
|
||||||
#include "hsTimer.h"
|
|
||||||
#include "plAudio/plWin32VideoSound.h"
|
|
||||||
|
|
||||||
|
#include "plPlanarImage.h"
|
||||||
#include "webm/mkvreader.hpp"
|
#include "webm/mkvreader.hpp"
|
||||||
#include "webm/mkvparser.hpp"
|
#include "webm/mkvparser.hpp"
|
||||||
|
|
||||||
@ -224,8 +225,7 @@ bool plMoviePlayer::IOpenMovie()
|
|||||||
SAFE_OP(seg->Load(), "load segment from webm");
|
SAFE_OP(seg->Load(), "load segment from webm");
|
||||||
fSegment.reset(seg);
|
fSegment.reset(seg);
|
||||||
|
|
||||||
// TODO: Figure out video and audio based on current language
|
// Use first tracks unless another one matches the current game language
|
||||||
// For now... just take the first one.
|
|
||||||
const mkvparser::Tracks* tracks = fSegment->GetTracks();
|
const mkvparser::Tracks* tracks = fSegment->GetTracks();
|
||||||
for (uint32_t i = 0; i < tracks->GetTracksCount(); ++i)
|
for (uint32_t i = 0; i < tracks->GetTracksCount(); ++i)
|
||||||
{
|
{
|
||||||
@ -237,13 +237,13 @@ bool plMoviePlayer::IOpenMovie()
|
|||||||
{
|
{
|
||||||
case mkvparser::Track::kAudio:
|
case mkvparser::Track::kAudio:
|
||||||
{
|
{
|
||||||
if (!fAudioTrack)
|
if (!fAudioTrack || ICheckLanguage(track))
|
||||||
fAudioTrack.reset(new TrackMgr(track));
|
fAudioTrack.reset(new TrackMgr(track));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case mkvparser::Track::kVideo:
|
case mkvparser::Track::kVideo:
|
||||||
{
|
{
|
||||||
if (!fVideoTrack)
|
if (!fVideoTrack || ICheckLanguage(track))
|
||||||
fVideoTrack.reset(new TrackMgr(track));
|
fVideoTrack.reset(new TrackMgr(track));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -255,6 +255,14 @@ bool plMoviePlayer::IOpenMovie()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool plMoviePlayer::ICheckLanguage(const mkvparser::Track* track)
|
||||||
|
{
|
||||||
|
auto codes = plLocalization::GetLanguageCodes(plLocalization::GetLanguage());
|
||||||
|
if (codes.find(track->GetLanguage()) != codes.end())
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void plMoviePlayer::IProcessVideoFrame(const std::vector<blkbuf_t>& frames)
|
void plMoviePlayer::IProcessVideoFrame(const std::vector<blkbuf_t>& frames)
|
||||||
{
|
{
|
||||||
#ifdef VIDEO_AVAILABLE
|
#ifdef VIDEO_AVAILABLE
|
||||||
|
@ -87,6 +87,7 @@ protected:
|
|||||||
bool fPaused;
|
bool fPaused;
|
||||||
|
|
||||||
bool IOpenMovie();
|
bool IOpenMovie();
|
||||||
|
bool ICheckLanguage(const mkvparser::Track* track);
|
||||||
void IProcessVideoFrame(const std::vector<blkbuf_t>& frames);
|
void IProcessVideoFrame(const std::vector<blkbuf_t>& frames);
|
||||||
void IProcessAudioFrame(const std::vector<blkbuf_t>& frames);
|
void IProcessAudioFrame(const std::vector<blkbuf_t>& frames);
|
||||||
|
|
||||||
|
@ -56,6 +56,17 @@ const char* plLocalization::fLangTags[] =
|
|||||||
};
|
};
|
||||||
const int kLangTagLen = 4;
|
const int kLangTagLen = 4;
|
||||||
|
|
||||||
|
// ISO 639, e.g. used in video tracks
|
||||||
|
std::set<plString> plLocalization::fLangCodes[] =
|
||||||
|
{
|
||||||
|
{"eng", "en"},
|
||||||
|
{"fre", "fra", "fr"},
|
||||||
|
{"ger", "deu", "de"},
|
||||||
|
{"spa", "es"},
|
||||||
|
{"ita", "it"},
|
||||||
|
{"jpn", "ja"}
|
||||||
|
};
|
||||||
|
|
||||||
const char* plLocalization::fLangNames[] =
|
const char* plLocalization::fLangNames[] =
|
||||||
{
|
{
|
||||||
"English", // kEnglish
|
"English", // kEnglish
|
||||||
|
@ -44,6 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <set>
|
||||||
#include "plFileSystem.h"
|
#include "plFileSystem.h"
|
||||||
|
|
||||||
class plLocalization
|
class plLocalization
|
||||||
@ -78,6 +79,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
static Language fLanguage;
|
static Language fLanguage;
|
||||||
static const char* fLangTags[kNumLanguages];
|
static const char* fLangTags[kNumLanguages];
|
||||||
|
static std::set<plString> fLangCodes[kNumLanguages];
|
||||||
static const char* fLangNames[kNumLanguages];
|
static const char* fLangNames[kNumLanguages];
|
||||||
static bool fUsesUnicode[kNumLanguages];
|
static bool fUsesUnicode[kNumLanguages];
|
||||||
static encodingTypes fUnicodeEncoding[kNumLanguages];
|
static encodingTypes fUnicodeEncoding[kNumLanguages];
|
||||||
@ -89,6 +91,7 @@ public:
|
|||||||
static Language GetLanguage() { return fLanguage; }
|
static Language GetLanguage() { return fLanguage; }
|
||||||
|
|
||||||
static const char* GetLanguageName(Language lang) { return fLangNames[lang]; }
|
static const char* GetLanguageName(Language lang) { return fLangNames[lang]; }
|
||||||
|
static std::set<plString> GetLanguageCodes(Language lang) { return fLangCodes[lang]; }
|
||||||
|
|
||||||
static bool UsingUnicode() { return fUsesUnicode[fLanguage]; }
|
static bool UsingUnicode() { return fUsesUnicode[fLanguage]; }
|
||||||
static encodingTypes UnicodeEncoding() { return fUnicodeEncoding[fLanguage]; }
|
static encodingTypes UnicodeEncoding() { return fUnicodeEncoding[fLanguage]; }
|
||||||
|
Reference in New Issue
Block a user