RTPHandler::RTPHandler(char* di, char* dp) { portbase = RCV_PORT; destip = inet_addr(di); destport = (uint16_t) atoi(dp); alive = true; if (destip == INADDR_NONE) { cerr << "Bad IP address specified" << endl; alive = false; return; } destip = ntohl(destip); RTPUDPv4TransmissionParams transparams; RTPSessionParams sessparams; sessparams.SetOwnTimestampUnit(1.0/CLK_RATE); sessparams.SetAcceptOwnPackets(true); transparams.SetPortbase(portbase); int e = sess.Create(sessparams,&transparams); if(error(e)) return; cout << sessparams.GetMaximumPacketSize()<< endl; RTPIPv4Address addr(destip,destport); e = sess.AddDestination(addr); if(error(e)) return; }
int RTPSession::Create(const RTPSessionParams &sessparams,const RTPTransmissionParams *transparams /* = 0 */, RTPTransmitter::TransmissionProtocol protocol) { int status; if (created) return ERR_RTP_SESSION_ALREADYCREATED; usingpollthread = sessparams.IsUsingPollThread(); useSR_BYEifpossible = sessparams.GetSenderReportForBYE(); sentpackets = false; // Check max packet size if ((maxpacksize = sessparams.GetMaximumPacketSize()) < RTP_MINPACKETSIZE) return ERR_RTP_SESSION_MAXPACKETSIZETOOSMALL; // Initialize the transmission component rtptrans = 0; switch(protocol) { case RTPTransmitter::IPv4UDPProto: rtptrans = RTPNew(GetMemoryManager(),RTPMEM_TYPE_CLASS_RTPTRANSMITTER) RTPUDPv4Transmitter(GetMemoryManager()); break; #ifdef RTP_SUPPORT_IPV6 case RTPTransmitter::IPv6UDPProto: rtptrans = RTPNew(GetMemoryManager(),RTPMEM_TYPE_CLASS_RTPTRANSMITTER) RTPUDPv6Transmitter(GetMemoryManager()); break; #endif // RTP_SUPPORT_IPV6 case RTPTransmitter::UserDefinedProto: rtptrans = NewUserDefinedTransmitter(); if (rtptrans == 0) return ERR_RTP_SESSION_USERDEFINEDTRANSMITTERNULL; break; default: return ERR_RTP_SESSION_UNSUPPORTEDTRANSMISSIONPROTOCOL; } if (rtptrans == 0) return ERR_RTP_OUTOFMEM; if ((status = rtptrans->Init(usingpollthread)) < 0) { RTPDelete(rtptrans,GetMemoryManager()); return status; } if ((status = rtptrans->Create(maxpacksize,transparams)) < 0) { RTPDelete(rtptrans,GetMemoryManager()); return status; } deletetransmitter = true; return InternalCreate(sessparams); }
int RTPSession::Create(const RTPSessionParams &sessparams,RTPTransmitter *transmitter) { int status; if (created) return ERR_RTP_SESSION_ALREADYCREATED; usingpollthread = sessparams.IsUsingPollThread(); useSR_BYEifpossible = sessparams.GetSenderReportForBYE(); sentpackets = false; // Check max packet size if ((maxpacksize = sessparams.GetMaximumPacketSize()) < RTP_MINPACKETSIZE) return ERR_RTP_SESSION_MAXPACKETSIZETOOSMALL; rtptrans = transmitter; if ((status = rtptrans->SetMaximumPacketSize(maxpacksize)) < 0) return status; deletetransmitter = false; return InternalCreate(sessparams); }