X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=input.cpp;h=3f6a9d73ee42095b7462ba32a93088c5a60aadfb;hp=00b654734f2aac406dd0bc34826b13fc76d4d61a;hb=ca9624c43b968a0f29ea44e47851ff686bb64bb6;hpb=f583e4d329222d8ce2a11524e924c02139b4f28d diff --git a/input.cpp b/input.cpp index 00b6547..3f6a9d7 100644 --- a/input.cpp +++ b/input.cpp @@ -2,6 +2,7 @@ #include #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; }