libosmo-netif 1.6.0.16-c51c Osmocom network interface library

Loading...
Searching...
No Matches
rtp.h
1#ifndef _OSMO_RTP_H_
2#define _OSMO_RTP_H_
3
4#include <osmocom/core/endian.h>
5
6/* RTP header as defined by RFC 3550 */
7 struct rtp_hdr {
8#if OSMO_IS_LITTLE_ENDIAN
9 uint8_t csrc_count:4,
10 extension:1,
11 padding:1,
12 version:2;
13 uint8_t payload_type:7,
14 marker:1;
15#elif OSMO_IS_BIG_ENDIAN
16/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianness.py) */
17 uint8_t version:2, padding:1, extension:1, csrc_count:4;
18 uint8_t marker:1, payload_type:7;
19#endif
20 uint16_t sequence;
21 uint32_t timestamp;
22 uint32_t ssrc;
23 uint8_t data[0];
24} __attribute__((packed));
25
26#define RTP_VERSION 2
27
28/* 5.3.1 RTP Header Extension
29 *
30 * If the X bit in the RTP header is one, a variable-length header
31 * extension MUST be appended to the RTP header, following the CSRC list
32 * if present. The header extension contains a 16-bit length field that
33 * counts the number of 32-bit words in the extension, excluding the
34 * four-octet extension header (therefore zero is a valid length). Only
35 * a single extension can be appended to the RTP data header.
36 */
37 struct rtp_x_hdr {
38 uint16_t by_profile;
39 uint16_t length;
40} __attribute__((packed));
41
42/* RTPC header. */
43 struct rtcp_hdr {
44 uint8_t byte0;
45 uint8_t type;
46 uint16_t length;
47} __attribute__((packed));
48
49/* XXX: RFC specifies that MTU should used, add generic function to obtain
50 existing MTU. */
51#define RTP_MSGB_SIZE 1500
52
53
54 struct msgb;
55
56 struct osmo_rtp_handle *osmo_rtp_handle_create(void *ctx);
57 void osmo_rtp_handle_free(struct osmo_rtp_handle *h);
58
59 int osmo_rtp_handle_tx_set_sequence(struct osmo_rtp_handle *h, uint16_t seq);
60 int osmo_rtp_handle_tx_set_ssrc(struct osmo_rtp_handle *h, uint32_t ssrc);
61 int osmo_rtp_handle_tx_set_timestamp(struct osmo_rtp_handle *h, uint32_t timestamp);
62
63 struct rtp_hdr *osmo_rtp_get_hdr(struct msgb *msg);
64 void *osmo_rtp_get_payload(struct rtp_hdr *rtph, struct msgb *msg, uint32_t *plen);
65
66 struct msgb *osmo_rtp_build(struct osmo_rtp_handle *h, uint8_t payload_type, uint32_t payload_len, const void *data, uint32_t duration);
67
68 int osmo_rtp_snprintf(char *buf, size_t size, struct msgb *msg);
69
70/* supported RTP payload types. */
71#define RTP_PT_RTCP 72 /* RFC 3551: 72-76 for RTCP */
72
73#define RTP_PT_GSM_FULL 3
74#define RTP_PT_GSM_FULL_PAYLOAD_LEN 33
75#define RTP_PT_GSM_FULL_DURATION 160 /* in samples. */
76
77#define RTP_PT_GSM_HALF 96
78
79#define RTP_PT_GSM_EFR 97
80#define RTP_PT_GSM_EFR_PAYLOAD_LEN 31
81#define RTP_PT_GSM_EFR_DURATION 160 /* in samples. */
82
83#define RTP_PT_AMR 98
84
85#define RTP_PT_CSDATA 120 /* 3GPP TS 48.103 table 5.4.2.2.1 */
86
87#endif
rtcp_hdr
Definition rtp.h:43
rtp_hdr
Definition rtp.h:7
rtp_x_hdr
Definition rtp.h:37