From dc986a40f5a09844558d50c2017667de606ab6f5 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sat, 24 Sep 2016 22:19:04 +0100 Subject: [PATCH] Export more stream info functions --- Opusfile.xs | 22 ++++++++++++++++++++++ lib/Audio/Opusfile.pm | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/Opusfile.xs b/Opusfile.xs index a8cf872..a8bd27b 100644 --- a/Opusfile.xs +++ b/Opusfile.xs @@ -75,6 +75,18 @@ op_serialno(of, li = -1) Audio::Opusfile of; int li; +# op_channel_count is not exported; it can be obtained via op_head + +long +op_raw_total(of, li = -1) + Audio::Opusfile of; + int li; + +long +op_pcm_total(of, li = -1) + Audio::Opusfile of; + int li; + Audio::Opusfile::Head op_head(of, li = -1) Audio::Opusfile of; @@ -85,6 +97,16 @@ op_tags(of, li = -1) Audio::Opusfile of; int li; +# op_current_link not exported until we export the decoding API + +int +op_bitrate(of, li = -1) + Audio::Opusfile of; + int li; + +# op_bitrate_instant, op_raw_tell, op_pcm_tell not exported until we +# export the decoding API + MODULE = Audio::Opusfile PACKAGE = Audio::Opusfile::Tags PREFIX = opus_tags_ int diff --git a/lib/Audio/Opusfile.pm b/lib/Audio/Opusfile.pm index 3c6a7c2..8f1e90e 100644 --- a/lib/Audio/Opusfile.pm +++ b/lib/Audio/Opusfile.pm @@ -177,6 +177,49 @@ If the source is not seekable, I<$link_index> is negative, or I<$link_index> is not given, then this function returns the serial number of the current link. +=item B<$of>->op_raw_total([I<$link_index>]) + +Get the total (compressed) size of the stream (with no arguments), or +of an individual link in a (possibly-chained) Ogg Opus stream (with +one nonnegative argument), including all headers and Ogg muxing +overhead. + +The stream must be seekable to get the total. A negative value is +returned if the stream is not seekable. + +B If the Opus stream (or link) is concurrently multiplexed +with other logical streams (e.g., video), this returns the size of the +entire stream (or link), not just the number of bytes in the first +logical Opus stream. Returning the latter would require scanning the +entire file. + +=item B<$of>->op_pcm_total([I<$link_index>]) + +Get the total PCM length (number of samples at 48 kHz) of the stream +(with no arguments), or of an individual link in a (possibly-chained) +Ogg Opus stream (with one nonnegative argument). + +Users looking for op_time_total() should use this function instead. +Because timestamps in Opus are fixed at 48 kHz, there is no need for a +separate function to convert this to seconds. + +The stream must be seekable to get the total. A negative value is +returned if the stream is not seekable. + +=item B<$of>->op_bitrate([I<$link_index>]) + +Computes the bitrate of the stream (with no arguments), or of an +individual link in a (possibly-chained) Ogg Opus stream (with one +nonnegative argument). + +The stream must be seekable to compute the bitrate. A negative value +is returned if the stream is not seekable. + +B If the Opus stream (or link) is concurrently multiplexed with +other logical streams (e.g., video), this uses the size of the entire +stream (or link) to compute the bitrate, not just the number of bytes +in the first logical Opus stream. + =back =head1 EXPORT -- 2.39.2