A BufferView that interprets its data as an RTP packet. More...
#include <rtppacket.h>


Public Types | |
| using | List = promeki::List< RtpPacket > |
| List of RtpPacket values. | |
| using | SizeList = promeki::List< size_t > |
| List of sizes. | |
Public Types inherited from BufferView | |
| using | List = promeki::List< BufferView > |
| List of BufferView values. | |
Public Member Functions | |
| RtpPacket ()=default | |
| Default constructor. | |
| RtpPacket (Buffer::Ptr buf, size_t offset, size_t size) | |
| Constructs an RtpPacket referencing a region of a shared buffer. | |
| bool | isNull () const |
| Returns true if the buffer pointer is null. | |
| bool | isValid () const |
| Returns true if this is a valid RTP packet. | |
| RtpPacket (size_t packetSize) | |
| Convenience constructor that allocates a buffer for a single packet. | |
| uint8_t | version () const |
| Returns the RTP version (normally 2). | |
| void | setVersion (uint8_t v) |
| Sets the RTP version. | |
| bool | padding () const |
| Returns the padding flag. | |
| void | setPadding (bool p) |
| Sets the padding flag. | |
| bool | extension () const |
| Returns the extension flag. | |
| void | setExtension (bool x) |
| Sets the extension flag. | |
| uint8_t | csrcCount () const |
| Returns the CSRC count. | |
| bool | marker () const |
| Returns the marker bit. | |
| void | setMarker (bool m) |
| Sets the marker bit. | |
| uint8_t | payloadType () const |
| Returns the payload type (7 bits). | |
| void | setPayloadType (uint8_t pt) |
| Sets the payload type. | |
| uint16_t | sequenceNumber () const |
| Returns the sequence number. | |
| void | setSequenceNumber (uint16_t seq) |
| Sets the sequence number. | |
| uint32_t | timestamp () const |
| Returns the timestamp. | |
| void | setTimestamp (uint32_t ts) |
| Sets the timestamp. | |
| uint32_t | ssrc () const |
| Returns the SSRC. | |
| void | setSsrc (uint32_t s) |
| Sets the SSRC. | |
| size_t | headerSize () const |
| Returns the full header size including CSRC list and extension. | |
| uint16_t | extensionProfile () const |
| Returns the extension profile ID, or 0 if no extension is present. | |
| uint16_t | extensionLength () const |
| Returns the extension data length in 32-bit words, or 0 if no extension. | |
| const uint8_t * | payload () const |
| Returns a pointer to the payload data (after the full header). | |
| uint8_t * | payload () |
| Returns a pointer to the payload data (after the full header). | |
| size_t | payloadSize () const |
| Returns the payload size in bytes. | |
| void | clear () |
| Zeroes the packet data and resets the RTP version to 2. | |
Public Member Functions inherited from BufferView | |
| BufferView ()=default | |
| Default constructor. Creates an empty view with no buffer. | |
| BufferView (Buffer::Ptr buf, size_t offset, size_t size) | |
| Constructs a BufferView referencing a region of a shared buffer. | |
| const Buffer::Ptr & | buffer () const |
| Returns the shared backing buffer. | |
| size_t | offset () const |
| Returns the byte offset into the buffer. | |
| size_t | size () const |
| Returns the byte size of this view. | |
| const uint8_t * | data () const |
| Returns a const pointer to this view's data. | |
| uint8_t * | data () |
| Returns a mutable pointer to this view's data. | |
| bool | isNull () const |
| Returns true if no buffer is set. | |
| bool | isValid () const |
| Returns true if a buffer is set. | |
Static Public Member Functions | |
| static List | createList (size_t count, size_t packetSize) |
| Creates a list of N RtpPackets packed into a single shared buffer. | |
| static List | createList (const SizeList &sizes) |
| Creates a list of RtpPackets with varying sizes, packed into a single shared buffer. | |
Static Public Attributes | |
| static constexpr size_t | HeaderSize = 12 |
| Minimum RTP fixed header size in bytes. | |
A BufferView that interprets its data as an RTP packet.
RtpPacket extends BufferView with accessors that read and write the standard 12-byte RTP header directly in the buffer data. No fields are stored separately — the buffer is the source of truth.
|
inline |
Constructs an RtpPacket referencing a region of a shared buffer.
| buf | The shared backing buffer. |
| offset | Byte offset into the buffer where this packet begins. |
| size | Byte size of this packet. |
|
inlineexplicit |
Convenience constructor that allocates a buffer for a single packet.
| packetSize | Total packet size in bytes (header + payload). |
Allocates a dedicated buffer, zeroes it, and sets the RTP version to 2. This is convenient for one-off packets but allocates a separate buffer per packet — for bulk packet construction, prefer createList().
|
inline |
Zeroes the packet data and resets the RTP version to 2.
Useful for reusing packets from a pre-allocated pool.
Creates a list of RtpPackets with varying sizes, packed into a single shared buffer.
| sizes | List of per-packet sizes in bytes (header + payload each). |
Each packet gets the size specified by the corresponding entry in sizes. All packets are zeroed and have their RTP version set to 2. Like the uniform-size overload, this allocates a single shared buffer to avoid per-packet allocation overhead.
Creates a list of N RtpPackets packed into a single shared buffer.
| count | Number of packets to create. |
| packetSize | Total size of each packet in bytes (header + payload). |
All packets are zeroed and have their RTP version set to 2. This is the preferred way to allocate packets in bulk, as it avoids per-packet allocation overhead.
|
inline |
Returns the extension data length in 32-bit words, or 0 if no extension.
|
inline |
Returns the extension profile ID, or 0 if no extension is present.
|
inline |
Returns the full header size including CSRC list and extension.
Computes: 12 + CC*4 + (if X=1: 4 + extensionLength*4). Returns 0 if the packet's size() is too small to hold the declared CSRC entries or extension data.
|
inline |
Returns true if the buffer pointer is null.
A null packet has no backing buffer and cannot be read or written.
|
inline |
Returns true if this is a valid RTP packet.
A valid packet has a non-null buffer, is large enough to hold the fixed 12-byte header, has RTP version 2, and is large enough to contain any CSRC entries and extension header that it declares.
|
inline |
Returns a pointer to the payload data (after the full header).
Accounts for CSRC entries and the extension header when present.
Returns a pointer to the payload data (after the full header).
Accounts for CSRC entries and the extension header when present.
|
inline |
Returns the payload size in bytes.
Accounts for CSRC entries and the extension header when present.