aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom/trau/osmo_ortp.h
blob: 278423bdbb1ea0f66d742b08a0e1f8a703c65855 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef _OSMO_ORTP_H
#define _OSMO_ORTP_H

#include <stdint.h>

#include <osmocom/core/linuxlist.h>
#include <osmocom/core/select.h>

//#include <ortp/ortp.h>
struct _RtpSession;


#define RTP_PT_GSM_FULL 3
#define RTP_PT_GSM_HALF 96
#define RTP_PT_GSM_EFR 97
#define RTP_PT_AMR 98

struct osmo_rtp_socket {
	/*! \biref list header for global list of sockets */
	struct llist_head list;

	/*! \brief libortp RTP session pointer */
	struct _RtpSession *sess;
	/*! \brief Osmo file descriptor for RTP socket FD */
	struct osmo_fd rtp_bfd;
	/*! \brief Osmo file descriptor for RTCP socket FD */
	struct osmo_fd rtcp_bfd;

	/*! \brief callback for incoming data */
	void (*rx_cb)(struct osmo_rtp_socket *rs, const uint8_t *payload,
		      unsigned int payload_len);

	/* Rx related */
	uint32_t rx_user_ts;

	/* Tx related */
	uint32_t tx_timestamp;

	void *priv;
};

void osmo_rtp_init(void *ctx);
struct osmo_rtp_socket *osmo_rtp_socket_create(void *talloc_ctx);
int osmo_rtp_socket_bind(struct osmo_rtp_socket *rs, const char *ip, int port);
int osmo_rtp_socket_connect(struct osmo_rtp_socket *rs, const char *ip, uint16_t port);
int osmo_rtp_socket_set_pt(struct osmo_rtp_socket *rs, int payload_type);
int osmo_rtp_socket_free(struct osmo_rtp_socket *rs);
int osmo_rtp_send_frame(struct osmo_rtp_socket *rs, const uint8_t *payload,
			unsigned int payload_len, unsigned int duration);

int osmo_rtp_get_bound_ip_port(struct osmo_rtp_socket *rs,
			       uint32_t *ip, int *port);
int osmo_rtp_get_bound_addr(struct osmo_rtp_socket *rs,
			    const char **addr, int *port);

#endif /* _OSMO_ORTP_H */