| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file is part of the Falcon Player (FPP) and is Copyright (C) | ||
| 3 | * 2013-2022 by the Falcon Player Developers. | ||
| 4 | * | ||
| 5 | * The Falcon Player (FPP) is free software, and is covered under | ||
| 6 | * multiple Open Source licenses. Please see the included 'LICENSES' | ||
| 7 | * file for descriptions of what files are covered by each license. | ||
| 8 | * | ||
| 9 | * This source file is covered under the LGPL v2.1 as described in the | ||
| 10 | * included LICENSE.LGPL file. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include "fpp-pch.h" | ||
| 14 | |||
| 15 | #include "fpp-json.h" | ||
| 16 | |||
| 17 | #include "../Player.h" | ||
| 18 | #include "../common.h" | ||
| 19 | #include "../Warnings.h" | ||
| 20 | #include "../log.h" | ||
| 21 | |||
| 22 | #include "PlaylistEntryBranch.h" | ||
| 23 | #include "mqtt.h" | ||
| 24 | |||
| 25 | 14 | PlaylistEntryBranch::PlaylistEntryBranch(Playlist* playlist, PlaylistEntryBase* parent) : | |
| 26 | PlaylistEntryBase(playlist, parent), | ||
| 27 | 14 | m_sHour(0), | |
| 28 | 14 | m_sMinute(0), | |
| 29 | 14 | m_sSecond(0), | |
| 30 | 14 | m_sDaySecond(-1), | |
| 31 | 14 | m_sHourSecond(-1), | |
| 32 | 14 | m_eHour(0), | |
| 33 | 14 | m_eMinute(0), | |
| 34 | 14 | m_eSecond(0), | |
| 35 | 14 | m_eDaySecond(-1), | |
| 36 | 14 | m_eHourSecond(-1), | |
| 37 | 14 | m_iterationStart(1), | |
| 38 | 14 | m_iterationCount(1), | |
| 39 | 14 | m_trueNextBranchType(PlaylistBranchType::NoBranch), | |
| 40 | 14 | m_trueNextItem(0), | |
| 41 | 14 | m_falseNextBranchType(PlaylistBranchType::NoBranch), | |
| 42 | 14 | m_falseNextItem(0), | |
| 43 | 14 | m_nextBranchType(PlaylistBranchType::NoBranch) { | |
| 44 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | LogDebug(VB_PLAYLIST, "PlaylistEntryBranch::PlaylistEntryBranch()\n"); |
| 45 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | m_type = "branch"; |
| 46 | 14 | } | |
| 47 | |||
| 48 | 56 | PlaylistEntryBranch::~PlaylistEntryBranch() { | |
| 49 | 56 | } | |
| 50 | |||
| 51 | 22 | static inline int asInt(Json::Value& v) { | |
| 52 |
2/4✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
|
22 | if (v.isIntegral()) { |
| 53 |
1/2✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
|
22 | return v.asInt(); |
| 54 | } | ||
| 55 | ✗ | std::string s = v.asString(); | |
| 56 | ✗ | return std::atoi(s.c_str()); | |
| 57 | ✗ | } | |
| 58 | |||
| 59 | 28 | static inline PlaylistEntryBase::PlaylistBranchType toBranchType(Json::Value& v) { | |
| 60 |
1/2✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
|
28 | std::string s = v.asString(); |
| 61 |
3/4✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 7 times.
|
28 | if (s == "Index") { |
| 62 | 21 | return PlaylistEntryBase::PlaylistBranchType::Index; | |
| 63 | } | ||
| 64 |
2/4✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
|
7 | if (s == "Playlist") { |
| 65 | ✗ | return PlaylistEntryBase::PlaylistBranchType::Playlist; | |
| 66 | } | ||
| 67 |
3/4✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 6 times.
|
7 | if (s == "Offset") { |
| 68 | 1 | return PlaylistEntryBase::PlaylistBranchType::Offset; | |
| 69 | } | ||
| 70 |
2/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
|
6 | if (s == "None") { |
| 71 | 6 | return PlaylistEntryBase::PlaylistBranchType::NoBranch; | |
| 72 | } | ||
| 73 | ✗ | return PlaylistEntryBase::PlaylistBranchType::Index; | |
| 74 | 28 | } | |
| 75 | /* | ||
| 76 | * | ||
| 77 | */ | ||
| 78 | 14 | int PlaylistEntryBranch::Init(Json::Value& config) { | |
| 79 | 14 | LogDebug(VB_PLAYLIST, "PlaylistEntryBranch::Init()\n"); | |
| 80 | |||
| 81 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | if (config.isMember("trueNextBranchType")) { |
| 82 | 14 | m_trueNextBranchType = toBranchType(config["trueNextBranchType"]); | |
| 83 | } | ||
| 84 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | if (config.isMember("falseNextBranchType")) { |
| 85 | 14 | m_falseNextBranchType = toBranchType(config["falseNextBranchType"]); | |
| 86 | } | ||
| 87 | |||
| 88 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 3 times.
|
14 | if (config.isMember("trueNextSection")) { |
| 89 |
2/4✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
|
11 | m_trueNextSection = config["trueNextSection"].asString(); |
| 90 | } | ||
| 91 | |||
| 92 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2 times.
|
14 | if (config.isMember("trueNextItem")) { |
| 93 | 12 | m_trueNextItem = asInt(config["trueNextItem"]); | |
| 94 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
|
12 | if (m_trueNextBranchType == PlaylistBranchType::Index) { |
| 95 | 11 | m_trueNextItem--; | |
| 96 | } | ||
| 97 | } | ||
| 98 | |||
| 99 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
|
14 | if (config.isMember("trueBranchPlaylist")) { |
| 100 | ✗ | m_trueBranchPlaylist = config["trueBranchPlaylist"].asString(); | |
| 101 | } | ||
| 102 | |||
| 103 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 4 times.
|
14 | if (config.isMember("falseNextSection")) { |
| 104 |
2/4✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
|
10 | m_falseNextSection = config["falseNextSection"].asString(); |
| 105 | } | ||
| 106 | |||
| 107 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 4 times.
|
14 | if (config.isMember("falseNextItem")) { |
| 108 | 10 | m_falseNextItem = asInt(config["falseNextItem"]); | |
| 109 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if (m_falseNextBranchType == PlaylistBranchType::Index) { |
| 110 | 10 | m_falseNextItem--; | |
| 111 | } | ||
| 112 | } | ||
| 113 | |||
| 114 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
|
14 | if (config.isMember("falseBranchPlaylist")) { |
| 115 | ✗ | m_falseBranchPlaylist = config["falseBranchPlaylist"].asString(); | |
| 116 | } | ||
| 117 | |||
| 118 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
|
14 | if (config.isMember("branchType")) |
| 119 | ✗ | m_branchTest = config["branchType"].asString(); | |
| 120 | else | ||
| 121 |
2/4✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
|
14 | m_branchTest = config["branchTest"].asString(); |
| 122 | |||
| 123 |
2/2✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7 times.
|
14 | if (config.isMember("startTime")) { |
| 124 |
2/4✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | m_startTime = config["startTime"].asString(); |
| 125 | |||
| 126 |
3/4✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 6 times.
|
14 | if ((m_startTime != "") && |
| 127 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6 times.
|
7 | !ParseTimeString(m_startTime, m_sHour, m_sMinute, m_sSecond)) { |
| 128 | 1 | LogErr(VB_PLAYLIST, "Invalid branch start time '%s'\n", m_startTime.c_str()); | |
| 129 |
4/8✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
|
2 | WarningHolder::AddWarningTimeout(60, 62, "Playlist branch has an invalid start time '" + m_startTime + "'"); |
| 130 | } | ||
| 131 | } | ||
| 132 | |||
| 133 |
2/2✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7 times.
|
14 | if (config.isMember("endTime")) { |
| 134 |
2/4✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | m_endTime = config["endTime"].asString(); |
| 135 | |||
| 136 |
2/4✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
|
14 | if ((m_endTime != "") && |
| 137 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
|
7 | !ParseTimeString(m_endTime, m_eHour, m_eMinute, m_eSecond)) { |
| 138 | ✗ | LogErr(VB_PLAYLIST, "Invalid branch end time '%s'\n", m_endTime.c_str()); | |
| 139 | ✗ | WarningHolder::AddWarningTimeout(60, 62, "Playlist branch has an invalid end time '" + m_endTime + "'"); | |
| 140 | } | ||
| 141 | } | ||
| 142 | |||
| 143 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11 times.
|
14 | if (config.isMember("iterationStart")) |
| 144 | 3 | m_iterationStart = config["iterationStart"].asInt(); | |
| 145 | |||
| 146 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11 times.
|
14 | if (config.isMember("iterationCount")) { |
| 147 | 3 | m_iterationCount = config["iterationCount"].asInt(); | |
| 148 | |||
| 149 | // The editor enforces a minimum of 1, but playlist JSON also arrives | ||
| 150 | // hand-written and over the API. The Loop test takes curLoop modulo | ||
| 151 | // this, so a 0 here is a SIGFPE the first time the branch is reached. | ||
| 152 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
|
3 | if (m_iterationCount < 1) { |
| 153 | 1 | LogErr(VB_PLAYLIST, "Invalid branch iteration count %d, using 1\n", m_iterationCount); | |
| 154 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
3 | WarningHolder::AddWarningTimeout(60, 62, "Playlist branch has an invalid iteration count"); |
| 155 | 1 | m_iterationCount = 1; | |
| 156 | } | ||
| 157 | } | ||
| 158 | |||
| 159 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
|
14 | if (config.isMember("mqttTopic")) |
| 160 | ✗ | m_mqttTopic = config["mqttTopic"].asString(); | |
| 161 | |||
| 162 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
|
14 | if (config.isMember("mqttMessage")) |
| 163 | ✗ | m_mqttMessage = config["mqttMessage"].asString(); | |
| 164 | |||
| 165 | // compInfo is deprecated and should be removed at some point. The fields | ||
| 166 | // are now parsed from the startTime and endTime string fields. | ||
| 167 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 10 times.
|
14 | if (config.isMember("compInfo")) { |
| 168 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | Json::Value ci = config["compInfo"]; |
| 169 | |||
| 170 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | if (m_branchTest == "Time") { |
| 171 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | if (ci.isMember("startHour")) |
| 172 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | m_sHour = ci["startHour"].asInt(); |
| 173 | |||
| 174 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | if (ci.isMember("startMinute")) |
| 175 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | m_sMinute = ci["startMinute"].asInt(); |
| 176 | |||
| 177 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | if (ci.isMember("startSecond")) |
| 178 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | m_sSecond = ci["startSecond"].asInt(); |
| 179 | |||
| 180 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | if (ci.isMember("endHour")) |
| 181 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | m_eHour = ci["endHour"].asInt(); |
| 182 | |||
| 183 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | if (ci.isMember("endMinute")) |
| 184 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | m_eMinute = ci["endMinute"].asInt(); |
| 185 | |||
| 186 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | if (ci.isMember("endSecond")) |
| 187 |
2/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
4 | m_eSecond = ci["endSecond"].asInt(); |
| 188 | } | ||
| 189 | 4 | } | |
| 190 | |||
| 191 | 14 | m_sHourSecond = (m_sMinute * 60) + m_sSecond; | |
| 192 | 14 | m_eHourSecond = (m_eMinute * 60) + m_eSecond; | |
| 193 | |||
| 194 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 4 times.
|
14 | if (m_sHour >= 0) |
| 195 | 10 | m_sDaySecond = (m_sHour * 3600) + (m_sMinute * 60) + m_sSecond; | |
| 196 | |||
| 197 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2 times.
|
14 | if (m_eHour >= 0) |
| 198 | 12 | m_eDaySecond = (m_eHour * 3600) + (m_eMinute * 60) + m_eSecond; | |
| 199 | |||
| 200 | 14 | return PlaylistEntryBase::Init(config); | |
| 201 | } | ||
| 202 | |||
| 203 | /* | ||
| 204 | * | ||
| 205 | */ | ||
| 206 | 17 | int PlaylistEntryBranch::StartPlaying(void) { | |
| 207 | 17 | LogDebug(VB_PLAYLIST, "PlaylistEntryBranch::StartPlaying()\n"); | |
| 208 | |||
| 209 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
|
17 | if (!CanPlay()) { |
| 210 | ✗ | FinishPlay(); | |
| 211 | ✗ | return 0; | |
| 212 | } | ||
| 213 | 17 | PlaylistEntryBase::StartPlaying(); | |
| 214 | 17 | return 1; | |
| 215 | } | ||
| 216 | 17 | int PlaylistEntryBranch::Process(void) { | |
| 217 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 6 times.
|
17 | if (m_branchTest == "Time") { |
| 218 | 11 | time_t currTime = time(NULL); | |
| 219 | struct tm now; | ||
| 220 | |||
| 221 | 11 | localtime_r(&currTime, &now); | |
| 222 | |||
| 223 | 11 | int daySecond = (now.tm_hour * 3600) + (now.tm_min * 60) + now.tm_sec; | |
| 224 | |||
| 225 |
3/4✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
11 | if ((m_sDaySecond >= 0) && (m_eDaySecond >= 0)) { |
| 226 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4 times.
|
7 | if (m_sDaySecond > m_eDaySecond) { |
| 227 | // The window runs past midnight, e.g. 22:00 to 02:00 | ||
| 228 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
|
3 | if ((daySecond >= m_sDaySecond) || (daySecond < m_eDaySecond)) |
| 229 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | SetNext(1); |
| 230 | else | ||
| 231 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | SetNext(0); |
| 232 |
4/4✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
|
4 | } else if ((daySecond >= m_sDaySecond) && (daySecond < m_eDaySecond)) |
| 233 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | SetNext(1); |
| 234 | else | ||
| 235 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | SetNext(0); |
| 236 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | } else if (m_sDaySecond >= 0) { |
| 237 | ✗ | if (daySecond >= m_sDaySecond) | |
| 238 | ✗ | SetNext(1); | |
| 239 | else | ||
| 240 | ✗ | SetNext(0); | |
| 241 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
|
4 | } else if (m_eDaySecond >= 0) { |
| 242 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (daySecond < m_eDaySecond) |
| 243 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | SetNext(1); |
| 244 | else | ||
| 245 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | SetNext(0); |
| 246 | } else { // Just compare minutes & seconds | ||
| 247 | 2 | int hourSecond = (now.tm_min * 60) + now.tm_sec; | |
| 248 | |||
| 249 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (m_sHourSecond > m_eHourSecond) { |
| 250 | // The window runs past the top of the hour, e.g. :50 to :10 | ||
| 251 |
3/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
|
2 | if ((hourSecond >= m_sHourSecond) || (hourSecond < m_eHourSecond)) |
| 252 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | SetNext(1); |
| 253 | else | ||
| 254 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | SetNext(0); |
| 255 | ✗ | } else if ((hourSecond >= m_sHourSecond) && (hourSecond < m_eHourSecond)) | |
| 256 | ✗ | SetNext(1); | |
| 257 | else | ||
| 258 | ✗ | SetNext(0); | |
| 259 | } | ||
| 260 | |||
| 261 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | LogDebug(VB_PLAYLIST, "Now: %02d:%02d:%02d, Start: %02d:%02d:%02d, End: %02d:%02d:%02d, NS: %s, NI: %d\n", now.tm_hour, now.tm_min, now.tm_sec, m_sHour, m_sMinute, m_sSecond, m_eHour, m_eMinute, m_eSecond, m_nextSection.c_str(), m_nextItem); |
| 262 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | } else if (m_branchTest == "Loop") { |
| 263 | 6 | int curLoop = m_parentPlaylist->GetLoopNumber(); | |
| 264 | |||
| 265 | 6 | LogDebug(VB_PLAYLIST, "Current Loop is %d, we want every %d iteration(s) starting at %d\n", curLoop, m_iterationCount, m_iterationStart); | |
| 266 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
|
6 | if ((curLoop >= m_iterationStart) && |
| 267 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | (((curLoop - m_iterationStart) % m_iterationCount) == 0)) |
| 268 | 4 | SetNext(1); | |
| 269 | else | ||
| 270 | 2 | SetNext(0); | |
| 271 | ✗ | } else if (m_branchTest == "MQTT") { | |
| 272 | ✗ | if ((mqtt) && (mqtt->CacheCheckMessage(m_mqttTopic, m_mqttMessage))) { | |
| 273 | ✗ | SetNext(1); | |
| 274 | } else { | ||
| 275 | ✗ | SetNext(0); | |
| 276 | } | ||
| 277 | } else { | ||
| 278 | ✗ | SetNext(0); | |
| 279 | } | ||
| 280 | |||
| 281 | 17 | FinishPlay(); | |
| 282 | 17 | return 1; | |
| 283 | } | ||
| 284 | |||
| 285 | /* | ||
| 286 | * | ||
| 287 | */ | ||
| 288 | 17 | void PlaylistEntryBranch::SetNext(int isTrue) { | |
| 289 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
|
17 | if (isTrue) { |
| 290 | 9 | m_nextBranchType = m_trueNextBranchType; | |
| 291 | 9 | m_nextSection = m_trueNextSection; | |
| 292 | 9 | m_nextItem = m_trueNextItem; | |
| 293 | 9 | m_nextBranchPlaylist = m_trueBranchPlaylist; | |
| 294 | } else { | ||
| 295 | 8 | m_nextBranchType = m_falseNextBranchType; | |
| 296 | 8 | m_nextSection = m_falseNextSection; | |
| 297 | 8 | m_nextItem = m_falseNextItem; | |
| 298 | 8 | m_nextBranchPlaylist = m_falseBranchPlaylist; | |
| 299 | } | ||
| 300 | |||
| 301 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
|
17 | if (GetNextBranchType() == PlaylistEntryBase::PlaylistBranchType::Playlist) { |
| 302 | ✗ | std::string branchPlaylist = GetNextData(); | |
| 303 | ✗ | if (branchPlaylist != "") { | |
| 304 | ✗ | Player::INSTANCE.InsertPlaylistAsNext(branchPlaylist, 0, -1); | |
| 305 | } | ||
| 306 | ✗ | } | |
| 307 | 17 | } | |
| 308 | |||
| 309 | /* | ||
| 310 | * | ||
| 311 | */ | ||
| 312 | ✗ | void PlaylistEntryBranch::Dump(void) { | |
| 313 | ✗ | PlaylistEntryBase::Dump(); | |
| 314 | |||
| 315 | ✗ | LogDebug(VB_PLAYLIST, "Branch Test : %s\n", m_branchTest.c_str()); | |
| 316 | |||
| 317 | ✗ | if (m_branchTest == "Time") { | |
| 318 | ✗ | LogDebug(VB_PLAYLIST, "Start Time : %s\n", m_startTime.c_str()); | |
| 319 | ✗ | LogDebug(VB_PLAYLIST, "End Time : %s\n", m_endTime.c_str()); | |
| 320 | ✗ | LogDebug(VB_PLAYLIST, "Start Hour : %d\n", m_sHour); | |
| 321 | ✗ | LogDebug(VB_PLAYLIST, "Start Minute : %d\n", m_sMinute); | |
| 322 | ✗ | LogDebug(VB_PLAYLIST, "Start Second : %d\n", m_sSecond); | |
| 323 | ✗ | LogDebug(VB_PLAYLIST, "Start Day Second : %d\n", m_sDaySecond); | |
| 324 | ✗ | LogDebug(VB_PLAYLIST, "Start Hour Second : %d\n", m_sHourSecond); | |
| 325 | ✗ | LogDebug(VB_PLAYLIST, "End Hour : %d\n", m_eHour); | |
| 326 | ✗ | LogDebug(VB_PLAYLIST, "End Minute : %d\n", m_eMinute); | |
| 327 | ✗ | LogDebug(VB_PLAYLIST, "End Second : %d\n", m_eSecond); | |
| 328 | ✗ | LogDebug(VB_PLAYLIST, "End Day Second : %d\n", m_eDaySecond); | |
| 329 | ✗ | LogDebug(VB_PLAYLIST, "End Hour Second : %d\n", m_eHourSecond); | |
| 330 | ✗ | } else if (m_branchTest == "Loop") { | |
| 331 | ✗ | LogDebug(VB_PLAYLIST, "Iteration Start : %d\n", m_iterationStart); | |
| 332 | ✗ | LogDebug(VB_PLAYLIST, "Iteration Count : %d\n", m_iterationCount); | |
| 333 | ✗ | } else if (m_branchTest == "MQTT") { | |
| 334 | ✗ | LogDebug(VB_PLAYLIST, "MQTT Topic : %s\n", m_mqttTopic.c_str()); | |
| 335 | ✗ | LogDebug(VB_PLAYLIST, "MQTT Message : %s\n", m_mqttMessage.c_str()); | |
| 336 | } | ||
| 337 | |||
| 338 | ✗ | switch (m_trueNextBranchType) { | |
| 339 | ✗ | case PlaylistEntryBase::PlaylistBranchType::Index: | |
| 340 | ✗ | LogDebug(VB_PLAYLIST, "True Next Section : %s\n", m_trueNextSection.c_str()); | |
| 341 | ✗ | LogDebug(VB_PLAYLIST, "True Next Item : %d\n", m_trueNextItem); | |
| 342 | ✗ | break; | |
| 343 | ✗ | case PlaylistEntryBase::PlaylistBranchType::Offset: | |
| 344 | ✗ | LogDebug(VB_PLAYLIST, "True Item Offset : %d\n", m_trueNextItem); | |
| 345 | ✗ | break; | |
| 346 | ✗ | case PlaylistEntryBase::PlaylistBranchType::Playlist: | |
| 347 | ✗ | LogDebug(VB_PLAYLIST, "True Branch PList : %s\n", m_trueBranchPlaylist.c_str()); | |
| 348 | ✗ | break; | |
| 349 | ✗ | default: | |
| 350 | ✗ | LogDebug(VB_PLAYLIST, "ERROR Unknown True branch type: %d\n", (int)m_trueNextBranchType); | |
| 351 | ✗ | break; | |
| 352 | } | ||
| 353 | |||
| 354 | ✗ | switch (m_falseNextBranchType) { | |
| 355 | ✗ | case PlaylistEntryBase::PlaylistBranchType::Index: | |
| 356 | ✗ | LogDebug(VB_PLAYLIST, "False Next Section: %s\n", m_falseNextSection.c_str()); | |
| 357 | ✗ | LogDebug(VB_PLAYLIST, "False Next Item : %d\n", m_falseNextItem); | |
| 358 | ✗ | break; | |
| 359 | ✗ | case PlaylistEntryBase::PlaylistBranchType::Offset: | |
| 360 | ✗ | LogDebug(VB_PLAYLIST, "False Item Offset : %d\n", m_falseNextItem); | |
| 361 | ✗ | break; | |
| 362 | ✗ | case PlaylistEntryBase::PlaylistBranchType::Playlist: | |
| 363 | ✗ | LogDebug(VB_PLAYLIST, "False Branch PList: %s\n", m_falseBranchPlaylist.c_str()); | |
| 364 | ✗ | break; | |
| 365 | ✗ | default: | |
| 366 | ✗ | LogDebug(VB_PLAYLIST, "ERROR Unknown False branch type: %d\n", (int)m_falseNextBranchType); | |
| 367 | ✗ | break; | |
| 368 | } | ||
| 369 | ✗ | } | |
| 370 | |||
| 371 | /* | ||
| 372 | * | ||
| 373 | */ | ||
| 374 | 34 | Json::Value PlaylistEntryBranch::GetConfig(void) { | |
| 375 | 34 | Json::Value result = PlaylistEntryBase::GetConfig(); | |
| 376 | |||
| 377 |
2/4✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
|
34 | result["branchTest"] = m_branchTest; |
| 378 |
3/4✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 20 times.
|
34 | if (m_startTime != "") { |
| 379 |
2/4✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
|
14 | result["startTime"] = m_startTime; |
| 380 | } else { | ||
| 381 | char timeStr[9]; | ||
| 382 | 20 | snprintf(timeStr, 9, "%02d:%02d:%02d", m_sHour, m_sMinute, m_sSecond); | |
| 383 |
2/4✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
|
20 | result["startTime"] = timeStr; |
| 384 | } | ||
| 385 | |||
| 386 |
3/4✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 20 times.
|
34 | if (m_endTime != "") { |
| 387 |
2/4✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
|
14 | result["endTime"] = m_endTime; |
| 388 | } else { | ||
| 389 | char timeStr[9]; | ||
| 390 | 20 | snprintf(timeStr, 9, "%02d:%02d:%02d", m_eHour, m_eMinute, m_eSecond); | |
| 391 |
2/4✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
|
20 | result["endTime"] = timeStr; |
| 392 | } | ||
| 393 | |||
| 394 | 34 | return result; | |
| 395 | ✗ | } | |
| 396 |