streamtools: refactor output/scaler drivers to their own directories
[jpcrr.git] / streamtools / newpacket.hpp
blobfe408d1b311a5887bfb90430b4991f8835dd35e5
1 #ifndef _newpacket__hpp__included__
2 #define _newpacket__hpp__included__
4 #include <vector>
5 #include <stdint.h>
6 #include <cstdlib>
7 #include <string>
8 #include <map>
10 struct packet
12 uint16_t rp_channel; //Channel number.
13 uint32_t rp_channel_perm; //Pemanent channel number. Not used when writing.
14 std::string rp_channel_name; //Channel name. Not used when writing.
15 uint16_t rp_major; //Major type. Not used when writing.
16 uint8_t rp_minor; //Minor type.
17 uint64_t rp_timestamp; //Timestamp in nanoseconds.
18 std::vector<unsigned char> rp_payload; //Payload.
21 struct channel
23 uint16_t c_channel; //Channel number.
24 uint32_t c_channel_perm; //Channel permanent number. Not used when writing.
25 uint16_t c_type; //Channel type.
26 std::string c_channel_name; //Channel name.
29 class read_channel
31 public:
32 read_channel(const std::string& filename);
33 ~read_channel();
34 uint32_t number_for_channel(const std::string& name);
35 struct packet* read();
36 private:
37 read_channel(const read_channel& x);
38 read_channel& operator=(const read_channel& x);
40 FILE* rc_stream;
41 std::vector<channel> rc_channels;
42 uint64_t rc_last_timestamp;
43 bool rc_eof_flag;
44 bool rc_segmenttable_coming;
45 uint32_t rc_next_permchan;
46 std::map<std::string, uint32_t> rc_permchans;
49 class write_channel
51 public:
52 write_channel(const std::string& filename);
53 ~write_channel();
54 void start_segment(const std::vector<channel>& channels);
55 void write(struct packet& p);
56 private:
57 write_channel(const write_channel& x);
58 write_channel& operator=(const write_channel& x);
60 FILE* wc_stream;
61 std::vector<channel> wc_channels;
62 uint64_t wc_last_timestamp;
65 #endif