Progressive mode edits, RTMP edits. Also, TODO: AMF3 implementen. *barf*
This commit is contained in:
parent
4b9caee604
commit
1705640f24
7 changed files with 37 additions and 16 deletions
|
@ -1,4 +1,5 @@
|
|||
#!/bin/bash
|
||||
ffmpeg -re -i "$1" -b 1024000 -ar 11025 -f flv - 2> /dev/null | ./Buffer 500
|
||||
ffmpeg -re -i "$1" -b 1024000 -ar 11025 -f flv - 2> /dev/null | ./Buffer 500 $2
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
SRC = main.cpp ../sockets/sw_base.cpp ../sockets/sw_inet.cpp ../sockets/sw_unix.cpp
|
||||
SRC = main.cpp
|
||||
OBJ = $(SRC:.cpp=.o)
|
||||
OUT = Connector_HTTP
|
||||
INCLUDES =
|
||||
|
|
|
@ -140,8 +140,7 @@ int mainHandler(int CONN_fd){
|
|||
HTTP_S.SetHeader("Content-Type","video/mp4");
|
||||
HTTP_S.SetBody(Interface::mdatFold(FlashBuf));
|
||||
FlashBuf = "";
|
||||
std::string tmpresp = HTTP_S.BuildResponse("200", "OK");
|
||||
DDV_write(tmpresp.c_str(), tmpresp.size(), CONN_fd);//schrijf de HTTP response header
|
||||
HTTP_S.SendResponse(CONN_fd, "200", "OK");//schrijf de HTTP response header
|
||||
}else{
|
||||
Movie = HTTP_R.url.substr(1);
|
||||
Movie = Movie.substr(0,Movie.find("/"));
|
||||
|
@ -212,8 +211,7 @@ int mainHandler(int CONN_fd){
|
|||
HTTP_S.SetHeader("Content-Type","text/xml");
|
||||
HTTP_S.SetHeader("Cache-Control","no-cache");
|
||||
HTTP_S.SetBody(BuildManifest(FlashMeta, Movie, 0));
|
||||
std::string tmpresp = HTTP_S.BuildResponse("200", "OK");
|
||||
DDV_write(tmpresp.c_str(), tmpresp.size(), CONN_fd);//schrijf de HTTP response header
|
||||
HTTP_S.SendResponse(CONN_fd, "200", "OK");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -221,12 +219,12 @@ int mainHandler(int CONN_fd){
|
|||
if (!progressive_has_sent_header){
|
||||
HTTP_S.Clean();//troep opruimen die misschien aanwezig is...
|
||||
HTTP_S.SetHeader("Content-Type", "video/x-flv");//FLV files hebben altijd dit content-type.
|
||||
std::string tmpresp = HTTP_S.BuildResponse("200", "OK");//geen SetBody = unknown length! Dat willen we hier.
|
||||
DDV_write(tmpresp.c_str(), tmpresp.size(), CONN_fd);//schrijf de HTTP response header
|
||||
DDV_write(FLVHeader, 13, CONN_fd);//schrijf de FLV header, altijd 13 chars lang
|
||||
HTTP_S.SetHeader("Transfer-Encoding", "chunked");
|
||||
HTTP_S.SendResponse(CONN_fd, "200", "OK");//geen SetBody = unknown length! Dat willen we hier.
|
||||
HTTP_S.SendBodyPart(CONN_fd, FLVHeader, 13);//schrijf de FLV header
|
||||
progressive_has_sent_header = true;
|
||||
}
|
||||
DDV_write(tag->data, tag->len, CONN_fd);//schrijf deze FLV tag onbewerkt weg
|
||||
HTTP_S.SendBodyPart(CONN_fd, tag->data, tag->len);//schrijf deze FLV tag onbewerkt weg
|
||||
}//PROGRESSIVE handler
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -11,8 +11,8 @@ unsigned int getNowMS(){
|
|||
}
|
||||
|
||||
|
||||
unsigned int chunk_rec_max = 102400;
|
||||
unsigned int chunk_snd_max = 102400;
|
||||
unsigned int chunk_rec_max = 128;
|
||||
unsigned int chunk_snd_max = 128;
|
||||
unsigned int rec_window_size = 0xFA00;
|
||||
unsigned int snd_window_size = 1024*500;
|
||||
unsigned int rec_window_at = 0;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
//debugging level 3 = status information
|
||||
//debugging level 4 = extremely verbose status information
|
||||
//debugging level 5 = save all streams to FLV files
|
||||
#define DEBUG 3
|
||||
#define DEBUG 4
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
|
|
|
@ -122,14 +122,14 @@ void parseChunk(){
|
|||
amfreply.addContent(amfdata.getContent(1));//same transaction ID
|
||||
// amfreply.addContent(AMFType("", (double)0, 0x05));//null - command info
|
||||
amfreply.addContent(AMFType(""));//server properties
|
||||
amfreply.getContentP(2)->addContent(AMFType("fmsVer", "FMS/3,0,1,123"));//stolen from examples
|
||||
amfreply.getContentP(2)->addContent(AMFType("fmsVer", "FMS/3,5,2,654"));//stolen from examples
|
||||
amfreply.getContentP(2)->addContent(AMFType("capabilities", (double)31));//stolen from examples
|
||||
amfreply.getContentP(2)->addContent(AMFType("mode", (double)1));//stolen from examples
|
||||
amfreply.getContentP(2)->addContent(AMFType("objectEncoding", (double)0));
|
||||
amfreply.addContent(AMFType(""));//info
|
||||
amfreply.getContentP(3)->addContent(AMFType("level", "status"));
|
||||
amfreply.getContentP(3)->addContent(AMFType("code", "NetConnection.Connect.Success"));
|
||||
amfreply.getContentP(3)->addContent(AMFType("description", "Connection succeeded."));
|
||||
amfreply.getContentP(3)->addContent(AMFType("capabilities", (double)33));//from red5 server
|
||||
amfreply.getContentP(3)->addContent(AMFType("fmsVer", "PLS/1,0,0,0"));//from red5 server
|
||||
#if DEBUG >= 4
|
||||
amfreply.Print();
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,9 @@ class HTTPReader{
|
|||
void SetBody(char * buffer, int len);
|
||||
std::string BuildRequest();
|
||||
std::string BuildResponse(std::string code, std::string message);
|
||||
void SendResponse(int conn, std::string code, std::string message);
|
||||
void SendBodyPart(int conn, char * buffer, int len);
|
||||
void SendBodyPart(int conn, std::string bodypart);
|
||||
void Clean();
|
||||
std::string method;
|
||||
std::string url;
|
||||
|
@ -171,4 +174,23 @@ bool HTTPReader::parse(){
|
|||
return false; //we should never get here...
|
||||
}//HTTPReader::parse
|
||||
|
||||
void HTTPReader::SendResponse(int conn, std::string code, std::string message){
|
||||
std::string tmp = BuildResponse(code, message);
|
||||
DDV_write(tmp.c_str(), tmp.size(), conn);
|
||||
}
|
||||
|
||||
void HTTPReader::SendBodyPart(int conn, char * buffer, int len){
|
||||
std::string tmp;
|
||||
tmp.append(buffer, len);
|
||||
SendBodyPart(conn, tmp);
|
||||
}
|
||||
|
||||
void HTTPReader::SendBodyPart(int conn, std::string bodypart){
|
||||
static char len[10];
|
||||
int sizelen;
|
||||
sizelen = snprintf(len, 10, "%x\r\n", (unsigned int)bodypart.size());
|
||||
DDV_write(len, sizelen, conn);
|
||||
DDV_write(bodypart.c_str(), bodypart.size(), conn);
|
||||
DDV_write(len+sizelen-2, 2, conn);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue