1 #include "newpacket.hpp"
14 input(const std::string
& name
)
22 if(!curpacket
&& !eof
) {
23 curpacket
= rchan
.read();
40 struct packet
* first_of_inputs(std::list
<input
*>& rchans
)
42 struct packet
* f
= NULL
;
43 std::list
<input
*>::iterator j
= rchans
.begin();
44 for(std::list
<input
*>::iterator i
= rchans
.begin(); i
!= rchans
.end(); ++i
) {
45 struct packet
* g
= (*i
)->peek_packet();
46 if(g
&& (!f
|| g
->rp_timestamp
< f
->rp_timestamp
)) {
51 (*j
)->discard_packet();
55 int real_main(int argc
, char** argv
)
57 std::list
<input
*> rchans
;
58 std::map
<std::string
, uint16_t> channel_assignments
;
59 std::vector
<struct channel
> chans
;
61 std::cerr
<< "syntax: muxdump.exe <input>... <output>" << std::endl
;
65 write_channel
wchan(argv
[argc
- 1]);
66 for(int i
= 1; i
< argc
- 1; i
++)
67 rchans
.push_back(new input(argv
[i
]));
70 while((p
= first_of_inputs(rchans
))) {
71 if(!channel_assignments
.count(p
->rp_channel_name
)) {
72 //No channel yet, create.
73 channel_assignments
[p
->rp_channel_name
] = (uint16_t)chans
.size();
75 c
.c_channel
= (uint16_t)chans
.size();
76 c
.c_type
= p
->rp_major
;
77 c
.c_channel_name
= p
->rp_channel_name
;
79 wchan
.start_segment(chans
);
81 uint16_t chan
= channel_assignments
[p
->rp_channel_name
];
82 if(chans
[chan
].c_type
!= p
->rp_major
) {
84 chans
[chan
].c_type
= p
->rp_major
;
85 wchan
.start_segment(chans
);
92 for(std::list
<input
*>::iterator i
= rchans
.begin(); i
!= rchans
.end(); ++i
)