#include "environment/Version.hpp"
#include "MediaUtils.hpp"
#include <cmath>
#include <map>
#include <string>
namespace libobsensor {
namespace utils {
double getBagFileVersion() {
constexpr int ver = OB_LIB_VERSION;
static const std::pair<int, double> versionMap[] = {
{ 20405, 2.1 }, { 20400, 2.0 }, { 0, 1.0 } };
for(auto &p: versionMap) {
if(ver >= p.first) {
return p.second;
}
}
return 1.0;
}
bool validateBagFileVersion(double recordedVersion) {
double currentVersion = getBagFileVersion();
int currentMajor = static_cast<int>(std::floor(currentVersion));
int recordMajor = static_cast<int>(std::floor(recordedVersion));
return currentMajor == recordMajor;
}
std::string createUnsupportedBagFileVersionMessage(double recordedVersion) {
int recordMajor = static_cast<int>(std::floor(recordedVersion));
std::string message = "Unsupported bag file version: ";
if (recordMajor < 2) {
message += "Please use lower version of OrbbecSDK, or re-record the bag file using a newer version of the SDK.";
}
else {
message += "unknown error.";
}
return message;
}
} }