From ca159350b8bdaa9147518d581485e26ffe46f8e5 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 27 Nov 2017 16:02:30 +0100 Subject: [PATCH] Some more fixes for call handling. --- src/conference/session/media-session.cpp | 10 ++++------ src/content/content-type.cpp | 5 +++++ src/content/content-type.h | 1 + src/content/content.cpp | 2 +- src/sal/call-op.cpp | 9 ++++++--- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/conference/session/media-session.cpp b/src/conference/session/media-session.cpp index 806dd4297..51f1225d2 100644 --- a/src/conference/session/media-session.cpp +++ b/src/conference/session/media-session.cpp @@ -3143,19 +3143,17 @@ void MediaSessionPrivate::updateStreams (SalMediaDescription *newMd, LinphoneCal ms_message("Playing ringback tone, will restart the streams."); #endif else { -#if 0 - if (call->all_muted && (targetState == LinphoneCallStreamsRunning)) { + if (allMuted && (targetState == LinphoneCallStreamsRunning)) { lInfo() << "Early media finished, unmuting inputs..."; /* We were in early media, now we want to enable real media */ - call->all_muted = FALSE; + allMuted = false; if (audioStream) linphone_core_enable_mic(core, linphone_core_mic_enabled(core)); #ifdef VIDEO_ENABLED if (videoStream && cameraEnabled) - linphone_call_enable_camera(call, linphone_call_camera_enabled(call)); + q->enableCamera(q->cameraEnabled()); #endif } -#endif if (mdChanged == SAL_MEDIA_DESCRIPTION_UNCHANGED) { /* FIXME ZRTP, might be restarted in any cases? */ lInfo() << "No need to restart streams, SDP is unchanged"; @@ -4201,11 +4199,11 @@ LinphoneStatus MediaSession::resume () { if (d->audioStream) audio_stream_play(d->audioStream, nullptr); d->makeLocalMediaDescription(); + sal_media_description_set_dir(d->localDesc, SalStreamSendRecv); if (!d->core->sip_conf.sdp_200_ack) d->op->set_local_media_description(d->localDesc); else d->op->set_local_media_description(nullptr); - sal_media_description_set_dir(d->localDesc, SalStreamSendRecv); string subject = "Call resuming"; if (d->params->getPrivate()->getInConference() && !getCurrentParams()->getPrivate()->getInConference()) subject = "Conference"; diff --git a/src/content/content-type.cpp b/src/content/content-type.cpp index 7245bf36f..b0851de71 100644 --- a/src/content/content-type.cpp +++ b/src/content/content-type.cpp @@ -151,6 +151,11 @@ void ContentType::setParameter (const string ¶meter) { d->parameter = parameter; } +bool ContentType::isEmpty () const { + L_D(); + return d->type.empty() && d->subType.empty(); +} + bool ContentType::isValid () const { L_D(); return !d->type.empty() && !d->subType.empty(); diff --git a/src/content/content-type.h b/src/content/content-type.h index 6969ce843..8da5f1cb5 100644 --- a/src/content/content-type.h +++ b/src/content/content-type.h @@ -45,6 +45,7 @@ public: bool operator== (const std::string &contentType) const = delete; bool operator!= (const std::string &contentType) const = delete; + bool isEmpty () const; bool isValid () const; bool isFile () const; diff --git a/src/content/content.cpp b/src/content/content.cpp index 68d86e9fd..8b309431d 100644 --- a/src/content/content.cpp +++ b/src/content/content.cpp @@ -153,7 +153,7 @@ bool Content::isEmpty () const { bool Content::isValid () const { L_D(); - return d->contentType.isValid() || d->body.empty(); + return d->contentType.isValid() || (d->contentType.isEmpty() && d->body.empty()); } LinphoneContent *Content::toLinphoneContent () const { diff --git a/src/sal/call-op.cpp b/src/sal/call-op.cpp index bd6d4ba16..bd269be58 100644 --- a/src/sal/call-op.cpp +++ b/src/sal/call-op.cpp @@ -255,7 +255,10 @@ int SalCallOp::parse_sdp_body(const Content &body,belle_sdp_session_description_ return 0; } - *session_desc = belle_sdp_session_description_parse(body.getBodyAsString().c_str()); + string strBody = body.getBodyAsString(); + if (strBody.empty()) + return 0; + *session_desc = belle_sdp_session_description_parse(strBody.c_str()); if (*session_desc == NULL) { ms_error("Failed to parse SDP message."); *error = SalReasonNotAcceptable; @@ -330,7 +333,7 @@ void SalCallOp::sdp_process(){ void SalCallOp::handle_body_from_response(belle_sip_response_t* response) { SalReason reason; - belle_sdp_session_description_t* sdp; + belle_sdp_session_description_t* sdp = nullptr; Content body = extract_body(BELLE_SIP_MESSAGE(response)); if (this->remote_media){ sal_media_description_unref(this->remote_media); @@ -568,7 +571,7 @@ SalReason SalCallOp::process_body_for_invite(belle_sip_request_t* invite) { Content body = extract_body(BELLE_SIP_MESSAGE(invite)); if (!body.isValid()) return SalReasonUnsupportedContent; - if (body.getContentType() == ContentType::Sdp) { + if ((body.getContentType() == ContentType::Sdp) || (body.getContentType().isEmpty() && body.isEmpty())) { belle_sdp_session_description_t* sdp; if (parse_sdp_body(body, &sdp, &reason) == 0) { if (sdp) {