summaryrefslogtreecommitdiff
path: root/res/res_pjsip_sdp_rtp.c
AgeCommit message (Collapse)Author
2018-03-19rtp: Add REMB RTP property and set it on PJSIP video RTP.Joshua Colp
This change adds a property to RTP instances to indicate that REMB support is enabled and that sending/receiving should be passed through. This also enables it on video RTP instances in PJSIP if WebRTC support is enabled. Finally the goog-remb extension is added to the SDP using the rtcp-fb attribute to indicate our support for it. Details about REMB can be found on the draft document for it: https://tools.ietf.org/html/draft-alvestrand-rmcat-remb-03 Change-Id: I1902dda1c0882bd1a0d71b2f120684b44b97e789
2018-02-23Add extended properties to rtp_engine for RTP retransmission support.Ben Ford
A couple of additional properties are needed in rtp_engine to enable support for packet retransmission: AST_RTP_PROPERTY_RETRANS_RECV and AST_RTP_PROPERTY_RETRANS_SEND. These will both be enabled automatically if an endpoint has the webrtc option enabled. While this adds no functionality currently, it will serve as a building block for future changes for RTP retransmission support. For more information, refer to the wiki page: https://wiki.asterisk.org/wiki/display/AST/WebRTC+User+Experience+Improvements Change-Id: Ic598acd042a045f9d10e5bdccb66f4efc9e587cc
2018-01-24Remove redundant module checks and references.Corey Farrell
This removes references that are no longer needed due to automatic references created by module dependencies. In addition this removes most calls to ast_module_check as they were checking modules which are listed as dependencies. Change-Id: I332a6e8383d4c72c8e89d988a184ab8320c4872e
2018-01-15loader: Add dependency fields to module structures.Corey Farrell
* Declare 'requires' and 'enhances' text fields on module info structure. * Rename 'nonoptreq' to 'optional_modules'. * Update doxygen comments. Still need to investigate dependencies among modules I cannot compile. Change-Id: I3ad9547a0a6442409ff4e352a6d897bef2cc04bf
2017-12-31ice: Increase foundation buffer sizeSean Bright
Per RFC 5245, the foundation specified with an ICE candidate can be up to 32 characters but we are only allowing for 31. ASTERISK-27498 #close Reported by: Michele Prà Change-Id: I05ce7a5952721a76a2b4c90366168022558dc7cf
2017-12-14res_pjsip_sdp_rtp: Add NULL check in add_crypto_to_streamGeorge Joseph
add_crypto_to_stream wasn't checking for a NULL session->inv_session->neg before calling pjmedia_sdp_neg_get_state. This was causing a crash if the negotiation hadn't already been completed and asterisk was compiled with --enable-dev-mode. Change-Id: I57c6229954a38145da9810fc18657bfcc4d9d0c9
2017-10-30core / pjsip: Add support for grouping streams together.Joshua Colp
In WebRTC streams (or media tracks in their world) can be grouped together using the mslabel. This informs the browser that each should be synchronized with each other. This change extends the stream API so this information can be stored with streams. The PJSIP support has been extended to use the mslabel to determine grouped streams and store this association on the streams. Finally when creating the SDP the group information is used to cause each media stream to use the same mslabel. ASTERISK-27379 Change-Id: Id6299aa031efe46254edbdc7973c534d54d641ad
2017-10-23res_pjsip_sdp_rtp: Fix setting of address type for rtp_ipv6George Joseph
create_outgoing_sdp_stream was setting "addr_type = STR_IP6" only when an ipv6 media_address was specified on the endpoint. If rtp_ipv6 was set and ast_sip_get_host_ip_string returned an ipv6 address, we were leaving the addr_type set at the default of STR_IP4. This caused the address type to be set incorrectly on the "o" and "c" SDP attributes even though the address was set correctly. Some clients don't like the mismatch. * Removed the test for endpoint/media_address and now check all addresses for ipv6. ASTERISK-27198 Reported by: Martin Cisárik Change-Id: I5214fc31b728117842243807e7927a319cf77592
2017-09-21Merge "bridge: Change participant SFU streams when source streams change."Joshua Colp
2017-09-21bridge: Change participant SFU streams when source streams change.Joshua Colp
Some endpoints do not like a stream being reused for a new media stream. The frame/jitterbuffer can rely on underlying attributes of the media stream in order to order the packets. When a new stream takes its place without any notice the buffer can get confused and the media ends up getting dropped. This change uses the SSRC change to determine that a new source is reusing an existing stream and then bridge_softmix renegotiates each participant such that they see a new media stream. This causes the frame/jitterbuffer to start fresh and work as expected. ASTERISK-27277 Change-Id: I30ccbdba16ca073d7f31e0e59ab778c153afae07
2017-09-20res_pjsip_session: Check for removed stream state.Ben Ford
When a sip session is refreshed, the stream topology is looped through, checking each stream for compatible formats. This would cause a crash if the stream state was AST_STREAM_STATE_REMOVED, since the formats would never be set for this stream, causing a NULL value to be returned from ast_stream_get_formats. This commit adds a check for streams with removed states. Also removed a stray semicolon. Change-Id: Ic86f8b65a4a26a60885b28b8b1a0b22e1b471d42
2017-09-10res/res_pjsip: Fix localnet checks in pjsip, part 2.Walter Doekes
In 45744fc53, I mistakenly broke SDP media address rewriting by misinterpreting which address was checked in the localnet comparison. Instead of checking the remote peer address to decide whether we need media address rewriting, we check our local media address: if it's local, then we rewrite. This feels awkward, but works and even made directmedia work properly if you set local_net. (For the record: for local peers, the SDP media rewrite code is not called, so the comparison does no harm there.) ASTERISK-27248 #close Change-Id: I566be1c33f4d0a689567d451ed46bab9c3861d4f
2017-09-05res/res_pjsip: Standardize/fix localnet checks across pjsip.Walter Doekes
In 2dee95cc (ASTERISK-27024) and 776ffd77 (ASTERISK-26879) there was confusion about whether the transport_state->localnet ACL has ALLOW or DENY semantics. For the record: the localnet has DENY semantics, meaning that "not in the list" means ALLOW, and the local nets are in the list. Therefore, checks like this look wrong, but are right: /* See if where we are sending this request is local or not, and if not that we can get a Contact URI to modify */ if (ast_apply_ha(transport_state->localnet, &addr) != AST_SENSE_ALLOW) { ast_debug(5, "Request is being sent to local address, " "skipping NAT manipulation\n"); (In the list == localnet == DENY == skip NAT manipulation.) And conversely, other checks that looked right, were wrong. This change adds two macro's to reduce the confusion and uses those instead: ast_sip_transport_is_nonlocal(transport_state, addr) ast_sip_transport_is_local(transport_state, addr) ASTERISK-27248 #close Change-Id: Ie7767519eb5a822c4848e531a53c0fd054fae934
2017-08-09res_rtp_asterisk: Make P2P bridge Asymmetric codec awareTorrey Searle
Introduce a new property to rtp-engine to make it aware of the desire for assymetric codecs or not. If asymmetric codecs is not allowed, the bridge will compare read/write formats and shut down the p2p bridge if needed ASTERISK-26745 #close Change-Id: I0d9c83e5356df81661e58d40a8db565833501a6f
2017-08-04res_pjsip_session/_sdp_rtp: Handling of 'msid' is incorrectKevin Harwell
Currently, the handling of the msid attribute is not quite right. According to the spec the msid's between the offer/answer are not dependent upon one another. Meaning the same msid's given in an offer do not have to be returned in the answer for a given stream. And they probably shouldn't be (copied/reused) since this can potentially cause some browser side confusion. This patch generates new msids when both an offer and answer are sent from Asterisk. However, Asterisk does reuse the original msid it sent out for a reinvite. Also audio+video streams are paired together by sharing the same stream id, but a different track id. ASTERISK-27179 #close Change-Id: Ifaec06dc7e65ad841633a24ebec8c8a9302d6643
2017-08-01res_pjsip: Add support for dnsmgr to external_media_address.Joshua Colp
The "external_media_address" option on transports is now resolved using dnsmgr. This allows it to be automatically refreshed regularly if refreshes are enabled in dnsmgr. If the system is using a dynamic IP address a dynamic DNS hostname can be provided to keep the IP address up to date. Change-Id: Ia54771720dff0105bde55d5bbb81a3ba437e05b2
2017-08-01chan_pjsip: add a new function PJSIP_DTMF_MODETorrey Searle
This function is a replica of SIPDtmfMode, allowing the DTMF mode of a PJSIP call to be modified on a per-call basis ASTERISK-27085 #close Change-Id: I20eef5da3e5d1d3e58b304416bc79683f87e7612
2017-07-13res_pjsip: Add "webrtc" configuration optionKevin Harwell
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
2017-07-13res_rtp_asterisk / res_pjsip: Add support for BUNDLE.Joshua Colp
BUNDLE is a specification used in WebRTC to allow multiple streams to use the same underlying transport. This reduces the number of ICE and DTLS negotiations that has to occur to 1 normally. This change implements this by adding support for it to the RTP SDP module in PJSIP. BUNDLE can be turned on using the "bundle" option and on an offer we will offer to bundle streams together. On an answer we will accept any bundle groups provided. Once accepted each stream is bundled to another RTP instance for transport. For the res_rtp_asterisk changes the ability to bundle an RTP instance to another based on the SSRC received from the remote side has been added. For outgoing traffic if an RTP instance is bundled to another we will use the other RTP instance for any transport related things. For incoming traffic received from the transport instance we look up the correct instance based on the SSRC and use it for any non-transport related data. ASTERISK-27118 Change-Id: I96c0920b9f9aca7382256484765a239017973c11
2017-06-29res_pjsip: Add DTMF INFO Failback modeTorrey Searle
The existing auto dtmf mode reverts to inband if 4733 fails to be negotiated. This patch adds a new mode auto_info which will switch to INFO instead of inband if 4733 is not available. ASTERISK-27066 #close Change-Id: Id185b11e84afd9191a2f269e8443019047765e91
2017-06-28chan_pjsip: Add support for multiple streams of the same type.Mark Michelson
The stream topology (list of streams and order) is now stored with the configured PJSIP endpoints and used during the negotiation process. Media negotiation state information has been changed to be stored in a separate object. Two of these objects exist at any one time on a session. The active media state information is what was previously negotiated and the pending media state information is what the media state will become if negotiation succeeds. Streams and other state information is stored in this object using the index (or position) of each individual stream for easy lookup. The ability for a media type handler to specify a callback for writing has been added as well as the ability to add file descriptors with a callback which is invoked when data is available to be read on them. This allows media logic to live outside of the chan_pjsip module. Direct media has been changed so that only the first audio and video stream are directly connected. In the future once the RTP engine glue API has been updated to know about streams each individual stream can be directly connected as appropriate. Media negotiation itself will currently answer all the provided streams on an offer within configured limits and on an offer will use the topology created as a result of the disallow/allow codec lines. If a stream has been removed or declined we will now mark it as such within the resulting SDP. Applications can now also request that the stream topology change. If we are told to do so we will limit any provided formats to the ones configured on the endpoint and send a re-invite with the new topology. Two new configuration options have also been added to PJSIP endpoints: max_audio_streams: determines the maximum number of audio streams to offer/accept from an endpoint. Defaults to 1. max_video_streams: determines the maximum number of video streams to offer/accept from an endpoint. Defaults to 1. ASTERISK-27076 Change-Id: I8afd8dd2eb538806a39b887af0abd046266e14c7
2017-06-07pjsip: Extend 'asymmetric_rtp_codec' option to include us changing.Joshua Colp
PJSIP support in Asterisk differs from chan_sip in that it allows media to be sent as-is without transcoding provided the codecs were negotiated in the SDP. This is allowed according to the RFC. Support for this differs quite a lot though and some endpoints do not handle it well. This change extends the 'asymmetric_rtp_codec' option to also cover this case. When set to no (the default) the code behaves as chan_sip does - the best codec is selected and we will only ever send that, unless we change what we are sending if the remote side changes. When set to yes we will send media as-is without transcoding if the codec has been negotiated in the SDP. ASTERISK-26996 Change-Id: Ib1647f6902a0843e8c435946f831c2159e8d1d51
2017-04-26Merge "res_pjsip_sdp_rtp: No rtpmap for static RTP payload IDs in SDP."Jenkins2
2017-04-13res_pjsip_sdp_rtp: No rtpmap for static RTP payload IDs in SDP.Alexander Traud
This saves around 100 bytes when G.711, G.722, G.729, and GSM are advertised in SDP. This reduces the chance to hit the MTU bearer of 1300 bytes for SIP over UDP, if many codecs are allowed in Asterisk. This new feature is enabled together with the optional feature compact_headers=yes via the file pjsip.conf. ASTERISK-26932 #close Change-Id: Iaa556ab4c8325cd34c334387ab2847fab07b1689
2017-04-12modules: change module LOAD_FAILUREs to LOAD_DECLINESGeorge Joseph
In all non-pbx modules, AST_MODULE_LOAD_FAILURE has been changed to AST_MODULE_LOAD_DECLINE. This prevents asterisk from exiting if a module can't be loaded. If the user wishes to retain the FAILURE behavior for a specific module, they can use the "require" or "preload-require" keyword in modules.conf. A new API was added to logger: ast_is_logger_initialized(). This allows asterisk.c/check_init() to print to the error log once the logger subsystem is ready instead of just to stdout. If something does fail before the logger is initialized, we now print to stderr instead of stdout. Change-Id: I5f4b50623d9b5a6cb7c5624a8c5c1274c13b2b25
2017-04-11res_pjsip_sdp_rtp.c: Don't use deprecated transport struct member.Richard Mudgett
* create_rtp(): Eliminate use of deprecated transport struct member. That member and several others in the transport structure were deprecated because of an infinite loop created when using realtime configuration. See 2451d4e4550336197ee2e482750cc53f30afa352 ASTERISK-26851 Change-Id: I0533aa13c9ce3c6cc394e0fd2b5bf1cd1b2ef3bc
2017-04-04res_pjsip_sdp_rtp.c: Don't alter global addr variable.Richard Mudgett
* create_rtp(): Fix unexpected alteration of global address_rtp if a transport is bound to an address. * create_rtp(): Fix use of uninitialized memory if the endpoint RTP media address is invalid or the transport has an invalid address. ASTERISK-26851 Change-Id: Icde42e65164a88913cb5c2601b285eebcff397b7
2017-03-27Add DTLS sanity check.Richard Mudgett
Change-Id: Ib32612cf6c7ce9213a11b9cba82f630f8cd3564b
2017-03-24res_pjsip_sdp_rtp: Set hangup cause for RTP timeoutsSean Bright
chan_sip sets the hangup cause code to AST_CAUSE_REQUESTED_CHAN_UNAVAIL (44) when a channel is hung up due to an RTP timeout. So do the same when it happens with PJSIP for parity. Change-Id: I3546ebbde6460c22a27c9da1bf321711b5961ab8
2017-03-20Merge "res/res_pjsip_session: Only check localnet if it is defined"Joshua Colp
2017-03-17Merge "res_pjsip_sdp_rtp.c: Fix cut-n-paste error"Joshua Colp
2017-03-16res_pjsip_sdp_rtp.c: Fix cut-n-paste errorRichard Mudgett
We were inadvertenly referencing the cos_video option to determine if we should set the tos_audio and cos_audio value on the RTP instance. Change-Id: Ia7964f486801d39dc6f5dae570baff079e1595b0
2017-03-16res/res_pjsip_session: Only check localnet if it is definedMatt Jordan
If local_net is not defined on a transport, transport_state->localnet will be NULL. ast_apply_ha will, be default, return AST_SENSE_ALLOW in this case, causing the external_media_address, if set, to be skipped. This patch causes us to only check if we are sending within a network if local_net is defined. ASTERISK-26879 #close Change-Id: Ib661c31a954cabc9c99f1f25c9c9a5c5b82cbbfb
2017-03-16res_pjsip_sdp_rtp: RTP instance does not use same IP as explicit transportRichard Begg
Currently a wildcard address is used for the local RTP socket, which will not always result in the same address as used by the SIP socket (e.g. if explicit transport addresses are configured). Use the transport's host address when binding new local RTP sockets if available. ASTERISK-26851 Change-Id: I098c29c9d1f79a4f970d72ba894874ac75954f1a
2017-03-15Add rtcp-mux supportMark Michelson
This commit adds support for RFC 5761: Multiplexing RTP Data and Control Packets on a Single Port. Specifically, it enables the feature when using chan_pjsip. A new option, "rtcp_mux" has been added to endpoint configuration in pjsip.conf. If set, then Asterisk will attempt to use rtcp-mux with whatever it communicates with. Asterisk follows the rules set forth in RFC 5761 with regards to falling back to standard RTCP behavior if the far end does not indicate support for rtcp-mux. The lion's share of the changes in this commit are in res_rtp_asterisk.c. This is because it was pretty much hard wired to have an RTP and an RTCP transport. The strategy used here is that when rtcp-mux is enabled, the current RTCP transport and its trappings (such as DTLS SSL session) are freed, and the RTCP session instead just mooches off the RTP session. This leads to a lot of specialized if statements throughout. ASTERISK-26732 #close Reported by Dan Jenkins Change-Id: If46a93ba1282418d2803e3fd7869374da8b77ab5
2017-02-13stream: Add media stream topology definition and APIGeorge Joseph
This change adds the media stream topology definition and API for accessing and using it. Some refactoring of the stream was also done. ASTERISK-26786 Change-Id: Ic930232d24d5ad66dcabc14e9b359e0ff8e7f568
2016-11-30res_rtp: Fix regression when IPv6 is not available.Guido Falsi
The latest Release candidate fails to create RTP streams when IPv6 is not available. Due to the changes made in September the ast_sockaddr structure passed around to create these streams is always of AF_INET6 type, causing failure when used for IPv4. This patch adds a utility function to check for availability of IPv6 and applies such check at startup to determine how to create the ast_sockaddr structures. ASTERISK-26617 #close Change-Id: I627a4e91795e821111e1cda523f083a40d0e0c3e
2016-11-11res_pjsip_sdp_rtp: Reject offer of required SRTP without res_srtp.Joshua Colp
When optimistic SRTP was on it was possible for us to still set up a call without an audio stream if an offer was received with required SRTP. This change makes it so this scenario will now fail with a 488 response. ASTERISK-26575 Change-Id: I7d14187037681f48879bd20319ac79d0877318f3
2016-11-01res_pjsip_sdp_rtp: Limit number of formats to defined maximum.Joshua Colp
The res_pjsip_sdp_rtp module did not restrict the number of formats added to a media stream in the SDP to the defined limit. If allow=all was used with additional loaded codecs this could result in the next media stream being overwritten some. This change restricts the module to limit it to the defined maximum and also increases the maximum in our bundled pjproject. ASTERISK-26541 #close Change-Id: I0dc5f59d3891246cafa2f3df5ec406f088559ee8
2016-10-27Merge "Remove ASTERISK_REGISTER_FILE."zuul
2016-10-27Merge "res_pjsip_sdp_rtp: Fix address family of explicit media_address."zuul
2016-10-27Remove ASTERISK_REGISTER_FILE.Corey Farrell
ASTERISK_REGISTER_FILE no longer has any purpose so this commit removes all traces of it. Previously exported symbols removed: * __ast_register_file * __ast_unregister_file * ast_complete_source_filename This also removes the mtx_prof static variable that was declared when MTX_PROFILE was enabled. This variable was only used in lock.c so it is now initialized in that file only. ASTERISK-26480 #close Change-Id: I1074af07d71f9e159c48ef36631aa432c86f9966
2016-10-26pjsip: Fix a few media bugs with reinvites and asymmetric payloads.Joshua Colp
When channel format changes occurred as a result of an RTP re-negotiation the bridge was not informed this had happened. As a result the bridge technology was not re-evaluated and the channel may have been in a bridge technology that was incompatible with its formats. The bridge is now unbridged and the technology re-evaluated when this occurs. The chan_pjsip module also allowed asymmetric codecs for sending and receiving. This did not work with all devices and caused one way audio problems. The default has been changed to NOT do this but to match the sending codec to the receiving codec. For users who want asymmetric codecs an option has been added, asymmetric_rtp_codec, which will return chan_pjsip to the previous behavior. The codecs returned by the chan_pjsip module when queried by the bridge_native_rtp module were also not reflective of the actual negotiated codecs. The nativeformats are now returned as they reflect the actual negotiated codecs. ASTERISK-26423 #close Change-Id: I6ec88c6e3912f52c334f1a26983ccb8f267020dc
2016-10-26res_pjsip_sdp_rtp: Fix address family of explicit media_address.Joshua Colp
When an explicit media_address is provided the address family in the SDP needs to be set to reflect it. ASTERISK-26309 Change-Id: Ib9350cc91c120eb2f96f0623d3907d12af67eb79
2016-10-23pjsip: Support dual stack automatically.Joshua Colp
This change adds support for dual stack automatically. No configuration is required and the IP address and version in the SIP messages and SDP will be automatically changed based on the transport over which the message is being sent. RTP usage has also been changed to listen on both IPv4 and IPv6 simultaneously to allow media to flow, and to allow ICE support on both simultaneously. This also allows failover between IPv6 and IPv4 to work as expected. ASTERISK-26309 #close Change-Id: I235a421d8f9a326606d861b449fa6fe3a030572d
2016-09-09res/res_pjsip: Add preferred_codec_only config to pjsip endpoint.Aaron An
This patch add config to pjsip by endpoint. ;preferred_codec_only=yes ; Respond to a SIP invite with the single most preferred codec ; rather than advertising all joint codec capabilities. This ; limits the other side's codec choice to exactly what we prefer. ASTERISK-26317 #close Reported by: AaronAn Tested by: AaronAn Change-Id: Iad04dc55055403bbf5ec050997aee2dadc4f0762
2016-07-21res_srtp: Enable AES-256 and AES-GCM.Alexander Traud
ASTERISK-26190 #close Change-Id: I11326d80edd656524a51a19450e586c583aa0a0b
2016-06-20fix: memory leaks, resource leaks, out of bounds and bugsAlexei Gradinari
ASTERISK-26119 #close Change-Id: Iecbf7d0f360a021147344c4e83ab242fd1e7512c
2016-02-08res_pjsip: Fix infinite recursion when loading transports from realtimeGeorge Joseph
Attempting to load a transport from realtime was forcing asterisk into an infinite recursion loop. The first thing transport_apply did was to do a sorcery retrieve by id for an existing transport of the same name. For files, this just returns the previous object from res_sorcery_config's internal container, if any. For realtime, the res_sourcery_realtime driver looks in the database and finds the existing row but now it has to rehydrate it into a sorcery object which means calling... transport_apply. And so it goes. The main issue with loading from realtime (apart from the loop) was that transport stores structures and pointers directly in the ast_sip_transport structure instead of the separate ast_transport_state structure. This patch separates those items into the ast_sip_transport_state structure. The pattern is roughly the same as res_pjsip_outbound_registration. Although all current usages of ast_sip_transport and ast_sip_transport_state were modified to use the new ast_sip_get_transport_state API, the original items are left in ast_sip_transport and kept updated to maintain ABI compatability for third-party modules. They are marked as deprecated and noted that they're now in ast_sip_transport_state. ASTERISK-25606 #close Reported-by: Martin Moučka Change-Id: Ic7a836ea8e786e8def51fe3f8cce855ea54f5f19
2016-01-11pjsip_sdp_rtp: Add option endpoint/bind_rtp_to_media_addressGeorge Joseph
On a system with multiple ip addresses in the same subnet, if a transport is bound to a specific ip address and endpoint/media_address is set, the SIP/SDP will have the correct address in all fields but the rtp stream MAY still originate from one of the other ip addresses, most probably the "primary" ip address. This happens because res_pjsip_sdp_rtp/create_rtp always calls ast_instance_new with the "all" ip address (0.0.0.0 or ::). The new option causes res_pjsip_sdp_rtp/create_rtp to call ast_rtp_instance_new with the endpoint's media_address (if specified) instead of the "all" address. This causes the packets to originate from the specified address. ASTERISK-25632 ASTERISK-25637 Reported-by: Olivier Krief Reported-by: Dan Journo Change-Id: I3dfaa079e54ba7fb7c4fd1f5f7bd9509bbf8bd88