blob: 100389643bc777e5fed262247efe437e30ca42ba [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
Harald Weltefcb1fe82011-09-07 11:51:52 +02009/* we cannot include ortp/ortp.h here, as they also use 'struct msgb' */
Harald Welte41d0d842011-09-03 15:33:24 +020010struct _RtpSession;
11
Harald Weltefcb1fe82011-09-07 11:51:52 +020012/*! \brief standard payload type for GSM Full Rate (FR) */
Harald Welte41d0d842011-09-03 15:33:24 +020013#define RTP_PT_GSM_FULL 3
Harald Weltefcb1fe82011-09-07 11:51:52 +020014
15/*! \brief Osmocom pseudo-static paylaod type for Half Rate (HR) */
Harald Welte41d0d842011-09-03 15:33:24 +020016#define RTP_PT_GSM_HALF 96
Harald Weltefcb1fe82011-09-07 11:51:52 +020017/*! \brief Osmocom pseudo-static paylaod type for Enhanced Full Rate (EFR) */
Harald Welte41d0d842011-09-03 15:33:24 +020018#define RTP_PT_GSM_EFR 97
Harald Weltefcb1fe82011-09-07 11:51:52 +020019/*! \brief Osmocom pseudo-static paylaod type for Adaptive Multi Rate (AMR) */
Harald Welte41d0d842011-09-03 15:33:24 +020020#define RTP_PT_AMR 98
21
Harald Weltefcb1fe82011-09-07 11:51:52 +020022/*! \brief Flag to indicate the socket is in polling-only mode */
Harald Welte9b737df2011-09-07 00:59:11 +020023#define OSMO_RTP_F_POLL 0x0001
24
Harald Weltefcb1fe82011-09-07 11:51:52 +020025/*! \brief A structure representing one RTP socket */
Harald Welte41d0d842011-09-03 15:33:24 +020026struct osmo_rtp_socket {
27 /*! \biref list header for global list of sockets */
28 struct llist_head list;
29
30 /*! \brief libortp RTP session pointer */
31 struct _RtpSession *sess;
32 /*! \brief Osmo file descriptor for RTP socket FD */
33 struct osmo_fd rtp_bfd;
34 /*! \brief Osmo file descriptor for RTCP socket FD */
35 struct osmo_fd rtcp_bfd;
36
37 /*! \brief callback for incoming data */
38 void (*rx_cb)(struct osmo_rtp_socket *rs, const uint8_t *payload,
39 unsigned int payload_len);
40
Harald Weltefcb1fe82011-09-07 11:51:52 +020041 /*! \brief Receive user timestamp, to be incremented by user */
Harald Welte41d0d842011-09-03 15:33:24 +020042 uint32_t rx_user_ts;
43
Harald Weltefcb1fe82011-09-07 11:51:52 +020044 /*! \brief Transmit timestamp, incremented by library */
Harald Welte41d0d842011-09-03 15:33:24 +020045 uint32_t tx_timestamp;
46
Harald Weltefcb1fe82011-09-07 11:51:52 +020047 /*! \brief Flags like OSMO_RTP_F_POLL */
Harald Welte9b737df2011-09-07 00:59:11 +020048 unsigned int flags;
49
Harald Welte41d0d842011-09-03 15:33:24 +020050 void *priv;
51};
52
53void osmo_rtp_init(void *ctx);
Harald Welte9b737df2011-09-07 00:59:11 +020054struct osmo_rtp_socket *osmo_rtp_socket_create(void *talloc_ctx, unsigned int flags);
Harald Welte41d0d842011-09-03 15:33:24 +020055int osmo_rtp_socket_bind(struct osmo_rtp_socket *rs, const char *ip, int port);
56int osmo_rtp_socket_connect(struct osmo_rtp_socket *rs, const char *ip, uint16_t port);
57int osmo_rtp_socket_set_pt(struct osmo_rtp_socket *rs, int payload_type);
58int osmo_rtp_socket_free(struct osmo_rtp_socket *rs);
59int osmo_rtp_send_frame(struct osmo_rtp_socket *rs, const uint8_t *payload,
60 unsigned int payload_len, unsigned int duration);
Harald Welte9b737df2011-09-07 00:59:11 +020061int osmo_rtp_socket_poll(struct osmo_rtp_socket *rs);
Harald Welte41d0d842011-09-03 15:33:24 +020062
63int osmo_rtp_get_bound_ip_port(struct osmo_rtp_socket *rs,
64 uint32_t *ip, int *port);
65int osmo_rtp_get_bound_addr(struct osmo_rtp_socket *rs,
66 const char **addr, int *port);
67
68#endif /* _OSMO_ORTP_H */