Skip to content

Commit d40e96c

Browse files
committed
Add human readable content nibble
1 parent f5125f4 commit d40e96c

File tree

2 files changed

+120
-1
lines changed

2 files changed

+120
-1
lines changed

src/Descriptors/Content.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
namespace PhpBg\DvbPsi\Descriptors;
2828

29+
use PhpBg\DvbPsi\Descriptors\Values\ContentNibble;
30+
2931
/**
3032
* Class Content
3133
* @see Final draft ETSI EN 300 468 V1.13.1 (2012-04), 6.2.9 Content descriptor
@@ -52,8 +54,11 @@ public function __toString()
5254
{
5355
$msg = "Content:\n";
5456
foreach ($this->nibbles as $nibble) {
55-
// TODO human decode levels
5657
$msg .= sprintf("Level1: 0x%x, Level2: 0x%x, User byte:0x%x\n", $nibble[0], $nibble[1], $nibble[2]);
58+
59+
if (isset(ContentNibble::NIBBLES[$nibble[0]][$nibble[1]])) {
60+
$msg .= sprintf("\t%s\n", ContentNibble::NIBBLES[$nibble[0]][$nibble[1]]);
61+
}
5762
}
5863
return $msg;
5964
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<?php
2+
3+
4+
namespace PhpBg\DvbPsi\Descriptors\Values;
5+
6+
7+
class ContentNibble
8+
{
9+
const NIBBLES = [
10+
0x1 => [
11+
0x0 => "movie/drama",
12+
0x1 => "detective/thriller",
13+
0x2 => "adventure/western/war",
14+
0x3 => "science fiction/fantasy/horror",
15+
0x4 => "comedy",
16+
0x5 => "soap/melodrama/folkloric",
17+
0x6 => "romance",
18+
0x7 => "serious/classical/religious/historical movie/drama",
19+
0x8 => "adult movie/drama",
20+
],
21+
0x2 => [
22+
0x0 => "news/current affairs",
23+
0x1 => "news/weather report",
24+
0x2 => "news magazine",
25+
0x3 => "documentary",
26+
0x4 => "discussion/interview/debate",
27+
],
28+
0x3 => [
29+
0x0 => "show/game show",
30+
0x1 => "game show/quiz/contest",
31+
0x2 => "variety show",
32+
0x3 => "talk show",
33+
],
34+
0x4 => [
35+
0x0 => "sports",
36+
0x1 => "special events", //(Olympic Games, World Cup, etc.)
37+
0x2 => "sports magazines",
38+
0x3 => "football/soccer",
39+
0x4 => "tennis/squash",
40+
0x5 => "team sports", //(excluding football)
41+
0x6 => "athletics",
42+
0x7 => "motor sport",
43+
0x8 => "water sport",
44+
0x9 => "winter sports",
45+
0xA => "equestrian",
46+
0xB => "martial sports",
47+
],
48+
0x5 => [
49+
0x0 => "children's/youth programmes",
50+
0x1 => "pre-school children's programmes",
51+
0x2 => "entertainment programmes for 6 to14",
52+
0x3 => "entertainment programmes for 10 to 16",
53+
0x4 => "informational/educational/school programmes",
54+
0x5 => "cartoons/puppets",
55+
],
56+
0x6 => [
57+
0x0 => "music/ballet/dance",
58+
0x1 => "rock/pop",
59+
0x2 => "serious music/classical music",
60+
0x3 => "folk/traditional music",
61+
0x4 => "jazz",
62+
0x5 => "musical/opera",
63+
0x6 => "ballet",
64+
],
65+
0x7 => [
66+
0x0 => "arts/culture", //(without music, general)
67+
0x1 => "performing arts",
68+
0x2 => "fine arts",
69+
0x3 => "religion",
70+
0x4 => "popular culture/traditional arts",
71+
0x5 => "literature",
72+
0x6 => "film/cinema",
73+
0x7 => "experimental film/video",
74+
0x8 => "broadcasting/press",
75+
0x9 => "new media",
76+
0xA => "arts/culture magazines",
77+
0xB => "fashion",
78+
],
79+
0x8 => [
80+
0x0 => "social/political issues/economics",
81+
0x1 => "magazines/reports/documentary",
82+
0x2 => "economics/social advisory",
83+
0x3 => "remarkable people",
84+
],
85+
0x9 => [
86+
0x0 => "education/science/factual topics",
87+
0x1 => "nature/animals/environment",
88+
0x2 => "technology/natural sciences",
89+
0x3 => "medicine/physiology/psychology",
90+
0x4 => "foreign countries/expeditions",
91+
0x5 => "social/spiritual sciences",
92+
0x6 => "further education",
93+
0x7 => "languages",
94+
],
95+
0xA => [
96+
0x0 => "leisure hobbies",
97+
0x1 => "tourism/travel",
98+
0x2 => "handicraft",
99+
0x3 => "motoring",
100+
0x4 => "fitness and health",
101+
0x5 => "cooking",
102+
0x6 => "advertisement/shopping",
103+
0x7 => "gardening",
104+
],
105+
0xB => [
106+
0x0 => "original language",
107+
0x1 => "black and white",
108+
0x2 => "unpublished",
109+
0x3 => "live broadcast",
110+
0x4 => "plano-stereoscopic",
111+
0x5 => "local or regional",
112+
],
113+
];
114+
}

0 commit comments

Comments
 (0)