diff --git a/src/sip/sipcall.cpp b/src/sip/sipcall.cpp index 1012db1a88ee9167053e5ca62b13ac09c9db6906..ef5ad8f3d03bb764623662bbb0d54bba31ea6c87 100644 --- a/src/sip/sipcall.cpp +++ b/src/sip/sipcall.cpp @@ -151,7 +151,7 @@ SIPCall::SIPCall(const std::shared_ptr<SIPAccountBase>& account, "[call:%s] No media offered in the incoming invite. An offer will be provided in " "the answer", getCallId().c_str()); - mediaAttrList = getSIPAccount()->createDefaultMediaList(getSIPAccount()->isVideoEnabled(), + mediaAttrList = getSIPAccount()->createDefaultMediaList(false, getState() == CallState::HOLD); } else { JAMI_WARN("[call:%s] Creating an outgoing call with empty offer", getCallId().c_str()); @@ -2487,7 +2487,7 @@ SIPCall::onReceiveOffer(const pjmedia_sdp_session* offer, const pjsip_rx_data* r } void -SIPCall::onReceiveOfferIn200OK(const pjmedia_sdp_session* offer, pjsip_rx_data* rdata) +SIPCall::onReceiveOfferIn200OK(const pjmedia_sdp_session* offer) { if (not rtpStreams_.empty()) { JAMI_ERR("[call:%s] Unexpected offer in '200 OK' answer", getCallId().c_str()); @@ -2541,7 +2541,6 @@ SIPCall::onReceiveOfferIn200OK(const pjmedia_sdp_session* offer, pjsip_rx_data* sdp_->startNegotiation(); - pjsip_tx_data* tdata = nullptr; if (pjsip_inv_set_sdp_answer(inviteSession_.get(), sdp_->getLocalSdpSession()) != PJ_SUCCESS) { JAMI_ERR("[call:%s] Could not start media negotiation for a re-invite request", getCallId().c_str()); diff --git a/src/sip/sipcall.h b/src/sip/sipcall.h index fd16200ff403aab596c366347754060fd77e4346..2449d8b3b510c25364b8249e80d701bae0a496ad 100644 --- a/src/sip/sipcall.h +++ b/src/sip/sipcall.h @@ -206,7 +206,7 @@ public: const pjmedia_sdp_session* offer, const pjsip_rx_data* rdata); pj_status_t onReceiveReinvite(const pjmedia_sdp_session* offer, pjsip_rx_data* rdata); - void onReceiveOfferIn200OK(const pjmedia_sdp_session* offer, pjsip_rx_data* rdata); + void onReceiveOfferIn200OK(const pjmedia_sdp_session* offer); /** * Called when the media negotiation (SDP offer/answer) has * completed. @@ -394,8 +394,6 @@ private: // Vector holding the current RTP sessions. std::vector<RtpStream> rtpStreams_; - bool srtpEnabled_ {false}; - /** * Hold the transport used for SIP communication. * Will be different from the account registration transport for @@ -426,6 +424,7 @@ private: unsigned int localVideoPort_ {0}; bool enableIce_ {true}; + bool srtpEnabled_ {false}; ///< Transport used for media streams std::shared_ptr<IceTransport> mediaTransport_; diff --git a/src/sip/sipvoiplink.cpp b/src/sip/sipvoiplink.cpp index cd84971513015f0e29339850dd9619f093685986..0f41f7693404a8880e2d1ba83148836d514d9c62 100644 --- a/src/sip/sipvoiplink.cpp +++ b/src/sip/sipvoiplink.cpp @@ -1001,7 +1001,7 @@ on_rx_offer2(pjsip_inv_session* inv, struct pjsip_inv_on_rx_offer_cb_param* para if (auto call = getCallFromInvite(inv)) { if (auto const& account = call->getAccount().lock()) { - call->onReceiveOfferIn200OK(param->offer, const_cast<pjsip_rx_data*>(param->rdata)); + call->onReceiveOfferIn200OK(param->offer); } } } diff --git a/test/unitTest/sip_account/sip_empty_offer.cpp b/test/unitTest/sip_account/sip_empty_offer.cpp index 42274fe3a410f3e683c5231814abc98850205603..41f3265bc5161ee124342f2c81958aa6daf74fb4 100644 --- a/test/unitTest/sip_account/sip_empty_offer.cpp +++ b/test/unitTest/sip_account/sip_empty_offer.cpp @@ -83,12 +83,10 @@ public: private: // Test cases. - void audio_only_test(); - void audio_video_test(); + void send_and_handle_empty_offer(); CPPUNIT_TEST_SUITE(SipEmptyOfferTest); - CPPUNIT_TEST(audio_only_test); - CPPUNIT_TEST(audio_video_test); + CPPUNIT_TEST(send_and_handle_empty_offer); CPPUNIT_TEST_SUITE_END(); // Event/Signal handlers @@ -466,24 +464,18 @@ SipEmptyOfferTest::audio_video_call(std::vector<MediaAttribute> offer, { auto activeMediaList = Manager::instance().getMediaAttributeList(aliceData_.callId_); CPPUNIT_ASSERT_EQUAL(answer.size(), activeMediaList.size()); - // Audio + CPPUNIT_ASSERT_EQUAL(MediaType::MEDIA_AUDIO, activeMediaList[0].type_); CPPUNIT_ASSERT_EQUAL(answer[0].enabled_, activeMediaList[0].enabled_); - // Video - CPPUNIT_ASSERT_EQUAL(MediaType::MEDIA_VIDEO, activeMediaList[1].type_); - CPPUNIT_ASSERT_EQUAL(answer[1].enabled_, activeMediaList[1].enabled_); } // Validate Bob's media { auto activeMediaList = Manager::instance().getMediaAttributeList(bobData_.callId_); CPPUNIT_ASSERT_EQUAL(offer.size(), activeMediaList.size()); - // Audio + CPPUNIT_ASSERT_EQUAL(MediaType::MEDIA_AUDIO, activeMediaList[0].type_); CPPUNIT_ASSERT_EQUAL(offer[0].enabled_, activeMediaList[0].enabled_); - // Video - CPPUNIT_ASSERT_EQUAL(MediaType::MEDIA_VIDEO, activeMediaList[1].type_); - CPPUNIT_ASSERT_EQUAL(offer[1].enabled_, activeMediaList[1].enabled_); } // Give some time to media to start and flow @@ -500,47 +492,13 @@ SipEmptyOfferTest::audio_video_call(std::vector<MediaAttribute> offer, } void -SipEmptyOfferTest::audio_only_test() +SipEmptyOfferTest::send_and_handle_empty_offer() { - // Test with video enabled on Bob's side and disabled - // on Alice's side. - - auto const aliceAcc = Manager::instance().getAccount<SIPAccount>(aliceData_.accountId_); - auto const bobAcc = Manager::instance().getAccount<SIPAccount>(bobData_.accountId_); - - std::vector<MediaAttribute> offer; - - MediaAttribute audio(MediaType::MEDIA_AUDIO); - audio.enabled_ = true; - audio.label_ = "audio_0"; - audio.secure_ = bobAcc->isSrtpEnabled(); - offer.emplace_back(audio); - - MediaAttribute video(MediaType::MEDIA_VIDEO); - video.enabled_ = true; - video.label_ = "video_0"; - video.secure_ = bobAcc->isSrtpEnabled(); - bobAcc->enableVideo(true); - offer.emplace_back(video); + // Current implementation, when an empty offer is received, the + // local UA will provide a media offer (SDP) in "200 OK" answer + // that includes audio media only. Each call participant can add + // the video is he/she wishes. - std::vector<MediaAttribute> answer; - audio.enabled_ = true; - audio.label_ = "audio_0"; - audio.secure_ = bobAcc->isSrtpEnabled(); - answer.emplace_back(audio); - - video.enabled_ = false; - video.label_ = "video_0"; - video.secure_ = aliceAcc->isSrtpEnabled(); - aliceAcc->enableVideo(false); - answer.emplace_back(video); - - audio_video_call(offer, answer); -} - -void -SipEmptyOfferTest::audio_video_test() -{ auto const aliceAcc = Manager::instance().getAccount<SIPAccount>(aliceData_.accountId_); auto const bobAcc = Manager::instance().getAccount<SIPAccount>(bobData_.accountId_); @@ -552,25 +510,12 @@ SipEmptyOfferTest::audio_video_test() audio.secure_ = bobAcc->isSrtpEnabled(); offer.emplace_back(audio); - MediaAttribute video(MediaType::MEDIA_VIDEO); - video.enabled_ = true; - video.label_ = "video_0"; - video.secure_ = bobAcc->isSrtpEnabled(); - bobAcc->enableVideo(true); - offer.emplace_back(video); - std::vector<MediaAttribute> answer; audio.enabled_ = true; audio.label_ = "audio_0"; audio.secure_ = bobAcc->isSrtpEnabled(); answer.emplace_back(audio); - video.enabled_ = true; - video.label_ = "video_0"; - video.secure_ = aliceAcc->isSrtpEnabled(); - aliceAcc->enableVideo(true); - answer.emplace_back(video); - audio_video_call(offer, answer); }