line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FLV::AudioTag; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
33
|
use warnings; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
213
|
|
4
|
6
|
|
|
6
|
|
33
|
use strict; |
|
6
|
|
|
|
|
86
|
|
|
6
|
|
|
|
|
178
|
|
5
|
6
|
|
|
6
|
|
137
|
use 5.008; |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
217
|
|
6
|
6
|
|
|
6
|
|
30
|
use Carp; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
616
|
|
7
|
6
|
|
|
6
|
|
174
|
use English qw(-no_match_vars); |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
44
|
|
8
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
4551
|
use base 'FLV::Base'; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
806
|
|
10
|
|
|
|
|
|
|
|
11
|
6
|
|
|
6
|
|
32
|
use FLV::Util; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
1520
|
|
12
|
6
|
|
|
6
|
|
34
|
use FLV::Tag; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
4309
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.24'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
FLV::AudioTag - Flash video file data structure |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 LICENSE |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
See L |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 METHODS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This is a subclass of FLV::Base. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=over |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=item $self->parse($fileinst) |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Takes a FLV::File instance and extracts an FLV audio tag from the file |
33
|
|
|
|
|
|
|
stream. This method throws exceptions if the stream is not a valid |
34
|
|
|
|
|
|
|
FLV v1.0 or v1.1 file. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
There is no return value. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Note: this method needs more work to extract the format-specific data. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub parse |
43
|
|
|
|
|
|
|
{ |
44
|
10556
|
|
|
10556
|
1
|
16546
|
my $self = shift; |
45
|
10556
|
|
|
|
|
12148
|
my $file = shift; |
46
|
10556
|
|
|
|
|
11550
|
my $datasize = shift; |
47
|
|
|
|
|
|
|
|
48
|
10556
|
|
|
|
|
28959
|
my $flags = unpack 'C', $file->get_bytes(1); |
49
|
|
|
|
|
|
|
|
50
|
10556
|
|
|
|
|
22634
|
my $format = (($flags >> 4) & 0x0f); |
51
|
10556
|
|
|
|
|
12982
|
my $rate = (($flags >> 2) & 0x03); |
52
|
10556
|
|
|
|
|
11709
|
my $size = (($flags >> 1) & 0x01); |
53
|
10556
|
|
|
|
|
13732
|
my $type = $flags & 0x01; |
54
|
|
|
|
|
|
|
|
55
|
10556
|
50
|
|
|
|
37261
|
if (!exists $AUDIO_FORMATS{$format}) |
56
|
|
|
|
|
|
|
{ |
57
|
0
|
|
|
|
|
0
|
die "Unknown audio format $format at byte " . $file->get_pos(-1); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
10556
|
|
|
|
|
86337
|
$self->{format} = $format; |
61
|
10556
|
|
|
|
|
17392
|
$self->{rate} = $rate; |
62
|
10556
|
|
|
|
|
16021
|
$self->{size} = $size; |
63
|
10556
|
|
|
|
|
15363
|
$self->{type} = $type; |
64
|
|
|
|
|
|
|
|
65
|
10556
|
|
|
|
|
38090
|
$self->{data} = $file->get_bytes($datasize - 1); |
66
|
|
|
|
|
|
|
|
67
|
10556
|
|
|
|
|
26825
|
return; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item $self->clone() |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Create an independent copy of this instance. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub clone |
77
|
|
|
|
|
|
|
{ |
78
|
2280
|
|
|
2280
|
1
|
3056
|
my $self = shift; |
79
|
|
|
|
|
|
|
|
80
|
2280
|
|
|
|
|
6319
|
my $copy = FLV::AudioTag->new; |
81
|
2280
|
|
|
|
|
7560
|
FLV::Tag->copy_tag($self, $copy); |
82
|
2280
|
|
|
|
|
3439
|
for my $key (qw( format rate size type data )) { |
83
|
11400
|
|
|
|
|
24821
|
$copy->{$key} = $self->{$key}; |
84
|
|
|
|
|
|
|
} |
85
|
2280
|
|
|
|
|
7144
|
return $copy; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item $self->serialize() |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Returns a byte string representation of the tag data. Throws an |
91
|
|
|
|
|
|
|
exception via croak() on error. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub serialize |
96
|
|
|
|
|
|
|
{ |
97
|
5919
|
|
|
5919
|
1
|
7362
|
my $self = shift; |
98
|
|
|
|
|
|
|
|
99
|
5919
|
|
|
|
|
18993
|
my $flags = pack 'C', |
100
|
|
|
|
|
|
|
($self->{format} << 4) | ($self->{rate} << 2) | ($self->{size} << 1) | |
101
|
|
|
|
|
|
|
$self->{type}; |
102
|
5919
|
|
|
|
|
22201
|
return $flags . $self->{data}; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item $self->get_info() |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Returns a hash of FLV metadata. See FLV::Info for more details. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub get_info |
112
|
|
|
|
|
|
|
{ |
113
|
4
|
|
|
4
|
1
|
127
|
my ($pkg, @args) = @_; |
114
|
4
|
|
|
|
|
63
|
return $pkg->_get_info( |
115
|
|
|
|
|
|
|
'audio', |
116
|
|
|
|
|
|
|
{ |
117
|
|
|
|
|
|
|
format => \%AUDIO_FORMATS, |
118
|
|
|
|
|
|
|
rate => \%AUDIO_RATES, |
119
|
|
|
|
|
|
|
size => \%AUDIO_SIZES, |
120
|
|
|
|
|
|
|
type => \%AUDIO_TYPES, |
121
|
|
|
|
|
|
|
}, |
122
|
|
|
|
|
|
|
\@args |
123
|
|
|
|
|
|
|
); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item $self->get_time() |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Returns the time in milliseconds for this tag. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub get_time |
133
|
|
|
|
|
|
|
{ |
134
|
291
|
|
|
291
|
1
|
339
|
my $self = shift; |
135
|
291
|
|
|
|
|
890
|
return $self->{start}; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
__END__ |