2012-07-09 17:39:55 +00:00
|
|
|
/*
|
|
|
|
* (C) 2012 by Pablo Neira Ayuso <pablo@gnumonks.org>
|
|
|
|
* (C) 2012 by On Waves ehf <http://www.on-waves.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <osmocom/core/msgb.h>
|
|
|
|
#include <osmocom/core/timer.h>
|
|
|
|
#include <osmocom/core/select.h>
|
2012-07-19 09:08:21 +00:00
|
|
|
#include <osmocom/core/talloc.h>
|
2012-07-19 11:04:39 +00:00
|
|
|
#include <osmocom/core/logging.h>
|
2012-07-09 17:39:55 +00:00
|
|
|
|
|
|
|
#include <osmocom/netif/amr.h>
|
|
|
|
#include <osmocom/netif/rtp.h>
|
|
|
|
#include <osmocom/netif/osmux.h>
|
|
|
|
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
2012-07-19 10:53:04 +00:00
|
|
|
#define DEBUG_TIMING 1
|
|
|
|
|
2012-08-02 18:24:31 +00:00
|
|
|
/* XXX: MTU - iphdr (20 bytes) - udphdr (8 bytes) */
|
|
|
|
#define OSMUX_BATCH_MAX 1472
|
2012-07-09 17:39:55 +00:00
|
|
|
|
2012-08-04 17:56:47 +00:00
|
|
|
/* delta time between two RTP messages */
|
2012-10-15 19:42:00 +00:00
|
|
|
#define DELTA_RTP_MSG 16000
|
|
|
|
#define DELTA_RTP_TIMESTAMP 160
|
2012-08-04 17:56:47 +00:00
|
|
|
|
2012-07-09 17:39:55 +00:00
|
|
|
struct osmux_hdr *osmux_xfrm_output_pull(struct msgb *msg)
|
|
|
|
{
|
|
|
|
struct osmux_hdr *osmuxh = NULL;
|
|
|
|
|
|
|
|
if (msg->len > sizeof(struct osmux_hdr)) {
|
|
|
|
osmuxh = (struct osmux_hdr *)msg->data;
|
|
|
|
|
2012-07-13 19:16:30 +00:00
|
|
|
msgb_pull(msg, sizeof(struct osmux_hdr) +
|
2013-02-12 18:22:45 +00:00
|
|
|
(osmo_amr_bytes(osmuxh->amr_ft) * (osmuxh->ctr+1)));
|
2012-07-09 17:39:55 +00:00
|
|
|
} else if (msg->len > 0) {
|
2012-10-15 13:59:14 +00:00
|
|
|
LOGP(DLMIB, LOGL_ERROR,
|
2012-07-19 11:04:39 +00:00
|
|
|
"remaining %d bytes, broken osmuxhdr?\n", msg->len);
|
2012-07-09 17:39:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return osmuxh;
|
|
|
|
}
|
|
|
|
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
static struct msgb *
|
|
|
|
osmux_rebuild_rtp(struct osmux_out_handle *h,
|
|
|
|
struct osmux_hdr *osmuxh, void *payload, int payload_len)
|
2012-07-09 17:39:55 +00:00
|
|
|
{
|
|
|
|
struct msgb *out_msg;
|
|
|
|
struct rtp_hdr *rtph;
|
|
|
|
struct amr_hdr *amrh;
|
2012-08-06 16:56:36 +00:00
|
|
|
uint32_t ssrc_from_ccid = osmuxh->circuit_id;
|
2012-08-06 15:45:21 +00:00
|
|
|
char buf[4096];
|
2012-07-09 17:39:55 +00:00
|
|
|
|
|
|
|
out_msg = msgb_alloc(sizeof(struct rtp_hdr) +
|
|
|
|
sizeof(struct amr_hdr) +
|
2013-02-12 18:22:45 +00:00
|
|
|
osmo_amr_bytes(osmuxh->amr_ft),
|
2012-07-13 19:16:30 +00:00
|
|
|
"OSMUX test");
|
2012-07-09 17:39:55 +00:00
|
|
|
if (out_msg == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Reconstruct RTP header */
|
|
|
|
rtph = (struct rtp_hdr *)out_msg->data;
|
2012-08-06 16:49:05 +00:00
|
|
|
rtph->csrc_count = 0;
|
2012-07-09 17:39:55 +00:00
|
|
|
rtph->extension = 0;
|
|
|
|
rtph->version = RTP_VERSION;
|
|
|
|
rtph->payload_type = 98;
|
|
|
|
/* ... emulate timestamp and ssrc */
|
2013-02-12 16:23:29 +00:00
|
|
|
rtph->timestamp = htonl(h->rtp_timestamp);
|
|
|
|
rtph->sequence = htons(h->rtp_seq);
|
2012-08-06 16:56:36 +00:00
|
|
|
rtph->ssrc = htonl(ssrc_from_ccid);
|
2012-07-09 17:39:55 +00:00
|
|
|
|
|
|
|
msgb_put(out_msg, sizeof(struct rtp_hdr));
|
|
|
|
|
|
|
|
/* Reconstruct AMR header */
|
|
|
|
amrh = (struct amr_hdr *)out_msg->tail;
|
|
|
|
amrh->cmr = osmuxh->amr_cmr;
|
|
|
|
amrh->f = osmuxh->amr_f;
|
|
|
|
amrh->ft = osmuxh->amr_ft;
|
|
|
|
amrh->q = osmuxh->amr_q;
|
|
|
|
|
|
|
|
msgb_put(out_msg, sizeof(struct amr_hdr));
|
|
|
|
|
|
|
|
/* add AMR speech data */
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
memcpy(out_msg->tail, payload, payload_len);
|
|
|
|
msgb_put(out_msg, payload_len);
|
2012-07-09 17:39:55 +00:00
|
|
|
|
|
|
|
/* bump last RTP sequence number and timestamp that has been used */
|
2013-02-12 16:23:29 +00:00
|
|
|
h->rtp_seq++;
|
|
|
|
h->rtp_timestamp += DELTA_RTP_TIMESTAMP;
|
2012-07-09 17:39:55 +00:00
|
|
|
|
2012-08-06 15:45:21 +00:00
|
|
|
osmo_rtp_snprintf(buf, sizeof(buf), out_msg);
|
2012-10-15 13:59:14 +00:00
|
|
|
LOGP(DLMIB, LOGL_DEBUG, "%s\n", buf);
|
2012-08-06 15:45:21 +00:00
|
|
|
|
2012-07-09 17:39:55 +00:00
|
|
|
return out_msg;
|
|
|
|
}
|
|
|
|
|
2012-08-04 17:56:47 +00:00
|
|
|
int osmux_xfrm_output(struct osmux_hdr *osmuxh, struct osmux_out_handle *h,
|
|
|
|
struct llist_head *list)
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
{
|
2012-08-04 17:56:47 +00:00
|
|
|
struct msgb *msg;
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
int i;
|
|
|
|
|
2012-08-04 17:56:47 +00:00
|
|
|
INIT_LLIST_HEAD(list);
|
|
|
|
|
|
|
|
for (i=0; i<osmuxh->ctr+1; i++) {
|
2012-10-15 18:33:32 +00:00
|
|
|
struct rtp_hdr *rtph;
|
|
|
|
char buf[4096];
|
|
|
|
|
2012-08-04 17:56:47 +00:00
|
|
|
msg = osmux_rebuild_rtp(h, osmuxh,
|
|
|
|
osmux_get_payload(osmuxh) +
|
2013-02-12 18:22:45 +00:00
|
|
|
i * osmo_amr_bytes(osmuxh->amr_ft),
|
|
|
|
osmo_amr_bytes(osmuxh->amr_ft));
|
2012-08-04 17:56:47 +00:00
|
|
|
if (msg == NULL)
|
2012-10-15 18:33:32 +00:00
|
|
|
continue;
|
2012-08-04 17:56:47 +00:00
|
|
|
|
2012-10-15 18:33:32 +00:00
|
|
|
rtph = osmo_rtp_get_hdr(msg);
|
|
|
|
if (rtph == NULL)
|
|
|
|
continue;
|
2012-08-04 17:56:47 +00:00
|
|
|
|
2012-10-15 18:33:32 +00:00
|
|
|
osmo_rtp_snprintf(buf, sizeof(buf), msg);
|
|
|
|
LOGP(DLMIB, LOGL_DEBUG, "extracted: %s\n", buf);
|
2012-08-04 17:56:47 +00:00
|
|
|
llist_add_tail(&msg->list, list);
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
}
|
2012-08-04 17:56:47 +00:00
|
|
|
return i;
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
}
|
|
|
|
|
2012-08-06 16:41:49 +00:00
|
|
|
struct osmux_batch {
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
struct osmo_timer_list timer;
|
|
|
|
struct osmux_hdr *osmuxh;
|
2012-10-15 18:33:32 +00:00
|
|
|
struct llist_head node_list;
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
unsigned int remaining_bytes;
|
|
|
|
uint8_t seq;
|
2012-08-06 16:41:49 +00:00
|
|
|
};
|
2012-07-09 17:39:55 +00:00
|
|
|
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
static int
|
2012-10-20 18:10:31 +00:00
|
|
|
osmux_batch_put(struct osmux_in_handle *h, struct msgb *out_msg,
|
2012-08-06 16:41:49 +00:00
|
|
|
struct msgb *msg, struct rtp_hdr *rtph,
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
struct amr_hdr *amrh, uint32_t amr_payload_len,
|
2012-10-20 18:10:31 +00:00
|
|
|
int ccid, int add_osmux_header)
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
{
|
2013-02-11 21:49:27 +00:00
|
|
|
struct osmux_batch *batch = (struct osmux_batch *)h->internal_data;
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
struct osmux_hdr *osmuxh;
|
|
|
|
|
|
|
|
if (add_osmux_header) {
|
|
|
|
osmuxh = (struct osmux_hdr *)out_msg->tail;
|
|
|
|
osmuxh->ft = OSMUX_FT_VOICE_AMR;
|
|
|
|
osmuxh->ctr = 0;
|
|
|
|
osmuxh->amr_f = amrh->f;
|
|
|
|
osmuxh->amr_q= amrh->q;
|
2012-08-06 16:41:49 +00:00
|
|
|
osmuxh->seq = batch->seq++;
|
2012-10-20 18:10:31 +00:00
|
|
|
osmuxh->circuit_id = ccid;
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
osmuxh->amr_cmr = amrh->cmr;
|
|
|
|
osmuxh->amr_ft = amrh->ft;
|
|
|
|
msgb_put(out_msg, sizeof(struct osmux_hdr));
|
|
|
|
|
|
|
|
/* annotate current osmux header */
|
2012-08-06 16:41:49 +00:00
|
|
|
batch->osmuxh = osmuxh;
|
2012-08-04 18:52:45 +00:00
|
|
|
} else {
|
2012-08-06 16:41:49 +00:00
|
|
|
if (batch->osmuxh->ctr == 0x7) {
|
2012-10-15 13:59:14 +00:00
|
|
|
LOGP(DLMIB, LOGL_ERROR, "cannot add msg=%p, "
|
2012-08-04 18:52:45 +00:00
|
|
|
"too many messages for this RTP ssrc=%u\n",
|
|
|
|
msg, rtph->ssrc);
|
|
|
|
return 0;
|
|
|
|
}
|
2012-08-06 16:41:49 +00:00
|
|
|
batch->osmuxh->ctr++;
|
2012-08-04 18:52:45 +00:00
|
|
|
}
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
|
|
|
|
memcpy(out_msg->tail, osmo_amr_get_payload(amrh), amr_payload_len);
|
|
|
|
msgb_put(out_msg, amr_payload_len);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-08-06 16:41:49 +00:00
|
|
|
osmux_xfrm_encode_amr(struct osmux_in_handle *h,
|
|
|
|
struct msgb *out_msg,
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
struct rtp_hdr *rtph, struct msgb *msg,
|
2012-10-20 18:10:31 +00:00
|
|
|
int ccid, int add_osmux_header)
|
2012-07-09 17:39:55 +00:00
|
|
|
{
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
struct amr_hdr *amrh;
|
|
|
|
uint32_t amr_len;
|
|
|
|
uint32_t amr_payload_len;
|
|
|
|
|
|
|
|
amrh = osmo_rtp_get_payload(rtph, msg, &amr_len);
|
|
|
|
if (amrh == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
amr_payload_len = amr_len - sizeof(struct amr_hdr);
|
|
|
|
|
2012-10-20 18:10:31 +00:00
|
|
|
if (osmux_batch_put(h, out_msg, msg, rtph, amrh, amr_payload_len,
|
|
|
|
ccid, add_osmux_header) < 0)
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-15 18:33:32 +00:00
|
|
|
struct batch_list_node {
|
|
|
|
struct llist_head head;
|
|
|
|
uint32_t ssrc;
|
2012-10-20 18:10:31 +00:00
|
|
|
int ccid;
|
2012-10-15 18:33:32 +00:00
|
|
|
struct llist_head list;
|
|
|
|
};
|
|
|
|
|
2012-08-06 16:41:49 +00:00
|
|
|
static struct msgb *osmux_build_batch(struct osmux_in_handle *h)
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
{
|
2012-10-15 18:33:32 +00:00
|
|
|
struct msgb *batch_msg;
|
|
|
|
struct batch_list_node *node, *tnode;
|
2013-02-11 21:49:27 +00:00
|
|
|
struct osmux_batch *batch = (struct osmux_batch *)h->internal_data;
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
|
2012-10-15 18:33:32 +00:00
|
|
|
LOGP(DLMIB, LOGL_DEBUG, "Now building batch\n");
|
|
|
|
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
batch_msg = msgb_alloc(OSMUX_BATCH_MAX, "OSMUX");
|
|
|
|
if (batch_msg == NULL) {
|
2012-10-15 13:59:14 +00:00
|
|
|
LOGP(DLMIB, LOGL_ERROR, "Not enough memory\n");
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-10-15 18:33:32 +00:00
|
|
|
llist_for_each_entry_safe(node, tnode, &batch->node_list, head) {
|
|
|
|
struct msgb *cur, *tmp;
|
|
|
|
int ctr = 0;
|
2012-08-04 18:56:53 +00:00
|
|
|
|
2012-10-15 18:33:32 +00:00
|
|
|
llist_for_each_entry_safe(cur, tmp, &node->list, list) {
|
|
|
|
struct rtp_hdr *rtph;
|
|
|
|
char buf[4096];
|
|
|
|
int add_osmux_hdr = 0;
|
2012-08-06 15:45:21 +00:00
|
|
|
|
2012-10-15 18:33:32 +00:00
|
|
|
osmo_rtp_snprintf(buf, sizeof(buf), cur);
|
|
|
|
LOGP(DLMIB, LOGL_DEBUG, "built: %s\n", buf);
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
|
2012-10-15 18:33:32 +00:00
|
|
|
rtph = osmo_rtp_get_hdr(cur);
|
|
|
|
if (rtph == NULL)
|
|
|
|
return NULL;
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
|
2012-10-15 18:33:32 +00:00
|
|
|
if (ctr == 0) {
|
|
|
|
LOGP(DLMIB, LOGL_DEBUG, "add osmux header\n");
|
|
|
|
add_osmux_hdr = 1;
|
|
|
|
}
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
|
2012-10-15 18:33:32 +00:00
|
|
|
osmux_xfrm_encode_amr(h, batch_msg, rtph, cur,
|
2012-10-20 18:10:31 +00:00
|
|
|
node->ccid, add_osmux_hdr);
|
2012-10-15 18:33:32 +00:00
|
|
|
llist_del(&cur->list);
|
|
|
|
msgb_free(cur);
|
|
|
|
ctr++;
|
|
|
|
}
|
|
|
|
llist_del(&node->head);
|
|
|
|
talloc_free(node);
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
}
|
|
|
|
return batch_msg;
|
2012-07-09 17:39:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void osmux_xfrm_input_deliver(struct osmux_in_handle *h)
|
|
|
|
{
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
struct msgb *batch_msg;
|
2013-02-11 21:49:27 +00:00
|
|
|
struct osmux_batch *batch = (struct osmux_batch *)h->internal_data;
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
|
2012-10-15 13:59:14 +00:00
|
|
|
LOGP(DLMIB, LOGL_DEBUG, "invoking delivery function\n");
|
2012-08-06 16:41:49 +00:00
|
|
|
batch_msg = osmux_build_batch(h);
|
2013-02-11 21:49:27 +00:00
|
|
|
h->deliver(batch_msg, h->data);
|
2012-08-06 16:41:49 +00:00
|
|
|
osmo_timer_del(&batch->timer);
|
|
|
|
batch->remaining_bytes = OSMUX_BATCH_MAX;
|
2012-07-09 17:39:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void osmux_batch_timer_expired(void *data)
|
|
|
|
{
|
|
|
|
struct osmux_in_handle *h = data;
|
|
|
|
|
2012-10-15 18:33:32 +00:00
|
|
|
LOGP(DLMIB, LOGL_DEBUG, "osmux_batch_timer_expired\n");
|
2012-07-09 17:39:55 +00:00
|
|
|
osmux_xfrm_input_deliver(h);
|
|
|
|
}
|
|
|
|
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
static int osmux_rtp_amr_payload_len(struct msgb *msg, struct rtp_hdr *rtph)
|
2012-07-09 17:39:55 +00:00
|
|
|
{
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
struct amr_hdr *amrh;
|
|
|
|
unsigned int amr_len;
|
2012-07-09 17:39:55 +00:00
|
|
|
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
amrh = osmo_rtp_get_payload(rtph, msg, &amr_len);
|
|
|
|
if (amrh == NULL)
|
|
|
|
return -1;
|
2012-07-09 17:39:55 +00:00
|
|
|
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
return amr_len - sizeof(struct amr_hdr);
|
2012-07-09 17:39:55 +00:00
|
|
|
}
|
|
|
|
|
2012-08-06 16:41:49 +00:00
|
|
|
static int
|
2012-10-20 18:10:31 +00:00
|
|
|
osmux_batch_add(struct osmux_batch *batch, struct msgb *msg, int ccid)
|
2012-07-09 17:39:55 +00:00
|
|
|
{
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
struct rtp_hdr *rtph;
|
2012-10-15 18:33:32 +00:00
|
|
|
struct batch_list_node *node;
|
|
|
|
int found = 0, bytes = 0;
|
2012-07-09 17:39:55 +00:00
|
|
|
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
rtph = osmo_rtp_get_hdr(msg);
|
|
|
|
if (rtph == NULL)
|
2012-10-15 18:33:32 +00:00
|
|
|
return 0;
|
2012-07-09 17:39:55 +00:00
|
|
|
|
2012-10-15 18:33:32 +00:00
|
|
|
/* Yes, there is room. Check if we have more message with same ssrc */
|
|
|
|
llist_for_each_entry(node, &batch->node_list, head) {
|
|
|
|
if (node->ssrc == rtph->ssrc) {
|
|
|
|
found = 1;
|
2012-08-04 18:53:57 +00:00
|
|
|
break;
|
2012-08-06 19:00:49 +00:00
|
|
|
}
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
}
|
2012-08-04 18:53:57 +00:00
|
|
|
|
2012-10-15 18:33:32 +00:00
|
|
|
/* First check if there is room for this message in the batch */
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
bytes += osmux_rtp_amr_payload_len(msg, rtph);
|
2012-10-15 18:33:32 +00:00
|
|
|
if (!found)
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
bytes += sizeof(struct osmux_hdr);
|
|
|
|
|
2012-10-15 18:33:32 +00:00
|
|
|
/* No room, sorry. You'll have to retry */
|
2012-08-06 16:41:49 +00:00
|
|
|
if (bytes > batch->remaining_bytes)
|
2012-07-09 17:39:55 +00:00
|
|
|
return 1;
|
|
|
|
|
2012-10-15 18:33:32 +00:00
|
|
|
if (found) {
|
|
|
|
struct msgb *cur;
|
2012-08-06 19:00:49 +00:00
|
|
|
|
2012-10-15 18:33:32 +00:00
|
|
|
/* Extra validation: check if this message already exists,
|
|
|
|
* should not happen but make sure we don't propagate
|
|
|
|
* duplicated messages.
|
|
|
|
*/
|
|
|
|
llist_for_each_entry(cur, &node->list, list) {
|
|
|
|
struct rtp_hdr *rtph2 = osmo_rtp_get_hdr(cur);
|
|
|
|
if (rtph2 == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Already exists message with this sequence, skip */
|
|
|
|
if (rtph2->sequence == rtph->sequence) {
|
|
|
|
LOGP(DLMIB, LOGL_DEBUG, "already exists "
|
|
|
|
"message with seq=%u, skip it\n",
|
|
|
|
rtph->sequence);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* This is the first message with that ssrc we've seen */
|
|
|
|
node = talloc_zero(NULL, struct batch_list_node);
|
|
|
|
if (node == NULL)
|
|
|
|
return 0;
|
2012-07-09 17:39:55 +00:00
|
|
|
|
2012-10-20 18:10:31 +00:00
|
|
|
node->ccid = ccid;
|
2012-10-15 18:33:32 +00:00
|
|
|
node->ssrc = rtph->ssrc;
|
|
|
|
INIT_LLIST_HEAD(&node->list);
|
|
|
|
llist_add_tail(&node->head, &batch->node_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
LOGP(DLMIB, LOGL_DEBUG, "adding msg with ssrc=%u to batch\n",
|
|
|
|
rtph->ssrc);
|
|
|
|
llist_add_tail(&msg->list, &node->list);
|
|
|
|
|
|
|
|
/* Update remaining room in this batch */
|
|
|
|
batch->remaining_bytes -= bytes;
|
2012-07-09 17:39:55 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* osmux_xfrm_input - add RTP message to OSmux batch
|
|
|
|
* \param msg: RTP message that you want to batch into one OSmux message
|
|
|
|
*
|
2012-10-15 18:33:32 +00:00
|
|
|
* If 0 is returned, this indicates that the message has been batched or that
|
|
|
|
* an error occured and we have skipped the message. If 1 is returned, you
|
|
|
|
* have to invoke osmux_xfrm_input_deliver and try again.
|
2012-07-09 17:39:55 +00:00
|
|
|
*/
|
2012-10-20 18:10:31 +00:00
|
|
|
int osmux_xfrm_input(struct osmux_in_handle *h, struct msgb *msg, int ccid)
|
2012-07-09 17:39:55 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct rtp_hdr *rtph;
|
2013-02-11 21:49:27 +00:00
|
|
|
struct osmux_batch *batch = (struct osmux_batch *)h->internal_data;
|
2012-07-09 17:39:55 +00:00
|
|
|
|
|
|
|
rtph = osmo_rtp_get_hdr(msg);
|
|
|
|
if (rtph == NULL)
|
2012-10-15 18:33:32 +00:00
|
|
|
return 0;
|
2012-07-09 17:39:55 +00:00
|
|
|
|
|
|
|
switch(rtph->payload_type) {
|
|
|
|
case RTP_PT_RTCP:
|
|
|
|
return 0;
|
|
|
|
case RTP_PT_AMR:
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
/* This is the first message in the batch, start the
|
|
|
|
* batch timer to deliver it.
|
|
|
|
*/
|
2012-10-15 18:33:32 +00:00
|
|
|
if (llist_empty(&batch->node_list)) {
|
2012-10-15 13:59:14 +00:00
|
|
|
LOGP(DLMIB, LOGL_DEBUG,
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
"osmux start timer batch\n");
|
|
|
|
|
2012-08-06 16:41:49 +00:00
|
|
|
osmo_timer_schedule(&batch->timer, 0,
|
2012-08-06 16:45:18 +00:00
|
|
|
h->batch_factor * DELTA_RTP_MSG);
|
osmux: major rework to reduce batch message size (add counter field)
This patch adds the counter field to the osmux header, so we can
reduce the size of the batch even further, eg.
osmuxhdr (ctr=3)
speech
speech
speech
osmuxhdr (ctr=2)
speech
speech
...
The new header is the following:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FT | CTR |F|Q| SeqNR | Circuit ID |AMR-FT |AMR-CMR|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The counter field is 3 bits long, thus, we can batch up to 8
RTP speech frames into one single batch per circuit ID.
I have also removed the RTP marker, since it can be reconstructed
from the AMR information.
Moreover, the entire workflow has been also reworked. Whenever a
packet arrives, we introduce it into the batch list. This batch
list contains a list of RTP messages ordered by RTP SSRC. Then,
once the batch timer expires or the it gets full, we build the
batch from the list of RTP messages.
Note that this allows us to put several speech frame into one
single osmux header without actually worrying about the amount
of messages that we'll receive.
The functions that reconstruct the RTP messages has been also
adjusted. Now, it returns a list of RTP messages per RTP SSRC
that has been extracted from the batch.
2012-08-02 18:24:57 +00:00
|
|
|
}
|
2012-10-20 18:10:31 +00:00
|
|
|
ret = osmux_batch_add(batch, msg, ccid);
|
2012-07-09 17:39:55 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Only AMR supported so far, sorry. */
|
2012-10-15 18:33:32 +00:00
|
|
|
ret = 0;
|
2012-07-09 17:39:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void osmux_xfrm_input_init(struct osmux_in_handle *h)
|
|
|
|
{
|
2012-08-06 16:41:49 +00:00
|
|
|
struct osmux_batch *batch;
|
|
|
|
|
2012-10-15 13:59:14 +00:00
|
|
|
LOGP(DLMIB, LOGL_DEBUG, "initialized osmux input converter\n");
|
2012-08-06 16:41:49 +00:00
|
|
|
|
|
|
|
batch = talloc(NULL, struct osmux_batch);
|
|
|
|
if (batch == NULL)
|
|
|
|
return;
|
|
|
|
|
2012-10-15 18:33:32 +00:00
|
|
|
INIT_LLIST_HEAD(&batch->node_list);
|
2012-08-06 16:41:49 +00:00
|
|
|
batch->remaining_bytes = OSMUX_BATCH_MAX;
|
|
|
|
batch->timer.cb = osmux_batch_timer_expired;
|
|
|
|
batch->timer.data = h;
|
|
|
|
|
2013-02-11 21:49:27 +00:00
|
|
|
h->internal_data = (void *)batch;
|
2012-07-09 17:39:55 +00:00
|
|
|
}
|
2012-07-19 09:08:21 +00:00
|
|
|
|
|
|
|
struct osmux_tx_handle {
|
2012-08-04 17:56:47 +00:00
|
|
|
struct osmo_timer_list timer;
|
|
|
|
struct msgb *msg;
|
|
|
|
void (*tx_cb)(struct msgb *msg, void *data);
|
|
|
|
void *data;
|
2012-07-19 10:53:04 +00:00
|
|
|
#ifdef DEBUG_TIMING
|
|
|
|
struct timeval start;
|
2012-08-04 19:11:44 +00:00
|
|
|
struct timeval when;
|
2012-07-19 10:53:04 +00:00
|
|
|
#endif
|
2012-07-19 09:08:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void osmux_tx_cb(void *data)
|
|
|
|
{
|
|
|
|
struct osmux_tx_handle *h = data;
|
2012-07-19 10:53:04 +00:00
|
|
|
#ifdef DEBUG_TIMING
|
|
|
|
struct timeval now, diff;
|
|
|
|
|
|
|
|
gettimeofday(&now, NULL);
|
|
|
|
timersub(&now, &h->start, &diff);
|
2012-08-04 19:11:44 +00:00
|
|
|
timersub(&diff,&h->when, &diff);
|
2012-10-15 13:59:14 +00:00
|
|
|
LOGP(DLMIB, LOGL_DEBUG, "we are lagging %lu.%.6lu in scheduled "
|
2012-08-04 19:11:44 +00:00
|
|
|
"transmissions\n", diff.tv_sec, diff.tv_usec);
|
2012-07-19 10:53:04 +00:00
|
|
|
#endif
|
2012-07-19 09:08:21 +00:00
|
|
|
|
|
|
|
h->tx_cb(h->msg, h->data);
|
|
|
|
|
|
|
|
talloc_free(h);
|
|
|
|
}
|
|
|
|
|
2012-08-04 17:56:47 +00:00
|
|
|
static void
|
|
|
|
osmux_tx(struct msgb *msg, struct timeval *when,
|
|
|
|
void (*tx_cb)(struct msgb *msg, void *data), void *data)
|
2012-07-19 09:08:21 +00:00
|
|
|
{
|
|
|
|
struct osmux_tx_handle *h;
|
|
|
|
|
|
|
|
h = talloc_zero(NULL, struct osmux_tx_handle);
|
|
|
|
if (h == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
h->msg = msg;
|
|
|
|
h->tx_cb = tx_cb;
|
|
|
|
h->data = data;
|
|
|
|
h->timer.cb = osmux_tx_cb;
|
|
|
|
h->timer.data = h;
|
|
|
|
|
2012-07-19 10:53:04 +00:00
|
|
|
#ifdef DEBUG_TIMING
|
|
|
|
gettimeofday(&h->start, NULL);
|
2012-08-04 19:11:44 +00:00
|
|
|
h->when.tv_sec = when->tv_sec;
|
|
|
|
h->when.tv_usec = when->tv_usec;
|
2012-07-19 10:53:04 +00:00
|
|
|
#endif
|
2012-07-19 10:49:55 +00:00
|
|
|
/* send it now */
|
|
|
|
if (when->tv_sec == 0 && when->tv_usec == 0) {
|
|
|
|
osmux_tx_cb(h);
|
|
|
|
return;
|
|
|
|
}
|
2012-07-19 09:08:21 +00:00
|
|
|
osmo_timer_schedule(&h->timer, when->tv_sec, when->tv_usec);
|
|
|
|
}
|
2012-08-04 17:56:47 +00:00
|
|
|
|
|
|
|
void
|
2012-08-04 19:03:56 +00:00
|
|
|
osmux_tx_sched(struct llist_head *list,
|
2012-08-04 17:56:47 +00:00
|
|
|
void (*tx_cb)(struct msgb *msg, void *data), void *data)
|
|
|
|
{
|
|
|
|
struct msgb *cur, *tmp;
|
|
|
|
struct timeval delta = { .tv_sec = 0, .tv_usec = DELTA_RTP_MSG };
|
2012-08-04 19:03:56 +00:00
|
|
|
struct timeval when;
|
|
|
|
|
|
|
|
timerclear(&when);
|
2012-08-04 17:56:47 +00:00
|
|
|
|
|
|
|
llist_for_each_entry_safe(cur, tmp, list, list) {
|
|
|
|
|
2012-10-15 13:59:14 +00:00
|
|
|
LOGP(DLMIB, LOGL_DEBUG, "scheduled transmision in %lu.%6lu "
|
2012-08-04 19:03:56 +00:00
|
|
|
"seconds, msg=%p\n", when.tv_sec, when.tv_usec, cur);
|
2012-08-04 17:56:47 +00:00
|
|
|
|
2012-10-21 02:12:29 +00:00
|
|
|
osmux_tx(cur, &when, tx_cb, data);
|
2012-08-04 19:03:56 +00:00
|
|
|
timeradd(&when, &delta, &when);
|
2012-08-04 17:56:47 +00:00
|
|
|
llist_del(&cur->list);
|
|
|
|
}
|
|
|
|
}
|
2012-08-06 16:56:36 +00:00
|
|
|
|
2012-08-06 18:15:46 +00:00
|
|
|
void osmux_xfrm_output_init(struct osmux_out_handle *h)
|
|
|
|
{
|
2013-02-12 16:23:29 +00:00
|
|
|
h->rtp_seq = (uint16_t)random();
|
|
|
|
h->rtp_timestamp = (uint32_t)random();
|
2012-08-06 18:15:46 +00:00
|
|
|
}
|