1
0
Fork 0
mirror of https://github.com/fastogt/fastocloud.git synced 2025-03-09 23:18:50 +00:00

Init FastoCloud on Github

This commit is contained in:
topilski 2023-01-21 05:21:27 +03:00
parent d0d234101d
commit d0d6551903
359 changed files with 32676 additions and 23 deletions

View file

@ -0,0 +1,15 @@
/* Copyright (C) 2014-2022 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 "stream_commands/commands.h"

View file

@ -0,0 +1,25 @@
/* Copyright (C) 2014-2022 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/>.
*/
#pragma once
#define STOP_STREAM "stop"
#define RESTART_STREAM "restart"
#define CHANGED_SOURCES_STREAM "changed_source_stream"
#define STATISTIC_STREAM "statistic_stream"
#if defined(MACHINE_LEARNING)
#define ML_NOTIFICATION_STREAM "ml_notification_stream"
#endif

View file

@ -0,0 +1,65 @@
/* Copyright (C) 2014-2022 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 "stream_commands/commands_factory.h"
#include "stream_commands/commands.h"
namespace fastocloud {
common::Error RestartStreamResponseSuccess(fastotv::protocol::sequance_id_t id, fastotv::protocol::response_t* resp) {
if (!resp) {
return common::make_error_inval();
}
*resp =
fastotv::protocol::response_t::MakeMessage(id, common::protocols::json_rpc::JsonRPCMessage::MakeSuccessMessage());
return common::Error();
}
common::Error StopStreamResponseSuccess(fastotv::protocol::sequance_id_t id, fastotv::protocol::response_t* resp) {
if (!resp) {
return common::make_error_inval();
}
*resp =
fastotv::protocol::response_t::MakeMessage(id, common::protocols::json_rpc::JsonRPCMessage::MakeSuccessMessage());
return common::Error();
}
common::Error RestartStreamRequest(fastotv::protocol::sequance_id_t id, fastotv::protocol::request_t* req) {
if (!req) {
return common::make_error_inval();
}
fastotv::protocol::request_t lreq;
lreq.id = id;
lreq.method = RESTART_STREAM;
*req = lreq;
return common::Error();
}
common::Error StopStreamRequest(fastotv::protocol::sequance_id_t id, fastotv::protocol::request_t* req) {
if (!req) {
return common::make_error_inval();
}
fastotv::protocol::request_t lreq;
lreq.id = id;
lreq.method = STOP_STREAM;
*req = lreq;
return common::Error();
}
} // namespace fastocloud

View file

@ -0,0 +1,31 @@
/* Copyright (C) 2014-2022 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/>.
*/
#pragma once
#include <fastotv/protocol/types.h>
namespace fastocloud {
common::Error RestartStreamRequest(fastotv::protocol::sequance_id_t id,
fastotv::protocol::request_t* req) WARN_UNUSED_RESULT;
common::Error StopStreamRequest(fastotv::protocol::sequance_id_t id,
fastotv::protocol::request_t* req) WARN_UNUSED_RESULT;
common::Error RestartStreamResponseSuccess(fastotv::protocol::sequance_id_t id,
fastotv::protocol::response_t* resp) WARN_UNUSED_RESULT;
common::Error StopStreamResponseSuccess(fastotv::protocol::sequance_id_t id,
fastotv::protocol::response_t* resp) WARN_UNUSED_RESULT;
} // namespace fastocloud

View file

