]> git.sesse.net Git - cubemap/blobdiff - main.cpp
Support UDP input. Also fix some issues with socket closing.
[cubemap] / main.cpp
index e258c86424dddcdd614dd3784d4ef59d40c50725..d77fb2e357cfbdc2f41c2abfcc3a90e3e5b31695 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -25,7 +25,6 @@
 #include "server.h"
 #include "serverpool.h"
 #include "input.h"
-#include "httpinput.h"
 #include "stats.h"
 #include "version.h"
 #include "state.pb.h"
@@ -216,7 +215,7 @@ vector<Acceptor *> create_acceptors(
                        acceptor = deserialized_acceptor_it->second;
                        deserialized_acceptors->erase(deserialized_acceptor_it);
                } else {
-                       int server_sock = create_server_socket(port);
+                       int server_sock = create_server_socket(port, TCP_SOCKET);
                        acceptor = new Acceptor(server_sock, port);
                }
                acceptor->run();
@@ -263,13 +262,19 @@ vector<Input *> create_inputs(const vector<ConfigLine> &config,
                        if (input->get_url() != src) {
                                fprintf(stderr, "INFO: Stream '%s' has changed URL from '%s' to '%s', restarting input.\n",
                                        stream_id.c_str(), input->get_url().c_str(), src.c_str());
+                               input->close_socket();
                                delete input;
                                input = NULL;
                        }
                        deserialized_inputs->erase(deserialized_input_it);
                }
                if (input == NULL) {
-                       input = new HTTPInput(stream_id, src);
+                       input = create_input(stream_id, src);
+                       if (input == NULL) {
+                               fprintf(stderr, "ERROR: did not understand URL '%s', clients will not get any data.\n",
+                                       src.c_str());
+                               continue;
+                       }
                }
                input->run();
                inputs.push_back(input);
@@ -360,7 +365,7 @@ int main(int argc, char **argv)
                for (int i = 0; i < loaded_state.inputs_size(); ++i) {
                        deserialized_inputs.insert(make_pair(
                                loaded_state.inputs(i).stream_id(),
-                               new HTTPInput(loaded_state.inputs(i))));
+                               create_input(loaded_state.inputs(i))));
                } 
 
                // Convert the acceptor from older serialized formats.