#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 */
/* 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);
/* 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",
/* 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",