summaryrefslogtreecommitdiff
path: root/res/res_rtp_asterisk.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2017-07-12 06:13:25 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2017-07-12 06:13:25 -0500
commit8082f6cf7e96c2691740848a0df5752b2da575c3 (patch)
treec03a47a579b946d7d61a3a6c3f19edf12f861c3b /res/res_rtp_asterisk.c
parent8b27bb100b010060cecfa52b4d2bc1240ad5092a (diff)
parent7df7b8a90c42068d0e9badee974a7efb065c741b (diff)
Merge "res_rtp_asterisk: trigger source change control frame when dtls is established"
Diffstat (limited to 'res/res_rtp_asterisk.c')
-rw-r--r--res/res_rtp_asterisk.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index e60d4af75..30efb2ca6 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -109,6 +109,8 @@
#define SRTP_MASTER_SALT_LEN 14
#define SRTP_MASTER_LEN (SRTP_MASTER_KEY_LEN + SRTP_MASTER_SALT_LEN)
+#define RTP_DTLS_ESTABLISHED -37
+
enum strict_rtp_state {
STRICT_RTP_OPEN = 0, /*! No RTP packets should be dropped, all sources accepted */
STRICT_RTP_LEARN, /*! Accept next packet as source */
@@ -2488,7 +2490,11 @@ static int __rtp_recvfrom(struct ast_rtp_instance *instance, void *buf, size_t s
/* Any further connections will be existing since this is now established */
dtls->connection = AST_RTP_DTLS_CONNECTION_EXISTING;
/* Use the keying material to set up key/salt information */
- res = dtls_srtp_setup(rtp, srtp, instance, rtcp);
+ if ((res = dtls_srtp_setup(rtp, srtp, instance, rtcp))) {
+ return res;
+ }
+ /* Notify that dtls has been established */
+ res = RTP_DTLS_ESTABLISHED;
} else {
/* Since we've sent additional traffic start the timeout timer for retransmission */
dtls_srtp_start_timeout_timer(instance, rtp, rtcp);
@@ -4772,6 +4778,12 @@ static struct ast_frame *ast_rtcp_read(struct ast_rtp_instance *instance)
/* Read in RTCP data from the socket */
if ((res = rtcp_recvfrom(instance, read_area, read_area_size,
0, &addr)) < 0) {
+ if (res == RTP_DTLS_ESTABLISHED) {
+ rtp->f.frametype = AST_FRAME_CONTROL;
+ rtp->f.subclass.integer = AST_CONTROL_SRCCHANGE;
+ return &rtp->f;
+ }
+
ast_assert(errno != EBADF);
if (errno != EAGAIN) {
ast_log(LOG_WARNING, "RTCP Read error: %s. Hanging up.\n",
@@ -4969,6 +4981,12 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc
/* Actually read in the data from the socket */
if ((res = rtp_recvfrom(instance, read_area, read_area_size, 0,
&addr)) < 0) {
+ if (res == RTP_DTLS_ESTABLISHED) {
+ rtp->f.frametype = AST_FRAME_CONTROL;
+ rtp->f.subclass.integer = AST_CONTROL_SRCCHANGE;
+ return &rtp->f;
+ }
+
ast_assert(errno != EBADF);
if (errno != EAGAIN) {
ast_log(LOG_WARNING, "RTP Read error: %s. Hanging up.\n",