1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037
|
/*
* Copyright (C) 2012-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "PVRGUIInfo.h"
#include "FileItem.h"
#include "GUIInfoManager.h"
#include "ServiceBroker.h"
#include "application/Application.h"
#include "application/ApplicationComponents.h"
#include "application/ApplicationPlayer.h"
#include "guilib/GUIComponent.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/LocalizeStrings.h"
#include "guilib/guiinfo/GUIInfo.h"
#include "guilib/guiinfo/GUIInfoLabels.h"
#include "pvr/PVRItem.h"
#include "pvr/PVRManager.h"
#include "pvr/PVRPlaybackState.h"
#include "pvr/addons/PVRClient.h"
#include "pvr/addons/PVRClients.h"
#include "pvr/channels/PVRChannel.h"
#include "pvr/channels/PVRChannelGroup.h"
#include "pvr/channels/PVRChannelGroupMember.h"
#include "pvr/channels/PVRChannelGroupsContainer.h"
#include "pvr/channels/PVRRadioRDSInfoTag.h"
#include "pvr/epg/EpgContainer.h"
#include "pvr/epg/EpgInfoTag.h"
#include "pvr/epg/EpgSearchFilter.h"
#include "pvr/guilib/PVRGUIActionsChannels.h"
#include "pvr/providers/PVRProvider.h"
#include "pvr/providers/PVRProviders.h"
#include "pvr/recordings/PVRRecording.h"
#include "pvr/recordings/PVRRecordings.h"
#include "pvr/timers/PVRTimerInfoTag.h"
#include "pvr/timers/PVRTimers.h"
#include "settings/AdvancedSettings.h"
#include "settings/Settings.h"
#include "settings/SettingsComponent.h"
#include "threads/SingleLock.h"
#include "threads/SystemClock.h"
#include "utils/StringUtils.h"
#include <cmath>
#include <ctime>
#include <memory>
#include <mutex>
#include <string>
#include <vector>
using namespace PVR;
using namespace KODI::GUILIB::GUIINFO;
using namespace std::chrono_literals;
CPVRGUIInfo::CPVRGUIInfo() : CThread("PVRGUIInfo")
{
ResetProperties();
}
void CPVRGUIInfo::ResetProperties()
{
std::unique_lock<CCriticalSection> lock(m_critSection);
m_anyTimersInfo.ResetProperties();
m_tvTimersInfo.ResetProperties();
m_radioTimersInfo.ResetProperties();
m_timesInfo.Reset();
m_bHasTVRecordings = false;
m_bHasRadioRecordings = false;
m_iCurrentActiveClient = 0;
m_strPlayingClientName.clear();
m_strBackendName.clear();
m_strBackendVersion.clear();
m_strBackendHost.clear();
m_strBackendTimers.clear();
m_strBackendRecordings.clear();
m_strBackendDeletedRecordings.clear();
m_strBackendProviders.clear();
m_strBackendChannelGroups.clear();
m_strBackendChannels.clear();
m_iBackendDiskTotal = 0;
m_iBackendDiskUsed = 0;
m_bIsPlayingTV = false;
m_bIsPlayingRadio = false;
m_bIsPlayingRecording = false;
m_bIsPlayingEpgTag = false;
m_bIsPlayingEncryptedStream = false;
m_bIsRecordingPlayingChannel = false;
m_bCanRecordPlayingChannel = false;
m_bIsPlayingActiveRecording = false;
m_bHasTVChannels = false;
m_bHasRadioChannels = false;
ClearQualityInfo(m_qualityInfo);
ClearDescrambleInfo(m_descrambleInfo);
m_updateBackendCacheRequested = false;
m_bRegistered = false;
}
void CPVRGUIInfo::ClearQualityInfo(PVR_SIGNAL_STATUS& qualityInfo)
{
memset(&qualityInfo, 0, sizeof(qualityInfo));
strncpy(qualityInfo.strAdapterName, g_localizeStrings.Get(13106).c_str(),
PVR_ADDON_NAME_STRING_LENGTH - 1);
strncpy(qualityInfo.strAdapterStatus, g_localizeStrings.Get(13106).c_str(),
PVR_ADDON_NAME_STRING_LENGTH - 1);
}
void CPVRGUIInfo::ClearDescrambleInfo(PVR_DESCRAMBLE_INFO& descrambleInfo)
{
descrambleInfo = {};
}
void CPVRGUIInfo::Start()
{
ResetProperties();
Create();
SetPriority(ThreadPriority::BELOW_NORMAL);
}
void CPVRGUIInfo::Stop()
{
StopThread();
auto& mgr = CServiceBroker::GetPVRManager();
auto& channels = mgr.Get<PVR::GUI::Channels>();
channels.GetChannelNavigator().Unsubscribe(this);
channels.Events().Unsubscribe(this);
mgr.Events().Unsubscribe(this);
CGUIComponent* gui = CServiceBroker::GetGUI();
if (gui)
{
gui->GetInfoManager().UnregisterInfoProvider(this);
m_bRegistered = false;
}
}
void CPVRGUIInfo::Notify(const PVREvent& event)
{
if (event == PVREvent::Timers || event == PVREvent::TimersInvalidated)
UpdateTimersCache();
}
void CPVRGUIInfo::Notify(const PVRChannelNumberInputChangedEvent& event)
{
std::unique_lock<CCriticalSection> lock(m_critSection);
m_channelNumberInput = event.m_input;
}
void CPVRGUIInfo::Notify(const PVRPreviewAndPlayerShowInfoChangedEvent& event)
{
std::unique_lock<CCriticalSection> lock(m_critSection);
m_previewAndPlayerShowInfo = event.m_previewAndPlayerShowInfo;
}
void CPVRGUIInfo::Process()
{
auto toggleIntervalMs = std::chrono::milliseconds(
CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_iPVRInfoToggleInterval);
XbmcThreads::EndTime<> cacheTimer(toggleIntervalMs);
auto& mgr = CServiceBroker::GetPVRManager();
mgr.Events().Subscribe(this, &CPVRGUIInfo::Notify);
auto& channels = mgr.Get<PVR::GUI::Channels>();
channels.Events().Subscribe(this, &CPVRGUIInfo::Notify);
channels.GetChannelNavigator().Subscribe(this, &CPVRGUIInfo::Notify);
/* updated on request */
UpdateTimersCache();
/* update the backend cache once initially */
m_updateBackendCacheRequested = true;
while (!g_application.m_bStop && !m_bStop)
{
if (!m_bRegistered)
{
CGUIComponent* gui = CServiceBroker::GetGUI();
if (gui)
{
gui->GetInfoManager().RegisterInfoProvider(this);
m_bRegistered = true;
}
}
if (!m_bStop)
UpdateQualityData();
std::this_thread::yield();
if (!m_bStop)
UpdateDescrambleData();
std::this_thread::yield();
if (!m_bStop)
UpdateMisc();
std::this_thread::yield();
if (!m_bStop)
UpdateTimeshiftData();
std::this_thread::yield();
if (!m_bStop)
UpdateTimersToggle();
std::this_thread::yield();
if (!m_bStop)
UpdateNextTimer();
std::this_thread::yield();
// Update the backend cache every toggleInterval seconds
if (!m_bStop && cacheTimer.IsTimePast())
{
UpdateBackendCache();
cacheTimer.Set(toggleIntervalMs);
}
if (!m_bStop)
CThread::Sleep(500ms);
}
}
void CPVRGUIInfo::UpdateQualityData()
{
if (!CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(
CSettings::SETTING_PVRPLAYBACK_SIGNALQUALITY))
return;
const std::shared_ptr<const CPVRPlaybackState> playbackState =
CServiceBroker::GetPVRManager().PlaybackState();
if (!playbackState)
return;
PVR_SIGNAL_STATUS qualityInfo;
ClearQualityInfo(qualityInfo);
const int channelUid = playbackState->GetPlayingChannelUniqueID();
if (channelUid > 0)
{
const std::shared_ptr<const CPVRClient> client =
CServiceBroker::GetPVRManager().Clients()->GetCreatedClient(
playbackState->GetPlayingClientID());
if (client)
client->SignalQuality(channelUid, qualityInfo);
}
std::unique_lock<CCriticalSection> lock(m_critSection);
m_qualityInfo = qualityInfo;
}
void CPVRGUIInfo::UpdateDescrambleData()
{
const std::shared_ptr<const CPVRPlaybackState> playbackState =
CServiceBroker::GetPVRManager().PlaybackState();
if (!playbackState)
return;
PVR_DESCRAMBLE_INFO descrambleInfo;
ClearDescrambleInfo(descrambleInfo);
const int channelUid = playbackState->GetPlayingChannelUniqueID();
if (channelUid > 0)
{
const std::shared_ptr<const CPVRClient> client =
CServiceBroker::GetPVRManager().Clients()->GetCreatedClient(
playbackState->GetPlayingClientID());
if (client)
client->GetDescrambleInfo(channelUid, descrambleInfo);
}
std::unique_lock<CCriticalSection> lock(m_critSection);
m_descrambleInfo = descrambleInfo;
}
void CPVRGUIInfo::UpdateMisc()
{
const CPVRManager& mgr = CServiceBroker::GetPVRManager();
bool bStarted = mgr.IsStarted();
const std::shared_ptr<const CPVRPlaybackState> state = mgr.PlaybackState();
/* safe to fetch these unlocked, since they're updated from the same thread as this one */
const std::string strPlayingClientName = bStarted ? state->GetPlayingClientName() : "";
const bool bHasTVRecordings = bStarted && mgr.Recordings()->GetNumTVRecordings() > 0;
const bool bHasRadioRecordings = bStarted && mgr.Recordings()->GetNumRadioRecordings() > 0;
const bool bIsPlayingTV = bStarted && state->IsPlayingTV();
const bool bIsPlayingRadio = bStarted && state->IsPlayingRadio();
const bool bIsPlayingRecording = bStarted && state->IsPlayingRecording();
const bool bIsPlayingEpgTag = bStarted && state->IsPlayingEpgTag();
const bool bIsPlayingEncryptedStream = bStarted && state->IsPlayingEncryptedChannel();
const bool bHasTVChannels = bStarted && mgr.ChannelGroups()->GetGroupAllTV()->HasChannels();
const bool bHasRadioChannels = bStarted && mgr.ChannelGroups()->GetGroupAllRadio()->HasChannels();
const bool bCanRecordPlayingChannel = bStarted && state->CanRecordOnPlayingChannel();
const bool bIsRecordingPlayingChannel = bStarted && state->IsRecordingOnPlayingChannel();
const bool bIsPlayingActiveRecording = bStarted && state->IsPlayingActiveRecording();
const std::string strPlayingTVGroup =
(bStarted && bIsPlayingTV) ? state->GetActiveChannelGroup(false)->GroupName() : "";
const std::string strPlayingRadioGroup =
(bStarted && bIsPlayingRadio) ? state->GetActiveChannelGroup(true)->GroupName() : "";
std::unique_lock<CCriticalSection> lock(m_critSection);
m_strPlayingClientName = strPlayingClientName;
m_bHasTVRecordings = bHasTVRecordings;
m_bHasRadioRecordings = bHasRadioRecordings;
m_bIsPlayingTV = bIsPlayingTV;
m_bIsPlayingRadio = bIsPlayingRadio;
m_bIsPlayingRecording = bIsPlayingRecording;
m_bIsPlayingEpgTag = bIsPlayingEpgTag;
m_bIsPlayingEncryptedStream = bIsPlayingEncryptedStream;
m_bHasTVChannels = bHasTVChannels;
m_bHasRadioChannels = bHasRadioChannels;
m_strPlayingTVGroup = strPlayingTVGroup;
m_strPlayingRadioGroup = strPlayingRadioGroup;
m_bCanRecordPlayingChannel = bCanRecordPlayingChannel;
m_bIsRecordingPlayingChannel = bIsRecordingPlayingChannel;
m_bIsPlayingActiveRecording = bIsPlayingActiveRecording;
}
void CPVRGUIInfo::UpdateTimeshiftData()
{
m_timesInfo.Update();
}
bool CPVRGUIInfo::InitCurrentItem(CFileItem* item)
{
CServiceBroker::GetPVRManager().PublishEvent(PVREvent::CurrentItem);
return false;
}
bool CPVRGUIInfo::GetLabel(std::string& value,
const CFileItem* item,
int contextWindow,
const CGUIInfo& info,
std::string* fallback) const
{
return GetListItemAndPlayerLabel(item, info, value) || GetPVRLabel(item, info, value) ||
GetRadioRDSLabel(item, info, value);
}
namespace
{
std::string GetAsLocalizedDateString(const CDateTime& datetime, bool bLongDate)
{
return datetime.IsValid() ? datetime.GetAsLocalizedDate(bLongDate) : "";
}
std::string GetAsLocalizedTimeString(const CDateTime& datetime)
{
return datetime.IsValid() ? datetime.GetAsLocalizedTime("", false) : "";
}
std::string GetAsLocalizedDateTimeString(const CDateTime& datetime)
{
return datetime.IsValid() ? datetime.GetAsLocalizedDateTime(false, false) : "";
}
std::string GetEpgTagTitle(const std::shared_ptr<const CPVREpgInfoTag>& epgTag)
{
if (epgTag)
{
if (CServiceBroker::GetPVRManager().IsParentalLocked(epgTag))
return g_localizeStrings.Get(19266); // Parental locked
else if (!epgTag->Title().empty())
return epgTag->Title();
}
if (!CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(
CSettings::SETTING_EPG_HIDENOINFOAVAILABLE))
return g_localizeStrings.Get(19055); // no information available
return {};
}
} // unnamed namespace
bool CPVRGUIInfo::GetListItemAndPlayerLabel(const CFileItem* item,
const CGUIInfo& info,
std::string& strValue) const
{
const std::shared_ptr<const CPVRTimerInfoTag> timer = item->GetPVRTimerInfoTag();
if (timer)
{
switch (info.m_info)
{
case LISTITEM_DATE:
strValue = timer->Summary();
return true;
case LISTITEM_STARTDATE:
strValue = GetAsLocalizedDateString(timer->StartAsLocalTime(), true);
return true;
case LISTITEM_STARTTIME:
strValue = GetAsLocalizedTimeString(timer->StartAsLocalTime());
return true;
case LISTITEM_ENDDATE:
strValue = GetAsLocalizedDateString(timer->EndAsLocalTime(), true);
return true;
case LISTITEM_ENDTIME:
strValue = GetAsLocalizedTimeString(timer->EndAsLocalTime());
return true;
case LISTITEM_DURATION:
if (timer->GetDuration() > 0)
{
strValue = StringUtils::SecondsToTimeString(timer->GetDuration(),
static_cast<TIME_FORMAT>(info.GetData4()));
return true;
}
return false;
case LISTITEM_TITLE:
strValue = timer->Title();
return true;
case LISTITEM_COMMENT:
strValue =
timer->GetStatus(CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindow() ==
WINDOW_RADIO_TIMER_RULES);
return true;
case LISTITEM_TIMERTYPE:
strValue = timer->GetTypeAsString();
return true;
case LISTITEM_CHANNEL_NAME:
strValue = timer->ChannelName();
return true;
case LISTITEM_EPG_EVENT_TITLE:
case LISTITEM_EPG_EVENT_ICON:
case LISTITEM_GENRE:
case LISTITEM_PLOT:
case LISTITEM_PLOT_OUTLINE:
case LISTITEM_ORIGINALTITLE:
case LISTITEM_YEAR:
case LISTITEM_SEASON:
case LISTITEM_EPISODE:
case LISTITEM_EPISODENAME:
case LISTITEM_DIRECTOR:
case LISTITEM_CHANNEL_NUMBER:
case LISTITEM_PREMIERED:
break; // obtain value from channel/epg
default:
return false;
}
}
const std::shared_ptr<const CPVRRecording> recording(item->GetPVRRecordingInfoTag());
if (recording)
{
// Note: CPVRRecoding is derived from CVideoInfoTag. All base class properties will be handled
// by CVideoGUIInfoProvider. Only properties introduced by CPVRRecording need to be handled here.
switch (info.m_info)
{
case LISTITEM_DATE:
strValue = GetAsLocalizedDateTimeString(recording->RecordingTimeAsLocalTime());
return true;
case LISTITEM_STARTDATE:
strValue = GetAsLocalizedDateString(recording->RecordingTimeAsLocalTime(), true);
return true;
case VIDEOPLAYER_STARTTIME:
case LISTITEM_STARTTIME:
strValue = GetAsLocalizedTimeString(recording->RecordingTimeAsLocalTime());
return true;
case LISTITEM_ENDDATE:
strValue = GetAsLocalizedDateString(recording->EndTimeAsLocalTime(), true);
return true;
case VIDEOPLAYER_ENDTIME:
case LISTITEM_ENDTIME:
strValue = GetAsLocalizedTimeString(recording->EndTimeAsLocalTime());
return true;
case LISTITEM_EXPIRATION_DATE:
if (recording->HasExpirationTime())
{
strValue = GetAsLocalizedDateString(recording->ExpirationTimeAsLocalTime(), false);
return true;
}
break;
case LISTITEM_EXPIRATION_TIME:
if (recording->HasExpirationTime())
{
strValue = GetAsLocalizedTimeString(recording->ExpirationTimeAsLocalTime());
;
return true;
}
break;
case VIDEOPLAYER_EPISODENAME:
case LISTITEM_EPISODENAME:
strValue = recording->EpisodeName();
// fixup multiline episode name strings (which do not fit in any way in our GUI)
StringUtils::Replace(strValue, "\n", ", ");
return true;
case VIDEOPLAYER_CHANNEL_NAME:
case LISTITEM_CHANNEL_NAME:
strValue = recording->ChannelName();
if (strValue.empty())
{
if (recording->ProviderName().empty())
{
const auto& provider = recording->GetProvider();
strValue = provider->GetName();
}
else
{
strValue = recording->ProviderName();
}
}
return true;
case VIDEOPLAYER_CHANNEL_NUMBER:
case LISTITEM_CHANNEL_NUMBER:
{
const std::shared_ptr<const CPVRChannelGroupMember> groupMember =
CServiceBroker::GetPVRManager().Get<PVR::GUI::Channels>().GetChannelGroupMember(*item);
if (groupMember)
{
strValue = groupMember->ChannelNumber().FormattedChannelNumber();
return true;
}
break;
}
case LISTITEM_ICON:
if (recording->ClientIconPath().empty() && recording->ClientThumbnailPath().empty() &&
// Only use a fallback if there is more than a single provider available
// Note: an add-on itself is a provider, hence we don't use > 0
CServiceBroker::GetPVRManager().Providers()->GetNumProviders() > 1 &&
!recording->Channel())
{
auto provider = recording->GetProvider();
if (!provider->GetIconPath().empty())
{
strValue = provider->GetIconPath();
return true;
}
}
return false;
case VIDEOPLAYER_CHANNEL_GROUP:
{
std::unique_lock<CCriticalSection> lock(m_critSection);
strValue = recording->IsRadio() ? m_strPlayingRadioGroup : m_strPlayingTVGroup;
return true;
}
case VIDEOPLAYER_PREMIERED:
case LISTITEM_PREMIERED:
if (recording->FirstAired().IsValid())
{
strValue = recording->FirstAired().GetAsLocalizedDate();
return true;
}
else if (recording->HasYear())
{
strValue = std::to_string(recording->GetYear());
return true;
}
return false;
case LISTITEM_SIZE:
if (recording->GetSizeInBytes() > 0)
{
strValue = StringUtils::SizeToString(recording->GetSizeInBytes());
return true;
}
return false;
}
return false;
}
const std::shared_ptr<const CPVREpgSearchFilter> filter = item->GetEPGSearchFilter();
if (filter)
{
switch (info.m_info)
{
case LISTITEM_DATE:
{
CDateTime lastExecLocal = filter->GetLastExecutedDateTime();
strValue = GetAsLocalizedDateTimeString(lastExecLocal);
if (strValue.empty())
strValue = g_localizeStrings.Get(10006); // "N/A"
return true;
}
}
return false;
}
std::shared_ptr<const CPVREpgInfoTag> epgTag;
std::shared_ptr<const CPVRChannel> channel;
if (item->IsPVRChannel() || item->IsEPG() || item->IsPVRTimer())
{
CPVRItem pvrItem(item);
channel = pvrItem.GetChannel();
switch (info.m_info)
{
case VIDEOPLAYER_NEXT_TITLE:
case VIDEOPLAYER_NEXT_GENRE:
case VIDEOPLAYER_NEXT_PLOT:
case VIDEOPLAYER_NEXT_PLOT_OUTLINE:
case VIDEOPLAYER_NEXT_STARTTIME:
case VIDEOPLAYER_NEXT_ENDTIME:
case VIDEOPLAYER_NEXT_DURATION:
case LISTITEM_NEXT_TITLE:
case LISTITEM_NEXT_GENRE:
case LISTITEM_NEXT_PLOT:
case LISTITEM_NEXT_PLOT_OUTLINE:
case LISTITEM_NEXT_STARTDATE:
case LISTITEM_NEXT_STARTTIME:
case LISTITEM_NEXT_ENDDATE:
case LISTITEM_NEXT_ENDTIME:
case LISTITEM_NEXT_DURATION:
// next playing event
epgTag = pvrItem.GetNextEpgInfoTag();
break;
default:
// now playing event
epgTag = pvrItem.GetEpgInfoTag();
break;
}
switch (info.m_info)
{
// special handling for channels without epg or with radio rds data
case PLAYER_TITLE:
case LISTITEM_TITLE:
case VIDEOPLAYER_NEXT_TITLE:
case LISTITEM_NEXT_TITLE:
case LISTITEM_EPG_EVENT_TITLE:
// Note: in difference to LISTITEM_TITLE, LISTITEM_EPG_EVENT_TITLE returns the title
// associated with the epg event of a timer, if any, and not the title of the timer.
strValue = GetEpgTagTitle(epgTag);
return true;
}
}
if (epgTag)
{
switch (info.m_info)
{
case VIDEOPLAYER_GENRE:
case LISTITEM_GENRE:
case VIDEOPLAYER_NEXT_GENRE:
case LISTITEM_NEXT_GENRE:
strValue = epgTag->GetGenresLabel();
return true;
case VIDEOPLAYER_PLOT:
case LISTITEM_PLOT:
case VIDEOPLAYER_NEXT_PLOT:
case LISTITEM_NEXT_PLOT:
if (!CServiceBroker::GetPVRManager().IsParentalLocked(epgTag))
strValue = epgTag->Plot();
return true;
case VIDEOPLAYER_PLOT_OUTLINE:
case LISTITEM_PLOT_OUTLINE:
case VIDEOPLAYER_NEXT_PLOT_OUTLINE:
case LISTITEM_NEXT_PLOT_OUTLINE:
if (!CServiceBroker::GetPVRManager().IsParentalLocked(epgTag))
strValue = epgTag->PlotOutline();
return true;
case LISTITEM_DATE:
strValue = GetAsLocalizedDateTimeString(epgTag->StartAsLocalTime());
return true;
case LISTITEM_STARTDATE:
case LISTITEM_NEXT_STARTDATE:
strValue = GetAsLocalizedDateString(epgTag->StartAsLocalTime(), true);
return true;
case VIDEOPLAYER_STARTTIME:
case VIDEOPLAYER_NEXT_STARTTIME:
case LISTITEM_STARTTIME:
case LISTITEM_NEXT_STARTTIME:
strValue = GetAsLocalizedTimeString(epgTag->StartAsLocalTime());
return true;
case LISTITEM_ENDDATE:
case LISTITEM_NEXT_ENDDATE:
strValue = GetAsLocalizedDateString(epgTag->EndAsLocalTime(), true);
return true;
case VIDEOPLAYER_ENDTIME:
case VIDEOPLAYER_NEXT_ENDTIME:
case LISTITEM_ENDTIME:
case LISTITEM_NEXT_ENDTIME:
strValue = GetAsLocalizedTimeString(epgTag->EndAsLocalTime());
return true;
// note: for some reason, there is no VIDEOPLAYER_DURATION
case LISTITEM_DURATION:
case VIDEOPLAYER_NEXT_DURATION:
case LISTITEM_NEXT_DURATION:
if (epgTag->GetDuration() > 0)
{
strValue = StringUtils::SecondsToTimeString(epgTag->GetDuration(),
static_cast<TIME_FORMAT>(info.GetData4()));
return true;
}
return false;
case VIDEOPLAYER_IMDBNUMBER:
case LISTITEM_IMDBNUMBER:
strValue = epgTag->IMDBNumber();
return true;
case VIDEOPLAYER_ORIGINALTITLE:
case LISTITEM_ORIGINALTITLE:
if (!CServiceBroker::GetPVRManager().IsParentalLocked(epgTag))
strValue = epgTag->OriginalTitle();
return true;
case VIDEOPLAYER_YEAR:
case LISTITEM_YEAR:
if (epgTag->Year() > 0)
{
strValue = std::to_string(epgTag->Year());
return true;
}
return false;
case VIDEOPLAYER_SEASON:
case LISTITEM_SEASON:
if (epgTag->SeriesNumber() >= 0)
{
strValue = std::to_string(epgTag->SeriesNumber());
return true;
}
return false;
case VIDEOPLAYER_EPISODE:
case LISTITEM_EPISODE:
if (epgTag->EpisodeNumber() >= 0)
{
strValue = std::to_string(epgTag->EpisodeNumber());
return true;
}
return false;
case VIDEOPLAYER_EPISODENAME:
case LISTITEM_EPISODENAME:
if (!CServiceBroker::GetPVRManager().IsParentalLocked(epgTag))
{
strValue = epgTag->EpisodeName();
// fixup multiline episode name strings (which do not fit in any way in our GUI)
StringUtils::Replace(strValue, "\n", ", ");
}
return true;
case VIDEOPLAYER_CAST:
case LISTITEM_CAST:
strValue = epgTag->GetCastLabel();
return true;
case VIDEOPLAYER_DIRECTOR:
case LISTITEM_DIRECTOR:
strValue = epgTag->GetDirectorsLabel();
return true;
case VIDEOPLAYER_WRITER:
case LISTITEM_WRITER:
strValue = epgTag->GetWritersLabel();
return true;
case LISTITEM_EPG_EVENT_ICON:
strValue = epgTag->IconPath();
return true;
case VIDEOPLAYER_PARENTAL_RATING:
case LISTITEM_PARENTAL_RATING:
if (epgTag->ParentalRating() > 0)
{
strValue = std::to_string(epgTag->ParentalRating());
return true;
}
return false;
case LISTITEM_PARENTAL_RATING_CODE:
strValue = epgTag->ParentalRatingCode();
return true;
case VIDEOPLAYER_PREMIERED:
case LISTITEM_PREMIERED:
if (epgTag->FirstAired().IsValid())
{
strValue = epgTag->FirstAired().GetAsLocalizedDate();
return true;
}
else if (epgTag->Year() > 0)
{
strValue = std::to_string(epgTag->Year());
return true;
}
return false;
case VIDEOPLAYER_RATING:
case LISTITEM_RATING:
{
int iStarRating = epgTag->StarRating();
if (iStarRating > 0)
{
strValue = StringUtils::FormatNumber(iStarRating);
return true;
}
return false;
}
}
}
if (channel)
{
switch (info.m_info)
{
case MUSICPLAYER_CHANNEL_NAME:
{
const std::shared_ptr<const CPVRRadioRDSInfoTag> rdsTag = channel->GetRadioRDSInfoTag();
if (rdsTag)
{
strValue = rdsTag->GetProgStation();
if (!strValue.empty())
return true;
}
// fall-thru is intended
[[fallthrough]];
}
case VIDEOPLAYER_CHANNEL_NAME:
case LISTITEM_CHANNEL_NAME:
strValue = channel->ChannelName();
return true;
case MUSICPLAYER_CHANNEL_NUMBER:
case VIDEOPLAYER_CHANNEL_NUMBER:
case LISTITEM_CHANNEL_NUMBER:
{
auto groupMember = item->GetPVRChannelGroupMemberInfoTag();
if (!groupMember)
groupMember =
CServiceBroker::GetPVRManager().Get<PVR::GUI::Channels>().GetChannelGroupMember(
*item);
if (groupMember)
{
strValue = groupMember->ChannelNumber().FormattedChannelNumber();
return true;
}
break;
}
case MUSICPLAYER_CHANNEL_GROUP:
case VIDEOPLAYER_CHANNEL_GROUP:
{
std::unique_lock<CCriticalSection> lock(m_critSection);
strValue = channel->IsRadio() ? m_strPlayingRadioGroup : m_strPlayingTVGroup;
return true;
}
}
}
return false;
}
bool CPVRGUIInfo::GetPVRLabel(const CFileItem* item,
const CGUIInfo& info,
std::string& strValue) const
{
std::unique_lock<CCriticalSection> lock(m_critSection);
switch (info.m_info)
{
case PVR_EPG_EVENT_ICON:
{
const std::shared_ptr<const CPVREpgInfoTag> epgTag =
(item->IsPVRChannel() || item->IsEPG()) ? CPVRItem(item).GetEpgInfoTag() : nullptr;
if (epgTag)
{
strValue = epgTag->IconPath();
}
return true;
}
case PVR_EPG_EVENT_DURATION:
{
const std::shared_ptr<const CPVREpgInfoTag> epgTag =
(item->IsPVRChannel() || item->IsEPG()) ? CPVRItem(item).GetEpgInfoTag() : nullptr;
strValue = m_timesInfo.GetEpgEventDuration(epgTag, static_cast<TIME_FORMAT>(info.GetData1()));
return true;
}
case PVR_EPG_EVENT_ELAPSED_TIME:
{
const std::shared_ptr<const CPVREpgInfoTag> epgTag =
(item->IsPVRChannel() || item->IsEPG()) ? CPVRItem(item).GetEpgInfoTag() : nullptr;
strValue =
m_timesInfo.GetEpgEventElapsedTime(epgTag, static_cast<TIME_FORMAT>(info.GetData1()));
return true;
}
case PVR_EPG_EVENT_REMAINING_TIME:
{
const std::shared_ptr<const CPVREpgInfoTag> epgTag =
(item->IsPVRChannel() || item->IsEPG()) ? CPVRItem(item).GetEpgInfoTag() : nullptr;
strValue =
m_timesInfo.GetEpgEventRemainingTime(epgTag, static_cast<TIME_FORMAT>(info.GetData1()));
return true;
}
case PVR_EPG_EVENT_FINISH_TIME:
{
const std::shared_ptr<const CPVREpgInfoTag> epgTag =
(item->IsPVRChannel() || item->IsEPG()) ? CPVRItem(item).GetEpgInfoTag() : nullptr;
strValue =
m_timesInfo.GetEpgEventFinishTime(epgTag, static_cast<TIME_FORMAT>(info.GetData1()));
return true;
}
case PVR_TIMESHIFT_START_TIME:
strValue = m_timesInfo.GetTimeshiftStartTime(static_cast<TIME_FORMAT>(info.GetData1()));
return true;
case PVR_TIMESHIFT_END_TIME:
strValue = m_timesInfo.GetTimeshiftEndTime(static_cast<TIME_FORMAT>(info.GetData1()));
return true;
case PVR_TIMESHIFT_PLAY_TIME:
strValue = m_timesInfo.GetTimeshiftPlayTime(static_cast<TIME_FORMAT>(info.GetData1()));
return true;
case PVR_TIMESHIFT_OFFSET:
strValue = m_timesInfo.GetTimeshiftOffset(static_cast<TIME_FORMAT>(info.GetData1()));
return true;
case PVR_TIMESHIFT_PROGRESS_DURATION:
strValue =
m_timesInfo.GetTimeshiftProgressDuration(static_cast<TIME_FORMAT>(info.GetData1()));
return true;
case PVR_TIMESHIFT_PROGRESS_START_TIME:
strValue =
m_timesInfo.GetTimeshiftProgressStartTime(static_cast<TIME_FORMAT>(info.GetData1()));
return true;
case PVR_TIMESHIFT_PROGRESS_END_TIME:
strValue = m_timesInfo.GetTimeshiftProgressEndTime(static_cast<TIME_FORMAT>(info.GetData1()));
return true;
case PVR_EPG_EVENT_SEEK_TIME:
{
const auto& components = CServiceBroker::GetAppComponents();
const auto appPlayer = components.GetComponent<CApplicationPlayer>();
strValue = m_timesInfo.GetEpgEventSeekTime(appPlayer->GetSeekHandler().GetSeekSize(),
static_cast<TIME_FORMAT>(info.GetData1()));
return true;
}
case PVR_NOW_RECORDING_TITLE:
strValue = m_anyTimersInfo.GetActiveTimerTitle();
return true;
case PVR_NOW_RECORDING_CHANNEL:
strValue = m_anyTimersInfo.GetActiveTimerChannelName();
return true;
case PVR_NOW_RECORDING_CHAN_ICO:
strValue = m_anyTimersInfo.GetActiveTimerChannelIcon();
return true;
case PVR_NOW_RECORDING_DATETIME:
strValue = m_anyTimersInfo.GetActiveTimerDateTime();
return true;
case PVR_NEXT_RECORDING_TITLE:
strValue = m_anyTimersInfo.GetNextTimerTitle();
return true;
case PVR_NEXT_RECORDING_CHANNEL:
strValue = m_anyTimersInfo.GetNextTimerChannelName();
return true;
case PVR_NEXT_RECORDING_CHAN_ICO:
strValue = m_anyTimersInfo.GetNextTimerChannelIcon();
return true;
case PVR_NEXT_RECORDING_DATETIME:
strValue = m_anyTimersInfo.GetNextTimerDateTime();
return true;
case PVR_TV_NOW_RECORDING_TITLE:
strValue = m_tvTimersInfo.GetActiveTimerTitle();
return true;
case PVR_TV_NOW_RECORDING_CHANNEL:
strValue = m_tvTimersInfo.GetActiveTimerChannelName();
return true;
case PVR_TV_NOW_RECORDING_CHAN_ICO:
strValue = m_tvTimersInfo.GetActiveTimerChannelIcon();
return true;
case PVR_TV_NOW_RECORDING_DATETIME:
strValue = m_tvTimersInfo.GetActiveTimerDateTime();
return true;
case PVR_TV_NEXT_RECORDING_TITLE:
strValue = m_tvTimersInfo.GetNextTimerTitle();
return true;
case PVR_TV_NEXT_RECORDING_CHANNEL:
strValue = m_tvTimersInfo.GetNextTimerChannelName();
return true;
case PVR_TV_NEXT_RECORDING_CHAN_ICO:
strValue = m_tvTimersInfo.GetNextTimerChannelIcon();
return true;
case PVR_TV_NEXT_RECORDING_DATETIME:
strValue = m_tvTimersInfo.GetNextTimerDateTime();
return true;
case PVR_RADIO_NOW_RECORDING_TITLE:
strValue = m_radioTimersInfo.GetActiveTimerTitle();
return true;
case PVR_RADIO_NOW_RECORDING_CHANNEL:
strValue = m_radioTimersInfo.GetActiveTimerChannelName();
return true;
case PVR_RADIO_NOW_RECORDING_CHAN_ICO:
strValue = m_radioTimersInfo.GetActiveTimerChannelIcon();
return true;
case PVR_RADIO_NOW_RECORDING_DATETIME:
strValue = m_radioTimersInfo.GetActiveTimerDateTime();
return true;
case PVR_RADIO_NEXT_RECORDING_TITLE:
strValue = m_radioTimersInfo.GetNextTimerTitle();
return true;
case PVR_RADIO_NEXT_RECORDING_CHANNEL:
strValue = m_radioTimersInfo.GetNextTimerChannelName();
return true;
case PVR_RADIO_NEXT_RECORDING_CHAN_ICO:
strValue = m_radioTimersInfo.GetNextTimerChannelIcon();
return true;
case PVR_RADIO_NEXT_RECORDING_DATETIME:
strValue = m_radioTimersInfo.GetNextTimerDateTime();
return true;
case PVR_NEXT_TIMER:
strValue = m_anyTimersInfo.GetNextTimer();
return true;
case PVR_ACTUAL_STREAM_SIG:
CharInfoSignal(strValue);
return true;
case PVR_ACTUAL_STREAM_SNR:
CharInfoSNR(strValue);
return true;
case PVR_ACTUAL_STREAM_BER:
CharInfoBER(strValue);
return true;
case PVR_ACTUAL_STREAM_UNC:
CharInfoUNC(strValue);
return true;
case PVR_ACTUAL_STREAM_CLIENT:
CharInfoPlayingClientName(strValue);
return true;
case PVR_ACTUAL_STREAM_DEVICE:
CharInfoFrontendName(strValue);
return true;
case PVR_ACTUAL_STREAM_STATUS:
CharInfoFrontendStatus(strValue);
return true;
case PVR_ACTUAL_STREAM_CRYPTION:
CharInfoEncryption(strValue);
return true;
case PVR_ACTUAL_STREAM_SERVICE:
CharInfoService(strValue);
return true;
case PVR_ACTUAL_STREAM_MUX:
CharInfoMux(strValue);
return true;
case PVR_ACTUAL_STREAM_PROVIDER:
CharInfoProvider(strValue);
return true;
case PVR_BACKEND_NAME:
CharInfoBackendName(strValue);
return true;
case PVR_BACKEND_VERSION:
CharInfoBackendVersion(strValue);
return true;
case PVR_BACKEND_HOST:
CharInfoBackendHost(strValue);
return true;
case PVR_BACKEND_DISKSPACE:
CharInfoBackendDiskspace(strValue);
return true;
case PVR_BACKEND_PROVIDERS:
CharInfoBackendProviders(strValue);
return true;
case PVR_BACKEND_CHANNEL_GROUPS:
CharInfoBackendChannelGroups(strValue);
return true;
case PVR_BACKEND_CHANNELS:
CharInfoBackendChannels(strValue);
return true;
case PVR_BACKEND_TIMERS:
CharInfoBackendTimers(strValue);
return true;
case PVR_BACKEND_RECORDINGS:
CharInfoBackendRecordings(strValue);
return true;
case PVR_BACKEND_DELETED_RECORDINGS:
CharInfoBackendDeletedRecordings(strValue);
return true;
case PVR_BACKEND_NUMBER:
CharInfoBackendNumber(strValue);
return true;
case PVR_TOTAL_DISKSPACE:
CharInfoTotalDiskSpace(strValue);
return true;
case PVR_CHANNEL_NUMBER_INPUT:
strValue = m_channelNumberInput;
return true;
}
return false;
}
bool CPVRGUIInfo::GetRadioRDSLabel(const CFileItem* item,
const CGUIInfo& info,
std::string& strValue) const
{
if (!item->HasPVRChannelInfoTag())
return false;
const std::shared_ptr<const CPVRRadioRDSInfoTag> tag =
item->GetPVRChannelInfoTag()->GetRadioRDSInfoTag();
if (tag)
{
switch (info.m_info)
{
case RDS_CHANNEL_COUNTRY:
strValue = tag->GetCountry();
return true;
case RDS_TITLE:
strValue = tag->GetTitle();
return true;
case RDS_ARTIST:
strValue = tag->GetArtist();
return true;
case RDS_BAND:
strValue = tag->GetBand();
return true;
case RDS_COMPOSER:
strValue = tag->GetComposer();
return true;
case RDS_CONDUCTOR:
strValue = tag->GetConductor();
return true;
case RDS_ALBUM:
strValue = tag->GetAlbum();
return true;
case RDS_ALBUM_TRACKNUMBER:
if (tag->GetAlbumTrackNumber() > 0)
{
strValue = std::to_string(tag->GetAlbumTrackNumber());
return true;
}
break;
case RDS_GET_RADIO_STYLE:
strValue = tag->GetRadioStyle();
return true;
case RDS_COMMENT:
strValue = tag->GetComment();
return true;
case RDS_INFO_NEWS:
strValue = tag->GetInfoNews();
return true;
case RDS_INFO_NEWS_LOCAL:
strValue = tag->GetInfoNewsLocal();
return true;
case RDS_INFO_STOCK:
strValue = tag->GetInfoStock();
return true;
case RDS_INFO_STOCK_SIZE:
strValue = std::to_string(static_cast<int>(tag->GetInfoStock().size()));
return true;
case RDS_INFO_SPORT:
strValue = tag->GetInfoSport();
return true;
case RDS_INFO_SPORT_SIZE:
strValue = std::to_string(static_cast<int>(tag->GetInfoSport().size()));
return true;
case RDS_INFO_LOTTERY:
strValue = tag->GetInfoLottery();
return true;
case RDS_INFO_LOTTERY_SIZE:
strValue = std::to_string(static_cast<int>(tag->GetInfoLottery().size()));
return true;
case RDS_INFO_WEATHER:
strValue = tag->GetInfoWeather();
return true;
case RDS_INFO_WEATHER_SIZE:
strValue = std::to_string(static_cast<int>(tag->GetInfoWeather().size()));
return true;
case RDS_INFO_HOROSCOPE:
strValue = tag->GetInfoHoroscope();
return true;
case RDS_INFO_HOROSCOPE_SIZE:
strValue = std::to_string(static_cast<int>(tag->GetInfoHoroscope().size()));
return true;
case RDS_INFO_CINEMA:
strValue = tag->GetInfoCinema();
return true;
case RDS_INFO_CINEMA_SIZE:
strValue = std::to_string(static_cast<int>(tag->GetInfoCinema().size()));
return true;
case RDS_INFO_OTHER:
strValue = tag->GetInfoOther();
return true;
case RDS_INFO_OTHER_SIZE:
strValue = std::to_string(static_cast<int>(tag->GetInfoOther().size()));
return true;
case RDS_PROG_HOST:
strValue = tag->GetProgHost();
return true;
case RDS_PROG_EDIT_STAFF:
strValue = tag->GetEditorialStaff();
return true;
case RDS_PROG_HOMEPAGE:
strValue = tag->GetProgWebsite();
return true;
case RDS_PROG_STYLE:
strValue = tag->GetProgStyle();
return true;
case RDS_PHONE_HOTLINE:
strValue = tag->GetPhoneHotline();
return true;
case RDS_PHONE_STUDIO:
strValue = tag->GetPhoneStudio();
return true;
case RDS_SMS_STUDIO:
strValue = tag->GetSMSStudio();
return true;
case RDS_EMAIL_HOTLINE:
strValue = tag->GetEMailHotline();
return true;
case RDS_EMAIL_STUDIO:
strValue = tag->GetEMailStudio();
return true;
case RDS_PROG_STATION:
strValue = tag->GetProgStation();
return true;
case RDS_PROG_NOW:
strValue = tag->GetProgNow();
return true;
case RDS_PROG_NEXT:
strValue = tag->GetProgNext();
return true;
case RDS_AUDIO_LANG:
strValue = tag->GetLanguage();
return true;
case RDS_GET_RADIOTEXT_LINE:
strValue = tag->GetRadioText(info.GetData1());
return true;
}
}
return false;
}
bool CPVRGUIInfo::GetFallbackLabel(std::string& value,
const CFileItem* item,
int contextWindow,
const CGUIInfo& info,
std::string* fallback)
{
if (item->IsPVRChannel() || item->IsEPG() || item->IsPVRTimer())
{
switch (info.m_info)
{
/////////////////////////////////////////////////////////////////////////////////////////////
// VIDEOPLAYER_*, MUSICPLAYER_*
/////////////////////////////////////////////////////////////////////////////////////////////
case VIDEOPLAYER_TITLE:
case MUSICPLAYER_TITLE:
value = GetEpgTagTitle(CPVRItem(item).GetEpgInfoTag());
return !value.empty();
default:
break;
}
}
return false;
}
bool CPVRGUIInfo::GetInt(int& value,
const CGUIListItem* item,
int contextWindow,
const CGUIInfo& info) const
{
if (!item->IsFileItem())
return false;
const CFileItem* fitem = static_cast<const CFileItem*>(item);
return GetListItemAndPlayerInt(fitem, info, value) || GetPVRInt(fitem, info, value);
}
bool CPVRGUIInfo::GetListItemAndPlayerInt(const CFileItem* item,
const CGUIInfo& info,
int& iValue) const
{
switch (info.m_info)
{
case LISTITEM_PROGRESS:
if (item->IsPVRChannel() || item->IsEPG())
{
const std::shared_ptr<const CPVREpgInfoTag> epgTag = CPVRItem(item).GetEpgInfoTag();
if (epgTag)
iValue = static_cast<int>(epgTag->ProgressPercentage());
}
return true;
}
return false;
}
bool CPVRGUIInfo::GetPVRInt(const CFileItem* item, const CGUIInfo& info, int& iValue) const
{
std::unique_lock<CCriticalSection> lock(m_critSection);
switch (info.m_info)
{
case PVR_EPG_EVENT_DURATION:
{
const std::shared_ptr<const CPVREpgInfoTag> epgTag =
(item->IsPVRChannel() || item->IsEPG()) ? CPVRItem(item).GetEpgInfoTag() : nullptr;
iValue = m_timesInfo.GetEpgEventDuration(epgTag);
return true;
}
case PVR_EPG_EVENT_PROGRESS:
{
const std::shared_ptr<const CPVREpgInfoTag> epgTag =
(item->IsPVRChannel() || item->IsEPG()) ? CPVRItem(item).GetEpgInfoTag() : nullptr;
iValue = m_timesInfo.GetEpgEventProgress(epgTag);
return true;
}
case PVR_TIMESHIFT_PROGRESS:
iValue = m_timesInfo.GetTimeshiftProgress();
return true;
case PVR_TIMESHIFT_PROGRESS_DURATION:
iValue = m_timesInfo.GetTimeshiftProgressDuration();
return true;
case PVR_TIMESHIFT_PROGRESS_PLAY_POS:
iValue = m_timesInfo.GetTimeshiftProgressPlayPosition();
return true;
case PVR_TIMESHIFT_PROGRESS_EPG_START:
iValue = m_timesInfo.GetTimeshiftProgressEpgStart();
return true;
case PVR_TIMESHIFT_PROGRESS_EPG_END:
iValue = m_timesInfo.GetTimeshiftProgressEpgEnd();
return true;
case PVR_TIMESHIFT_PROGRESS_BUFFER_START:
iValue = m_timesInfo.GetTimeshiftProgressBufferStart();
return true;
case PVR_TIMESHIFT_PROGRESS_BUFFER_END:
iValue = m_timesInfo.GetTimeshiftProgressBufferEnd();
return true;
case PVR_TIMESHIFT_SEEKBAR:
iValue = GetTimeShiftSeekPercent();
return true;
case PVR_ACTUAL_STREAM_SIG_PROGR:
iValue = std::lrintf(static_cast<float>(m_qualityInfo.iSignal) / 0xFFFF * 100);
return true;
case PVR_ACTUAL_STREAM_SNR_PROGR:
iValue = std::lrintf(static_cast<float>(m_qualityInfo.iSNR) / 0xFFFF * 100);
return true;
case PVR_BACKEND_DISKSPACE_PROGR:
if (m_iBackendDiskTotal > 0)
iValue = std::lrintf(static_cast<float>(m_iBackendDiskUsed) / m_iBackendDiskTotal * 100);
else
iValue = 0xFF;
return true;
}
return false;
}
bool CPVRGUIInfo::GetBool(bool& value,
const CGUIListItem* item,
int contextWindow,
const CGUIInfo& info) const
{
if (!item->IsFileItem())
return false;
const CFileItem* fitem = static_cast<const CFileItem*>(item);
return GetListItemAndPlayerBool(fitem, info, value) || GetPVRBool(fitem, info, value) ||
GetRadioRDSBool(fitem, info, value);
}
bool CPVRGUIInfo::GetListItemAndPlayerBool(const CFileItem* item,
const CGUIInfo& info,
bool& bValue) const
{
switch (info.m_info)
{
case LISTITEM_HASARCHIVE:
if (item->IsPVRChannel())
{
bValue = item->GetPVRChannelInfoTag()->HasArchive();
return true;
}
break;
case LISTITEM_ISPLAYABLE:
if (item->IsEPG())
{
bValue = item->GetEPGInfoTag()->IsPlayable();
return true;
}
break;
case LISTITEM_ISRECORDING:
if (item->IsPVRChannel())
{
bValue = CServiceBroker::GetPVRManager().Timers()->IsRecordingOnChannel(
*item->GetPVRChannelInfoTag());
return true;
}
else if (item->IsEPG() || item->IsPVRTimer())
{
const std::shared_ptr<const CPVRTimerInfoTag> timer = CPVRItem(item).GetTimerInfoTag();
if (timer)
bValue = timer->IsRecording();
return true;
}
else if (item->IsPVRRecording())
{
bValue = item->GetPVRRecordingInfoTag()->IsInProgress();
return true;
}
break;
case LISTITEM_INPROGRESS:
if (item->IsPVRChannel() || item->IsEPG())
{
const std::shared_ptr<const CPVREpgInfoTag> epgTag = CPVRItem(item).GetEpgInfoTag();
if (epgTag)
bValue = epgTag->IsActive();
return true;
}
break;
case LISTITEM_HASTIMER:
if (item->IsPVRChannel() || item->IsEPG() || item->IsPVRTimer())
{
const std::shared_ptr<const CPVRTimerInfoTag> timer = CPVRItem(item).GetTimerInfoTag();
if (timer)
bValue = true;
return true;
}
break;
case LISTITEM_HASTIMERSCHEDULE:
if (item->IsPVRChannel() || item->IsEPG() || item->IsPVRTimer())
{
const std::shared_ptr<const CPVRTimerInfoTag> timer = CPVRItem(item).GetTimerInfoTag();
if (timer)
bValue = timer->HasParent();
return true;
}
break;
case LISTITEM_HASREMINDER:
if (item->IsPVRChannel() || item->IsEPG() || item->IsPVRTimer())
{
const std::shared_ptr<const CPVRTimerInfoTag> timer = CPVRItem(item).GetTimerInfoTag();
if (timer)
bValue = timer->IsReminder();
return true;
}
break;
case LISTITEM_HASREMINDERRULE:
if (item->IsPVRChannel() || item->IsEPG() || item->IsPVRTimer())
{
const std::shared_ptr<const CPVRTimerInfoTag> timer = CPVRItem(item).GetTimerInfoTag();
if (timer)
bValue = timer->IsReminder() && timer->HasParent();
return true;
}
break;
case LISTITEM_TIMERISACTIVE:
if (item->IsPVRChannel() || item->IsEPG())
{
const std::shared_ptr<const CPVRTimerInfoTag> timer = CPVRItem(item).GetTimerInfoTag();
if (timer)
bValue = timer->IsActive();
break;
}
break;
case LISTITEM_TIMERHASCONFLICT:
if (item->IsPVRChannel() || item->IsEPG())
{
const std::shared_ptr<const CPVRTimerInfoTag> timer = CPVRItem(item).GetTimerInfoTag();
if (timer)
bValue = timer->HasConflict();
return true;
}
break;
case LISTITEM_TIMERHASERROR:
if (item->IsPVRChannel() || item->IsEPG())
{
const std::shared_ptr<const CPVRTimerInfoTag> timer = CPVRItem(item).GetTimerInfoTag();
if (timer)
bValue = (timer->IsBroken() && !timer->HasConflict());
return true;
}
break;
case LISTITEM_HASRECORDING:
if (item->IsPVRChannel() || item->IsEPG())
{
const std::shared_ptr<const CPVREpgInfoTag> epgTag = CPVRItem(item).GetEpgInfoTag();
if (epgTag)
bValue = !!CServiceBroker::GetPVRManager().Recordings()->GetRecordingForEpgTag(epgTag);
return true;
}
break;
case LISTITEM_HAS_EPG:
if (item->IsPVRChannel() || item->IsEPG() || item->IsPVRTimer())
{
const std::shared_ptr<const CPVREpgInfoTag> epgTag = CPVRItem(item).GetEpgInfoTag();
bValue = (epgTag != nullptr);
return true;
}
break;
case LISTITEM_ISENCRYPTED:
if (item->IsPVRChannel() || item->IsEPG())
{
const std::shared_ptr<const CPVRChannel> channel = CPVRItem(item).GetChannel();
if (channel)
bValue = channel->IsEncrypted();
return true;
}
break;
case LISTITEM_IS_NEW:
if (item->IsEPG())
{
if (item->GetEPGInfoTag())
{
bValue = item->GetEPGInfoTag()->IsNew();
return true;
}
}
else if (item->IsPVRRecording())
{
bValue = item->GetPVRRecordingInfoTag()->IsNew();
return true;
}
else if (item->IsPVRTimer() && item->GetPVRTimerInfoTag()->GetEpgInfoTag())
{
bValue = item->GetPVRTimerInfoTag()->GetEpgInfoTag()->IsNew();
return true;
}
else if (item->IsPVRChannel())
{
const std::shared_ptr<const CPVREpgInfoTag> epgNow =
item->GetPVRChannelInfoTag()->GetEPGNow();
bValue = epgNow ? epgNow->IsNew() : false;
return true;
}
break;
case LISTITEM_IS_PREMIERE:
if (item->IsEPG())
{
bValue = item->GetEPGInfoTag()->IsPremiere();
return true;
}
else if (item->IsPVRRecording())
{
bValue = item->GetPVRRecordingInfoTag()->IsPremiere();
return true;
}
else if (item->IsPVRTimer() && item->GetPVRTimerInfoTag()->GetEpgInfoTag())
{
bValue = item->GetPVRTimerInfoTag()->GetEpgInfoTag()->IsPremiere();
return true;
}
else if (item->IsPVRChannel())
{
const std::shared_ptr<const CPVREpgInfoTag> epgNow =
item->GetPVRChannelInfoTag()->GetEPGNow();
bValue = epgNow ? epgNow->IsPremiere() : false;
return true;
}
break;
case LISTITEM_IS_FINALE:
if (item->IsEPG())
{
bValue = item->GetEPGInfoTag()->IsFinale();
return true;
}
else if (item->IsPVRRecording())
{
bValue = item->GetPVRRecordingInfoTag()->IsFinale();
return true;
}
else if (item->IsPVRTimer() && item->GetPVRTimerInfoTag()->GetEpgInfoTag())
{
bValue = item->GetPVRTimerInfoTag()->GetEpgInfoTag()->IsFinale();
return true;
}
else if (item->IsPVRChannel())
{
const std::shared_ptr<const CPVREpgInfoTag> epgNow =
item->GetPVRChannelInfoTag()->GetEPGNow();
bValue = epgNow ? epgNow->IsFinale() : false;
return true;
}
break;
case LISTITEM_IS_LIVE:
if (item->IsEPG())
{
bValue = item->GetEPGInfoTag()->IsLive();
return true;
}
else if (item->IsPVRRecording())
{
bValue = item->GetPVRRecordingInfoTag()->IsLive();
return true;
}
else if (item->IsPVRTimer() && item->GetPVRTimerInfoTag()->GetEpgInfoTag())
{
bValue = item->GetPVRTimerInfoTag()->GetEpgInfoTag()->IsLive();
return true;
}
else if (item->IsPVRChannel())
{
const std::shared_ptr<const CPVREpgInfoTag> epgNow =
item->GetPVRChannelInfoTag()->GetEPGNow();
bValue = epgNow ? epgNow->IsLive() : false;
return true;
}
break;
case LISTITEM_ISPLAYING:
if (item->IsPVRChannel())
{
const std::shared_ptr<const CPVRChannel> playingChannel{
CServiceBroker::GetPVRManager().PlaybackState()->GetPlayingChannel()};
if (playingChannel)
{
const std::shared_ptr<const CPVRChannel> channel{item->GetPVRChannelInfoTag()};
bValue = (channel->StorageId() == playingChannel->StorageId());
return true;
}
}
break;
case MUSICPLAYER_CONTENT:
case VIDEOPLAYER_CONTENT:
if (item->IsPVRChannel())
{
bValue = StringUtils::EqualsNoCase(info.GetData3(), "livetv");
return bValue; // if no match for this provider, other providers shall be asked.
}
break;
case VIDEOPLAYER_HAS_INFO:
if (item->IsPVRChannel())
{
bValue = !item->GetPVRChannelInfoTag()->ChannelName().empty();
return true;
}
break;
case VIDEOPLAYER_HAS_EPG:
if (item->IsPVRChannel())
{
bValue = (item->GetPVRChannelInfoTag()->GetEPGNow() != nullptr);
return true;
}
break;
case VIDEOPLAYER_CAN_RESUME_LIVE_TV:
if (item->IsPVRRecording())
{
const std::shared_ptr<const CPVRRecording> recording = item->GetPVRRecordingInfoTag();
const std::shared_ptr<const CPVREpg> epg =
recording->Channel() ? recording->Channel()->GetEPG() : nullptr;
const std::shared_ptr<const CPVREpgInfoTag> epgTag =
CServiceBroker::GetPVRManager().EpgContainer().GetTagById(epg,
recording->BroadcastUid());
bValue = (epgTag && epgTag->IsActive());
return true;
}
break;
case PLAYER_IS_CHANNEL_PREVIEW_ACTIVE:
if (item->IsPVRChannel())
{
if (m_previewAndPlayerShowInfo)
{
bValue = true;
}
else
{
bValue = !m_videoInfo.valid;
if (bValue && item->GetPVRChannelInfoTag()->IsRadio())
bValue = !m_audioInfo.valid;
}
return true;
}
break;
}
return false;
}
bool CPVRGUIInfo::GetPVRBool(const CFileItem* item, const CGUIInfo& info, bool& bValue) const
{
std::unique_lock<CCriticalSection> lock(m_critSection);
switch (info.m_info)
{
case PVR_IS_RECORDING:
bValue = m_anyTimersInfo.HasRecordingTimers();
return true;
case PVR_IS_RECORDING_TV:
bValue = m_tvTimersInfo.HasRecordingTimers();
return true;
case PVR_IS_RECORDING_RADIO:
bValue = m_radioTimersInfo.HasRecordingTimers();
return true;
case PVR_HAS_TIMER:
bValue = m_anyTimersInfo.HasTimers();
return true;
case PVR_HAS_TV_TIMER:
bValue = m_tvTimersInfo.HasTimers();
return true;
case PVR_HAS_RADIO_TIMER:
bValue = m_radioTimersInfo.HasTimers();
return true;
case PVR_HAS_TV_CHANNELS:
bValue = m_bHasTVChannels;
return true;
case PVR_HAS_RADIO_CHANNELS:
bValue = m_bHasRadioChannels;
return true;
case PVR_HAS_NONRECORDING_TIMER:
bValue = m_anyTimersInfo.HasNonRecordingTimers();
return true;
case PVR_HAS_NONRECORDING_TV_TIMER:
bValue = m_tvTimersInfo.HasNonRecordingTimers();
return true;
case PVR_HAS_NONRECORDING_RADIO_TIMER:
bValue = m_radioTimersInfo.HasNonRecordingTimers();
return true;
case PVR_IS_PLAYING_TV:
bValue = m_bIsPlayingTV;
return true;
case PVR_IS_PLAYING_RADIO:
bValue = m_bIsPlayingRadio;
return true;
case PVR_IS_PLAYING_RECORDING:
bValue = m_bIsPlayingRecording;
return true;
case PVR_IS_PLAYING_EPGTAG:
bValue = m_bIsPlayingEpgTag;
return true;
case PVR_ACTUAL_STREAM_ENCRYPTED:
bValue = m_bIsPlayingEncryptedStream;
return true;
case PVR_IS_TIMESHIFTING:
bValue = m_timesInfo.IsTimeshifting();
return true;
case PVR_CAN_RECORD_PLAYING_CHANNEL:
bValue = m_bCanRecordPlayingChannel;
return true;
case PVR_IS_RECORDING_PLAYING_CHANNEL:
bValue = m_bIsRecordingPlayingChannel;
return true;
case PVR_IS_PLAYING_ACTIVE_RECORDING:
bValue = m_bIsPlayingActiveRecording;
return true;
}
return false;
}
bool CPVRGUIInfo::GetRadioRDSBool(const CFileItem* item, const CGUIInfo& info, bool& bValue) const
{
if (!item->HasPVRChannelInfoTag())
return false;
const std::shared_ptr<const CPVRRadioRDSInfoTag> tag =
item->GetPVRChannelInfoTag()->GetRadioRDSInfoTag();
if (tag)
{
switch (info.m_info)
{
case RDS_HAS_RADIOTEXT:
bValue = tag->IsPlayingRadioText();
return true;
case RDS_HAS_RADIOTEXT_PLUS:
bValue = tag->IsPlayingRadioTextPlus();
return true;
case RDS_HAS_HOTLINE_DATA:
bValue = (!tag->GetEMailHotline().empty() || !tag->GetPhoneHotline().empty());
return true;
case RDS_HAS_STUDIO_DATA:
bValue = (!tag->GetEMailStudio().empty() || !tag->GetSMSStudio().empty() ||
!tag->GetPhoneStudio().empty());
return true;
}
}
switch (info.m_info)
{
case RDS_HAS_RDS:
{
const auto& components = CServiceBroker::GetAppComponents();
const auto appPlayer = components.GetComponent<CApplicationPlayer>();
bValue = appPlayer->IsPlayingRDS();
return true;
}
}
return false;
}
void CPVRGUIInfo::CharInfoBackendNumber(std::string& strValue) const
{
size_t numBackends = m_backendProperties.size();
if (numBackends > 0)
strValue = StringUtils::Format("{0} {1} {2}", m_iCurrentActiveClient + 1,
g_localizeStrings.Get(20163), numBackends);
else
strValue = g_localizeStrings.Get(14023);
}
void CPVRGUIInfo::CharInfoTotalDiskSpace(std::string& strValue) const
{
strValue = StringUtils::SizeToString(m_iBackendDiskTotal).c_str();
}
void CPVRGUIInfo::CharInfoSignal(std::string& strValue) const
{
strValue = StringUtils::Format("{} %", m_qualityInfo.iSignal / 655);
}
void CPVRGUIInfo::CharInfoSNR(std::string& strValue) const
{
strValue = StringUtils::Format("{} %", m_qualityInfo.iSNR / 655);
}
void CPVRGUIInfo::CharInfoBER(std::string& strValue) const
{
strValue = StringUtils::Format("{:08X}", m_qualityInfo.iBER);
}
void CPVRGUIInfo::CharInfoUNC(std::string& strValue) const
{
strValue = StringUtils::Format("{:08X}", m_qualityInfo.iUNC);
}
void CPVRGUIInfo::CharInfoFrontendName(std::string& strValue) const
{
if (!strlen(m_qualityInfo.strAdapterName))
strValue = g_localizeStrings.Get(13205);
else
strValue = m_qualityInfo.strAdapterName;
}
void CPVRGUIInfo::CharInfoFrontendStatus(std::string& strValue) const
{
if (!strlen(m_qualityInfo.strAdapterStatus))
strValue = g_localizeStrings.Get(13205);
else
strValue = m_qualityInfo.strAdapterStatus;
}
void CPVRGUIInfo::CharInfoBackendName(std::string& strValue) const
{
m_updateBackendCacheRequested = true;
strValue = m_strBackendName;
}
void CPVRGUIInfo::CharInfoBackendVersion(std::string& strValue) const
{
m_updateBackendCacheRequested = true;
strValue = m_strBackendVersion;
}
void CPVRGUIInfo::CharInfoBackendHost(std::string& strValue) const
{
m_updateBackendCacheRequested = true;
strValue = m_strBackendHost;
}
void CPVRGUIInfo::CharInfoBackendDiskspace(std::string& strValue) const
{
m_updateBackendCacheRequested = true;
auto diskTotal = m_iBackendDiskTotal;
auto diskUsed = m_iBackendDiskUsed;
if (diskTotal > 0)
{
strValue = StringUtils::Format(g_localizeStrings.Get(802),
StringUtils::SizeToString(diskTotal - diskUsed),
StringUtils::SizeToString(diskTotal));
}
else
strValue = g_localizeStrings.Get(13205);
}
void CPVRGUIInfo::CharInfoBackendProviders(std::string& strValue) const
{
m_updateBackendCacheRequested = true;
strValue = m_strBackendProviders;
}
void CPVRGUIInfo::CharInfoBackendChannelGroups(std::string& strValue) const
{
m_updateBackendCacheRequested = true;
strValue = m_strBackendChannelGroups;
}
void CPVRGUIInfo::CharInfoBackendChannels(std::string& strValue) const
{
m_updateBackendCacheRequested = true;
strValue = m_strBackendChannels;
}
void CPVRGUIInfo::CharInfoBackendTimers(std::string& strValue) const
{
m_updateBackendCacheRequested = true;
strValue = m_strBackendTimers;
}
void CPVRGUIInfo::CharInfoBackendRecordings(std::string& strValue) const
{
m_updateBackendCacheRequested = true;
strValue = m_strBackendRecordings;
}
void CPVRGUIInfo::CharInfoBackendDeletedRecordings(std::string& strValue) const
{
m_updateBackendCacheRequested = true;
strValue = m_strBackendDeletedRecordings;
}
void CPVRGUIInfo::CharInfoPlayingClientName(std::string& strValue) const
{
if (m_strPlayingClientName.empty())
strValue = g_localizeStrings.Get(13205);
else
strValue = m_strPlayingClientName;
}
void CPVRGUIInfo::CharInfoEncryption(std::string& strValue) const
{
if (m_descrambleInfo.iCaid != PVR_DESCRAMBLE_INFO_NOT_AVAILABLE)
{
// prefer dynamically updated info, if available
strValue = CPVRChannel::GetEncryptionName(m_descrambleInfo.iCaid);
return;
}
else
{
const std::shared_ptr<const CPVRChannel> channel =
CServiceBroker::GetPVRManager().PlaybackState()->GetPlayingChannel();
if (channel)
{
strValue = channel->EncryptionName();
return;
}
}
strValue.clear();
}
void CPVRGUIInfo::CharInfoService(std::string& strValue) const
{
if (!strlen(m_qualityInfo.strServiceName))
strValue = g_localizeStrings.Get(13205);
else
strValue = m_qualityInfo.strServiceName;
}
void CPVRGUIInfo::CharInfoMux(std::string& strValue) const
{
if (!strlen(m_qualityInfo.strMuxName))
strValue = g_localizeStrings.Get(13205);
else
strValue = m_qualityInfo.strMuxName;
}
void CPVRGUIInfo::CharInfoProvider(std::string& strValue) const
{
if (!strlen(m_qualityInfo.strProviderName))
strValue = g_localizeStrings.Get(13205);
else
strValue = m_qualityInfo.strProviderName;
}
void CPVRGUIInfo::UpdateBackendCache()
{
std::unique_lock<CCriticalSection> lock(m_critSection);
// Update the backend information for all backends if
// an update has been requested
if (m_iCurrentActiveClient == 0 && m_updateBackendCacheRequested)
{
std::vector<SBackend> backendProperties;
{
CSingleExit exit(m_critSection);
backendProperties = CServiceBroker::GetPVRManager().Clients()->GetBackendProperties();
}
m_backendProperties = backendProperties;
m_updateBackendCacheRequested = false;
}
// Store some defaults
m_strBackendName = g_localizeStrings.Get(13205);
m_strBackendVersion = g_localizeStrings.Get(13205);
m_strBackendHost = g_localizeStrings.Get(13205);
m_strBackendProviders = g_localizeStrings.Get(13205);
m_strBackendChannelGroups = g_localizeStrings.Get(13205);
m_strBackendChannels = g_localizeStrings.Get(13205);
m_strBackendTimers = g_localizeStrings.Get(13205);
m_strBackendRecordings = g_localizeStrings.Get(13205);
m_strBackendDeletedRecordings = g_localizeStrings.Get(13205);
m_iBackendDiskTotal = 0;
m_iBackendDiskUsed = 0;
// Update with values from the current client when we have at least one
if (!m_backendProperties.empty())
{
const auto& backend = m_backendProperties[m_iCurrentActiveClient];
m_strBackendName = backend.name;
m_strBackendVersion = backend.version;
m_strBackendHost = backend.host;
// We always display one extra as the add-on itself counts as a provider
if (backend.numProviders >= 0)
m_strBackendProviders = std::to_string(backend.numProviders + 1);
if (backend.numChannelGroups >= 0)
m_strBackendChannelGroups = std::to_string(backend.numChannelGroups);
if (backend.numChannels >= 0)
m_strBackendChannels = std::to_string(backend.numChannels);
if (backend.numTimers >= 0)
m_strBackendTimers = std::to_string(backend.numTimers);
if (backend.numRecordings >= 0)
m_strBackendRecordings = std::to_string(backend.numRecordings);
if (backend.numDeletedRecordings >= 0)
m_strBackendDeletedRecordings = std::to_string(backend.numDeletedRecordings);
m_iBackendDiskTotal = backend.diskTotal;
m_iBackendDiskUsed = backend.diskUsed;
}
// Update the current active client, eventually wrapping around
if (++m_iCurrentActiveClient >= m_backendProperties.size())
m_iCurrentActiveClient = 0;
}
void CPVRGUIInfo::UpdateTimersCache()
{
m_anyTimersInfo.UpdateTimersCache();
m_tvTimersInfo.UpdateTimersCache();
m_radioTimersInfo.UpdateTimersCache();
}
void CPVRGUIInfo::UpdateTimersToggle()
{
m_anyTimersInfo.UpdateTimersToggle();
m_tvTimersInfo.UpdateTimersToggle();
m_radioTimersInfo.UpdateTimersToggle();
}
void CPVRGUIInfo::UpdateNextTimer()
{
m_anyTimersInfo.UpdateNextTimer();
m_tvTimersInfo.UpdateNextTimer();
m_radioTimersInfo.UpdateNextTimer();
}
int CPVRGUIInfo::GetTimeShiftSeekPercent() const
{
int progress = m_timesInfo.GetTimeshiftProgressPlayPosition();
const auto& components = CServiceBroker::GetAppComponents();
const auto appPlayer = components.GetComponent<CApplicationPlayer>();
int seekSize = appPlayer->GetSeekHandler().GetSeekSize();
if (seekSize != 0)
{
int total = m_timesInfo.GetTimeshiftProgressDuration();
float totalTime = static_cast<float>(total);
if (totalTime == 0.0f)
return 0;
float percentPerSecond = 100.0f / totalTime;
float percent = progress + percentPerSecond * seekSize;
percent = std::max(0.0f, std::min(percent, 100.0f));
return std::lrintf(percent);
}
return progress;
}
|