osmux: Extend osmux_out_handle and add new API to set rtp payload_type

Previously payload_type was always hardcoded to 98 for generated rtp
packets from incoming osmux frame.

Change-Id: I5cbeb494a8932953d9fd2dc24dacf8cd97fd84e4
This commit is contained in:
Pau Espin 2019-05-17 17:11:02 +02:00
parent fd339712c4
commit f0f1ebf70e
7 changed files with 22 additions and 11 deletions

View File

@ -7,3 +7,5 @@
# If any interfaces have been added since the last public release: c:r:a + 1.
# If any interfaces have been removed or changed since the last public release: c:r:0.
#library what description / commit summary line
libosmo-netif Add new field to struct osmux_out_handle Breaks ABI with older versions
libosmo-netif Add new API osmux_xfrm_output_init2 Deprecates old osmux_xfrm_output_init

View File

@ -80,6 +80,7 @@ struct osmux_out_handle {
uint16_t rtp_seq;
uint32_t rtp_timestamp;
uint32_t rtp_ssrc;
uint8_t rtp_payload_type;
uint8_t osmux_seq_ack; /* Latest received seq num */
struct osmo_timer_list timer;
struct llist_head list;
@ -106,7 +107,8 @@ void osmux_xfrm_input_close_circuit(struct osmux_in_handle *h, int ccid);
int osmux_xfrm_input(struct osmux_in_handle *h, struct msgb *msg, int ccid);
void osmux_xfrm_input_deliver(struct osmux_in_handle *h);
void osmux_xfrm_output_init(struct osmux_out_handle *h, uint32_t rtp_ssrc);
void osmux_xfrm_output_init(struct osmux_out_handle *h, uint32_t rtp_ssrc) OSMO_DEPRECATED("Use osmux_xfrm_output_init2() instead");
void osmux_xfrm_output_init2(struct osmux_out_handle *h, uint32_t rtp_ssrc, uint8_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);
int osmux_xfrm_output(struct osmux_hdr *osmuxh, struct osmux_out_handle *h, struct llist_head *list) OSMO_DEPRECATED("Use osmux_xfrm_output_sched() instead");
int osmux_xfrm_output_sched(struct osmux_out_handle *h, struct osmux_hdr *osmuxh);

View File

@ -146,7 +146,7 @@ osmux_rebuild_rtp(struct osmux_out_handle *h, struct osmux_hdr *osmuxh,
rtph->csrc_count = 0;
rtph->extension = 0;
rtph->version = RTP_VERSION;
rtph->payload_type = 98;
rtph->payload_type = h->rtp_payload_type;
/* ... emulate timestamp and ssrc */
rtph->timestamp = htonl(h->rtp_timestamp);
rtph->sequence = htons(h->rtp_seq);
@ -999,16 +999,23 @@ osmux_tx_sched(struct llist_head *list,
}
}
void osmux_xfrm_output_init(struct osmux_out_handle *h, uint32_t rtp_ssrc)
void osmux_xfrm_output_init2(struct osmux_out_handle *h, uint32_t rtp_ssrc, uint8_t rtp_payload_type)
{
memset(h, 0, sizeof(*h));
h->rtp_seq = (uint16_t)random();
h->rtp_timestamp = (uint32_t)random();
h->rtp_ssrc = rtp_ssrc;
h->rtp_payload_type = rtp_payload_type;
INIT_LLIST_HEAD(&h->list);
osmo_timer_setup(&h->timer, osmux_xfrm_output_trigger, h);
}
void osmux_xfrm_output_init(struct osmux_out_handle *h, uint32_t rtp_ssrc)
{
/* backward compatibility with old users, where 98 was harcoded in osmux_rebuild_rtp() */
osmux_xfrm_output_init2(h, rtp_ssrc, 98);
}
#define SNPRINTF_BUFFER_SIZE(ret, remain, offset) \
if (ret < 0) \
ret = 0; \

View File

@ -517,7 +517,7 @@ void pcap_test() {
osmo_pcap.timer.cb = pcap_pkt_timer_cb;
if(opt_osmux) {
osmux_xfrm_output_init(&pcap_osmux_h, 0);
osmux_xfrm_output_init2(&pcap_osmux_h, 0, 98);
osmux_xfrm_output_set_tx_cb(&pcap_osmux_h, glue_cb, NULL);
}

View File

@ -189,7 +189,7 @@ int main(int argc, char *argv[])
osmo_pcap.timer.cb = osmo_pcap_pkt_timer_cb;
osmux_xfrm_input_init(&h_input);
osmux_xfrm_output_init(&h_output);
osmux_xfrm_output_init2(&h_output, 0, 98);
osmux_xfrm_output_set_tx_cb(&h_output, tx_cb, NULL);
/* first run */

View File

@ -269,7 +269,7 @@ int main(void)
osmo_init_logging2(tall_ctx, &osmux_test_log_info);
log_set_log_level(osmo_stderr_target, LOGL_DEBUG);
osmux_xfrm_output_init(&h_output, 0x7000000);
osmux_xfrm_output_init2(&h_output, 0x7000000, 98);
osmux_xfrm_output_set_tx_cb(&h_output, tx_cb, NULL);
/* If the test takes longer than 10 seconds, abort it */

View File

@ -164,7 +164,7 @@ static void test_output_consecutive(void)
clock_override_enable(true);
clock_override_set(0, 0);
osmux_init(32);
osmux_xfrm_output_init(&h_output, 0x7000000);
osmux_xfrm_output_init2(&h_output, 0x7000000, 98);
h_output.rtp_seq = (uint16_t)50;
h_output.rtp_timestamp = (uint32_t)500;
osmux_xfrm_output_set_tx_cb(&h_output, tx_cb, &h_output);
@ -226,7 +226,7 @@ static void test_output_interleaved(void)
clock_override_enable(true);
clock_override_set(0, 0);
osmux_init(32);
osmux_xfrm_output_init(&h_output, 0x7000000);
osmux_xfrm_output_init2(&h_output, 0x7000000, 98);
h_output.rtp_seq = (uint16_t)50;
h_output.rtp_timestamp = (uint32_t)500;
osmux_xfrm_output_set_tx_cb(&h_output, tx_cb, &h_output);
@ -263,7 +263,7 @@ static void test_output_2together(void)
clock_override_enable(true);
clock_override_set(0, 0);
osmux_init(32);
osmux_xfrm_output_init(&h_output, 0x7000000);
osmux_xfrm_output_init2(&h_output, 0x7000000, 98);
h_output.rtp_seq = (uint16_t)50;
h_output.rtp_timestamp = (uint32_t)500;
osmux_xfrm_output_set_tx_cb(&h_output, tx_cb, &h_output);
@ -297,7 +297,7 @@ static void test_output_frame_lost(void)
clock_override_enable(true);
clock_override_set(0, 0);
osmux_init(32);
osmux_xfrm_output_init(&h_output, 0x7000000);
osmux_xfrm_output_init2(&h_output, 0x7000000, 98);
h_output.rtp_seq = (uint16_t)50;
h_output.rtp_timestamp = (uint32_t)500;
osmux_xfrm_output_set_tx_cb(&h_output, tx_cb, &h_output);
@ -329,7 +329,7 @@ static void test_output_flush(void)
clock_override_enable(true);
clock_override_set(0, 0);
osmux_init(32);
osmux_xfrm_output_init(&h_output, 0x7000000);
osmux_xfrm_output_init2(&h_output, 0x7000000, 98);
h_output.rtp_seq = (uint16_t)50;
h_output.rtp_timestamp = (uint32_t)500;
osmux_xfrm_output_set_tx_cb(&h_output, tx_cb, &h_output);