MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / buildFrameIndex

Method buildFrameIndex

app/src/MDF4/Player.cpp:848–904  ·  view source on GitHub ↗

* @brief Builds a sparse frame index for efficient streaming playback. */

Source from the content-addressed store, hash-verified

846 * @brief Builds a sparse frame index for efficient streaming playback.
847 */
848void MDF4::Player::buildFrameIndex()
849{
850 m_frameIndex.clear();
851 m_channels.clear();
852 m_sampleCache.clear();
853 m_stringCache.clear();
854 m_timestampCache.clear();
855 m_activeChannels.clear();
856 m_channelIsString.clear();
857 m_masterTimeChannel = nullptr;
858
859 if (!m_reader || !m_reader->IsOk())
860 return;
861
862 auto* file = m_reader->GetFile();
863 if (!file)
864 return;
865
866 mdf::DataGroupList dataGroups;
867 file->DataGroups(dataGroups);
868
869 if (dataGroups.empty())
870 return;
871
872 std::vector<mdf::IChannel*> allChannels;
873 std::map<mdf::IChannelGroup*, mdf::IChannel*> groupTimeChannels;
874 int masterChannelCount = 0;
875 collectAllChannels(dataGroups, allChannels, groupTimeChannels, masterChannelCount);
876
877 const bool perGroupTime = (masterChannelCount > 1);
878 uint64_t legacyTimeRecId = 0;
879 if (masterChannelCount == 1) {
880 auto it = groupTimeChannels.begin();
881 m_masterTimeChannel = it->second;
882 legacyTimeRecId = it->first->RecordId();
883 groupTimeChannels.clear();
884 }
885
886 m_channels = allChannels;
887
888 m_channelIsString.clear();
889 m_channelIsString.reserve(m_channels.size());
890 for (const auto* ch : m_channels)
891 m_channelIsString.push_back(isStringChannel(ch));
892
893 for (auto* dg : dataGroups) {
894 if (!dg)
895 continue;
896
897 readDataGroupWithObservers(dg, perGroupTime, groupTimeChannels);
898 }
899
900 if (m_isSerialStudioFile && !perGroupTime && m_masterTimeChannel)
901 readLegacyTimestamps(dataGroups, legacyTimeRecId);
902
903 buildFrameIndexFromCache();
904}
905

Callers

nothing calls this directly

Calls 9

isStringChannelFunction · 0.85
emptyMethod · 0.80
beginMethod · 0.80
clearMethod · 0.45
IsOkMethod · 0.45
GetFileMethod · 0.45
DataGroupsMethod · 0.45
RecordIdMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected