Subject: | readData type == 8 |
The implementation for readData($type == 8) in the Deserializer should parse a hash. Cribbing from the Ruby implementation at http://www.inlet-media.de/flvtool2/ and from the readArray method, I figured out how to do that. The attached patch implements a new readHash method which I've successfully tested against some embedded FLV 1.1 AMF data. I have not done the corresponding Serializer.pm method, but it should be easy.
-- Chris
diff -ur AMF-Perl-0.15-orig/lib/AMF/Perl/IO/Deserializer.pm AMF-Perl-0.15/lib/AMF/Perl/IO/Deserializer.pm
--- AMF-Perl-0.15-orig/lib/AMF/Perl/IO/Deserializer.pm 2004-09-19 12:08:47.000000000 -0500
+++ AMF-Perl-0.15/lib/AMF/Perl/IO/Deserializer.pm 2005-11-28 23:50:33.000000000 -0600
@@ -182,6 +182,29 @@
return \@ret;
}
+# reads a hash object and converts the binary data into a Perl array
+sub readHash
+{
+ my ($self)=@_;
+ # init the hash
+ print "readHash\n";
+ my %ret;
+ # get the length of the array
+ my $length = $self->{inputStream}->readLong();
+ die "Malformed AMF data, array length too big" if $length > $self->{inputStream}{content_length};
+ # loop over all of the elements in the data
+ for (my $i=0; $i<$length; $i++)
+ {
+ my $key = $self->readString();
+ # grab the type for each element
+ my $type = $self->{inputStream}->readByte();
+ # grab each element
+ $ret{$key} = $self->readData($type);
+ }
+ # return the data
+ return \%ret;
+}
+
sub readCustomClass
{
my ($self)=@_;
@@ -308,15 +331,9 @@
{
$data = $self->readFlushedSO();
}
- elsif ($type == 8) # array
+ elsif ($type == 8) # mixed array
{
- # shared object format only (*.sol)
- # only time I saw it was the serverinfo value in a ColdFusion RecordSet
- # It was just four zeroes - skip them.
- for (my $i=0; $i<4; $i++)
- {
- $self->{inputStream}->readByte();
- }
+ $data = $self->readHash();
}
elsif ($type == 10) # array
{