【问题标题】:Using Live555 HTTP capacities as a server for signaling使用 Live555 HTTP 容量作为信令服务器
【发布时间】:2017-07-25 11:02:26
【问题描述】:

最近我设法(使用其他库)制作了一个带有 Live555、WebRTC 和 FFMPEG 的 rtsp 流媒体服务器。 一切都很好,但我的最终目标是最大限度地使用 Live555 以减少我的处理足迹。 启动 rtp 流后,我仅将 HTTP 信令服务器用于保活。

我的问题是(因为我似乎在 live555 代码和文档中都找不到答案):

有没有办法只使用 Live555 构建 HTTP Server ?

【问题讨论】:

    标签: http ffmpeg webrtc live555


    【解决方案1】:

    在 live555 中有一个嵌入式 HTTP 服务器,用于通过 HTTP 传输 RTP。

    你可以使用它重载RTSPServer::RTSPClientConnectionhandleHTTPCmd_StreamingGET

    为了实现您的 GET 实现,您需要:

    • 重载RTSPServer::RTSPClientConnection类实现handleHTTPCmd_StreamingGET
    • 重载 RTSPServer 类以实例化您重载的 RTSPServer::RTSPClientConnection 类

    将所有内容放在一起可以提供非常简单的示例,无需错误处理,例如:

    #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);
            }
    };
    

    这个 HTTPServer 实现用它收到的 http 请求来回答,比如:

    GET / HTTP/1.1
    Host: 127.0.0.1:9999
    User-Agent: curl/7.54.0
    Accept: */*
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-16
      • 2015-01-16
      • 1970-01-01
      相关资源
      最近更新 更多