@ -0,0 +1,72 @@
/* Copyright (C) 2014-2022 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 "stream_commands/commands_info/changed_sources_info.h"
#include <string>
#define CHANGE_SOURCES_ID_FIELD "id"
#define CHANGE_SOURCES_URL_FIELD "url"
namespace fastocloud {
ChangedSouresInfo::ChangedSouresInfo(const fastotv::stream_id_t& sid, const url_t& url)
: base_class(), id_(sid), url_(url) {}
ChangedSouresInfo::ChangedSouresInfo() : base_class(), id_(), url_() {}
common::Error ChangedSouresInfo::SerializeFields(json_object* out) const {
json_object* url_obj = nullptr;
common::Error err = url_.Serialize(&url_obj);
if (err) {
return err;
}
ignore_result(SetStringField(out, CHANGE_SOURCES_ID_FIELD, id_));
ignore_result(SetObjectField(out, CHANGE_SOURCES_URL_FIELD, url_obj));
return common::Error();
}
ChangedSouresInfo::url_t ChangedSouresInfo::GetUrl() const {
return url_;
}
fastotv::stream_id_t ChangedSouresInfo::GetStreamID() const {
return id_;
}
common::Error ChangedSouresInfo::DoDeSerialize(json_object* serialized) {
fastotv::stream_id_t sid;
common::Error err = GetStringField(serialized, CHANGE_SOURCES_ID_FIELD, &sid);
if (err) {
return err;
}
json_object* jurl = nullptr;
err = GetObjectField(serialized, CHANGE_SOURCES_URL_FIELD, &jurl);
if (err) {
return err;
}
url_t url;
err = url.DeSerialize(jurl);
if (err) {
return err;
}
*this = ChangedSouresInfo(sid, url);
return common::Error();
}
} // namespace fastocloud

View file

@ -0,0 +1,44 @@
/* Copyright (C) 2014-2022 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/>.
*/
#pragma once
#include <common/serializer/json_serializer.h>
#include <fastotv/types/input_uri.h>
#include "base/types.h"
namespace fastocloud {
class ChangedSouresInfo : public common::serializer::JsonSerializer<ChangedSouresInfo> {
public:
typedef JsonSerializer<ChangedSouresInfo> base_class;
typedef fastotv::InputUri url_t;
ChangedSouresInfo();
explicit ChangedSouresInfo(const fastotv::stream_id_t& sid, const url_t& url);
url_t GetUrl() const;
fastotv::stream_id_t GetStreamID() const;
protected:
common::Error DoDeSerialize(json_object* serialized) override;
common::Error SerializeFields(json_object* out) const override;
private:
fastotv::stream_id_t id_;
url_t url_;
};
} // namespace fastocloud

View file

