Skip to content

Commit 1d58971

Browse files
committed
onebinary: it almost works!
1 parent 8c2d888 commit 1d58971

File tree

8 files changed

+56
-19
lines changed

8 files changed

+56
-19
lines changed

src/controller/controller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ int main_loop(int argc, char **argv){
618618

619619
///\brief The controller angel process.
620620
/// Starts a forked main_loop in a loop. Yes, you read that right.
621-
int main(int argc, char **argv){
621+
int ControllerMain(int argc, char **argv){
622622
Util::Procs::setHandler(); // set child handler
623623
{
624624
struct sigaction new_action;

src/controller/controller_capabilities.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
#include "controller_capabilities.h"
2+
#include "../output/output_rtmp.h"
3+
#include "../output/output_hls.h"
4+
#include "../output/output_http_internal.h"
5+
#include "../input/input_buffer.h"
26
#include <fstream>
37
#include <mist/config.h>
48
#include <mist/defines.h>
@@ -249,6 +253,7 @@ namespace Controller{
249253

250254
/// Aquire list of available protocols, storing in global 'capabilities' JSON::Value.
251255
void checkAvailProtocols(){
256+
#ifdef GO_AWAY
252257
std::deque<std::string> execs;
253258
Util::getMyExec(execs);
254259
std::string arg_one;
@@ -313,6 +318,15 @@ namespace Controller{
313318
}
314319
}
315320
}
321+
#else
322+
// Mist::OutHTTP
323+
// Mist::OutRTMP
324+
// Mist::inputBuffer
325+
capabilities["inputs"]["Buffer"] = JSON::fromString(Mist::inputBuffer::capa.toString());
326+
capabilities["connectors"]["HLS"] = JSON::fromString(Mist::OutHLS::capa.toString());
327+
capabilities["connectors"]["HTTP"] = JSON::fromString(Mist::OutHTTP::capa.toString());
328+
capabilities["connectors"]["RTMP"] = JSON::fromString(Mist::OutRTMP::capa.toString());
329+
#endif
316330
}
317331

318332
///\brief A class storing information about the cpu the server is running on.

src/controller/controller_connectors.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ namespace Controller{
126126
}
127127

128128
static inline void buildPipedArguments(JSON::Value &p, char *argarr[], const JSON::Value &capabilities){
129-
int argnum = 0;
129+
int argnum = 1;
130130
static std::string tmparg;
131-
tmparg = Util::getMyPath() + std::string("MistOut") + p["connector"].asStringRef();
132-
struct stat buf;
133-
if (::stat(tmparg.c_str(), &buf) != 0){
134-
tmparg = Util::getMyPath() + std::string("MistConn") + p["connector"].asStringRef();
135-
}
136-
if (::stat(tmparg.c_str(), &buf) != 0){return;}
131+
tmparg = std::string("MistOut") + p["connector"].asStringRef();
132+
// struct stat buf;
133+
// if (::stat(tmparg.c_str(), &buf) != 0){
134+
// tmparg = Util::getMyPath() + std::string("MistConn") + p["connector"].asStringRef();
135+
// }
136+
// if (::stat(tmparg.c_str(), &buf) != 0){return;}
137137
argarr[argnum++] = (char *)tmparg.c_str();
138138
const JSON::Value &pipedCapa = capabilities["connectors"][p["connector"].asStringRef()];
139139
if (pipedCapa.isMember("required")){builPipedPart(p, argarr, argnum, pipedCapa["required"]);}
@@ -160,7 +160,7 @@ namespace Controller{
160160

161161
// used for building args
162162
int err = fileno(stderr);
163-
char *argarr[15]; // approx max # of args (with a wide margin)
163+
char *argarr[16] = {"/home/iameli/code/mistserver/build/MistServer"}; // approx max # of args (with a wide margin)
164164
int i;
165165

166166
std::string tmp;
@@ -255,11 +255,12 @@ namespace Controller{
255255
Log("CONF", "Starting connector: " + *runningConns.begin());
256256
action = true;
257257
// clear out old args
258-
for (i = 0; i < 15; i++){argarr[i] = 0;}
258+
for (i = 1; i < 16; i++){argarr[i] = 0;}
259259
// get args for this connector
260260
JSON::Value p = JSON::fromString(*runningConns.begin());
261261
buildPipedArguments(p, (char **)&argarr, capabilities);
262262
// start piped w/ generated args
263+
INFO_MSG("piped command[0]: %s [1]: %s", argarr[0], argarr[1])
263264
currentConnectors[*runningConns.begin()] = Util::Procs::StartPiped(argarr, 0, 0, &err);
264265
Triggers::doTrigger("OUTPUT_START", *runningConns.begin()); // LTS
265266
}

src/input/input.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
namespace Mist{
2020
Util::Config *Input::config = NULL;
21+
JSON::Value Input::capa = JSON::Value();
2122

2223
void Input::userLeadIn(){
2324
connectedUsers = 0;

src/input/input.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ namespace Mist{
5454
virtual bool needsLock(){return !config->getBool("realtime");}
5555
virtual bool publishesTracks(){return true;}
5656

57+
static JSON::Value capa;
58+
5759
protected:
5860
bool internalOnly;
5961
bool isBuffer;
@@ -104,8 +106,6 @@ namespace Mist{
104106

105107
uint64_t activityCounter;
106108

107-
JSON::Value capa;
108-
109109
std::map<size_t, std::set<uint64_t> > keyTimes;
110110
std::map<trackKey, uint64_t> keyLoadPriority;
111111

src/meson.build

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,28 @@ executables += {
2727
'output/output_http_internal.cpp',
2828
'output/output_ts.cpp',
2929
'output/output_ts_base.cpp',
30-
'output/output_rtmp.cpp'
30+
'output/output_rtmp.cpp',
31+
'controller/controller_external_writers.cpp',
32+
'controller/controller_updater.cpp',
33+
'controller/controller_streams.cpp',
34+
'controller/controller_storage.cpp',
35+
'controller/controller_connectors.cpp',
36+
'controller/controller_statistics.cpp',
37+
'controller/controller_limits.cpp',
38+
'controller/controller_capabilities.cpp',
39+
'controller/controller_uplink.cpp',
40+
'controller/controller_api.cpp',
41+
'controller/controller_push.cpp',
42+
'controller/controller_variables.cpp',
3143
),
3244
io_cpp,
3345
header_tgts,
34-
embed_tgts
46+
embed_tgts,
47+
server_html
3548
],
3649
'defines': [
3750
'-DTS_BASECLASS=HTTPOutput',
51+
'-DONE_BINARY=true',
3852
],
3953
'deps' : [libmist_dep]
4054
}

src/mistserver.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
#include "input/mist_in.cpp"
1111
#include "input/input_buffer.h"
1212
#include "session.cpp"
13+
#include "controller/controller.cpp"
1314

1415
int main(int argc, char *argv[]){
16+
INFO_MSG("starting")
1517
if (argc < 2) {
16-
INFO_MSG("usage: %s [MistSomething]", argv[0]);
17-
return 1;
18+
return 201;
1819
}
1920
// Create a new argv array without argv[1]
2021
int new_argc = argc - 1;
@@ -24,6 +25,9 @@ int main(int argc, char *argv[]){
2425
new_argv[j++] = argv[i];
2526
}
2627
}
28+
if (strcmp(argv[1], "MistController") == 0) {
29+
return ControllerMain(new_argc, new_argv);
30+
}
2731
if (strcmp(argv[1], "MistOutHLS") == 0) {
2832
return OutputMain<Mist::OutHLS>(new_argc, new_argv);
2933
}
@@ -39,6 +43,9 @@ int main(int argc, char *argv[]){
3943
else if (strcmp(argv[1], "MistSession") == 0) {
4044
return SessionMain(new_argc, new_argv);
4145
}
46+
else {
47+
return ControllerMain(argc, argv);
48+
}
4249
INFO_MSG("binary not found: %s", argv[1]);
43-
return 0;
50+
return 202;
4451
}

src/output/mist_out.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ int spawnForked(Socket::Connection &S){
1717
return tmp.run();
1818
}
1919

20-
void handleUSR1(int signum, siginfo_t *sigInfo, void *ignore){
20+
void handleUSR1Output(int signum, siginfo_t *sigInfo, void *ignore){
2121
HIGH_MSG("USR1 received - triggering rolling restart");
2222
Util::Config::is_restarting = true;
2323
Util::logExitReason(ER_CLEAN_SIGNAL, "signal USR1");
@@ -54,7 +54,7 @@ int OutputMain(int argc, char *argv[]){
5454
if (T::listenMode()){
5555
{
5656
struct sigaction new_action;
57-
new_action.sa_sigaction = handleUSR1;
57+
new_action.sa_sigaction = handleUSR1Output;
5858
sigemptyset(&new_action.sa_mask);
5959
new_action.sa_flags = 0;
6060
sigaction(SIGUSR1, &new_action, NULL);

0 commit comments

Comments
 (0)