...
 
Commits (8)
......@@ -476,9 +476,19 @@ char * sal_media_description_print_differences(int result){
}
int sal_media_description_equals(const SalMediaDescription *md1, const SalMediaDescription *md2) {
int result = SAL_MEDIA_DESCRIPTION_UNCHANGED;
int result = sal_media_description_global_equals(md1, md2);
int i;
for(i = 0; i < SAL_MEDIA_DESCRIPTION_MAX_STREAMS; ++i){
if (!sal_stream_description_active(&md1->streams[i]) && !sal_stream_description_active(&md2->streams[i])) continue;
result |= sal_stream_description_equals(&md1->streams[i], &md2->streams[i]);
}
return result;
}
int sal_media_description_global_equals(const SalMediaDescription *md1, const SalMediaDescription *md2) {
int result = SAL_MEDIA_DESCRIPTION_UNCHANGED;
if (strcmp(md1->addr, md2->addr) != 0) result |= SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED;
if (md1->addr[0]!='\0' && md2->addr[0]!='\0' && ms_is_multicast(md1->addr) != ms_is_multicast(md2->addr))
result |= SAL_MEDIA_DESCRIPTION_NETWORK_XXXCAST_CHANGED;
......@@ -489,10 +499,6 @@ int sal_media_description_equals(const SalMediaDescription *md1, const SalMediaD
if (strcmp(md1->ice_ufrag, md2->ice_ufrag) != 0 && md2->ice_ufrag[0] != '\0') result |= SAL_MEDIA_DESCRIPTION_ICE_RESTART_DETECTED;
if (strcmp(md1->ice_pwd, md2->ice_pwd) != 0 && md2->ice_pwd[0] != '\0') result |= SAL_MEDIA_DESCRIPTION_ICE_RESTART_DETECTED;
for(i = 0; i < SAL_MEDIA_DESCRIPTION_MAX_STREAMS; ++i){
if (!sal_stream_description_active(&md1->streams[i]) && !sal_stream_description_active(&md2->streams[i])) continue;
result |= sal_stream_description_equals(&md1->streams[i], &md2->streams[i]);
}
return result;
}
......
......@@ -338,6 +338,7 @@ SalMediaDescription * sal_media_description_ref(SalMediaDescription *md);
void sal_media_description_unref(SalMediaDescription *md);
bool_t sal_media_description_empty(const SalMediaDescription *md);
int sal_media_description_equals(const SalMediaDescription *md1, const SalMediaDescription *md2);
int sal_media_description_global_equals(const SalMediaDescription *md1, const SalMediaDescription *md2);
char * sal_media_description_print_differences(int result);
bool_t sal_media_description_has_dir(const SalMediaDescription *md, SalStreamDir dir);
LINPHONE_PUBLIC SalStreamDescription *sal_media_description_find_stream(SalMediaDescription *md, SalMediaProto proto, SalStreamType type);
......@@ -346,6 +347,7 @@ SalStreamDescription * sal_media_description_get_active_stream_of_type(SalMediaD
SalStreamDescription * sal_media_description_find_secure_stream_of_type(SalMediaDescription *md, SalStreamType type);
SalStreamDescription * sal_media_description_find_best_stream(SalMediaDescription *md, SalStreamType type);
void sal_media_description_set_dir(SalMediaDescription *md, SalStreamDir stream_dir);
int sal_stream_description_equals(const SalStreamDescription *sd1, const SalStreamDescription *sd2);
bool_t sal_stream_description_active(const SalStreamDescription *sd);
bool_t sal_stream_description_has_avpf(const SalStreamDescription *sd);
bool_t sal_stream_description_has_implicit_avpf(const SalStreamDescription *sd);
......
......@@ -42,7 +42,9 @@ Imdn::Imdn (ChatRoom *chatRoom) : chatRoom(chatRoom) {
Imdn::~Imdn () {
stopTimer();
chatRoom->getCore()->getPrivate()->unregisterListener(this);
try { //getCore may no longuer be available when deleting, specially in case of managed enviroment like java
chatRoom->getCore()->getPrivate()->unregisterListener(this);
} catch (const bad_weak_ptr &) {}
}
// -----------------------------------------------------------------------------
......@@ -208,8 +210,12 @@ bool Imdn::aggregationEnabled () const {
}
void Imdn::send () {
if (!linphone_core_is_network_reachable(chatRoom->getCore()->getCCore()))
return;
try {
if (!linphone_core_is_network_reachable(chatRoom->getCore()->getCCore()))
return;
} catch (const bad_weak_ptr &) {
return; // Cannot send imdn if core is destroyed.
}
if (!deliveredMessages.empty() || !displayedMessages.empty()) {
auto imdnMessage = chatRoom->getPrivate()->createImdnMessage(deliveredMessages, displayedMessages);
......
......@@ -883,7 +883,9 @@ CallSession::CallSession (CallSessionPrivate &p, const shared_ptr<Core> &core) :
CallSession::~CallSession () {
L_D();
getCore()->getPrivate()->unregisterListener(d);
try { //getCore may no longuer be available when deleting, specially in case of managed enviroment like java
getCore()->getPrivate()->unregisterListener(d);
} catch (const bad_weak_ptr &) {}
if (d->currentParams)
delete d->currentParams;
if (d->params)
......
......@@ -20,6 +20,9 @@
#ifndef _L_MEDIA_SESSION_P_H_
#define _L_MEDIA_SESSION_P_H_
#include <vector>
#include <functional>
#include "call-session-p.h"
#include "media-session.h"
......@@ -94,6 +97,8 @@ public:
void initializeStreams ();
void stopStreams ();
void stopStream (SalStreamDescription *streamDesc);
void restartStream (SalStreamDescription *streamDesc, int streamIndex, int sdChanged, CallSession::State targetState);
// Methods used by testers
void addLocalDescChangedFlag (int flag) { localDescChanged |= flag; }
......@@ -169,15 +174,21 @@ private:
SalMulticastRole getMulticastRole (SalStreamType type);
void joinMulticastGroup (int streamIndex, MediaStream *ms);
int findCryptoIndexFromTag (const SalSrtpCryptoAlgo crypto[], unsigned char tag);
void setDtlsFingerprint (MSMediaStreamSessions *sessions, const SalStreamDescription *sd, const SalStreamDescription *remote);
void setDtlsFingerprintOnAllStreams ();
void setDtlsFingerprintOnAudioStream ();
void setDtlsFingerprintOnVideoStream ();
void setDtlsFingerprintOnTextStream ();
void setupDtlsParams (MediaStream *ms);
void setZrtpCryptoTypesParameters (MSZrtpParams *params);
void startDtls (MSMediaStreamSessions *sessions, const SalStreamDescription *sd, const SalStreamDescription *remote);
void startDtlsOnAllStreams ();
void updateCryptoParameters (SalMediaDescription *oldMd, SalMediaDescription *newMd);
bool updateStreamCryptoParameters (const SalStreamDescription *localStreamDesc, SalStreamDescription *oldStream, SalStreamDescription *newStream, MediaStream *ms);
void startDtlsOnAudioStream ();
void startDtlsOnTextStream ();
void startDtlsOnVideoStream ();
void updateStreamCryptoParameters (SalStreamDescription *oldStream, SalStreamDescription *newStream);
void updateStreamsCryptoParameters (SalMediaDescription *oldMd, SalMediaDescription *newMd);
bool updateCryptoParameters (const SalStreamDescription *localStreamDesc, SalStreamDescription *oldStream, SalStreamDescription *newStream, MediaStream *ms);
int getIdealAudioBandwidth (const SalMediaDescription *md, const SalStreamDescription *desc);
int getVideoBandwidth (const SalMediaDescription *md, const SalStreamDescription *desc);
......@@ -202,17 +213,24 @@ private:
void prepareEarlyMediaForking ();
void postConfigureAudioStreams (bool muted);
void setSymmetricRtp (bool value);
void setStreamSymmetricRtp(bool value, int streamIndex);
void setupRingbackPlayer ();
void startAudioStream (CallSession::State targetState, bool videoWillBeUsed);
void startAudioStream (CallSession::State targetState);
void startStreams (CallSession::State targetState);
void startStream (SalStreamDescription *streamDesc, int streamIndex, CallSession::State targetState);
void startTextStream ();
void startVideoStream (CallSession::State targetState);
void stopAudioStream ();
void stopTextStream ();
void stopVideoStream ();
void tryEarlyMediaForking (SalMediaDescription *md);
void updateStreamFrozenPayloads (SalStreamDescription *resultDesc, SalStreamDescription *localStreamDesc);
void updateFrozenPayloads (SalMediaDescription *result);
void updateAudioStream (SalMediaDescription *newMd, CallSession::State targetState);
void updateStreams (SalMediaDescription *newMd, CallSession::State targetState);
void updateTextStream (SalMediaDescription *newMd, CallSession::State targetState);
void updateVideoStream (SalMediaDescription *newMd, CallSession::State targetState);
void updateStreamDestination (SalMediaDescription *newMd, SalStreamDescription *newDesc);
void updateStreamsDestinations (SalMediaDescription *oldMd, SalMediaDescription *newMd);
bool allStreamsAvpfEnabled () const;
......@@ -291,6 +309,8 @@ private:
std::unique_ptr<StunClient> stunClient;
std::unique_ptr<IceAgent> iceAgent;
std::vector<std::function<void()>> postProcessHooks;
// The address family to prefer for RTP path, guessed from signaling path.
int af;
......@@ -316,7 +336,12 @@ private:
bool authTokenVerified = false;
std::string dtlsCertificateFingerprint;
bool forceStreamsReconstruction = false;
unsigned int mediaStartCount = 0;
unsigned int audioStartCount = 0;
unsigned int videoStartCount = 0;
unsigned int textStartCount = 0;
// Upload bandwidth setting at the time the call is started. Used to detect if it changes during a call.
int upBandwidth = 0;
......@@ -324,8 +349,11 @@ private:
// Upload bandwidth used by audio.
int audioBandwidth = 0;
bool allMuted = false;
bool speakerMuted = false;
bool microphoneMuted = false;
bool audioMuted = false;
bool videoMuted = false;
bool automaticallyPaused = false;
bool pausedByApp = false;
bool recordActive = false;
......
This diff is collapsed.
......@@ -339,9 +339,13 @@ void SalCallOp::sdpProcess(){
strcpy(mResult->streams[i].rtcp_addr,mRemoteMedia->streams[i].rtcp_addr);
mResult->streams[i].rtcp_port=mRemoteMedia->streams[i].rtcp_port;
if (sal_stream_description_has_srtp(&mResult->streams[i])) {
mResult->streams[i].crypto[0] = mRemoteMedia->streams[i].crypto[0];
}
if (sal_stream_description_has_srtp(&mResult->streams[i])) {
int cryptoIdx = Sal::findCryptoIndexFromTag( mRemoteMedia->streams[i].crypto, static_cast<unsigned char>(mResult->streams[i].crypto[0].tag));
if (cryptoIdx >= 0)
mResult->streams[i].crypto[0] = mRemoteMedia->streams[i].crypto[cryptoIdx];
else
lError() << "Failed to find crypto algo with tag: " << mResult->streams[i].crypto_local_tag << "from resulting description [" << mResult << "]";
}
}
}
}
......
......@@ -823,6 +823,13 @@ belle_sip_response_t* Sal::createResponseFromRequest (belle_sip_request_t* req,
return resp;
}
int Sal::findCryptoIndexFromTag (const SalSrtpCryptoAlgo crypto[], unsigned char tag) {
for (int i = 0; i < SAL_CRYPTO_ALGO_MAX; i++) {
if (crypto[i].tag == tag)
return i;
}
return -1;
}
......
......@@ -253,6 +253,8 @@ public:
belle_sip_source_t *createTimer (belle_sip_source_func_t func, void *data, unsigned int timeoutValueMs, const std::string &timerName);
void cancelTimer (belle_sip_source_t *timer);
//utils
static int findCryptoIndexFromTag (const SalSrtpCryptoAlgo crypto[], unsigned char tag);
private:
struct SalUuid {
......
......@@ -2665,6 +2665,13 @@ static void srtp_call(void) {
call_base(LinphoneMediaEncryptionSRTP,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE);
}
/*
*Purpose of this test is to check that even if caller and callee does not have exactly the same crypto suite configured, the matching crypto suite is used.
*/
static void srtp_call_with_different_crypto_suite(void) {
call_base_with_configfile(LinphoneMediaEncryptionSRTP,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE, "laure_tcp_rc", "marie_rc");
}
static void zrtp_call(void) {
call_base(LinphoneMediaEncryptionZRTP,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE);
}
......@@ -6542,6 +6549,7 @@ test_t call_tests[] = {
TEST_NO_TAG("Call paused resumed with loss", call_paused_resumed_with_loss),
TEST_NO_TAG("Call paused resumed from callee", call_paused_resumed_from_callee),
TEST_NO_TAG("SRTP call", srtp_call),
TEST_NO_TAG("SRTP call with different crypto suite", srtp_call_with_different_crypto_suite),
TEST_NO_TAG("ZRTP call", zrtp_call),
TEST_NO_TAG("ZRTP silent call", zrtp_silent_call),
TEST_NO_TAG("ZRTP SAS call", zrtp_sas_call),
......
......@@ -4,6 +4,7 @@ sip_tcp_port=-1
sip_tls_port=-1
default_proxy=0
ping_with_options=0
srtp_crypto_suites=AES_256_CM_HMAC_SHA1_80
[auth_info_0]
username=laure
......