diff options
author | Martin Storsjö <martin@martin.st> | 2012-10-20 23:18:01 +0300 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2013-01-15 11:54:40 +0200 |
commit | 424da308302bef604844d3110a39f2f03bf5358e (patch) | |
tree | 701e11c88de13eaf50c51242886ace686de18342 /libavformat/rtpdec.c | |
parent | ab2ad8bd56882c0ea160b154e8b836eb71abc49d (diff) | |
download | ffmpeg-424da308302bef604844d3110a39f2f03bf5358e.tar.gz |
rtsp: Support decryption of SRTP signalled via RFC 4568 (SDES)
This only takes care of decrypting incoming packets; the outgoing
RTCP packets are not encrypted. This is enough for some use cases,
and signalling crypto keys for use with outgoing RTCP packets
doesn't fit as simply into the API. If the SDP demuxer is hooked
up with custom IO, the return packets can be encrypted e.g. via the
SRTP protocol.
If the SRTP keys aren't available within the SDP, the decryption
can be handled externally as well (when using custom IO).
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/rtpdec.c')
-rw-r--r-- | libavformat/rtpdec.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index 73d02069ea..e052ee6f33 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. @@ -876,7 +884,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); @@ -889,6 +900,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); } |