diff options
author | Martin Storsjö <martin@martin.st> | 2012-10-21 00:18:01 +0400 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2013-01-15 13:54:40 +0400 |
commit | 424da308302bef604844d3110a39f2f03bf5358e (patch) | |
tree | 701e11c88de13eaf50c51242886ace686de18342 /libavformat/rtsp.c | |
parent | ab2ad8bd56882c0ea160b154e8b836eb71abc49d (diff) |
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/rtsp.c')
-rw-r--r-- | libavformat/rtsp.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 05058d014a..9a657fb440 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -479,6 +479,14 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, s->nb_streams > 0) { st = s->streams[s->nb_streams - 1]; st->codec->sample_rate = atoi(p); + } else if (av_strstart(p, "crypto:", &p) && s->nb_streams > 0) { + // RFC 4568 + rtsp_st = rt->rtsp_streams[rt->nb_rtsp_streams - 1]; + get_word(buf1, sizeof(buf1), &p); // ignore tag + get_word(rtsp_st->crypto_suite, sizeof(rtsp_st->crypto_suite), &p); + p += strspn(p, SPACE_CHARS); + if (av_strstart(p, "inline:", &p)) + get_word(rtsp_st->crypto_params, sizeof(rtsp_st->crypto_params), &p); } else { if (rt->server_type == RTSP_SERVER_WMS) ff_wms_parse_sdp_a_line(s, p); @@ -652,6 +660,10 @@ int ff_rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st) rtsp_st->dynamic_protocol_context, rtsp_st->dynamic_handler); } + if (rtsp_st->crypto_suite[0]) + ff_rtp_parse_set_crypto(rtsp_st->transport_priv, + rtsp_st->crypto_suite, + rtsp_st->crypto_params); } return 0; |