pa_rtp_context rtp_context;
pa_sap_context sap_context;
- size_t mtu;
pa_time_event *sap_event;
return;
}
- pa_rtp_send(&u->rtp_context, u->mtu, u->memblockq);
+ pa_rtp_send(&u->rtp_context, u->memblockq);
}
static pa_source_output_flags_t get_dont_inhibit_auto_suspend_flag(pa_source *source,
0,
NULL);
- u->mtu = mtu;
-
k = sizeof(sa_dst);
pa_assert_se((r = getsockname(fd, (struct sockaddr*) &sa_dst, &k)) >= 0);
pa_xfree(n);
- if (pa_rtp_context_init_send(&u->rtp_context, fd, payload, pa_frame_size(&ss)) < 0)
+ if (pa_rtp_context_init_send(&u->rtp_context, fd, payload, mtu, pa_frame_size(&ss)) < 0)
goto fail;
pa_sap_context_init_send(&u->sap_context, sap_fd, p);
#include "rtp.h"
-int pa_rtp_context_init_send(pa_rtp_context *c, int fd, uint8_t payload, size_t frame_size) {
+int pa_rtp_context_init_send(pa_rtp_context *c, int fd, uint8_t payload, size_t mtu, size_t frame_size) {
pa_assert(c);
pa_assert(fd >= 0);
c->ssrc = (uint32_t) (rand()*rand());
c->payload = (uint8_t) (payload & 127U);
c->frame_size = frame_size;
+ c->mtu = mtu;
c->recv_buf = NULL;
c->recv_buf_size = 0;
#define MAX_IOVECS 16
-int pa_rtp_send(pa_rtp_context *c, size_t size, pa_memblockq *q) {
+int pa_rtp_send(pa_rtp_context *c, pa_memblockq *q) {
struct iovec iov[MAX_IOVECS];
pa_memblock* mb[MAX_IOVECS];
int iov_idx = 1;
size_t n = 0;
pa_assert(c);
- pa_assert(size > 0);
pa_assert(q);
- if (pa_memblockq_get_length(q) < size)
+ if (pa_memblockq_get_length(q) < c->mtu)
return 0;
for (;;) {
if ((r = pa_memblockq_peek(q, &chunk)) >= 0) {
- size_t k = n + chunk.length > size ? size - n : chunk.length;
+ size_t k = n + chunk.length > c->mtu ? c->mtu - n : chunk.length;
pa_assert(chunk.memblock);
pa_assert(n % c->frame_size == 0);
- if (r < 0 || n >= size || iov_idx >= MAX_IOVECS) {
+ if (r < 0 || n >= c->mtu || iov_idx >= MAX_IOVECS) {
uint32_t header[3];
struct msghdr m;
ssize_t k;
return -1;
}
- if (r < 0 || pa_memblockq_get_length(q) < size)
+ if (r < 0 || pa_memblockq_get_length(q) < c->mtu)
break;
n = 0;
uint32_t ssrc;
uint8_t payload;
size_t frame_size;
+ size_t mtu;
uint8_t *recv_buf;
size_t recv_buf_size;
pa_memchunk memchunk;
} pa_rtp_context;
-int pa_rtp_context_init_send(pa_rtp_context *c, int fd, uint8_t payload, size_t frame_size);
+int pa_rtp_context_init_send(pa_rtp_context *c, int fd, uint8_t payload, size_t mtu, size_t frame_size);
/* If the memblockq doesn't have a silence memchunk set, then the caller must
* guarantee that the current read index doesn't point to a hole. */
-int pa_rtp_send(pa_rtp_context *c, size_t size, pa_memblockq *q);
+int pa_rtp_send(pa_rtp_context *c, pa_memblockq *q);
pa_rtp_context* pa_rtp_context_init_recv(pa_rtp_context *c, int fd, size_t frame_size);
int pa_rtp_recv(pa_rtp_context *c, pa_memchunk *chunk, pa_mempool *pool, struct timeval *tstamp);