diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-09-22 00:42:14 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-09-25 01:58:51 +0100 |
commit | d369448ace7ab9b77b6f0e644fdb42ff8dc9a31d (patch) | |
tree | 7b0435adf621698cb8698c464b7140776cf6b739 | |
parent | f60900c4b813abbce213db6de217837645c6590e (diff) |
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.
-rw-r--r-- | CMakeLists.txt | 5 | ||||
-rwxr-xr-x | other/astyle/format-source | 4 | ||||
-rw-r--r-- | testing/av_test.c | 29 | ||||
-rw-r--r-- | toxav/ring_buffer.c | 4 |
4 files changed, 29 insertions, 13 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 58e3e673..bbb9a014 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -289,6 +289,11 @@ if(NOT WIN32 AND BUILD_TOXAV AND SNDFILE_FOUND AND PORTAUDIO_FOUND AND OPENCV_FO | |||
289 | ${OPENCV_LIBRARIES} | 289 | ${OPENCV_LIBRARIES} |
290 | ${PORTAUDIO_LIBRARIES} | 290 | ${PORTAUDIO_LIBRARIES} |
291 | ${SNDFILE_LIBRARIES}) | 291 | ${SNDFILE_LIBRARIES}) |
292 | # Due to https://github.com/opencv/opencv/issues/6585, we need to compile | ||
293 | # av_test as C++ for newer OpenCV versions. | ||
294 | if(NOT OPENCV_VERSION VERSION_LESS 3) | ||
295 | set_source_files_properties(testing/av_test.c PROPERTIES LANGUAGE CXX) | ||
296 | endif() | ||
292 | endif() | 297 | endif() |
293 | 298 | ||
294 | if(NOT WIN32) | 299 | if(NOT WIN32) |
diff --git a/other/astyle/format-source b/other/astyle/format-source index 157f0fec..47a4a420 100755 --- a/other/astyle/format-source +++ b/other/astyle/format-source | |||
@@ -20,8 +20,8 @@ if ! which "$ASTYLE"; then | |||
20 | exit 1 | 20 | exit 1 |
21 | fi | 21 | fi |
22 | 22 | ||
23 | if [ -f ../apidsl/_build/apigen.native ]; then | 23 | if [ -f ../apidsl/apigen.native ]; then |
24 | APIDSL=../apidsl/_build/apigen.native | 24 | APIDSL=../apidsl/apigen.native |
25 | else | 25 | else |
26 | APIDSL=apidsl_curl | 26 | APIDSL=apidsl_curl |
27 | fi | 27 | fi |
diff --git a/testing/av_test.c b/testing/av_test.c index 637fb9ac..04605468 100644 --- a/testing/av_test.c +++ b/testing/av_test.c | |||
@@ -22,6 +22,10 @@ | |||
22 | * -lopencv_highgui -lopencv_imgproc -lsndfile -pthread -lvpx -lopus -lsodium -lportaudio | 22 | * -lopencv_highgui -lopencv_imgproc -lsndfile -pthread -lvpx -lopus -lsodium -lportaudio |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #ifdef __cplusplus | ||
26 | extern "C" { | ||
27 | #endif | ||
28 | |||
25 | // XXX: Hack because toxav doesn't really expose ring_buffer, but this av test | 29 | // XXX: Hack because toxav doesn't really expose ring_buffer, but this av test |
26 | // uses it. Not all of these functions are used, but when linking statically, | 30 | // uses it. Not all of these functions are used, but when linking statically, |
27 | // not renaming them will cause multiple definition errors, so we need to rename | 31 | // not renaming them will cause multiple definition errors, so we need to rename |
@@ -37,12 +41,15 @@ | |||
37 | #define rb_data test_rb_data | 41 | #define rb_data test_rb_data |
38 | #include "../toxav/ring_buffer.c" | 42 | #include "../toxav/ring_buffer.c" |
39 | 43 | ||
40 | #include "../toxav/ring_buffer.h" | ||
41 | #include "../toxav/toxav.h" | 44 | #include "../toxav/toxav.h" |
42 | #include "../toxcore/network.h" /* current_time_monotonic() */ | 45 | #include "../toxcore/network.h" /* current_time_monotonic() */ |
43 | #include "../toxcore/tox.h" | 46 | #include "../toxcore/tox.h" |
44 | #include "../toxcore/util.h" | 47 | #include "../toxcore/util.h" |
45 | 48 | ||
49 | #ifdef __cplusplus | ||
50 | } | ||
51 | #endif | ||
52 | |||
46 | /* Playing audio data */ | 53 | /* Playing audio data */ |
47 | #include <portaudio.h> | 54 | #include <portaudio.h> |
48 | /* Reading audio */ | 55 | /* Reading audio */ |
@@ -175,7 +182,9 @@ static void t_toxav_receive_video_frame_cb(ToxAV *av, uint32_t friend_number, | |||
175 | 182 | ||
176 | CvMat mat = cvMat(height, width, CV_8UC3, img_data); | 183 | CvMat mat = cvMat(height, width, CV_8UC3, img_data); |
177 | 184 | ||
178 | CvSize sz = {.height = height, .width = width}; | 185 | CvSize sz; |
186 | sz.height = height; | ||
187 | sz.width = width; | ||
179 | 188 | ||
180 | IplImage *header = cvCreateImageHeader(sz, 1, 3); | 189 | IplImage *header = cvCreateImageHeader(sz, 1, 3); |
181 | IplImage *img = cvGetImage(&mat, header); | 190 | IplImage *img = cvGetImage(&mat, header); |
@@ -598,9 +607,9 @@ CHECK_ARG: | |||
598 | 607 | ||
599 | /* Start decode thread */ | 608 | /* Start decode thread */ |
600 | struct toxav_thread_data data = { | 609 | struct toxav_thread_data data = { |
601 | .AliceAV = AliceAV, | 610 | AliceAV, |
602 | .BobAV = BobAV, | 611 | BobAV, |
603 | .sig = 0 | 612 | 0, |
604 | }; | 613 | }; |
605 | 614 | ||
606 | pthread_t dect; | 615 | pthread_t dect; |
@@ -723,9 +732,9 @@ CHECK_ARG: | |||
723 | 732 | ||
724 | /* Start decode thread */ | 733 | /* Start decode thread */ |
725 | struct toxav_thread_data data = { | 734 | struct toxav_thread_data data = { |
726 | .AliceAV = AliceAV, | 735 | AliceAV, |
727 | .BobAV = BobAV, | 736 | BobAV, |
728 | .sig = 0 | 737 | 0, |
729 | }; | 738 | }; |
730 | 739 | ||
731 | pthread_t dect; | 740 | pthread_t dect; |
@@ -739,7 +748,9 @@ CHECK_ARG: | |||
739 | exit(1); | 748 | exit(1); |
740 | } | 749 | } |
741 | 750 | ||
742 | // toxav_video_bit_rate_set(AliceAV, 0, 5000, false, NULL); | 751 | #if 0 |
752 | toxav_video_bit_rate_set(AliceAV, 0, 5000, false, NULL); | ||
753 | #endif | ||
743 | 754 | ||
744 | time_t start_time = time(NULL); | 755 | time_t start_time = time(NULL); |
745 | 756 | ||
diff --git a/toxav/ring_buffer.c b/toxav/ring_buffer.c index cef3e943..94091c54 100644 --- a/toxav/ring_buffer.c +++ b/toxav/ring_buffer.c | |||
@@ -47,7 +47,7 @@ bool rb_read(RingBuffer *b, void **p) | |||
47 | } | 47 | } |
48 | RingBuffer *rb_new(int size) | 48 | RingBuffer *rb_new(int size) |
49 | { | 49 | { |
50 | RingBuffer *buf = calloc(sizeof(RingBuffer), 1); | 50 | RingBuffer *buf = (RingBuffer *)calloc(sizeof(RingBuffer), 1); |
51 | 51 | ||
52 | if (!buf) { | 52 | if (!buf) { |
53 | return NULL; | 53 | return NULL; |
@@ -55,7 +55,7 @@ RingBuffer *rb_new(int size) | |||
55 | 55 | ||
56 | buf->size = size + 1; /* include empty elem */ | 56 | buf->size = size + 1; /* include empty elem */ |
57 | 57 | ||
58 | if (!(buf->data = calloc(buf->size, sizeof(void *)))) { | 58 | if (!(buf->data = (void **)calloc(buf->size, sizeof(void *)))) { |
59 | free(buf); | 59 | free(buf); |
60 | return NULL; | 60 | return NULL; |
61 | } | 61 | } |