X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=input.cpp;fp=input.cpp;h=00b654734f2aac406dd0bc34826b13fc76d4d61a;hp=1e617807d0058c88b92d6b5f8b13da97c0c837c2;hb=7c4707af4ea7af05e34bc0414d18d9fd54e4f23e;hpb=742f56c25bdd54dc438b21cb5e422de520bc7231 diff --git a/input.cpp b/input.cpp index 1e61780..00b6547 100644 --- a/input.cpp +++ b/input.cpp @@ -1,7 +1,9 @@ #include #include +#include "httpinput.h" #include "input.h" +#include "state.pb.h" using namespace std; @@ -50,5 +52,29 @@ bool parse_url(const string &url, string *protocol, string *host, string *port, return true; } +Input *create_input(const std::string &stream_id, const std::string &url) +{ + string protocol, host, port, path; + if (!parse_url(url, &protocol, &host, &port, &path)) { + return NULL; + } + if (protocol == "http") { + return new HTTPInput(stream_id, url); + } + return NULL; +} + +Input *create_input(const InputProto &serialized) +{ + string protocol, host, port, path; + if (!parse_url(serialized.url(), &protocol, &host, &port, &path)) { + return NULL; + } + if (protocol == "http") { + return new HTTPInput(serialized); + } + return NULL; +} + Input::~Input() {}