@ -0,0 +1,104 @@
/* Copyright (C) 2014-2022 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 "stream_commands/commands_info/details/channel_stats_info.h"
#include <string>
#define FIELD_STATS_ID "id"
#define FIELD_STATS_LAST_UPDATE_TIME "last_update_time"
#define FIELD_STATS_PREV_TOTAL_BYTES "prev_total_bytes"
#define FIELD_STATS_TOTAL_BYTES "total_bytes"
#define FIELD_STATS_BYTES_PER_SECOND "bps"
#define FIELD_STATS_DESIRE_BYTES_PER_SECOND "dbps"
namespace fastocloud {
namespace details {
ChannelStatsInfo::ChannelStatsInfo() : ChannelStatsInfo(ChannelStats()) {}
ChannelStatsInfo::ChannelStatsInfo(const ChannelStats& stats) : stats_(stats) {}
ChannelStats ChannelStatsInfo::GetChannelStats() const {
return stats_;
}
common::Error ChannelStatsInfo::SerializeFields(json_object* out) const {
fastotv::channel_id_t sid = stats_.GetID();
ignore_result(SetUInt64Field(out, FIELD_STATS_ID, sid));
fastotv::timestamp_t last = stats_.GetLastUpdateTime();
ignore_result(SetInt64Field(out, FIELD_STATS_LAST_UPDATE_TIME, last));
size_t prev_t = stats_.GetPrevTotalBytes();
ignore_result(SetUInt64Field(out, FIELD_STATS_PREV_TOTAL_BYTES, prev_t));
size_t tot = stats_.GetPrevTotalBytes();
ignore_result(SetUInt64Field(out, FIELD_STATS_TOTAL_BYTES, tot));
size_t bps = stats_.GetBps();
ignore_result(SetUInt64Field(out, FIELD_STATS_BYTES_PER_SECOND, bps));
common::media::DesireBytesPerSec dbps = stats_.GetDesireBytesPerSecond();
std::string dbps_str = common::ConvertToString(dbps);
ignore_result(SetStringField(out, FIELD_STATS_DESIRE_BYTES_PER_SECOND, dbps_str));
return common::Error();
}
common::Error ChannelStatsInfo::DoDeSerialize(json_object* serialized) {
int64_t sid;
common::Error err = GetInt64Field(serialized, FIELD_STATS_ID, &sid);
if (err) {
return err;
}
ChannelStats stats(sid);
int64_t lut;
err = GetInt64Field(serialized, FIELD_STATS_LAST_UPDATE_TIME, &lut);
if (!err) {
stats.SetLastUpdateTime(lut);
}
int64_t ptb;
err = GetInt64Field(serialized, FIELD_STATS_PREV_TOTAL_BYTES, &ptb);
if (!err) {
stats.SetPrevTotalBytes(ptb);
}
int64_t tb;
err = GetInt64Field(serialized, FIELD_STATS_TOTAL_BYTES, &tb);
if (!err) {
stats.SetTotalBytes(tb);
}
int64_t bps;
err = GetInt64Field(serialized, FIELD_STATS_BYTES_PER_SECOND, &bps);
if (!err) {
stats.SetBps(bps);
}
std::string dbps_str;
err = GetStringField(serialized, FIELD_STATS_DESIRE_BYTES_PER_SECOND, &dbps_str);
common::media::DesireBytesPerSec dbps;
if (!err && common::ConvertFromString(dbps_str, &dbps)) {
stats.SetDesireBytesPerSecond(dbps);
}
*this = ChannelStatsInfo(stats);
return common::Error();
}
} // namespace details
} // namespace fastocloud

View file

@ -0,0 +1,41 @@
/* Copyright (C) 2014-2022 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/>.
*/
#pragma once
#include <common/serializer/json_serializer.h>
#include "base/channel_stats.h"
namespace fastocloud {
namespace details {
class ChannelStatsInfo : public common::serializer::JsonSerializer<ChannelStatsInfo> {
public:
typedef JsonSerializer<ChannelStatsInfo> base_class;
ChannelStatsInfo();
explicit ChannelStatsInfo(const ChannelStats& stats);
ChannelStats GetChannelStats() const;
protected:
common::Error DoDeSerialize(json_object* serialized) override;
common::Error SerializeFields(json_object* out) const override;
private:
ChannelStats stats_;
};
} // namespace details
} // namespace fastocloud

View file

@ -0,0 +1,33 @@
/* Copyright (C) 2014-2022 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 "stream_commands/commands_info/restart_info.h"
namespace fastocloud {
RestartInfo::RestartInfo() : base_class() {}
common::Error RestartInfo::SerializeFields(json_object* out) const {
UNUSED(out);
return common::Error();
}
common::Error RestartInfo::DoDeSerialize(json_object* serialized) {
UNUSED(serialized);
*this = RestartInfo();
return common::Error();
}
} // namespace fastocloud

View file

@ -0,0 +1,31 @@
/* Copyright (C) 2014-2022 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/>.
*/
#pragma once
#include <common/serializer/json_serializer.h>
namespace fastocloud {
class RestartInfo : public common::serializer::JsonSerializer<RestartInfo> {
public:
typedef JsonSerializer<RestartInfo> base_class;
RestartInfo();
protected:
common::Error DoDeSerialize(json_object* serialized) override;
common::Error SerializeFields(json_object* out) const override;
};
} // namespace fastocloud

View file

