Commit 95d56c15 authored by Matthieu Tanon's avatar Matthieu Tanon

Merge branch 'dev_lime_v2'

parents b8e6db79 bf1642fb
......@@ -131,7 +131,8 @@ typedef struct _MSSndCard MSSndCard;
enum _MSSndCardStreamType{
MS_SND_CARD_STREAM_VOICE,
MS_SND_CARD_STREAM_RING
MS_SND_CARD_STREAM_RING,
MS_SND_CARD_STREAM_MEDIA
};
/**
......
......@@ -22,6 +22,7 @@
#include <ortp/rtpsession.h>
#include "mediastreamer2/mscommon.h"
#include <bctoolbox/port.h>
#ifdef __cplusplus
extern "C"{
......@@ -90,8 +91,15 @@ typedef enum _MSZrtpSasType{
MS_ZRTP_SAS_B256
} MSZrtpSasType;
typedef enum _MSZrtpPeerStatus{
MS_ZRTP_PEER_STATUS_UNKNOWN,
MS_ZRTP_PEER_STATUS_INVALID,
MS_ZRTP_PEER_STATUS_VALID
} MSZrtpPeerStatus;
typedef struct MSZrtpParams {
void *zidCacheDB; /**< a pointer to an sqlite database holding all zrtp related information */
bctbx_mutex_t *zidCacheDBMutex; /**< pointer to a mutex used to lock cache access */
const char *selfUri; /* our sip URI, needed for zrtp Cache */
const char *peerUri; /* the sip URI of correspondant, needed for zrtp Cache */
uint32_t limeKeyTimeSpan; /**< amount in seconds of the lime key life span, set to 0 for infinite life span **/
......@@ -113,7 +121,7 @@ typedef struct _MSZrtpContext MSZrtpContext ;
/**
* check if ZRTP is available
* @return TRUE if it is available, FALSE if not
* @return TRUE if it is available, FALSE if not
*/
MS2_PUBLIC bool_t ms_zrtp_available(void);
......@@ -133,10 +141,10 @@ MS2_PUBLIC MSZrtpContext* ms_zrtp_context_new(struct _MSMediaStreamSessions *str
*/
MS2_PUBLIC MSZrtpContext* ms_zrtp_multistream_new(struct _MSMediaStreamSessions *stream_sessions, MSZrtpContext* activeContext);
/***
/**
* Start a previously created ZRTP channel, ZRTP engine will start sending Hello packets
* @param[in] ctx Context previously created using ms_zrtp_context_new or ms_zrtp_multistream_new
* @return 0 on success
* @return 0 on success
*/
MS2_PUBLIC int ms_zrtp_channel_start(MSZrtpContext *ctx);
......@@ -148,7 +156,7 @@ MS2_PUBLIC int ms_zrtp_channel_start(MSZrtpContext *ctx);
MS2_PUBLIC void ms_zrtp_context_destroy(MSZrtpContext *ctx);
/**
* can be used to give more time for establishing zrtp session
* Can be used to give more time for establishing zrtp session
* @param[in] ctx The MSZRTP context
* */
MS2_PUBLIC void ms_zrtp_reset_transmition_timer(MSZrtpContext* ctx);
......@@ -165,6 +173,20 @@ MS2_PUBLIC void ms_zrtp_sas_verified(MSZrtpContext* ctx);
*/
MS2_PUBLIC void ms_zrtp_sas_reset_verified(MSZrtpContext* ctx);
/**
* Get the zrtp sas validation status for a peer uri.
* Once the SAS has been validated or rejected, the status will never return to UNKNOWN (unless you delete your cache)
* @param[in/out] db Pointer to the sqlite3 db open connection
* Use a void * to keep this API when building cacheless
* @param[in] peerUri the sip uri of the peer device we're querying status
* @param[in] dbMutex a mutex to synchronise zrtp cache database operation. Ignored if NULL
*
* @return - MS_ZRTP_PEER_STATUS_UNKNOWN: this uri is not present in cache OR during calls with the active device, SAS never was validated or rejected
* - MS_ZRTP_PEER_STATUS_INVALID: the active device status is set to valid
* - MS_ZRTP_PEER_STATUS_VALID: the active peer device status is set to invalid
*/
MS2_PUBLIC MSZrtpPeerStatus ms_zrtp_get_peer_status(void *db, const char *peerUri, bctbx_mutex_t *dbMutex);
/**
* Get the ZRTP Hello Hash from the given context
* @param[in] ctx MSZRTP context
......@@ -172,13 +194,28 @@ MS2_PUBLIC void ms_zrtp_sas_reset_verified(MSZrtpContext* ctx);
*/
MS2_PUBLIC int ms_zrtp_getHelloHash(MSZrtpContext* ctx, uint8_t *output, size_t outputLength);
/**
* Set the optional ZRTP auxiliary shared secret
* @param[in] ctx MSZRTP context
* @param[in] The ZRTP auxiliary shared secret
* @param[in] The size of the auxiliary shared secret
* @return 0 on success, error code otherwise
*/
MS2_PUBLIC int ms_zrtp_setAuxiliarySharedSecret(MSZrtpContext *ctx, const uint8_t *auxSharedSecret, size_t auxSharedSecretLength);
/**
* Get the ZRTP auxiliary shared secret mismatch status
* @param[in] ctx MSZRTP context
* @return 0 on match, 1 otherwise
*/
MS2_PUBLIC uint8_t ms_zrtp_getAuxiliarySharedSecretMismatch(MSZrtpContext *ctx);
/**
* Set the peer ZRTP Hello Hash to the given context
* @param[in] ctx MSZRTP context
* @param[in] The Zrtp Hello Hash as defined in RFC6189 section 8
* @param[in] The Zrtp Hello Hash length
*
* @return 0 on succes, Error code otherwise
* @return 0 on success, error code otherwise
*/
MS2_PUBLIC int ms_zrtp_setPeerHelloHash(MSZrtpContext *ctx, uint8_t *peerHelloHashHexString, size_t peerHelloHashHexStringLength);
......@@ -202,10 +239,11 @@ MS2_PUBLIC const char* ms_zrtp_sas_type_to_string(const MSZrtpSasType sasType);
* Also manage DB schema upgrade
* @param[in/out] db Pointer to the sqlite3 db open connection
* Use a void * to keep this API when building cacheless
* @param[in] dbMutex a mutex to synchronise zrtp cache database operation. Ignored if NULL
*
* @return 0 on succes, MSZRTP_CACHE_SETUP if cache was empty, MSZRTP_CACHE_UPDATE if db structure was updated error code otherwise
* @return 0 on success, MSZRTP_CACHE_SETUP if cache was empty, MSZRTP_CACHE_UPDATE if db structure was updated error code otherwise
*/
MS2_PUBLIC int ms_zrtp_initCache(void *db);
MS2_PUBLIC int ms_zrtp_initCache(void *db, bctbx_mutex_t *dbMutex);
/**
* @brief Perform migration from xml version to sqlite3 version of cache
......
......@@ -58,7 +58,7 @@ public class AndroidVideoApi9JniWrapper {
}
public static Object startRecording(int cameraId, int width, int height, int fps, int rotation, final long nativePtr) {
Log.d("startRecording(" + cameraId + ", " + width + ", " + height + ", " + fps + ", " + rotation + ", " + nativePtr + ")");
Log.i("startRecording(" + cameraId + ", " + width + ", " + height + ", " + fps + ", " + rotation + ", " + nativePtr + ")");
try {
Camera camera = Camera.open(cameraId);
Parameters params = camera.getParameters();
......@@ -66,14 +66,14 @@ public class AndroidVideoApi9JniWrapper {
for (String focusMode : params.getSupportedFocusModes()) {
if (focusMode.equalsIgnoreCase(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
Log.d("FOCUS_MODE_CONTINUOUS_VIDEO is supported, let's use it");
Log.i("FOCUS_MODE_CONTINUOUS_VIDEO is supported, let's use it");
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
break;
}
}
if (params.isVideoStabilizationSupported()) {
Log.d("Video stabilization is supported, let's use it");
Log.i("Video stabilization is supported, let's use it");
params.setVideoStabilization(true);
}
......@@ -107,7 +107,7 @@ public class AndroidVideoApi9JniWrapper {
});
setCameraDisplayOrientation(rotation, cameraId, camera);
camera.startPreview();
AndroidVideoApi5JniWrapper.isRecording = true;
Log.d("Returning camera object: " + camera);
return camera;
......@@ -124,6 +124,9 @@ public class AndroidVideoApi9JniWrapper {
public static void setPreviewDisplaySurface(Object cam, Object surf) {
AndroidVideoApi5JniWrapper.setPreviewDisplaySurface(cam, surf);
//start preview is delayed to workaround autofocus issues on Samsung devices
((Camera)cam).startPreview();
Log.i("Camera ["+((Camera)cam) +"] preview started");
}
private static void setCameraDisplayOrientation(int rotationDegrees, int cameraId, Camera camera) {
......
......@@ -68,7 +68,6 @@ add_definitions(
-DBCTBX_LOG_DOMAIN="mediastreamer"
)
set(VOIP_SOURCE_FILES_C
audiofilters/alaw.c
audiofilters/audiomixer.c
......
......@@ -189,6 +189,8 @@ struct AndroidSndWriteData{
stype = AUDIO_STREAM_VOICE_CALL;
if (type == MS_SND_CARD_STREAM_RING) {
stype = AUDIO_STREAM_RING;
} else if (type == MS_SND_CARD_STREAM_MEDIA) {
stype = AUDIO_STREAM_MUSIC;
}
}
void setCard(AndroidNativeSndCardData *card){
......
......@@ -164,6 +164,8 @@ struct OpenSLESOutputContext {
streamType = SL_ANDROID_STREAM_VOICE;
if (type == MS_SND_CARD_STREAM_RING) {
streamType = SL_ANDROID_STREAM_RING;
} else if (type == MS_SND_CARD_STREAM_MEDIA) {
streamType = SL_ANDROID_STREAM_MEDIA;
}
}
......
......@@ -39,6 +39,7 @@ struct _MSZrtpContext{
/* cache related data */
uint32_t limeKeyTimeSpan; /**< amount in seconds of the lime key life span */
void *cacheDB; /**< pointer to an already open sqlite db holding the zid cache */
bctbx_mutex_t *cacheDBMutex; /**< pointer to a mutex used to lock cache access */
};
/***********************************************/
......@@ -363,7 +364,7 @@ static int ms_zrtp_addExportedKeysInZidCache(void *clientData, int zuid, uint8_t
colValues[5][0] &= 0x7F;
/* then insert all in cache */
ret = bzrtp_cache_write(userData->cacheDB, zuid, "lime", colNames, colValues, colLength, 7);
ret = bzrtp_cache_write_lock(userData->cacheDB, zuid, "lime", colNames, colValues, colLength, 7, userData->cacheDBMutex);
for (i=0; i<7; i++) {
ms_free(colValues[i]);
......@@ -596,7 +597,7 @@ MSZrtpContext* ms_zrtp_context_new(MSMediaStreamSessions *sessions, MSZrtpParams
if (params->zidCacheDB != NULL && params->selfUri != NULL && params->peerUri) { /* to enable cache we need a self and peer uri and a pointer to the sqlite cache DB */
/*enabling cache*/
bzrtp_setZIDCache(context, params->zidCacheDB, params->selfUri, params->peerUri);
bzrtp_setZIDCache_lock(context, params->zidCacheDB, params->selfUri, params->peerUri, params->zidCacheDBMutex);
cbs.bzrtp_contextReadyForExportedKeys=ms_zrtp_addExportedKeysInZidCache;
}
......@@ -626,7 +627,8 @@ MSZrtpContext* ms_zrtp_context_new(MSMediaStreamSessions *sessions, MSZrtpParams
userData->self_ssrc = sessions->rtp_session->snd.ssrc;
userData->limeKeyTimeSpan = params->limeKeyTimeSpan;
userData->cacheDB = params->zidCacheDB; /* add a link to the ZidCache to be able to free it when we will destroy this context */
userData->cacheDB = params->zidCacheDB; /* add a link to the ZidCache and mutex to be able to access it from callbacks */
userData->cacheDBMutex = params->zidCacheDBMutex;
bzrtp_setClientData(context, sessions->rtp_session->snd.ssrc, (void *)userData);
......@@ -682,14 +684,36 @@ void ms_zrtp_sas_verified(MSZrtpContext* ctx){
bzrtp_SASVerified(ctx->zrtpContext);
}
uint8_t ms_zrtp_getAuxiliarySharedSecretMismatch(MSZrtpContext *ctx) {
return bzrtp_getAuxiliarySharedSecretMismatch(ctx->zrtpContext);
}
void ms_zrtp_sas_reset_verified(MSZrtpContext* ctx){
bzrtp_resetSASVerified(ctx->zrtpContext);
}
MSZrtpPeerStatus ms_zrtp_get_peer_status(void *db, const char *peerUri, bctbx_mutex_t *dbMutex){
int status = bzrtp_cache_getPeerStatus_lock(db, peerUri, dbMutex);
switch (status) {
case BZRTP_CACHE_PEER_STATUS_UNKNOWN:
return MS_ZRTP_PEER_STATUS_UNKNOWN;
case BZRTP_CACHE_PEER_STATUS_INVALID:
return MS_ZRTP_PEER_STATUS_INVALID;
case BZRTP_CACHE_PEER_STATUS_VALID:
return MS_ZRTP_PEER_STATUS_VALID;
default:
return MS_ZRTP_PEER_STATUS_UNKNOWN;
}
}
int ms_zrtp_getHelloHash(MSZrtpContext* ctx, uint8_t *output, size_t outputLength) {
return bzrtp_getSelfHelloHash(ctx->zrtpContext, ctx->self_ssrc, output, outputLength);
}
int ms_zrtp_setAuxiliarySharedSecret(MSZrtpContext *ctx, const uint8_t *auxSharedSecret, size_t auxSharedSecretLength) {
return bzrtp_setAuxiliarySharedSecret(ctx->zrtpContext, auxSharedSecret, auxSharedSecretLength);
}
int ms_zrtp_setPeerHelloHash(MSZrtpContext *ctx, uint8_t *peerHelloHashHexString, size_t peerHelloHashHexStringLength) {
return bzrtp_setPeerHelloHash(ctx->zrtpContext, ctx->self_ssrc, peerHelloHashHexString, peerHelloHashHexStringLength);
}
......@@ -699,11 +723,12 @@ int ms_zrtp_setPeerHelloHash(MSZrtpContext *ctx, uint8_t *peerHelloHashHexString
* Also manage DB schema upgrade
* @param[in/out] db Pointer to the sqlite3 db open connection
* Use a void * to keep this API when building cacheless
* @param[in] dbMutex a mutex to synchronise zrtp cache database operation. Ignored if NULL
*
* @return 0 on succes, MSZRTP_CACHE_SETUP if cache was empty, MSZRTP_CACHE_UPDATE if db structure was updated error code otherwise
*/
int ms_zrtp_initCache(void *db) {
int ret = bzrtp_initCache(db);
int ms_zrtp_initCache(void *db, bctbx_mutex_t *dbMutex) {
int ret = bzrtp_initCache_lock(db, dbMutex);
switch (ret) {
case BZRTP_CACHE_SETUP:
return MSZRTP_CACHE_SETUP;
......@@ -742,7 +767,7 @@ int ms_zrtp_cache_migration(void *cacheXmlPtr, void *cacheSqlite, const char *se
}
}
#else
#else /* HAVE_ZRTP */
MSZrtpContext* ms_zrtp_context_new(MSMediaStreamSessions *sessions, MSZrtpParams *params){
ms_message("ZRTP is disabled");
......@@ -758,6 +783,7 @@ int ms_zrtp_channel_start(MSZrtpContext *ctx) { return 0;}
bool_t ms_zrtp_available(){return FALSE;}
void ms_zrtp_sas_verified(MSZrtpContext* ctx){}
void ms_zrtp_sas_reset_verified(MSZrtpContext* ctx){}
MSZrtpPeerStatus ms_zrtp_get_peer_status(void *db, const char *peerUri, bctbx_mutex_t *dbMutex) {return MS_ZRTP_PEER_STATUS_UNKNOWN;}
void ms_zrtp_context_destroy(MSZrtpContext *ctx){}
void ms_zrtp_reset_transmition_timer(MSZrtpContext* ctx) {};
int ms_zrtp_transport_modifier_new(MSZrtpContext* ctx, RtpTransportModifier **rtpt, RtpTransportModifier **rtcpt ) {return 0;}
......@@ -765,9 +791,9 @@ void ms_zrtp_transport_modifier_destroy(RtpTransportModifier *tp) {}
void ms_zrtp_set_stream_sessions(MSZrtpContext *zrtp_context, MSMediaStreamSessions *stream_sessions) {}
int ms_zrtp_getHelloHash(MSZrtpContext* ctx, uint8_t *output, size_t outputLength) {return 0;}
int ms_zrtp_setPeerHelloHash(MSZrtpContext *ctx, uint8_t *peerHelloHashHexString, size_t peerHelloHashHexStringLength) {return 0;}
int ms_zrtp_initCache(void *db){return 0;}
int ms_zrtp_initCache(void *db, bctbx_mutex_t *dbMutex){return 0;}
int ms_zrtp_cache_migration(void *cacheXmlPtr, void *cacheSqlite, const char *selfURI) {return 0;}
#endif
#endif /* HAVE_ZRTP */
#define STRING_COMPARE_RETURN(string, value)\
if (strcmp(string,#value) == 0) return value
......
......@@ -3645,6 +3645,7 @@ static void ice_check_list_perform_nominations(IceCheckList *cl, bool_t nominati
bctbx_list_free(best_valid_list);
}
static void ice_remove_waiting_and_frozen_pairs_from_list(bctbx_list_t **list, uint16_t componentID)
{
IceCandidatePair *pair;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment