diff --git a/applications/merger/src/main.cpp b/applications/merger/src/main.cpp index 42c862b6ecada27be254c4677259144c9ee1c4a6..e0abb65efd4b3d911dafe185a1497d82bb9247d4 100644 --- a/applications/merger/src/main.cpp +++ b/applications/merger/src/main.cpp @@ -13,6 +13,9 @@ int main(int argc, char **argv) { std::string outputfile = root->value("out", std::string("output.ftl")); std::vector<std::string> paths = *root->get<std::vector<std::string>>("paths"); + int timeoff = int(root->value("offset", 0.0f) * 1000.0f); + int stream_mask1 = root->value("mask1",0xFF); + int stream_mask2 = root->value("mask2",0xFF); if (paths.size() == 0) { LOG(ERROR) << "Missing input ftl file(s)."; @@ -52,8 +55,8 @@ int main(int argc, char **argv) { std::map<int,int> idmap; int lastid = 0; - bool res = rs[0]->read(90000000000000, [&rs,&out,&idmap,&lastid](const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt) { - if (spkt.streamID > 0) return; + bool res = rs[0]->read(90000000000000, [&rs,&out,&idmap,&lastid,stream_mask1,stream_mask2,timeoff](const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt) { + if (((0x1 << spkt.streamID) & stream_mask1) == 0) return; ftl::codecs::StreamPacket spkt2 = spkt; if (idmap.find(spkt.streamID) == idmap.end()) { @@ -66,16 +69,16 @@ int main(int argc, char **argv) { for (size_t j=1; j<rs.size(); ++j) { ftl::codecs::Reader *r = rs[j]; - rs[j]->read(spkt.timestamp+1000, [&out,&idmap,&lastid,j,r](const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt) { - if (spkt.streamID > 0) return; - if (int(spkt.channel) < 32 && spkt.timestamp < r->getStartTime()+1000) return; + rs[j]->read(spkt.timestamp+timeoff, [&out,&idmap,&lastid,j,r,stream_mask2,timeoff](const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt) { + if (((0x1 << spkt.streamID) & stream_mask2) == 0) return; + if (int(spkt.channel) < 32 && spkt.timestamp < r->getStartTime()+timeoff) return; ftl::codecs::StreamPacket spkt2 = spkt; if (idmap.find(spkt.streamID + (j << 16)) == idmap.end()) { idmap[spkt.streamID+(j << 16)] = lastid++; } spkt2.streamID = idmap[spkt.streamID + (j << 16)]; - spkt2.timestamp -= 1000; + spkt2.timestamp -= timeoff; out.write(spkt2, pkt); });