Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around bug in opencv3 headers. #160

Merged
merged 1 commit into from
Sep 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,11 @@ if(NOT WIN32 AND BUILD_TOXAV AND SNDFILE_FOUND AND PORTAUDIO_FOUND AND OPENCV_FO
${OPENCV_LIBRARIES}
${PORTAUDIO_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()

if(NOT WIN32)
Expand Down
4 changes: 2 additions & 2 deletions other/astyle/format-source
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ if ! which "$ASTYLE"; then
exit 1
fi

if [ -f ../apidsl/_build/apigen.native ]; then
APIDSL=../apidsl/_build/apigen.native
if [ -f ../apidsl/apigen.native ]; then
APIDSL=../apidsl/apigen.native
else
APIDSL=apidsl_curl
fi
Expand Down
29 changes: 20 additions & 9 deletions testing/av_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
* -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
// 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
Expand All @@ -37,12 +41,15 @@
#define rb_data test_rb_data
#include "../toxav/ring_buffer.c"

#include "../toxav/ring_buffer.h"
#include "../toxav/toxav.h"
#include "../toxcore/network.h" /* current_time_monotonic() */
#include "../toxcore/tox.h"
#include "../toxcore/util.h"

#ifdef __cplusplus
}
#endif

/* Playing audio data */
#include <portaudio.h>
/* Reading audio */
Expand Down Expand Up @@ -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);

CvSize sz = {.height = height, .width = width};
CvSize sz;
sz.height = height;
sz.width = width;

IplImage *header = cvCreateImageHeader(sz, 1, 3);
IplImage *img = cvGetImage(&mat, header);
Expand Down Expand Up @@ -598,9 +607,9 @@ int main(int argc, char **argv)

/* Start decode thread */
struct toxav_thread_data data = {
.AliceAV = AliceAV,
.BobAV = BobAV,
.sig = 0
AliceAV,
BobAV,
0,
};

pthread_t dect;
Expand Down Expand Up @@ -723,9 +732,9 @@ int main(int argc, char **argv)

/* Start decode thread */
struct toxav_thread_data data = {
.AliceAV = AliceAV,
.BobAV = BobAV,
.sig = 0
AliceAV,
BobAV,
0,
};

pthread_t dect;
Expand All @@ -739,7 +748,9 @@ int main(int argc, char **argv)
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);

Expand Down
4 changes: 2 additions & 2 deletions toxav/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ bool rb_read(RingBuffer *b, void **p)
}
RingBuffer *rb_new(int size)
{
RingBuffer *buf = calloc(sizeof(RingBuffer), 1);
RingBuffer *buf = (RingBuffer *)calloc(sizeof(RingBuffer), 1);

if (!buf) {
return NULL;
}

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);
return NULL;
}
Expand Down