]> git.sesse.net Git - cubemap/blobdiff - input.cpp
More support for multiple input types.
[cubemap] / input.cpp
index 1e617807d0058c88b92d6b5f8b13da97c0c837c2..00b654734f2aac406dd0bc34826b13fc76d4d61a 100644 (file)
--- a/input.cpp
+++ b/input.cpp
@@ -1,7 +1,9 @@
 #include <string.h>
 #include <string>
 
+#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() {}