Skip to content

Commit

Permalink
added more args (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mast3rwaf1z authored Nov 28, 2024
1 parent 205915e commit a529328
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ ffmpeg -f x11grab -i :0 -vcodec libx264 -f mpegts tcp://127.0.0.1:8600
```
then in another shell, start the hyperwall:
```sh
./build/sender --file "tcp://127.0.0.1:8600?listen" ... <args>
./build/sender screenshare <args>
```
5 changes: 5 additions & 0 deletions include/FFmpeg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class FFmpeg {
const coordinate resolution;
const coordinate position;
const coordinate dimensions;
const std::string rtsp_server;
const int framerate;
const std::string input;
const std::string bitrate;
Expand All @@ -22,6 +23,7 @@ class FFmpeg {
constexpr FFmpeg(Settings settings, coordinate position) :
resolution(settings.resolution),
dimensions(settings.dimensions),
rtsp_server(settings.rtsp_server),
framerate(settings.framerate),
bitrate(settings.bitrate),
position(position) {
Expand All @@ -31,6 +33,7 @@ class FFmpeg {
constexpr FFmpeg(Settings settings) :
resolution(settings.resolution),
dimensions(settings.dimensions),
rtsp_server(settings.rtsp_server),
framerate(settings.framerate),
bitrate(settings.bitrate),
position({0, 0}) {
Expand All @@ -39,6 +42,7 @@ class FFmpeg {
constexpr FFmpeg(coordinate position) :
resolution(1920, 1080),
dimensions(2, 2),
rtsp_server("0.0.0.0:8554"),
framerate(60),
bitrate("1G"),
position(position) {
Expand All @@ -47,6 +51,7 @@ class FFmpeg {
constexpr FFmpeg() :
resolution(1920, 1080),
dimensions(0, 0),
rtsp_server("0.0.0.0:8554"),
framerate(60),
bitrate("1G"),
position(0, 0) {
Expand Down
4 changes: 2 additions & 2 deletions include/Hyperwall.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class HyperFrame {
FFmpeg ffmpeg;
public:
HyperFrame(const HyperFrame&);
HyperFrame(const coordinate&, Settings, FFmpeg&);
HyperFrame(const coordinate&, Settings&, FFmpeg&);
void run(const cv::Mat&);
};

Expand All @@ -22,7 +22,7 @@ class Hyperwall {
std::vector<HyperFrame> frames;
const coordinate dimensions;
public:
Hyperwall(VideoSourceT&, Settings);
Hyperwall(VideoSourceT&, Settings&);
void run();
};

Expand Down
25 changes: 23 additions & 2 deletions include/Settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,64 @@ struct Settings {
public:
const coordinate resolution;
const coordinate dimensions;
const std::string rtsp_server;
const std::string bitrate;
const unsigned int framerate;
constexpr Settings(const coordinate& resolution, const coordinate& dimensions, const std::string bitrate, const unsigned int framerate) :

constexpr Settings(const coordinate& resolution, const coordinate& dimensions, const std::string rtsp_server, const std::string bitrate, const unsigned int framerate) :
resolution(resolution),
dimensions(dimensions),
rtsp_server(rtsp_server),
bitrate(bitrate),
framerate(framerate) {
}

constexpr Settings(const coordinate& resolution, const coordinate& dimensions, const std::string bitrate) :
constexpr Settings(const coordinate& resolution, const coordinate& dimensions, const std::string rtsp_server, const std::string bitrate) :
resolution(resolution),
dimensions(dimensions),
rtsp_server(rtsp_server),
bitrate(bitrate),
framerate(60) {
}

constexpr Settings(const coordinate& resolution, const coordinate& dimensions, const std::string rtsp_server) :
resolution(resolution),
dimensions(dimensions),
rtsp_server(rtsp_server),
bitrate("1G"),
framerate(60) {
}

constexpr Settings(const coordinate& resolution, const coordinate& dimensions) :
resolution(resolution),
dimensions(dimensions),
rtsp_server("0.0.0.0:8554"),
bitrate("1G"),
framerate(60) {
}

constexpr Settings(const coordinate& resolution) :
resolution(resolution),
dimensions({2, 2}),
rtsp_server("0.0.0.0:8554"),
bitrate("1G"),
framerate(60) {
}

constexpr Settings() :
resolution({1920, 1080}),
dimensions({2, 2}),
rtsp_server("0.0.0.0:8554"),
bitrate("1G"),
framerate(60) {
}

constexpr Settings(Settings& other) :
resolution(other.resolution),
dimensions(other.dimensions),
rtsp_server(other.rtsp_server),
bitrate(other.bitrate),
framerate(other.framerate) {
}
};

Expand Down
8 changes: 8 additions & 0 deletions src/Sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ int main(int argc, char* argv[]) {
.default_value("file.mp4");
parser.add_argument("--bitrate")
.default_value("1G");
parser.add_argument("--rtsp-server")
.default_value("0.0.0.0:8554");
parser.add_argument("mode")
.default_value("file");
parser.add_argument("-v")
Expand Down Expand Up @@ -67,6 +69,7 @@ int main(int argc, char* argv[]) {
stoi(split_res(parser.get("--dimensions"), "x")),
stoi(split_res(parser.get("--dimensions"), "y"))
},
parser.get("--rtsp-server"),
parser.get("--bitrate"),
parser.get<int>("--framerate")
);
Expand All @@ -78,6 +81,11 @@ int main(int argc, char* argv[]) {
Hyperwall::Hyperwall hyperwall(source, settings);
return hyperwall;
}
else if(mode == "screenshare") {
Hyperwall::FileSource source("tcp://0.0.0.0:8600?listen");
Hyperwall::Hyperwall hyperwall(source, settings);
return hyperwall;
}
else {
auto filename = parser.get<std::string>("--file");
if(!std::filesystem::exists(std::filesystem::path(filename))){
Expand Down
2 changes: 1 addition & 1 deletion src/impl/FFmpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const void Hyperwall::FFmpeg::open() {
<< " -r " << framerate
<< " -f rtsp -b:v "
<< bitrate
<< " rtsp://0.0.0.0:8554/frame/" << x << "/" << y <<
<< " rtsp://" << rtsp_server << "/frame/" << x << "/" << y <<
" 2> ./logs/stderr-" << x << "-" << y << ".log"
<< " > ./logs/stdout-" << x << "-" << y << ".log";

Expand Down
4 changes: 2 additions & 2 deletions src/impl/Hyperwall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "FFmpeg.hpp"
#include "Hyperwall.hpp"

Hyperwall::HyperFrame::HyperFrame(const coordinate& position, Settings settings, FFmpeg& ffmpeg) :
Hyperwall::HyperFrame::HyperFrame(const coordinate& position, Settings& settings, FFmpeg& ffmpeg) :
position(position),
dimensions(settings.dimensions),
ffmpeg(ffmpeg),
Expand Down Expand Up @@ -42,7 +42,7 @@ void Hyperwall::HyperFrame::run(const cv::Mat& image) {
ffmpeg.write(resized_image);
}

Hyperwall::Hyperwall::Hyperwall(VideoSourceT& source, Settings settings) :
Hyperwall::Hyperwall::Hyperwall(VideoSourceT& source, Settings& settings) :
source(source.clone()),
dimensions(settings.dimensions) {
spdlog::info("Generating hyperwall...");
Expand Down
5 changes: 3 additions & 2 deletions src/test/ffmpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

TEST_CASE("test ffmpeg constructors") {
std::vector<Hyperwall::FFmpeg> ffmpegs({
{{{1920, 1080}, {2, 2}, "1G", 60}},
{{{1920, 1080}, {2, 2}, "1G"}},
{{{1920, 1080}, {2, 2}, "0.0.0.0:8554", "1G", 60}},
{{{1920, 1080}, {2, 2}, "0.0.0.0:8554", "1G"}},
{{{1920, 1080}, {2, 2}, "0.0.0.0:8554"}},
{{{1920, 1080}, {2, 2}}},
{{{1920, 1080}}},
{}
Expand Down
4 changes: 3 additions & 1 deletion src/test/hyperwall.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include <catch2/catch_test_macros.hpp>

#include "Hyperwall.hpp"
#include "Settings.hpp"
#include "Sources/FileSource.hpp"

TEST_CASE("Hyperwall") {
Hyperwall::FileSource source("file.mp4");
Hyperwall::Hyperwall wall(source, {});
Hyperwall::Settings settings;
Hyperwall::Hyperwall wall(source, settings);
}

0 comments on commit a529328

Please sign in to comment.