#!/usr/bin/perl -w use strict; use Test::More tests => 29; use lib "t/lib"; use Test::FloatNear; BEGIN { if ($] >= 5.006){ require Fcntl; Fcntl->import(qw/SEEK_SET/); } else { require POSIX; POSIX->import(qw/SEEK_SET/); } } BEGIN { use_ok("MPEG::Audio::Frame") } { isa_ok(my $frame = MPEG::Audio::Frame->read(\*DATA), "MPEG::Audio::Frame"); ok(!$frame->has_crc, "no crc in frame"); ok(!$frame->broken, "crc check returns true if no crc"); is($frame->bitrate, 128, "bitrate"); is($frame->sample, 44100, "sample rate"); is_near($frame->seconds, 0.0261, "duration"); is($frame->length, 418, "calculated byte length"); is(length("$frame"), $frame->length, "actual byte length"); seek DATA, $frame->offset, SEEK_SET; read DATA, my $data, $frame->length; is($data, $frame->asbin, "asbin returns data from handle"); } { # a different frame isa_ok(my $frame = MPEG::Audio::Frame->read(\*DATA), "MPEG::Audio::Frame"); ok($frame->has_crc, "frame has CRC"); ok(!$frame->broken, "CRC is good"); is($frame->bitrate, 224, "bitrate"); is($frame->sample, 44100, "sample rate"); is_near($frame->seconds, 0.0261, "duration"); is($frame->length, 731, "calculated byte length"); is(length("$frame"), $frame->length, "actual byte length"); seek DATA, $frame->offset, SEEK_SET; read DATA, my $data, $frame->length; is($data, "$frame", "asbin through overload returns data from handle"); } { # yet another isa_ok(my $frame = MPEG::Audio::Frame->read(\*DATA), "MPEG::Audio::Frame"); ok(!$frame->has_crc, "frame has no CRC"); ok(!$frame->broken, "crc check returns true if no crc"); is($frame->bitrate, 320, "bitrate"); is($frame->sample, 44100, "sample rate"); is(int($frame->seconds()*10000), 261, "duration"); is($frame->length, 1045, "calculated byte length"); is(length("$frame"), $frame->length, "actual byte length"); seek DATA, $frame->offset, SEEK_SET; read DATA, my $data, $frame->length; is($data, "$frame", "asbin through overload returns data from handle"); } ok(!MPEG::Audio::Frame->read(\*DATA), "no mpeg audio left in DATA"); __DATA__ the following data is used to test the module. and mp3 header and frame will follow this (text|garbage) and will be parsed and munged and whatever. here goes nothing... @7 this is more garbage to be ignored dgskjhag ɊH&N HHe"= jKc:#f;+\ o> 5gbqO P(%1s?&.A"69O'ly+a*r.W"S"PhOfPr.nE|n\.x Si* o G@0< No| Y8 L\1da8ȟ,"9 ,"c0A @Ș x 6Ar ό7 Pо_7p00 D=1sA%YhROA0=AE$afbI%EM$ffkRUUzUj[etMC#=3LsBphq\`YF 0Ѐsh>!hBYt4b `Y(nQ&< dgkuwj more ʬĩϫgarbage&&$Y n4bnoet aӲyco17*T1FIlƟ9;Wj.~I$K?8_nHփ,3PZ~\x,%+̎yb \HIDFG*|'G IѸU90FrcUNt 7ZGswcuퟹ}٤ɵOڟXd xb2",y8n jLgXcfaų?2Mj@6ziD3ȍî5/Vd'V3c 49(\ 3H' `!#4% ˜ ĚŦ D2Xڐ5JLibi.rDJ fMd 3D H Pū@k!A؊%\i8T}Anh

L!Ow?O| "(qZMl %^r verujrȨ_ i>y6@ҰI&*|$IlyLVۭyՖP;wqU%M]nJ^Q^C)F)ou*`|aNpjane͇4-HI%y4k:l1hG12400 - $, ,. &)(&0TʁG"Hk-Q p-@* (4W/0 )3M牫T%{olMQ"yop7X7q{xa-A?&fYQ6@o($:Po6JCZ/(Þ MG0C$AB8hA2$)31a,/˕Đvr`H "(B!`б4d#p< ,.b0nEJ! !0`Y)ЬD@} B( lx:p1R1 $ Qy|t\b~"6&I(Q-kD1E2 Ht_Dh:iDШ]iDIi x[ƨ̊QYlԐ,}_QuNE(_%FpaRy7/ Tp务YI(F6vaᒧdb.YtS <%S  gR,q%B.24y7K!lx0T }hgfy)4٩oNy8c y3@cɌ% H}{x[A.o&e,>뾔j˽tFN" p PaZluf\|* Y- `[IcrEf$#\{c-p qH=PG*X+x:M8_c{mxP:ʌ$:9,r0XlrdF*JD/8=