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

Only stream on change and fix mult pack send

parent c7379466
No related branches found
No related tags found
1 merge request!316Resolves #343 GUI and Frame Refactor
Pipeline #28409 canceled
......@@ -826,7 +826,7 @@ void Feed::_beginRecord(Filter *f) {
record_stream_->select(fs->frameset(), f->channels(), true);
for (auto c : f->channels()) {
recorder_->post(*fs.get(), c);
if (fs->hasAnyChanged(c)) recorder_->post(*fs.get(), c);
}
return true;
});
......
......@@ -173,11 +173,12 @@ void Sender::post(ftl::data::FrameSet &fs, ftl::codecs::Channel c, bool noencode
const auto &packets = frame.getEncoded(cc);
if (packets.size() > 0) {
if (packets.size() == 1) {
forward_count += packets.front().frame_count;
} else {
// PROBLEMS
LOG(WARNING) << "Multi packet send!";
LOG(WARNING) << "Multi packet send! - Channel = " << int(c) << ", count = " << packets.size();
}
forward_count += packets.back().frame_count;
}
} else {
needs_encoding = false;
......@@ -200,7 +201,7 @@ void Sender::post(ftl::data::FrameSet &fs, ftl::codecs::Channel c, bool noencode
if (!frame.has(c)) continue;
const auto &packets = frame.getEncoded(c);
if (packets.size() == 1) {
//if (packets.size() == 1) {
StreamPacket spkt;
spkt.version = 5;
spkt.timestamp = fs.timestamp();
......@@ -209,10 +210,10 @@ void Sender::post(ftl::data::FrameSet &fs, ftl::codecs::Channel c, bool noencode
spkt.channel = c;
spkt.flags = (last_flush) ? ftl::codecs::kFlagCompleted : 0;
stream_->post(spkt, packets.front());
} else if (packets.size() > 1) {
stream_->post(spkt, packets.back());
//} else if (packets.size() > 1) {
// PROBLEMS
}
//}
}
}
......
......@@ -125,6 +125,11 @@ class FrameSet : public ftl::data::Frame {
*/
static std::shared_ptr<FrameSet> fromFrame(Frame &);
/**
* Check if channel has changed in any frames.
*/
bool hasAnyChanged(ftl::codecs::Channel) const;
private:
std::atomic<int> flags_;
};
......
......@@ -83,6 +83,13 @@ const ftl::data::Frame &ftl::data::FrameSet::firstFrame() const {
throw FTL_Error("No frames in frameset");
}
bool ftl::data::FrameSet::hasAnyChanged(ftl::codecs::Channel c) const {
for (size_t i=0; i<frames.size(); ++i) {
if (frames[i].changed(c)) return true;
}
return false;
}
void FrameSet::store() {
if (status() != ftl::data::FrameStatus::CREATED) throw FTL_Error("Cannot store frameset multiple times");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment