line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
package TV::Humax::Foxsat::hmt_data; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
TV::Humax::Foxsat::hmt_data - Package representing Humax file metadata |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
version 0.06 |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
535141
|
use namespace::autoclean; |
|
2
|
|
|
|
|
560032
|
|
|
2
|
|
|
|
|
13
|
|
15
|
2
|
|
|
2
|
|
225997
|
use DateTime; |
|
2
|
|
|
|
|
1944710
|
|
|
2
|
|
|
|
|
88
|
|
16
|
2
|
|
|
2
|
|
1112
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use Moose::Util::TypeConstraints; |
18
|
|
|
|
|
|
|
use TV::Humax::Foxsat::epg_data; |
19
|
|
|
|
|
|
|
use TV::Humax::Foxsat; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.06'; # VERSION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use Trait::Attribute::Derived Unpack => { |
24
|
|
|
|
|
|
|
source => 'rawDataBlock', |
25
|
|
|
|
|
|
|
fields => { 'unpacker' => 'Str' }, |
26
|
|
|
|
|
|
|
processor => sub { |
27
|
|
|
|
|
|
|
my ($self, $value, $fields) = @_; |
28
|
|
|
|
|
|
|
defined $value or die "Error rawDataBlock not defined"; |
29
|
|
|
|
|
|
|
return unpack( $fields->{'unpacker' }, $value) |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# The raw data that all the fields are extracted from. |
34
|
|
|
|
|
|
|
has 'rawDataBlock' => ( |
35
|
|
|
|
|
|
|
is => 'rw', |
36
|
|
|
|
|
|
|
isa => 'Str', |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# For field documentation see: http://foxsatdisk.wikispaces.com/.hmt+file+format |
40
|
|
|
|
|
|
|
has 'lastPlay' => ( |
41
|
|
|
|
|
|
|
is => 'rw', |
42
|
|
|
|
|
|
|
isa => 'Int', |
43
|
|
|
|
|
|
|
traits => [ Unpack ], |
44
|
|
|
|
|
|
|
unpacker => '@5 n', |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has 'ChanNum' => ( |
48
|
|
|
|
|
|
|
is => 'rw', |
49
|
|
|
|
|
|
|
isa => 'Int', |
50
|
|
|
|
|
|
|
traits => [ Unpack ], |
51
|
|
|
|
|
|
|
unpacker => '@17 n', |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
has 'startTime' => ( |
55
|
|
|
|
|
|
|
is => 'rw', |
56
|
|
|
|
|
|
|
isa => 'DateTime', |
57
|
|
|
|
|
|
|
traits => [ Unpack ], |
58
|
|
|
|
|
|
|
unpacker => '@25 N', |
59
|
|
|
|
|
|
|
postprocessor => sub { return DateTime->from_epoch( epoch => $_, time_zone => 'GMT' ) }, |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
has 'endTime' => ( |
63
|
|
|
|
|
|
|
is => 'rw', |
64
|
|
|
|
|
|
|
isa => 'DateTime', |
65
|
|
|
|
|
|
|
traits => [ Unpack ], |
66
|
|
|
|
|
|
|
unpacker => '@29 N', |
67
|
|
|
|
|
|
|
postprocessor => sub { return DateTime->from_epoch( epoch => $_, time_zone => 'GMT' ) }, |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
has 'fileName' => ( |
71
|
|
|
|
|
|
|
is => 'rw', |
72
|
|
|
|
|
|
|
isa => 'Str', |
73
|
|
|
|
|
|
|
traits => [ Unpack ], |
74
|
|
|
|
|
|
|
unpacker => '@33 A512', |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
has 'progName' => ( |
78
|
|
|
|
|
|
|
is => 'rw', |
79
|
|
|
|
|
|
|
isa => 'Str', |
80
|
|
|
|
|
|
|
traits => [ Unpack ], |
81
|
|
|
|
|
|
|
unpacker => '@546 A255', |
82
|
|
|
|
|
|
|
); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
has 'ChanNameEPG' => ( |
85
|
|
|
|
|
|
|
is => 'rw', |
86
|
|
|
|
|
|
|
isa => 'Str', |
87
|
|
|
|
|
|
|
traits => [ Unpack ], |
88
|
|
|
|
|
|
|
unpacker => '@838 A9', |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
has 'Freesat' => ( |
92
|
|
|
|
|
|
|
is => 'rw', |
93
|
|
|
|
|
|
|
isa => 'Bool', |
94
|
|
|
|
|
|
|
traits => [ Unpack ], |
95
|
|
|
|
|
|
|
unpacker => '@870 c', |
96
|
|
|
|
|
|
|
postprocessor => sub { return !!( $_ & 0x50 ) }, |
97
|
|
|
|
|
|
|
); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
has 'Viewed' => ( |
100
|
|
|
|
|
|
|
is =>'rw', |
101
|
|
|
|
|
|
|
isa =>'Bool', |
102
|
|
|
|
|
|
|
traits => [ Unpack ], |
103
|
|
|
|
|
|
|
unpacker => '@871 c', |
104
|
|
|
|
|
|
|
postprocessor => sub { return !!( $_ & 0x20 ) }, |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
has 'Locked' => ( |
108
|
|
|
|
|
|
|
is => 'rw', |
109
|
|
|
|
|
|
|
isa => 'Bool', |
110
|
|
|
|
|
|
|
traits => [ Unpack ], |
111
|
|
|
|
|
|
|
unpacker => '@871 c', |
112
|
|
|
|
|
|
|
postprocessor => sub { return !!( $_ & 0x80 ) }, |
113
|
|
|
|
|
|
|
); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
has 'HiDef' => ( |
116
|
|
|
|
|
|
|
is => 'rw', |
117
|
|
|
|
|
|
|
isa => 'Bool', |
118
|
|
|
|
|
|
|
traits => [ Unpack ], |
119
|
|
|
|
|
|
|
unpacker => '@872 c', |
120
|
|
|
|
|
|
|
postprocessor => sub { return !!( $_ & 0x80 ) }, |
121
|
|
|
|
|
|
|
); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
has 'Encrypted' => ( |
124
|
|
|
|
|
|
|
is => 'rw', |
125
|
|
|
|
|
|
|
isa => 'Bool', |
126
|
|
|
|
|
|
|
traits => [ Unpack ], |
127
|
|
|
|
|
|
|
unpacker => '@872 c', |
128
|
|
|
|
|
|
|
postprocessor => sub { return !!( $_ & 0x10 ) }, |
129
|
|
|
|
|
|
|
); |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
has 'CopyProtect' => ( |
132
|
|
|
|
|
|
|
is => 'rw', |
133
|
|
|
|
|
|
|
isa => 'Bool', |
134
|
|
|
|
|
|
|
traits => [ Unpack ], |
135
|
|
|
|
|
|
|
unpacker => '@873 c', |
136
|
|
|
|
|
|
|
postprocessor => sub { return !!( $_ & 0x21 ) }, |
137
|
|
|
|
|
|
|
); |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
has 'Subtitles' => ( |
140
|
|
|
|
|
|
|
is => 'rw', |
141
|
|
|
|
|
|
|
isa => 'Bool', |
142
|
|
|
|
|
|
|
traits => [ Unpack ], |
143
|
|
|
|
|
|
|
unpacker => '@1037 c', |
144
|
|
|
|
|
|
|
postprocessor => sub { return ( $_ == 0x1F ) }, |
145
|
|
|
|
|
|
|
); |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
has 'AudioType' => ( |
148
|
|
|
|
|
|
|
is => 'rw', |
149
|
|
|
|
|
|
|
isa => enum([qw[ MPEG1 AC3 ]]), |
150
|
|
|
|
|
|
|
traits => [ Unpack ], |
151
|
|
|
|
|
|
|
unpacker => '@1037 c', |
152
|
|
|
|
|
|
|
postprocessor => sub { return ( ( $_ & 0x10 ) ? 'AC3' :'MPEG1' ) }, |
153
|
|
|
|
|
|
|
); |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
has 'VideoPID' => ( |
156
|
|
|
|
|
|
|
is => 'rw', |
157
|
|
|
|
|
|
|
isa => 'Int', |
158
|
|
|
|
|
|
|
traits => [ Unpack ], |
159
|
|
|
|
|
|
|
unpacker => '@1051 n', |
160
|
|
|
|
|
|
|
); |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
has 'AudioPID' => ( |
163
|
|
|
|
|
|
|
is => 'rw', |
164
|
|
|
|
|
|
|
isa => 'Int', |
165
|
|
|
|
|
|
|
traits => [ Unpack ], |
166
|
|
|
|
|
|
|
unpacker => '@1053 n', |
167
|
|
|
|
|
|
|
); |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
has 'TeletextPID' => ( |
170
|
|
|
|
|
|
|
is => 'rw', |
171
|
|
|
|
|
|
|
isa => 'Int', |
172
|
|
|
|
|
|
|
traits => [ Unpack ], |
173
|
|
|
|
|
|
|
unpacker => '@1059 n', |
174
|
|
|
|
|
|
|
); |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
has 'VideoType' => ( |
177
|
|
|
|
|
|
|
is => 'rw', |
178
|
|
|
|
|
|
|
isa => enum([qw[ SD HD ]]), |
179
|
|
|
|
|
|
|
traits => [ Unpack ], |
180
|
|
|
|
|
|
|
unpacker => '@1069 c', |
181
|
|
|
|
|
|
|
postprocessor => sub { return ( ( $_ & 0x01 ) ? 'HD' :'SD' ) }, |
182
|
|
|
|
|
|
|
); |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
has 'EPG_Block_count' => ( |
185
|
|
|
|
|
|
|
is => 'rw', |
186
|
|
|
|
|
|
|
isa => 'Int', |
187
|
|
|
|
|
|
|
traits => [ Unpack ], |
188
|
|
|
|
|
|
|
unpacker => '@4099 c', |
189
|
|
|
|
|
|
|
); |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
has 'EPG_blocks' => ( |
192
|
|
|
|
|
|
|
is => 'ro', |
193
|
|
|
|
|
|
|
isa => 'ArrayRef[TV::Humax::Foxsat::epg_data]', |
194
|
|
|
|
|
|
|
lazy_build => 1, |
195
|
|
|
|
|
|
|
); |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
# Convenience function to read data from a file |
199
|
|
|
|
|
|
|
# TODO: Don't read more than we need by checking how many EPG blocks there are. |
200
|
|
|
|
|
|
|
sub raw_from_file |
201
|
|
|
|
|
|
|
{ |
202
|
|
|
|
|
|
|
my $self = shift @_; |
203
|
|
|
|
|
|
|
my $src_file = shift; |
204
|
|
|
|
|
|
|
my $file_size = -s $src_file; |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
# Read the data into a memory buffer |
207
|
|
|
|
|
|
|
open my $src_FH, '<', $src_file or die("Error reading from $src_file $!"); |
208
|
|
|
|
|
|
|
my $raw_buff = undef; |
209
|
|
|
|
|
|
|
my $bytes_read = sysread $src_FH, $raw_buff, $file_size, 0; |
210
|
|
|
|
|
|
|
close $src_FH; |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
$self->rawDataBlock($raw_buff); |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
return; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
sub _build_EPG_blocks |
218
|
|
|
|
|
|
|
{ |
219
|
|
|
|
|
|
|
my $self = shift @_; |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
my @retList = (); |
222
|
|
|
|
|
|
|
my $epg_blocks = substr $self->rawDataBlock(), 4100; |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
for( my $block_num=0; $block_num < $self->EPG_Block_count(); $block_num++ ) |
225
|
|
|
|
|
|
|
{ |
226
|
|
|
|
|
|
|
my $nextBlock = TV::Humax::Foxsat::epg_data->new(); |
227
|
|
|
|
|
|
|
$nextBlock->rawEPGBlock( substr $epg_blocks, 0, 544 ); |
228
|
|
|
|
|
|
|
my $remainder = substr $epg_blocks, 544; |
229
|
|
|
|
|
|
|
my $guide_block_len = unpack('@2 n', $remainder ); |
230
|
|
|
|
|
|
|
$nextBlock->guideBlockLen( $guide_block_len ); |
231
|
|
|
|
|
|
|
$nextBlock->rawGuideBlock( substr($remainder, 4+$guide_block_len) ); |
232
|
|
|
|
|
|
|
$epg_blocks = substr $epg_blocks, 544+4+$guide_block_len; |
233
|
|
|
|
|
|
|
push @retList, $nextBlock; |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
return \@retList; |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
# All done |
240
|
|
|
|
|
|
|
1; |