Skip to content

Commit 2ad58fe

Browse files
committed
WHIP: Update the dependency, requires openssl.
1 parent c0e1296 commit 2ad58fe

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

configure

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3480,6 +3480,7 @@ ogg_demuxer_select="dirac_parse"
34803480
ogv_muxer_select="ogg_muxer"
34813481
opus_muxer_select="ogg_muxer"
34823482
psp_muxer_select="mov_muxer"
3483+
rtc_muxer_deps_any="openssl"
34833484
rtp_demuxer_select="sdp_demuxer"
34843485
rtp_mpegts_muxer_select="mpegts_muxer rtp_muxer"
34853486
rtpdec_select="asf_demuxer mov_demuxer mpegts_demuxer rm_demuxer rtp_protocol srtp"

libavformat/rtcenc.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020
*/
2121

22+
#include "config.h"
23+
24+
#if CONFIG_OPENSSL
25+
#include <openssl/ssl.h>
26+
#include <openssl/err.h>
27+
#endif
28+
2229
#include "libavutil/dict.h"
2330
#include "libavutil/avassert.h"
2431
#include "libavutil/mathematics.h"
@@ -632,6 +639,34 @@ static int ice_handshake(AVFormatContext *s)
632639
return ret;
633640
}
634641

642+
#if CONFIG_OPENSSL
643+
/**
644+
* DTLS handshake with server, as a client in active mode, using openssl.
645+
*
646+
* @return 0 if OK, AVERROR_xxx on error
647+
*/
648+
static int dtls_handshake_openssl(AVFormatContext *s)
649+
{
650+
int ret = 0;
651+
SSL_CTX *dtls_ctx = NULL;
652+
653+
#if OPENSSL_VERSION_NUMBER < 0x10002000L // v1.0.2
654+
dtls_ctx = SSL_CTX_new(DTLSv1_method());
655+
#else
656+
dtls_ctx = SSL_CTX_new(DTLS_client_method());
657+
#endif
658+
if (!dtls_ctx) {
659+
av_log(s, AV_LOG_ERROR, "Failed to create DTLS context\n");
660+
ret = AVERROR(ENOMEM);
661+
goto end;
662+
}
663+
664+
end:
665+
SSL_CTX_free(dtls_ctx);
666+
return ret;
667+
}
668+
#endif
669+
635670
static av_cold int rtc_init(AVFormatContext *s)
636671
{
637672
int ret;
@@ -658,6 +693,14 @@ static int rtc_write_header(AVFormatContext *s)
658693
if ((ret = ice_handshake(s)) < 0)
659694
return ret;
660695

696+
#if CONFIG_OPENSSL
697+
if ((ret = dtls_handshake_openssl(s)) < 0)
698+
return ret;
699+
#else
700+
av_log(s, AV_LOG_ERROR, "DTLS is not supported, please enable openssl\n");
701+
return AVERROR(ENOSYS);
702+
#endif
703+
661704
return ret;
662705
}
663706

0 commit comments

Comments
 (0)