PvRecorder
Rust API
API Reference for the PvRecorder Rust SDK (crates.io).
pv_recorder::PvRecorder
Struct representing the PvRecorder
object.
pv_recorder::PvRecorder.start()
Starts recording and buffering audio frames.
Returns
Result<(), PvRecorderError>
: IfErr
, aPvRecorderError
.
pv_recorder::PvRecorder.stop()
Stops recording audio.
Returns
Result<(), PvRecorderError>
: IfErr
, aPvRecorderError
.
pv_recorder::PvRecorder.read()
Synchronous call to read a frame of audio.
Returns
Result<Vec<i16>, PvRecorderError>
: IfOk
, A frame with sizeframe_length
. IfErr
, aPvRecorderError
.
pv_recorder::PvRecorder.set_debug_logging()
Enable or disable debug logging for PvRecorder
. Debug logs will indicate when there are overflows
in the internal frame buffer and when an audio source is generating frames of silence.
Parameters
is_debug_logging_enabled
bool : Boolean indicating whether the debug logging is enabled or disabled.
pv_recorder::PvRecorder.frame_length()
The length of audio frame given at each read()
call.
Returns
usize
: The length of audio frame.
pv_recorder::PvRecorder.is_recording()
Whether the recorder is currently recording audio or not.
Returns
bool
: Whether the recorder is currently recording audio or not.
pv_recorder::PvRecorder.sample_rate()
The audio sample rate used by PvRecorder
.
Returns
u32
: Sample rate used by the engine.
pv_recorder::PvRecorder.selected_device()
The audio device that the given PvRecorder
instance is using.
Returns
String
: Audio device string.
pv_recorder::PvRecorder.version()
PvRecorder
version.
Returns
String
: Version string.
pv_recorder::PvRecorderBuilder
Builder class for creating an instance of PvRecorder
with a variety of properties.
pv_recorder::PvRecorderBuilder.new()
Creates a PvRecorderBuilder
.
Parameters
frame_length
i32 : The length of audio frame to get for each read call.
Returns
PvRecorderBuilder
: A new Builder object.
pv_recorder::PvRecorderBuilder.frame_length()
Modifies the frame_length
of a PvRecorderBuilder
object.
Parameters
frame_length
i32 : The length of audio frame to get for each read call.
Returns
PvRecorderBuilder
: The modified Builder object.
pv_recorder::PvRecorderBuilder.device_index()
Modifies the device_index
of a PvRecorderBuilder
object.
Parameters
device_index
i32 : The index of the audio device to use. A value of (-1) will resort to default device.
Returns
PvRecorderBuilder
: The modified Builder object.
pv_recorder::PvRecorderBuilder.buffered_frames_count()
Modifies the buffered_frames_count
of a PvRecorderBuilder
object. This is the number of audio frames buffered internally for reading - i.e. internal circular buffer will be of size frame_length
* buffered_frames_count
. If this value is too low, buffer overflows could occur and audio frames could be dropped. A higher value will increase memory usage.
Parameters
buffered_frames_count
i32 : The number of audio frames buffered internally for reading.
Returns
PvRecorderBuilder
: The modified Builder object.
pv_recorder::PvRecorderBuilder.library_path()
Overrides the default library_path
of a PvRecorderBuilder
object.
Parameters
library_path
&Path : Path to the PvRecorder library file.
Returns
PvRecorderBuilder
: The modified Builder object.
pv_recorder::PvRecorderBuilder.init()
Creates an instance of PvRecorder
from the PvRecorderBuilder
object.
Returns
Result<PvRecorder, PvRecorderError>
: IfOk
, an initialized instance ofPvRecorder
. IfErr
, and instance ofPvRecorderError
detailing the error that was encountered.
pv_recorder::PvRecorderBuilder.get_available_devices()
Gets the list of available audio devices that can be used for recording.
Returns
Result<Vec<String>, PvRecorderError>
: IfOk
, A list of strings, indicating the names of audio devices.. IfErr
, aPvRecorderError
.
pv_recorder::PvRecorderError
An error type describing any errors encountered by the PvRecorder SDK.
pv_recorder::PvRecorderError.status
Type of error encountered.
pv_recorder::PvRecorderError.message
Message detailing the cause of the error.
pv_recorder::PvRecorderError.new()
Creates a new instance of PvRecorderError
.
Parameters
status
PvRecorderErrorStatus
: Type of error encountered.message
&str : Message detailing the cause of the error.
pv_recorder::PvRecorderErrorStatus
Enum describing possible error types returned from the PvRecorder Rust SDK.
pv_recorder::PvRecorderStatus
Error codes returned from the PvRecorder library.