2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 2013, Digium, Inc.
6 * Joshua Colp <jcolp@digium.com>
7 * Kevin Harwell <kharwell@digium.com>
9 * See http://www.asterisk.org for more information about
10 * the Asterisk project. Please do not directly contact
11 * any of the maintainers of this project for assistance;
12 * the project provides a web site, mailing lists and IRC
13 * channels for your use.
15 * This program is free software, distributed under the terms of
16 * the GNU General Public License Version 2. See the LICENSE file
17 * at the top of the source tree.
22 * \author Joshua Colp <jcolp@digium.com>
24 * \brief SIP SDP media stream handling
28 <depend>pjproject</depend>
29 <depend>res_pjsip</depend>
30 <depend>res_pjsip_session</depend>
31 <support_level>core</support_level>
41 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
43 #include "asterisk/module.h"
44 #include "asterisk/format.h"
45 #include "asterisk/format_cap.h"
46 #include "asterisk/rtp_engine.h"
47 #include "asterisk/netsock2.h"
48 #include "asterisk/channel.h"
49 #include "asterisk/causes.h"
50 #include "asterisk/sched.h"
51 #include "asterisk/acl.h"
52 #include "asterisk/sdp_srtp.h"
54 #include "asterisk/res_pjsip.h"
55 #include "asterisk/res_pjsip_session.h"
57 /*! \brief Scheduler for RTCP purposes */
58 static struct ast_sched_context *sched;
60 /*! \brief Address for IPv4 RTP */
61 static struct ast_sockaddr address_ipv4;
63 /*! \brief Address for IPv6 RTP */
64 static struct ast_sockaddr address_ipv6;
66 static const char STR_AUDIO[] = "audio";
67 static const int FD_AUDIO = 0;
69 static const char STR_VIDEO[] = "video";
70 static const int FD_VIDEO = 2;
72 /*! \brief Retrieves an ast_format_type based on the given stream_type */
73 static enum ast_media_type stream_to_media_type(const char *stream_type)
75 if (!strcasecmp(stream_type, STR_AUDIO)) {
76 return AST_MEDIA_TYPE_AUDIO;
77 } else if (!strcasecmp(stream_type, STR_VIDEO)) {
78 return AST_MEDIA_TYPE_VIDEO;
84 /*! \brief Get the starting descriptor for a media type */
85 static int media_type_to_fdno(enum ast_media_type media_type)
88 case AST_MEDIA_TYPE_AUDIO: return FD_AUDIO;
89 case AST_MEDIA_TYPE_VIDEO: return FD_VIDEO;
90 case AST_MEDIA_TYPE_TEXT:
91 case AST_MEDIA_TYPE_UNKNOWN:
92 case AST_MEDIA_TYPE_IMAGE: break;
97 /*! \brief Remove all other cap types but the one given */
98 static void format_cap_only_type(struct ast_format_cap *caps, enum ast_media_type media_type)
101 while (i <= AST_MEDIA_TYPE_TEXT) {
102 if (i != media_type && i != AST_MEDIA_TYPE_UNKNOWN) {
103 ast_format_cap_remove_by_type(caps, i);
109 /*! \brief Internal function which creates an RTP instance */
110 static int create_rtp(struct ast_sip_session *session, struct ast_sip_session_media *session_media, unsigned int ipv6)
112 struct ast_rtp_engine_ice *ice;
114 if (!(session_media->rtp = ast_rtp_instance_new(session->endpoint->media.rtp.engine, sched, ipv6 ? &address_ipv6 : &address_ipv4, NULL))) {
115 ast_log(LOG_ERROR, "Unable to create RTP instance using RTP engine '%s'\n", session->endpoint->media.rtp.engine);
119 ast_rtp_instance_set_prop(session_media->rtp, AST_RTP_PROPERTY_RTCP, 1);
120 ast_rtp_instance_set_prop(session_media->rtp, AST_RTP_PROPERTY_NAT, session->endpoint->media.rtp.symmetric);
122 if (session->endpoint->dtmf == AST_SIP_DTMF_INBAND) {
123 ast_rtp_instance_dtmf_mode_set(session_media->rtp, AST_RTP_DTMF_MODE_INBAND);
126 if (!session->endpoint->media.rtp.ice_support && (ice = ast_rtp_instance_get_ice(session_media->rtp))) {
127 ice->stop(session_media->rtp);
130 if (session->endpoint->dtmf == AST_SIP_DTMF_RFC_4733) {
131 ast_rtp_instance_dtmf_mode_set(session_media->rtp, AST_RTP_DTMF_MODE_RFC2833);
132 } else if (session->endpoint->dtmf == AST_SIP_DTMF_INBAND) {
133 ast_rtp_instance_dtmf_mode_set(session_media->rtp, AST_RTP_DTMF_MODE_INBAND);
136 if (!strcmp(session_media->stream_type, STR_AUDIO) &&
137 (session->endpoint->media.tos_audio || session->endpoint->media.cos_video)) {
138 ast_rtp_instance_set_qos(session_media->rtp, session->endpoint->media.tos_audio,
139 session->endpoint->media.cos_audio, "SIP RTP Audio");
140 } else if (!strcmp(session_media->stream_type, STR_VIDEO) &&
141 (session->endpoint->media.tos_video || session->endpoint->media.cos_video)) {
142 ast_rtp_instance_set_qos(session_media->rtp, session->endpoint->media.tos_video,
143 session->endpoint->media.cos_video, "SIP RTP Video");
149 static void get_codecs(struct ast_sip_session *session, const struct pjmedia_sdp_media *stream, struct ast_rtp_codecs *codecs)
151 pjmedia_sdp_attr *attr;
152 pjmedia_sdp_rtpmap *rtpmap;
153 pjmedia_sdp_fmtp fmtp;
154 struct ast_format *format;
160 ast_rtp_codecs_payloads_initialize(codecs);
162 /* Iterate through provided formats */
163 for (i = 0; i < stream->desc.fmt_count; ++i) {
164 /* The payload is kept as a string for things like t38 but for video it is always numerical */
165 ast_rtp_codecs_payloads_set_m_type(codecs, NULL, pj_strtoul(&stream->desc.fmt[i]));
166 /* Look for the optional rtpmap attribute */
167 if (!(attr = pjmedia_sdp_media_find_attr2(stream, "rtpmap", &stream->desc.fmt[i]))) {
171 /* Interpret the attribute as an rtpmap */
172 if ((pjmedia_sdp_attr_to_rtpmap(session->inv_session->pool_prov, attr, &rtpmap)) != PJ_SUCCESS) {
176 ast_copy_pj_str(name, &rtpmap->enc_name, sizeof(name));
177 ast_copy_pj_str(media, (pj_str_t*)&stream->desc.media, sizeof(media));
178 ast_rtp_codecs_payloads_set_rtpmap_type_rate(codecs, NULL, pj_strtoul(&stream->desc.fmt[i]),
179 media, name, 0, rtpmap->clock_rate);
180 /* Look for an optional associated fmtp attribute */
181 if (!(attr = pjmedia_sdp_media_find_attr2(stream, "fmtp", &rtpmap->pt))) {
185 if ((pjmedia_sdp_attr_get_fmtp(attr, &fmtp)) == PJ_SUCCESS) {
186 sscanf(pj_strbuf(&fmtp.fmt), "%d", &num);
187 if ((format = ast_rtp_codecs_get_payload_format(codecs, num))) {
188 struct ast_format *format_parsed;
190 ast_copy_pj_str(fmt_param, &fmtp.fmt_param, sizeof(fmt_param));
192 format_parsed = ast_format_parse_sdp_fmtp(format, fmt_param);
194 ast_rtp_codecs_payload_replace_format(codecs, num, format_parsed);
195 ao2_ref(format_parsed, -1);
203 /* Get the packetization, if it exists */
204 if ((attr = pjmedia_sdp_media_find_attr2(stream, "ptime", NULL))) {
205 unsigned long framing = pj_strtoul(pj_strltrim(&attr->value));
206 if (framing && session->endpoint->media.rtp.use_ptime) {
207 ast_rtp_codecs_set_framing(codecs, framing);
212 static int set_caps(struct ast_sip_session *session, struct ast_sip_session_media *session_media,
213 const struct pjmedia_sdp_media *stream)
215 RAII_VAR(struct ast_format_cap *, caps, NULL, ao2_cleanup);
216 RAII_VAR(struct ast_format_cap *, peer, NULL, ao2_cleanup);
217 RAII_VAR(struct ast_format_cap *, joint, NULL, ao2_cleanup);
218 enum ast_media_type media_type = stream_to_media_type(session_media->stream_type);
219 struct ast_rtp_codecs codecs = AST_RTP_CODECS_NULL_INIT;
221 int direct_media_enabled = !ast_sockaddr_isnull(&session_media->direct_media_addr) &&
222 ast_format_cap_count(session->direct_media_cap);
224 if (!(caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT)) ||
225 !(peer = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT)) ||
226 !(joint = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
227 ast_log(LOG_ERROR, "Failed to allocate %s capabilities\n", session_media->stream_type);
231 /* get the endpoint capabilities */
232 if (direct_media_enabled) {
233 ast_format_cap_get_compatible(session->endpoint->media.codecs, session->direct_media_cap, caps);
234 format_cap_only_type(caps, media_type);
236 ast_format_cap_append_from_cap(caps, session->endpoint->media.codecs, media_type);
239 /* get the capabilities on the peer */
240 get_codecs(session, stream, &codecs);
241 ast_rtp_codecs_payload_formats(&codecs, peer, &fmts);
243 /* get the joint capabilities between peer and endpoint */
244 ast_format_cap_get_compatible(caps, peer, joint);
245 if (!ast_format_cap_count(joint)) {
246 struct ast_str *usbuf = ast_str_alloca(64);
247 struct ast_str *thembuf = ast_str_alloca(64);
249 ast_rtp_codecs_payloads_destroy(&codecs);
250 ast_log(LOG_WARNING, "No joint capabilities between our configuration(%s) and incoming SDP(%s)\n",
251 ast_format_cap_get_names(peer, &usbuf),
252 ast_format_cap_get_names(caps, &thembuf));
256 ast_rtp_codecs_payloads_copy(&codecs, ast_rtp_instance_get_codecs(session_media->rtp),
259 ast_format_cap_append_from_cap(session->req_caps, joint, AST_MEDIA_TYPE_UNKNOWN);
261 if (session->channel) {
262 struct ast_format *fmt;
264 ast_channel_lock(session->channel);
265 ast_format_cap_remove_by_type(caps, AST_MEDIA_TYPE_UNKNOWN);
266 ast_format_cap_append_from_cap(caps, ast_channel_nativeformats(session->channel), AST_MEDIA_TYPE_UNKNOWN);
267 ast_format_cap_remove_by_type(caps, media_type);
270 * XXX Historically we picked the "best" joint format to use
271 * and stuck with it. It would be nice to just append the
272 * determined joint media capabilities to give translation
273 * more formats to choose from when necessary. Unfortunately,
274 * there are some areas of the system where this doesn't work
275 * very well. (The softmix bridge in particular is reluctant
276 * to pick higher fidelity formats and has a problem with
277 * asymmetric sample rates.)
279 fmt = ast_format_cap_get_format(joint, 0);
280 ast_format_cap_append(caps, fmt, 0);
283 * Apply the new formats to the channel, potentially changing
284 * raw read/write formats and translation path while doing so.
286 ast_channel_nativeformats_set(session->channel, caps);
287 ast_set_read_format(session->channel, ast_channel_readformat(session->channel));
288 ast_set_write_format(session->channel, ast_channel_writeformat(session->channel));
289 ast_channel_unlock(session->channel);
294 ast_rtp_codecs_payloads_destroy(&codecs);
298 static pjmedia_sdp_attr* generate_rtpmap_attr(pjmedia_sdp_media *media, pj_pool_t *pool, int rtp_code,
299 int asterisk_format, struct ast_format *format, int code)
301 pjmedia_sdp_rtpmap rtpmap;
302 pjmedia_sdp_attr *attr = NULL;
305 snprintf(tmp, sizeof(tmp), "%d", rtp_code);
306 pj_strdup2(pool, &media->desc.fmt[media->desc.fmt_count++], tmp);
307 rtpmap.pt = media->desc.fmt[media->desc.fmt_count - 1];
308 rtpmap.clock_rate = ast_rtp_lookup_sample_rate2(asterisk_format, format, code);
309 pj_strdup2(pool, &rtpmap.enc_name, ast_rtp_lookup_mime_subtype2(asterisk_format, format, code, 0));
310 rtpmap.param.slen = 0;
311 rtpmap.param.ptr = NULL;
313 pjmedia_sdp_rtpmap_to_attr(pool, &rtpmap, &attr);
318 static pjmedia_sdp_attr* generate_fmtp_attr(pj_pool_t *pool, struct ast_format *format, int rtp_code)
320 struct ast_str *fmtp0 = ast_str_alloca(256);
322 pjmedia_sdp_attr *attr = NULL;
325 ast_format_generate_sdp_fmtp(format, rtp_code, &fmtp0);
326 if (ast_str_strlen(fmtp0)) {
327 tmp = ast_str_buffer(fmtp0) + ast_str_strlen(fmtp0) - 1;
328 /* remove any carriage return line feeds */
329 while (*tmp == '\r' || *tmp == '\n') --tmp;
331 /* ast...generate gives us everything, just need value */
332 tmp = strchr(ast_str_buffer(fmtp0), ':');
333 if (tmp && tmp + 1) {
334 fmtp1 = pj_str(tmp + 1);
336 fmtp1 = pj_str(ast_str_buffer(fmtp0));
338 attr = pjmedia_sdp_attr_create(pool, "fmtp", &fmtp1);
343 /*! \brief Function which adds ICE attributes to a media stream */
344 static void add_ice_to_stream(struct ast_sip_session *session, struct ast_sip_session_media *session_media, pj_pool_t *pool, pjmedia_sdp_media *media)
346 struct ast_rtp_engine_ice *ice;
347 struct ao2_container *candidates;
348 const char *username, *password;
350 pjmedia_sdp_attr *attr;
351 struct ao2_iterator it_candidates;
352 struct ast_rtp_engine_ice_candidate *candidate;
354 if (!session->endpoint->media.rtp.ice_support || !(ice = ast_rtp_instance_get_ice(session_media->rtp)) ||
355 !(candidates = ice->get_local_candidates(session_media->rtp))) {
359 if ((username = ice->get_ufrag(session_media->rtp))) {
360 attr = pjmedia_sdp_attr_create(pool, "ice-ufrag", pj_cstr(&stmp, username));
361 media->attr[media->attr_count++] = attr;
364 if ((password = ice->get_password(session_media->rtp))) {
365 attr = pjmedia_sdp_attr_create(pool, "ice-pwd", pj_cstr(&stmp, password));
366 media->attr[media->attr_count++] = attr;
369 it_candidates = ao2_iterator_init(candidates, 0);
370 for (; (candidate = ao2_iterator_next(&it_candidates)); ao2_ref(candidate, -1)) {
371 struct ast_str *attr_candidate = ast_str_create(128);
373 ast_str_set(&attr_candidate, -1, "%s %u %s %d %s ", candidate->foundation, candidate->id, candidate->transport,
374 candidate->priority, ast_sockaddr_stringify_addr_remote(&candidate->address));
375 ast_str_append(&attr_candidate, -1, "%s typ ", ast_sockaddr_stringify_port(&candidate->address));
377 switch (candidate->type) {
378 case AST_RTP_ICE_CANDIDATE_TYPE_HOST:
379 ast_str_append(&attr_candidate, -1, "host");
381 case AST_RTP_ICE_CANDIDATE_TYPE_SRFLX:
382 ast_str_append(&attr_candidate, -1, "srflx");
384 case AST_RTP_ICE_CANDIDATE_TYPE_RELAYED:
385 ast_str_append(&attr_candidate, -1, "relay");
389 if (!ast_sockaddr_isnull(&candidate->relay_address)) {
390 ast_str_append(&attr_candidate, -1, " raddr %s rport", ast_sockaddr_stringify_addr_remote(&candidate->relay_address));
391 ast_str_append(&attr_candidate, -1, " %s", ast_sockaddr_stringify_port(&candidate->relay_address));
394 attr = pjmedia_sdp_attr_create(pool, "candidate", pj_cstr(&stmp, ast_str_buffer(attr_candidate)));
395 media->attr[media->attr_count++] = attr;
397 ast_free(attr_candidate);
400 ao2_iterator_destroy(&it_candidates);
403 /*! \brief Function which processes ICE attributes in an audio stream */
404 static void process_ice_attributes(struct ast_sip_session *session, struct ast_sip_session_media *session_media,
405 const struct pjmedia_sdp_session *remote, const struct pjmedia_sdp_media *remote_stream)
407 struct ast_rtp_engine_ice *ice;
408 const pjmedia_sdp_attr *attr;
409 char attr_value[256];
412 /* If ICE support is not enabled or available exit early */
413 if (!session->endpoint->media.rtp.ice_support || !(ice = ast_rtp_instance_get_ice(session_media->rtp))) {
417 attr = pjmedia_sdp_media_find_attr2(remote_stream, "ice-ufrag", NULL);
419 attr = pjmedia_sdp_attr_find2(remote->attr_count, remote->attr, "ice-ufrag", NULL);
422 ast_copy_pj_str(attr_value, (pj_str_t*)&attr->value, sizeof(attr_value));
423 ice->set_authentication(session_media->rtp, attr_value, NULL);
428 attr = pjmedia_sdp_media_find_attr2(remote_stream, "ice-pwd", NULL);
430 attr = pjmedia_sdp_attr_find2(remote->attr_count, remote->attr, "ice-pwd", NULL);
433 ast_copy_pj_str(attr_value, (pj_str_t*)&attr->value, sizeof(attr_value));
434 ice->set_authentication(session_media->rtp, NULL, attr_value);
439 if (pjmedia_sdp_media_find_attr2(remote_stream, "ice-lite", NULL)) {
440 ice->ice_lite(session_media->rtp);
443 /* Find all of the candidates */
444 for (attr_i = 0; attr_i < remote_stream->attr_count; ++attr_i) {
445 char foundation[32], transport[32], address[PJ_INET6_ADDRSTRLEN + 1], cand_type[6], relay_address[PJ_INET6_ADDRSTRLEN + 1] = "";
446 unsigned int port, relay_port = 0;
447 struct ast_rtp_engine_ice_candidate candidate = { 0, };
449 attr = remote_stream->attr[attr_i];
451 /* If this is not a candidate line skip it */
452 if (pj_strcmp2(&attr->name, "candidate")) {
456 ast_copy_pj_str(attr_value, (pj_str_t*)&attr->value, sizeof(attr_value));
458 if (sscanf(attr_value, "%31s %30u %31s %30u %46s %30u typ %5s %*s %23s %*s %30u", foundation, &candidate.id, transport,
459 (unsigned *)&candidate.priority, address, &port, cand_type, relay_address, &relay_port) < 7) {
460 /* Candidate did not parse properly */
464 candidate.foundation = foundation;
465 candidate.transport = transport;
467 ast_sockaddr_parse(&candidate.address, address, PARSE_PORT_FORBID);
468 ast_sockaddr_set_port(&candidate.address, port);
470 if (!strcasecmp(cand_type, "host")) {
471 candidate.type = AST_RTP_ICE_CANDIDATE_TYPE_HOST;
472 } else if (!strcasecmp(cand_type, "srflx")) {
473 candidate.type = AST_RTP_ICE_CANDIDATE_TYPE_SRFLX;
474 } else if (!strcasecmp(cand_type, "relay")) {
475 candidate.type = AST_RTP_ICE_CANDIDATE_TYPE_RELAYED;
480 if (!ast_strlen_zero(relay_address)) {
481 ast_sockaddr_parse(&candidate.relay_address, relay_address, PARSE_PORT_FORBID);
485 ast_sockaddr_set_port(&candidate.relay_address, relay_port);
488 ice->add_remote_candidate(session_media->rtp, &candidate);
491 ice->set_role(session_media->rtp, pjmedia_sdp_neg_was_answer_remote(session->inv_session->neg) == PJ_TRUE ?
492 AST_RTP_ICE_ROLE_CONTROLLING : AST_RTP_ICE_ROLE_CONTROLLED);
493 ice->start(session_media->rtp);
496 /*! \brief figure out media transport encryption type from the media transport string */
497 static enum ast_sip_session_media_encryption get_media_encryption_type(pj_str_t transport)
499 RAII_VAR(char *, transport_str, ast_strndup(transport.ptr, transport.slen), ast_free);
500 if (strstr(transport_str, "UDP/TLS")) {
501 return AST_SIP_MEDIA_ENCRYPT_DTLS;
502 } else if (strstr(transport_str, "SAVP")) {
503 return AST_SIP_MEDIA_ENCRYPT_SDES;
505 return AST_SIP_MEDIA_ENCRYPT_NONE;
510 * \brief Checks whether the encryption offered in SDP is compatible with the endpoint's configuration
513 * \param endpoint_encryption Media encryption configured for the endpoint
514 * \param stream pjmedia_sdp_media stream description
516 * \retval AST_SIP_MEDIA_TRANSPORT_INVALID on encryption mismatch
517 * \retval The encryption requested in the SDP
519 static enum ast_sip_session_media_encryption check_endpoint_media_transport(
520 struct ast_sip_endpoint *endpoint,
521 const struct pjmedia_sdp_media *stream)
523 enum ast_sip_session_media_encryption incoming_encryption;
525 if (endpoint->media.rtp.use_avpf) {
526 char transport_end = stream->desc.transport.ptr[stream->desc.transport.slen - 1];
527 if (transport_end != 'F') {
528 return AST_SIP_MEDIA_TRANSPORT_INVALID;
532 incoming_encryption = get_media_encryption_type(stream->desc.transport);
534 if (incoming_encryption == endpoint->media.rtp.encryption) {
535 return incoming_encryption;
538 if (endpoint->media.rtp.force_avp) {
539 return incoming_encryption;
542 return AST_SIP_MEDIA_TRANSPORT_INVALID;
545 static int setup_srtp(struct ast_sip_session_media *session_media)
547 if (!session_media->srtp) {
548 session_media->srtp = ast_sdp_srtp_alloc();
549 if (!session_media->srtp) {
554 if (!session_media->srtp->crypto) {
555 session_media->srtp->crypto = ast_sdp_crypto_alloc();
556 if (!session_media->srtp->crypto) {
564 static int setup_dtls_srtp(struct ast_sip_session *session,
565 struct ast_sip_session_media *session_media)
567 struct ast_rtp_engine_dtls *dtls;
569 if (!session->endpoint->media.rtp.dtls_cfg.enabled || !session_media->rtp) {
573 dtls = ast_rtp_instance_get_dtls(session_media->rtp);
578 session->endpoint->media.rtp.dtls_cfg.suite = ((session->endpoint->media.rtp.srtp_tag_32) ? AST_AES_CM_128_HMAC_SHA1_32 : AST_AES_CM_128_HMAC_SHA1_80);
579 if (dtls->set_configuration(session_media->rtp, &session->endpoint->media.rtp.dtls_cfg)) {
580 ast_log(LOG_ERROR, "Attempted to set an invalid DTLS-SRTP configuration on RTP instance '%p'\n",
585 if (setup_srtp(session_media)) {
591 static void apply_dtls_attrib(struct ast_sip_session_media *session_media,
592 pjmedia_sdp_attr *attr)
594 struct ast_rtp_engine_dtls *dtls = ast_rtp_instance_get_dtls(session_media->rtp);
597 if (!attr->value.ptr) {
601 value = pj_strtrim(&attr->value);
603 if (!pj_strcmp2(&attr->name, "setup")) {
604 if (!pj_stricmp2(value, "active")) {
605 dtls->set_setup(session_media->rtp, AST_RTP_DTLS_SETUP_ACTIVE);
606 } else if (!pj_stricmp2(value, "passive")) {
607 dtls->set_setup(session_media->rtp, AST_RTP_DTLS_SETUP_PASSIVE);
608 } else if (!pj_stricmp2(value, "actpass")) {
609 dtls->set_setup(session_media->rtp, AST_RTP_DTLS_SETUP_ACTPASS);
610 } else if (!pj_stricmp2(value, "holdconn")) {
611 dtls->set_setup(session_media->rtp, AST_RTP_DTLS_SETUP_HOLDCONN);
613 ast_log(LOG_WARNING, "Unsupported setup attribute value '%*s'\n", (int)value->slen, value->ptr);
615 } else if (!pj_strcmp2(&attr->name, "connection")) {
616 if (!pj_stricmp2(value, "new")) {
617 dtls->reset(session_media->rtp);
618 } else if (!pj_stricmp2(value, "existing")) {
621 ast_log(LOG_WARNING, "Unsupported connection attribute value '%*s'\n", (int)value->slen, value->ptr);
623 } else if (!pj_strcmp2(&attr->name, "fingerprint")) {
624 char hash_value[256], hash[32];
625 char fingerprint_text[value->slen + 1];
626 ast_copy_pj_str(fingerprint_text, value, sizeof(fingerprint_text));
627 if (sscanf(fingerprint_text, "%31s %255s", hash, hash_value) == 2) {
628 if (!strcasecmp(hash, "sha-1")) {
629 dtls->set_fingerprint(session_media->rtp, AST_RTP_DTLS_HASH_SHA1, hash_value);
630 } else if (!strcasecmp(hash, "sha-256")) {
631 dtls->set_fingerprint(session_media->rtp, AST_RTP_DTLS_HASH_SHA256, hash_value);
633 ast_log(LOG_WARNING, "Unsupported fingerprint hash type '%s'\n",
640 static int parse_dtls_attrib(struct ast_sip_session_media *session_media,
641 const struct pjmedia_sdp_session *sdp,
642 const struct pjmedia_sdp_media *stream)
646 for (i = 0; i < sdp->attr_count; i++) {
647 apply_dtls_attrib(session_media, sdp->attr[i]);
650 for (i = 0; i < stream->attr_count; i++) {
651 apply_dtls_attrib(session_media, stream->attr[i]);
654 ast_set_flag(session_media->srtp, AST_SRTP_CRYPTO_OFFER_OK);
659 static int setup_sdes_srtp(struct ast_sip_session_media *session_media,
660 const struct pjmedia_sdp_media *stream)
664 for (i = 0; i < stream->attr_count; i++) {
665 pjmedia_sdp_attr *attr;
666 RAII_VAR(char *, crypto_str, NULL, ast_free);
668 /* check the stream for the required crypto attribute */
669 attr = stream->attr[i];
670 if (pj_strcmp2(&attr->name, "crypto")) {
674 crypto_str = ast_strndup(attr->value.ptr, attr->value.slen);
679 if (setup_srtp(session_media)) {
683 if (!ast_sdp_crypto_process(session_media->rtp, session_media->srtp, crypto_str)) {
684 /* found a valid crypto attribute */
688 ast_debug(1, "Ignoring crypto offer with unsupported parameters: %s\n", crypto_str);
691 /* no usable crypto attributes found */
695 static int setup_media_encryption(struct ast_sip_session *session,
696 struct ast_sip_session_media *session_media,
697 const struct pjmedia_sdp_session *sdp,
698 const struct pjmedia_sdp_media *stream)
700 switch (session->endpoint->media.rtp.encryption) {
701 case AST_SIP_MEDIA_ENCRYPT_SDES:
702 if (setup_sdes_srtp(session_media, stream)) {
706 case AST_SIP_MEDIA_ENCRYPT_DTLS:
707 if (setup_dtls_srtp(session, session_media)) {
710 if (parse_dtls_attrib(session_media, sdp, stream)) {
714 case AST_SIP_MEDIA_TRANSPORT_INVALID:
715 case AST_SIP_MEDIA_ENCRYPT_NONE:
722 /*! \brief Function which negotiates an incoming media stream */
723 static int negotiate_incoming_sdp_stream(struct ast_sip_session *session, struct ast_sip_session_media *session_media,
724 const struct pjmedia_sdp_session *sdp, const struct pjmedia_sdp_media *stream)
726 char host[NI_MAXHOST];
727 RAII_VAR(struct ast_sockaddr *, addrs, NULL, ast_free_ptr);
728 enum ast_media_type media_type = stream_to_media_type(session_media->stream_type);
730 /* If no type formats have been configured reject this stream */
731 if (!ast_format_cap_has_type(session->endpoint->media.codecs, media_type)) {
735 /* Ensure incoming transport is compatible with the endpoint's configuration */
736 if (!session->endpoint->media.rtp.use_received_transport &&
737 check_endpoint_media_transport(session->endpoint, stream) == AST_SIP_MEDIA_TRANSPORT_INVALID) {
741 ast_copy_pj_str(host, stream->conn ? &stream->conn->addr : &sdp->conn->addr, sizeof(host));
743 /* Ensure that the address provided is valid */
744 if (ast_sockaddr_resolve(&addrs, host, PARSE_PORT_FORBID, AST_AF_UNSPEC) <= 0) {
745 /* The provided host was actually invalid so we error out this negotiation */
749 /* Using the connection information create an appropriate RTP instance */
750 if (!session_media->rtp && create_rtp(session, session_media, ast_sockaddr_is_ipv6(addrs))) {
754 if (session->endpoint->media.rtp.use_received_transport) {
755 pj_strdup(session->inv_session->pool, &session_media->transport, &stream->desc.transport);
758 if (setup_media_encryption(session, session_media, sdp, stream)) {
762 if (set_caps(session, session_media, stream)) {
768 static int add_crypto_to_stream(struct ast_sip_session *session,
769 struct ast_sip_session_media *session_media,
770 pj_pool_t *pool, pjmedia_sdp_media *media)
773 pjmedia_sdp_attr *attr;
774 enum ast_rtp_dtls_hash hash;
775 const char *crypto_attribute;
776 struct ast_rtp_engine_dtls *dtls;
777 static const pj_str_t STR_NEW = { "new", 3 };
778 static const pj_str_t STR_EXISTING = { "existing", 8 };
779 static const pj_str_t STR_ACTIVE = { "active", 6 };
780 static const pj_str_t STR_PASSIVE = { "passive", 7 };
781 static const pj_str_t STR_ACTPASS = { "actpass", 7 };
782 static const pj_str_t STR_HOLDCONN = { "holdconn", 8 };
784 switch (session->endpoint->media.rtp.encryption) {
785 case AST_SIP_MEDIA_ENCRYPT_NONE:
786 case AST_SIP_MEDIA_TRANSPORT_INVALID:
788 case AST_SIP_MEDIA_ENCRYPT_SDES:
789 if (!session_media->srtp) {
790 session_media->srtp = ast_sdp_srtp_alloc();
791 if (!session_media->srtp) {
796 crypto_attribute = ast_sdp_srtp_get_attrib(session_media->srtp,
797 0 /* DTLS running? No */,
798 session->endpoint->media.rtp.srtp_tag_32 /* 32 byte tag length? */);
799 if (!crypto_attribute) {
800 /* No crypto attribute to add, bad news */
804 attr = pjmedia_sdp_attr_create(pool, "crypto", pj_cstr(&stmp, crypto_attribute));
805 media->attr[media->attr_count++] = attr;
807 case AST_SIP_MEDIA_ENCRYPT_DTLS:
808 if (setup_dtls_srtp(session, session_media)) {
812 dtls = ast_rtp_instance_get_dtls(session_media->rtp);
817 switch (dtls->get_connection(session_media->rtp)) {
818 case AST_RTP_DTLS_CONNECTION_NEW:
819 attr = pjmedia_sdp_attr_create(pool, "connection", &STR_NEW);
820 media->attr[media->attr_count++] = attr;
822 case AST_RTP_DTLS_CONNECTION_EXISTING:
823 attr = pjmedia_sdp_attr_create(pool, "connection", &STR_EXISTING);
824 media->attr[media->attr_count++] = attr;
830 switch (dtls->get_setup(session_media->rtp)) {
831 case AST_RTP_DTLS_SETUP_ACTIVE:
832 attr = pjmedia_sdp_attr_create(pool, "setup", &STR_ACTIVE);
833 media->attr[media->attr_count++] = attr;
835 case AST_RTP_DTLS_SETUP_PASSIVE:
836 attr = pjmedia_sdp_attr_create(pool, "setup", &STR_PASSIVE);
837 media->attr[media->attr_count++] = attr;
839 case AST_RTP_DTLS_SETUP_ACTPASS:
840 attr = pjmedia_sdp_attr_create(pool, "setup", &STR_ACTPASS);
841 media->attr[media->attr_count++] = attr;
843 case AST_RTP_DTLS_SETUP_HOLDCONN:
844 attr = pjmedia_sdp_attr_create(pool, "setup", &STR_HOLDCONN);
845 media->attr[media->attr_count++] = attr;
851 hash = dtls->get_fingerprint_hash(session_media->rtp);
852 crypto_attribute = dtls->get_fingerprint(session_media->rtp);
853 if (crypto_attribute && (hash == AST_RTP_DTLS_HASH_SHA1 || hash == AST_RTP_DTLS_HASH_SHA256)) {
854 RAII_VAR(struct ast_str *, fingerprint, ast_str_create(64), ast_free);
859 if (hash == AST_RTP_DTLS_HASH_SHA1) {
860 ast_str_set(&fingerprint, 0, "SHA-1 %s", crypto_attribute);
862 ast_str_set(&fingerprint, 0, "SHA-256 %s", crypto_attribute);
865 attr = pjmedia_sdp_attr_create(pool, "fingerprint", pj_cstr(&stmp, ast_str_buffer(fingerprint)));
866 media->attr[media->attr_count++] = attr;
874 /*! \brief Function which creates an outgoing stream */
875 static int create_outgoing_sdp_stream(struct ast_sip_session *session, struct ast_sip_session_media *session_media,
876 struct pjmedia_sdp_session *sdp)
878 pj_pool_t *pool = session->inv_session->pool_prov;
879 static const pj_str_t STR_IN = { "IN", 2 };
880 static const pj_str_t STR_IP4 = { "IP4", 3};
881 static const pj_str_t STR_IP6 = { "IP6", 3};
882 static const pj_str_t STR_SENDRECV = { "sendrecv", 8 };
883 pjmedia_sdp_media *media;
884 char hostip[PJ_INET6_ADDRSTRLEN+2];
885 struct ast_sockaddr addr;
888 pjmedia_sdp_attr *attr;
890 int noncodec = (session->endpoint->dtmf == AST_SIP_DTMF_RFC_4733) ? AST_RTP_DTMF : 0;
891 int min_packet_size = 0, max_packet_size = 0;
893 RAII_VAR(struct ast_format_cap *, caps, NULL, ao2_cleanup);
894 enum ast_media_type media_type = stream_to_media_type(session_media->stream_type);
895 int use_override_prefs = ast_format_cap_count(session->req_caps);
897 int direct_media_enabled = !ast_sockaddr_isnull(&session_media->direct_media_addr) &&
898 ast_format_cap_count(session->direct_media_cap);
900 if ((use_override_prefs && !ast_format_cap_has_type(session->req_caps, media_type)) ||
901 (!use_override_prefs && !ast_format_cap_has_type(session->endpoint->media.codecs, media_type))) {
902 /* If no type formats are configured don't add a stream */
904 } else if (!session_media->rtp && create_rtp(session, session_media, session->endpoint->media.rtp.ipv6)) {
908 if (!(media = pj_pool_zalloc(pool, sizeof(struct pjmedia_sdp_media))) ||
909 !(media->conn = pj_pool_zalloc(pool, sizeof(struct pjmedia_sdp_conn)))) {
913 if (add_crypto_to_stream(session, session_media, pool, media)) {
917 media->desc.media = pj_str(session_media->stream_type);
918 if (session->endpoint->media.rtp.use_received_transport && pj_strlen(&session_media->transport)) {
919 media->desc.transport = session_media->transport;
921 media->desc.transport = pj_str(ast_sdp_get_rtp_profile(
922 session->endpoint->media.rtp.encryption == AST_SIP_MEDIA_ENCRYPT_SDES,
923 session_media->rtp, session->endpoint->media.rtp.use_avpf,
924 session->endpoint->media.rtp.force_avp));
927 /* Add connection level details */
928 if (direct_media_enabled) {
929 ast_copy_string(hostip, ast_sockaddr_stringify_fmt(&session_media->direct_media_addr, AST_SOCKADDR_STR_ADDR), sizeof(hostip));
930 } else if (ast_strlen_zero(session->endpoint->media.address)) {
931 pj_sockaddr localaddr;
933 if (pj_gethostip(session->endpoint->media.rtp.ipv6 ? pj_AF_INET6() : pj_AF_INET(), &localaddr)) {
936 pj_sockaddr_print(&localaddr, hostip, sizeof(hostip), 2);
938 ast_copy_string(hostip, session->endpoint->media.address, sizeof(hostip));
941 media->conn->net_type = STR_IN;
942 media->conn->addr_type = session->endpoint->media.rtp.ipv6 ? STR_IP6 : STR_IP4;
943 pj_strdup2(pool, &media->conn->addr, hostip);
944 ast_rtp_instance_get_local_address(session_media->rtp, &addr);
945 media->desc.port = direct_media_enabled ? ast_sockaddr_port(&session_media->direct_media_addr) : (pj_uint16_t) ast_sockaddr_port(&addr);
946 media->desc.port_count = 1;
948 /* Add ICE attributes and candidates */
949 add_ice_to_stream(session, session_media, pool, media);
951 if (!(caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
952 ast_log(LOG_ERROR, "Failed to allocate %s capabilities\n", session_media->stream_type);
956 if (direct_media_enabled) {
957 ast_format_cap_get_compatible(session->endpoint->media.codecs, session->direct_media_cap, caps);
958 } else if (!ast_format_cap_count(session->req_caps) ||
959 !ast_format_cap_iscompatible(session->req_caps, session->endpoint->media.codecs)) {
960 ast_format_cap_append_from_cap(caps, session->endpoint->media.codecs, media_type);
962 ast_format_cap_append_from_cap(caps, session->req_caps, media_type);
965 for (index = 0; index < ast_format_cap_count(caps); ++index) {
966 struct ast_format *format = ast_format_cap_get_format(caps, index);
968 if (ast_format_get_type(format) != media_type) {
973 if ((rtp_code = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(session_media->rtp), 1, format, 0)) == -1) {
974 ast_log(LOG_WARNING,"Unable to get rtp codec payload code for %s\n", ast_format_get_name(format));
979 if (!(attr = generate_rtpmap_attr(media, pool, rtp_code, 1, format, 0))) {
983 media->attr[media->attr_count++] = attr;
985 if ((attr = generate_fmtp_attr(pool, format, rtp_code))) {
986 media->attr[media->attr_count++] = attr;
989 if (ast_format_get_maximum_ms(format) &&
990 ((ast_format_get_maximum_ms(format) < max_packet_size) || !max_packet_size)) {
991 max_packet_size = ast_format_get_maximum_ms(format);
996 /* Add non-codec formats */
997 if (media_type != AST_MEDIA_TYPE_VIDEO) {
998 for (index = 1LL; index <= AST_RTP_MAX; index <<= 1) {
999 if (!(noncodec & index) || (rtp_code = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(session_media->rtp),
1000 0, NULL, index)) == -1) {
1004 if (!(attr = generate_rtpmap_attr(media, pool, rtp_code, 0, NULL, index))) {
1008 media->attr[media->attr_count++] = attr;
1010 if (index == AST_RTP_DTMF) {
1011 snprintf(tmp, sizeof(tmp), "%d 0-16", rtp_code);
1012 attr = pjmedia_sdp_attr_create(pool, "fmtp", pj_cstr(&stmp, tmp));
1013 media->attr[media->attr_count++] = attr;
1018 /* If no formats were actually added to the media stream don't add it to the SDP */
1019 if (!media->desc.fmt_count) {
1023 /* If ptime is set add it as an attribute */
1024 min_packet_size = ast_rtp_codecs_get_framing(ast_rtp_instance_get_codecs(session_media->rtp));
1025 if (!min_packet_size) {
1026 min_packet_size = ast_format_cap_get_framing(caps);
1028 if (min_packet_size) {
1029 snprintf(tmp, sizeof(tmp), "%d", min_packet_size);
1030 attr = pjmedia_sdp_attr_create(pool, "ptime", pj_cstr(&stmp, tmp));
1031 media->attr[media->attr_count++] = attr;
1034 if (max_packet_size) {
1035 snprintf(tmp, sizeof(tmp), "%d", max_packet_size);
1036 attr = pjmedia_sdp_attr_create(pool, "maxptime", pj_cstr(&stmp, tmp));
1037 media->attr[media->attr_count++] = attr;
1040 /* Add the sendrecv attribute - we purposely don't keep track because pjmedia-sdp will automatically change our offer for us */
1041 attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr);
1042 attr->name = STR_SENDRECV;
1043 media->attr[media->attr_count++] = attr;
1045 /* Add the media stream to the SDP */
1046 sdp->media[sdp->media_count++] = media;
1051 static int apply_negotiated_sdp_stream(struct ast_sip_session *session, struct ast_sip_session_media *session_media,
1052 const struct pjmedia_sdp_session *local, const struct pjmedia_sdp_media *local_stream,
1053 const struct pjmedia_sdp_session *remote, const struct pjmedia_sdp_media *remote_stream)
1055 RAII_VAR(struct ast_sockaddr *, addrs, NULL, ast_free_ptr);
1056 enum ast_media_type media_type = stream_to_media_type(session_media->stream_type);
1057 char host[NI_MAXHOST];
1060 if (!session->channel) {
1064 /* Ensure incoming transport is compatible with the endpoint's configuration */
1065 if (!session->endpoint->media.rtp.use_received_transport &&
1066 check_endpoint_media_transport(session->endpoint, remote_stream) == AST_SIP_MEDIA_TRANSPORT_INVALID) {
1070 /* Create an RTP instance if need be */
1071 if (!session_media->rtp && create_rtp(session, session_media, session->endpoint->media.rtp.ipv6)) {
1075 if (setup_media_encryption(session, session_media, remote, remote_stream)) {
1079 ast_copy_pj_str(host, remote_stream->conn ? &remote_stream->conn->addr : &remote->conn->addr, sizeof(host));
1081 /* Ensure that the address provided is valid */
1082 if (ast_sockaddr_resolve(&addrs, host, PARSE_PORT_FORBID, AST_AF_UNSPEC) <= 0) {
1083 /* The provided host was actually invalid so we error out this negotiation */
1087 /* Apply connection information to the RTP instance */
1088 ast_sockaddr_set_port(addrs, remote_stream->desc.port);
1089 ast_rtp_instance_set_remote_address(session_media->rtp, addrs);
1090 if (set_caps(session, session_media, local_stream)) {
1094 if ((fdno = media_type_to_fdno(media_type)) < 0) {
1097 ast_channel_set_fd(session->channel, fdno, ast_rtp_instance_fd(session_media->rtp, 0));
1098 ast_channel_set_fd(session->channel, fdno + 1, ast_rtp_instance_fd(session_media->rtp, 1));
1100 /* If ICE support is enabled find all the needed attributes */
1101 process_ice_attributes(session, session_media, remote, remote_stream);
1103 /* Ensure the RTP instance is active */
1104 ast_rtp_instance_activate(session_media->rtp);
1106 /* audio stream handles music on hold */
1107 if (media_type != AST_MEDIA_TYPE_AUDIO) {
1111 if (ast_sockaddr_isnull(addrs) ||
1112 ast_sockaddr_is_any(addrs) ||
1113 pjmedia_sdp_media_find_attr2(remote_stream, "sendonly", NULL)) {
1114 if (!session_media->held) {
1115 /* The remote side has put us on hold */
1116 ast_queue_hold(session->channel, session->endpoint->mohsuggest);
1117 ast_rtp_instance_stop(session_media->rtp);
1118 ast_queue_frame(session->channel, &ast_null_frame);
1119 session_media->held = 1;
1121 } else if (session_media->held) {
1122 /* The remote side has taken us off hold */
1123 ast_queue_unhold(session->channel);
1124 ast_queue_frame(session->channel, &ast_null_frame);
1125 session_media->held = 0;
1131 /*! \brief Function which updates the media stream with external media address, if applicable */
1132 static void change_outgoing_sdp_stream_media_address(pjsip_tx_data *tdata, struct pjmedia_sdp_media *stream, struct ast_sip_transport *transport)
1134 char host[NI_MAXHOST];
1135 struct ast_sockaddr addr = { { 0, } };
1137 /* If the stream has been rejected there will be no connection line */
1138 if (!stream->conn) {
1142 ast_copy_pj_str(host, &stream->conn->addr, sizeof(host));
1143 ast_sockaddr_parse(&addr, host, PARSE_PORT_FORBID);
1145 /* Is the address within the SDP inside the same network? */
1146 if (ast_apply_ha(transport->localnet, &addr) == AST_SENSE_ALLOW) {
1150 pj_strdup2(tdata->pool, &stream->conn->addr, transport->external_media_address);
1153 /*! \brief Function which destroys the RTP instance when session ends */
1154 static void stream_destroy(struct ast_sip_session_media *session_media)
1156 if (session_media->rtp) {
1157 ast_rtp_instance_stop(session_media->rtp);
1158 ast_rtp_instance_destroy(session_media->rtp);
1162 /*! \brief SDP handler for 'audio' media stream */
1163 static struct ast_sip_session_sdp_handler audio_sdp_handler = {
1165 .negotiate_incoming_sdp_stream = negotiate_incoming_sdp_stream,
1166 .create_outgoing_sdp_stream = create_outgoing_sdp_stream,
1167 .apply_negotiated_sdp_stream = apply_negotiated_sdp_stream,
1168 .change_outgoing_sdp_stream_media_address = change_outgoing_sdp_stream_media_address,
1169 .stream_destroy = stream_destroy,
1172 /*! \brief SDP handler for 'video' media stream */
1173 static struct ast_sip_session_sdp_handler video_sdp_handler = {
1175 .negotiate_incoming_sdp_stream = negotiate_incoming_sdp_stream,
1176 .create_outgoing_sdp_stream = create_outgoing_sdp_stream,
1177 .apply_negotiated_sdp_stream = apply_negotiated_sdp_stream,
1178 .change_outgoing_sdp_stream_media_address = change_outgoing_sdp_stream_media_address,
1179 .stream_destroy = stream_destroy,
1182 static int video_info_incoming_request(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
1184 struct pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata);
1185 pjsip_tx_data *tdata;
1187 if (!ast_sip_is_content_type(&rdata->msg_info.msg->body->content_type,
1189 "media_control+xml")) {
1193 ast_queue_control(session->channel, AST_CONTROL_VIDUPDATE);
1195 if (pjsip_dlg_create_response(session->inv_session->dlg, rdata, 200, NULL, &tdata) == PJ_SUCCESS) {
1196 pjsip_dlg_send_response(session->inv_session->dlg, tsx, tdata);
1202 static struct ast_sip_session_supplement video_info_supplement = {
1204 .incoming_request = video_info_incoming_request,
1207 /*! \brief Unloads the sdp RTP/AVP module from Asterisk */
1208 static int unload_module(void)
1210 ast_sip_session_unregister_supplement(&video_info_supplement);
1211 ast_sip_session_unregister_sdp_handler(&video_sdp_handler, STR_VIDEO);
1212 ast_sip_session_unregister_sdp_handler(&audio_sdp_handler, STR_AUDIO);
1215 ast_sched_context_destroy(sched);
1222 * \brief Load the module
1224 * Module loading including tests for configuration or dependencies.
1225 * This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE,
1226 * or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails
1227 * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the
1228 * configuration file or other non-critical problem return
1229 * AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS.
1231 static int load_module(void)
1233 CHECK_PJSIP_SESSION_MODULE_LOADED();
1235 ast_sockaddr_parse(&address_ipv4, "0.0.0.0", 0);
1236 ast_sockaddr_parse(&address_ipv6, "::", 0);
1238 if (!(sched = ast_sched_context_create())) {
1239 ast_log(LOG_ERROR, "Unable to create scheduler context.\n");
1243 if (ast_sched_start_thread(sched)) {
1244 ast_log(LOG_ERROR, "Unable to create scheduler context thread.\n");
1248 if (ast_sip_session_register_sdp_handler(&audio_sdp_handler, STR_AUDIO)) {
1249 ast_log(LOG_ERROR, "Unable to register SDP handler for %s stream type\n", STR_AUDIO);
1253 if (ast_sip_session_register_sdp_handler(&video_sdp_handler, STR_VIDEO)) {
1254 ast_log(LOG_ERROR, "Unable to register SDP handler for %s stream type\n", STR_VIDEO);
1258 ast_sip_session_register_supplement(&video_info_supplement);
1260 return AST_MODULE_LOAD_SUCCESS;
1264 return AST_MODULE_LOAD_FAILURE;
1267 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP SDP RTP/AVP stream handler",
1268 .support_level = AST_MODULE_SUPPORT_CORE,
1269 .load = load_module,
1270 .unload = unload_module,
1271 .load_pri = AST_MODPRI_CHANNEL_DRIVER,