#include <rtp_audio_receiver.hpp>
|
| | AudioReceiver (boost::asio::io_context &io_context) |
| | ~AudioReceiver () |
| bool | add_reader (Id id, const ReaderParameters ¶meters, const ArrayOfAddresses &interfaces) |
| | Adds a reader to the receiver.
|
| bool | remove_reader (Id id) |
| | Removes the reader with given id, if it exists.
|
| bool | set_interfaces (const ArrayOfAddresses &interfaces) |
| | Sets the interfaces on all readers, leaving and joining multicast groups where necessary.
|
| void | read_incoming_packets () |
| | Call this to read incoming packets and place the data inside a fifo for consumption.
|
| std::optional< uint32_t > | read_data_realtime (Id id, uint8_t *buffer, size_t buffer_size, std::optional< uint32_t > at_timestamp, std::optional< uint32_t > require_delay) |
| | Reads data from the buffer at the given timestamp.
|
| std::optional< uint32_t > | read_audio_data_realtime (Id id, AudioBufferView< float > &output_buffer, std::optional< uint32_t > at_timestamp, std::optional< uint32_t > require_delay) |
| | Reads the data from the receiver with the given id.
|
| std::optional< PacketStats::Counters > | get_packet_stats (Id reader_id, size_t stream_index) |
| std::optional< StreamState > | get_stream_state (Id reader_id, size_t stream_index) const |
Definition at line 51 of file rtp_audio_receiver.hpp.
◆ ArrayOfAddresses
◆ StreamState
The state of a reader.
| Enumerator |
|---|
| inactive | The stream is inactive because no packets have been received for a while.
|
| receiving | Packets are being received and consumed.
|
| no_consumer | Packets are being received, but they are not consumed.
|
Definition at line 122 of file rtp_audio_receiver.hpp.
◆ AudioReceiver()
| rav::rtp::AudioReceiver::AudioReceiver |
( |
boost::asio::io_context & | io_context | ) |
|
|
explicit |
◆ ~AudioReceiver()
| rav::rtp::AudioReceiver::~AudioReceiver |
( |
| ) |
|
◆ add_reader()
Adds a reader to the receiver.
Thread safe: no.
- Parameters
-
| id | The id to use, must be unique. |
| parameters | The parameters of a reader. |
| interfaces | The interfaces to receive multicast sessions on. |
- Returns
- true if a new reader was added, or false if not.
◆ get_packet_stats()
| std::optional< PacketStats::Counters > rav::rtp::AudioReceiver::get_packet_stats |
( |
Id | reader_id, |
|
|
size_t | stream_index ) |
- Parameters
-
| reader_id | The id of the reader to get statistics from. |
| stream_index | The index of the stream to get stats from. |
- Returns
- The statistics for given stream index, or nullopt if no statistics could be read.
◆ get_stream_state()
| std::optional< StreamState > rav::rtp::AudioReceiver::get_stream_state |
( |
Id | reader_id, |
|
|
size_t | stream_index ) const |
|
nodiscard |
- Parameters
-
| reader_id | The id of the reader to get the state for. |
| stream_index | The index of the stream to get the state for. |
- Returns
- The stream state for given reader.
◆ read_audio_data_realtime()
| std::optional< uint32_t > rav::rtp::AudioReceiver::read_audio_data_realtime |
( |
Id | id, |
|
|
AudioBufferView< float > & | output_buffer, |
|
|
std::optional< uint32_t > | at_timestamp, |
|
|
std::optional< uint32_t > | require_delay ) |
|
nodiscard |
Reads the data from the receiver with the given id.
Calling this function is realtime safe and thread safe when called from a single arbitrary thread.
- Parameters
-
| id | The id of the reader to get data from. |
| output_buffer | The buffer to read the data into. |
| at_timestamp | The optional timestamp to read at. If nullopt, the most recent timestamp minus the delay will be used for the first read and after that the timestamp will be incremented by the packet time. |
| require_delay | If set, the call to read_audio_data_realtime will only succeed if the requested timestamp is older than the most recent received timestamp - require_delay. This can be useful in a case where there is no PTP clock driving time, and instead, the time of the RTP stream has to be used. In normal PTP driven operation you would not set require_delay. |
- Returns
- The timestamp at which the data was read, or std::nullopt if an error occurred.
◆ read_data_realtime()
| std::optional< uint32_t > rav::rtp::AudioReceiver::read_data_realtime |
( |
Id | id, |
|
|
uint8_t * | buffer, |
|
|
size_t | buffer_size, |
|
|
std::optional< uint32_t > | at_timestamp, |
|
|
std::optional< uint32_t > | require_delay ) |
|
nodiscard |
Reads data from the buffer at the given timestamp.
Calling this function is realtime safe and thread safe when called from a single arbitrary thread.
- Parameters
-
| id | The id of the reader to get data from. |
| buffer | The destination to write the data to. |
| buffer_size | The size of the buffer in bytes. |
| at_timestamp | The optional timestamp to read at. If nullopt, the most recent timestamp minus the delay will be used for the first read and after that the timestamp will be incremented by the packet time. |
| require_delay | If set, the call to read_data_realtime will only succeed if the requested timestamp is older than the most recent received timestamp - require_delay. This can be useful in a case where there is no PTP clock driving time, and instead, the time of the RTP stream has to be used. In normal PTP driven operation you would not set require_delay. |
- Returns
- The timestamp at which the data was read, or std::nullopt if an error occurred.
◆ read_incoming_packets()
| void rav::rtp::AudioReceiver::read_incoming_packets |
( |
| ) |
|
Call this to read incoming packets and place the data inside a fifo for consumption.
Should be called from a single high priority thread with regular short intervals.
◆ remove_reader()
| bool rav::rtp::AudioReceiver::remove_reader |
( |
Id | id | ) |
|
|
nodiscard |
Removes the reader with given id, if it exists.
Thread safe: no.
- Parameters
-
| id | The id of the reader to remove. |
- Returns
- true if a reader was removed, or false if not.
◆ set_interfaces()
| bool rav::rtp::AudioReceiver::set_interfaces |
( |
const ArrayOfAddresses & | interfaces | ) |
|
|
nodiscard |
Sets the interfaces on all readers, leaving and joining multicast groups where necessary.
- Parameters
-
| interfaces | The new interfaces to use. |
◆ join_multicast_group
Function for joining a multicast group. Can be overridden to alter behaviour. Used for unit testing.
Definition at line 266 of file rtp_audio_receiver.hpp.
◆ k_buffer_size_ms
| uint32_t rav::rtp::AudioReceiver::k_buffer_size_ms = 200 |
|
staticconstexpr |
The length of the receiver buffer in milliseconds.
AES67 specifies at least 20 ms or 20 times the packet time, whichever is smaller, but since we're on desktop systems we go a bit higher. Note that this number is not the same as the delay or added latency.
Definition at line 64 of file rtp_audio_receiver.hpp.
◆ k_max_num_readers
◆ k_max_num_redundant_sessions
| auto rav::rtp::AudioReceiver::k_max_num_redundant_sessions = 2 |
|
staticconstexpr |
The maximum number of redundant sessions per reader (redundant paths).
Definition at line 56 of file rtp_audio_receiver.hpp.
◆ k_max_num_sessions
◆ k_receive_timeout_ms
| uint64_t rav::rtp::AudioReceiver::k_receive_timeout_ms = 1000 |
|
staticconstexpr |
The number of milliseconds after which a stream is considered inactive.
Definition at line 59 of file rtp_audio_receiver.hpp.
◆ last_time_maintenance
| uint64_t rav::rtp::AudioReceiver::last_time_maintenance {} |
◆ leave_multicast_group
Function for leaving a multicast group. Can be overridden to alter behaviour. Used for unit testing.
Definition at line 269 of file rtp_audio_receiver.hpp.
◆ ptp_instance_subscriber
◆ readers
◆ sockets
The documentation for this struct was generated from the following file: