Skip to content

Commit

Permalink
Rist URL options into GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
patcarter883 committed Nov 23, 2023
1 parent 51955c2 commit 8a4fed3
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 62 deletions.
2 changes: 1 addition & 1 deletion extern/rist-cpp
60 changes: 39 additions & 21 deletions source/UserInterface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Fl_Menu_Item* UserInterface::qsvEncoderChoice = UserInterface::menu_encoderSelec
Fl_Menu_Item* UserInterface::nvencEncoderChoice = UserInterface::menu_encoderSelect + 3;

UserInterface::UserInterface() {
{ mainWindow = new Fl_Double_Window(1175, 612, "NDI RIST Encoder");
{ mainWindow = new Fl_Double_Window(1330, 610, "NDI RIST Encoder");
mainWindow->user_data((void*)(this));
{ inputGroup = new Fl_Group(35, 25, 235, 99, "Input");
{ ndiSourceSelect = new Fl_Choice(104, 32, 140, 22, "NDI Source");
Expand Down Expand Up @@ -53,16 +53,37 @@ UserInterface::UserInterface() {
} // Fl_Input* encoderBitrateInput
encodeGroup->end();
} // Fl_Group* encodeGroup
{ ristAddressInput = new Fl_Input(390, 33, 218, 22, "Address and Port");
ristAddressInput->callback((Fl_Callback*)rist_address_cb);
} // Fl_Input* ristAddressInput
{ Fl_Group* o = new Fl_Group(685, 53, 92, 52, "RIST Settings");
{ ristBufferInput = new Fl_Input(685, 53, 92, 22, "Buffer");
ristBufferInput->callback((Fl_Callback*)rist_buffer_cb);
} // Fl_Input* ristBufferInput
{ ristBandwidthInput = new Fl_Input(685, 83, 92, 22, "Bandwidth");
{ Fl_Group* o = new Fl_Group(390, 33, 218, 77, "Output");
{ ristAddressInput = new Fl_Input(390, 33, 218, 22, "RIST Address");
ristAddressInput->callback((Fl_Callback*)rist_address_cb);
} // Fl_Input* ristAddressInput
{ rtmpAddressInput = new Fl_Input(390, 60, 218, 22, "RTMP Server");
rtmpAddressInput->callback((Fl_Callback*)rtmp_address_cb);
} // Fl_Input* rtmpAddressInput
{ rtmpKeyInput = new Fl_Input(390, 88, 218, 22, "RTMP Key");
rtmpKeyInput->callback((Fl_Callback*)rtmp_key_cb);
} // Fl_Input* rtmpKeyInput
o->end();
} // Fl_Group* o
{ Fl_Group* o = new Fl_Group(765, 28, 95, 149, "RIST Settings");
{ ristBandwidthInput = new Fl_Input(765, 28, 92, 22, "Bandwidth");
ristBandwidthInput->callback((Fl_Callback*)rist_bandwidth_cb);
} // Fl_Input* ristBandwidthInput
{ ristBufferMinInput = new Fl_Input(765, 53, 92, 22, "Buffer Min");
ristBufferMinInput->callback((Fl_Callback*)rist_buffer_min_cb);
} // Fl_Input* ristBufferMinInput
{ ristBufferMaxInput = new Fl_Input(765, 78, 92, 22, "Buffer Max");
ristBufferMaxInput->callback((Fl_Callback*)rist_buffer_max_cb);
} // Fl_Input* ristBufferMaxInput
{ ristRttMinInput = new Fl_Input(765, 103, 92, 22, "RTT Min");
ristRttMinInput->callback((Fl_Callback*)rist_rtt_min_cb);
} // Fl_Input* ristRttMinInput
{ ristRttMaxInput = new Fl_Input(765, 128, 92, 22, "RTT Max");
ristRttMaxInput->callback((Fl_Callback*)rist_rtt_max_cb);
} // Fl_Input* ristRttMaxInput
{ ristReorderBufferInput = new Fl_Input(765, 153, 92, 22, "Reorder Buffer");
ristReorderBufferInput->callback((Fl_Callback*)rist_reorder_buffer_cb);
} // Fl_Input* ristReorderBufferInput
o->end();
} // Fl_Group* o
{ btnStartStream = new Fl_Button(610, 203, 218, 22, "Start Stream");
Expand All @@ -72,28 +93,25 @@ UserInterface::UserInterface() {
btnStopStream->callback((Fl_Callback*)stopStream_cb);
btnStopStream->deactivate();
} // Fl_Button* btnStopStream
{ statsGroup = new Fl_Group(845, 20, 266, 200, "Stats");
{ bandwidthOutput = new Fl_Output(940, 45, 165, 24, "Bandwidth");
{ statsGroup = new Fl_Group(1040, 25, 266, 200, "Stats");
{ bandwidthOutput = new Fl_Output(1135, 50, 165, 24, "Bandwidth");
} // Fl_Output* bandwidthOutput
{ linkQualityOutput = new Fl_Output(940, 71, 165, 24, "Link Quality");
{ linkQualityOutput = new Fl_Output(1135, 76, 165, 24, "Link Quality");
} // Fl_Output* linkQualityOutput
{ retransmittedPacketsOutput = new Fl_Output(940, 96, 165, 24, "Retransmitted Packets");
{ retransmittedPacketsOutput = new Fl_Output(1135, 101, 165, 24, "Retransmitted Packets");
} // Fl_Output* retransmittedPacketsOutput
{ rttOutput = new Fl_Output(940, 146, 165, 24, "RTT");
{ rttOutput = new Fl_Output(1135, 151, 165, 24, "RTT");
} // Fl_Output* rttOutput
{ totalPacketsOutput = new Fl_Output(940, 121, 165, 24, "Total Packets");
{ totalPacketsOutput = new Fl_Output(1135, 126, 165, 24, "Packets");
} // Fl_Output* totalPacketsOutput
{ encodeBitrateOutput = new Fl_Output(940, 196, 165, 24, "Encode Bitrate");
{ encodeBitrateOutput = new Fl_Output(1135, 201, 165, 24, "Encode Bitrate");
} // Fl_Output* encodeBitrateOutput
statsGroup->end();
} // Fl_Group* statsGroup
{ logDisplay = new Fl_Text_Display(21, 246, 1132, 164, "Log");
{ logDisplay = new Fl_Text_Display(21, 246, 1294, 168, "Log");
} // Fl_Text_Display* logDisplay
{ ristLogDisplay = new Fl_Text_Display(22, 431, 1132, 164, "RIST Log");
{ ristLogDisplay = new Fl_Text_Display(22, 431, 1293, 163, "RIST Log");
} // Fl_Text_Display* ristLogDisplay
{ rtmpAddressInput = new Fl_Input(390, 63, 218, 22, "RTMP");
rtmpAddressInput->callback((Fl_Callback*)rtmp_address_cb);
} // Fl_Input* rtmpAddressInput
mainWindow->end();
mainWindow->resizable(mainWindow);
} // Fl_Double_Window* mainWindow
Expand Down
86 changes: 58 additions & 28 deletions source/UserInterface.fl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class UserInterface {open
} {
Fl_Window mainWindow {
label {NDI RIST Encoder} open
xywh {665 163 1175 612} type Double resizable visible
xywh {355 340 1330 610} type Double resizable visible
} {
Fl_Group inputGroup {
label Input
Expand Down Expand Up @@ -91,24 +91,59 @@ class UserInterface {open
xywh {141 196 90 24}
}
}
Fl_Input ristAddressInput {
label {Address and Port}
callback rist_address_cb
xywh {390 33 218 22}
}
Fl_Group {} {
label {RIST Settings}
xywh {685 53 92 52}
label Output open
xywh {390 33 218 77}
} {
Fl_Input ristBufferInput {
label Buffer
callback rist_buffer_cb
xywh {685 53 92 22}
Fl_Input ristAddressInput {
label {RIST Address}
callback rist_address_cb selected
xywh {390 33 218 22}
}
Fl_Input rtmpAddressInput {
label {RTMP Server}
callback rtmp_address_cb selected
xywh {390 60 218 22}
}
Fl_Input rtmpKeyInput {
label {RTMP Key}
callback rtmp_key_cb selected
xywh {390 88 218 22}
}
}
Fl_Group {} {
label {RIST Settings} open
xywh {765 28 95 149}
} {
Fl_Input ristBandwidthInput {
label Bandwidth
callback rist_bandwidth_cb
xywh {685 83 92 22}
xywh {765 28 92 22}
}
Fl_Input ristBufferMinInput {
label {Buffer Min}
callback rist_buffer_min_cb
xywh {765 53 92 22}
}
Fl_Input ristBufferMaxInput {
label {Buffer Max}
callback rist_buffer_max_cb
xywh {765 78 92 22}
}
Fl_Input ristRttMinInput {
label {RTT Min}
callback rist_rtt_min_cb
xywh {765 103 92 22}
}
Fl_Input ristRttMaxInput {
label {RTT Max}
callback rist_rtt_max_cb
xywh {765 128 92 22}
}
Fl_Input ristReorderBufferInput {
label {Reorder Buffer}
callback rist_reorder_buffer_cb
xywh {765 153 92 22}
}
}
Fl_Button btnStartStream {
Expand All @@ -123,45 +158,40 @@ class UserInterface {open
}
Fl_Group statsGroup {
label Stats
xywh {845 20 266 200}
xywh {1040 25 266 200}
} {
Fl_Output bandwidthOutput {
label Bandwidth
xywh {940 45 165 24}
xywh {1135 50 165 24}
}
Fl_Output linkQualityOutput {
label {Link Quality}
xywh {940 71 165 24}
xywh {1135 76 165 24}
}
Fl_Output retransmittedPacketsOutput {
label {Retransmitted Packets}
xywh {940 96 165 24}
xywh {1135 101 165 24}
}
Fl_Output rttOutput {
label RTT
xywh {940 146 165 24}
xywh {1135 151 165 24}
}
Fl_Output totalPacketsOutput {
label {Total Packets}
xywh {940 121 165 24}
label Packets
xywh {1135 126 165 24}
}
Fl_Output encodeBitrateOutput {
label {Encode Bitrate}
xywh {940 196 165 24}
xywh {1135 201 165 24}
}
}
Fl_Text_Display logDisplay {
label Log
xywh {21 246 1132 164}
xywh {21 246 1294 168}
}
Fl_Text_Display ristLogDisplay {
label {RIST Log}
xywh {22 431 1132 164}
}
Fl_Input rtmpAddressInput {
label RTMP
callback rtmp_address_cb selected
xywh {390 63 218 22}
xywh {22 431 1293 163}
}
}
}
Expand Down
18 changes: 14 additions & 4 deletions source/UserInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ extern void select_encoder_cb(Fl_Menu_*, void*);
#include <FL/Fl_Input.H>
extern void encoder_bitrate_cb(Fl_Input*, void*);
extern void rist_address_cb(Fl_Input*, void*);
extern void rist_buffer_cb(Fl_Input*, void*);
extern void rtmp_address_cb(Fl_Input*, void*);
extern void rtmp_key_cb(Fl_Input*, void*);
extern void rist_bandwidth_cb(Fl_Input*, void*);
extern void rist_buffer_min_cb(Fl_Input*, void*);
extern void rist_buffer_max_cb(Fl_Input*, void*);
extern void rist_rtt_min_cb(Fl_Input*, void*);
extern void rist_rtt_max_cb(Fl_Input*, void*);
extern void rist_reorder_buffer_cb(Fl_Input*, void*);
extern void startStream_cb(Fl_Button*, void*);
extern void stopStream_cb(Fl_Button*, void*);
#include <FL/Fl_Output.H>
#include <FL/Fl_Text_Display.H>
extern void rtmp_address_cb(Fl_Input*, void*);

class UserInterface {
public:
Expand All @@ -44,8 +49,14 @@ class UserInterface {
static Fl_Menu_Item *nvencEncoderChoice;
Fl_Input *encoderBitrateInput;
Fl_Input *ristAddressInput;
Fl_Input *ristBufferInput;
Fl_Input *rtmpAddressInput;
Fl_Input *rtmpKeyInput;
Fl_Input *ristBandwidthInput;
Fl_Input *ristBufferMinInput;
Fl_Input *ristBufferMaxInput;
Fl_Input *ristRttMinInput;
Fl_Input *ristRttMaxInput;
Fl_Input *ristReorderBufferInput;
Fl_Button *btnStartStream;
Fl_Button *btnStopStream;
Fl_Group *statsGroup;
Expand All @@ -57,7 +68,6 @@ class UserInterface {
Fl_Output *encodeBitrateOutput;
Fl_Text_Display *logDisplay;
Fl_Text_Display *ristLogDisplay;
Fl_Input *rtmpAddressInput;
void show(int argc, char **argv);
};
#endif
49 changes: 41 additions & 8 deletions source/ndi-rist-encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,15 @@ struct _Config
std::string encoder = "software";
std::string transport = "m2ts";
std::string bitrate = "4300";
std::string rist_output_address = "127.0.0.1:5000?bandwidth=10000buffer-min=245&buffer-max=5000&rtt-min=40&rtt-max=500&reorder-buffer=120&congestion-control=1";
std::string rist_output_buffer;
std::string rist_output_address = "127.0.0.1:5000";
std::string rist_output_buffer_min = "245";
std::string rist_output_buffer_max = "5000";
std::string rist_output_rtt_min = "40";
std::string rist_output_rtt_max = "500";
std::string rist_output_reorder_buffer = "120";
std::string rist_output_bandwidth = "6000";
std::string rtmpAddress = "";
std::string rtmpAddress = "sydney.restream.io/live";
std::string rtmpKey = "";
};

/* Globals */
Expand All @@ -95,7 +100,11 @@ void initUi()
ui->ristLogDisplay->buffer(ristLogBuff);
ui->ristAddressInput->value(config.rist_output_address.c_str());
ui->ristBandwidthInput->value(config.rist_output_bandwidth.c_str());
ui->ristBufferInput->value(config.rist_output_buffer.c_str());
ui->ristBufferMaxInput->value(config.rist_output_buffer_max.c_str());
ui->ristBufferMinInput->value(config.rist_output_buffer_min.c_str());
ui->ristRttMaxInput->value(config.rist_output_rtt_max.c_str());
ui->ristRttMinInput->value(config.rist_output_rtt_min.c_str());
ui->ristReorderBufferInput->value(config.rist_output_reorder_buffer.c_str());
ui->encoderBitrateInput->value(config.bitrate.c_str());
ui->show(NULL, NULL);
}
Expand Down Expand Up @@ -361,7 +370,13 @@ void *runEncodeThread(void *p)
RISTNetSender::RISTNetSenderSettings mySendConfiguration;

// Generate a vector of RIST URL's, ip(name), ports, RIST URL output, listen(true) or send mode (false)
std::string lURL = fmt::format("rist://{}", config.rist_output_address);
std::string lURL = fmt::format("rist://{}??bandwidth={}buffer-min={}&buffer-max={}&rtt-min={}&rtt-max={}&reorder-buffer={}",
config.rist_output_address,
config.rist_output_buffer_min,
config.rist_output_buffer_max,
config.rist_output_rtt_min,
config.rist_output_rtt_max,
config.rist_output_reorder_buffer);
std::vector<std::tuple<std::string, int>> interfaceListSender;
// if (RISTNetTools::buildRISTURL(config.rist_output_address, config.rist_output_port, lURL, false))
// {
Expand Down Expand Up @@ -516,7 +531,7 @@ void startStream()
Url url{ fmt::format("rist://{}", config.rist_output_address) };

rpc::client client(url.getHost(), 5999);
auto result = client.call("start", fmt::format("rtmp://{} live=true", config.rtmpAddress));
auto result = client.call("start", fmt::format("rtmp://{}/{} live=true", config.rtmpAddress, config.rtmpKey));
}
catch(const std::exception& e)
{
Expand Down Expand Up @@ -665,16 +680,34 @@ void rtmp_address_cb(Fl_Input *o, void *v)
config.rtmpAddress = o->value();
}

void rist_buffer_cb(Fl_Input *o, void *v)
void rtmp_key_cb(Fl_Input *o, void *v)
{
config.rist_output_buffer = o->value();
config.rtmpKey = o->value();
}

void rist_bandwidth_cb(Fl_Input *o, void *v)
{
config.rist_output_bandwidth = o->value();
}

void rist_buffer_min_cb(Fl_Input *o, void *v)
{
config.rist_output_buffer_min = o->value();
}

void rist_buffer_max_cb(Fl_Input* o, void* v){
config.rist_output_buffer_max = o->value();
}
void rist_rtt_min_cb(Fl_Input* o, void* v){
config.rist_output_rtt_min = o->value();
}
void rist_rtt_max_cb(Fl_Input* o, void* v){
config.rist_output_rtt_max = o->value();
}
void rist_reorder_buffer_cb(Fl_Input* o, void* v){
config.rist_output_reorder_buffer = o->value();
}

void encoder_bitrate_cb(Fl_Input *o, void *v)
{
config.bitrate = o->value();
Expand Down

0 comments on commit 8a4fed3

Please sign in to comment.