summaryrefslogtreecommitdiff
path: root/res/res_pjsip_session.c
AgeCommit message (Collapse)Author
2018-03-06res_pjsip_session: properly handle SDP from a forked call with early medialvl
In handle_negotiated_sdp(), use session->active_media_state when session->pending_media_state is empty. The 200's SDP should be fed into handle_negotiated_sdp_session_media() together with the already negotiated state, which is now in session->active_media_state instead. Only if both the session's pending and active media are empty should handle_negotiated_sdp() abort. ASTERISK-27441 Change-Id: If0d5150ffe6f38d8a854831fef37942258d4629c
2018-02-21AST-2018-005: Fix tdata leaks when calling pjsip_endpt_send_response(2)George Joseph
pjsip_distributor: authenticate() creates a tdata and uses it to send a challenge or failure response. When pjsip_endpt_send_response2() succeeds, it automatically decrements the tdata ref count but when it fails, it doesn't. Since we weren't checking for a return status, we weren't decrementing the count ourselves on error and were therefore leaking tdatas. res_pjsip_session: session_reinvite_on_rx_request wasn't decrementing the ref count if an error happened while sending a 491 response. pre_session_setup wasn't decrementing the ref count if while sending an error after a pjsip_inv_verify_request failure. res_pjsip: ast_sip_send_response wasn't decrementing the ref count on error. ASTERISK-27618 Reported By: Sandro Gauci Change-Id: Iab33a6c7b6fba96148ed465b690ba8534ac961bf
2018-01-30res_pjsip_session: Prevent crash during shutdown.Corey Farrell
pjproject does not have a function to reverse pjsip_inv_usage_init. This means we need to ignore any calls to the functions once shutdown is final. ASTERISK-27571 #close Change-Id: Ia550fcba563e2328f03162d79fb185f16b7c9b9d
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
2018-01-09res_pjsip_session: Always bundle streams if WebRTC is enabled.Joshua Colp
Some WebRTC clients can't handle renegotiation with the addition of streams that include an offer to bundle. They instead expect the newly added streams to already be bundled. This change does such a thing if WebRTC support is enabled on an endpoint. ASTERISK-27566 Change-Id: I7fe9b7ac35a2798627d9c2c8369129f407af6461
2018-01-03res_pjsip_session: Check if sequence header is missingKevin Harwell
The pjsip_msg_find_hdr function can return NULL. This patch adds a check when searching for the sequence header to make sure a NULL pointer is never de-referenced. Change-Id: I19af23aeeded65be016be92360e8cb7ffe51fad2
2017-12-20Fix Common Typo's.Corey Farrell
Fix instances of: * Retreive * Recieve * other then * different then * Repeated words ("the the", "an an", "and and", etc). * othterwise, teh ASTERISK-24198 #close Change-Id: I3809a9c113b92fd9d0d9f9bac98e9c66dc8b2d31
2017-12-14Merge "res_pjsip_session: Reinvite using active stream topology if none ↵Jenkins2
requested."
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."Joshua Colp
2017-11-09Merge "res_pjsip_session: Check for errors from ast_stream_topology_set_stream."Joshua Colp
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."Jenkins2
2017-10-07res_pjsip_session: Fix format_cap leak.Corey Farrell
ASTERISK-27306 Change-Id: I2c8d3fc148f9f53715c958314e1146f9611741f3
2017-10-04res_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"Joshua Colp
2017-09-25Merge "res_pjsip_session: Reduce (and improve) SDP renegotiation."Joshua Colp
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 reinvite"Joshua Colp
2017-09-25Merge "res_pjsip: Use ast_sip_is_content_type() where appropriate"Joshua 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"Joshua Colp
2017-09-22Merge "res_pjsip_session: Change some asserts to warning/debug messages"Joshua Colp
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
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."Jenkins2
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"Jenkins2
2017-08-07res_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-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-19bridge_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