Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rework enable Forced Track Selection based on preferred language set …

…for MPC-HC Engine by using LCID.
  • Loading branch information...
commit decc556f256ccc8d6b88c3f8d856825c0bb6c00d 1 parent 8425629
Sebastiii Sebastiii authored
24 DirectShowFilters/mpc-hc_subs/src/mpc-hc_subs/SubManager.cpp
View
@@ -328,7 +328,7 @@ static bool isTextConnection(IPin* pPin)
}
//load internal subtitles through TextPassThruFilter
-void CSubManager::LoadInternalSubtitles(IGraphBuilder* pGB, bool onlyShowForcedSubs)
+void CSubManager::LoadInternalSubtitles(IGraphBuilder* pGB, bool onlyShowForcedSubs, LCID lcidci)
{
BeginEnumFilters(pGB, pEF, pBF)
{
@@ -392,7 +392,7 @@ void CSubManager::LoadInternalSubtitles(IGraphBuilder* pGB, bool onlyShowForcedS
ApplyStyleSubStream(pSubStream);
if (m_pSS == 0 && ((m_pSS = pBF) != 0))
{
- InitInternalSubs(pBF);
+ InitInternalSubs(pBF, lcidci);
m_intSubStream = pSubStream;
}
else
@@ -420,7 +420,7 @@ void CSubManager::LoadInternalSubtitles(IGraphBuilder* pGB, bool onlyShowForcedS
EndEnumFilters
}
-void CSubManager::InitInternalSubs(IBaseFilter* pBF)
+void CSubManager::InitInternalSubs(IBaseFilter* pBF, LCID lcidci)
{
if(!m_pSS) return;
DWORD cStreams = 0;
@@ -439,7 +439,7 @@ void CSubManager::InitInternalSubs(IBaseFilter* pBF)
if(dwGroup == 2)
{
- CString lang, track(pszName);
+ CString lang, langForced, track(pszName);
if (lcid == 0)
{
lang = pszName;
@@ -463,8 +463,16 @@ void CSubManager::InitInternalSubs(IBaseFilter* pBF)
memset(&trackElement, 0, sizeof(trackElement));
pTrackInfo->GetTrackInfo(i, &trackElement);
if (trackElement.FlagForced) {
- m_forcedSubIndex = m_intSubs.GetCount() - 1;;
- ATLTRACE("subtitle track %d is forced", i);
+ langForced = pszName;
+ if (m_forcedSubIndex <= -1 && langForced.Find(L"Forced Subtitles (auto)") >= 0)
+ {
+ m_forcedSubIndex = m_intSubs.GetCount() - 1;
+ }
+ else if (lcid == lcidci && langForced.Find(L"Forced Subtitles (auto)") <= 0)
+ {
+ m_forcedSubIndex = m_intSubs.GetCount() - 1;
+ ATLTRACE("subtitle track %d is forced", i);
+ }
}
}
}
@@ -591,7 +599,7 @@ void CSubManager::SaveToDisk()
}
}
-void CSubManager::LoadSubtitlesForFile(const wchar_t* fn, IGraphBuilder* pGB, const wchar_t* paths)
+void CSubManager::LoadSubtitlesForFile(const wchar_t* fn, IGraphBuilder* pGB, const wchar_t* paths, LCID lcidci)
{
{//hook vmr
CComPtr<IBaseFilter> vmr;
@@ -626,7 +634,7 @@ void CSubManager::LoadSubtitlesForFile(const wchar_t* fn, IGraphBuilder* pGB, co
HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
}
bool onlyShowForcedSubs = g_onlyShowForcedSubs ? true : false;
- LoadInternalSubtitles(pGB, onlyShowForcedSubs);
+ LoadInternalSubtitles(pGB, onlyShowForcedSubs, lcidci);
LoadExternalSubtitles(fn, paths, onlyShowForcedSubs);
if(GetCount() > 0)
{
6 DirectShowFilters/mpc-hc_subs/src/mpc-hc_subs/SubManager.h
View
@@ -17,7 +17,7 @@ class CSubManager
CSubManager(IDirect3DDevice9* d3DDev, SIZE size, HRESULT& hr);
~CSubManager(void);
- void LoadSubtitlesForFile(const wchar_t* fn, IGraphBuilder* pGB, const wchar_t* paths);
+ void LoadSubtitlesForFile(const wchar_t* fn, IGraphBuilder* pGB, const wchar_t* paths, LCID lcidci);
int GetCount();
BSTR GetLanguage(int i);
@@ -41,7 +41,7 @@ class CSubManager
void InvalidateSubtitle(ISubStream* pSubStream, REFERENCE_TIME rtInvalidate);
//load internal subtitles through TextPassThruFilter
- void LoadInternalSubtitles(IGraphBuilder* pGB, bool onlyShowForcedSubs);
+ void LoadInternalSubtitles(IGraphBuilder* pGB, bool onlyShowForcedSubs, LCID lcidci);
void LoadExternalSubtitles(const wchar_t* fn, const wchar_t* paths, bool onlyShowForcedSubs);
void UpdateSubtitle();
@@ -49,7 +49,7 @@ class CSubManager
void ApplyStyleSubStream(ISubStream* pSubStream);
void SetSubPicProvider(ISubStream* pSubStream);
- void InitInternalSubs(IBaseFilter* pBF);
+ void InitInternalSubs(IBaseFilter* pBF, LCID lcidci);
bool SelectStream(int i);
int GetExtCount();
BSTR GetLanguageHelper(int i, bool useTrackName);
4 DirectShowFilters/mpc-hc_subs/src/mpc-hc_subs/mpcSubs.cpp
View
@@ -38,7 +38,7 @@ void SetShowForcedOnly(BOOL onlyShowForcedSubs)
}
-BOOL LoadSubtitles(IDirect3DDevice9* d3DDev, SIZE size, const wchar_t* fn, IGraphBuilder* pGB, const wchar_t* paths)
+BOOL LoadSubtitles(IDirect3DDevice9* d3DDev, SIZE size, const wchar_t* fn, IGraphBuilder* pGB, const wchar_t* paths, LCID lcidci)
{
g_subManager.Free();
HRESULT hr = S_OK;
@@ -47,7 +47,7 @@ BOOL LoadSubtitles(IDirect3DDevice9* d3DDev, SIZE size, const wchar_t* fn, IGrap
{
return FALSE;
}
- subManager->LoadSubtitlesForFile(fn, pGB, paths);
+ subManager->LoadSubtitlesForFile(fn, pGB, paths, lcidci);
g_subManager.Attach(subManager.Detach());
return TRUE;
}
2  DirectShowFilters/mpc-hc_subs/src/mpc-hc_subs/mpcSubs.h
View
@@ -32,7 +32,7 @@ MPCSUBS_API void SetAdvancedOptions(int subPicsBufferAhead, SIZE textureSize, BO
MPCSUBS_API void SetShowForcedOnly(BOOL onlyShowForcedSubs);
//load subtitles for video file fn, with given (rendered) graph
-MPCSUBS_API BOOL LoadSubtitles(IDirect3DDevice9* d3DDev, SIZE size, const wchar_t* fn, IGraphBuilder* pGB, const wchar_t* paths);
+MPCSUBS_API BOOL LoadSubtitles(IDirect3DDevice9* d3DDev, SIZE size, const wchar_t* fn, IGraphBuilder* pGB, const wchar_t* paths, LCID lcidci);
//set sample time (set from EVR presenter, not used in case of vmr9)
MPCSUBS_API void SetTime(REFERENCE_TIME nsSampleTime);
43 mediaportal/Core/Player/Subtitles/MpcEngine.cs
View
@@ -20,6 +20,7 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Text;
using System.Drawing;
using System.Runtime.InteropServices;
@@ -124,9 +125,47 @@ public bool LoadSubtitles(IGraphBuilder graphBuilder, string filename)
Size size = new Size(GUIGraphicsContext.Width, GUIGraphicsContext.Height);
+ // Get Default Language from MP Setting and parse it to MPC-HC Engine (needed for forced track)
+ string defaultLanguageCulture = "EN";
+ string localizedCINameSub = "EN";
+ int lcidCI = 0;
+
+ using (Settings xmlreader = new MPSettings())
+ {
+ try
+ {
+ if (g_Player.IsVideo && (g_Player.CurrentFile.ToUpperInvariant().Contains(@"\BDMV\INDEX.BDMV")))
+ {
+ localizedCINameSub = (xmlreader.GetValueAsString("bdplayer", "subtitlelanguage", "English"));
+ foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.NeutralCultures))
+ {
+ if (ci.EnglishName == localizedCINameSub)
+ {
+ lcidCI = ci.TextInfo.LCID;;
+ }
+ }
+ Log.Info("MpcEngine: Subtitle Blu-ray Player CultureInfo {0}", localizedCINameSub);
+ }
+ else
+ {
+ CultureInfo ci = new CultureInfo(xmlreader.GetValueAsString("subtitles", "language", defaultLanguageCulture));
+ lcidCI = ci.TextInfo.LCID;
+ Log.Info("MpcEngine: Subtitle VideoPlayer CultureInfo {0}", ci);
+ }
+ }
+ catch (Exception ex)
+ {
+ CultureInfo ci = new CultureInfo(defaultLanguageCulture);
+ lcidCI = ci.TextInfo.LCID;
+ Log.Error(
+ "MpcEngine: SelectSubtitleLanguage - unable to build CultureInfo, make sure MediaPortal.xml is not corrupted! - {0}",
+ ex);
+ }
+ }
+
return MpcSubtitles.LoadSubtitles(
DirectShowUtil.GetUnmanagedDevice(GUIGraphicsContext.DX9Device),
- size, filename, graphBuilder, subPaths);
+ size, filename, graphBuilder, subPaths, lcidCI);
}
public void FreeSubtitles()
@@ -230,7 +269,7 @@ private class MpcSubtitles
//load subtitles for video file filename, with given (rendered) graph
[DllImport("mpcSubs.dll", ExactSpelling = true, CharSet = CharSet.Unicode)]
public static extern bool LoadSubtitles(IntPtr d3DDev, Size size, string filename, IGraphBuilder graphBuilder,
- string paths);
+ string paths, int lcidCI);
//set sample time (set from EVR presenter, not used in case of vmr9)
[DllImport("mpcSubs.dll", ExactSpelling = true)]
Please sign in to comment.
Something went wrong with that request. Please try again.