PROJECT(aitt VERSION 0.0.1 LANGUAGES CXX)
SET_PROPERTY(GLOBAL PROPERTY GLOBAL_DEPENDS_DEBUG_MODE 0)
SET(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
-SET(CMAKE_CXX_STANDARD 17)
+SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_EXTENSIONS OFF)
// The broken clientTable or subscribeTable
}
- std::unique_ptr<TCP> client(std::make_unique<TCP>(host, portIt->first));
+ std::unique_ptr<TCP> client(new TCP(host, portIt->first));
// TODO:
// If the client gets disconnected,
}
}
-void Module::SendExactSize(Module::PortMap::iterator &port_iterator, const void *data, size_t data_length)
+void Module::SendExactSize(Module::PortMap::iterator &port_iterator, const void *data,
+ size_t data_length)
{
size_t remaining_size = data_length;
while (0 < remaining_size) {
std::unique_ptr<TCP::Server> tcpServer;
unsigned short port = 0;
- tcpServer = std::make_unique<TCP::Server>("0.0.0.0", port);
+ tcpServer = std::unique_ptr<TCP::Server>(new TCP::Server("0.0.0.0", port));
TCPServerData *listen_info = new TCPServerData;
listen_info->impl = this;
listen_info->cb = cb;
class AittTcpSample {
public:
AittTcpSample(const std::string &host, unsigned short &port)
- : server(std::make_unique<TCP::Server>(host, port))
+ : server(new TCP::Server(host, port))
{
}
virtual ~AittTcpSample(void) {}
SEND_INTERVAL,
[](gpointer data) -> gboolean {
Main *ctx = static_cast<Main *>(data);
- std::unique_ptr<TCP> client(std::make_unique<TCP>(ctx->host, ctx->port));
+ std::unique_ptr<TCP> client(new TCP(ctx->host, ctx->port));
INFO("Assigned client port: %u", client->GetPort());
TEST(TCPServer, Positive_Create_Anytime)
{
unsigned short port = TEST_SERVER_PORT;
- std::unique_ptr<TCP::Server> tcp(std::make_unique<TCP::Server>(TEST_SERVER_ADDRESS, port));
+ std::unique_ptr<TCP::Server> tcp(new TCP::Server(TEST_SERVER_ADDRESS, port));
ASSERT_NE(tcp, nullptr);
}
try {
unsigned short port = TEST_SERVER_PORT;
- std::unique_ptr<TCP::Server> tcp(
- std::make_unique<TCP::Server>(TEST_SERVER_INVALID_ADDRESS, port));
+ std::unique_ptr<TCP::Server> tcp(new TCP::Server(TEST_SERVER_INVALID_ADDRESS, port));
ASSERT_EQ(tcp, nullptr);
} catch (std::exception &e) {
ASSERT_STREQ(e.what(), strerror(EINVAL));
TEST(TCPServer, Positive_Create_AutoPort_Anytime)
{
unsigned short port = TEST_SERVER_AVAILABLE_PORT;
- std::unique_ptr<TCP::Server> tcp(std::make_unique<TCP::Server>(TEST_SERVER_ADDRESS, port));
+ std::unique_ptr<TCP::Server> tcp(new TCP::Server(TEST_SERVER_ADDRESS, port));
ASSERT_NE(tcp, nullptr);
ASSERT_NE(port, 0);
}
TEST(TCPServer, Positive_GetPort_Anytime)
{
unsigned short port = TEST_SERVER_PORT;
- std::unique_ptr<TCP::Server> tcp(std::make_unique<TCP::Server>(TEST_SERVER_ADDRESS, port));
+ std::unique_ptr<TCP::Server> tcp(new TCP::Server(TEST_SERVER_ADDRESS, port));
ASSERT_NE(tcp, nullptr);
ASSERT_EQ(tcp->GetPort(), TEST_SERVER_PORT);
}
TEST(TCPServer, Positive_GetHandle_Anytime)
{
unsigned short port = TEST_SERVER_PORT;
- std::unique_ptr<TCP::Server> tcp(std::make_unique<TCP::Server>(TEST_SERVER_ADDRESS, port));
+ std::unique_ptr<TCP::Server> tcp(new TCP::Server(TEST_SERVER_ADDRESS, port));
ASSERT_NE(tcp, nullptr);
ASSERT_GE(tcp->GetHandle(), 0);
}
TEST(TCPServer, Positive_GetPort_AutoPort_Anytime)
{
unsigned short port = TEST_SERVER_AVAILABLE_PORT;
- std::unique_ptr<TCP::Server> tcp(std::make_unique<TCP::Server>(TEST_SERVER_ADDRESS, port));
+ std::unique_ptr<TCP::Server> tcp(new TCP::Server(TEST_SERVER_ADDRESS, port));
ASSERT_NE(tcp, nullptr);
ASSERT_EQ(tcp->GetPort(), port);
}
unsigned short serverPort = TEST_SERVER_PORT;
std::thread serverThread(
[serverPort, &m, &ready, &connected, &ready_cv, &connected_cv](void) mutable -> void {
- std::unique_ptr<TCP::Server> tcp(
- std::make_unique<TCP::Server>(TEST_SERVER_ADDRESS, serverPort));
+ std::unique_ptr<TCP::Server> tcp(new TCP::Server(TEST_SERVER_ADDRESS, serverPort));
{
std::lock_guard<std::mutex> lk(m);
ready = true;
{
std::unique_lock<std::mutex> lk(m);
ready_cv.wait(lk, [&ready] { return ready; });
- std::unique_ptr<TCP> tcp(std::make_unique<TCP>(TEST_SERVER_ADDRESS, serverPort));
+ std::unique_ptr<TCP> tcp(new TCP(TEST_SERVER_ADDRESS, serverPort));
connected_cv.wait(lk, [&connected] { return connected; });
}
clientThread = std::thread([this](void) mutable -> void {
std::unique_lock<std::mutex> lk(m);
ready_cv.wait(lk, [this] { return ready; });
- client = std::make_unique<TCP>(TEST_SERVER_ADDRESS, serverPort);
+ client = std::unique_ptr<TCP>(new TCP(TEST_SERVER_ADDRESS, serverPort));
customTest();
});
void RunServer(void)
{
- tcp = std::make_unique<TCP::Server>(TEST_SERVER_ADDRESS, serverPort);
+ tcp = std::unique_ptr<TCP::Server>(new TCP::Server(TEST_SERVER_ADDRESS, serverPort));
{
std::lock_guard<std::mutex> lk(m);
ready = true;
TEST(TCP, Negative_Create_InvalidPort_Anytime)
{
try {
- std::unique_ptr<TCP> tcp(
- std::make_unique<TCP>(TEST_SERVER_ADDRESS, TEST_SERVER_AVAILABLE_PORT));
+ std::unique_ptr<TCP> tcp(new TCP(TEST_SERVER_ADDRESS, TEST_SERVER_AVAILABLE_PORT));
ASSERT_EQ(tcp, nullptr);
} catch (std::exception &e) {
ASSERT_STREQ(e.what(), strerror(EINVAL));
TEST(TCP, Negative_Create_InvalidAddress_Anytime)
{
try {
- std::unique_ptr<TCP> tcp(
- std::make_unique<TCP>(TEST_SERVER_INVALID_ADDRESS, TEST_SERVER_PORT));
+ std::unique_ptr<TCP> tcp(new TCP(TEST_SERVER_INVALID_ADDRESS, TEST_SERVER_PORT));
ASSERT_EQ(tcp, nullptr);
} catch (std::exception &e) {
ASSERT_STREQ(e.what(), strerror(EINVAL));
return false;
}
- camera_handler_ = std::make_unique<CameraHandler>();
+ camera_handler_ = std::unique_ptr<CameraHandler>(new CameraHandler());
camera_handler_->Init(OnMediaPacketPreview, this);
auto ret = webrtc_add_media_source(webrtc_handle_, WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET,
#include <memory>
#include <mutex>
#include <string>
+#include <vector>
// TODO: webrtc.h is very heavy header file.
// I think we need to decide whether to include this or not
private:
webrtc_h webrtc_handle_;
- std::shared_ptr<CameraHandler> camera_handler_;
+ std::unique_ptr<CameraHandler> camera_handler_;
// DO we need to make is_source_overflow_ as atomic?
bool is_source_overflow_;
unsigned int source_id_;
if (ip_addr.empty())
valid_ip = "127.0.0.1";
- pImpl = std::make_unique<AITT::Impl>(*this, valid_id, valid_ip, option.GetClearSession());
+ pImpl = std::unique_ptr<AITT::Impl>(
+ new AITT::Impl(*this, valid_id, valid_ip, option.GetClearSession()));
}
AITT::~AITT(void)
#include <glib.h>
#include <gtest/gtest.h>
-#include <sys/random.h>
-#include <thread>
+#include <random>
#include "aitt_internal.h"
#include "aitt_tests.h"
TEST_F(AITTTest, TCP_Publish_Disconnect_Anytime)
{
try {
- char dump_msg[204800] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
- int dump_msg_size = getrandom(dump_msg, sizeof(dump_msg), 0);
- if (-1 == dump_msg_size) {
- ERR("getrandom() Fail(%d)", errno);
- dump_msg_size = 62;
+ const char character_set[] =
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+ std::mt19937 random_gen{std::random_device{}()};
+ std::uniform_int_distribution<std::string::size_type> gen(0, 61);
+
+ char dump_msg[204800] = {};
+ for (size_t i = 0; i < sizeof(dump_msg); i++) {
+ dump_msg[i] = character_set[gen(random_gen)];
}
AITT aitt(clientId, LOCAL_IP);
sleep(SLEEP_MS);
for (int i = 0; i < 10; i++) {
- INFO("size = %d", dump_msg_size);
- aitt1.Publish("test/stress1", dump_msg, dump_msg_size, AITT_TYPE_TCP,
+ INFO("size = %zu", sizeof(dump_msg));
+ aitt1.Publish("test/stress1", dump_msg, sizeof(dump_msg), AITT_TYPE_TCP,
AITT_QOS_AT_MOST_ONCE, true);
}
g_timeout_add(10, AittTests::ReadyCheck, static_cast<AittTests *>(this));
ASSERT_TRUE(ready);
ready = false;
- aitt_retry.Publish("test/stress1", dump_msg, dump_msg_size, AITT_TYPE_TCP,
+ aitt_retry.Publish("test/stress1", dump_msg, sizeof(dump_msg), AITT_TYPE_TCP,
AITT_QOS_AT_MOST_ONCE, true);
g_timeout_add(10, AittTests::ReadyCheck, static_cast<AittTests *>(this));