blob: d9a85c2b44c5471f0417bf1813f6b3f02706b24a [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>
Neels Hofmeyr62bfa372022-10-31 18:51:07 +01008#include <osmocom/msc/sdp_msg.h>
Neels Hofmeyrc4628a32018-12-07 14:47:34 +01009
10struct gsm_trans;
11
12struct osmo_fsm_inst;
13struct call_leg;
14struct osmo_mgcpc_ep;
15struct osmo_mgcpc_ep_ci;
16
17enum rtp_direction {
18 RTP_TO_RAN,
19 RTP_TO_CN,
20};
21
22extern const struct value_string rtp_direction_names[];
23static 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. */
27struct rtp_stream {
28 struct osmo_fsm_inst *fi;
29 struct call_leg *parent_call_leg;
30 enum rtp_direction dir;
31
32 uint32_t call_id;
33
34 /* Backpointer for callers (optional) */
35 struct gsm_trans *for_trans;
36
37 struct osmo_sockaddr_str local;
38 struct osmo_sockaddr_str remote;
39 bool remote_sent_to_mgw;
40
Neels Hofmeyr62bfa372022-10-31 18:51:07 +010041 bool codecs_known;
42 struct sdp_audio_codecs codecs;
43 bool codecs_sent_to_mgw;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010044
45 struct osmo_mgcpc_ep_ci *ci;
46
47 enum mgcp_connection_mode crcx_conn_mode;
Pau Espin Pedrola3cdab42019-05-09 17:54:08 +020048
49 /* configured to use Osmux */
50 bool use_osmux;
51 /* Allocated by our MGW, negative means invalid, not yet known */
52 int local_osmux_cid;
53 /* Allocated by BSC MGW, negative means invalid, not yet known */
54 int remote_osmux_cid;
55 /* Whether remote_osmux_cid has been communicated to MGW */
56 bool remote_osmux_cid_sent_to_mgw;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010057};
58
59#define RTP_STREAM_FMT "local=" RTP_IP_PORT_FMT ",remote=" RTP_IP_PORT_FMT
60#define RTP_STREAM_ARGS(RS) RTP_IP_PORT_ARGS(&(RS)->local), RTP_IP_PORT_ARGS(&(RS)->remote),
61
62struct rtp_stream *rtp_stream_alloc(struct call_leg *parent_call_leg, enum rtp_direction dir,
63 uint32_t call_id, struct gsm_trans *for_trans);
64
65int rtp_stream_ensure_ci(struct rtp_stream *rtps, struct osmo_mgcpc_ep *at_endpoint);
66int rtp_stream_do_mdcx(struct rtp_stream *rtps);
67
Neels Hofmeyr62bfa372022-10-31 18:51:07 +010068bool rtp_stream_set_codecs_from_mgcp_codec(struct rtp_stream *rtps, enum mgcp_codecs codec);
69void rtp_stream_set_one_codec(struct rtp_stream *rtps, const struct sdp_audio_codec *codec);
70void rtp_stream_set_codecs(struct rtp_stream *rtps, const struct sdp_audio_codecs *codecs);
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010071void rtp_stream_set_remote_addr(struct rtp_stream *rtps, const struct osmo_sockaddr_str *r);
Neels Hofmeyr8dd16462022-01-13 20:06:53 +010072void rtp_stream_set_remote_addr_and_codecs(struct rtp_stream *rtps, const struct sdp_msg *sdp);
Pau Espin Pedrola3cdab42019-05-09 17:54:08 +020073void rtp_stream_set_remote_osmux_cid(struct rtp_stream *rtps, uint8_t osmux_cid);
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010074int rtp_stream_commit(struct rtp_stream *rtps);
75
76void rtp_stream_release(struct rtp_stream *rtps);
77
78bool rtp_stream_is_established(struct rtp_stream *rtps);