Skip to content

Commit

Permalink
add function to return last data record timestamp
Browse files Browse the repository at this point in the history
Summary:
analagous to getFirstDataRecordTime()

this is useful for testing purpose when, for example, writing a tool that translates timestamps

Reviewed By: georges-berenger

Differential Revision: D67035162

fbshipit-source-id: 200a678939d0a7a8ef8dec62cbbf06e716c70dc2
  • Loading branch information
Daniel James authored and facebook-github-bot committed Dec 13, 2024
1 parent 694aefa commit 3054451
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions tools/vrs/test/VrsAppTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ TEST_F(VrsAppTest, ANDROID_DISABLED(mergeTimeFilterTest)) {
// Data records are constrained by the +0.2 range
EXPECT_NEAR(reader.getFirstDataRecordTime(), 2.002, 0.0001);
EXPECT_NEAR(reader.getIndex().back().timestamp, 12.071, 0.0001);
EXPECT_NEAR(reader.getLastDataRecordTime(), 12.071, 0.0001);

remove(outputFile.c_str());
}
Expand Down
9 changes: 9 additions & 0 deletions vrs/RecordFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,15 @@ double RecordFileReader::getFirstDataRecordTime() const {
return 0; // no data record...
}

double RecordFileReader::getLastDataRecordTime() const {
for (auto iter = recordIndex_.rbegin(); iter != recordIndex_.rend(); ++iter) {
if (iter->recordType == Record::Type::DATA) {
return iter->timestamp;
}
}
return 0;
}

bool RecordFileReader::readConfigRecords(
const set<const IndexRecord::RecordInfo*>& configRecords,
StreamPlayer* streamPlayer) {
Expand Down
4 changes: 4 additions & 0 deletions vrs/RecordFileReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ class RecordFileReader {
/// @return The timestamp for the file data record, or 0, if the file contains no data record.
double getFirstDataRecordTime() const;

/// Timestamp for the last data record in the whole file.
/// @return The timestamp for the file data record, or 0, if the file contains no data record.
double getLastDataRecordTime() const;

/// Helper function: Read a stream's first configuration record.
/// This might be necessary to properly read records containing image or audio blocks,
/// if their configuration is defined in a configuration record using datalayout conventions.
Expand Down

0 comments on commit 3054451

Please sign in to comment.