Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <stdint.h> |
| 4 | #include <stdbool.h> |
| 5 | |
| 6 | #include <osmocom/core/sockaddr_str.h> |
| 7 | #include <osmocom/mgcp_client/mgcp_client.h> |
| 8 | |
| 9 | struct gsm_trans; |
| 10 | |
| 11 | struct osmo_fsm_inst; |
| 12 | struct call_leg; |
| 13 | struct osmo_mgcpc_ep; |
| 14 | struct osmo_mgcpc_ep_ci; |
| 15 | |
| 16 | enum rtp_direction { |
| 17 | RTP_TO_RAN, |
| 18 | RTP_TO_CN, |
| 19 | }; |
| 20 | |
| 21 | extern const struct value_string rtp_direction_names[]; |
| 22 | static inline const char *rtp_direction_name(enum rtp_direction val) |
| 23 | { return get_value_string(rtp_direction_names, val); } |
| 24 | |
| 25 | /* A single bidirectional RTP hop between remote and MGW's local RTP port. */ |
| 26 | struct rtp_stream { |
| 27 | struct osmo_fsm_inst *fi; |
| 28 | struct call_leg *parent_call_leg; |
| 29 | enum rtp_direction dir; |
| 30 | |
| 31 | uint32_t call_id; |
| 32 | |
| 33 | /* Backpointer for callers (optional) */ |
| 34 | struct gsm_trans *for_trans; |
| 35 | |
| 36 | struct osmo_sockaddr_str local; |
| 37 | struct osmo_sockaddr_str remote; |
| 38 | bool remote_sent_to_mgw; |
| 39 | |
| 40 | bool codec_known; |
| 41 | enum mgcp_codecs codec; |
| 42 | bool codec_sent_to_mgw; |
| 43 | |
| 44 | struct osmo_mgcpc_ep_ci *ci; |
| 45 | |
| 46 | enum mgcp_connection_mode crcx_conn_mode; |
Pau Espin Pedrol | a3cdab4 | 2019-05-09 17:54:08 +0200 | [diff] [blame] | 47 | |
| 48 | /* configured to use Osmux */ |
| 49 | bool use_osmux; |
| 50 | /* Allocated by our MGW, negative means invalid, not yet known */ |
| 51 | int local_osmux_cid; |
| 52 | /* Allocated by BSC MGW, negative means invalid, not yet known */ |
| 53 | int remote_osmux_cid; |
| 54 | /* Whether remote_osmux_cid has been communicated to MGW */ |
| 55 | bool remote_osmux_cid_sent_to_mgw; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | #define RTP_STREAM_FMT "local=" RTP_IP_PORT_FMT ",remote=" RTP_IP_PORT_FMT |
| 59 | #define RTP_STREAM_ARGS(RS) RTP_IP_PORT_ARGS(&(RS)->local), RTP_IP_PORT_ARGS(&(RS)->remote), |
| 60 | |
| 61 | struct rtp_stream *rtp_stream_alloc(struct call_leg *parent_call_leg, enum rtp_direction dir, |
| 62 | uint32_t call_id, struct gsm_trans *for_trans); |
| 63 | |
| 64 | int rtp_stream_ensure_ci(struct rtp_stream *rtps, struct osmo_mgcpc_ep *at_endpoint); |
| 65 | int rtp_stream_do_mdcx(struct rtp_stream *rtps); |
| 66 | |
| 67 | void rtp_stream_set_codec(struct rtp_stream *rtps, enum mgcp_codecs codec); |
| 68 | void rtp_stream_set_remote_addr(struct rtp_stream *rtps, const struct osmo_sockaddr_str *r); |
Pau Espin Pedrol | a3cdab4 | 2019-05-09 17:54:08 +0200 | [diff] [blame] | 69 | void rtp_stream_set_remote_osmux_cid(struct rtp_stream *rtps, uint8_t osmux_cid); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 70 | int rtp_stream_commit(struct rtp_stream *rtps); |
| 71 | |
| 72 | void rtp_stream_release(struct rtp_stream *rtps); |
| 73 | |
| 74 | bool rtp_stream_is_established(struct rtp_stream *rtps); |