pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/29259 )
Change subject: osmux: Use new osmux APIs to let libosmo-netif alloc struct osmux_out_handle ......................................................................
osmux: Use new osmux APIs to let libosmo-netif alloc struct osmux_out_handle
This way we don't need to worry about implementation details (struct size) in the future in case they change (they will).
Related: OS#5987 Requires: libosmo-netif.git Change-Id Ie8df581f375c9a183a7af60b431561bda82f6e34 Change-Id: I2d0d8c152b8f1234ddfcd74d6cb04b1818b41510 --- M include/osmocom/mgcp/mgcp_conn.h M src/libosmo-mgcp/mgcp_osmux.c 2 files changed, 12 insertions(+), 12 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/59/29259/1
diff --git a/include/osmocom/mgcp/mgcp_conn.h b/include/osmocom/mgcp/mgcp_conn.h index 7338027..a08c089 100644 --- a/include/osmocom/mgcp/mgcp_conn.h +++ b/include/osmocom/mgcp/mgcp_conn.h @@ -84,10 +84,10 @@ bool cid_allocated; /* Allocated Osmux circuit ID for this conn */ uint8_t cid; - /* handle to batch messages */ + /* handle to batch messages, shared (refcounted) among several conns */ struct osmux_in_handle *in; - /* handle to unbatch messages */ - struct osmux_out_handle out; + /* handle to unbatch messages, one allocated and owned per conn */ + struct osmux_out_handle *out; /* statistics */ struct { uint32_t chunks; diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c index abc3f0e..5ce850d 100644 --- a/src/libosmo-mgcp/mgcp_osmux.c +++ b/src/libosmo-mgcp/mgcp_osmux.c @@ -403,7 +403,7 @@ if (endp_osmux_state_check(conn_src->conn->endp, conn_src, false) == 0) { conn_src->osmux.stats.octets += osmux_chunk_length(msg, rem); conn_src->osmux.stats.chunks++; - osmux_xfrm_output_sched(&conn_src->osmux.out, osmuxh); + osmux_xfrm_output_sched(conn_src->osmux.out, osmuxh); } rem = msg->len; } @@ -494,12 +494,12 @@ return -1; }
- osmux_xfrm_output_init2(&conn->osmux.out, - (conn->osmux.cid * rtp_ssrc_winlen) + - (random() % rtp_ssrc_winlen), - conn->end.codec->payload_type); - - osmux_xfrm_output_set_tx_cb(&conn->osmux.out, + conn->osmux.out = osmux_xfrm_output_alloc(osmux); + osmux_xfrm_output_set_rtp_ssrc(conn->osmux.out, + (conn->osmux.cid * rtp_ssrc_winlen) + + (random() % rtp_ssrc_winlen)); + osmux_xfrm_output_set_rtp_pl_type(conn->osmux.out, conn->end.codec->payload_type); + osmux_xfrm_output_set_tx_cb(conn->osmux.out, scheduled_from_osmux_tx_rtp_cb, conn);
conn->osmux.state = OSMUX_STATE_ENABLED; @@ -519,8 +519,8 @@
if (conn->osmux.state == OSMUX_STATE_ENABLED) { /* We are closing, we don't need pending RTP packets to be transmitted */ - osmux_xfrm_output_set_tx_cb(&conn->osmux.out, NULL, NULL); - osmux_xfrm_output_flush(&conn->osmux.out); + osmux_xfrm_output_set_tx_cb(conn->osmux.out, NULL, NULL); + TALLOC_FREE(conn->osmux.out);
osmux_xfrm_input_close_circuit(conn->osmux.in, conn->osmux.cid); conn->osmux.state = OSMUX_STATE_DISABLED;