const char *path;
PREINIT:
int err;
-CODE:
- RETVAL = op_open_file(path, &err);
+C_ARGS:
+ path, &err
+POSTCALL:
if(err)
croak("op_open_file returned error %d\n", err);
+
+OggOpusFile*
+op_open_memory(const char *data, size_t length(data))
+PREINIT:
+ int err;
+C_ARGS:
+ data, XSauto_length_of_data, &err
+POSTCALL:
+ if(err)
+ croak("op_open_memory returned error %d\n", err);
+
+bool
+op_test(const char *data, size_t length(data))
+PROTOTYPE: $
+PREINIT:
+ int ret;
+CODE:
+ ret = op_test (NULL, data, XSauto_length_of_data);
+ if(ret < 0 && ret != OP_ENOTFORMAT && ret != OP_EBADHEADER)
+ croak("op_test returned error %d\n", RETVAL);
+ RETVAL = !ret;
OUTPUT:
RETVAL
+
void
DESTROY(of)
OggOpusFile *of;
CODE:
op_free(of);
+bool
+op_seekable(of)
+ OggOpusFile* of;
+
+int
+op_link_count(of)
+ OggOpusFile* of;
+
+int
+op_serialno(of, li = -1)
+ OggOpusFile* of;
+ int li;
+
const OpusHead*
op_head(of, li = -1)
OggOpusFile *of;
use strict;
use warnings;
-use Test::More tests => 5;
+use Test::More tests => 12;
BEGIN { use_ok('Audio::Opusfile') };
my $fail = 0;
ok( $fail == 0 , 'Constants' );
my $of = Audio::Opusfile->new_from_file('empty.opus');
+ok $of->seekable, 'seekable';
+is $of->link_count, 1, 'link_count';
+is $of->serialno(0), 1745145935, 'serialno, arg=0';
+is $of->serialno(200), 1745145935, 'serialno, arg=200';
+is $of->serialno, 1745145935, 'serialno, no arg';
my $tags = $of->tags;
is $tags->query_count('TITLE'), 1, 'query_count';
is $tags->query('TITLE'), 'Cellule', 'query';
is_deeply [$tags->query_all('TITLE')], ['Cellule'], 'query_all';
+
+open my $fh, '<', 'empty.opus';
+read $fh, my $buf, 100;
+ok Audio::Opusfile::test($buf), 'test';
+
+seek $fh, 0, 0;
+read $fh, $buf, 20000;
+$of = Audio::Opusfile->new_from_memory($buf);
+is $of->tags->query('TITLE'), 'Cellule', 'new_from_memory + query';