Annwan
3 months ago
10 changed files with 250 additions and 71 deletions
-
84src/Application.cppm
-
117src/Node.cppm
-
18src/Nodes/InputNode.cpp
-
20src/Nodes/OutputNode.cpp
-
34src/Nodes/SplitterNode.cpp
-
2src/Nodes/StreamSpecConstantNode.cpp
-
18src/Port.cppm
-
5src/Ports/InputPort.cpp
-
10src/Ports/Label.cpp
-
13src/Ports/OutputPort.cpp
@ -1,20 +1,24 @@ |
|||||
module; |
module; |
||||
|
#include <string>
|
||||
#include <variant>
|
#include <variant>
|
||||
module Node; |
module Node; |
||||
using namespace ffmpegraph; |
using namespace ffmpegraph; |
||||
|
|
||||
OutputNode::OutputNode() |
OutputNode::OutputNode() |
||||
: label("File Output", this) |
: label("File Output", this) |
||||
, in_data("Data", this, PortTypeE::STRING) |
|
||||
, in_filename("File", this, PortTypeE::STRING) { |
|
||||
|
, prev("Chain", this, PortTypeE::INPUTS) |
||||
|
, opts("Opts", this, PortTypeE::OPTIONS) |
||||
|
, filename("File", this, PortTypeE::STRING) { |
||||
ports.push_back(&label); |
ports.push_back(&label); |
||||
ports.push_back(&in_data); |
|
||||
ports.push_back(&in_filename); |
|
||||
|
ports.push_back(&prev); |
||||
|
ports.push_back(&opts); |
||||
|
ports.push_back(&filename); |
||||
} |
} |
||||
|
|
||||
Result<> OutputNode::Run() { |
Result<> OutputNode::Run() { |
||||
auto data = std::get_if<std::string>(&in_data.GetValue()); |
|
||||
|
auto data = std::get_if<std::string>(&prev.GetValue()); |
||||
if (not data) return {}; |
if (not data) return {}; |
||||
auto fname = std::get_if<std::string>(&in_filename.GetValue()); |
|
||||
|
auto fname = std::get_if<std::string>(&filename.GetValue()); |
||||
auto path = fname and not fname->empty() ? std::string_view{*fname} : "/tmp/ffmpegraph_out"; |
auto path = fname and not fname->empty() ? std::string_view{*fname} : "/tmp/ffmpegraph_out"; |
||||
return Error("ffmpeg {} {}", *data, path); |
|
||||
} |
|
||||
|
return Error("ffmpeg -nostdin {} {} '{}'", *data, opts.GetValue(), path); |
||||
|
} |
@ -0,0 +1,34 @@ |
|||||
|
module Node; |
||||
|
import Base; |
||||
|
using namespace ffmpegraph; |
||||
|
|
||||
|
SplitterNode::SplitterNode() |
||||
|
: label("Splitter", this) |
||||
|
, in("Input", this, PortTypeE::GENERIC) |
||||
|
, out1("Output", this, PortTypeE::GENERIC) |
||||
|
, out2("Output", this, PortTypeE::GENERIC) { |
||||
|
ports.push_back(&label); |
||||
|
ports.push_back(&in); |
||||
|
ports.push_back(&out1); |
||||
|
ports.push_back(&out2); |
||||
|
} |
||||
|
|
||||
|
Result<> SplitterNode::Run() { |
||||
|
out1.SetValue(in.GetValue()); |
||||
|
out2.SetValue(in.GetValue()); |
||||
|
return {}; |
||||
|
} |
||||
|
|
||||
|
void SplitterNode::OnConnect() { |
||||
|
out1.type = out2.type = in.type; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void SplitterNode::OnDisconnect() { |
||||
|
in.type = out1.type = out2.type = PortTypeE::GENERIC; |
||||
|
out1.Disconnect(); |
||||
|
out2.Disconnect(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
@ -0,0 +1,10 @@ |
|||||
|
module; |
||||
|
#include <raylib.h>
|
||||
|
module Node; |
||||
|
using namespace ffmpegraph; |
||||
|
|
||||
|
i32 Label::Render(i32 x, i32 y, i32 width) { |
||||
|
DrawRectangleLines(x, y, width, 20, BLACK); |
||||
|
DrawText(name.c_str(), x + 5, y + 5, 10, BLACK); |
||||
|
return 10 + MeasureText(name.c_str(), 10); |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue