Work around bug in opencv3 headers.

OpenCV 3.1 doesn't define cvRound in C, only in C++. Thus, we now need
to compile av_test as C++ code.
This commit is contained in:
iphydf 2016-09-22 00:42:14 +01:00
parent f60900c4b8
commit d369448ace
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
4 changed files with 29 additions and 13 deletions

View File

@ -289,6 +289,11 @@ if(NOT WIN32 AND BUILD_TOXAV AND SNDFILE_FOUND AND PORTAUDIO_FOUND AND OPENCV_FO
${OPENCV_LIBRARIES} ${OPENCV_LIBRARIES}
${PORTAUDIO_LIBRARIES} ${PORTAUDIO_LIBRARIES}
${SNDFILE_LIBRARIES}) ${SNDFILE_LIBRARIES})
# Due to https://github.com/opencv/opencv/issues/6585, we need to compile
# av_test as C++ for newer OpenCV versions.
if(NOT OPENCV_VERSION VERSION_LESS 3)
set_source_files_properties(testing/av_test.c PROPERTIES LANGUAGE CXX)
endif()
endif() endif()
if(NOT WIN32) if(NOT WIN32)

View File

@ -20,8 +20,8 @@ if ! which "$ASTYLE"; then
exit 1 exit 1
fi fi
if [ -f ../apidsl/_build/apigen.native ]; then if [ -f ../apidsl/apigen.native ]; then
APIDSL=../apidsl/_build/apigen.native APIDSL=../apidsl/apigen.native
else else
APIDSL=apidsl_curl APIDSL=apidsl_curl
fi fi

View File

@ -22,6 +22,10 @@
* -lopencv_highgui -lopencv_imgproc -lsndfile -pthread -lvpx -lopus -lsodium -lportaudio * -lopencv_highgui -lopencv_imgproc -lsndfile -pthread -lvpx -lopus -lsodium -lportaudio
*/ */
#ifdef __cplusplus
extern "C" {
#endif
// XXX: Hack because toxav doesn't really expose ring_buffer, but this av test // XXX: Hack because toxav doesn't really expose ring_buffer, but this av test
// uses it. Not all of these functions are used, but when linking statically, // uses it. Not all of these functions are used, but when linking statically,
// not renaming them will cause multiple definition errors, so we need to rename // not renaming them will cause multiple definition errors, so we need to rename
@ -37,12 +41,15 @@
#define rb_data test_rb_data #define rb_data test_rb_data
#include "../toxav/ring_buffer.c" #include "../toxav/ring_buffer.c"
#include "../toxav/ring_buffer.h"
#include "../toxav/toxav.h" #include "../toxav/toxav.h"
#include "../toxcore/network.h" /* current_time_monotonic() */ #include "../toxcore/network.h" /* current_time_monotonic() */
#include "../toxcore/tox.h" #include "../toxcore/tox.h"
#include "../toxcore/util.h" #include "../toxcore/util.h"
#ifdef __cplusplus
}
#endif
/* Playing audio data */ /* Playing audio data */
#include <portaudio.h> #include <portaudio.h>
/* Reading audio */ /* Reading audio */
@ -175,7 +182,9 @@ static void t_toxav_receive_video_frame_cb(ToxAV *av, uint32_t friend_number,
CvMat mat = cvMat(height, width, CV_8UC3, img_data); CvMat mat = cvMat(height, width, CV_8UC3, img_data);
CvSize sz = {.height = height, .width = width}; CvSize sz;
sz.height = height;
sz.width = width;
IplImage *header = cvCreateImageHeader(sz, 1, 3); IplImage *header = cvCreateImageHeader(sz, 1, 3);
IplImage *img = cvGetImage(&mat, header); IplImage *img = cvGetImage(&mat, header);
@ -598,9 +607,9 @@ CHECK_ARG:
/* Start decode thread */ /* Start decode thread */
struct toxav_thread_data data = { struct toxav_thread_data data = {
.AliceAV = AliceAV, AliceAV,
.BobAV = BobAV, BobAV,
.sig = 0 0,
}; };
pthread_t dect; pthread_t dect;
@ -723,9 +732,9 @@ CHECK_ARG:
/* Start decode thread */ /* Start decode thread */
struct toxav_thread_data data = { struct toxav_thread_data data = {
.AliceAV = AliceAV, AliceAV,
.BobAV = BobAV, BobAV,
.sig = 0 0,
}; };
pthread_t dect; pthread_t dect;
@ -739,7 +748,9 @@ CHECK_ARG:
exit(1); exit(1);
} }
// toxav_video_bit_rate_set(AliceAV, 0, 5000, false, NULL); #if 0
toxav_video_bit_rate_set(AliceAV, 0, 5000, false, NULL);
#endif
time_t start_time = time(NULL); time_t start_time = time(NULL);

View File

@ -47,7 +47,7 @@ bool rb_read(RingBuffer *b, void **p)
} }
RingBuffer *rb_new(int size) RingBuffer *rb_new(int size)
{ {
RingBuffer *buf = calloc(sizeof(RingBuffer), 1); RingBuffer *buf = (RingBuffer *)calloc(sizeof(RingBuffer), 1);
if (!buf) { if (!buf) {
return NULL; return NULL;
@ -55,7 +55,7 @@ RingBuffer *rb_new(int size)
buf->size = size + 1; /* include empty elem */ buf->size = size + 1; /* include empty elem */
if (!(buf->data = calloc(buf->size, sizeof(void *)))) { if (!(buf->data = (void **)calloc(buf->size, sizeof(void *)))) {
free(buf); free(buf);
return NULL; return NULL;
} }