| FLV-Info documentation | Contained in the FLV-Info distribution. |
FLV::AudioTag - Flash video file data structure
See FLV::Info
This is a subclass of FLV::Base.
Takes a FLV::File instance and extracts an FLV audio tag from the file stream. This method throws exceptions if the stream is not a valid FLV v1.0 or v1.1 file.
There is no return value.
Note: this method needs more work to extract the format-specific data.
Create an independent copy of this instance.
Returns a byte string representation of the tag data. Throws an exception via croak() on error.
Returns a hash of FLV metadata. See FLV::Info for more details.
Returns the time in milliseconds for this tag.
See FLV::Info
| FLV-Info documentation | Contained in the FLV-Info distribution. |
package FLV::AudioTag; use warnings; use strict; use 5.008; use Carp; use English qw(-no_match_vars); use base 'FLV::Base'; use FLV::Util; use FLV::Tag; our $VERSION = '0.24';
sub parse { my $self = shift; my $file = shift; my $datasize = shift; my $flags = unpack 'C', $file->get_bytes(1); my $format = (($flags >> 4) & 0x0f); my $rate = (($flags >> 2) & 0x03); my $size = (($flags >> 1) & 0x01); my $type = $flags & 0x01; if (!exists $AUDIO_FORMATS{$format}) { die "Unknown audio format $format at byte " . $file->get_pos(-1); } $self->{format} = $format; $self->{rate} = $rate; $self->{size} = $size; $self->{type} = $type; $self->{data} = $file->get_bytes($datasize - 1); return; }
sub clone { my $self = shift; my $copy = FLV::AudioTag->new; FLV::Tag->copy_tag($self, $copy); for my $key (qw( format rate size type data )) { $copy->{$key} = $self->{$key}; } return $copy; }
sub serialize { my $self = shift; my $flags = pack 'C', ($self->{format} << 4) | ($self->{rate} << 2) | ($self->{size} << 1) | $self->{type}; return $flags . $self->{data}; }
sub get_info { my ($pkg, @args) = @_; return $pkg->_get_info( 'audio', { format => \%AUDIO_FORMATS, rate => \%AUDIO_RATES, size => \%AUDIO_SIZES, type => \%AUDIO_TYPES, }, \@args ); }
sub get_time { my $self = shift; return $self->{start}; } 1; __END__