Skip to content

Commit

Permalink
changed to references to optimize constructor calls (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mast3rwaf1z authored Nov 26, 2024
1 parent b4f29a3 commit 03546de
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/Sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ int main(int argc, char* argv[]) {
.default_value("60");
parser.add_argument("--file")
.default_value("file.mp4");
parser.add_argument("--bitrate")
.default_value("1G");
parser.add_argument("mode")
.default_value("file");
parser.add_argument("-v")
Expand All @@ -53,14 +55,15 @@ int main(int argc, char* argv[]) {
exit(EXIT_FAILURE);
}
spdlog::set_level(static_cast<spdlog::level::level_enum>(loglevel));
spdlog::info("Log level: {}", loglevel);
std::cout << "Log level: " << loglevel << std::endl;
spdlog::debug("Generating settings");
std::unordered_map<std::string, std::string> settings({
{"RES_X", split_res(parser.get<std::string>("--resolution"), "x")},
{"RES_Y", split_res(parser.get<std::string>("--resolution"), "y")},
{"X", split_res(parser.get<std::string>("--dimensions"), "x")},
{"Y", split_res(parser.get<std::string>("--dimensions"), "y")},
{"FRAMERATE", parser.get<std::string>("--framerate")}
{"FRAMERATE", parser.get<std::string>("--framerate")},
{"BITRATE", parser.get<std::string>("--bitrate")}
});
Hyperwall::Hyperwall hyperwall = [&settings, &parser](std::string mode) {
spdlog::info("Chosen mode: {}", mode);
Expand Down
1 change: 1 addition & 0 deletions src/impl/FFmpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <string>

#include <opencv2/opencv.hpp>
#include <spdlog/spdlog.h>

#include "FFmpeg.hpp"

Expand Down
12 changes: 8 additions & 4 deletions src/impl/Hyperwall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
#include <string>
#include <unordered_map>

#include <spdlog/spdlog.h>

#include "Utils.hpp"
#include "FFmpeg.hpp"
#include "Hyperwall.hpp"

Hyperwall::FFmpeg default_ffmpeg(const int RES_X, const int RES_Y, const int X, const int Y, const int FRAMERATE, const int x, const int y) {
Hyperwall::FFmpeg default_ffmpeg(const int RES_X, const int RES_Y, const int X, const int Y, const int FRAMERATE, const std::string BITRATE, const int x, const int y) {
Hyperwall::FFmpegBuilder builder;
spdlog::debug("Creating default ffmpeg instance");
return builder.add("-re")
Expand All @@ -22,6 +24,7 @@ Hyperwall::FFmpeg default_ffmpeg(const int RES_X, const int RES_Y, const int X,
.add("-s", std::format("{}x{}", RES_X/X, RES_Y/Y))
.add("-r", std::to_string(FRAMERATE))
.add("-f", "rtsp")
.add("-b:v", BITRATE)
.url(std::format("rtsp://0.0.0.0:8554/frame/{}/{}", x, y))
.build(std::format("ffmpeg-{}-{}.log", x, y));
}
Expand Down Expand Up @@ -68,10 +71,11 @@ Hyperwall::Hyperwall::Hyperwall(VideoSourceT& source, std::unordered_map<std::st
for(const auto y : Util::range(Y)) {
FFmpeg ffmpeg = default_ffmpeg(
std::stoi(settings["RES_X"]),
std::stoi(settings["RES_Y"]),
std::stoi(settings["RES_Y"]),
std::stoi(settings["X"]),
std::stoi(settings["Y"]),
std::stoi(settings["FRAMERATE"]),
settings["BITRATE"],
x,
y
);
Expand All @@ -87,8 +91,8 @@ void Hyperwall::Hyperwall::run() {
if (image.rows == 0 || image.cols == 0) {
break;
}
for(auto [x, x_frames] : frames) {
for(auto [y, frame] : x_frames) {
for(auto& [x, x_frames] : frames) {
for(auto& [y, frame] : x_frames) {
frame.run(image);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/impl/Sources.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <spdlog/spdlog.h>
#include <string>

#include <opencv2/opencv.hpp>
#include <spdlog/spdlog.h>

#include "Sources/FileSource.hpp"
#include "Sources/VideoSource.hpp"
Expand Down

0 comments on commit 03546de

Please sign in to comment.