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> |
Neels Hofmeyr | 62bfa37 | 2022-10-31 18:51:07 +0100 | [diff] [blame] | 8 | #include <osmocom/msc/sdp_msg.h> |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 9 | |
| 10 | struct gsm_trans; |
| 11 | |
| 12 | struct osmo_fsm_inst; |
| 13 | struct call_leg; |
| 14 | struct osmo_mgcpc_ep; |
| 15 | struct osmo_mgcpc_ep_ci; |
| 16 | |
| 17 | enum rtp_direction { |
| 18 | RTP_TO_RAN, |
| 19 | RTP_TO_CN, |
| 20 | }; |
| 21 | |
| 22 | extern const struct value_string rtp_direction_names[]; |
| 23 | static inline const char *rtp_direction_name(enum rtp_direction val) |
| 24 | { return get_value_string(rtp_direction_names, val); } |
| 25 | |
| 26 | /* A single bidirectional RTP hop between remote and MGW's local RTP port. */ |
| 27 | struct rtp_stream { |
| 28 | struct osmo_fsm_inst *fi; |
Andreas Eversberg | bcb4d6b | 2023-07-05 15:03:19 +0200 | [diff] [blame] | 29 | uint32_t event_avail; |
| 30 | uint32_t event_estab; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 31 | enum rtp_direction dir; |
| 32 | |
| 33 | uint32_t call_id; |
| 34 | |
| 35 | /* Backpointer for callers (optional) */ |
| 36 | struct gsm_trans *for_trans; |
| 37 | |
| 38 | struct osmo_sockaddr_str local; |
| 39 | struct osmo_sockaddr_str remote; |
| 40 | bool remote_sent_to_mgw; |
| 41 | |
Neels Hofmeyr | 62bfa37 | 2022-10-31 18:51:07 +0100 | [diff] [blame] | 42 | bool codecs_known; |
| 43 | struct sdp_audio_codecs codecs; |
| 44 | bool codecs_sent_to_mgw; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 45 | |
| 46 | struct osmo_mgcpc_ep_ci *ci; |
| 47 | |
| 48 | enum mgcp_connection_mode crcx_conn_mode; |
Andreas Eversberg | 58fe2e0 | 2023-06-21 12:37:18 +0200 | [diff] [blame] | 49 | bool mode_sent_to_mgw; |
Pau Espin Pedrol | a3cdab4 | 2019-05-09 17:54:08 +0200 | [diff] [blame] | 50 | |
| 51 | /* configured to use Osmux */ |
| 52 | bool use_osmux; |
| 53 | /* Allocated by our MGW, negative means invalid, not yet known */ |
| 54 | int local_osmux_cid; |
| 55 | /* Allocated by BSC MGW, negative means invalid, not yet known */ |
| 56 | int remote_osmux_cid; |
| 57 | /* Whether remote_osmux_cid has been communicated to MGW */ |
| 58 | bool remote_osmux_cid_sent_to_mgw; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | #define RTP_STREAM_FMT "local=" RTP_IP_PORT_FMT ",remote=" RTP_IP_PORT_FMT |
| 62 | #define RTP_STREAM_ARGS(RS) RTP_IP_PORT_ARGS(&(RS)->local), RTP_IP_PORT_ARGS(&(RS)->remote), |
| 63 | |
Andreas Eversberg | bcb4d6b | 2023-07-05 15:03:19 +0200 | [diff] [blame] | 64 | struct rtp_stream *rtp_stream_alloc(struct osmo_fsm_inst *parent_fi, uint32_t event_gone, uint32_t event_avail, |
| 65 | uint32_t event_estab, enum rtp_direction dir, uint32_t call_id, |
| 66 | struct gsm_trans *for_trans); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 67 | |
| 68 | int rtp_stream_ensure_ci(struct rtp_stream *rtps, struct osmo_mgcpc_ep *at_endpoint); |
| 69 | int rtp_stream_do_mdcx(struct rtp_stream *rtps); |
| 70 | |
Neels Hofmeyr | 62bfa37 | 2022-10-31 18:51:07 +0100 | [diff] [blame] | 71 | bool rtp_stream_set_codecs_from_mgcp_codec(struct rtp_stream *rtps, enum mgcp_codecs codec); |
| 72 | void rtp_stream_set_one_codec(struct rtp_stream *rtps, const struct sdp_audio_codec *codec); |
| 73 | void rtp_stream_set_codecs(struct rtp_stream *rtps, const struct sdp_audio_codecs *codecs); |
Andreas Eversberg | 58fe2e0 | 2023-06-21 12:37:18 +0200 | [diff] [blame] | 74 | void rtp_stream_set_mode(struct rtp_stream *rtps, enum mgcp_connection_mode mode); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 75 | void rtp_stream_set_remote_addr(struct rtp_stream *rtps, const struct osmo_sockaddr_str *r); |
Neels Hofmeyr | 8dd1646 | 2022-01-13 20:06:53 +0100 | [diff] [blame] | 76 | void rtp_stream_set_remote_addr_and_codecs(struct rtp_stream *rtps, const struct sdp_msg *sdp); |
Pau Espin Pedrol | a3cdab4 | 2019-05-09 17:54:08 +0200 | [diff] [blame] | 77 | 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] | 78 | int rtp_stream_commit(struct rtp_stream *rtps); |
| 79 | |
| 80 | void rtp_stream_release(struct rtp_stream *rtps); |
| 81 | |
| 82 | bool rtp_stream_is_established(struct rtp_stream *rtps); |