forked from berolinaro/dvbv5-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServiceDescriptor.h
69 lines (68 loc) · 1.59 KB
/
ServiceDescriptor.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#pragma once
#include "DVBDescriptor.h"
#include "ServiceType.h"
#include <string>
#include <cstring>
#include <bitset>
#include <iostream>
#include <cassert>
#include "Util.h"
class ServiceDescriptor:public DVBDescriptor {
public:
ServiceDescriptor(DVBDescriptor * const d):DVBDescriptor(d) {
}
ServiceType serviceType() const {
return static_cast<ServiceType>(_data[0]);
}
bool isTV() const {
return (serviceType() == TV) ||
(serviceType() == MPEG2HDTV) ||
(serviceType() == H264TV) ||
(serviceType() == H264HDTV) ||
(serviceType() == H2643DHDTV) ||
(serviceType() == HEVCTV);
}
bool isRadio() const {
return (serviceType() == Radio) ||
(serviceType() == ACRadio);
}
std::string provider() const {
return Util::StringFromDVB(_data+1);
}
std::string name() const {
assert(_data);
unsigned char const *pos = _data + _data[1] + 2;
return Util::StringFromDVB(pos);
}
void dump(std::ostream &where=std::cerr, std::string const &indent="") const override {
where << indent << "Service type: ";
switch(_data[0]) {
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;
where << indent << "Provider name: " << provider() << std::endl;
where << indent << "Name: " << name() << std::endl;
}
};