blob: c53c4f179f5c6ebbd2ee4a0f5fe2cbf3eff1ccca [file] [log] [blame]
Neels Hofmeyrc4628a32018-12-07 14:47:34 +01001#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
9struct gsm_trans;
10
11struct osmo_fsm_inst;
12struct call_leg;
13struct osmo_mgcpc_ep;
14struct osmo_mgcpc_ep_ci;
15
16enum rtp_direction {
17 RTP_TO_RAN,
18 RTP_TO_CN,
19};
20
21extern const struct value_string rtp_direction_names[];
22static 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. */
26struct 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 Pedrola3cdab42019-05-09 17:54:08 +020047
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 Hofmeyrc4628a32018-12-07 14:47:34 +010056};
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
61struct 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
64int rtp_stream_ensure_ci(struct rtp_stream *rtps, struct osmo_mgcpc_ep *at_endpoint);
65int rtp_stream_do_mdcx(struct rtp_stream *rtps);
66
67void rtp_stream_set_codec(struct rtp_stream *rtps, enum mgcp_codecs codec);
68void rtp_stream_set_remote_addr(struct rtp_stream *rtps, const struct osmo_sockaddr_str *r);
Pau Espin Pedrola3cdab42019-05-09 17:54:08 +020069void rtp_stream_set_remote_osmux_cid(struct rtp_stream *rtps, uint8_t osmux_cid);
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010070int rtp_stream_commit(struct rtp_stream *rtps);
71
72void rtp_stream_release(struct rtp_stream *rtps);
73
74bool rtp_stream_is_established(struct rtp_stream *rtps);