#define CHUNK_SIZE 128 * 1024
-extern int msg_to_buf(mblk_t *, char *, int);
-
/**
* data specific to the ortp receiver
*
uint32_t chunk_ts;
};
+
+static int msg_to_buf(mblk_t *mp, char *buffer, int len)
+{
+ int rlen = len;
+ mblk_t *m, *mprev;
+ int mlen;
+
+ m = mp->b_cont;
+ mprev = mp;
+ while (m != NULL) {
+ mlen = (int) (m->b_wptr - m->b_rptr);
+ if (mlen <= rlen) {
+ mblk_t *consumed = m;
+ memcpy (buffer, m->b_rptr, mlen);
+ /* go to next mblk_t */
+ mprev->b_cont = m->b_cont;
+ m = m->b_cont;
+ consumed->b_cont = NULL;
+ freeb (consumed);
+ buffer += mlen;
+ rlen -= mlen;
+ } else { /*if mlen>rlen */
+ memcpy (buffer, m->b_rptr, rlen);
+ m->b_rptr += rlen;
+ return len;
+ }
+ }
+ return len - rlen;
+}
+
+
static void ortp_recv_pre_select(struct sched *s, struct task *t)
{
struct receiver_node *rn = t->private_data;
struct private_ortp_recv_data *pord = rn->private_data;
struct timeval tmp;
- if (tv_diff(&s->now, &pord->next_chunk, &tmp) >= 0) {
+ if (tv_diff(now, &pord->next_chunk, &tmp) >= 0) {
tmp.tv_sec = 0;
tmp.tv_usec = 1000;
}
pord->next_chunk.tv_usec);
}
-static void ortp_recv_post_select(struct sched *s, struct task *t)
+static void ortp_recv_post_select(__a_unused struct sched *s, struct task *t)
{
struct receiver_node *rn = t->private_data;
struct private_ortp_recv_data *pord = rn->private_data;
unsigned chunk_time;
// PARA_INFO_LOG("rn: %p, pord: %p, session: %p\n", rn, pord, pord->session);
+ t->ret = -E_ORTP_RECV_EOF;
+ if (rn->output_eof && *rn->output_eof) {
+ rn->eof = 1;
+ return;
+ }
t->ret = 1;
if (pord->start.tv_sec)
- if (tv_diff(&s->now, &pord->next_chunk, NULL) < 0)
+ if (tv_diff(now, &pord->next_chunk, NULL) < 0)
return;
mp = rtp_session_recvm_with_ts(pord->session, pord->timestamp);
if (!mp) {
if ((pord->c_bad > 5000 && pord->start.tv_sec) || pord->c_bad > 10000)
return;
t->ret = 1;
- tv_add(&s->now, &min_delay, &pord->next_chunk);
+ tv_add(now, &min_delay, &pord->next_chunk);
return;
}
/* okay, we have a chunk of data */
if (!pord->start.tv_sec)
- pord->start = s->now;
+ pord->start = *now;
t->ret = msg_to_buf(mp, tmpbuf, CHUNK_SIZE);
if (t->ret < ORTP_AUDIO_HEADER_LEN) {
rn->eof = 1;
freemsg(mp);
if (pord->c_bad) {
pord->c_bad = 0;
- pord->next_chunk = s->now;
+ pord->next_chunk = *now;
}
compute_next_chunk(chunk_time, pord);
return;