pespin has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-netif/+/29260 )
Change subject: osmux: Allow the user to alloc msgbs used to provide generated RTP
packets
......................................................................
osmux: Allow the user to alloc msgbs used to provide generated RTP packets
This is useful for users of the API which need to keep forwarding the
msgb to lower layers which may need prepending a new header to the msgb,
like osmo-bts with l1sap.
Related: SYS#5987
Change-Id: I632654221826340423e1e97b0f8ed9a2baf6c6c3
---
M include/osmocom/netif/osmux.h
M src/osmux.c
2 files changed, 27 insertions(+), 4 deletions(-)
Approvals:
pespin: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/include/osmocom/netif/osmux.h b/include/osmocom/netif/osmux.h
index 8742797..c663c1b 100644
--- a/include/osmocom/netif/osmux.h
+++ b/include/osmocom/netif/osmux.h
@@ -75,6 +75,8 @@
#define OSMUX_MAX_CONCURRENT_CALLS 8
+typedef struct msgb *(*rtp_msgb_alloc_cb_t)(void *rtp_msgb_alloc_priv_data,
+ unsigned int msg_len);
/* one per OSmux circuit_id, ie. one per RTP flow. */
struct osmux_out_handle {
uint16_t rtp_seq;
@@ -86,6 +88,8 @@
struct llist_head list;
void (*tx_cb)(struct msgb *msg, void *data); /* Used defined rtp tx callback */
void *data; /* User defined opaque data structure */
+ rtp_msgb_alloc_cb_t rtp_msgb_alloc_cb; /* User defined msgb alloc function for generated
RTP pkts */
+ void *rtp_msgb_alloc_cb_data; /* Opaque data pointer set by user and passed in
rtp_msgb_alloc_cb() */
};
static inline uint8_t *osmux_get_payload(struct osmux_hdr *osmuxh)
@@ -113,6 +117,7 @@
void osmux_xfrm_output_set_rtp_ssrc(struct osmux_out_handle *h, uint32_t rtp_ssrc);
void osmux_xfrm_output_set_rtp_pl_type(struct osmux_out_handle *h, uint32_t
rtp_payload_type);
void osmux_xfrm_output_set_tx_cb(struct osmux_out_handle *h, void (*tx_cb)(struct msgb
*msg, void *data), void *data);
+void osmux_xfrm_output_set_rtp_msgb_alloc_cb(struct osmux_out_handle *h,
rtp_msgb_alloc_cb_t cb, void *cb_data);
int osmux_xfrm_output_sched(struct osmux_out_handle *h, struct osmux_hdr *osmuxh);
void osmux_xfrm_output_flush(struct osmux_out_handle *h);
struct osmux_hdr *osmux_xfrm_output_pull(struct msgb *msg);
diff --git a/src/osmux.c b/src/osmux.c
index 63342fa..71afe5c 100644
--- a/src/osmux.c
+++ b/src/osmux.c
@@ -127,11 +127,15 @@
struct rtp_hdr *rtph;
struct amr_hdr *amrh;
struct timespec delta = { .tv_sec = 0, .tv_nsec = DELTA_RTP_MSG*1000 };
+ unsigned int msg_len = sizeof(struct rtp_hdr) +
+ sizeof(struct amr_hdr) +
+ payload_len;
- out_msg = msgb_alloc(sizeof(struct rtp_hdr) +
- sizeof(struct amr_hdr) +
- osmo_amr_bytes(osmuxh->amr_ft),
- "OSMUX test");
+ if (h->rtp_msgb_alloc_cb) {
+ out_msg = h->rtp_msgb_alloc_cb(h->rtp_msgb_alloc_cb_data, msg_len);
+ } else {
+ out_msg = msgb_alloc(msg_len, "osmux-rtp");
+ }
if (out_msg == NULL)
return NULL;
@@ -932,6 +936,20 @@
h->data = data;
}
+/*! \brief Set callback to call when an RTP packet to be generated is to be allocated
+ * \param[in] h the osmux out handle handling a specific CID
+ * \param[in] cb User defined msgb alloc function for generated RTP pkts
+ * \param[in] cb_data Opaque data pointer set by user and passed in \ref cb
+ * \return msgb structure to be used to fill in generated RTP pkt content
+ */
+void osmux_xfrm_output_set_rtp_msgb_alloc_cb(struct osmux_out_handle *h,
+ rtp_msgb_alloc_cb_t cb,
+ void *cb_data)
+{
+ h->rtp_msgb_alloc_cb = cb;
+ h->rtp_msgb_alloc_cb_data = cb_data;
+}
+
/*! \brief Set SSRC of generated RTP packets from Osmux frames
* \param[in] h the osmux out handle handling a specific CID
* \param[in] rtp_ssrc the RTP SSRC to set
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-netif/+/29260
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I632654221826340423e1e97b0f8ed9a2baf6c6c3
Gerrit-Change-Number: 29260
Gerrit-PatchSet: 4
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged