ASCI: Allow usage of rtp_stream with other FSM
Allow the caller of rtp_stream_alloc() to define what events will be dispatched to the parent FSM. This allows other state machines to use rtp_stream. It is required for using RTP stream process with VGCS FSM. Drop the unused parent_call_leg member. Change-Id: I0991927b6d00da08dfd455980645e68281a73a9e Related: OS#4854
This commit is contained in:
parent
58fe2e03c8
commit
bcb4d6b26f
|
@ -26,7 +26,8 @@ static inline const char *rtp_direction_name(enum rtp_direction val)
|
|||
/* A single bidirectional RTP hop between remote and MGW's local RTP port. */
|
||||
struct rtp_stream {
|
||||
struct osmo_fsm_inst *fi;
|
||||
struct call_leg *parent_call_leg;
|
||||
uint32_t event_avail;
|
||||
uint32_t event_estab;
|
||||
enum rtp_direction dir;
|
||||
|
||||
uint32_t call_id;
|
||||
|
@ -60,8 +61,9 @@ struct rtp_stream {
|
|||
#define RTP_STREAM_FMT "local=" RTP_IP_PORT_FMT ",remote=" RTP_IP_PORT_FMT
|
||||
#define RTP_STREAM_ARGS(RS) RTP_IP_PORT_ARGS(&(RS)->local), RTP_IP_PORT_ARGS(&(RS)->remote),
|
||||
|
||||
struct rtp_stream *rtp_stream_alloc(struct call_leg *parent_call_leg, enum rtp_direction dir,
|
||||
uint32_t call_id, struct gsm_trans *for_trans);
|
||||
struct rtp_stream *rtp_stream_alloc(struct osmo_fsm_inst *parent_fi, uint32_t event_gone, uint32_t event_avail,
|
||||
uint32_t event_estab, enum rtp_direction dir, uint32_t call_id,
|
||||
struct gsm_trans *for_trans);
|
||||
|
||||
int rtp_stream_ensure_ci(struct rtp_stream *rtps, struct osmo_mgcpc_ep *at_endpoint);
|
||||
int rtp_stream_do_mdcx(struct rtp_stream *rtps);
|
||||
|
|
|
@ -303,7 +303,8 @@ int call_leg_ensure_rtp_alloc(struct call_leg *cl, enum rtp_direction dir, uint3
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
cl->rtp[dir] = rtp_stream_alloc(cl, dir, call_id, for_trans);
|
||||
cl->rtp[dir] = rtp_stream_alloc(cl->fi, CALL_LEG_EV_RTP_STREAM_GONE, CALL_LEG_EV_RTP_STREAM_ADDR_AVAILABLE,
|
||||
CALL_LEG_EV_RTP_STREAM_ESTABLISHED, dir, call_id, for_trans);
|
||||
OSMO_ASSERT(cl->rtp[dir]);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -110,13 +110,14 @@ void rtp_stream_update_id(struct rtp_stream *rtps)
|
|||
/* Allocate RTP stream under a call leg. This is one RTP connection from some remote entity with address and port to a
|
||||
* local RTP address and port. call_id is stored for sending in MGCP transactions and as logging context. for_trans is
|
||||
* optional, merely stored for reference by callers, and appears as log context if not NULL. */
|
||||
struct rtp_stream *rtp_stream_alloc(struct call_leg *parent_call_leg, enum rtp_direction dir,
|
||||
uint32_t call_id, struct gsm_trans *for_trans)
|
||||
struct rtp_stream *rtp_stream_alloc(struct osmo_fsm_inst *parent_fi, uint32_t event_gone, uint32_t event_avail,
|
||||
uint32_t event_estab, enum rtp_direction dir, uint32_t call_id,
|
||||
struct gsm_trans *for_trans)
|
||||
{
|
||||
struct osmo_fsm_inst *fi;
|
||||
struct rtp_stream *rtps;
|
||||
|
||||
fi = osmo_fsm_inst_alloc_child(&rtp_stream_fsm, parent_call_leg->fi, CALL_LEG_EV_RTP_STREAM_GONE);
|
||||
fi = osmo_fsm_inst_alloc_child(&rtp_stream_fsm, parent_fi, event_gone);
|
||||
OSMO_ASSERT(fi);
|
||||
|
||||
rtps = talloc(fi, struct rtp_stream);
|
||||
|
@ -124,7 +125,8 @@ struct rtp_stream *rtp_stream_alloc(struct call_leg *parent_call_leg, enum rtp_d
|
|||
fi->priv = rtps;
|
||||
*rtps = (struct rtp_stream){
|
||||
.fi = fi,
|
||||
.parent_call_leg = parent_call_leg,
|
||||
.event_avail = event_avail,
|
||||
.event_estab = event_estab,
|
||||
.call_id = call_id,
|
||||
.for_trans = for_trans,
|
||||
.dir = dir,
|
||||
|
@ -172,7 +174,7 @@ static void rtp_stream_fsm_establishing_established(struct osmo_fsm_inst *fi, ui
|
|||
if (crcx_info->x_osmo_osmux_use)
|
||||
rtps->local_osmux_cid = crcx_info->x_osmo_osmux_cid;
|
||||
rtp_stream_update_id(rtps);
|
||||
osmo_fsm_inst_dispatch(fi->proc.parent, CALL_LEG_EV_RTP_STREAM_ADDR_AVAILABLE, rtps);
|
||||
osmo_fsm_inst_dispatch(fi->proc.parent, rtps->event_avail, rtps);
|
||||
check_established(rtps);
|
||||
|
||||
if ((!rtps->remote_sent_to_mgw || !rtps->codecs_sent_to_mgw || !rtps->mode_sent_to_mgw)
|
||||
|
@ -212,7 +214,7 @@ static void rtp_stream_fsm_establishing_established(struct osmo_fsm_inst *fi, ui
|
|||
void rtp_stream_fsm_established_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
|
||||
{
|
||||
struct rtp_stream *rtps = fi->priv;
|
||||
osmo_fsm_inst_dispatch(fi->proc.parent, CALL_LEG_EV_RTP_STREAM_ESTABLISHED, rtps);
|
||||
osmo_fsm_inst_dispatch(fi->proc.parent, rtps->event_estab, rtps);
|
||||
}
|
||||
|
||||
static int rtp_stream_fsm_timer_cb(struct osmo_fsm_inst *fi)
|
||||
|
|
Loading…
Reference in New Issue