Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::packet::PacketFactory Class Reference

Packet factory. More...

#include <packet_factory.h>

Inheritance diagram for roc::packet::PacketFactory:
Collaboration diagram for roc::packet::PacketFactory:

Public Member Functions

 PacketFactory (core::IArena &arena, size_t buffer_size)
 Initialize with default pools. buffer_size defines number of bytes in packet buffer. More...
 
 PacketFactory (core::IPool &packet_pool, core::IPool &buffer_pool)
 Initialize with custom pools. packet_pool is a pool of packet::Packet objects. buffer_pool is a pool of core::Buffer objects. More...
 
size_t packet_buffer_size () const
 Get packet buffer size in bytes. More...
 
core::BufferPtr new_packet_buffer ()
 Allocate packet buffer. More...
 
PacketPtr new_packet ()
 Allocate packet. More...
 

Detailed Description

Packet factory.

Allows allocating packets and packet buffers (byte buffers of appropriate size that should be attached to packet to hold payload).

Serves several purposes:

  • implements convenient and type-safe wrapper on top of memory pools
  • combines two related pools (packet pool and buffer pool) in one class
  • detaches pipeline logic from memory management interface, so that it can change independently without affecting every pipeline element

Definition at line 36 of file packet_factory.h.

Constructor & Destructor Documentation

◆ PacketFactory() [1/2]

roc::packet::PacketFactory::PacketFactory ( core::IArena arena,
size_t  buffer_size 
)

Initialize with default pools. buffer_size defines number of bytes in packet buffer.

◆ PacketFactory() [2/2]

roc::packet::PacketFactory::PacketFactory ( core::IPool packet_pool,
core::IPool buffer_pool 
)

Initialize with custom pools. packet_pool is a pool of packet::Packet objects. buffer_pool is a pool of core::Buffer objects.

Member Function Documentation

◆ new_packet()

PacketPtr roc::packet::PacketFactory::new_packet ( )

Allocate packet.

◆ new_packet_buffer()

core::BufferPtr roc::packet::PacketFactory::new_packet_buffer ( )

Allocate packet buffer.

Remarks
Returned buffer may be attached to packet using Packet::set_buffer().

◆ packet_buffer_size()

size_t roc::packet::PacketFactory::packet_buffer_size ( ) const

Get packet buffer size in bytes.


The documentation for this class was generated from the following file: