98 if(
data() ==
nullptr)
return false;
100 if(((
data()[0] >> 6) & 0x03) != 2)
return false;
137 for(
size_t i = 0;
i < count; ++
i) {
140 ret.pushToBack(std::move(
pkt));
165 for(
size_t i = 0;
i <
sizes.size(); ++
i) {
168 ret.pushToBack(std::move(
pkt));
181 bool padding()
const {
return (hdr()[0] >> 5) & 0x01; }
184 void setPadding(
bool p) { hdr()[0] = (hdr()[0] & 0xDF) | (p ? 0x20 : 0x00); }
187 bool extension()
const {
return (hdr()[0] >> 4) & 0x01; }
190 void setExtension(
bool x) { hdr()[0] = (hdr()[0] & 0xEF) | (x ? 0x10 : 0x00); }
196 bool marker()
const {
return (hdr()[1] >> 7) & 0x01; }
199 void setMarker(
bool m) { hdr()[1] = (hdr()[1] & 0x7F) | (
m ? 0x80 : 0x00); }
209 return (
static_cast<uint16_t>(hdr()[2]) << 8) | hdr()[3];
220 return (
static_cast<uint32_t>(hdr()[4]) << 24) |
221 (
static_cast<uint32_t>(hdr()[5]) << 16) |
222 (
static_cast<uint32_t>(hdr()[6]) << 8) |
228 hdr()[4] =
static_cast<uint8_t>((ts >> 24) & 0xFF);
229 hdr()[5] =
static_cast<uint8_t>((ts >> 16) & 0xFF);
230 hdr()[6] =
static_cast<uint8_t>((ts >> 8) & 0xFF);
231 hdr()[7] =
static_cast<uint8_t>(ts & 0xFF);
236 return (
static_cast<uint32_t>(hdr()[8]) << 24) |
237 (
static_cast<uint32_t>(hdr()[9]) << 16) |
238 (
static_cast<uint32_t>(hdr()[10]) << 8) |
244 hdr()[8] =
static_cast<uint8_t>((
s >> 24) & 0xFF);
245 hdr()[9] =
static_cast<uint8_t>((
s >> 16) & 0xFF);
246 hdr()[10] =
static_cast<uint8_t>((
s >> 8) & 0xFF);
247 hdr()[11] =
static_cast<uint8_t>(
s & 0xFF);
265 if(
hs + 4 >
size())
return 0;
306 if(
hs == 0 ||
hs >=
size())
return nullptr;
313 if(
hs == 0 ||
hs >=
size())
return nullptr;
325 if(
hs == 0 ||
hs >=
size())
return 0;
Lightweight view into a region of a shared Buffer.
Definition bufferview.h:41
size_t offset() const
Returns the byte offset into the buffer.
Definition bufferview.h:65
size_t size() const
Returns the byte size of this view.
Definition bufferview.h:68
const uint8_t * data() const
Returns a const pointer to this view's data.
Definition bufferview.h:74
Generic memory buffer descriptor with alignment and memory space support.
Definition buffer.h:85
Dynamic array container wrapping std::vector.
Definition list.h:40
List()=default
Default constructor. Creates an empty list.
A BufferView that interprets its data as an RTP packet.
Definition rtppacket.h:59
bool extension() const
Returns the extension flag.
Definition rtppacket.h:187
size_t headerSize() const
Returns the full header size including CSRC list and extension.
Definition rtppacket.h:259
uint8_t version() const
Returns the RTP version (normally 2).
Definition rtppacket.h:175
uint32_t ssrc() const
Returns the SSRC.
Definition rtppacket.h:235
bool isValid() const
Returns true if this is a valid RTP packet.
Definition rtppacket.h:97
static List createList(size_t count, size_t packetSize)
Creates a list of N RtpPackets packed into a single shared buffer.
Definition rtppacket.h:130
uint16_t extensionProfile() const
Returns the extension profile ID, or 0 if no extension is present.
Definition rtppacket.h:278
void setPayloadType(uint8_t pt)
Sets the payload type.
Definition rtppacket.h:205
promeki::List< size_t > SizeList
List of sizes.
Definition rtppacket.h:65
uint8_t csrcCount() const
Returns the CSRC count.
Definition rtppacket.h:193
uint32_t timestamp() const
Returns the timestamp.
Definition rtppacket.h:219
uint16_t sequenceNumber() const
Returns the sequence number.
Definition rtppacket.h:208
static List createList(const SizeList &sizes)
Creates a list of RtpPackets with varying sizes, packed into a single shared buffer.
Definition rtppacket.h:155
void setVersion(uint8_t v)
Sets the RTP version.
Definition rtppacket.h:178
void setMarker(bool m)
Sets the marker bit.
Definition rtppacket.h:199
void setSsrc(uint32_t s)
Sets the SSRC.
Definition rtppacket.h:243
uint8_t * payload()
Returns a pointer to the payload data (after the full header).
Definition rtppacket.h:311
size_t payloadSize() const
Returns the payload size in bytes.
Definition rtppacket.h:323
static constexpr size_t HeaderSize
Minimum RTP fixed header size in bytes.
Definition rtppacket.h:68
promeki::List< RtpPacket > List
List of RtpPacket values.
Definition rtppacket.h:62
RtpPacket(Buffer::Ptr buf, size_t offset, size_t size)
Constructs an RtpPacket referencing a region of a shared buffer.
Definition rtppacket.h:79
void setTimestamp(uint32_t ts)
Sets the timestamp.
Definition rtppacket.h:227
uint16_t extensionLength() const
Returns the extension data length in 32-bit words, or 0 if no extension.
Definition rtppacket.h:290
uint8_t payloadType() const
Returns the payload type (7 bits).
Definition rtppacket.h:202
bool padding() const
Returns the padding flag.
Definition rtppacket.h:181
void setExtension(bool x)
Sets the extension flag.
Definition rtppacket.h:190
void clear()
Zeroes the packet data and resets the RTP version to 2.
Definition rtppacket.h:334
RtpPacket()=default
Default constructor.
void setPadding(bool p)
Sets the padding flag.
Definition rtppacket.h:184
bool isNull() const
Returns true if the buffer pointer is null.
Definition rtppacket.h:87
void setSequenceNumber(uint16_t seq)
Sets the sequence number.
Definition rtppacket.h:213
RtpPacket(size_t packetSize)
Convenience constructor that allocates a buffer for a single packet.
Definition rtppacket.h:113
bool marker() const
Returns the marker bit.
Definition rtppacket.h:196
const uint8_t * payload() const
Returns a pointer to the payload data (after the full header).
Definition rtppacket.h:304
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19