~singpolyma/asterisk

a192e25f489ab2455395eac2c106f1fd517ad05f — Stephen Paul Weber 6 months ago aac0fc0
DTLS support for video
1 files changed, 32 insertions(+), 2 deletions(-)

M channels/chan_motif.c
M channels/chan_motif.c => channels/chan_motif.c +32 -2
@@ 666,6 666,9 @@ static void jingle_set_owner(struct jingle_session *session, struct ast_channel 
	}
}

static struct ast_rtp_dtls_cfg dtls_cfg;
static struct ast_rtp_dtls_cfg dtls_cfg_video;

/*! \brief Internal helper function which enables video support on a sesson if possible */
static void jingle_enable_video(struct jingle_session *session)
{


@@ 697,9 700,31 @@ static void jingle_enable_video(struct jingle_session *session)
	if (session->transport == JINGLE_TRANSPORT_GOOGLE_V2 && (ice = ast_rtp_instance_get_ice(session->vrtp))) {
		ice->stop(session->vrtp);
	}
}

static struct ast_rtp_dtls_cfg dtls_cfg;
	struct ast_rtp_engine_dtls *dtls;
	if (session->vrtp && (dtls = ast_rtp_instance_get_dtls(session->vrtp))) {
		dtls_cfg_video.enabled = 1;
		dtls_cfg_video.default_setup = AST_RTP_DTLS_SETUP_ACTPASS;
		dtls_cfg_video.hash = AST_RTP_DTLS_HASH_SHA256;
		dtls_cfg_video.verify = AST_RTP_DTLS_VERIFY_FINGERPRINT;
		dtls_cfg_video.suite = AST_AES_CM_128_HMAC_SHA1_80;
		dtls_cfg_video.ephemeral_cert = 1;
		dtls_cfg_video.certfile = ast_strdup("");
		dtls_cfg_video.pvtfile = ast_strdup("");
		dtls_cfg_video.cipher = ast_strdup("");
		dtls_cfg_video.cafile = ast_strdup("");
		dtls_cfg_video.capath = ast_strdup("");

		if (dtls->set_configuration(session->vrtp, &dtls_cfg_video)) {
			ast_log(LOG_ERROR, "Attempted to set an invalid DTLS-SRTP configuration on RTP instance '%p'\n",
					session->rtp);
		}
	}
	else {
		ast_log(LOG_ERROR, "No DTLS-SRTP support present on engine for RTP instance '%p', was it compiled with support for it?\n",
				session->rtp);
	}
}

/*! \brief Internal helper function used to allocate Jingle session on an endpoint */
static struct jingle_session *jingle_alloc(struct jingle_endpoint *endpoint, const char *from, const char *sid)


@@ 1604,6 1629,11 @@ static void jingle_send_session_accept(struct jingle_session *session)
		// This will cause us to reply with active
		dtls->set_setup(session->rtp, AST_RTP_DTLS_SETUP_ACTPASS);
	}
	if (session->vrtp && (dtls = ast_rtp_instance_get_dtls(session->vrtp)) && dtls->get_setup(session->vrtp) == AST_RTP_DTLS_SETUP_ACTPASS) {
		// We don't know what the remote wants yet, so just assume both?
		// This will cause us to reply with active
		dtls->set_setup(session->vrtp, AST_RTP_DTLS_SETUP_ACTPASS);
	}
	jingle_send_session_action(session, session->transport == JINGLE_TRANSPORT_GOOGLE_V1 ? "accept" : "session-accept");
}