#include "output_httpts.h" #include #include #include #include namespace Mist { OutHTTPTS::OutHTTPTS(Socket::Connection & conn) : TSOutput(conn) {} OutHTTPTS::~OutHTTPTS() {} void OutHTTPTS::init(Util::Config * cfg){ HTTPOutput::init(cfg); capa["name"] = "HTTPTS"; capa["desc"] = "Enables HTTP protocol MPEG2/TS pseudostreaming."; capa["url_rel"] = "/$.ts"; capa["url_match"] = "/$.ts"; capa["socket"] = "http_ts"; capa["codecs"][0u][0u].append("H264"); capa["codecs"][0u][1u].append("AAC"); capa["codecs"][0u][1u].append("MP3"); capa["methods"][0u]["handler"] = "http"; capa["methods"][0u]["type"] = "html5/video/mp2t"; capa["methods"][0u]["priority"] = 1ll; } void OutHTTPTS::onHTTP(){ std::string method = H.method; initialize(); H.clearHeader("Range"); H.clearHeader("Icy-MetaData"); H.clearHeader("User-Agent"); H.SetHeader("Content-Type", "video/mpeg"); H.setCORSHeaders(); if(method == "OPTIONS" || method == "HEAD"){ H.SendResponse("200", "OK", myConn); H.Clean(); return; } H.protocol = "HTTP/1.0";//Force HTTP/1.0 because some devices just don't understand chunked replies H.StartResponse(H, myConn); parseData = true; wantRequest = false; } void OutHTTPTS::sendTS(const char * tsData, unsigned int len){ H.Chunkify(tsData, len, myConn); } }