summaryrefslogtreecommitdiff
path: root/res/res_pjsip_session.c
AgeCommit message (Collapse)Author
2017-12-14Merge "res_pjsip_session: Reinvite using active stream topology if none ↵Jenkins2
requested." into 15
2017-12-13res_pjsip_session: Reinvite using active stream topology if none requested.Joshua Colp
When a connected line update is sent to an endpoint we do not request a specific stream topology to be used. Previously this resulted in the configured stream topology being used which may actually differ from the currently negotiated topology. PJSIP is helpful in this regard in that it will fill in any missing streams with removed ones. This results in our own state not matching the SDP, though, and we do not apply the negotiated SDP. This change tweaks the code to use the actively negotiated stream topology if it is present with a fallback to the configured one. This results in the SDP and the state having matching information and the world is happy. ASTERISK*27397 Change-Id: I7a57117f0183479e6884b7bf3a53bb8c7464f604
2017-12-12chan_pjsip/res_pjsip: Add CHANNEL(pjsip,request_uri)Richard Mudgett
This patch does three things associated with the initial incoming INVITE request URI. 1) Add access to the full initial incoming INVITE request URI. 2) We were not setting DNID on incoming PJSIP channels. The DNID is the user portion of the initial incoming INVITE Request-URI. The value is accessed by reading CALLERID(dnid). 3) Fix CHANNEL(pjsip,target_uri) documentation. * The initial incoming INVITE request URI is now available using CHANNEL(pjsip,request_uri). * Set the DNID on PJSIP channel creation so CALLERID(dnid) can return the initial incoming INVITE request URI user portion. * CHANNEL(pjsip,target_uri) now correctly documents that the target URI is the contact URI. * Refactored print_escaped_uri() out of channel_read_pjsip() to handle pjsip_uri_print() error condition when the buffer is too small. ASTERISK-27478 Change-Id: I512e60d1f162395c946451becb37af3333337b33
2017-11-09Merge "res_pjsip_session: Fix multiple leaks." into 15Joshua Colp
2017-11-09Merge "res_pjsip_session: Check for errors from ↵Joshua Colp
ast_stream_topology_set_stream." into 15
2017-11-08AST-2017-011 - res_pjsip_session: session leak when a call is rejectedKevin Harwell
A previous commit made it so when an invite session transitioned into a disconnected state destruction of the Asterisk pjsip session object was postponed until either a transport error occurred or the event timer expired. However, if a call was rejected (for instance a 488) before the session was fully established the event timer may not have been initiated, or it was canceled without triggering either of the session finalizing states mentioned above. Really the only time destruction of the session should be delayed is when a BYE is being transacted. This is because it's possible in some cases for the session to be disconnected, but the BYE is still transacting. This patch makes it so the session object always gets released (no more memory leak) when the pjsip session is in a disconnected state. Except when the method is a BYE. Then it waits until a transport error occurs or an event timeout. ASTERISK-27345 #close Reported by: Corey Farrell Change-Id: I1e724737b758c20ac76d19d3611e3d2876ae10ed
2017-11-07res_pjsip_session: Fix multiple leaks.Corey Farrell
* Pre-initialize cloned media state vectors to final size to ensure vector errors cannot happen later in the clone initialization. * Release session_media on vector replace failure in ast_sip_session_media_state_add. * Release clone and media_state in ast_sip_session_refresh if we fail to append to the stream topology, return an error. Change-Id: Ib5ffc9b198683fa7e9bf166d74d30c1334c23acb
2017-11-07res_pjsip_session: Check for errors from ast_stream_topology_set_stream.Corey Farrell
Free memory and return error if ast_stream_topology_set_stream fails. Change-Id: I9f4dbf44bed627243d2f1dd8aea2eab6c38a028d
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-14res_pjsip_session: Rewrite o= with external_media_address.Alexander Traud
PJSIP allows a domain name as external_media_address. This allows chan_pjsip to be used behind a NAT with changing IP addresses. The IP address of that domain is resolved to the c= line already. This change sets also the o= line to that domain. ASTERISK-27341 #close Change-Id: I690163b6e762042ec38b3995aa5c9bea909d8ec4
2017-10-12res_pjsip_session: Prevent user=phone being added to anonimized URIs.Daniel Tryba
Move ast_sip_add_usereqphone to be called after anonymization of URIs, to prevent the user_eq_phone adding "user=phone" to URIs containing a username that is not a phonenumber (RFC3261 19.1.1). An extra call to ast_sip_add_usereqphone on the saved version before anonymization is added to add user=phone" to the PAI. ASTERISK-27047 #close Change-Id: Ie5644bc66341b86dc08b1f7442210de2e6acdec6
2017-10-09Merge "res_pjsip: Fix issues that prevented shutdown of modules." into 15Jenkins2
2017-10-07res_pjsip_session: Fix format_cap leak.Corey Farrell
ASTERISK-27306 Change-Id: I2c8d3fc148f9f53715c958314e1146f9611741f3
2017-10-05res_pjsip: Fix issues that prevented shutdown of modules.Corey Farrell
res_pjsip and res_pjsip_session had circular references, preventing both modules from shutting down. * Move session supplement registration to res_pjsip. * Use create internal functions for use by pjsip_message_filter.c. ASTERISK-27306 Change-Id: Ifbd5c19ec848010111afeab2436f9699da06ba6b
2017-09-28Merge "res_pjsip_session: outgoing call did not offer all configured codecs" ↵Jenkins2
into 15
2017-09-25Merge "res_pjsip_session: Reduce (and improve) SDP renegotiation." into 15Jenkins2
2017-09-25res_pjsip_session: outgoing call did not offer all configured codecsKevin Harwell
For some scenarios when an outgoing call was made only a subset of the configured codecs were offered. If the codecs being offered happened to not have a codec supported by the phone then the call would fail. For instance Alice and Bob both are configured in Asterisk for g722 and ulaw( allow=!all,g722,ulaw). Alice's endpoint however only supports g722 while Bob's only supports ulaw. When Alice calls Bob, Alice negotiates g722 fine with Asterisk. But when Asterisk sends the outgoing offer to Bob it only contains g722 and not both g722 and ulaw, so the call ends. This patch makes it so all the audio codecs configured on the endpoint always get sent, and not just a subset. However priority is given to those codecs that are compatible with the "other side". ASTERISK-27259 #close Change-Id: Iffabc373bd94cd1dc700925dcfe406e12918c696
2017-09-25Merge "res_pjsip_session: Don't end session when receiving a 500 on a ↵Joshua Colp
reinvite" into 15
2017-09-25Merge "res_pjsip: Use ast_sip_is_content_type() where appropriate" into 15Joshua Colp
2017-09-22res_pjsip_session: Reduce (and improve) SDP renegotiation.Joshua Colp
When pruning a request to change the topology of a channel be more intelligent about the resulting topology that is actually used for SDP renegotiation. In a case where a stream has not already been negotiated we don't need to renegotiate and offer a declined stream. This can occur if something in Asterisk (such as ConfBridge) requests to add video to a PJSIP channel that has no video codecs configured. In this case since the stream did not already exist we can safely remove the stream from the requested topology, resulting in no renegotiation occurring. In a case where a renegotiation is requested with a codec that is not supported we can reuse the formats of the existing stream if it exists to ensure that the stream continues to flow, instead of removing it. Change-Id: I636540798d55922377318fe619c510fb6ed125fb
2017-09-22res_pjsip_session: Don't end session when receiving a 500 on a reinviteKevin Harwell
During a reinvite, if a remote endpoint error occurs and it returns a 500 the session would end. This patch makes it so the session is not terminated, but continues as it was. The reason for this is because some endpoints may send non session terminating "server errors" like a failed codec negotiation. So in this case instead of ending the call it can hopefully continue. In the case of a real server error the session is already "doomed", will be known soon enough and appropriately ended by Asterisk later. Change-Id: Ifeedae86b8cb44b92d52c79046522ec5f0aff1d5
2017-09-22Merge "res_pjsip_session/BUNDLE: Handle no audio codecs on endpoint" into 15Joshua Colp
2017-09-22Merge "res_pjsip_session: Change some asserts to warning/debug messages" ↵Joshua Colp
into 15
2017-09-22res_pjsip: Use ast_sip_is_content_type() where appropriateSean Bright
Change-Id: If3ab0d73d79ac4623308bd48508af2bfd554937d
2017-09-22res_pjsip_session/BUNDLE: Handle no audio codecs on endpointGeorge Joseph
When an INVITE came in with both audio and video streams but there were no audio codecs defined for the endpoint, we weren't declining the audio stream. Since it's usually the first/transport stream, when the video stream was processed and tried to use the transport, it was empty and caused a crash. We now decline the the stream if there are no matching codecs so when the video stream is processed, it's now the first/transport stream and processes normally. Change-Id: Ic854eda54c95031e66b076ecfae3041d34daa692
2017-09-21Merge "bridge: Change participant SFU streams when source streams change." ↵Joshua Colp
into 15
2017-09-21Merge "res_pjsip_session: Check for removed stream state." into 15Joshua 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-21res_pjsip_session: Change some asserts to warning/debug messagesGeorge Joseph
There was an issue reported where an SDP received on a 183 Session Progress message caused a crash because the pending streams had already been processed when the OK was received. In that case the pending topology was legitimately NULL. There was an assert for an incorrect number of streams in the topology but not one for topology being NULL. In any case, if you're not in dev-mode the asserts don't do anything and since the scenario is legit, the asserts weren't appropriate anyway. * Changed several asserts to warning or debug messages and return codes as appropriate. ASTERISK-27264 Reported by: Daniel Heckl Change-Id: I58daaa9d2938fa980857ab3ec41925ab5ff9c848
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-07Merge "res_pjsip_session: Preserve stream name during renegotiation." into 15Jenkins2
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-09-05res_pjsip_session: Preserve stream name during renegotiation.Joshua Colp
Stream names within Asterisk can have meaning so when an externally initiated renegotiation occurs we need to preserve the name of the stream if it already exists. Change-Id: I29f50d0cc7f3238287d6d647777e76e1bdf8c596
2017-08-25res/res_pjsip_session: allow SDP answer to be regeneratedTorrey Searle
If an SDP answer hasn't been sent yet, it's legal to change it. This is required for PJSIP_DTMF_MODE to work correctly, and can also have use in the future for updating codecs too. ASTERISK-27209 #close Change-Id: Idbbfb7cb3f72fbd96c94d10d93540f69bd51e7a1
2017-08-22res_pjsip_session.c: Fix crash when declining an active stream.Richard Mudgett
If a previously active stream is declined we could crash because the channel's thread is still using the stream while we are updating the topology in the serializer thread. * Defer removing any declined stream's handler until we have blocked the channel's thread with the channel lock. ASTERISK-27212 Change-Id: I50e1d3ef26f8e41948f4c411ee329aa3b960a420
2017-08-09Merge "res_pjsip_session/_sdp_rtp: Handling of 'msid' is incorrect" into 15Joshua Colp
2017-08-08res_pjsip_session: Release media resources on session end quicker.Joshua Colp
A change was made long ago where the session was kept around until the underlying INVITE session had been destroyed. This had the side effect of also keeping the underlying media resources around for this time as well. This change ensures that when we are told to terminate the session we immediately release any media sessions associated with it. ASTERISK-27110 Change-Id: I643e431d5c3bf05cda220c1d39e824a505a29b82
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-01Revert "res_pjsip_session: Release media resources on session end quicker."George Joseph
This reverts commit 6c374d863c420d2519a52fffba3de5f935a30cdb. Change-Id: Ia89836005df66ef540885afd6f171886de0db442
2017-08-01res_pjsip_session: Release media resources on session end quicker.Joshua Colp
A change was made long ago where the session was kept around until the underlying INVITE session had been destroyed. This had the side effect of also keeping the underlying media resources around for this time as well. This change ensures that when we know the session is ending we release the media resources immediately. ASTERISK-27110 Change-Id: I3c6a82fe7d2c50b9dc9197cb12ef22f20d337501
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-26bridge_softmix / res_rtp_asterisk: Fix packet loss and renegotiation issues.Joshua Colp
This change does a few things to improve packet loss and renegotiation: 1. On outgoing RTP streams we will now properly reflect out of order packets and packet loss in the sequence number. This allows the remote jitterbuffer to better reorder things. 2. Video updates can now be discarded for a period of time after one has been sent to prevent flooding of clients. 3. For declined and removed streams we will now release any media session resources associated with them. This was not previously done and caused an issue where old state was being used for a new stream. 4. RTP bundling was not actually removing bundled RTP instances from the parent. This has been resolved by removing based on the RTP instance itself and not the SSRC. 5. The code did not properly handle explicitly unbundling an RTP instance from its parent. This now works as expected. ASTERISK-27143 Change-Id: Ibd91362f0e4990b6129638e712bc8adf0899fd45
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-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-15Merge "res_pjsip_refer/session: Calls dropped during transfer"Jenkins2
2017-06-14res_pjsip_session: Correct inverted test in session_outgoing_nat_hookGeorge Joseph
There was a typo introduced in commit 776ffd77 which was preventing the transport's external media address from being used. ASTERISK-27024 #close Reported-by: Christopher van de Sande patches: patch.diff submitted by Florian Floimair (license 6892) Change-Id: I7ec617171eaa2d86d2680b00cf37d5088adafc27
2017-06-13res_pjsip_refer/session: Calls dropped during transferKevin Harwell
When doing an attended transfer it's possible for the transferer, after receiving an accepted response from Asterisk, to send a BYE to Asterisk, which can then be processed before Asterisk has time to start and/or complete the transfer process. This of course causes the transfer to not complete successfully, thus dropping the call. This patch makes it so any BYEs received from the transferer, after the REFER, that initiate a session end are deferred until the transfer is complete. This allows the channel that would have otherwise been hung up by Asterisk to remain available throughout the transfer process. ASTERISK-27053 #close Change-Id: I43586db79079457d92d71f1fd993be9a3b409d5a