]> git.sesse.net Git - cubemap/blobdiff - input.cpp
When re-execing, try with --test-config first, and revert if it fails.
[cubemap] / input.cpp
index 00b654734f2aac406dd0bc34826b13fc76d4d61a..3f6a9d73ee42095b7462ba32a93088c5a60aadfb 100644 (file)
--- a/input.cpp
+++ b/input.cpp
@@ -2,6 +2,7 @@
 #include <string>
 
 #include "httpinput.h"
+#include "udpinput.h"
 #include "input.h"
 #include "state.pb.h"
 
@@ -10,18 +11,18 @@ using namespace std;
 // Extremely rudimentary URL parsing.
 bool parse_url(const string &url, string *protocol, string *host, string *port, string *path)
 {
-       if (url.find("http://") != 0) {
+       size_t split = url.find("://");
+       if (split == string::npos) {
                return false;
        }
+       *protocol = string(url.begin(), url.begin() + split);
 
-       *protocol = "http";
-       
-       string rest = url.substr(strlen("http://"));
-       size_t split = rest.find_first_of(":/");
+       string rest = string(url.begin() + split + 3, url.end());
+       split = rest.find_first_of(":/");
        if (split == string::npos) {
                // http://foo
                *host = rest;
-               *port = "http";
+               *port = *protocol;
                *path = "/";
                return true;
        }
@@ -47,7 +48,7 @@ bool parse_url(const string &url, string *protocol, string *host, string *port,
        }
 
        // http://foo/bar
-       *port = "http";
+       *port = *protocol;
        *path = rest;
        return true;
 }
@@ -61,6 +62,9 @@ Input *create_input(const std::string &stream_id, const std::string &url)
        if (protocol == "http") {
                return new HTTPInput(stream_id, url);
        }
+       if (protocol == "udp") {
+               return new UDPInput(stream_id, url);
+       }
        return NULL;
 }
 
@@ -73,6 +77,9 @@ Input *create_input(const InputProto &serialized)
        if (protocol == "http") {
                return new HTTPInput(serialized);
        }
+       if (protocol == "udp") {
+               return new UDPInput(serialized);
+       }
        return NULL;
 }