HTTP proxy rewrite, by Wouter Spruit.
This commit is contained in:
parent
00d1dfb1e5
commit
81d56bc04b
13 changed files with 191 additions and 244 deletions
32
src/output/mist_out_http.cpp
Normal file
32
src/output/mist_out_http.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
#include OUTPUTTYPE
|
||||
#include <mist/config.h>
|
||||
#include <mist/socket.h>
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
Util::Config conf(argv[0], PACKAGE_VERSION);
|
||||
mistOut::init(&conf);
|
||||
|
||||
mistOut::capa["forward"]["streamname"]["name"] = "Stream";
|
||||
mistOut::capa["forward"]["streamname"]["help"] = "What streamname to serve.";
|
||||
mistOut::capa["forward"]["streamname"]["type"] = "str";
|
||||
mistOut::capa["forward"]["streamname"]["option"] = "--stream";
|
||||
mistOut::capa["forward"]["ip"]["name"] = "IP";
|
||||
mistOut::capa["forward"]["ip"]["help"] = "IP of forwarded connection.";
|
||||
mistOut::capa["forward"]["ip"]["type"] = "str";
|
||||
mistOut::capa["forward"]["ip"]["option"] = "--ip";
|
||||
|
||||
conf.addOption("streamname",
|
||||
JSON::fromString("{\"arg\":\"string\",\"short\":\"s\",\"long\":\"stream\",\"help\":\"The name of the stream that this connector will transmit.\"}"));
|
||||
conf.addOption("ip",
|
||||
JSON::fromString("{\"arg\":\"string\",\"short\":\"i\",\"long\":\"ip\",\"help\":\"Ip addr of connection.\"}"));
|
||||
if (conf.parseArgs(argc, argv)) {
|
||||
if (conf.getBool("json")) {
|
||||
std::cout << mistOut::capa.toString() << std::endl;
|
||||
return -1;
|
||||
}
|
||||
Socket::Connection S(fileno(stdout),fileno(stdin) );
|
||||
mistOut tmp(S);
|
||||
return tmp.run();
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -123,6 +123,8 @@ namespace Mist {
|
|||
OutHDS::OutHDS(Socket::Connection & conn) : Output(conn) {
|
||||
audioTrack = 0;
|
||||
playUntil = 0;
|
||||
myConn.setHost(config->getString("ip"));
|
||||
streamName = config->getString("streamname");
|
||||
}
|
||||
|
||||
void OutHDS::onFail(){
|
||||
|
@ -170,8 +172,6 @@ namespace Mist {
|
|||
while (HTTP_R.Read(myConn)){
|
||||
DEBUG_MSG(DLVL_DEVEL, "Received request: %s", HTTP_R.getUrl().c_str());
|
||||
if (HTTP_R.url.find(".abst") != std::string::npos){
|
||||
myConn.setHost(HTTP_R.GetHeader("X-Origin"));
|
||||
streamName = HTTP_R.GetHeader("X-Stream");
|
||||
initialize();
|
||||
std::string streamID = HTTP_R.url.substr(streamName.size() + 10);
|
||||
streamID = streamID.substr(0, streamID.find(".abst"));
|
||||
|
@ -184,8 +184,6 @@ namespace Mist {
|
|||
continue;
|
||||
}
|
||||
if (HTTP_R.url.find("f4m") == std::string::npos){
|
||||
myConn.setHost(HTTP_R.GetHeader("X-Origin"));
|
||||
streamName = HTTP_R.GetHeader("X-Stream");
|
||||
initialize();
|
||||
std::string tmp_qual = HTTP_R.url.substr(HTTP_R.url.find("/", 10) + 1);
|
||||
unsigned int tid;
|
||||
|
@ -246,8 +244,6 @@ namespace Mist {
|
|||
parseData = true;
|
||||
wantRequest = false;
|
||||
}else{
|
||||
myConn.setHost(HTTP_R.GetHeader("X-Origin"));
|
||||
streamName = HTTP_R.GetHeader("X-Stream");
|
||||
initialize();
|
||||
std::stringstream tmpstr;
|
||||
myMeta.toPrettyString(tmpstr);
|
||||
|
|
|
@ -75,6 +75,8 @@ namespace Mist {
|
|||
|
||||
OutHLS::OutHLS(Socket::Connection & conn) : Output(conn) {
|
||||
haveAvcc = false;
|
||||
myConn.setHost(config->getString("ip"));
|
||||
streamName = config->getString("streamname");
|
||||
}
|
||||
|
||||
OutHLS::~OutHLS() {}
|
||||
|
@ -212,9 +214,7 @@ namespace Mist {
|
|||
void OutHLS::onRequest(){
|
||||
while (HTTP_R.Read(myConn)){
|
||||
DEBUG_MSG(DLVL_DEVEL, "Received request: %s", HTTP_R.getUrl().c_str());
|
||||
myConn.setHost(HTTP_R.GetHeader("X-Origin"));
|
||||
AppleCompat = (HTTP_R.GetHeader("User-Agent").find("Apple") != std::string::npos);
|
||||
streamName = HTTP_R.GetHeader("X-Stream");
|
||||
initialize();
|
||||
if (HTTP_R.url.find(".m3u") == std::string::npos){
|
||||
std::string tmpStr = HTTP_R.getUrl();
|
||||
|
@ -257,7 +257,6 @@ namespace Mist {
|
|||
parseData = true;
|
||||
wantRequest = false;
|
||||
}else{
|
||||
streamName = HTTP_R.GetHeader("X-Stream");
|
||||
initialize();
|
||||
std::string request = HTTP_R.url.substr(HTTP_R.url.find("/", 5) + 1);
|
||||
HTTP_S.Clean();
|
||||
|
|
|
@ -44,7 +44,10 @@ std::string toUTF16(std::string original) {
|
|||
|
||||
|
||||
namespace Mist {
|
||||
OutHSS::OutHSS(Socket::Connection & conn) : Output(conn) { }
|
||||
OutHSS::OutHSS(Socket::Connection & conn) : Output(conn) {
|
||||
myConn.setHost(config->getString("ip"));
|
||||
streamName = config->getString("streamname");
|
||||
}
|
||||
|
||||
OutHSS::~OutHSS() {}
|
||||
|
||||
|
@ -449,8 +452,6 @@ namespace Mist {
|
|||
sentHeader = false;
|
||||
while (HTTP_R.Read(myConn)) {
|
||||
DEBUG_MSG(DLVL_DEVEL, "(%d) Received request %s", getpid(), HTTP_R.getUrl().c_str());
|
||||
myConn.setHost(HTTP_R.GetHeader("X-Origin"));
|
||||
streamName = HTTP_R.GetHeader("X-Stream");
|
||||
initialize();
|
||||
if (HTTP_R.url.find("Manifest") != std::string::npos) {
|
||||
//Manifest, direct reply
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
namespace Mist {
|
||||
OutJSON::OutJSON(Socket::Connection & conn) : Output(conn){
|
||||
realTime = 0;
|
||||
myConn.setHost(config->getString("ip"));
|
||||
streamName = config->getString("streamname");
|
||||
}
|
||||
|
||||
OutJSON::~OutJSON() {}
|
||||
|
@ -60,8 +62,6 @@ namespace Mist {
|
|||
while (HTTP_R.Read(myConn)){
|
||||
DEBUG_MSG(DLVL_DEVEL, "Received request %s", HTTP_R.getUrl().c_str());
|
||||
first = true;
|
||||
myConn.setHost(HTTP_R.GetHeader("X-Origin"));
|
||||
streamName = HTTP_R.GetHeader("X-Stream");
|
||||
jsonp = "";
|
||||
if (HTTP_R.GetVar("callback") != ""){
|
||||
jsonp = HTTP_R.GetVar("callback");
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
#include <mist/defines.h>
|
||||
|
||||
namespace Mist {
|
||||
OutProgressiveFLV::OutProgressiveFLV(Socket::Connection & conn) : Output(conn) { }
|
||||
OutProgressiveFLV::OutProgressiveFLV(Socket::Connection & conn) : Output(conn) {
|
||||
myConn.setHost(config->getString("ip"));
|
||||
streamName = config->getString("streamname");
|
||||
}
|
||||
|
||||
OutProgressiveFLV::~OutProgressiveFLV() {}
|
||||
|
||||
|
@ -78,8 +81,6 @@ namespace Mist {
|
|||
if (HTTP_R.GetVar("video") != ""){
|
||||
selectedTracks.insert(JSON::Value(HTTP_R.GetVar("video")).asInt());
|
||||
}
|
||||
myConn.setHost(HTTP_R.GetHeader("X-Origin"));
|
||||
streamName = HTTP_R.GetHeader("X-Stream");
|
||||
parseData = true;
|
||||
wantRequest = false;
|
||||
HTTP_R.Clean();
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
#include <mist/defines.h>
|
||||
|
||||
namespace Mist {
|
||||
OutProgressiveMP3::OutProgressiveMP3(Socket::Connection & conn) : Output(conn) { }
|
||||
OutProgressiveMP3::OutProgressiveMP3(Socket::Connection & conn) : Output(conn) {
|
||||
myConn.setHost(config->getString("ip"));
|
||||
streamName = config->getString("streamname");
|
||||
}
|
||||
|
||||
OutProgressiveMP3::~OutProgressiveMP3() {}
|
||||
|
||||
|
@ -55,8 +58,6 @@ namespace Mist {
|
|||
if (HTTP_R.GetVar("audio") != ""){
|
||||
selectedTracks.insert(JSON::Value(HTTP_R.GetVar("audio")).asInt());
|
||||
}
|
||||
myConn.setHost(HTTP_R.GetHeader("X-Origin"));
|
||||
streamName = HTTP_R.GetHeader("X-Stream");
|
||||
parseData = true;
|
||||
wantRequest = false;
|
||||
HTTP_R.Clean();
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
#include <mist/mp4_generic.h>
|
||||
|
||||
namespace Mist {
|
||||
OutProgressiveMP4::OutProgressiveMP4(Socket::Connection & conn) : Output(conn) { }
|
||||
OutProgressiveMP4::OutProgressiveMP4(Socket::Connection & conn) : Output(conn) {
|
||||
myConn.setHost(config->getString("ip"));
|
||||
streamName = config->getString("streamname");
|
||||
}
|
||||
|
||||
OutProgressiveMP4::~OutProgressiveMP4() {}
|
||||
|
||||
|
@ -401,8 +404,6 @@ namespace Mist {
|
|||
void OutProgressiveMP4::onRequest(){
|
||||
if (HTTP_R.Read(myConn)){
|
||||
DEBUG_MSG(DLVL_MEDIUM, "Received request: %s", HTTP_R.getUrl().c_str());
|
||||
myConn.setHost(HTTP_R.GetHeader("X-Origin"));
|
||||
streamName = HTTP_R.GetHeader("X-Stream");
|
||||
if (HTTP_R.GetVar("audio") != ""){
|
||||
selectedTracks.insert(JSON::Value(HTTP_R.GetVar("audio")).asInt());
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
namespace Mist {
|
||||
OutProgressiveSRT::OutProgressiveSRT(Socket::Connection & conn) : Output(conn) {
|
||||
realTime = 0;
|
||||
myConn.setHost(config->getString("ip"));
|
||||
streamName = config->getString("streamname");
|
||||
}
|
||||
|
||||
void OutProgressiveSRT::onFail(){
|
||||
|
@ -72,8 +74,6 @@ namespace Mist {
|
|||
if (HTTP_R.GetVar("track") != ""){
|
||||
selectedTracks.insert(JSON::Value(HTTP_R.GetVar("track")).asInt());
|
||||
}
|
||||
myConn.setHost(HTTP_R.GetHeader("X-Origin"));
|
||||
streamName = HTTP_R.GetHeader("X-Stream");
|
||||
parseData = true;
|
||||
wantRequest = false;
|
||||
HTTP_R.Clean();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue