Lately i managed to make (using other libraries) a rtsp streaming server with Live555, WebRTC and FFMPEG. All is rolling great, but my ultimate goal is to maximise my usage of Live555 to reduce my processing footprint. Once the rtp stream is started i use the HTTP signaling server only for keepalives.
My question is (As i don't seem to find the answer in the live555 code nor documentation) :
Is there any way to build a HTTP Server using only Live555 ?
In live555 there is an embededed HTTP server that is used for streaming RTP over HTTP.
You can use it overloading the handleHTTPCmd_StreamingGET
of RTSPServer::RTSPClientConnection
In order to implement your GET implementation, you need to :
Putting everything together could give a very simplify sample, without error handling, like :
#include "BasicUsageEnvironment.hh"
#include "RTSPServer.hh"
class HTTPServer : public RTSPServer {
class HTTPClientConnection : public RTSPServer::RTSPClientConnection {
public:
HTTPClientConnection(RTSPServer& ourServer, int clientSocket, struct sockaddr_in clientAddr)
: RTSPServer::RTSPClientConnection(ourServer, clientSocket, clientAddr) {}
private:
virtual void handleHTTPCmd_StreamingGET(char const* urlSuffix, char const* fullRequestStr) {
// build HTTP answer
snprintf((char*)fResponseBuffer, sizeof fResponseBuffer,
"HTTP/1.1 200 OK\r\n"
"Content-Length: %zd\r\n"
"\r\n"
"%s",
strlen(fullRequestStr),fullRequestStr);
}
};
public:
static HTTPServer* createNew(UsageEnvironment& env, Port rtspPort) {
return new HTTPServer(env, setUpOurSocket(env, rtspPort), rtspPort);
}
HTTPServer(UsageEnvironment& env, int ourSocket, Port rtspPort)
: RTSPServer(env, ourSocket, rtspPort, NULL, 0) {}
RTSPServer::RTSPClientConnection* createNewClientConnection(int clientSocket, struct sockaddr_in clientAddr) {
return new HTTPClientConnection(*this, clientSocket, clientAddr);
}
};
This HTTPServer implementation answer with the http request it received, something like :
GET / HTTP/1.1
Host: 127.0.0.1:9999
User-Agent: curl/7.54.0
Accept: */*