summaryrefslogtreecommitdiff
path: root/src/stream.c
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-06-02 22:07:34 +0200
committerGitHub <noreply@github.com>2017-06-02 22:07:34 +0200
commit9c2b349424c49cd94e18c788e6fe9527d04be5d1 (patch)
treec295c3ec91f5ee51ff8bb482d9865e125fe1128c /src/stream.c
parent0338f6dca9ed181c2e182c7bf8185c23ec880adb (diff)
add RTP Header extension for Client-to-Mixer Audio Level Indication (#264)
* add RTP Header extension for Client-to-Mixer Audio Level Indication https://tools.ietf.org/html/rfc6464 requires libre from this commit or later: https://github.com/creytiv/re/commit/1544a1e375c76a80084b411d21b0431f95e9cdfb * fix warnings * fix warnings * minor cleanup
Diffstat (limited to 'src/stream.c')
-rw-r--r--src/stream.c67
1 files changed, 61 insertions, 6 deletions
diff --git a/src/stream.c b/src/stream.c
index acd4766..b9a0d6a 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -148,6 +148,61 @@ static void stream_destructor(void *arg)
}
+static void handle_rtp(struct stream *s, const struct rtp_header *hdr,
+ struct mbuf *mb)
+{
+ struct rtpext extv[8];
+ size_t extc = 0;
+
+ /* RFC 5285 -- A General Mechanism for RTP Header Extensions */
+ if (hdr->ext && hdr->x.len && mb) {
+
+ const size_t pos = mb->pos;
+ const size_t end = mb->end;
+ const size_t ext_stop = mb->pos;
+ size_t ext_len;
+ size_t i;
+ int err;
+
+ if (hdr->x.type != RTPEXT_TYPE_MAGIC) {
+ info("stream: unknown ext type ignored (0x%04x)\n",
+ hdr->x.type);
+ goto handler;
+ }
+
+ ext_len = hdr->x.len*sizeof(uint32_t);
+ if (mb->pos < ext_len) {
+ warning("stream: corrupt rtp packet,"
+ " not enough space for rtpext of %zu bytes\n",
+ ext_len);
+ return;
+ }
+
+ mb->pos = mb->pos - ext_len;
+ mb->end = ext_stop;
+
+ for (i=0; i<ARRAY_SIZE(extv) && mbuf_get_left(mb); i++) {
+
+ err = rtpext_decode(&extv[i], mb);
+ if (err) {
+ warning("stream: rtpext_decode failed (%m)\n",
+ err);
+ return;
+ }
+ }
+
+ extc = i;
+
+ mb->pos = pos;
+ mb->end = end;
+ }
+
+ handler:
+ s->rtph(hdr, extv, extc, mb, s->arg);
+
+}
+
+
static void rtp_recv(const struct sa *src, const struct rtp_header *hdr,
struct mbuf *mb, void *arg)
{
@@ -204,17 +259,17 @@ static void rtp_recv(const struct sa *src, const struct rtp_header *hdr,
s->jbuf_started = true;
if (lostcalc(s, hdr2.seq) > 0)
- s->rtph(hdr, NULL, s->arg);
+ handle_rtp(s, hdr, NULL);
- s->rtph(&hdr2, mb2, s->arg);
+ handle_rtp(s, &hdr2, mb2);
mem_deref(mb2);
}
else {
if (lostcalc(s, hdr->seq) > 0)
- s->rtph(hdr, NULL, s->arg);
+ handle_rtp(s, hdr, NULL);
- s->rtph(hdr, mb, s->arg);
+ handle_rtp(s, hdr, mb);
}
}
@@ -419,7 +474,7 @@ static void stream_start_keepalive(struct stream *s)
}
-int stream_send(struct stream *s, bool marker, int pt, uint32_t ts,
+int stream_send(struct stream *s, bool ext, bool marker, int pt, uint32_t ts,
struct mbuf *mb)
{
int err = 0;
@@ -438,7 +493,7 @@ int stream_send(struct stream *s, bool marker, int pt, uint32_t ts,
pt = s->pt_enc;
if (pt >= 0) {
- err = rtp_send(s->rtp, sdp_media_raddr(s->sdp), false,
+ err = rtp_send(s->rtp, sdp_media_raddr(s->sdp), ext,
marker, pt, ts, mb);
if (err)
s->metric_tx.n_err++;