Membrane Core v0.1.0 Membrane.Helper.Bitstring View Source
Module containing helper functions for manipulating bitstrings.
Link to this section Summary
Functions
Splits given bitstring into parts of given size. Returns {:ok, list of bitstrings, remaining bitstrings}
Same as above, but returns only list of chunks, remaining part is being cut off
Works similarily to split_map/4
but does not accumulate return values
Splits given bitstring into parts of given size, and calls given function for each part
Link to this section Functions
split(bitstring(), pos_integer()) :: {:ok, [] | [...], bitstring()}
Splits given bitstring into parts of given size. Returns {:ok, list of bitstrings, remaining bitstrings}
split!(bitstring(), pos_integer()) :: [] | [...]
Same as above, but returns only list of chunks, remaining part is being cut off
split_each(bitstring(), pos_integer(), (... -> any()), [] | [...]) :: {:ok, bitstring()} | {:error, any()}
Works similarily to split_map/4
but does not accumulate return values.
Processing function should return :ok
on success and {:error, reason}
otherwise. Returning {:error, reason}
will break the recursion.
In case of success, returns {:ok, remaining_bitstring}
.
In case of failure, returns {:error, reason}
.
split_map(bitstring(), pos_integer(), (... -> any()), [] | [...]) :: {:ok, {[] | [...], bitstring()}} | {:error, any()}
Splits given bitstring into parts of given size, and calls given function for each part.
Passed processing function has to accept at least one argument that will be always a bitstring representing current part.
Additionally you may pass a list of extra arguments that will be passed as second and further arguments to the given function.
Processing function should return {:ok, value}
on success and
{:error, reason}
otherwise. Returning {:error, reason}
will break the
recursion.
It accumulates return values of all successful function calls.
In case of success, returns {:ok, {accumulated_result, remaining_bitstring}}
.
In case of failure, returns {:error, reason}
.
This function is useful for handling buffer’s payload if element’s logic expects to process certain amount of samples in one pass. For example, Opus encoder expects to receive particular amount of samples, which total duration is equal to the selected frame size duration, but there’s no guarantee that incoming buffer contains exactly requested amount of samples.