@ -0,0 +1,183 @@
/* Copyright (C) 2014-2022 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 "stream_commands/commands_info/statistic_info.h"
#include <math.h>
#include "stream_commands/commands_info/details/channel_stats_info.h"
#define STREAM_ID_FIELD "id"
#define STREAM_TYPE_FIELD "type"
#define STREAM_CPU_FIELD "cpu"
#define STREAM_RSS_FIELD "rss"
#define STREAM_STATUS_FIELD "status"
#define STREAM_LOOP_START_TIME_FIELD "loop_start_time"
#define STREAM_RESTARTS_FIELD "restarts"
#define STREAM_START_TIME_FIELD "start_time"
#define STREAM_TIMESTAMP_FIELD "timestamp"
#define STREAM_IDLE_TIME_FIELD "idle_time"
#define STREAM_INPUT_STREAMS_FIELD "input_streams"
#define STREAM_OUTPUT_STREAMS_FIELD "output_streams"
namespace fastocloud {
StatisticInfo::StatisticInfo() : stream_struct_(), cpu_load_(), rss_bytes_(), timestamp_(0) {}
StatisticInfo::StatisticInfo(const StreamStruct& str,
cpu_load_t cpu_load,
rss_t rss_bytes,
fastotv::timestamp_t utc_time)
: stream_struct_(str), cpu_load_(cpu_load), rss_bytes_(rss_bytes), timestamp_(utc_time) {}
StreamStruct StatisticInfo::GetStreamStruct() const {
return stream_struct_;
}
StatisticInfo::cpu_load_t StatisticInfo::GetCpuLoad() const {
return cpu_load_;
}
StatisticInfo::rss_t StatisticInfo::GetRssBytes() const {
return rss_bytes_;
}
fastotv::timestamp_t StatisticInfo::GetTimestamp() const {
return timestamp_;
}
common::Error StatisticInfo::SerializeFields(json_object* out) const {
if (!stream_struct_.IsValid()) {
return common::make_error_inval();
}
const auto channel_id = stream_struct_.id;
ignore_result(SetStringField(out, STREAM_ID_FIELD, channel_id));
ignore_result(SetEnumField(out, STREAM_TYPE_FIELD, stream_struct_.type));
input_channels_info_t input_streams = stream_struct_.input;
json_object* jinput_streams = json_object_new_array();
for (auto inf : input_streams) {
json_object* jinf = nullptr;
details::ChannelStatsInfo sinf(inf);
common::Error err = sinf.Serialize(&jinf);
if (err) {
continue;
}
json_object_array_add(jinput_streams, jinf);
}
ignore_result(SetArrayField(out, STREAM_INPUT_STREAMS_FIELD, jinput_streams));
output_channels_info_t output_streams = stream_struct_.output;
json_object* joutput_streams = json_object_new_array();
for (auto inf : output_streams) {
json_object* jinf = nullptr;
details::ChannelStatsInfo sinf(inf);
common::Error err = sinf.Serialize(&jinf);
if (err) {
continue;
}
json_object_array_add(joutput_streams, jinf);
}
ignore_result(SetArrayField(out, STREAM_OUTPUT_STREAMS_FIELD, joutput_streams));
ignore_result(SetInt64Field(out, STREAM_LOOP_START_TIME_FIELD, stream_struct_.loop_start_time));
ignore_result(SetUInt64Field(out, STREAM_RSS_FIELD, rss_bytes_));
ignore_result(SetDoubleField(out, STREAM_CPU_FIELD, cpu_load_));
ignore_result(SetEnumField(out, STREAM_STATUS_FIELD, stream_struct_.status));
ignore_result(SetUInt64Field(out, STREAM_RESTARTS_FIELD, stream_struct_.restarts));
ignore_result(SetInt64Field(out, STREAM_START_TIME_FIELD, stream_struct_.start_time));
ignore_result(SetInt64Field(out, STREAM_TIMESTAMP_FIELD, timestamp_));
ignore_result(SetInt64Field(out, STREAM_IDLE_TIME_FIELD, stream_struct_.idle_time));
return common::Error();
}
common::Error StatisticInfo::DoDeSerialize(json_object* serialized) {
fastotv::stream_id_t cid;
common::Error err = GetStringField(serialized, STREAM_ID_FIELD, &cid);
if (err) {
return err;
}
fastotv::StreamType type;
err = GetEnumField<fastotv::StreamType>(serialized, STREAM_TYPE_FIELD, &type);
if (err) {
return err;
}
input_channels_info_t input;
json_object* jinput = nullptr;
size_t len;
err = GetArrayField(serialized, STREAM_INPUT_STREAMS_FIELD, &jinput, &len);
if (!err) {
for (size_t i = 0; i < len; ++i) {
json_object* jin = json_object_array_get_idx(jinput, i);
details::ChannelStatsInfo sinf;
common::Error err = sinf.DeSerialize(jin);
if (err) {
continue;
}
input.push_back(ChannelStats(sinf.GetChannelStats()));
}
}
output_channels_info_t output;
json_object* joutput = nullptr;
err = GetArrayField(serialized, STREAM_OUTPUT_STREAMS_FIELD, &joutput, &len);
if (!err) {
for (size_t i = 0; i < len; ++i) {
json_object* jin = json_object_array_get_idx(joutput, i);
details::ChannelStatsInfo sinf;
common::Error err = sinf.DeSerialize(jin);
if (err) {
continue;
}
output.push_back(ChannelStats(sinf.GetChannelStats()));
}
}
StreamStatus st = NEW;
ignore_result(GetEnumField(serialized, STREAM_STATUS_FIELD, &st));
cpu_load_t cpu_load = 0;
ignore_result(GetDoubleField(serialized, STREAM_CPU_FIELD, &cpu_load));
rss_t rss = 0;
ignore_result(GetUint64Field(serialized, STREAM_RSS_FIELD, &rss));
fastotv::timestamp_t time = 0;
ignore_result(GetInt64Field(serialized, STREAM_TIMESTAMP_FIELD, &time));
fastotv::timestamp_t start_time = 0;
ignore_result(GetInt64Field(serialized, STREAM_START_TIME_FIELD, &start_time));
size_t restarts = 0;
ignore_result(GetUint64Field(serialized, STREAM_RESTARTS_FIELD, &restarts));
fastotv::timestamp_t loop_start_time = 0;
ignore_result(GetInt64Field(serialized, STREAM_LOOP_START_TIME_FIELD, &loop_start_time));
fastotv::timestamp_t idle_time = 0;
ignore_result(GetInt64Field(serialized, STREAM_IDLE_TIME_FIELD, &idle_time));
StreamStruct strct(cid, type, st, input, output, start_time, loop_start_time, restarts);
strct.idle_time = idle_time;
*this = StatisticInfo(strct, cpu_load, rss, time);
return common::Error();
}
} // namespace fastocloud

View file

@ -0,0 +1,48 @@
/* Copyright (C) 2014-2022 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/>.
*/
#pragma once
#include <common/serializer/json_serializer.h>
#include "base/stream_struct.h"
namespace fastocloud {
class StatisticInfo : public common::serializer::JsonSerializer<StatisticInfo> {
public:
typedef JsonSerializer<StatisticInfo> base_class;
typedef double cpu_load_t;
typedef size_t rss_t;
StatisticInfo();
StatisticInfo(const StreamStruct& str, cpu_load_t cpu_load, rss_t rss_bytes, fastotv::timestamp_t utc_time);
StreamStruct GetStreamStruct() const;
cpu_load_t GetCpuLoad() const;
rss_t GetRssBytes() const;
fastotv::timestamp_t GetTimestamp() const;
protected:
common::Error SerializeFields(json_object* out) const override;
common::Error DoDeSerialize(json_object* serialized) override;
private:
StreamStruct stream_struct_;
cpu_load_t cpu_load_;
rss_t rss_bytes_;
fastotv::timestamp_t timestamp_; // utc
};
} // namespace fastocloud

View file

@ -0,0 +1,33 @@
/* Copyright (C) 2014-2022 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 "stream_commands/commands_info/stop_info.h"
namespace fastocloud {
StopInfo::StopInfo() : base_class() {}
common::Error StopInfo::SerializeFields(json_object* out) const {
UNUSED(out);
return common::Error();
}
common::Error StopInfo::DoDeSerialize(json_object* serialized) {
UNUSED(serialized);
*this = StopInfo();
return common::Error();
}
} // namespace fastocloud

View file

@ -0,0 +1,31 @@
/* Copyright (C) 2014-2022 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/>.
*/
#pragma once
#include <common/serializer/json_serializer.h>
namespace fastocloud {
class StopInfo : public common::serializer::JsonSerializer<StopInfo> {
public:
typedef JsonSerializer<StopInfo> base_class;
StopInfo();
protected:
common::Error DoDeSerialize(json_object* serialized) override;
common::Error SerializeFields(json_object* out) const override;
};
} // namespace fastocloud