aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@soleta.eu>2014-08-28 14:26:03 +0200
committerPablo Neira Ayuso <pablo@soleta.eu>2014-08-28 14:27:54 +0200
commit3789791b6b5b0bdbcb03e50d521040c813c659c0 (patch)
tree35c3d3326b03b35a90e473636fce4c67aa84cef5
parent0143d6ec18f441433b94b9b3765fb01228c117c1 (diff)
osmux: revisit osmux_batch_enqueue() in case of batch full
1) Force batch delivery in case it is full. 2) Skip padding with more RTP clone in case of message lost if the batch is full.
-rw-r--r--src/osmux.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/osmux.c b/src/osmux.c
index 97e78fa..61e3fc4 100644
--- a/src/osmux.c
+++ b/src/osmux.c
@@ -178,7 +178,7 @@ struct batch_list_node {
int nmsgs;
};
-static void osmux_batch_enqueue(struct msgb *msg, struct batch_list_node *node)
+static int osmux_batch_enqueue(struct msgb *msg, struct batch_list_node *node)
{
/* Too many messages per batch, discard it. The counter field of the
* osmux header is just 3 bits long, so make sure it doesn't overflow.
@@ -188,16 +188,17 @@ static void osmux_batch_enqueue(struct msgb *msg, struct batch_list_node *node)
rtph = osmo_rtp_get_hdr(msg);
if (rtph == NULL)
- return;
+ return -1;
LOGP(DLMIB, LOGL_ERROR, "too many messages for this RTP "
"ssrc=%u\n", rtph->ssrc);
msgb_free(msg);
- return;
+ return -1;
}
llist_add_tail(&msg->list, &node->list);
node->nmsgs++;
+ return 0;
}
static void osmux_batch_dequeue(struct msgb *msg, struct batch_list_node *node)
@@ -408,8 +409,11 @@ static void osmux_replay_lost_packets(struct batch_list_node *node,
rtph->timestamp = htonl(ntohl(rtph->timestamp) +
DELTA_RTP_TIMESTAMP);
+ /* No more room in this batch, skip padding with more clones */
+ if (osmux_batch_enqueue(clone, node) < 0)
+ break;
+
LOGP(DLMIB, LOGL_ERROR, "adding cloned RTP\n");
- osmux_batch_enqueue(clone, node);
}
}
@@ -474,9 +478,12 @@ osmux_batch_add(struct osmux_batch *batch, struct msgb *msg,
llist_add_tail(&node->head, &batch->node_list);
}
+ /* This batch is full, force batch delivery */
+ if (osmux_batch_enqueue(msg, node) < 0)
+ return 1;
+
LOGP(DLMIB, LOGL_DEBUG, "adding msg with ssrc=%u to batch\n",
rtph->ssrc);
- osmux_batch_enqueue(msg, node);
/* Update remaining room in this batch */
batch->remaining_bytes -= bytes;