res_pjsip: Add "webrtc" configuration option

This patch creates a new configuration option called "webrtc". When enabled it
defaults and enables the following options that are needed in order for webrtc
to work in Asterisk:

  rtcp-mux, use_avpf, ice_support, and use_received_transport=enabled
  media_encryption=dtls
  dtls_verify=fingerprint
  dtls_setup=actpass

When "webrtc" is enabled, this patch also parses the "msid" media level
attribute from an SDP. It will also appropriately add it onto the outgoing
session when applicable.

Lastly, when "webrtc" is enabled h264 RTCP FIR feedback frames are now sent.

ASTERISK-27119 #close

Change-Id: I5ec02e07c5d5b9ad86a34fdf31bf2f9da9aac6fd
This commit is contained in:
Kevin Harwell
2017-07-10 18:17:44 -05:00
parent 0f45c979a3
commit 7da6ddda30
9 changed files with 151 additions and 7 deletions

View File

@@ -1363,8 +1363,30 @@ static int sip_endpoint_apply_handler(const struct ast_sorcery *sorcery, void *o
return -1;
}
if (endpoint->media.bundle) {
endpoint->media.rtcp_mux = 1;
endpoint->media.rtcp_mux |= endpoint->media.bundle;
/*
* If webrtc has been enabled then enable those attributes, and default
* some, that are needed in order for webrtc to work.
*/
endpoint->media.bundle |= endpoint->media.webrtc;
endpoint->media.rtcp_mux |= endpoint->media.webrtc;
endpoint->media.rtp.use_avpf |= endpoint->media.webrtc;
endpoint->media.rtp.ice_support |= endpoint->media.webrtc;
endpoint->media.rtp.use_received_transport |= endpoint->media.webrtc;
if (endpoint->media.webrtc) {
endpoint->media.rtp.encryption = AST_SIP_MEDIA_ENCRYPT_DTLS;
endpoint->media.rtp.dtls_cfg.enabled = 1;
endpoint->media.rtp.dtls_cfg.default_setup = AST_RTP_DTLS_SETUP_ACTPASS;
endpoint->media.rtp.dtls_cfg.verify = AST_RTP_DTLS_VERIFY_FINGERPRINT;
if (ast_strlen_zero(endpoint->media.rtp.dtls_cfg.certfile) ||
(ast_strlen_zero(endpoint->media.rtp.dtls_cfg.cafile))) {
ast_log(LOG_ERROR, "WebRTC can't be enabled on endpoint '%s' - a DTLS cert "
"or ca file has not been specified", ast_sorcery_object_get_id(endpoint));
return -1;
}
}
return 0;
@@ -1990,6 +2012,7 @@ int ast_res_pjsip_initialize_configuration(void)
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "max_audio_streams", "1", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.max_audio_streams));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "max_video_streams", "1", OPT_UINT_T, 0, FLDSET(struct ast_sip_endpoint, media.max_video_streams));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "bundle", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.bundle));
ast_sorcery_object_field_register(sip_sorcery, "endpoint", "webrtc", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, media.webrtc));
if (ast_sip_initialize_sorcery_transport()) {
ast_log(LOG_ERROR, "Failed to register SIP transport support with sorcery\n");