Commit 4e8d9732 authored by Simon Morlat's avatar Simon Morlat

updated for lastest bzrtp

parent a8664070
......@@ -147,6 +147,18 @@ AS_CASE([$enable_debug],
],
[AC_MSG_ERROR([Bad value ($enable_debug) for --enable-debug. Valid values are yes or no.])])
AC_ARG_ENABLE(non-free-codecs,
AC_HELP_STRING([--enable-non-free-codecs], [Include non-free codecs in build @<:@yes@:>@]),
[non_free_codecs="${enableval}"],
[non_free_codecs=yes]
)
if test "$non_free_codecs" = "yes" ; then
AC_DEFINE(HAVE_NON_FREE_CODECS, 1, [whether non free codecs are allowed in the build])
else
AC_DEFINE(HAVE_NON_FREE_CODECS, 0, [whether non free codecs are allowed in the build])
fi
dnl Checks for header files.
AC_HEADER_STDC
......@@ -1089,23 +1101,31 @@ fi
dnl check for libzrtp support (RFC 6189: Media Path Key Agreement for Unicast Secure RTP)
AC_ARG_ENABLE(zrtp,
[AS_HELP_STRING([--enable-zrtp], [Turn on or off compilation of zrtp (default=no)])],
[AS_HELP_STRING([--enable-zrtp], [Turn on or off compilation of zrtp (default=detect)])],
[case "${enableval}" in
yes) zrtp=true ;;
no) zrtp=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-zrtp) ;;
esac],
[zrtp=false]
[zrtp=detect]
)
if test "$zrtp" = "true" ; then
PKG_CHECK_MODULES(LIBBZRTP, libbzrtp >= 0.0.0)
if test "$have_srtp" = "no" ; then
AC_MSG_ERROR("ZRTP requires SRTP")
if test "$zrtp" != "false" ; then
PKG_CHECK_MODULES(LIBBZRTP, libbzrtp >= 1.0.0, found_zrtp=true, found_zrtp=false)
if test "$zrtp$found_zrtp" = "truefalse" ; then
AC_MSG_ERROR("Cound not find bZRTP library.")
fi
if test "$found_zrtp" = "true" ; then
if test "$have_srtp" = "no" ; then
AC_MSG_ERROR("ZRTP requires SRTP")
fi
AC_DEFINE(HAVE_ZRTP, 1, [Defined when zrtp support is compiled])
LIBS="$LIBS $LIBBZRTP_LIBS"
CFLAGS="$CFLAGS $LIBBZRTP_CFLAGS"
zrtp=true
else
zrtp=false
fi
AC_DEFINE(HAVE_ZRTP, 1, [Defined when zrtp support is compiled])
LIBS="$LIBS $LIBBZRTP_LIBS"
CFLAGS="$CFLAGS $LIBBZRTP_CFLAGS"
else
echo "ZRTP compilation is disabled."
fi
......@@ -1317,3 +1337,11 @@ AC_CONFIG_FILES(
)
AC_OUTPUT
echo "Mediastreamer2 build configuration ended."
echo "Summary of build options:"
printf "* %-30s %s\n" "Video support" $video
printf "* %-30s %s\n" "zRTP encryption" $zrtp
printf "* %-30s %s\n" "DTLS encryption" $dtls
printf "* %-30s %s\n" "Non-free codecs" $non_free_codecs
......@@ -302,6 +302,20 @@ bool_t ms_is_multicast_addr(const struct sockaddr *address);
* @return TRUE if address is multicast
*/
MS2_PUBLIC bool_t ms_is_multicast(const char *address);
/**
* Utility function to load a file into memory.
* @param file a FILE handle
* @param nbytes (optional) number of bytes read
**/
MS2_PUBLIC char *ms_load_file_content(FILE *file, size_t *nbytes);
/**
* Utility function to load a file into memory.
* @param path a FILE handle
* @param nbytes (optional) number of bytes read
**/
MS2_PUBLIC char *ms_load_path_content(const char *path, size_t *nbytes);
/** @} */
#ifdef __cplusplus
......
......@@ -505,4 +505,35 @@ unsigned int ms_concealer_ts_context_is_concealement_required(MSConcealerTsConte
return 0;
}
char *ms_load_file_content(FILE *f, size_t *nbytes){
size_t bufsize=2048;
size_t step=bufsize;
size_t pos=0;
size_t count;
char *buffer=ms_malloc(bufsize+1);
while((count=fread(buffer+pos, 1, step, f))>0){
pos+=count;
if (pos+step>=bufsize){
bufsize*=2;
buffer=ms_realloc(buffer, bufsize+1);
}
}
if (nbytes) *nbytes=pos;
buffer[pos]='\0';
return buffer;
}
char *ms_load_path_content(const char *path, size_t *nbytes){
FILE *f=fopen(path,"rb");
char *buffer;
if (!f) {
ms_error("ms_load_file_content(): could not open [%s]",path);
return NULL;
}
buffer=ms_load_file_content(f, nbytes);
fclose(f);
return buffer;
}
/*** plc context end***/
......@@ -72,7 +72,7 @@ static ORTP_INLINE uint64_t get_timeval_in_millis() {
* @param[in] length The length in bytes of the data
* @return 0 on success
*/
static int32_t ms_zrtp_sendDataZRTP (void *clientData, uint8_t* data, int32_t length ){
static int32_t ms_zrtp_sendDataZRTP (void *clientData, const uint8_t* data, uint16_t length ){
MSZrtpContext *userData = (MSZrtpContext *)clientData;
RtpSession *session = userData->stream_sessions->rtp_session;
RtpTransport *rtpt=NULL;
......@@ -185,7 +185,7 @@ static int32_t ms_zrtp_srtpSecretsAvailable(void* clientData, bzrtpSrtpSecrets_t
* @param[in] sas The SAS string(4 characters, not null terminated, fixed length)
* @param[in] verified if <code>verified</code> is true then SAS was verified by both parties during a previous call.
*/
static int ms_zrtp_startSrtpSession(void *clientData, char* sas, int32_t verified ){
static int ms_zrtp_startSrtpSession(void *clientData, const char* sas, int32_t verified ){
MSZrtpContext *userData = (MSZrtpContext *)clientData;
// srtp processing is enabled in SecretsReady fuction when receiver secrets are ready
......@@ -223,13 +223,14 @@ static int ms_zrtp_startSrtpSession(void *clientData, char* sas, int32_t verifie
* @param[out] outputSize Buffer length in bytes
* @return outputSize
*/
static int ms_zrtp_loadCache(void *clientData, uint8_t** output, uint32_t *outputSize) {
static int ms_zrtp_loadCache(void *clientData, uint8_t** output, uint32_t *outputSize, zrtpFreeBuffer_callback *cb) {
/* get filename from ClientData */
MSZrtpContext *userData = (MSZrtpContext *)clientData;
char *filename = userData->zidFilename;
FILE *CACHEFD = fopen(filename, "r+");
size_t nbytes=0;
FILE *CACHEFD = fopen(filename, "rb+");
if (CACHEFD == NULL) { /* file doesn't seem to exist, try to create it */
CACHEFD = fopen(filename, "w");
CACHEFD = fopen(filename, "wb");
if (CACHEFD != NULL) { /* file created with success */
*output = NULL;
*outputSize = 0;
......@@ -238,13 +239,9 @@ static int ms_zrtp_loadCache(void *clientData, uint8_t** output, uint32_t *outpu
}
return -1;
}
fseek(CACHEFD, 0L, SEEK_END); /* Position to end of file */
*outputSize = ftell(CACHEFD); /* Get file length */
rewind(CACHEFD); /* Back to start of file */
*output = (uint8_t *)malloc(*outputSize*sizeof(uint8_t)+1); /* string must be null terminated */
fread(*output, 1, *outputSize, CACHEFD);
*(*output+*outputSize) = '\0';
*outputSize += 1;
*output=(uint8_t*)ms_load_file_content(CACHEFD, &nbytes);
*outputSize = nbytes+1;
*cb=ms_free;
fclose(CACHEFD);
return *outputSize;
}
......@@ -256,7 +253,7 @@ static int ms_zrtp_loadCache(void *clientData, uint8_t** output, uint32_t *outpu
* @param[in] inputSize input string length in bytes
* @return number of bytes written to file
*/
static int ms_zrtp_writeCache(void *clientData, uint8_t* input, uint32_t inputSize) {
static int ms_zrtp_writeCache(void *clientData, const uint8_t* input, uint32_t inputSize) {
/* get filename from ClientData */
MSZrtpContext *userData = (MSZrtpContext *)clientData;
char *filename = userData->zidFilename;
......@@ -521,22 +518,27 @@ bool_t ms_zrtp_available(){return TRUE;}
MSZrtpContext* ms_zrtp_context_new(MSMediaStreamSessions *sessions, MSZrtpParams *params) {
MSZrtpContext *userData;
bzrtpContext_t *context;
bzrtpCallbacks_t cbs={0};
ms_message("Creating ZRTP engine on rtp session [%p]",sessions->rtp_session);
context = bzrtp_createBzrtpContext(sessions->rtp_session->snd.ssrc); /* create the zrtp context, provide the SSRC of first channel */
/* set callback functions */
bzrtp_setCallback(context, (int (*)())ms_zrtp_sendDataZRTP, ZRTP_CALLBACK_SENDDATA);
bzrtp_setCallback(context, (int (*)())ms_zrtp_srtpSecretsAvailable, ZRTP_CALLBACK_SRTPSECRETSAVAILABLE);
bzrtp_setCallback(context, (int (*)())ms_zrtp_startSrtpSession, ZRTP_CALLBACK_STARTSRTPSESSION);
cbs.bzrtp_sendData=ms_zrtp_sendDataZRTP;
cbs.bzrtp_srtpSecretsAvailable=ms_zrtp_srtpSecretsAvailable;
cbs.bzrtp_startSrtpSession=ms_zrtp_startSrtpSession;
if (params->zid_file) {
/*enabling cache*/
bzrtp_setCallback(context, (int (*)())ms_zrtp_loadCache, ZRTP_CALLBACK_LOADCACHE);
bzrtp_setCallback(context, (int (*)())ms_zrtp_writeCache, ZRTP_CALLBACK_WRITECACHE);
cbs.bzrtp_loadCache=ms_zrtp_loadCache;
cbs.bzrtp_writeCache=ms_zrtp_writeCache;
/* enable exportedKeys computation only if we have an uri to associate them */
if (params->uri && strlen(params->uri)>0) {
bzrtp_setCallback(context, (int (*)())ms_zrtp_addExportedKeysInZidCache, ZRTP_CALLBACK_CONTEXTREADYFOREXPORTEDKEYS);
cbs.bzrtp_contextReadyForExportedKeys=ms_zrtp_addExportedKeysInZidCache;
}
}
bzrtp_setCallbacks(context, &cbs);
/* create and link user data */
userData=createUserData(context, params);
userData->stream_sessions=sessions;
......
......@@ -1141,9 +1141,9 @@ MSFilterDesc ms_mjpeg_enc_desc={
void __register_ffmpeg_encoders_if_possible(MSFactory *obj){
ms_ffmpeg_check_init();
if (avcodec_find_encoder(CODEC_ID_MPEG4))
if (avcodec_find_encoder(CODEC_ID_MPEG4) && HAVE_NON_FREE_CODECS)
ms_factory_register_filter(obj,&ms_mpeg4_enc_desc);
if (avcodec_find_encoder(CODEC_ID_H263)){
if (avcodec_find_encoder(CODEC_ID_H263) && HAVE_NON_FREE_CODECS){
ms_factory_register_filter(obj,&ms_h263_enc_desc);
ms_factory_register_filter(obj,&ms_h263_old_enc_desc);
}
......
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