mirror of
https://github.com/TokTok/c-toxcore
synced 2026-04-26 19:35:37 +00:00
Enable build of av_test.
It has not been built in a while. We do want to keep this one working (or at least compiling).
This commit is contained in:
+7
-2
@@ -18,9 +18,14 @@ addons:
|
||||
- avsm
|
||||
packages:
|
||||
- check
|
||||
- libcv-dev # For av_test.
|
||||
- libhighgui-dev # For av_test.
|
||||
- libopencv-contrib-dev # For av_test.
|
||||
- libsndfile1-dev # For av_test.
|
||||
- libvpx-dev
|
||||
- opam # For apidsl and Frama-C.
|
||||
- texinfo # For libconfig.
|
||||
- opam # For apidsl and Frama-C.
|
||||
- portaudio19-dev # For av_test.
|
||||
- texinfo # For libconfig.
|
||||
|
||||
cache:
|
||||
directories:
|
||||
|
||||
+48
-34
@@ -29,44 +29,49 @@ endif()
|
||||
find_package(PkgConfig REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
find_library(UTIL_LIBRARIES util)
|
||||
find_library(RT_LIBRARIES rt)
|
||||
find_library(UTIL_LIBRARIES util )
|
||||
find_library(RT_LIBRARIES rt )
|
||||
|
||||
pkg_search_module(CHECK check)
|
||||
pkg_search_module(LIBCONFIG libconfig)
|
||||
pkg_search_module(LIBSODIUM REQUIRED libsodium)
|
||||
pkg_search_module(OPUS REQUIRED opus)
|
||||
pkg_search_module(VPX REQUIRED vpx)
|
||||
# For toxcore.
|
||||
pkg_search_module(LIBSODIUM REQUIRED libsodium )
|
||||
|
||||
if(CHECK_FOUND)
|
||||
link_directories(${CHECK_LIBRARY_DIRS})
|
||||
endif()
|
||||
if(LIBCONFIG_FOUND)
|
||||
link_directories(${LIBCONFIG_LIBRARY_DIRS})
|
||||
endif()
|
||||
link_directories(${LIBSODIUM_LIBRARY_DIRS})
|
||||
link_directories(${OPUS_LIBRARY_DIRS})
|
||||
link_directories(${VPX_LIBRARY_DIRS})
|
||||
# For toxav.
|
||||
pkg_search_module(OPUS REQUIRED opus )
|
||||
pkg_search_module(VPX REQUIRED vpx )
|
||||
|
||||
if(CHECK_FOUND)
|
||||
include_directories(${CHECK_INCLUDE_DIRS})
|
||||
endif()
|
||||
if(LIBCONFIG_FOUND)
|
||||
include_directories(${LIBCONFIG_INCLUDE_DIRS})
|
||||
endif()
|
||||
include_directories(${LIBSODIUM_INCLUDE_DIRS})
|
||||
include_directories(${OPUS_INCLUDE_DIRS})
|
||||
include_directories(${VPX_INCLUDE_DIRS})
|
||||
# For tox-bootstrapd.
|
||||
pkg_search_module(LIBCONFIG libconfig )
|
||||
|
||||
# For auto tests.
|
||||
pkg_search_module(CHECK check )
|
||||
|
||||
# For av_test.
|
||||
pkg_search_module(OPENCV opencv )
|
||||
pkg_search_module(PORTAUDIO portaudio-2.0)
|
||||
pkg_search_module(SNDFILE sndfile )
|
||||
|
||||
# TODO(iphydf): fold the pkg_search_module call into this function.
|
||||
function(pkg_use_module mod)
|
||||
if(${mod}_FOUND)
|
||||
link_directories(${${mod}_LIBRARY_DIRS})
|
||||
include_directories(${${mod}_INCLUDE_DIRS})
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${mod}_CFLAGS_OTHER}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
pkg_use_module(LIBSODIUM)
|
||||
|
||||
pkg_use_module(OPUS)
|
||||
pkg_use_module(VPX)
|
||||
|
||||
pkg_use_module(LIBCONFIG)
|
||||
|
||||
pkg_use_module(CHECK)
|
||||
|
||||
pkg_use_module(OPENCV)
|
||||
pkg_use_module(PORTAUDIO)
|
||||
pkg_use_module(SNDFILE)
|
||||
|
||||
if(CHECK_FOUND)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CHECK_CFLAGS_OTHER}")
|
||||
endif()
|
||||
if(LIBCONFIG_FOUND)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBCONFIG_CFLAGS_OTHER}")
|
||||
endif()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBSODIUM_CFLAGS_OTHER}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPUS_CFLAGS_OTHER}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VPX_CFLAGS_OTHER}")
|
||||
|
||||
# Users can call cmake -DLIBTYPE=STATIC or -DLIBTYPE=SHARED to override this.
|
||||
if(NOT LIBTYPE)
|
||||
@@ -281,6 +286,15 @@ endif()
|
||||
#
|
||||
################################################################################
|
||||
|
||||
if(NOT WIN32 AND SNDFILE_FOUND AND PORTAUDIO_FOUND AND OPENCV_FOUND)
|
||||
add_executable(av_test testing/av_test.c)
|
||||
target_link_libraries(av_test
|
||||
toxav
|
||||
${OPENCV_LIBRARIES}
|
||||
${PORTAUDIO_LIBRARIES}
|
||||
${SNDFILE_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(NOT WIN32)
|
||||
add_executable(nTox testing/nTox.c)
|
||||
target_link_libraries(nTox toxcore ncurses)
|
||||
|
||||
+23
-16
@@ -47,6 +47,11 @@
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <sched.h>
|
||||
#define pthread_yield sched_yield
|
||||
#endif
|
||||
|
||||
#define c_sleep(x) usleep(1000*x)
|
||||
|
||||
|
||||
@@ -113,6 +118,8 @@ void *pa_write_thread (void *d)
|
||||
c_sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,9 +246,9 @@ void initialize_tox(Tox **bootstrap, ToxAV **AliceAV, CallControl *AliceCC, ToxA
|
||||
uint8_t off = 1;
|
||||
|
||||
while (1) {
|
||||
tox_iterate(*bootstrap);
|
||||
tox_iterate(Alice);
|
||||
tox_iterate(Bob);
|
||||
tox_iterate(*bootstrap, &to_compare);
|
||||
tox_iterate(Alice, &to_compare);
|
||||
tox_iterate(Bob, &to_compare);
|
||||
|
||||
if (tox_self_get_connection_status(*bootstrap) &&
|
||||
tox_self_get_connection_status(Alice) &&
|
||||
@@ -284,11 +291,11 @@ void initialize_tox(Tox **bootstrap, ToxAV **AliceAV, CallControl *AliceCC, ToxA
|
||||
printf("Created 2 instances of ToxAV\n");
|
||||
printf("All set after %llu seconds!\n", time(NULL) - cur_time);
|
||||
}
|
||||
int iterate_tox(Tox *bootstrap, ToxAV *AliceAV, ToxAV *BobAV)
|
||||
int iterate_tox(Tox *bootstrap, ToxAV *AliceAV, ToxAV *BobAV, void *userdata)
|
||||
{
|
||||
tox_iterate(bootstrap);
|
||||
tox_iterate(toxav_get_tox(AliceAV));
|
||||
tox_iterate(toxav_get_tox(BobAV));
|
||||
tox_iterate(bootstrap, userdata);
|
||||
tox_iterate(toxav_get_tox(AliceAV), userdata);
|
||||
tox_iterate(toxav_get_tox(BobAV), userdata);
|
||||
|
||||
return MIN(tox_iteration_interval(toxav_get_tox(AliceAV)), tox_iteration_interval(toxav_get_tox(BobAV)));
|
||||
}
|
||||
@@ -542,7 +549,7 @@ CHECK_ARG:
|
||||
}
|
||||
|
||||
while (!BobCC.incoming)
|
||||
iterate_tox(bootstrap, AliceAV, BobAV);
|
||||
iterate_tox(bootstrap, AliceAV, BobAV, NULL);
|
||||
|
||||
{ /* Answer */
|
||||
TOXAV_ERR_ANSWER rc;
|
||||
@@ -555,7 +562,7 @@ CHECK_ARG:
|
||||
}
|
||||
|
||||
while (AliceCC.state == 0)
|
||||
iterate_tox(bootstrap, AliceAV, BobAV);
|
||||
iterate_tox(bootstrap, AliceAV, BobAV, NULL);
|
||||
|
||||
/* Open audio file */
|
||||
af_handle = sf_open(af_name, SFM_READ, &af_info);
|
||||
@@ -615,11 +622,11 @@ CHECK_ARG:
|
||||
|
||||
if (toxav_audio_send_frame(AliceAV, 0, PCM, count / af_info.channels, af_info.channels, af_info.samplerate,
|
||||
&rc) == false) {
|
||||
printf("Error sending frame of size %ld: %d\n", count, rc);
|
||||
printf("Error sending frame of size %ld: %d\n", (long)count, rc);
|
||||
}
|
||||
}
|
||||
|
||||
iterate_tox(bootstrap, AliceAV, BobAV);
|
||||
iterate_tox(bootstrap, AliceAV, BobAV, NULL);
|
||||
c_sleep(abs(audio_frame_duration - (current_time_monotonic() - enc_start_time) - 1));
|
||||
}
|
||||
|
||||
@@ -638,7 +645,7 @@ CHECK_ARG:
|
||||
}
|
||||
}
|
||||
|
||||
iterate_tox(bootstrap, AliceAV, BobAV);
|
||||
iterate_tox(bootstrap, AliceAV, BobAV, NULL);
|
||||
assert(BobCC.state == TOXAV_FRIEND_CALL_STATE_FINISHED);
|
||||
|
||||
/* Stop decode thread */
|
||||
@@ -678,7 +685,7 @@ CHECK_ARG:
|
||||
}
|
||||
|
||||
while (!BobCC.incoming)
|
||||
iterate_tox(bootstrap, AliceAV, BobAV);
|
||||
iterate_tox(bootstrap, AliceAV, BobAV, NULL);
|
||||
|
||||
{ /* Answer */
|
||||
TOXAV_ERR_ANSWER rc;
|
||||
@@ -690,7 +697,7 @@ CHECK_ARG:
|
||||
}
|
||||
}
|
||||
|
||||
iterate_tox(bootstrap, AliceAV, BobAV);
|
||||
iterate_tox(bootstrap, AliceAV, BobAV, NULL);
|
||||
|
||||
/* Start decode thread */
|
||||
struct toxav_thread_data data = {
|
||||
@@ -721,7 +728,7 @@ CHECK_ARG:
|
||||
break;
|
||||
|
||||
send_opencv_img(AliceAV, 0, frame);
|
||||
iterate_tox(bootstrap, AliceAV, BobAV);
|
||||
iterate_tox(bootstrap, AliceAV, BobAV, NULL);
|
||||
c_sleep(10);
|
||||
}
|
||||
|
||||
@@ -737,7 +744,7 @@ CHECK_ARG:
|
||||
}
|
||||
}
|
||||
|
||||
iterate_tox(bootstrap, AliceAV, BobAV);
|
||||
iterate_tox(bootstrap, AliceAV, BobAV, NULL);
|
||||
assert(BobCC.state == TOXAV_FRIEND_CALL_STATE_FINISHED);
|
||||
|
||||
/* Stop decode thread */
|
||||
|
||||
Reference in New Issue
Block a user