summaryrefslogtreecommitdiff
path: root/res/res_pjsip_session.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2017-09-25 15:35:11 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2017-09-25 15:35:11 -0500
commit87c4a72f16aba71ffcdffec9454b99ddab8023da (patch)
tree9c2479f6ebcaa11dab2144f9ba08b4b5b6c07bd2 /res/res_pjsip_session.c
parent0133d29c8300376229e3a7e9b9b05e2daa705809 (diff)
parent601e0c563fb9c936bf20da7b2cd746e21022e405 (diff)
Merge "res_pjsip_session: Reduce (and improve) SDP renegotiation."
Diffstat (limited to 'res/res_pjsip_session.c')
-rw-r--r--res/res_pjsip_session.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index 76dafb378..9636583d2 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -1482,8 +1482,15 @@ int ast_sip_session_refresh(struct ast_sip_session *session,
* are configurable on the endpoint.
*/
for (index = 0; index < ast_stream_topology_get_count(media_state->topology); ++index) {
+ struct ast_stream *existing_stream = NULL;
+
stream = ast_stream_topology_get_stream(media_state->topology, index);
+ if (session->active_media_state->topology &&
+ index < ast_stream_topology_get_count(session->active_media_state->topology)) {
+ existing_stream = ast_stream_topology_get_stream(session->active_media_state->topology, index);
+ }
+
if (is_stream_limitation_reached(ast_stream_get_type(stream), session->endpoint, type_streams)) {
if (index < AST_VECTOR_SIZE(&media_state->sessions)) {
struct ast_sip_session_media *session_media = AST_VECTOR_GET(&media_state->sessions, index);
@@ -1516,8 +1523,28 @@ int ast_sip_session_refresh(struct ast_sip_session *session,
ast_format_cap_get_compatible(ast_stream_get_formats(stream), session->endpoint->media.codecs, joint_cap);
if (!ast_format_cap_count(joint_cap)) {
ao2_ref(joint_cap, -1);
- ast_stream_set_state(stream, AST_STREAM_STATE_REMOVED);
- continue;
+
+ if (!existing_stream) {
+ /* If there is no existing stream we can just not have this stream in the topology
+ * at all.
+ */
+ ast_stream_topology_del_stream(media_state->topology, index);
+ index -= 1;
+ continue;
+ } else if (ast_stream_get_state(stream) != ast_stream_get_state(existing_stream) ||
+ strcmp(ast_stream_get_name(stream), ast_stream_get_name(existing_stream))) {
+ /* If the underlying stream is a different type or different name then we have to
+ * mark it as removed, as it is replacing an existing stream. We do this so order
+ * is preserved.
+ */
+ ast_stream_set_state(stream, AST_STREAM_STATE_REMOVED);
+ continue;
+ } else {
+ /* However if the stream is otherwise remaining the same we can keep the formats
+ * that exist on it already which allows media to continue to flow.
+ */
+ joint_cap = ao2_bump(ast_stream_get_formats(existing_stream));
+ }
}
ast_stream_set_formats(stream, joint_cap);
}