forked from berolinaro/dvbv5-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServiceListDescriptor.h
52 lines (51 loc) · 1.21 KB
/
ServiceListDescriptor.h
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
#pragma once
#include "DVBDescriptor.h"
#include "ServiceType.h"
#include <map>
#include <cstdint>
class ServiceListDescriptor:public DVBDescriptor {
public:
ServiceListDescriptor(DVBDescriptor * const d):DVBDescriptor(d) {
}
std::map<uint16_t,ServiceType> services() const {
std::map<uint16_t,ServiceType> ret;
uint8_t *pos=_data, *end=_data+_length;
while(pos<end) {
ret.insert(std::make_pair<uint16_t,ServiceType>((pos[0]<<8)|pos[1], static_cast<ServiceType>(pos[2])));
pos += 3;
}
return ret;
}
void dump(std::ostream &where=std::cerr, std::string const &indent="") const override {
where << indent << "Service List Descriptor:" << std::endl;
for(auto const &a: services()) {
where << indent << "\t" << "Service ID " << a.first << " is a ";
switch(a.second) {
case 0x1:
where << "TV";
break;
case 0x2:
where << "Radio";
break;
case 0x7:
where << "FM Radio";
break;
case 0x11:
where << "MPEG-2 HD TV";
break;
case 0x16:
where << "H.264 SD TV";
break;
case 0x19:
where << "H.264 HD TV";
break;
case 0x1f:
where << "HEVC TV";
break;
default:
where << static_cast<int>(_data[0]);
}
where << std::endl;
}
}
};