summaryrefslogtreecommitdiff
path: root/libavformat/rtpdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-01-15 16:05:00 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-01-15 16:05:34 +0100
commitb52925d2cde98b2a3ffaf451248191c8627d356a (patch)
treeb5bc13efa1c4f0151fb47fecf295935000c71dc7 /libavformat/rtpdec.c
parente7e0186eeb0a0aa1e2ca805b97eb60cbd14e0567 (diff)
parent2f3bada63e57345329c4f9b48e9b81b5cfc03d05 (diff)
Merge commit '2f3bada63e57345329c4f9b48e9b81b5cfc03d05'
* commit '2f3bada63e57345329c4f9b48e9b81b5cfc03d05': lavf: Add a protocol for SRTP encryption/decryption rtsp: Support decryption of SRTP signalled via RFC 4568 (SDES) Conflicts: libavformat/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/rtpdec.c')
-rw-r--r--libavformat/rtpdec.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 597b8040a3..fb1e5b9ea7 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -26,6 +26,7 @@
#include "avformat.h"
#include "mpegts.h"
#include "network.h"
+#include "srtp.h"
#include "url.h"
#include "rtpdec.h"
#include "rtpdec_formats.h"
@@ -543,6 +544,13 @@ void ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx,
s->handler = handler;
}
+void ff_rtp_parse_set_crypto(RTPDemuxContext *s, const char *suite,
+ const char *params)
+{
+ if (!ff_srtp_set_crypto(&s->srtp, suite, params))
+ s->srtp_enabled = 1;
+}
+
/**
* This was the second switch in rtp_parse packet.
* Normalizes time, if required, sets stream_index, etc.
@@ -879,7 +887,10 @@ static int rtp_parse_one_packet(RTPDemuxContext *s, AVPacket *pkt,
int ff_rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
uint8_t **bufptr, int len)
{
- int rv = rtp_parse_one_packet(s, pkt, bufptr, len);
+ int rv;
+ if (s->srtp_enabled && bufptr && ff_srtp_decrypt(&s->srtp, *bufptr, &len) < 0)
+ return -1;
+ rv = rtp_parse_one_packet(s, pkt, bufptr, len);
s->prev_ret = rv;
while (rv == AVERROR(EAGAIN) && has_next_packet(s))
rv = rtp_parse_queued_packet(s, pkt);
@@ -892,6 +903,7 @@ void ff_rtp_parse_close(RTPDemuxContext *s)
if (!strcmp(ff_rtp_enc_name(s->payload_type), "MP2T")) {
ff_mpegts_parse_close(s->ts);
}
+ ff_srtp_free(&s->srtp);
av_free(s);
}