Commit 30dafe43 authored by Sandrine Avakian's avatar Sandrine Avakian

Merge branch 'master' of git.linphone.org:ortp into dev_codecbv16

parents 58c087e7 de0aee3f
......@@ -21,17 +21,18 @@
############################################################################
cmake_minimum_required(VERSION 3.0)
project(ORTP)
project(oRTP VERSION 0.26.0)
set(ORTP_MAJOR_VERSION "0")
set(ORTP_MINOR_VERSION "26")
set(ORTP_MICRO_VERSION "0")
set(ORTP_VERSION "${ORTP_MAJOR_VERSION}.${ORTP_MINOR_VERSION}.${ORTP_MICRO_VERSION}")
set(ORTP_MAJOR_VERSION ${PROJECT_VERSION_MAJOR})
set(ORTP_MINOR_VERSION ${PROJECT_VERSION_MINOR})
set(ORTP_MICRO_VERSION ${PROJECT_VERSION_PATCH})
set(ORTP_VERSION ${PROJECT_VERSION})
set(ORTP_SO_VERSION "11") # incremented on January, the 20th 2015. DO NOT INCREMENT BEFORE ORTP 0.26
option(ENABLE_STATIC "Build static library (default is shared library)." NO)
option(ENABLE_SHARED "Build shared library." YES)
option(ENABLE_STATIC "Build static library." YES)
option(ENABLE_DOC "Enable documentation generation with Doxygen." YES)
option(ENABLE_NTP_TIMESTAMP "Turn on NTP timestamping on packet reception." NO)
option(ENABLE_PERF "Disable costly features to reduce cpu consumtion and increase performance." NO)
......@@ -57,10 +58,14 @@ macro(apply_compile_flags SOURCE_FILES)
endmacro()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_PREFIX_PATH}/share/cmake/Modules)
include(CheckIncludeFile)
include(CheckFunctionExists)
include(GNUInstallDirs)
if(NOT CMAKE_INSTALL_RPATH AND CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
message(STATUS "Setting install rpath to ${CMAKE_INSTALL_RPATH}")
endif()
set(MSVC_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/MSVC")
if(MSVC)
......@@ -170,7 +175,7 @@ if(ENABLE_DOC)
)
add_custom_target(ortp-html-doc ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/doc/html/index.html")
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doc/html"
DESTINATION "share/doc/oRTP-${ORTP_VERSION}")
DESTINATION "${CMAKE_INSTALL_DATADIR}/doc/oRTP-${ORTP_VERSION}")
endif()
endif()
......@@ -185,7 +190,7 @@ set(ORTP_PKGCONFIG_VERSION "${ORTP_VERSION}")
set(ORTPDEPS_LIBS )
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ortp.pc.in ${CMAKE_CURRENT_BINARY_DIR}/ortp.pc)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ortp.pc DESTINATION lib/pkgconfig)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ortp.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
include(CMakePackageConfigHelpers)
......@@ -202,13 +207,13 @@ configure_file(ORTPConfig.cmake.in
@ONLY
)
set(ConfigPackageLocation lib/cmake/oRTP)
set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake")
install(EXPORT ${EXPORT_TARGETS_NAME}Targets
FILE ORTPTargets.cmake
DESTINATION ${ConfigPackageLocation}
DESTINATION ${CONFIG_PACKAGE_LOCATION}
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/ORTPConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/ORTPConfigVersion.cmake"
DESTINATION ${ConfigPackageLocation}
DESTINATION ${CONFIG_PACKAGE_LOCATION}
)
......@@ -38,6 +38,10 @@ if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
else()
set(ORTP_INCLUDE_DIRS "${ORTP_CMAKE_DIR}/../../../include")
endif()
set(ORTP_LIBRARIES ortp)
if(@ENABLE_SHARED@)
set(ORTP_LIBRARIES ortp)
else()
set(ORTP_LIBRARIES ortp-static)
endif()
set(ORTP_CPPFLAGS @ORTP_CPPFLAGS@)
set(ORTP_FOUND 1)
......@@ -44,5 +44,5 @@ endforeach()
set(ORTP_HEADER_FILES ${ORTP_HEADER_FILES} PARENT_SCOPE)
install(FILES ${ORTP_HEADER_FILES}
DESTINATION include/ortp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ortp
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
......@@ -83,28 +83,37 @@ endif()
apply_compile_flags(ORTP_SOURCE_FILES_C "CPP" "C")
apply_compile_flags(ORTP_SOURCE_FILES_CXX "CPP" "CXX")
add_library(ortp-objects OBJECT ${ORTP_HEADER_FILES} ${ORTP_SOURCE_FILES_C} ${ORTP_SOURCE_FILES_CXX})
set_target_properties(ortp-objects PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
if(ENABLE_STATIC)
add_library(ortp STATIC ${ORTP_HEADER_FILES} ${ORTP_SOURCE_FILES_C} ${ORTP_SOURCE_FILES_CXX})
else()
add_library(ortp SHARED ${ORTP_HEADER_FILES} ${ORTP_SOURCE_FILES_C} ${ORTP_SOURCE_FILES_CXX})
add_library(ortp-static STATIC $<TARGET_OBJECTS:ortp-objects>)
set_target_properties(ortp-static PROPERTIES OUTPUT_NAME ortp)
target_link_libraries(ortp-static ${LIBS})
install(TARGETS ortp-static EXPORT ${EXPORT_TARGETS_NAME}Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
if(ENABLE_SHARED)
add_library(ortp SHARED $<TARGET_OBJECTS:ortp-objects>)
set_target_properties(ortp PROPERTIES VERSION ${ORTP_SO_VERSION})
target_link_libraries(ortp ${LIBS})
if(MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/ortp.pdb
DESTINATION bin
DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
endif()
install(TARGETS ortp EXPORT ${EXPORT_TARGETS_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
target_link_libraries(ortp ${LIBS})
install(TARGETS ortp EXPORT ${EXPORT_TARGETS_NAME}Targets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
if(ENABLE_TESTS)
#add_subdirectory(tests)
......
......@@ -832,7 +832,9 @@ char* strtok_r(char *str, const char *delim, char **nextp){
#endif
#if defined(_WIN32) && !defined(_MSC_VER)
#if defined(_WIN32)
#if !defined(_MSC_VER)
#include <wincrypt.h>
static int ortp_wincrypto_random(unsigned int *rand_number){
static HCRYPTPROV hProv=(HCRYPTPROV)-1;
......@@ -855,11 +857,9 @@ static int ortp_wincrypto_random(unsigned int *rand_number){
return 0;
}
#endif
#else
unsigned int ortp_random(void){
#ifdef HAVE_ARC4RANDOM
return arc4random();
#elif defined(__linux) || defined(__APPLE__)
static unsigned int ortp_urandom(void) {
static int fd=-1;
if (fd==-1) fd=open("/dev/urandom",O_RDONLY);
if (fd!=-1){
......@@ -867,7 +867,24 @@ unsigned int ortp_random(void){
if (read(fd,&tmp,4)!=4){
ortp_error("Reading /dev/urandom failed.");
}else return tmp;
}else ortp_error("Could not open /dev/urandom");
} else ortp_error("Could not open /dev/urandom");
return (unsigned int) random();
}
#endif
unsigned int ortp_random(void){
#ifdef HAVE_ARC4RANDOM
#if defined(__QNXNTO__) // There is a false positive with blackberry build
return ortp_urandom();
#else
return arc4random();
#endif
#elif defined(__linux) || defined(__APPLE__)
return ortp_urandom();
#elif defined(_WIN32)
static int initd=0;
unsigned int ret;
......@@ -891,12 +908,9 @@ unsigned int ortp_random(void){
ortp_warning("ortp: Random generator is using rand(), this is unsecure !");
}
return rand()<<16 | rand();
#endif
/*fallback to UNIX random()*/
#ifndef _WIN32
return (unsigned int) random();
#endif
}
bool_t ortp_is_multicast_addr(const struct sockaddr *addr) {
switch (addr->sa_family) {
......
......@@ -1419,29 +1419,29 @@ void rtp_session_set_time_jump_limit(RtpSession *session, int milisecs){
}
void _rtp_session_release_sockets(RtpSession *session, bool_t release_transports){
if (release_transports){
if (session->rtp.gs.tr) {
if (session->rtp.gs.tr->t_close)
session->rtp.gs.tr->t_close(session->rtp.gs.tr, session->rtp.gs.tr->data);
session->rtp.gs.tr->t_destroy(session->rtp.gs.tr);
}
session->rtp.gs.tr = 0;
if (session->rtcp.gs.tr) {
if (session->rtcp.gs.tr->t_close)
session->rtcp.gs.tr->t_close(session->rtcp.gs.tr, session->rtcp.gs.tr->data);
session->rtcp.gs.tr->t_destroy(session->rtcp.gs.tr);
}
session->rtcp.gs.tr = 0;
}
if (session->rtp.gs.socket!=(ortp_socket_t)-1) close_socket (session->rtp.gs.socket);
if (session->rtcp.gs.socket!=(ortp_socket_t)-1) close_socket (session->rtcp.gs.socket);
session->rtp.gs.socket=-1;
session->rtcp.gs.socket=-1;
if (!release_transports)
return;
if (session->rtp.gs.tr) {
if (session->rtp.gs.tr->t_close)
session->rtp.gs.tr->t_close(session->rtp.gs.tr, session->rtp.gs.tr->data);
session->rtp.gs.tr->t_destroy(session->rtp.gs.tr);
}
session->rtp.gs.tr = 0;
if (session->rtcp.gs.tr) {
if (session->rtcp.gs.tr->t_close)
session->rtcp.gs.tr->t_close(session->rtcp.gs.tr, session->rtcp.gs.tr->data);
session->rtcp.gs.tr->t_destroy(session->rtcp.gs.tr);
}
session->rtcp.gs.tr = 0;
/* don't discard remote addresses, then can be preserved for next use.
session->rtp.gs.rem_addrlen=0;
session->rtcp.gs.rem_addrlen=0;
......
......@@ -1165,7 +1165,7 @@ int rtp_session_rtp_send (RtpSession * session, mblk_t * m){
destlen=0;
}
/*first send to main destination*/
if (destlen) error=rtp_session_rtp_sendto(session,m,destaddr,destlen,FALSE);
error=rtp_session_rtp_sendto(session,m,destaddr,destlen,FALSE);
/*then iterate over auxiliary destinations*/
for(elem=session->rtp.gs.aux_destinations;elem!=NULL;elem=elem->next){
OrtpAddress *addr=(OrtpAddress*)elem->data;
......
......@@ -140,7 +140,7 @@ int main(int argc, char*argv[])
ortp_init();
ortp_scheduler_init();
ortp_set_log_level_mask(ORTP_DEBUG|ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR);
ortp_set_log_level_mask(NULL, ORTP_DEBUG|ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR);
signal(SIGINT,stop_handler);
session=rtp_session_new(RTP_SESSION_RECVONLY);
rtp_session_set_scheduling_mode(session,1);
......
......@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
ortp_init();
ortp_scheduler_init();
ortp_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR);
ortp_set_log_level_mask(NULL, ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR);
session=rtp_session_new(RTP_SESSION_SENDONLY);
rtp_session_set_scheduling_mode(session,1);
......
......@@ -76,7 +76,7 @@ int main(int argc, char *argv[])
ortp_init();
ortp_scheduler_init();
ortp_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR);
ortp_set_log_level_mask(NULL, ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR);
session=rtp_session_new(RTP_SESSION_SENDONLY);
rtp_session_set_scheduling_mode(session,1);
......
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