bool CNetworkServices::StartAirPlayServer() { #ifdef HAS_AIRPLAY if (!g_application.getNetwork().IsAvailable() || !CSettings::Get().GetBool("services.airplay")) return false; if (IsAirPlayServerRunning()) return true; if (!CAirPlayServer::StartServer(g_advancedSettings.m_airPlayPort, true)) return false; if (!CAirPlayServer::SetCredentials(CSettings::Get().GetBool("services.useairplaypassword"), CSettings::Get().GetString("services.airplaypassword"))) return false; #ifdef HAS_ZEROCONF std::vector<std::pair<std::string, std::string> > txt; CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface(); txt.push_back(make_pair("deviceid", iface != NULL ? iface->GetMacAddress() : "FF:FF:FF:FF:FF:F2")); txt.push_back(make_pair("features", "0x77")); txt.push_back(make_pair("model", "Xbmc,1")); txt.push_back(make_pair("srcvers", AIRPLAY_SERVER_VERSION_STR)); CZeroconf::GetInstance()->PublishService("servers.airplay", "_airplay._tcp", g_infoManager.GetLabel(SYSTEM_FRIENDLY_NAME), g_advancedSettings.m_airPlayPort, txt); #endif // HAS_ZEROCONF return true; #endif // HAS_AIRPLAY return false; }
void CAirPlayServer::Process() { CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface(); apw = APW_Method_Create( MicroStackChain, ILib_Pool, m_port, "LeoChenPlayer", iface ? iface->GetMacAddress().c_str() : "FF:FF:FF:FF:FF:F2", m_usePassword ? m_password.c_str():""); if (apw == NULL) { // ´´½¨Ê§°Ü ILibThreadPool_Destroy(ILib_Pool); return; } apw->Event_SetAVTransportURI = APW_Callback_SetAVTransportURI; apw->Event_GetAVProtocolInfo = APW_Callback_GetAVProtocolInfo; apw->Event_SetPlayMode = APW_Callback_SetPlayMode; apw->Event_Stop = APW_Callback_Stop; apw->Event_Play = APW_Callback_Play; apw->Event_Pause = APW_Callback_Pause; apw->Event_SeekTrack = APW_Callback_SeekTrack; apw->Event_SeekTrackPosition = APW_Callback_SeekTrackPosition; apw->Event_SeekMediaPosition = APW_Callback_SeekMediaPosition; apw->Event_Next = APW_Callback_Next; apw->Event_Previous = APW_Callback_Previous; apw->Event_SelectPreset = APW_Callback_SelectPreset; apw->Event_SetVolume = APW_Callback_SetVolume; apw->Event_SetMute = APW_Callback_SetMute; apw->Event_SetContrast = APW_Callback_SetContrast; apw->Event_SetBrightness = APW_Callback_SetBrightness; ILibStartChain(MicroStackChain); }
bool CAirTunesServer::StartServer(int port, bool nonlocal, bool usePassword, const std::string &password/*=""*/) { bool success = false; std::string pw = password; CNetworkInterface *net = g_application.getNetwork().GetFirstConnectedInterface(); StopServer(true); if (net) { m_macAddress = net->GetMacAddress(); StringUtils::Replace(m_macAddress, ":",""); while (m_macAddress.size() < 12) { m_macAddress = '0' + m_macAddress; } } else { m_macAddress = "000102030405"; } if (!usePassword) { pw.clear(); } ServerInstance = new CAirTunesServer(port, nonlocal); if (ServerInstance->Initialize(pw)) { success = true; std::string appName = StringUtils::Format("%s@%s", m_macAddress.c_str(), CSysInfo::GetDeviceName().c_str()); std::vector<std::pair<std::string, std::string> > txt; txt.push_back(std::make_pair("txtvers", "1")); txt.push_back(std::make_pair("cn", "0,1")); txt.push_back(std::make_pair("ch", "2")); txt.push_back(std::make_pair("ek", "1")); txt.push_back(std::make_pair("et", "0,1")); txt.push_back(std::make_pair("sv", "false")); txt.push_back(std::make_pair("tp", "UDP")); txt.push_back(std::make_pair("sm", "false")); txt.push_back(std::make_pair("ss", "16")); txt.push_back(std::make_pair("sr", "44100")); txt.push_back(std::make_pair("pw", usePassword?"true":"false")); txt.push_back(std::make_pair("vn", "3")); txt.push_back(std::make_pair("da", "true")); txt.push_back(std::make_pair("md", "0,1,2")); txt.push_back(std::make_pair("am", "Kodi,1")); txt.push_back(std::make_pair("vs", "130.14")); CZeroconf::GetInstance()->PublishService("servers.airtunes", "_raop._tcp", appName, port, txt); } return success; }
std::string CSysInfoJob::GetMACAddress() { #if defined(HAS_LINUX_NETWORK) CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface(); if (iface) return iface->GetMacAddress(); #endif return ""; }
std::string CSysInfoJob::GetMACAddress() { #if defined(HAS_LINUX_NETWORK) || defined(HAS_WIN32_NETWORK) || defined(HAS_WIN10_NETWORK) CNetworkInterface* iface = CServiceBroker::GetNetwork().GetFirstConnectedInterface(); if (iface) return iface->GetMacAddress(); #endif return ""; }
bool CAirTunesServer::StartServer(int port, bool nonlocal, bool usePassword, const CStdString &password/*=""*/) { bool success = false; CStdString pw = password; CNetworkInterface *net = g_application.getNetwork().GetFirstConnectedInterface(); StopServer(true); if (net) { m_macAddress = net->GetMacAddress(); m_macAddress.Replace(":",""); while (m_macAddress.size() < 12) { m_macAddress = CStdString("0") + m_macAddress; } } else { m_macAddress = "000102030405"; } if (!usePassword) { pw.Empty(); } ServerInstance = new CAirTunesServer(port, nonlocal); if (ServerInstance->Initialize(password)) { ServerInstance->Create(); success = true; } if (success) { CStdString appName; appName.Format("%s@XBMC", m_macAddress.c_str()); std::map<std::string, std::string> txt; txt["cn"] = "0,1"; txt["ch"] = "2"; txt["ek"] = "1"; txt["et"] = "0,1"; txt["sv"] = "false"; txt["tp"] = "UDP"; txt["sm"] = "false"; txt["ss"] = "16"; txt["sr"] = "44100"; txt["pw"] = "false"; txt["vn"] = "3"; txt["txtvers"] = "1"; CZeroconf::GetInstance()->PublishService("servers.airtunes", "_raop._tcp", appName, port, txt); } return success; }
bool CNetworkServices::StartAirPlayServer() { #ifdef HAS_AIRPLAY if (!g_application.getNetwork().IsAvailable() || !CSettings::GetInstance().GetBool(CSettings::SETTING_SERVICES_AIRPLAY)) return false; if (IsAirPlayServerRunning()) return true; if (!CAirPlayServer::StartServer(g_advancedSettings.m_airPlayPort, true)) return false; if (!CAirPlayServer::SetCredentials(CSettings::GetInstance().GetBool(CSettings::SETTING_SERVICES_USEAIRPLAYPASSWORD), CSettings::GetInstance().GetString(CSettings::SETTING_SERVICES_AIRPLAYPASSWORD))) return false; #ifdef HAS_ZEROCONF std::vector<std::pair<std::string, std::string> > txt; CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface(); txt.push_back(make_pair("deviceid", iface != NULL ? iface->GetMacAddress() : "FF:FF:FF:FF:FF:F2")); txt.push_back(make_pair("model", "Xbmc,1")); txt.push_back(make_pair("srcvers", AIRPLAY_SERVER_VERSION_STR)); if (CSettings::GetInstance().GetBool(CSettings::SETTING_SERVICES_AIRPLAYIOS8COMPAT)) { // for ios8 clients we need to announce mirroring support // else we won't get video urls anymore. // We also announce photo caching support (as it seems faster and // we have implemented it anyways). txt.push_back(make_pair("features", "0x20F7")); } else { txt.push_back(make_pair("features", "0x77")); } CZeroconf::GetInstance()->PublishService("servers.airplay", "_airplay._tcp", CSysInfo::GetDeviceName(), g_advancedSettings.m_airPlayPort, txt); #endif // HAS_ZEROCONF return true; #endif // HAS_AIRPLAY return false; }
bool CAirTunesServer::StartServer(int port, bool nonlocal, bool usePassword, const CStdString &password/*=""*/) { bool success = false; CStdString pw = password; CNetworkInterface *net = g_application.getNetwork().GetFirstConnectedInterface(); StopServer(true); if (net) { m_macAddress = net->GetMacAddress(); m_macAddress.Replace(":",""); while (m_macAddress.size() < 12) { m_macAddress = CStdString("0") + m_macAddress; } } else { m_macAddress = "000102030405"; } if (!usePassword) { pw.Empty(); } ServerInstance = new CAirTunesServer(port, nonlocal); if (ServerInstance->Initialize(pw)) { #if !defined(HAVE_LIBSHAIRPLAY) ServerInstance->Create(); #endif success = true; } if (success) { CStdString appName; appName.Format("%s@%s", m_macAddress.c_str(), g_infoManager.GetLabel(SYSTEM_FRIENDLY_NAME).c_str()); std::vector<std::pair<std::string, std::string> > txt; txt.push_back(std::make_pair("txtvers", "1")); txt.push_back(std::make_pair("cn", "0,1")); txt.push_back(std::make_pair("ch", "2")); txt.push_back(std::make_pair("ek", "1")); txt.push_back(std::make_pair("et", "0,1")); txt.push_back(std::make_pair("sv", "false")); txt.push_back(std::make_pair("tp", "UDP")); txt.push_back(std::make_pair("sm", "false")); txt.push_back(std::make_pair("ss", "16")); txt.push_back(std::make_pair("sr", "44100")); txt.push_back(std::make_pair("pw", usePassword?"true":"false")); txt.push_back(std::make_pair("vn", "3")); txt.push_back(std::make_pair("da", "true")); txt.push_back(std::make_pair("vs", "130.14")); txt.push_back(std::make_pair("md", "0,1,2")); txt.push_back(std::make_pair("am", "Xbmc,1")); CZeroconf::GetInstance()->PublishService("servers.airtunes", "_raop._tcp", appName, port, txt); } return success; }