mirror of
https://github.com/fastogt/fastocloud.git
synced 2025-03-09 23:18:50 +00:00
Release 1.4.4
This commit is contained in:
commit
310132c21d
363 changed files with 32789 additions and 0 deletions
1
tests/data/yolov2_labels.txt
Normal file
1
tests/data/yolov2_labels.txt
Normal file
|
@ -0,0 +1 @@
|
|||
aeroplane;bicycle;bird;boat;bottle;bus;car;cat;chair;cow;diningtable;dog;horse;motorbike;person;pottedplant;sheep;sofa;train;tvmonitor
|
1
tests/data/yolov3_labels.txt
Normal file
1
tests/data/yolov3_labels.txt
Normal file
|
@ -0,0 +1 @@
|
|||
person;bicycle;car;motorbike;aeroplane;bus;train;truck;boat;traffic light;fire hydrant;stop sign;parking meter;bench;bird;cat;dog;horse;sheep;cow;elephant;bear;zebra;giraffe;backpack;umbrella;handbag;tie;suitcase;frisbee;skis;snowboard;sports ball;kite;baseball bat;baseball glove;skateboard;surfboard;tennis racket;bottle;wine glass;cup;fork;knife;spoon;bowl;banana;apple;sandwich;orange;broccoli;carrot;hot dog;pizza;donut;cake;chair;sofa;pottedplant;bed;diningtable;toilet;tvmonitor;laptop;mouse;remote;keyboard;cell phone;microwave;oven;toaster;sink;refrigerator;book;clock;vase;scissors;teddy bear;hair drier;toothbrush
|
55
tests/server/unit_test_server.cpp
Normal file
55
tests/server/unit_test_server.cpp
Normal file
|
@ -0,0 +1,55 @@
|
|||
/* Copyright (C) 2014-2019 FastoGT. All right reserved.
|
||||
This file is part of fastocloud.
|
||||
fastocloud is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
fastocloud is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "base/config_fields.h"
|
||||
#include "base/constants.h"
|
||||
#include "base/stream_config_parse.h"
|
||||
|
||||
#include "server/options/options.h"
|
||||
|
||||
namespace {
|
||||
const char kTimeshiftRecorderConfig[] = R"({
|
||||
"id" : "test_1",
|
||||
"input" : {"urls" : [ {"id" : 1, "uri" : "http://example.com/manager/fo/forward2.php?cid=14"} ]},
|
||||
"output" : {"urls" : [ {"id" : 80, "timeshift_dir" : "/var/www/html/live/14"} ]},
|
||||
"type" : 3
|
||||
})";
|
||||
}
|
||||
|
||||
TEST(Options, logo_path) {
|
||||
std::string cfg = "{\"" LOGO_FIELD "\" : {\"path\": \"file:///home/user/logo.png\"}}";
|
||||
fastocloud::StreamConfig args = fastocloud::MakeConfigFromJson(cfg);
|
||||
ASSERT_TRUE(args);
|
||||
common::ErrnoError err = fastocloud::server::options::ValidateConfig(args);
|
||||
ASSERT_FALSE(err);
|
||||
ASSERT_EQ(args->GetSize(), 1);
|
||||
|
||||
cfg = "{\"" LOGO_FIELD "\" : {\"path\": \"http://home/user/logo.png\"}}";
|
||||
args = fastocloud::MakeConfigFromJson(cfg);
|
||||
ASSERT_TRUE(args);
|
||||
err = fastocloud::server::options::ValidateConfig(args);
|
||||
ASSERT_FALSE(err);
|
||||
ASSERT_EQ(args->GetSize(), 1);
|
||||
}
|
||||
|
||||
TEST(Options, cfgs) {
|
||||
fastocloud::StreamConfig args = fastocloud::MakeConfigFromJson(kTimeshiftRecorderConfig);
|
||||
ASSERT_TRUE(args);
|
||||
|
||||
common::ErrnoError err = fastocloud::server::options::ValidateConfig(args);
|
||||
ASSERT_FALSE(err);
|
||||
ASSERT_EQ(args->GetSize(), 4);
|
||||
}
|
86
tests/stream/mock_test_job.cpp
Normal file
86
tests/stream/mock_test_job.cpp
Normal file
|
@ -0,0 +1,86 @@
|
|||
/* Copyright (C) 2014-2019 FastoGT. All right reserved.
|
||||
This file is part of fastocloud.
|
||||
fastocloud is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
fastocloud is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include "base/constants.h"
|
||||
|
||||
#include "stream/configs_factory.h"
|
||||
#include "stream/streams/screen_stream.h"
|
||||
|
||||
using testing::_;
|
||||
|
||||
class FakeObserver : public fastocloud::stream::IBaseStream::IStreamClient {
|
||||
public:
|
||||
MOCK_METHOD2(OnStatusChanged, void(fastocloud::stream::IBaseStream*, fastocloud::StreamStatus));
|
||||
MOCK_METHOD1(OnPipelineEOS, void(fastocloud::stream::IBaseStream*));
|
||||
MOCK_METHOD1(OnTimeoutUpdated, void(fastocloud::stream::IBaseStream*));
|
||||
MOCK_METHOD2(OnSyncMessageReceived, void(fastocloud::stream::IBaseStream*, GstMessage*));
|
||||
MOCK_METHOD2(OnASyncMessageReceived, void(fastocloud::stream::IBaseStream*, GstMessage*));
|
||||
MOCK_METHOD2(OnInputChanged, void(fastocloud::stream::IBaseStream*, const fastocloud::InputUri&));
|
||||
#if defined(MACHINE_LEARNING)
|
||||
MOCK_METHOD2(OnMlNotification, void(fastocloud::stream::IBaseStream*, const std::vector<fastotv::commands_info::ml::ImageBox>&));
|
||||
#endif
|
||||
GstPadProbeInfo* OnCheckReveivedOutputData(fastocloud::stream::IBaseStream* job,
|
||||
fastocloud::stream::OutputProbe* probe,
|
||||
GstPadProbeInfo* info) override {
|
||||
UNUSED(job);
|
||||
UNUSED(probe);
|
||||
return info;
|
||||
}
|
||||
GstPadProbeInfo* OnCheckReveivedData(fastocloud::stream::IBaseStream* job,
|
||||
fastocloud::stream::InputProbe* probe,
|
||||
GstPadProbeInfo* info) override {
|
||||
UNUSED(job);
|
||||
UNUSED(probe);
|
||||
return info;
|
||||
}
|
||||
MOCK_METHOD3(OnInputProbeEvent, void(fastocloud::stream::IBaseStream*, fastocloud::stream::InputProbe*, GstEvent*));
|
||||
MOCK_METHOD3(OnOutputProbeEvent, void(fastocloud::stream::IBaseStream*, fastocloud::stream::OutputProbe*, GstEvent*));
|
||||
MOCK_METHOD1(OnPipelineCreated, void(fastocloud::stream::IBaseStream*));
|
||||
};
|
||||
|
||||
void* quit_job(fastocloud::stream::IBaseStream* job) {
|
||||
sleep(5);
|
||||
job->Quit(fastocloud::stream::EXIT_SELF);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TEST(Job, Status) {
|
||||
fastocloud::output_t ouri;
|
||||
fastocloud::OutputUri uri;
|
||||
uri.SetOutput(common::uri::Url("screen"));
|
||||
ouri.push_back(uri);
|
||||
|
||||
FakeObserver cl;
|
||||
fastocloud::stream::streams_init(0, NULL);
|
||||
fastocloud::StreamStruct st(fastocloud::StreamInfo{"screen", fastotv::SCREEN, {}, {fastocloud::OutputUri(0, common::uri::Url(TEST_URL))}});
|
||||
fastocloud::stream::Config bconf(fastotv::SCREEN, 10, {fastocloud::InputUri(0, common::uri::Url(SCREEN_URL))},
|
||||
{fastocloud::OutputUri(0, common::uri::Url(TEST_URL))});
|
||||
fastocloud::stream::streams::AudioVideoConfig conf(bconf);
|
||||
fastocloud::stream::IBaseStream* job = new fastocloud::stream::streams::ScreenStream(&conf, &cl, &st);
|
||||
std::thread th(&quit_job, job);
|
||||
EXPECT_CALL(cl, OnStatusChanged(job, _)).Times(5);
|
||||
EXPECT_CALL(cl, OnTimeoutUpdated(job)).Times(::testing::AnyNumber());
|
||||
EXPECT_CALL(cl, OnSyncMessageReceived(job, _)).Times(::testing::AnyNumber());
|
||||
EXPECT_CALL(cl, OnInputProbeEvent(job, _, _)).Times(::testing::AnyNumber());
|
||||
EXPECT_CALL(cl, OnOutputProbeEvent(job, _, _)).Times(::testing::AnyNumber());
|
||||
job->Exec();
|
||||
th.join();
|
||||
delete job;
|
||||
}
|
44
tests/stream/unit_test_api.cpp
Normal file
44
tests/stream/unit_test_api.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* Copyright (C) 2014-2019 FastoGT. All right reserved.
|
||||
This file is part of fastocloud.
|
||||
fastocloud is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
fastocloud is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "base/config_fields.h"
|
||||
#include "base/constants.h"
|
||||
#include "base/inputs_outputs.h"
|
||||
|
||||
#include "stream/configs_factory.h"
|
||||
#include "stream/stypes.h"
|
||||
|
||||
TEST(Api, init) {
|
||||
fastocloud::StreamConfig emp;
|
||||
fastocloud::stream::Config* empty_api = nullptr;
|
||||
common::Error err = fastocloud::stream::make_config(emp, &empty_api);
|
||||
ASSERT_TRUE(err);
|
||||
fastocloud::output_t ouri;
|
||||
fastocloud::OutputUri uri;
|
||||
uri.SetOutput(common::uri::Url("screen"));
|
||||
ouri.push_back(uri);
|
||||
|
||||
ASSERT_TRUE(fastocloud::IsTestInputUrl(fastocloud::InputUri(0, common::uri::Url(TEST_URL))));
|
||||
ASSERT_TRUE(fastocloud::stream::IsScreenUrl(common::uri::Url(SCREEN_URL)));
|
||||
ASSERT_TRUE(fastocloud::stream::IsRecordingUrl(common::uri::Url(RECORDING_URL)));
|
||||
}
|
||||
|
||||
TEST(Api, logo) {
|
||||
fastocloud::output_t ouri;
|
||||
fastocloud::OutputUri uri2;
|
||||
uri2.SetOutput(common::uri::Url("screen"));
|
||||
ouri.push_back(uri2);
|
||||
}
|
34
tests/stream/unit_test_link_gen.cpp
Normal file
34
tests/stream/unit_test_link_gen.cpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* Copyright (C) 2014-2019 FastoGT. All right reserved.
|
||||
This file is part of fastocloud.
|
||||
fastocloud is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
fastocloud is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <common/file_system/file_system.h>
|
||||
|
||||
#include "stream/link_generator/streamlink.h"
|
||||
|
||||
TEST(StreamLinkGenerator, Generate) {
|
||||
std::string script_path_str;
|
||||
if (!common::file_system::find_file_in_path("streamlink", &script_path_str)) {
|
||||
return;
|
||||
}
|
||||
|
||||
common::file_system::ascii_file_string_path script_path(script_path_str);
|
||||
fastocloud::stream::link_generator::StreamLinkGenerator gena(script_path);
|
||||
fastocloud::InputUri out;
|
||||
fastocloud::InputUri url(0, common::uri::Url("https://www.youtube.com/watch?v=HVYJJirRADU"));
|
||||
url.SetStreamLink(true);
|
||||
ASSERT_TRUE(gena.Generate(url, &out));
|
||||
ASSERT_FALSE(url.Equals(out));
|
||||
}
|
62
tests/stream/unit_test_types.cpp
Normal file
62
tests/stream/unit_test_types.cpp
Normal file
|
@ -0,0 +1,62 @@
|
|||
/* Copyright (C) 2014-2019 FastoGT. All right reserved.
|
||||
This file is part of fastocloud.
|
||||
fastocloud is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
fastocloud is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "stream/stypes.h"
|
||||
|
||||
TEST(element_id_t, GetElementId) {
|
||||
fastocloud::stream::element_id_t id;
|
||||
ASSERT_FALSE(fastocloud::stream::GetElementId("udv_", nullptr));
|
||||
ASSERT_FALSE(fastocloud::stream::GetElementId("udv_", &id));
|
||||
ASSERT_FALSE(fastocloud::stream::GetElementId("udv_42_udv", &id));
|
||||
ASSERT_FALSE(fastocloud::stream::GetElementId("udv42", &id));
|
||||
ASSERT_FALSE(fastocloud::stream::GetElementId("_42", &id) && id == 42);
|
||||
ASSERT_TRUE(fastocloud::stream::GetElementId("udv_0", &id) && id == 0);
|
||||
ASSERT_TRUE(fastocloud::stream::GetElementId("udv_1", &id) && id == 1);
|
||||
ASSERT_TRUE(fastocloud::stream::GetElementId("udv_777", &id) && id == 777);
|
||||
ASSERT_TRUE(fastocloud::stream::GetElementId("udv_udv_777", &id) && id == 777);
|
||||
ASSERT_TRUE(fastocloud::stream::GetElementId("udv_udv1_udv_777", &id) && id == 777);
|
||||
ASSERT_TRUE(fastocloud::stream::GetElementId("queue2_776", &id) && id == 776);
|
||||
ASSERT_TRUE(fastocloud::stream::GetElementId("udv_24_udv_42", &id) && id == 42);
|
||||
}
|
||||
|
||||
TEST(element_id_t, GetPadId) {
|
||||
int id;
|
||||
ASSERT_FALSE(fastocloud::stream::GetPadId("udv_", nullptr));
|
||||
ASSERT_FALSE(fastocloud::stream::GetPadId("udv_", &id));
|
||||
ASSERT_FALSE(fastocloud::stream::GetPadId("udv_42_udv", &id));
|
||||
ASSERT_FALSE(fastocloud::stream::GetPadId("udv42", &id));
|
||||
ASSERT_FALSE(fastocloud::stream::GetPadId("_42", &id) && id == 42);
|
||||
ASSERT_TRUE(fastocloud::stream::GetPadId("udv_0", &id) && id == 0);
|
||||
ASSERT_TRUE(fastocloud::stream::GetPadId("udv_1", &id) && id == 1);
|
||||
ASSERT_TRUE(fastocloud::stream::GetPadId("udv_777", &id) && id == 777);
|
||||
ASSERT_TRUE(fastocloud::stream::GetPadId("udv_udv_777", &id) && id == 777);
|
||||
ASSERT_TRUE(fastocloud::stream::GetPadId("udv_udv1_udv_777", &id) && id == 777);
|
||||
ASSERT_TRUE(fastocloud::stream::GetPadId("queue2_776", &id) && id == 776);
|
||||
ASSERT_TRUE(fastocloud::stream::GetPadId("udv_24_udv_42", &id) && id == 42);
|
||||
}
|
||||
|
||||
TEST(m3u8, GetIndexFromHttpTsTemplate) {
|
||||
uint64_t ind;
|
||||
ASSERT_TRUE(fastocloud::stream::GetIndexFromHttpTsTemplate("123_324.ts", &ind));
|
||||
ASSERT_EQ(ind, 324);
|
||||
|
||||
uint64_t ind2;
|
||||
ASSERT_TRUE(fastocloud::stream::GetIndexFromHttpTsTemplate("123_0.ts", &ind2));
|
||||
ASSERT_EQ(ind2, 0);
|
||||
|
||||
uint64_t ind3;
|
||||
ASSERT_FALSE(fastocloud::stream::GetIndexFromHttpTsTemplate("123_g.ts", &ind3));
|
||||
}
|
129
tests/stream/workflow_tests.cpp
Normal file
129
tests/stream/workflow_tests.cpp
Normal file
|
@ -0,0 +1,129 @@
|
|||
/* Copyright (C) 2014-2019 FastoGT. All right reserved.
|
||||
This file is part of fastocloud.
|
||||
fastocloud is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
fastocloud is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include <common/file_system/file_system.h>
|
||||
#include <common/sprintf.h>
|
||||
|
||||
#include "stream/configs_factory.h"
|
||||
#include "stream/link_generator/streamlink.h"
|
||||
#include "stream/streams/screen_stream.h"
|
||||
#include "stream/streams_factory.h"
|
||||
|
||||
#include "base/config_fields.h"
|
||||
#include "base/stream_config_parse.h"
|
||||
|
||||
#define STREAMS_TRY_COUNT 10
|
||||
|
||||
#define SCREEN_SLEEP_SEC 10
|
||||
#define RELAY_SLEEP_SEC 10
|
||||
#define RELAY_PLAYLIST_SLEEP_SEC 10
|
||||
#define ENCODE_SLEEP_SEC 10
|
||||
#define TIMESHIFT_REC_SLEEP_SEC 10
|
||||
#define TIMESHIFT_PLAYLIST_SLEEP_SEC 10
|
||||
#define MOSAIC_SLEEP_SEC 10
|
||||
#define AD_SLEEP_SEC 10
|
||||
#define RELAY_AUDIO_SLEEP_SEC 10
|
||||
#define RELAY_VIDEO_SLEEP_SEC 10
|
||||
#define STATIC_IMAGE_SLEEP_SEC 10
|
||||
#define TEST_SLEEP_SEC 10
|
||||
#define CATCHUP_SLEEP_SEC 20
|
||||
#define M3U8LOG_SLEEP_SEC 10
|
||||
#define DIFF_SEC 1
|
||||
|
||||
#define YOLOV2_MODEL_GRAPH_PATH PROJECT_TEST_SOURCES_DIR "/data/graph_tinyyolov2_tensorflow.pb"
|
||||
#define YOLOV3_MODEL_GRAPH_PATH PROJECT_TEST_SOURCES_DIR "/data/graph_tinyyolov3_tensorflow.pb"
|
||||
#define YOLOV2_LABELS_GRAPH_PATH PROJECT_TEST_SOURCES_DIR "/data/yolov2_labels.txt"
|
||||
#define YOLOV3_LABELS_GRAPH_PATH PROJECT_TEST_SOURCES_DIR "/data/yolov3_labels.txt"
|
||||
|
||||
void* quit_job(fastocloud::stream::IBaseStream* job, uint32_t sleep_sec) {
|
||||
static unsigned int seed = time(NULL);
|
||||
int rand = rand_r(&seed) % (sleep_sec + DIFF_SEC);
|
||||
sleep(rand);
|
||||
job->Quit(fastocloud::stream::EXIT_SELF);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void check_encoders() {
|
||||
const std::string yuri =
|
||||
R"({"urls": [{"id": 115, "uri": "rtsp://admin:admin@192.168.1.168"}]})";
|
||||
const std::string enc_uri_str =
|
||||
R"({"urls": [{"id": 115, "uri": "tcp://localhost:1935"}]})";
|
||||
#if defined(MACHINE_LEARNING)
|
||||
const std::string deep_learning_str =
|
||||
"{\"model_path\": \"" YOLOV2_MODEL_GRAPH_PATH
|
||||
"\", \"backend\": 0, \"properties\": [{\"input\":\"input/Placeholder\"}, {\"output\":\"add_8\"}]}";
|
||||
const std::string deep_learning_overlay_str = "{\"labels_path\" : \"" YOLOV2_LABELS_GRAPH_PATH "\"}";
|
||||
#endif
|
||||
|
||||
fastocloud::StreamConfig config_args(new common::HashValue);
|
||||
config_args->Insert(ID_FIELD, common::Value::CreateStringValueFromBasicString("encoding"));
|
||||
config_args->Insert(TYPE_FIELD, common::Value::CreateIntegerValue(fastotv::ENCODE));
|
||||
config_args->Insert(HAVE_AUDIO_FIELD, common::Value::CreateBooleanValue(false));
|
||||
config_args->Insert(FEEDBACK_DIR_FIELD, common::Value::CreateStringValueFromBasicString("~"));
|
||||
config_args->Insert(VIDEO_CODEC_FIELD, common::Value::CreateStringValueFromBasicString("x264enc"));
|
||||
config_args->Insert(AUDIO_CODEC_FIELD, common::Value::CreateStringValueFromBasicString("faac"));
|
||||
config_args->Insert(SIZE_FIELD, common::Value::CreateStringValueFromBasicString("416x416"));
|
||||
// config_args->Insert(ASPECT_RATIO_FIELD, common::Value::CreateStringValueFromBasicString("3:4"));
|
||||
auto ihs = fastocloud::MakeConfigFromJson(yuri);
|
||||
config_args->Insert(INPUT_FIELD, ihs.release());
|
||||
auto ohs = fastocloud::MakeConfigFromJson(enc_uri_str);
|
||||
config_args->Insert(OUTPUT_FIELD, ohs.release());
|
||||
|
||||
#if defined(MACHINE_LEARNING)
|
||||
auto dep = fastocloud::MakeConfigFromJson(deep_learning_str);
|
||||
config_args->Insert(DEEP_LEARNING_FIELD, dep.release());
|
||||
config_args->Insert(DEEP_LEARNING_OVERLAY_FIELD, fastocloud::MakeConfigFromJson(deep_learning_overlay_str).release());
|
||||
#endif
|
||||
|
||||
std::string script_path_str;
|
||||
if (!common::file_system::find_file_in_path("streamlink", &script_path_str)) {
|
||||
return;
|
||||
}
|
||||
|
||||
common::file_system::ascii_file_string_path script_path(script_path_str);
|
||||
fastocloud::stream::link_generator::StreamLinkGenerator gena(script_path);
|
||||
static const auto test_url = common::uri::Url();
|
||||
|
||||
for (size_t i = 0; i < STREAMS_TRY_COUNT; ++i) {
|
||||
fastocloud::StreamStruct encoding(
|
||||
fastocloud::StreamInfo{common::MemSPrintf("encoding_%llu", i), fastotv::ENCODE, {fastocloud::InputUri(0, test_url)}, {fastocloud::OutputUri(0, test_url)}});
|
||||
fastocloud::stream::TimeShiftInfo tinf;
|
||||
fastocloud::stream::Config* lconfig = nullptr;
|
||||
common::Error err = fastocloud::stream::make_config(config_args, &lconfig);
|
||||
if (!err) {
|
||||
const std::unique_ptr<fastocloud::stream::Config> config_copy(
|
||||
fastocloud::stream::make_config_copy(lconfig, &gena));
|
||||
fastocloud::stream::IBaseStream* job_enc = fastocloud::stream::StreamsFactory::GetInstance().CreateStream(
|
||||
config_copy.get(), nullptr, &encoding, tinf, fastocloud::stream::invalid_chunk_index);
|
||||
std::thread th(quit_job, job_enc, ENCODE_SLEEP_SEC);
|
||||
CHECK(job_enc->GetType() == fastotv::ENCODE);
|
||||
job_enc->Exec();
|
||||
th.join();
|
||||
delete job_enc;
|
||||
delete lconfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
fastocloud::stream::streams_init(argc, argv);
|
||||
check_encoders();
|
||||
return 0;
|
||||
}
|
70
tests/unit_test_input_uri.cpp
Normal file
70
tests/unit_test_input_uri.cpp
Normal file
|
@ -0,0 +1,70 @@
|
|||
/* Copyright (C) 2014-2019 FastoGT. All right reserved.
|
||||
This file is part of fastocloud.
|
||||
fastocloud is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
fastocloud is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <json-c/json_object.h>
|
||||
|
||||
#include "base/input_uri.h"
|
||||
|
||||
#define RTMP_INPUT "rtmp://4.31.30.153:1935/devapp/tokengenffmpeg1"
|
||||
#define FILE_INPUT "file:///home/sasha/2.txt"
|
||||
#define DEVICE_VIDEO "/dev/video3"
|
||||
#define HW_30 "hw:3,0"
|
||||
#define DEVICE_AUDIO "audio=" HW_30
|
||||
#define PURPLE "purple"
|
||||
#define COLOR "color=" PURPLE
|
||||
#define QUERY DEVICE_AUDIO "&" COLOR
|
||||
#define DEVICE_INPUT "dev://" DEVICE_VIDEO "?" QUERY
|
||||
|
||||
TEST(InputUri, ConvertFromString) {
|
||||
const std::string invalid_uri_json = R"({ "id": 0, "uri": "", "user_agent": 0, "stream_link": false })";
|
||||
fastocloud::InputUri invalid_uri;
|
||||
ASSERT_EQ(invalid_uri.GetID(), 0);
|
||||
ASSERT_EQ(invalid_uri.GetInput(), common::uri::Url());
|
||||
std::string conv;
|
||||
common::Error err = invalid_uri.SerializeToString(&conv);
|
||||
ASSERT_FALSE(err);
|
||||
ASSERT_EQ(conv, invalid_uri_json);
|
||||
|
||||
const std::string uri_json = "{ \"id\": 1, \"uri\": \"" RTMP_INPUT "\"}";
|
||||
fastocloud::InputUri uri;
|
||||
err = uri.DeSerializeFromString(uri_json);
|
||||
ASSERT_FALSE(err);
|
||||
ASSERT_EQ(uri.GetID(), 1);
|
||||
common::uri::Url ro(RTMP_INPUT);
|
||||
ASSERT_EQ(uri.GetInput(), ro);
|
||||
const std::string file_uri_json = "{ \"id\": 2, \"uri\": \"" FILE_INPUT "\" }";
|
||||
fastocloud::InputUri file_uri;
|
||||
err = file_uri.DeSerializeFromString(file_uri_json);
|
||||
ASSERT_FALSE(err);
|
||||
ASSERT_EQ(file_uri.GetID(), 2);
|
||||
common::uri::Url file_ro(FILE_INPUT);
|
||||
ASSERT_EQ(file_uri.GetInput(), file_ro);
|
||||
|
||||
const std::string dev_uri_json = "{ \"id\": 2, \"uri\": \"" DEVICE_INPUT "\",\"user_agent\": 3 }";
|
||||
fastocloud::InputUri dev_uri;
|
||||
err = dev_uri.DeSerializeFromString(dev_uri_json);
|
||||
ASSERT_FALSE(err);
|
||||
ASSERT_EQ(dev_uri.GetID(), 2);
|
||||
common::uri::Url dev_ro(DEVICE_INPUT);
|
||||
ASSERT_EQ(dev_uri.GetInput(), dev_ro);
|
||||
ASSERT_TRUE(dev_ro.GetScheme() == common::uri::Url::dev);
|
||||
common::uri::Upath dpath = dev_ro.GetPath();
|
||||
ASSERT_EQ(dpath.GetPath(), DEVICE_VIDEO);
|
||||
ASSERT_EQ(dpath.GetQuery(), QUERY);
|
||||
auto params = dpath.GetQueryParams();
|
||||
ASSERT_EQ(params.size(), 2);
|
||||
ASSERT_EQ(dev_uri.GetUserAgent(), fastocloud::InputUri::WINK);
|
||||
}
|
47
tests/unit_test_output_uri.cpp
Normal file
47
tests/unit_test_output_uri.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* Copyright (C) 2014-2019 FastoGT. All right reserved.
|
||||
This file is part of fastocloud.
|
||||
fastocloud is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
fastocloud is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <common/macros.h>
|
||||
|
||||
#include "base/constants.h"
|
||||
#include "base/output_uri.h"
|
||||
|
||||
#define RTMP_OUTPUT "rtmp://4.31.30.153:1935/devapp/tokengenffmpeg1"
|
||||
#define HTTP_OUTPUT "/home/sasha/123/"
|
||||
|
||||
TEST(OutputUri, ConvertFromString) {
|
||||
const std::string invalid_uri_json = "{ \"id\": 0, \"uri\": \"\", \"http_root\": \"\", \"hls_type\": 0 }";
|
||||
fastocloud::OutputUri invalid_uri;
|
||||
ASSERT_EQ(invalid_uri.GetID(), 0);
|
||||
ASSERT_EQ(invalid_uri.GetOutput(), common::uri::Url());
|
||||
ASSERT_EQ(invalid_uri.GetHttpRoot(), common::file_system::ascii_file_string_path());
|
||||
std::string conv;
|
||||
invalid_uri.SerializeToString(&conv);
|
||||
ASSERT_EQ(conv, invalid_uri_json);
|
||||
|
||||
const std::string uri_json = "{ \"id\": 1, \"uri\": \"" RTMP_OUTPUT "\", \"http_root\": \"" HTTP_OUTPUT
|
||||
"\", \"size\": \"0x0\", \"video_bitrate\": 0, \"audio_bitrate\": 0 }";
|
||||
fastocloud::OutputUri uri;
|
||||
common::Error err = uri.DeSerializeFromString(uri_json);
|
||||
ASSERT_FALSE(err);
|
||||
ASSERT_EQ(uri.GetID(), 1);
|
||||
common::uri::Url ro(RTMP_OUTPUT);
|
||||
ASSERT_EQ(uri.GetOutput(), ro);
|
||||
ASSERT_EQ(uri.GetHttpRoot(), common::file_system::ascii_directory_string_path(HTTP_OUTPUT));
|
||||
|
||||
err = uri.SerializeToString(&conv);
|
||||
ASSERT_FALSE(err);
|
||||
}
|
55
tests/unit_test_types.cpp
Normal file
55
tests/unit_test_types.cpp
Normal file
|
@ -0,0 +1,55 @@
|
|||
/* Copyright (C) 2014-2019 FastoGT. All right reserved.
|
||||
This file is part of fastocloud.
|
||||
fastocloud is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
fastocloud is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "stream_commands/commands_info/statistic_info.h"
|
||||
#include "base/constants.h"
|
||||
|
||||
TEST(StreamStructInfo, SerializeDeSerialize) {
|
||||
fastocloud::StreamInfo sha;
|
||||
static const auto test_url = common::uri::Url(TEST_URL);
|
||||
sha.id = "test";
|
||||
sha.input = {fastocloud::InputUri(0, test_url),
|
||||
fastocloud::InputUri(1,test_url),
|
||||
fastocloud::InputUri(0,test_url),
|
||||
fastocloud::InputUri(3,test_url)};
|
||||
sha.output = {fastocloud::OutputUri(4, test_url),
|
||||
fastocloud::OutputUri(1, test_url),
|
||||
fastocloud::OutputUri(2, test_url),
|
||||
fastocloud::OutputUri(3, test_url)};
|
||||
|
||||
time_t start_time = 15;
|
||||
time_t lst = 33;
|
||||
size_t rest = 1;
|
||||
fastocloud::StreamStruct str(sha, start_time, lst, rest);
|
||||
fastocloud::StatisticInfo::cpu_load_t cpu_load = 0.33;
|
||||
fastocloud::StatisticInfo::rss_t rss = 12;
|
||||
time_t time = 10;
|
||||
|
||||
fastocloud::StatisticInfo sinf(str, cpu_load, rss, time);
|
||||
json_object* serialized = NULL;
|
||||
common::Error err = sinf.Serialize(&serialized);
|
||||
ASSERT_FALSE(err);
|
||||
|
||||
fastocloud::StatisticInfo sinf2;
|
||||
err = sinf2.DeSerialize(serialized);
|
||||
ASSERT_FALSE(err);
|
||||
// ASSERT_EQ(sinf.GetStreamStruct(), sinf2.GetStreamStruct());
|
||||
ASSERT_EQ(sinf.GetCpuLoad(), sinf2.GetCpuLoad());
|
||||
ASSERT_EQ(sinf.GetRssBytes(), sinf2.GetRssBytes());
|
||||
ASSERT_EQ(sinf.GetTimestamp(), sinf2.GetTimestamp());
|
||||
|
||||
json_object_put(serialized);
|
||||
}
|
22
tests/utils/unit_test_utils.cpp
Normal file
22
tests/utils/unit_test_utils.cpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* Copyright (C) 2014-2019 FastoGT. All right reserved.
|
||||
This file is part of fastocloud.
|
||||
fastocloud is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
fastocloud is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "utils/chunk_info.h"
|
||||
|
||||
TEST(ChunkInfo, double) {
|
||||
fastocloud::utils::ChunkInfo ch("1497615343667_segment10012.ts", 11.43 * fastocloud::utils::ChunkInfo::SECOND, 10012);
|
||||
ASSERT_EQ(ch.GetDurationInSecconds(), 11.43);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue