This commit is contained in:
parent
8722effe2f
commit
ebc1b9f093
5 changed files with 39 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
|||
SRC = main.cpp ../util/socket.cpp ../util/http_parser.cpp ../util/flv_tag.cpp ../util/amf.cpp ../util/dtsc.cpp ../util/config.cpp ../util/base64.cpp
|
||||
SRC = main.cpp ../util/socket.cpp ../util/http_parser.cpp ../util/flv_tag.cpp ../util/amf.cpp ../util/dtsc.cpp ../util/config.cpp ../util/base64.cpp ../util/json.cpp
|
||||
OBJ = $(SRC:.cpp=.o)
|
||||
OUT = MistConnHTTP
|
||||
INCLUDES =
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <ctime>
|
||||
#include "../util/socket.h"
|
||||
#include "../util/http_parser.h"
|
||||
#include "../util/json.h"
|
||||
#include "../util/dtsc.h"
|
||||
#include "../util/flv_tag.h"
|
||||
#include "../util/MP4/interface.cpp"
|
||||
|
@ -187,6 +188,28 @@ namespace Connector_HTTP{
|
|||
printf("Sending crossdomain.xml file\n");
|
||||
#endif
|
||||
}
|
||||
if (HTTP_R.url.substr(0, 7) == "/embed_" && HTTP_R.url.substr(HTTP_R.url.length() - 3, 3) == ".js"){
|
||||
streamname = HTTP_R.url.substr(7, HTTP_R.url.length() - 10);
|
||||
JSON::Value ServConf = JSON::fromFile("/tmp/mist/streamlist");
|
||||
std::string response;
|
||||
handler = HANDLER_NONE;
|
||||
HTTP_S.Clean();
|
||||
HTTP_S.SetHeader("Content-Type", "application/javascript");
|
||||
response = "// Generating embed code for stream " + streamname + "\n\n";
|
||||
if (ServConf["streams"].isMember(streamname)){
|
||||
std::string streamurl = "http://" + HTTP_S.GetHeader("Host") + "/" + streamname + ".flv";
|
||||
response += "// Stream URL: " + streamurl + "\n\n";
|
||||
response += "document.write('<object width=\"600\" height=\"409\"><param name=\"movie\" value=\"http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf\"></param><param name=\"flashvars\" value=\"src="+HTTP::Parser::urlencode(streamurl)+"&controlBarMode=floating\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"600\" height=\"409\" flashvars=\"src="+HTTP::Parser::urlencode(streamurl)+"&controlBarMode=floating\"></embed></object>');\n";
|
||||
}else{
|
||||
response += "// Stream not available at this server.\nalert(\"This stream is currently not available at this server.\\\\nPlease try again later!\");";
|
||||
}
|
||||
response += "";
|
||||
HTTP_S.SetBody(response);
|
||||
HTTP_S.SendResponse(conn, "200", "OK");
|
||||
#if DEBUG >= 3
|
||||
printf("Sending embed code for %s\n", streamname.c_str());
|
||||
#endif
|
||||
}
|
||||
if (handler == HANDLER_FLASH){
|
||||
if (HTTP_R.url.find("f4m") == std::string::npos){
|
||||
Movie = HTTP_R.url.substr(1);
|
||||
|
|
|
@ -72,15 +72,6 @@ void WriteFile( std::string Filename, std::string contents ) {
|
|||
File.close( );
|
||||
}
|
||||
|
||||
std::string ReadFile( std::string Filename ) {
|
||||
std::string Result;
|
||||
std::ifstream File;
|
||||
File.open( Filename.c_str( ) );
|
||||
while( File.good( ) ) { Result += File.get( ); }
|
||||
File.close( );
|
||||
return Result;
|
||||
}
|
||||
|
||||
class ConnectedUser{
|
||||
public:
|
||||
std::string writebuffer;
|
||||
|
@ -268,7 +259,7 @@ void CheckAllStreams(JSON::Value & data){
|
|||
}
|
||||
}
|
||||
if (changed){
|
||||
WriteFile("/tmp/mist/streamlist", data.toString());
|
||||
WriteFile("/tmp/mist/streamlist", Storage.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -297,7 +288,7 @@ void CheckStreams(JSON::Value & in, JSON::Value & out){
|
|||
}
|
||||
out = in;
|
||||
if (changed){
|
||||
WriteFile("/tmp/mist/streamlist", out.toString());
|
||||
WriteFile("/tmp/mist/streamlist", Storage.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,7 +303,7 @@ int main(int argc, char ** argv){
|
|||
sigaction(SIGTERM, &new_action, NULL);
|
||||
sigaction(SIGPIPE, &new_action, NULL);
|
||||
|
||||
Storage = JSON::fromString(ReadFile("config.json"));
|
||||
Storage = JSON::fromFile("config.json");
|
||||
Util::Config C;
|
||||
C.listen_port = (long long int)Storage["config"]["controller"]["port"];
|
||||
if (C.listen_port < 1){C.listen_port = 4242;}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "json.h"
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
int JSON::Value::c2hex(int c){
|
||||
if (c >= '0' && c <= '9') return c - '0';
|
||||
|
@ -423,3 +424,13 @@ JSON::Value JSON::fromString(std::string json){
|
|||
std::istringstream is(json);
|
||||
return JSON::Value(is);
|
||||
}
|
||||
|
||||
/// Converts a file to a JSON::Value.
|
||||
JSON::Value JSON::fromFile(std::string filename){
|
||||
std::string Result;
|
||||
std::ifstream File;
|
||||
File.open(filename.c_str());
|
||||
while (File.good()){Result += File.get();}
|
||||
File.close( );
|
||||
return fromString(Result);
|
||||
}
|
||||
|
|
|
@ -69,5 +69,6 @@ namespace JSON{
|
|||
};
|
||||
|
||||
Value fromString(std::string json);
|
||||
Value fromFile(std::string filename);
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue