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
Branches
Tags
No related merge requests found
...@@ -73,6 +73,7 @@ class File : public Stream { ...@@ -73,6 +73,7 @@ class File : public Stream {
int version_; int version_;
ftl::timer::TimerHandle timer_; ftl::timer::TimerHandle timer_;
bool is_video_; bool is_video_;
bool save_data_;
StreamCallback cb_; StreamCallback cb_;
MUTEX mutex_; MUTEX mutex_;
......
...@@ -14,18 +14,29 @@ File::File(nlohmann::json &config) : Stream(config), ostream_(nullptr), istream_ ...@@ -14,18 +14,29 @@ File::File(nlohmann::json &config) : Stream(config), ostream_(nullptr), istream_
mode_ = Mode::Read; mode_ = Mode::Read;
jobs_ = 0; jobs_ = 0;
checked_ = false; 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) { File::File(nlohmann::json &config, std::ifstream *is) : Stream(config), ostream_(nullptr), istream_(is), active_(false) {
mode_ = Mode::Read; mode_ = Mode::Read;
jobs_ = 0; jobs_ = 0;
checked_ = false; checked_ = false;
save_data_ = false;
} }
File::File(nlohmann::json &config, std::ofstream *os) : Stream(config), ostream_(os), istream_(nullptr), active_(false) { File::File(nlohmann::json &config, std::ofstream *os) : Stream(config), ostream_(os), istream_(nullptr), active_(false) {
mode_ = Mode::Write; mode_ = Mode::Write;
jobs_ = 0; jobs_ = 0;
checked_ = false; 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() { File::~File() {
...@@ -102,7 +113,7 @@ bool File::post(const ftl::codecs::StreamPacket &s, const ftl::codecs::Packet &p ...@@ -102,7 +113,7 @@ bool File::post(const ftl::codecs::StreamPacket &s, const ftl::codecs::Packet &p
// Discard all data channel packets for now // Discard all data channel packets for now
// TODO: Allow saving of data channels once formats have solidified. // 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; ftl::codecs::StreamPacket s2 = s;
// Adjust timestamp relative to start of file. // 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