Skip to content
Browse files

[droid] add a way to specify forbidden players based on playerfactory…

… rules

Use the "forbiddenplayers" attribute in a rule in playercorefactory.xml to
specify that a player should NOT be used for a specific rule. Multiple comma-
separated players can be specified. Forbidden rules trump all others.

Example:
.nsv is an audio file, but paplayer can't play it. So the current rule forces
it to dvdplayer instead. This is a problem when a third (default) player is
introduced that may handle .nsv with no problems. The solution then is to
forbid paplayer instead.
  • Loading branch information...
1 parent ff3a045 commit 981d40cc118cc40da42bc0b90fae6caee3e6a81f Cory Fields committed Jul 28, 2012
View
16 xbmc/cores/playercorefactory/PlayerCoreFactory.cpp
@@ -175,9 +175,10 @@ void CPlayerCoreFactory::GetPlayers( const CFileItem& item, VECPLAYERCORES &vecC
CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers(%s)", item.GetPath().c_str());
+ VECPLAYERCORES vecCoresDisabled;
// Process rules
for(unsigned int i = 0; i < s_vecCoreSelectionRules.size(); i++)
- s_vecCoreSelectionRules[i]->GetPlayers(item, vecCores);
+ s_vecCoreSelectionRules[i]->GetPlayers(item, vecCores, vecCoresDisabled);
CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: matched %"PRIuS" rules with players", vecCores.size());
@@ -252,6 +253,19 @@ void CPlayerCoreFactory::GetPlayers( const CFileItem& item, VECPLAYERCORES &vecC
/* make our list unique, preserving first added players */
unique(vecCores);
+ for(VECPLAYERCORES::iterator i = vecCoresDisabled.begin(); i != vecCoresDisabled.end(); i++)
+ {
+ for(VECPLAYERCORES::iterator j = vecCores.begin(); j != vecCores.end(); j++)
+ {
+ if (*i == *j)
+ {
+ CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: removing disabled player %s (%d)", GetPlayerName(*j).c_str(),*j);
+ vecCores.erase(j);
+ break;
+ }
+ }
+ }
+
CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: added %"PRIuS" players", vecCores.size());
}
View
17 xbmc/cores/playercorefactory/PlayerSelectionRule.cpp
@@ -73,6 +73,8 @@ void CPlayerSelectionRule::Initialize(TiXmlElement* pRule)
}
m_playerName = pRule->Attribute("player");
+ CStdString disabledPlayerNames = pRule->Attribute("forbiddenplayers");
+ StringUtils::SplitString(disabledPlayerNames, ",", m_disabledPlayerNames);
m_playerCoreId = 0;
TiXmlElement* pSubRule = pRule->FirstChildElement("rule");
@@ -103,7 +105,7 @@ bool CPlayerSelectionRule::MatchesRegExp(const CStdString& str, CRegExp& regExp)
return regExp.RegFind(str, 0) == 0;
}
-void CPlayerSelectionRule::GetPlayers(const CFileItem& item, VECPLAYERCORES &vecCores)
+void CPlayerSelectionRule::GetPlayers(const CFileItem& item, VECPLAYERCORES &vecCores, VECPLAYERCORES &vecCoresDisabled)
{
CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: considering rule: %s", m_name.c_str());
@@ -153,14 +155,25 @@ void CPlayerSelectionRule::GetPlayers(const CFileItem& item, VECPLAYERCORES &vec
CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: matches rule: %s", m_name.c_str());
for (unsigned int i = 0; i < vecSubRules.size(); i++)
- vecSubRules[i]->GetPlayers(item, vecCores);
+ vecSubRules[i]->GetPlayers(item, vecCores, vecCoresDisabled);
PLAYERCOREID playerCoreId = GetPlayerCore();
if (playerCoreId != EPC_NONE)
{
CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: adding player: %s (%d) for rule: %s", m_playerName.c_str(), playerCoreId, m_name.c_str());
vecCores.push_back(GetPlayerCore());
}
+
+ int playerCoreDisabledId = 0;
+ for(CStdStringArray::iterator i = m_disabledPlayerNames.begin(); i != m_disabledPlayerNames.end(); i++)
+ {
+ playerCoreDisabledId = CPlayerCoreFactory::GetPlayerCore(*i);
+ if (playerCoreDisabledId)
+ {
+ CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: disabling player: %s (%d) for rule: %s", i->c_str(), playerCoreDisabledId, m_name.c_str());
+ vecCoresDisabled.push_back(playerCoreDisabledId);
+ }
+ }
}
PLAYERCOREID CPlayerSelectionRule::GetPlayerCore()
View
4 xbmc/cores/playercorefactory/PlayerSelectionRule.h
@@ -22,6 +22,7 @@
#include "FileItem.h"
#include "PlayerCoreFactory.h"
+#include "utils/StringUtils.h"
class CRegExp;
class TiXmlElement;
@@ -34,7 +35,7 @@ class CPlayerSelectionRule
//bool Matches(const CFileItem& item) const;
//CStdString GetPlayerName() const;
- void GetPlayers(const CFileItem& item, VECPLAYERCORES &vecCores);
+ void GetPlayers(const CFileItem& item, VECPLAYERCORES &vecCores, VECPLAYERCORES &vecCoresDisabled);
private:
int GetTristate(const char* szValue) const;
@@ -67,6 +68,7 @@ class CPlayerSelectionRule
CStdString m_videoAspect;
CStdString m_playerName;
+ CStdStringArray m_disabledPlayerNames;
PLAYERCOREID m_playerCoreId;
std::vector<CPlayerSelectionRule *> vecSubRules;

0 comments on commit 981d40c

Please sign in to comment.
Something went wrong with that request. Please try again.