line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FLV::Base; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
41
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
200
|
|
4
|
6
|
|
|
6
|
|
28
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
167
|
|
5
|
6
|
|
|
6
|
|
125
|
use 5.008; |
|
6
|
|
|
|
|
20
|
|
|
6
|
|
|
|
|
246
|
|
6
|
6
|
|
|
6
|
|
3533
|
use Data::Dumper; |
|
6
|
|
|
|
|
25168
|
|
|
6
|
|
|
|
|
420
|
|
7
|
6
|
|
|
6
|
|
7564
|
use List::MoreUtils qw(any); |
|
6
|
|
|
|
|
9705
|
|
|
6
|
|
|
|
|
3380
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.24'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $verbose = 0; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
FLV::Base - Utility methods for other FLV::* classes |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 LICENSE |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
See L |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 METHODS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=over |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=item $pkg->new() |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Creates a new, generic instance. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new |
32
|
|
|
|
|
|
|
{ |
33
|
37396
|
|
|
37396
|
1
|
55781
|
my $pkg = shift; |
34
|
37396
|
|
|
|
|
161537
|
return bless {}, $pkg; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# utility method called by sub class get_info() methods |
38
|
|
|
|
|
|
|
# Arguments: |
39
|
|
|
|
|
|
|
# $prefix is a string that is inserted with an underscore before all outgoing info keys |
40
|
|
|
|
|
|
|
# $fields is a hashref |
41
|
|
|
|
|
|
|
# the key is a field name for the tag instances |
42
|
|
|
|
|
|
|
# the value is undef or a lookup hashref |
43
|
|
|
|
|
|
|
# the key is the tag instance field value |
44
|
|
|
|
|
|
|
# the value is a human-readable string |
45
|
|
|
|
|
|
|
# $tags is an arrayref of tag instances |
46
|
|
|
|
|
|
|
# See FLV::Info::get_info() for more discussion |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _get_info |
49
|
|
|
|
|
|
|
{ |
50
|
12
|
|
|
12
|
|
25
|
my $pkg = shift; |
51
|
12
|
|
|
|
|
30
|
my $prefix = shift; # string |
52
|
12
|
|
|
|
|
17
|
my $fields = shift; # hashref |
53
|
12
|
|
|
|
|
18
|
my $tags = shift; # arrayref |
54
|
|
|
|
|
|
|
|
55
|
12
|
|
|
|
|
17
|
my %complex; |
56
|
12
|
|
|
|
|
14
|
my %info = (count => scalar @{$tags}); |
|
12
|
|
|
|
|
44
|
|
57
|
12
|
|
|
|
|
21
|
my %types = map { $_ => {} } keys %{$fields}; |
|
92
|
|
|
|
|
201
|
|
|
12
|
|
|
|
|
59
|
|
58
|
12
|
|
|
|
|
32
|
for my $tag (@{$tags}) |
|
12
|
|
|
|
|
30
|
|
59
|
|
|
|
|
|
|
{ |
60
|
1740
|
|
|
|
|
1902
|
for my $field (keys %{$fields}) |
|
1740
|
|
|
|
|
3564
|
|
61
|
|
|
|
|
|
|
{ |
62
|
7004
|
|
|
|
|
9232
|
my $value = $tag->{$field}; |
63
|
7004
|
100
|
|
|
|
12087
|
if (defined $value) |
64
|
|
|
|
|
|
|
{ |
65
|
6408
|
100
|
|
|
|
11200
|
if (ref $value) |
66
|
|
|
|
|
|
|
{ |
67
|
2
|
|
|
|
|
48
|
$value = q{\\} . Data::Dumper->Dump([$value], ['VAR']); |
68
|
2
|
|
|
|
|
445
|
$complex{$value} = $tag->{$field}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
6408
|
|
|
|
|
12468
|
$types{$field}->{$value}++; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
12
|
|
|
|
|
19
|
for my $field (keys %{$fields}) |
|
12
|
|
|
|
|
43
|
|
76
|
|
|
|
|
|
|
{ |
77
|
92
|
|
|
|
|
132
|
my $counts = $types{$field}; |
78
|
4
|
50
|
|
|
|
26
|
my @list = reverse sort { $counts->{$a} <=> $counts->{$b} || $a cmp $b } |
|
92
|
|
|
|
|
442
|
|
79
|
92
|
|
|
|
|
94
|
keys %{$counts}; |
80
|
92
|
|
|
|
|
149
|
my $lookup = $fields->{$field}; |
81
|
92
|
100
|
|
|
|
358
|
if ($lookup) |
82
|
|
|
|
|
|
|
{ |
83
|
24
|
|
|
|
|
50
|
@list = map { $lookup->{$_} } @list; |
|
28
|
|
|
|
|
190
|
|
84
|
|
|
|
|
|
|
} |
85
|
92
|
100
|
|
92
|
|
743
|
if (any { m/\A\\/xms } @list) |
|
92
|
|
|
|
|
4875
|
|
86
|
|
|
|
|
|
|
{ |
87
|
2
|
50
|
|
|
|
14
|
$info{$field} = 1 == @list ? $complex{ $list[0] } : ''; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
else |
90
|
|
|
|
|
|
|
{ |
91
|
90
|
|
|
|
|
950
|
$info{$field} = join q{/}, @list; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
12
|
|
|
|
|
47
|
return map { $prefix . q{_} . $_ => $info{$_} } keys %info; |
|
104
|
|
|
|
|
424
|
|
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# This is only meaningful for FLV::*Tag classes. See FLV::Tag::parse() |
98
|
|
|
|
|
|
|
sub _pos |
99
|
|
|
|
|
|
|
{ |
100
|
9
|
|
|
9
|
|
42
|
my $self = shift; |
101
|
9
|
|
|
|
|
41
|
return $self->{_pos}; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |