From b9f6107528dfade3f5aa2a60ca3791fce2285296 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Wed, 11 May 2016 15:08:22 +0200 Subject: [PATCH] Implemented push setting storage. --- src/controller/controller_api.cpp | 4 ++++ src/controller/controller_push.cpp | 20 ++++++++++++++++++++ src/controller/controller_push.h | 5 +++++ 3 files changed, 29 insertions(+) diff --git a/src/controller/controller_api.cpp b/src/controller/controller_api.cpp index 61087ff9..0df116d6 100644 --- a/src/controller/controller_api.cpp +++ b/src/controller/controller_api.cpp @@ -616,6 +616,10 @@ int Controller::handleAPIConnection(Socket::Connection & conn){ Response["push_auto_list"] = Controller::Storage["autopushes"]; } + if (Request.isMember("push_settings")){ + Controller::pushSettings(Request["push_settings"], Response["push_settings"]); + } + Controller::configChanged = true; }else{//unauthorized diff --git a/src/controller/controller_push.cpp b/src/controller/controller_push.cpp index ff7667a5..09a30d8b 100644 --- a/src/controller/controller_push.cpp +++ b/src/controller/controller_push.cpp @@ -12,6 +12,9 @@ namespace Controller { /// Internal list of currently active pushes std::map activePushes; + /// Internal list of waiting pushes + std::deque waitingPushes; + /// Immediately starts a push for the given stream to the given target. /// Simply calls Util::startPush and stores the resulting PID in the local activePushes map. void startPush(std::string & stream, std::string & target){ @@ -30,6 +33,10 @@ namespace Controller { Util::Procs::Stop(ID); } + /// Loops, checking every second if any pushes need restarting. + void pushCheckLoop(){ + } + /// Gives a list of all currently active pushes void listPush(JSON::Value & output){ output.null(); @@ -116,5 +123,18 @@ namespace Controller { } } + void pushSettings(const JSON::Value & request, JSON::Value & response){ + if (request.isObject()){ + if (request.isMember("wait")){ + Controller::Storage["push_settings"]["wait"] = request["wait"].asInt(); + } + if (request.isMember("maxspeed")){ + Controller::Storage["push_settings"]["maxspeed"] = request["maxspeed"].asInt(); + } + + } + response = Controller::Storage["push_settings"]; + } + } diff --git a/src/controller/controller_push.h b/src/controller/controller_push.h index f2ca128a..8b1e0c14 100644 --- a/src/controller/controller_push.h +++ b/src/controller/controller_push.h @@ -14,6 +14,11 @@ namespace Controller { void removePush(const JSON::Value & request); void removePush(const std::string & streamname); + //internal use only void doAutoPush(std::string & streamname); + void pushCheckLoop(); + + //for storing/retrieving settings + void pushSettings(const JSON::Value & request, JSON::Value & response); }