12#ifndef ZEPHYR_INCLUDE_NET_RTP_H_
13#define ZEPHYR_INCLUDE_NET_RTP_H_
20#ifdef CONFIG_NET_PKT_TIMESTAMP
42#define RTP_MIN_HEADER_LEN 12
45#define RTP_PAYLOAD_TYPE_MAX 127
53#define RTP_HDR_V_MASK GENMASK(7, 6)
55#define RTP_HDR_P_MASK BIT(5)
57#define RTP_HDR_X_MASK BIT(4)
59#define RTP_HDR_CC_MASK GENMASK(3, 0)
61#define RTP_HDR_M_MASK BIT(7)
63#define RTP_HDR_PT_MASK GENMASK(6, 0)
65#if defined(CONFIG_RTP_MAX_CSRC_COUNT) || defined(__DOXYGEN__)
67#define RTP_MAX_CSRC_COUNT CONFIG_RTP_MAX_CSRC_COUNT
69#define RTP_MAX_CSRC_COUNT 0
113#ifdef CONFIG_NET_PKT_TIMESTAMP
176#ifdef CONFIG_RTP_TRANSPORT_SOCKET
180 RTP_TRANSPORT_SOCKET,
182#ifdef CONFIG_RTP_TRANSPORT_NET_PKT
187 RTP_TRANSPORT_NET_PKT,
207#ifdef CONFIG_RTP_TRANSPORT_SOCKET
215#ifdef CONFIG_RTP_TRANSPORT_NET_PKT
218 struct net_conn_handle *net_handle_rtp;
232 struct rtp_transport transport;
234 struct rtp_session_context rtp_context;
256#if CONFIG_RTP_LOG_LEVEL >= LOG_LEVEL_DBG
263#if CONFIG_RTP_LOG_LEVEL >= LOG_LEVEL_DBG
264#define RTP_SESSION_NAME(_name) .name = STRINGIFY(_name),
266#define RTP_SESSION_NAME(_name)
283#define RTP_SESSION_DEFINE(_name, _local_port) \
284 struct rtp_session _name = {.local_port = _local_port, RTP_SESSION_NAME(_name)}
321int rtp_session_init(
struct rtp_session *session,
struct net_if *iface,
341static inline int rtp_session_init_rx(
struct rtp_session *session,
struct net_if *iface,
345 return rtp_session_init(session, iface, sock_addr,
RTP_ROLE_SINK, 0, callback, user_data,
364static inline int rtp_session_init_tx(
struct rtp_session *session,
struct net_if *iface,
369 NULL, transport_type);
383int rtp_session_start(
struct rtp_session *session);
395int rtp_session_stop(
struct rtp_session *session);
406int rtp_session_add_csrc(
struct rtp_session *session,
uint32_t csrc);
417int rtp_session_remove_csrc(
struct rtp_session *session,
uint32_t csrc);
436int rtp_session_send(
struct rtp_session *session,
void *data,
size_t len,
uint32_t delta_ts,
454static inline int rtp_session_send_simple(
struct rtp_session *session,
void *data,
size_t len,
457 return rtp_session_send(session, data, len, delta_ts, 0, 0,
NULL,
NULL);
469 __ASSERT_NO_MSG(h !=
NULL);
483 __ASSERT_NO_MSG(h !=
NULL);
497 __ASSERT_NO_MSG(h !=
NULL);
511 __ASSERT_NO_MSG(h !=
NULL);
525 __ASSERT_NO_MSG(h !=
NULL);
539 __ASSERT_NO_MSG(h !=
NULL);
552 __ASSERT_NO_MSG(h !=
NULL);
566 __ASSERT_NO_MSG(h !=
NULL);
580 __ASSERT_NO_MSG(h !=
NULL);
594 __ASSERT_NO_MSG(h !=
NULL);
608 __ASSERT_NO_MSG(h !=
NULL);
622 __ASSERT_NO_MSG(h !=
NULL);
void * user_data
Opaque user data forwarded to callback.
Definition rtp.h:171
rtp_transport_type
Transport backend used by an RTP session.
Definition rtp.h:175
rtp_rx_cb_t callback
Callback invoked upon packet reception; required when role is RTP_ROLE_SINK or RTP_ROLE_BOTH.
Definition rtp.h:169
uint8_t mpt
Raw encoding of the marker, and payload type fields.
Definition rtp.h:87
uint16_t seq
Sequence number, incremented by one for each RTP data packet sent.
Definition rtp.h:89
enum rtp_transport_type type
Active transport backend for this session.
Definition rtp.h:203
uint8_t * payload
Pointer to the packet payload.
Definition rtp.h:109
struct net_sockaddr_storage sock_addr
Session address and port (multicast group address or unicast peer).
Definition rtp.h:159
struct rtp_header header
Parsed RTP header.
Definition rtp.h:107
#define RTP_HDR_X_MASK
Mask for the extension (X) flag within rtp_header::vpxcc.
Definition rtp.h:57
#define RTP_HDR_PT_MASK
Mask for the payload type (PT) field within rtp_header::mpt.
Definition rtp.h:63
#define RTP_HDR_P_MASK
Mask for the padding (P) flag within rtp_header::vpxcc.
Definition rtp.h:55
void(* rtp_rx_cb_t)(struct rtp_session *session, struct rtp_packet *packet, void *user_data)
RTP packet receive callback type.
Definition rtp.h:140
enum rtp_role role
Role of the session: sink, source, or both.
Definition rtp.h:161
#define RTP_HDR_V_MASK
Mask for the version (V) field within rtp_header::vpxcc.
Definition rtp.h:53
uint32_t ts
Timestamp reflecting the sampling instant of the first octet in the payload.
Definition rtp.h:91
uint8_t * data
Pointer to the extension data.
Definition rtp.h:79
#define RTP_HDR_CC_MASK
Mask for the CSRC count (CC) field within rtp_header::vpxcc.
Definition rtp.h:59
struct rtp_header_extension header_extension
Optional header extension; valid only when the x bit is set.
Definition rtp.h:101
#define RTP_MAX_CSRC_COUNT
Maximum number of csrc's that can be stored.
Definition rtp.h:67
size_t payload_len
Length of the payload in bytes.
Definition rtp.h:111
uint8_t payload_type
RTP payload type field value used when transmitting.
Definition rtp.h:164
#define RTP_HDR_M_MASK
Mask for the marker (M) bit within rtp_header::mpt.
Definition rtp.h:61
uint32_t ssrc
Synchronization source (SSRC) identifier, chosen randomly and intended to be globally unique.
Definition rtp.h:95
uint16_t length
Length of the extension data in 32-bit words.
Definition rtp.h:77
uint16_t definition
Profile-defined extension header identifier.
Definition rtp.h:75
rtp_role
Role of an RTP session.
Definition rtp.h:144
uint8_t vpxcc
Raw encoding of the version, padding, extension, and CC fields.
Definition rtp.h:85
struct net_if * iface
Network interface used by the session.
Definition rtp.h:156
uint32_t csrc[CONFIG_RTP_MAX_CSRC_COUNT]
Contributing source (CSRC) identifiers, up to.
Definition rtp.h:99
@ RTP_TRANSPORT_NUM
Shall not be used as a transport type.
Definition rtp.h:193
@ RTP_ROLE_BOTH
Session both transmits and receives packets.
Definition rtp.h:150
@ RTP_ROLE_SOURCE
Session transmits packets only.
Definition rtp.h:148
@ RTP_ROLE_SINK
Session receives packets only.
Definition rtp.h:146
#define NULL
Definition iar_missing_defs.h:20
Header file for the logging core.
BSD Sockets compatible API definitions.
Network context definitions.
Public API for network interface.
IPv6 and IPv4 definitions.
Public functions for the Precision Time Protocol time specification.
#define FIELD_PREP(mask, value)
Definition silabs-pinctrl-siwx91x.h:15
#define FIELD_GET(mask, value)
Definition silabs-pinctrl-siwx91x.h:14
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Network Interface structure.
Definition net_if.h:744
(Generalized) Precision Time Protocol Timestamp format.
Definition ptp_time.h:111
Generic sockaddr struct.
Definition net_ip.h:455
Decoded RTP packet with header and payload separated.
Definition rtp.h:105
RTP session configuration context.
Definition rtp.h:154
Internal transport state embedded in rtp_session.
Definition rtp.h:201