laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-msc/+/33500 )

Change subject: ASCI: Allow usage of rtp_stream with other FSM
......................................................................

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
---
M include/osmocom/msc/rtp_stream.h
M src/libmsc/call_leg.c
M src/libmsc/rtp_stream.c
3 files changed, 31 insertions(+), 10 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified




diff --git a/include/osmocom/msc/rtp_stream.h b/include/osmocom/msc/rtp_stream.h
index c42657a..5bc0144 100644
--- a/include/osmocom/msc/rtp_stream.h
+++ b/include/osmocom/msc/rtp_stream.h
@@ -26,7 +26,8 @@
 /* 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 @@
 #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);
diff --git a/src/libmsc/call_leg.c b/src/libmsc/call_leg.c
index b078c77..d0dc642 100644
--- a/src/libmsc/call_leg.c
+++ b/src/libmsc/call_leg.c
@@ -303,7 +303,8 @@
                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;
 }
diff --git a/src/libmsc/rtp_stream.c b/src/libmsc/rtp_stream.c
index dcb4ef0..1f885c5 100644
--- a/src/libmsc/rtp_stream.c
+++ b/src/libmsc/rtp_stream.c
@@ -110,13 +110,14 @@
 /* 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 @@
        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 @@
                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 @@
 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)

--
To view, visit https://gerrit.osmocom.org/c/osmo-msc/+/33500
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Change-Id: I0991927b6d00da08dfd455980645e68281a73a9e
Gerrit-Change-Number: 33500
Gerrit-PatchSet: 9
Gerrit-Owner: jolly <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: neels <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to