live555代理live555ProxyServer支持组播

发布时间:2024年01月11日

1、live555ProxyServer支持多个RTSP代理,但不支持组播。

2、现对相关的类进行修改,让其支持组播,新建1个文件夹,把相关文件拷贝过来:

live555ProxyServer.cpp、ProxyServerMediaSession.hh、ProxyServerMediaSession.cxx、PassiveServerMediaSubsession.hh、PassiveServerMediaSubsession.cpp

3、live555ProxyServer.cpp修改

#include "ProxyServerMediaSession.hh"
.
.
.
int main(int argc, char** argv) {
.
.
.

ServerMediaSession* sms
  = ProxyServerMediaSession::createNewMulticact(*env, rtspServer,
				   proxiedStreamURL, streamName, username, password);
rtspServer->addServerMediaSession(sms);
.
.
.

4、PassiveServerMediaSubsession类修改==>PassiveServerMediaSubsession1

PassiveServerMediaSubsession1.hh:

/****************PassiveServerMediaSubsession1.hh****************/

class PassiveServerMediaSubsession1: public ServerMediaSubsession {
public:
  static PassiveServerMediaSubsession1* createNew(UsageEnvironment& env);
protected:
  PassiveServerMediaSubsession1(UsageEnvironment& env);
      // called only by createNew();
  virtual ~PassiveServerMediaSubsession1();

  virtual Boolean rtcpIsMuxed();

protected: // redefined virtual functions
  virtual char const* sdpLines(int addressFamily);
  virtual void getStreamParameters(unsigned clientSessionId,
				   struct sockaddr_storage const& clientAddress,
                                   Port const& clientRTPPort,
                                   Port const& clientRTCPPort,
				   int tcpSocketNum,
                                   unsigned char rtpChannelId,
                                   unsigned char rtcpChannelId,
				   TLSState* tlsSTate,
                                   struct sockaddr_storage& destinationAddress,
				   u_int8_t& destinationTTL,
                                   Boolean& isMulticast,
                                   Port& serverRTPPort,
                                   Port& serverRTCPPort,
                                   void*& streamToken);
  virtual void startStream(unsigned clientSessionId, void* streamToken,
			   TaskFunc* rtcpRRHandler,
			   void* rtcpRRHandlerClientData,
                           unsigned short& rtpSeqNum,
                           unsigned& rtpTimestamp,
			   ServerRequestAlternativeByteHandler* serverRequestAlternativeByteHandler,
                           void* serverRequestAlternativeByteHandlerClientData);
  virtual float getCurrentNPT(void* streamToken);
  virtual void getRTPSinkandRTCP(void* streamToken,
				 RTPSink*& rtpSink, RTCPInstance*& rtcp);
  virtual void deleteStream(unsigned clientSessionId, void*& streamToken);

protected:
  char* fSDPLines;
  RTPSink* fRTPSink;
  RTCPInstance* fRTCPInstance;
  HashTable* fClientRTCPSourceRecords; // indexed by client session id; used to implement RTCP "RR" handling

  FramedSource* fvideoSource;
};

PassiveServerMediaSubsession1.cpp



#include "PassiveServerMediaSubsession1.hh"
#include <GroupsockHelper.hh>

// PassiveServerMediaSubsession1 //

PassiveServerMediaSubsession1*
PassiveServerMediaSubsession1::createNew(UsageEnvironment& env) {
  return new PassiveServerMediaSubsession1(env);
}

PassiveServerMediaSubsession1
::PassiveServerMediaSubsession1(UsageEnvironment& env)
  : ServerMediaSubsession(env),
    fSDPLines(NULL), fRTPSink(NULL), fRTCPInstance(NULL), fvideoSource(NULL) {
  fClientRTCPSourceRecords = HashTable::create(ONE_WORD_HASH_KEYS);
}

class RTCPSourceRecord {
public:
  RTCPSourceRecord(struct sockaddr_storage const& addr, Port const& port)
    : addr(addr), port(port) {
  }

  struct sockaddr_storage addr;
  Port port;
};

PassiveServerMediaSubsession1::~PassiveServerMediaSubsession1() {
  delete[] fSDPLines;

  //
文章来源:https://blog.csdn.net/howesao/article/details/135535344
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。