Skip to content
Draft
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,9 @@ if(BUILD_TOXAV)
toxav/rtp.h
toxav/toxav.c
toxav/toxav.h
toxav/toxav_compat.c
toxav/toxav_old.c
toxav/toxav_private.h
toxav/video.c
toxav/video.h)
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
Expand Down
62 changes: 56 additions & 6 deletions toxav/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -261,22 +261,55 @@ cc_test(
],
)

cc_library(
name = "toxav_core",
srcs = ["toxav.c"],
hdrs = [
"toxav.h",
"toxav_private.h",
],
deps = [
":audio",
":bwcontroller",
":msi",
":rtp",
":video",
"//c-toxcore/toxcore:Messenger",
"//c-toxcore/toxcore:ccompat",
"//c-toxcore/toxcore:logger",
"//c-toxcore/toxcore:mono_time",
"//c-toxcore/toxcore:net_crypto",
"//c-toxcore/toxcore:network",
"//c-toxcore/toxcore:tox",
"//c-toxcore/toxcore:util",
"@libsodium",
"@opus",
],
)

cc_test(
name = "toxav_test",
size = "small",
srcs = ["toxav_test.cc"],
deps = [
":av_test_support",
":toxav_core",
"@com_google_googletest//:gtest_main",
],
)

cc_library(
name = "toxav",
srcs = [
"groupav.c",
"groupav.h",
"toxav.c",
"toxav_compat.c",
"toxav_old.c",
],
hdrs = ["toxav.h"],
visibility = ["//c-toxcore:__subpackages__"],
deps = [
":audio",
":bwcontroller",
":msi",
":rtp",
":video",
":toxav_core",
"//c-toxcore/toxcore:Messenger",
"//c-toxcore/toxcore:ccompat",
"//c-toxcore/toxcore:group",
Expand All @@ -299,3 +332,20 @@ sh_library(
]),
visibility = ["//c-toxcore/testing:__pkg__"],
)

cc_fuzz_test(
name = "toxav_fuzz_test",
srcs = ["toxav_fuzz_test.cc"],
copts = ["-UNDEBUG"],
# corpus = ["//tools/toktok-fuzzer/corpus:toxav_fuzz_test"],
deps = [
":toxav_core",
"//c-toxcore/testing/fuzzing:fuzz_support",
],
)

cc_binary(
name = "toxav_fuzz_seed_gen",
srcs = ["toxav_fuzz_seed_gen.cc"],
visibility = ["//visibility:public"],
)
4 changes: 3 additions & 1 deletion toxav/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ libtoxav_la_SOURCES = ../toxav/rtp.h \
../toxav/ring_buffer.c \
../toxav/toxav.h \
../toxav/toxav.c \
../toxav/toxav_old.c
../toxav/toxav_compat.c \
../toxav/toxav_old.c \
../toxav/toxav_private.h

libtoxav_la_CFLAGS = -I../toxcore \
-I../toxav \
Expand Down
18 changes: 18 additions & 0 deletions toxav/av_test_support.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ int RtpMock::noop_cb(const Mono_Time * /*mono_time*/, void * /*cs*/, RTPMessage
void fill_audio_frame(uint32_t sampling_rate, uint8_t channels, int frame_index,
size_t sample_count, std::vector<int16_t> &pcm)
{
if (pcm.size() < sample_count * channels) {
pcm.resize(sample_count * channels);
}

const double pi = std::acos(-1.0);
double amplitude = 10000.0;

Expand All @@ -68,6 +72,10 @@ void fill_audio_frame(uint32_t sampling_rate, uint8_t channels, int frame_index,

void fill_silent_frame(uint8_t channels, size_t sample_count, std::vector<int16_t> &pcm)
{
if (pcm.size() < sample_count * channels) {
pcm.resize(sample_count * channels);
}

for (size_t i = 0; i < sample_count * channels; ++i) {
// Very low amplitude white noise (simulating silence with background hiss)
pcm[i] = (std::rand() % 21) - 10;
Expand All @@ -92,6 +100,16 @@ void AudioTestData::receive_frame(uint32_t friend_number, const int16_t *pcm, si
void fill_video_frame(uint16_t width, uint16_t height, int frame_index, std::vector<uint8_t> &y,
std::vector<uint8_t> &u, std::vector<uint8_t> &v)
{
size_t y_size = static_cast<size_t>(width) * height;
size_t uv_size = y_size / 4;

if (y.size() < y_size)
y.resize(y_size);
if (u.size() < uv_size)
u.resize(uv_size);
if (v.size() < uv_size)
v.resize(uv_size);

// Background (dark gray)
std::fill(y.begin(), y.end(), 32);
std::fill(u.begin(), u.end(), 128);
Expand Down
1 change: 1 addition & 0 deletions toxav/msi.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define C_TOXCORE_TOXAV_MSI_H

#include <pthread.h>
#include <stddef.h>
#include <stdint.h>

#include "../toxcore/logger.h"
Expand Down
Loading
Loading