* @brief Injects an MDF4 frame through the appropriate pipeline path. */
| 1111 | * @brief Injects an MDF4 frame through the appropriate pipeline path. |
| 1112 | */ |
| 1113 | void MDF4::Player::injectFrame(const QByteArray& frame, int frameIndex) |
| 1114 | { |
| 1115 | if (frame.isEmpty()) |
| 1116 | return; |
| 1117 | |
| 1118 | if (!m_multiSource) { |
| 1119 | IO::ConnectionManager::instance().processPayload(frame); |
| 1120 | return; |
| 1121 | } |
| 1122 | |
| 1123 | const std::vector<bool>* active = nullptr; |
| 1124 | if (frameIndex >= 0 && frameIndex < static_cast<int>(m_frameIndex.size())) { |
| 1125 | auto ait = m_activeChannels.find(m_frameIndex[frameIndex].recordIndex); |
| 1126 | if (ait != m_activeChannels.end()) |
| 1127 | active = &ait->second; |
| 1128 | } |
| 1129 | |
| 1130 | const QString row = QString::fromUtf8(frame).trimmed(); |
| 1131 | const auto fields = DataModel::splitReplayRow(row); |
| 1132 | |
| 1133 | QMap<int, QStringList> sourceFields; |
| 1134 | QMap<int, bool> sourceHasActive; |
| 1135 | for (auto it = m_sourceChannelsByIndex.constBegin(); it != m_sourceChannelsByIndex.constEnd(); |
| 1136 | ++it) { |
| 1137 | const int srcId = it.key(); |
| 1138 | const auto& orderedChs = it.value(); |
| 1139 | QStringList orderedCells; |
| 1140 | orderedCells.reserve(orderedChs.size()); |
| 1141 | bool anyActive = !active; |
| 1142 | for (int ch : orderedChs) { |
| 1143 | const QString cell = (ch >= 0 && ch < fields.size()) ? fields[ch] : QString(); |
| 1144 | orderedCells.append(cell); |
| 1145 | if (active && ch >= 0 && ch < static_cast<int>(active->size()) && (*active)[ch]) |
| 1146 | anyActive = true; |
| 1147 | } |
| 1148 | sourceFields.insert(srcId, std::move(orderedCells)); |
| 1149 | sourceHasActive.insert(srcId, anyActive); |
| 1150 | } |
| 1151 | |
| 1152 | QMap<int, QByteArray> sourcePayloads; |
| 1153 | for (auto it = sourceFields.constBegin(); it != sourceFields.constEnd(); ++it) { |
| 1154 | if (!sourceHasActive.value(it.key(), true)) |
| 1155 | continue; |
| 1156 | |
| 1157 | sourcePayloads[it.key()] = DataModel::joinReplayRow(it.value()) + '\n'; |
| 1158 | } |
| 1159 | |
| 1160 | if (!sourcePayloads.isEmpty()) |
| 1161 | IO::ConnectionManager::instance().processMultiSourcePayload(frame, sourcePayloads); |
| 1162 | } |
| 1163 | |
| 1164 | //-------------------------------------------------------------------------------------------------- |
| 1165 | // Event handling |
nothing calls this directly
no test coverage detected