-
Notifications
You must be signed in to change notification settings - Fork 3
/
eit.hpp
72 lines (58 loc) · 1.49 KB
/
eit.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef _TSD_EIT_HPP_
#define _TSD_EIT_HPP_
#include "util.hpp"
#include "descriptor.hpp"
#include "aribtime.hpp"
namespace tsd
{
struct event_information_table
{
struct event
{
uint16_t event_id;
aribtime start_time;
aribduration duration;
uint8_t running_status;
uint8_t free_ca_mode;
std::vector<descriptor> descriptors;
};
uint16_t transport_stream_id;
uint16_t original_network_id;
uint8_t segment_last_section_number;
uint8_t last_table_id;
std::vector<event> events;
void unpack(const char* data, size_t size) {
const uint8_t* p = reinterpret_cast<const uint8_t*>(data);
const uint8_t* pend = p+size;
events.clear();
transport_stream_id = get16(p);
p += 2;
original_network_id = get16(p);
p += 2;
segment_last_section_number = get8(p);
p += 1;
last_table_id = get8(p);
p += 1;
while(pend - p > 4) {
events.resize(events.size()+1);
auto& e = events.back();
e.event_id = get16(p);
p += 2;
e.start_time.unpack(&p, pend);
e.duration.unpack(&p, pend);
e.running_status = get8(p) >> 5;
e.free_ca_mode = (get8(p) >> 4) & 0x01;
size_t loop_length = get16(p) & 0x0FFF;
p += 2;
const uint8_t* ploop_end = p + loop_length;
if(pend - p - 4 < loop_length)
std::runtime_error("");
while(p < ploop_end) {
e.descriptors.resize(e.descriptors.size()+1);
e.descriptors.back().unpack(&p, ploop_end);
}
}
}
};
}
#endif