libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
rtpsession.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <cstdint>
12#include <promeki/core/error.h>
13#include <promeki/core/buffer.h>
16
18
19class UdpSocket;
20
47class RtpSession : public ObjectBase {
48 PROMEKI_OBJECT(RtpSession, ObjectBase)
49 public:
55
57 ~RtpSession() override;
58
70
72 void stop();
73
75 bool isRunning() const { return _running; }
76
89 Error sendPacket(const Buffer &payload, uint32_t timestamp,
91 bool marker = false);
92
108 const SocketAddress &dest, bool markerOnLast = true);
109
111 uint32_t ssrc() const { return _ssrc; }
112
114 void setSsrc(uint32_t ssrc) { _ssrc = ssrc; }
115
117 uint16_t sequenceNumber() const { return _sequenceNumber; }
118
120 void setPayloadType(uint8_t pt) { _payloadType = pt; }
121
123 uint8_t payloadType() const { return _payloadType; }
124
126 void setClockRate(uint32_t hz) { _clockRate = hz; }
127
129 uint32_t clockRate() const { return _clockRate; }
130
139 UdpSocket *socket() const { return _socket; }
140
150
153
154 private:
155 void fillHeader(RtpPacket &pkt, uint8_t pt, bool marker,
156 uint32_t timestamp);
157 void generateSsrc();
158
159 UdpSocket *_socket = nullptr;
160 bool _running = false;
161 uint32_t _ssrc = 0;
162 uint16_t _sequenceNumber = 0;
163 uint8_t _payloadType = 96;
164 uint32_t _clockRate = 90000;
165};
166
Generic memory buffer descriptor with alignment and memory space support.
Definition buffer.h:85
Lightweight error code wrapper for the promeki library.
Definition error.h:39
Dynamic array container wrapping std::vector.
Definition list.h:40
Base object for promeki.
Definition objectbase.h:129
ObjectBase * parent() const
Returns the parent object, if one. nullptr if none.
Definition objectbase.h:258
A BufferView that interprets its data as an RTP packet.
Definition rtppacket.h:59
promeki::List< RtpPacket > List
List of RtpPacket values.
Definition rtppacket.h:62
RTP session for sending and receiving packets (RFC 3550).
Definition rtpsession.h:47
Error start(const SocketAddress &localAddr)
Starts the session, binding to a local address.
Error sendPacket(const Buffer &payload, uint32_t timestamp, uint8_t payloadType, const SocketAddress &dest, bool marker=false)
Sends a single RTP packet with raw payload data.
~RtpSession() override
Destructor. Stops the session if running.
uint32_t ssrc() const
Returns the locally generated SSRC.
Definition rtpsession.h:111
uint8_t payloadType() const
Returns the default payload type.
Definition rtpsession.h:123
void setSsrc(uint32_t ssrc)
Overrides the auto-generated SSRC.
Definition rtpsession.h:114
uint32_t clockRate() const
Returns the RTP timestamp clock rate.
Definition rtpsession.h:129
void setPayloadType(uint8_t pt)
Sets the default payload type.
Definition rtpsession.h:120
PROMEKI_SIGNAL(packetReceived, Buffer, uint32_t, uint8_t, bool)
Emitted when a packet is received.
UdpSocket * socket() const
Returns the internal UDP socket.
Definition rtpsession.h:139
Error sendPackets(RtpPacket::List &packets, uint32_t timestamp, const SocketAddress &dest, bool markerOnLast=true)
Sends pre-packed RTP packets from a payload handler.
PROMEKI_SIGNAL(ssrcCollision, uint32_t)
Emitted when an SSRC collision is detected.
uint16_t sequenceNumber() const
Returns the current sequence number.
Definition rtpsession.h:117
RtpSession(ObjectBase *parent=nullptr)
Constructs an RtpSession.
bool isRunning() const
Returns true if the session is started.
Definition rtpsession.h:75
void stop()
Stops the session and closes the socket.
void setClockRate(uint32_t hz)
Sets the RTP timestamp clock rate in Hz.
Definition rtpsession.h:126
Network address with port number.
Definition socketaddress.h:50
Datagram-oriented UDP socket with multicast support.
Definition udpsocket.h:47
#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