blob: fc7bca2949e2d3bab5fb9c94a0760eface754307 [file] [log] [blame]
Harald Welte41d0d842011-09-03 15:33:24 +02001#ifndef _OSMO_ORTP_H
2#define _OSMO_ORTP_H
3
4#include <stdint.h>
5
6#include <osmocom/core/linuxlist.h>
7#include <osmocom/core/select.h>
8
9//#include <ortp/ortp.h>
10struct _RtpSession;
11
12
13#define RTP_PT_GSM_FULL 3
14#define RTP_PT_GSM_HALF 96
15#define RTP_PT_GSM_EFR 97
16#define RTP_PT_AMR 98
17
Harald Welte9b737df2011-09-07 00:59:11 +020018#define OSMO_RTP_F_POLL 0x0001
19
Harald Welte41d0d842011-09-03 15:33:24 +020020struct osmo_rtp_socket {
21 /*! \biref list header for global list of sockets */
22 struct llist_head list;
23
24 /*! \brief libortp RTP session pointer */
25 struct _RtpSession *sess;
26 /*! \brief Osmo file descriptor for RTP socket FD */
27 struct osmo_fd rtp_bfd;
28 /*! \brief Osmo file descriptor for RTCP socket FD */
29 struct osmo_fd rtcp_bfd;
30
31 /*! \brief callback for incoming data */
32 void (*rx_cb)(struct osmo_rtp_socket *rs, const uint8_t *payload,
33 unsigned int payload_len);
34
35 /* Rx related */
36 uint32_t rx_user_ts;
37
38 /* Tx related */
39 uint32_t tx_timestamp;
40
Harald Welte9b737df2011-09-07 00:59:11 +020041 unsigned int flags;
42
Harald Welte41d0d842011-09-03 15:33:24 +020043 void *priv;
44};
45
46void osmo_rtp_init(void *ctx);
Harald Welte9b737df2011-09-07 00:59:11 +020047struct osmo_rtp_socket *osmo_rtp_socket_create(void *talloc_ctx, unsigned int flags);
Harald Welte41d0d842011-09-03 15:33:24 +020048int osmo_rtp_socket_bind(struct osmo_rtp_socket *rs, const char *ip, int port);
49int osmo_rtp_socket_connect(struct osmo_rtp_socket *rs, const char *ip, uint16_t port);
50int osmo_rtp_socket_set_pt(struct osmo_rtp_socket *rs, int payload_type);
51int osmo_rtp_socket_free(struct osmo_rtp_socket *rs);
52int osmo_rtp_send_frame(struct osmo_rtp_socket *rs, const uint8_t *payload,
53 unsigned int payload_len, unsigned int duration);
Harald Welte9b737df2011-09-07 00:59:11 +020054int osmo_rtp_socket_poll(struct osmo_rtp_socket *rs);
Harald Welte41d0d842011-09-03 15:33:24 +020055
56int osmo_rtp_get_bound_ip_port(struct osmo_rtp_socket *rs,
57 uint32_t *ip, int *port);
58int osmo_rtp_get_bound_addr(struct osmo_rtp_socket *rs,
59 const char **addr, int *port);
60
61#endif /* _OSMO_ORTP_H */