Skip to content
Snippets Groups Projects
Commit 87d660a3 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Optional data save in file streams

parent 1d8c7687
No related branches found
No related tags found
No related merge requests found
......@@ -73,6 +73,7 @@ class File : public Stream {
int version_;
ftl::timer::TimerHandle timer_;
bool is_video_;
bool save_data_;
StreamCallback cb_;
MUTEX mutex_;
......
......@@ -14,18 +14,29 @@ File::File(nlohmann::json &config) : Stream(config), ostream_(nullptr), istream_
mode_ = Mode::Read;
jobs_ = 0;
checked_ = false;
save_data_ = value("save_data", false);
on("save_data", [this](const ftl::config::Event &e) {
save_data_ = value("save_data", false);
});
}
File::File(nlohmann::json &config, std::ifstream *is) : Stream(config), ostream_(nullptr), istream_(is), active_(false) {
mode_ = Mode::Read;
jobs_ = 0;
checked_ = false;
save_data_ = false;
}
File::File(nlohmann::json &config, std::ofstream *os) : Stream(config), ostream_(os), istream_(nullptr), active_(false) {
mode_ = Mode::Write;
jobs_ = 0;
checked_ = false;
save_data_ = value("save_data", false);
on("save_data", [this](const ftl::config::Event &e) {
save_data_ = value("save_data", false);
});
}
File::~File() {
......@@ -102,7 +113,7 @@ bool File::post(const ftl::codecs::StreamPacket &s, const ftl::codecs::Packet &p
// Discard all data channel packets for now
// TODO: Allow saving of data channels once formats have solidified.
if (static_cast<int>(s.channel) >= static_cast<int>(ftl::codecs::Channel::Data)) return true;
if (!save_data_ && static_cast<int>(s.channel) >= static_cast<int>(ftl::codecs::Channel::Data)) return true;
ftl::codecs::StreamPacket s2 = s;
// Adjust timestamp relative to start of file.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment