2018-02-26 19:35:16 -05:00
|
|
|
/*
|
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
This file is a part of JRTPLIB
|
|
|
|
Copyright (c) 1999-2017 Jori Liesenborgs
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
Contact: jori.liesenborgs@gmail.com
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
This library was developed at the Expertise Centre for Digital Media
|
|
|
|
(http://www.edm.uhasselt.be), a research center of the Hasselt University
|
|
|
|
(http://www.uhasselt.be). The library is based upon work done for
|
|
|
|
my thesis at the School for Knowledge Technology (Belgium/The Netherlands).
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
copy of this software and associated documentation files (the "Software"),
|
|
|
|
to deal in the Software without restriction, including without limitation
|
|
|
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
Software is furnished to do so, subject to the following conditions:
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
The above copyright notice and this permission notice shall be included
|
|
|
|
in all copies or substantial portions of the Software.
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
IN THE SOFTWARE.
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
*/
|
2018-02-26 19:35:16 -05:00
|
|
|
|
|
|
|
#include "rtpsession.h"
|
|
|
|
#include "rtperrors.h"
|
2018-02-27 19:37:47 -05:00
|
|
|
// TODO: this is for Create with transmitter creation. See if we keep it.
|
|
|
|
//#include "rtpudpv4transmitter.h"
|
|
|
|
//#include "rtptcptransmitter.h"
|
|
|
|
//#include "rtpexternaltransmitter.h"
|
2018-02-26 19:35:16 -05:00
|
|
|
#include "rtpsessionparams.h"
|
|
|
|
#include "rtpdefines.h"
|
|
|
|
#include "rtprawpacket.h"
|
|
|
|
#include "rtppacket.h"
|
|
|
|
#include "rtptimeutilities.h"
|
|
|
|
#include "rtprandomrand48.h"
|
|
|
|
#include "rtprandomrands.h"
|
|
|
|
#include "rtprandomurandom.h"
|
|
|
|
#ifdef RTP_SUPPORT_SENDAPP
|
2018-02-27 17:05:46 -05:00
|
|
|
#include "rtcpcompoundpacket.h"
|
2018-02-26 19:35:16 -05:00
|
|
|
#endif // RTP_SUPPORT_SENDAPP
|
|
|
|
#include "rtpinternalutils.h"
|
2018-03-05 10:40:53 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
#include <stdlib.h>
|
2018-03-05 10:40:53 -05:00
|
|
|
|
|
|
|
#include <QHostInfo>
|
2018-02-26 19:35:16 -05:00
|
|
|
|
|
|
|
|
|
|
|
namespace qrtplib
|
|
|
|
{
|
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
RTPSession::RTPSession(RTPRandom *r) :
|
2018-03-04 19:17:19 -05:00
|
|
|
rtprnd(GetRandomNumberGenerator(r)),
|
|
|
|
sources(*this),
|
|
|
|
packetbuilder(*rtprnd),
|
|
|
|
rtcpsched(sources, *rtprnd),
|
|
|
|
rtcpbuilder(sources, packetbuilder)
|
2018-02-26 19:35:16 -05:00
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
// We're not going to set these flags in Create, so that the constructor of a derived class
|
|
|
|
// can already change them
|
|
|
|
m_changeIncomingData = false;
|
|
|
|
m_changeOutgoingData = false;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
created = false;
|
|
|
|
timeinit.Dummy();
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
//std::cout << (void *)(rtprnd) << std::endl;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
RTPSession::~RTPSession()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
Destroy();
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
if (deletertprnd)
|
|
|
|
delete rtprnd;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
2018-04-04 17:39:31 -04:00
|
|
|
//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)
|
|
|
|
// {
|
2018-02-27 19:37:47 -05:00
|
|
|
// TODO: see if we keep this Create method or use the one with the transmitter specified
|
|
|
|
// case RTPTransmitter::IPv4UDPProto:
|
|
|
|
// rtptrans = new RTPUDPv4Transmitter();
|
|
|
|
// break;
|
|
|
|
// case RTPTransmitter::ExternalProto:
|
|
|
|
// rtptrans = new RTPExternalTransmitter();
|
|
|
|
// break;
|
|
|
|
// case RTPTransmitter::UserDefinedProto:
|
|
|
|
// rtptrans = NewUserDefinedTransmitter();
|
|
|
|
// if (rtptrans == 0)
|
|
|
|
// return ERR_RTP_SESSION_USERDEFINEDTRANSMITTERNULL;
|
|
|
|
// break;
|
|
|
|
// case RTPTransmitter::TCPProto:
|
|
|
|
// rtptrans = new RTPTCPTransmitter();
|
|
|
|
// break;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-04-04 17:39:31 -04:00
|
|
|
// default:
|
|
|
|
// return ERR_RTP_SESSION_UNSUPPORTEDTRANSMISSIONPROTOCOL;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (rtptrans == 0)
|
|
|
|
// return ERR_RTP_OUTOFMEM;
|
|
|
|
// if ((status = rtptrans->Init()) < 0)
|
|
|
|
// {
|
|
|
|
// delete rtptrans;
|
|
|
|
// return status;
|
|
|
|
// }
|
|
|
|
// if ((status = rtptrans->Create(maxpacksize, transparams)) < 0)
|
|
|
|
// {
|
|
|
|
// delete rtptrans;
|
|
|
|
// return status;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// deletetransmitter = true;
|
|
|
|
// return InternalCreate(sessparams);
|
|
|
|
//}
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
int RTPSession::Create(const RTPSessionParams &sessparams, RTPTransmitter *transmitter)
|
2018-02-26 19:35:16 -05:00
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
int status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
if (created)
|
|
|
|
return ERR_RTP_SESSION_ALREADYCREATED;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
usingpollthread = sessparams.IsUsingPollThread();
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
useSR_BYEifpossible = sessparams.GetSenderReportForBYE();
|
|
|
|
sentpackets = false;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
// Check max packet size
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
if ((maxpacksize = sessparams.GetMaximumPacketSize()) < RTP_MINPACKETSIZE)
|
|
|
|
return ERR_RTP_SESSION_MAXPACKETSIZETOOSMALL;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
rtptrans = transmitter;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
if ((status = rtptrans->SetMaximumPacketSize(maxpacksize)) < 0)
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
deletetransmitter = false;
|
|
|
|
return InternalCreate(sessparams);
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::InternalCreate(const RTPSessionParams &sessparams)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
int status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
// Initialize packet builder
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
if ((status = packetbuilder.Init(maxpacksize)) < 0)
|
|
|
|
{
|
|
|
|
if (deletetransmitter)
|
|
|
|
delete rtptrans;
|
|
|
|
return status;
|
|
|
|
}
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
if (sessparams.GetUsePredefinedSSRC())
|
|
|
|
packetbuilder.AdjustSSRC(sessparams.GetPredefinedSSRC());
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
// Add our own ssrc to the source table
|
|
|
|
|
|
|
|
if ((status = sources.CreateOwnSSRC(packetbuilder.GetSSRC())) < 0)
|
|
|
|
{
|
|
|
|
packetbuilder.Destroy();
|
|
|
|
if (deletetransmitter)
|
|
|
|
delete rtptrans;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the initial receive mode
|
|
|
|
|
|
|
|
if ((status = rtptrans->SetReceiveMode(sessparams.GetReceiveMode())) < 0)
|
|
|
|
{
|
|
|
|
packetbuilder.Destroy();
|
|
|
|
sources.Clear();
|
|
|
|
if (deletetransmitter)
|
|
|
|
delete rtptrans;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Init the RTCP packet builder
|
|
|
|
|
|
|
|
double timestampunit = sessparams.GetOwnTimestampUnit();
|
qrtplib: clear buffer fed to RTPSession::CreateCNAME
The RTPSession::CreateCNAME function checks to see if the buffer that
it is provided already has any data in it, and appends to it if so. The
RTPSession::InternalCreate function calls this function with an uninitialized
buffer, which results in indeterminate behavior. To ensure that the CNAME
is properly created, we clear the buffer before use.
==30323== Conditional jump or move depends on uninitialised value(s)
==30323== at 0x4C30109: __strlen_sse2 (vg_replace_strmem.c:460)
==30323== by 0x85647A4: qrtplib::RTPSession::CreateCNAME(unsigned char*, unsigned long*, bool) (rtpsession.cpp:1150)
==30323== by 0x8564B35: qrtplib::RTPSession::InternalCreate(qrtplib::RTPSessionParams const&) (rtpsession.cpp:218)
==30323== by 0x5499159: RTPSink::RTPSink(QUdpSocket*, int, bool) (rtpsink.cpp:48)
==30323== by 0x5420B6A: AudioNetSink::AudioNetSink(QObject*, int, bool) (audionetsink.cpp:42)
==30323== by 0x541F465: AudioOutput::start(int, int) (audiooutput.cpp:114)
==30323== by 0x5412763: AudioDeviceManager::startAudioOutput(int) (audiodevicemanager.cpp:361)
==30323== by 0x5412B0C: AudioDeviceManager::addAudioSink(AudioFifo*, MessageQueue*, int) (audiodevicemanager.cpp:229)
==30323== by 0x33F96DE7: BFMDemod::BFMDemod(DeviceSourceAPI*) (bfmdemod.cpp:56)
==30323== by 0x33FB03F2: non-virtual thunk to BFMPlugin::createRxChannelBS(DeviceSourceAPI*) (bfmplugin.cpp:62)
==30323== by 0x4F47F25: DeviceUISet::loadRxChannelSettings(Preset const*, PluginAPI*) (deviceuiset.cpp:199)
==30323== by 0x4EA51EA: MainWindow::loadPresetSettings(Preset const*, int) (mainwindow.cpp:575)
==30323== by 0x4EAC81B: MainWindow::MainWindow(qtwebapp::LoggerWithFile*, MainParser const&, QWidget*) (mainwindow.cpp:176)
==30323== by 0x10A49B: runQtApplication(int, char**, qtwebapp::LoggerWithFile*) (main.cpp:120)
==30323== by 0x109B38: main (main.cpp:131)
2018-04-20 20:49:46 -04:00
|
|
|
uint8_t buf[1024] = {0};
|
2018-02-28 07:31:44 -05:00
|
|
|
std::size_t buflen = 1024;
|
2018-02-27 17:05:46 -05:00
|
|
|
std::string forcedcname = sessparams.GetCNAME();
|
|
|
|
|
|
|
|
if (forcedcname.length() == 0)
|
|
|
|
{
|
|
|
|
if ((status = CreateCNAME(buf, &buflen, sessparams.GetResolveLocalHostname())) < 0)
|
|
|
|
{
|
|
|
|
packetbuilder.Destroy();
|
|
|
|
sources.Clear();
|
|
|
|
if (deletetransmitter)
|
|
|
|
delete rtptrans;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-04 19:17:19 -05:00
|
|
|
strncpy((char * )buf, forcedcname.c_str(), buflen);
|
2018-02-27 17:05:46 -05:00
|
|
|
buf[buflen - 1] = 0;
|
|
|
|
buflen = strlen((char *) buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((status = rtcpbuilder.Init(maxpacksize, timestampunit, buf, buflen)) < 0)
|
|
|
|
{
|
|
|
|
packetbuilder.Destroy();
|
|
|
|
sources.Clear();
|
|
|
|
if (deletetransmitter)
|
|
|
|
delete rtptrans;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set scheduler parameters
|
|
|
|
|
|
|
|
rtcpsched.Reset();
|
|
|
|
rtcpsched.SetHeaderOverhead(rtptrans->GetHeaderOverhead());
|
|
|
|
|
|
|
|
RTCPSchedulerParams schedparams;
|
|
|
|
|
|
|
|
sessionbandwidth = sessparams.GetSessionBandwidth();
|
|
|
|
controlfragment = sessparams.GetControlTrafficFraction();
|
|
|
|
|
|
|
|
if ((status = schedparams.SetRTCPBandwidth(sessionbandwidth * controlfragment)) < 0)
|
|
|
|
{
|
|
|
|
if (deletetransmitter)
|
|
|
|
delete rtptrans;
|
|
|
|
packetbuilder.Destroy();
|
|
|
|
sources.Clear();
|
|
|
|
rtcpbuilder.Destroy();
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
if ((status = schedparams.SetSenderBandwidthFraction(sessparams.GetSenderControlBandwidthFraction())) < 0)
|
|
|
|
{
|
|
|
|
if (deletetransmitter)
|
|
|
|
delete rtptrans;
|
|
|
|
packetbuilder.Destroy();
|
|
|
|
sources.Clear();
|
|
|
|
rtcpbuilder.Destroy();
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
if ((status = schedparams.SetMinimumTransmissionInterval(sessparams.GetMinimumRTCPTransmissionInterval())) < 0)
|
|
|
|
{
|
|
|
|
if (deletetransmitter)
|
|
|
|
delete rtptrans;
|
|
|
|
packetbuilder.Destroy();
|
|
|
|
sources.Clear();
|
|
|
|
rtcpbuilder.Destroy();
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
schedparams.SetUseHalfAtStartup(sessparams.GetUseHalfRTCPIntervalAtStartup());
|
|
|
|
schedparams.SetRequestImmediateBYE(sessparams.GetRequestImmediateBYE());
|
|
|
|
|
|
|
|
rtcpsched.SetParameters(schedparams);
|
|
|
|
|
|
|
|
// copy other parameters
|
|
|
|
|
|
|
|
acceptownpackets = sessparams.AcceptOwnPackets();
|
|
|
|
membermultiplier = sessparams.GetSourceTimeoutMultiplier();
|
|
|
|
sendermultiplier = sessparams.GetSenderTimeoutMultiplier();
|
|
|
|
byemultiplier = sessparams.GetBYETimeoutMultiplier();
|
|
|
|
collisionmultiplier = sessparams.GetCollisionTimeoutMultiplier();
|
|
|
|
notemultiplier = sessparams.GetNoteTimeoutMultiplier();
|
|
|
|
|
|
|
|
// Do thread stuff if necessary
|
|
|
|
|
|
|
|
created = true;
|
|
|
|
return 0;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RTPSession::Destroy()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
if (deletetransmitter)
|
|
|
|
delete rtptrans;
|
|
|
|
packetbuilder.Destroy();
|
|
|
|
rtcpbuilder.Destroy();
|
|
|
|
rtcpsched.Reset();
|
|
|
|
collisionlist.Clear();
|
|
|
|
sources.Clear();
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
std::list<RTCPCompoundPacket *>::const_iterator it;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
for (it = byepackets.begin(); it != byepackets.end(); it++)
|
|
|
|
delete *it;
|
|
|
|
byepackets.clear();
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
created = false;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
2018-02-28 07:31:44 -05:00
|
|
|
void RTPSession::BYEDestroy(const RTPTime &maxwaittime, const void *reason, std::size_t reasonlength)
|
2018-02-26 19:35:16 -05:00
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
// first, stop the thread so we have full control over all components
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
RTPTime stoptime = RTPTime::CurrentTime();
|
|
|
|
stoptime += maxwaittime;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
// add bye packet to the list if we've sent data
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
RTCPCompoundPacket *pack;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
if (sentpackets)
|
|
|
|
{
|
|
|
|
int status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
reasonlength = (reasonlength > RTCP_BYE_MAXREASONLENGTH) ? RTCP_BYE_MAXREASONLENGTH : reasonlength;
|
|
|
|
status = rtcpbuilder.BuildBYEPacket(&pack, reason, reasonlength, useSR_BYEifpossible);
|
|
|
|
if (status >= 0)
|
|
|
|
{
|
|
|
|
byepackets.push_back(pack);
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
if (byepackets.size() == 1)
|
|
|
|
rtcpsched.ScheduleBYEPacket(pack->GetCompoundPacketLength());
|
|
|
|
}
|
|
|
|
}
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!byepackets.empty())
|
|
|
|
{
|
|
|
|
bool done = false;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
while (!done)
|
|
|
|
{
|
|
|
|
RTPTime curtime = RTPTime::CurrentTime();
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
if (curtime >= stoptime)
|
|
|
|
done = true;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
if (rtcpsched.IsTime())
|
|
|
|
{
|
|
|
|
pack = *(byepackets.begin());
|
|
|
|
byepackets.pop_front();
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
SendRTCPData(pack->GetCompoundPacketData(), pack->GetCompoundPacketLength());
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
OnSendRTCPCompoundPacket(pack); // we'll place this after the actual send to avoid tampering
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
delete pack;
|
|
|
|
if (!byepackets.empty()) // more bye packets to send, schedule them
|
|
|
|
rtcpsched.ScheduleBYEPacket((*(byepackets.begin()))->GetCompoundPacketLength());
|
|
|
|
else
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
if (!done)
|
|
|
|
RTPTime::Wait(RTPTime(0, 100000));
|
|
|
|
}
|
|
|
|
}
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
if (deletetransmitter)
|
|
|
|
delete rtptrans;
|
|
|
|
packetbuilder.Destroy();
|
|
|
|
rtcpbuilder.Destroy();
|
|
|
|
rtcpsched.Reset();
|
|
|
|
collisionlist.Clear();
|
|
|
|
sources.Clear();
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
// clear rest of bye packets
|
|
|
|
std::list<RTCPCompoundPacket *>::const_iterator it;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
for (it = byepackets.begin(); it != byepackets.end(); it++)
|
|
|
|
delete *it;
|
|
|
|
byepackets.clear();
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
created = false;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool RTPSession::IsActive()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
return created;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t RTPSession::GetLocalSSRC()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return 0;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
uint32_t ssrc;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
ssrc = packetbuilder.GetSSRC();
|
|
|
|
return ssrc;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::AddDestination(const RTPAddress &addr)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
|
|
|
return rtptrans->AddDestination(addr);
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::DeleteDestination(const RTPAddress &addr)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
|
|
|
return rtptrans->DeleteDestination(addr);
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RTPSession::ClearDestinations()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return;
|
|
|
|
rtptrans->ClearDestinations();
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool RTPSession::SupportsMulticasting()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return false;
|
|
|
|
return rtptrans->SupportsMulticasting();
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::JoinMulticastGroup(const RTPAddress &addr)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
|
|
|
return rtptrans->JoinMulticastGroup(addr);
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::LeaveMulticastGroup(const RTPAddress &addr)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
|
|
|
return rtptrans->LeaveMulticastGroup(addr);
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
2018-02-28 07:31:44 -05:00
|
|
|
int RTPSession::SendPacket(const void *data, std::size_t len)
|
2018-02-27 17:05:46 -05:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
|
|
|
|
|
|
|
if ((status = packetbuilder.BuildPacket(data, len)) < 0)
|
|
|
|
{
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
if ((status = SendRTPData(packetbuilder.GetPacket(), packetbuilder.GetPacketLength())) < 0)
|
|
|
|
{
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
sources.SentRTPPacket();
|
|
|
|
sentpackets = true;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-02-28 07:31:44 -05:00
|
|
|
int RTPSession::SendPacket(const void *data, std::size_t len, uint8_t pt, bool mark, uint32_t timestampinc)
|
2018-02-27 17:05:46 -05:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
|
|
|
|
|
|
|
if ((status = packetbuilder.BuildPacket(data, len, pt, mark, timestampinc)) < 0)
|
|
|
|
{
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
if ((status = SendRTPData(packetbuilder.GetPacket(), packetbuilder.GetPacketLength())) < 0)
|
|
|
|
{
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
sources.SentRTPPacket();
|
|
|
|
sentpackets = true;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-02-28 07:31:44 -05:00
|
|
|
int RTPSession::SendPacketEx(const void *data, std::size_t len, uint16_t hdrextID, const void *hdrextdata, std::size_t numhdrextwords)
|
2018-02-27 17:05:46 -05:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
|
|
|
|
|
|
|
if ((status = packetbuilder.BuildPacketEx(data, len, hdrextID, hdrextdata, numhdrextwords)) < 0)
|
|
|
|
{
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
if ((status = SendRTPData(packetbuilder.GetPacket(), packetbuilder.GetPacketLength())) < 0)
|
|
|
|
{
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
sources.SentRTPPacket();
|
|
|
|
sentpackets = true;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-02-28 07:31:44 -05:00
|
|
|
int RTPSession::SendPacketEx(const void *data, std::size_t len, uint8_t pt, bool mark, uint32_t timestampinc, uint16_t hdrextID, const void *hdrextdata, std::size_t numhdrextwords)
|
2018-02-27 17:05:46 -05:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
|
|
|
|
|
|
|
if ((status = packetbuilder.BuildPacketEx(data, len, pt, mark, timestampinc, hdrextID, hdrextdata, numhdrextwords)) < 0)
|
|
|
|
{
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
if ((status = SendRTPData(packetbuilder.GetPacket(), packetbuilder.GetPacketLength())) < 0)
|
|
|
|
{
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
sources.SentRTPPacket();
|
|
|
|
sentpackets = true;
|
|
|
|
return 0;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef RTP_SUPPORT_SENDAPP
|
|
|
|
|
2018-02-28 07:31:44 -05:00
|
|
|
int RTPSession::SendRTCPAPPPacket(uint8_t subtype, const uint8_t name[4], const void *appdata, std::size_t appdatalen)
|
2018-02-26 19:35:16 -05:00
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
int status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
uint32_t ssrc = packetbuilder.GetSSRC();
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
RTCPCompoundPacketBuilder pb;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
status = pb.InitBuild(maxpacksize);
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
if (status < 0)
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
//first packet in an rtcp compound packet should always be SR or RR
|
|
|
|
if ((status = pb.StartReceiverReport(ssrc)) < 0)
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
//add SDES packet with CNAME item
|
|
|
|
if ((status = pb.AddSDESSource(ssrc)) < 0)
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-28 07:31:44 -05:00
|
|
|
std::size_t owncnamelen = 0;
|
2018-02-27 17:05:46 -05:00
|
|
|
uint8_t *owncname = rtcpbuilder.GetLocalCNAME(&owncnamelen);
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
if ((status = pb.AddSDESNormalItem(RTCPSDESPacket::CNAME, owncname, owncnamelen)) < 0)
|
|
|
|
{
|
|
|
|
return status;
|
|
|
|
}
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
//add our application specific packet
|
|
|
|
if ((status = pb.AddAPPPacket(subtype, ssrc, name, appdata, appdatalen)) < 0)
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
if ((status = pb.EndBuild()) < 0)
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
//send packet
|
|
|
|
status = SendRTCPData(pb.GetCompoundPacketData(), pb.GetCompoundPacketLength());
|
|
|
|
if (status < 0)
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
sentpackets = true;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
return pb.GetCompoundPacketLength();
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // RTP_SUPPORT_SENDAPP
|
|
|
|
|
2018-02-28 07:31:44 -05:00
|
|
|
int RTPSession::SendRawData(const void *data, std::size_t len, bool usertpchannel)
|
2018-02-26 19:35:16 -05:00
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
int status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
if (usertpchannel)
|
|
|
|
status = rtptrans->SendRTPData(data, len);
|
|
|
|
else
|
|
|
|
status = rtptrans->SendRTCPData(data, len);
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::SetDefaultPayloadType(uint8_t pt)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
int status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
status = packetbuilder.SetDefaultPayloadType(pt);
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::SetDefaultMark(bool m)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
int status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
status = packetbuilder.SetDefaultMark(m);
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::SetDefaultTimestampIncrement(uint32_t timestampinc)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
int status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
status = packetbuilder.SetDefaultTimestampIncrement(timestampinc);
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::IncrementTimestamp(uint32_t inc)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
int status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
status = packetbuilder.IncrementTimestamp(inc);
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::IncrementTimestampDefault()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
int status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
status = packetbuilder.IncrementTimestampDefault();
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::SetPreTransmissionDelay(const RTPTime &delay)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
int status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
status = rtcpbuilder.SetPreTransmissionDelay(delay);
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
RTPTransmissionInfo *RTPSession::GetTransmissionInfo()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return 0;
|
|
|
|
return rtptrans->GetTransmissionInfo();
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RTPSession::DeleteTransmissionInfo(RTPTransmissionInfo *inf)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return;
|
|
|
|
rtptrans->DeleteTransmissionInfo(inf);
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
RTPTime RTPSession::GetRTCPDelay()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return RTPTime(0, 0);
|
|
|
|
if (usingpollthread)
|
|
|
|
return RTPTime(0, 0);
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
RTPTime t = rtcpsched.GetTransmissionDelay();
|
|
|
|
return t;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::BeginDataAccess()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
|
|
|
return 0;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool RTPSession::GotoFirstSource()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return false;
|
|
|
|
return sources.GotoFirstSource();
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool RTPSession::GotoNextSource()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return false;
|
|
|
|
return sources.GotoNextSource();
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool RTPSession::GotoPreviousSource()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return false;
|
|
|
|
return sources.GotoPreviousSource();
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool RTPSession::GotoFirstSourceWithData()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return false;
|
|
|
|
return sources.GotoFirstSourceWithData();
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool RTPSession::GotoNextSourceWithData()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return false;
|
|
|
|
return sources.GotoNextSourceWithData();
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool RTPSession::GotoPreviousSourceWithData()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return false;
|
|
|
|
return sources.GotoPreviousSourceWithData();
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
RTPSourceData *RTPSession::GetCurrentSourceInfo()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return 0;
|
|
|
|
return sources.GetCurrentSourceInfo();
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
RTPSourceData *RTPSession::GetSourceInfo(uint32_t ssrc)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return 0;
|
|
|
|
return sources.GetSourceInfo(ssrc);
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
RTPPacket *RTPSession::GetNextPacket()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return 0;
|
|
|
|
return sources.GetNextPacket();
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t RTPSession::GetNextSequenceNumber() const
|
|
|
|
{
|
|
|
|
return packetbuilder.GetSequenceNumber();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RTPSession::DeletePacket(RTPPacket *p)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
delete p;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::EndDataAccess()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
|
|
|
return 0;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::SetReceiveMode(RTPTransmitter::ReceiveMode m)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
|
|
|
return rtptrans->SetReceiveMode(m);
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::AddToIgnoreList(const RTPAddress &addr)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
|
|
|
return rtptrans->AddToIgnoreList(addr);
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::DeleteFromIgnoreList(const RTPAddress &addr)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
|
|
|
return rtptrans->DeleteFromIgnoreList(addr);
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RTPSession::ClearIgnoreList()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return;
|
|
|
|
rtptrans->ClearIgnoreList();
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::AddToAcceptList(const RTPAddress &addr)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
|
|
|
return rtptrans->AddToAcceptList(addr);
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::DeleteFromAcceptList(const RTPAddress &addr)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
|
|
|
return rtptrans->DeleteFromAcceptList(addr);
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RTPSession::ClearAcceptList()
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return;
|
|
|
|
rtptrans->ClearAcceptList();
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
2018-02-28 07:31:44 -05:00
|
|
|
int RTPSession::SetMaximumPacketSize(std::size_t s)
|
2018-02-26 19:35:16 -05:00
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
|
|
|
|
|
|
|
if (s < RTP_MINPACKETSIZE)
|
|
|
|
return ERR_RTP_SESSION_MAXPACKETSIZETOOSMALL;
|
|
|
|
|
|
|
|
int status;
|
|
|
|
|
|
|
|
if ((status = rtptrans->SetMaximumPacketSize(s)) < 0)
|
|
|
|
return status;
|
|
|
|
|
|
|
|
if ((status = packetbuilder.SetMaximumPacketSize(s)) < 0)
|
|
|
|
{
|
|
|
|
// restore previous max packet size
|
|
|
|
rtptrans->SetMaximumPacketSize(maxpacksize);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
if ((status = rtcpbuilder.SetMaximumPacketSize(s)) < 0)
|
|
|
|
{
|
|
|
|
// restore previous max packet size
|
|
|
|
packetbuilder.SetMaximumPacketSize(maxpacksize);
|
|
|
|
rtptrans->SetMaximumPacketSize(maxpacksize);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
maxpacksize = s;
|
|
|
|
return 0;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::SetSessionBandwidth(double bw)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
int status;
|
|
|
|
RTCPSchedulerParams p = rtcpsched.GetParameters();
|
|
|
|
status = p.SetRTCPBandwidth(bw * controlfragment);
|
|
|
|
if (status >= 0)
|
|
|
|
{
|
|
|
|
rtcpsched.SetParameters(p);
|
|
|
|
sessionbandwidth = bw;
|
|
|
|
}
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::SetTimestampUnit(double u)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
int status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-02-27 17:05:46 -05:00
|
|
|
status = rtcpbuilder.SetTimestampUnit(u);
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RTPSession::SetNameInterval(int count)
|
|
|
|
{
|
2018-02-27 17:05:46 -05:00
|
|
|
if (!created)
|
|
|
|
return;
|
|
|
|
rtcpbuilder.SetNameInterval(count);
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RTPSession::SetEMailInterval(int count)
|
|
|
|
{
|
2018-03-04 19:17:19 -05:00
|
|
|
if (!created)
|
|
|
|
return;
|
|
|
|
rtcpbuilder.SetEMailInterval(count);
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RTPSession::SetLocationInterval(int count)
|
|
|
|
{
|
2018-03-04 19:17:19 -05:00
|
|
|
if (!created)
|
|
|
|
return;
|
|
|
|
rtcpbuilder.SetLocationInterval(count);
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RTPSession::SetPhoneInterval(int count)
|
|
|
|
{
|
2018-03-04 19:17:19 -05:00
|
|
|
if (!created)
|
|
|
|
return;
|
|
|
|
rtcpbuilder.SetPhoneInterval(count);
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RTPSession::SetToolInterval(int count)
|
|
|
|
{
|
2018-03-04 19:17:19 -05:00
|
|
|
if (!created)
|
|
|
|
return;
|
|
|
|
rtcpbuilder.SetToolInterval(count);
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void RTPSession::SetNoteInterval(int count)
|
|
|
|
{
|
2018-03-04 19:17:19 -05:00
|
|
|
if (!created)
|
|
|
|
return;
|
|
|
|
rtcpbuilder.SetNoteInterval(count);
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
2018-02-28 07:31:44 -05:00
|
|
|
int RTPSession::SetLocalName(const void *s, std::size_t len)
|
2018-02-26 19:35:16 -05:00
|
|
|
{
|
2018-03-04 19:17:19 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
int status;
|
|
|
|
status = rtcpbuilder.SetLocalName(s, len);
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
2018-02-28 07:31:44 -05:00
|
|
|
int RTPSession::SetLocalEMail(const void *s, std::size_t len)
|
2018-02-26 19:35:16 -05:00
|
|
|
{
|
2018-03-04 19:17:19 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
int status;
|
|
|
|
status = rtcpbuilder.SetLocalEMail(s, len);
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
2018-02-28 07:31:44 -05:00
|
|
|
int RTPSession::SetLocalLocation(const void *s, std::size_t len)
|
2018-02-26 19:35:16 -05:00
|
|
|
{
|
2018-03-04 19:17:19 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
int status;
|
|
|
|
status = rtcpbuilder.SetLocalLocation(s, len);
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
2018-02-28 07:31:44 -05:00
|
|
|
int RTPSession::SetLocalPhone(const void *s, std::size_t len)
|
2018-02-26 19:35:16 -05:00
|
|
|
{
|
2018-03-04 19:17:19 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
int status;
|
|
|
|
status = rtcpbuilder.SetLocalPhone(s, len);
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
2018-02-28 07:31:44 -05:00
|
|
|
int RTPSession::SetLocalTool(const void *s, std::size_t len)
|
2018-02-26 19:35:16 -05:00
|
|
|
{
|
2018-03-04 19:17:19 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
int status;
|
|
|
|
status = rtcpbuilder.SetLocalTool(s, len);
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
2018-02-28 07:31:44 -05:00
|
|
|
int RTPSession::SetLocalNote(const void *s, std::size_t len)
|
2018-02-26 19:35:16 -05:00
|
|
|
{
|
2018-03-04 19:17:19 -05:00
|
|
|
if (!created)
|
|
|
|
return ERR_RTP_SESSION_NOTCREATED;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
int status;
|
|
|
|
status = rtcpbuilder.SetLocalNote(s, len);
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int RTPSession::ProcessPolledData()
|
|
|
|
{
|
2018-03-04 19:17:19 -05:00
|
|
|
RTPRawPacket *rawpack;
|
|
|
|
int status;
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
while ((rawpack = rtptrans->GetNextPacket()) != 0)
|
|
|
|
{
|
|
|
|
if (m_changeIncomingData)
|
|
|
|
{
|
|
|
|
// Provide a way to change incoming data, for decryption for example
|
|
|
|
if (!OnChangeIncomingData(rawpack))
|
|
|
|
{
|
|
|
|
delete rawpack;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
sources.ClearOwnCollisionFlag();
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
// since our sources instance also uses the scheduler (analysis of incoming packets)
|
|
|
|
// we'll lock it
|
|
|
|
if ((status = sources.ProcessRawPacket(rawpack, rtptrans, acceptownpackets)) < 0)
|
|
|
|
{
|
|
|
|
delete rawpack;
|
|
|
|
return status;
|
|
|
|
}
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
if (sources.DetectedOwnCollision()) // collision handling!
|
|
|
|
{
|
|
|
|
bool created;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
if ((status = collisionlist.UpdateAddress(&rawpack->GetSenderAddress(), rawpack->GetReceiveTime(), &created)) < 0)
|
|
|
|
{
|
|
|
|
delete rawpack;
|
|
|
|
return status;
|
|
|
|
}
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
if (created) // first time we've encountered this address, send bye packet and
|
|
|
|
{ // change our own SSRC
|
|
|
|
bool hassentpackets = sentpackets;
|
|
|
|
|
|
|
|
if (hassentpackets)
|
|
|
|
{
|
|
|
|
// Only send BYE packet if we've actually sent data using this
|
|
|
|
// SSRC
|
|
|
|
|
|
|
|
RTCPCompoundPacket *rtcpcomppack;
|
|
|
|
|
|
|
|
if ((status = rtcpbuilder.BuildBYEPacket(&rtcpcomppack, 0, 0, useSR_BYEifpossible)) < 0)
|
|
|
|
{
|
|
|
|
delete rawpack;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
byepackets.push_back(rtcpcomppack);
|
|
|
|
if (byepackets.size() == 1) // was the first packet, schedule a BYE packet (otherwise there's already one scheduled)
|
|
|
|
{
|
|
|
|
rtcpsched.ScheduleBYEPacket(rtcpcomppack->GetCompoundPacketLength());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// bye packet is built and scheduled, now change our SSRC
|
|
|
|
// and reset the packet count in the transmitter
|
|
|
|
|
|
|
|
uint32_t newssrc = packetbuilder.CreateNewSSRC(sources);
|
|
|
|
|
|
|
|
sentpackets = false;
|
|
|
|
|
|
|
|
// remove old entry in source table and add new one
|
|
|
|
|
|
|
|
if ((status = sources.DeleteOwnSSRC()) < 0)
|
|
|
|
{
|
|
|
|
delete rawpack;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
if ((status = sources.CreateOwnSSRC(newssrc)) < 0)
|
|
|
|
{
|
|
|
|
delete rawpack;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete rawpack;
|
|
|
|
}
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
RTPTime d = rtcpsched.CalculateDeterministicInterval(false);
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
RTPTime t = RTPTime::CurrentTime();
|
|
|
|
double Td = d.GetDouble();
|
|
|
|
RTPTime sendertimeout = RTPTime(Td * sendermultiplier);
|
|
|
|
RTPTime generaltimeout = RTPTime(Td * membermultiplier);
|
|
|
|
RTPTime byetimeout = RTPTime(Td * byemultiplier);
|
|
|
|
RTPTime colltimeout = RTPTime(Td * collisionmultiplier);
|
|
|
|
RTPTime notetimeout = RTPTime(Td * notemultiplier);
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
sources.MultipleTimeouts(t, sendertimeout, byetimeout, generaltimeout, notetimeout);
|
|
|
|
collisionlist.Timeout(t, colltimeout);
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
// We'll check if it's time for RTCP stuff
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
bool istime = rtcpsched.IsTime();
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
if (istime)
|
|
|
|
{
|
|
|
|
RTCPCompoundPacket *pack;
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
// we'll check if there's a bye packet to send, or just a normal packet
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
if (byepackets.empty())
|
|
|
|
{
|
|
|
|
if ((status = rtcpbuilder.BuildNextPacket(&pack)) < 0)
|
|
|
|
{
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
if ((status = SendRTCPData(pack->GetCompoundPacketData(), pack->GetCompoundPacketLength())) < 0)
|
|
|
|
{
|
|
|
|
delete pack;
|
|
|
|
return status;
|
|
|
|
}
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
sentpackets = true;
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
OnSendRTCPCompoundPacket(pack); // we'll place this after the actual send to avoid tampering
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pack = *(byepackets.begin());
|
|
|
|
byepackets.pop_front();
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
if ((status = SendRTCPData(pack->GetCompoundPacketData(), pack->GetCompoundPacketLength())) < 0)
|
|
|
|
{
|
|
|
|
delete pack;
|
|
|
|
return status;
|
|
|
|
}
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
sentpackets = true;
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
OnSendRTCPCompoundPacket(pack); // we'll place this after the actual send to avoid tampering
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
if (!byepackets.empty()) // more bye packets to send, schedule them
|
|
|
|
{
|
|
|
|
rtcpsched.ScheduleBYEPacket((*(byepackets.begin()))->GetCompoundPacketLength());
|
|
|
|
}
|
|
|
|
}
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
rtcpsched.AnalyseOutgoing(*pack);
|
2018-02-27 17:05:46 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
delete pack;
|
|
|
|
}
|
|
|
|
return 0;
|
2018-02-27 17:05:46 -05:00
|
|
|
}
|
|
|
|
|
2018-11-12 10:05:18 -05:00
|
|
|
int RTPSession::CreateCNAME(uint8_t *buffer, std::size_t *bufferlength, bool resolve)
|
2018-02-26 19:35:16 -05:00
|
|
|
{
|
2018-11-12 10:05:18 -05:00
|
|
|
(void) resolve;
|
2018-03-04 19:17:19 -05:00
|
|
|
buffer[*bufferlength - 1] = 0;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
std::size_t offset = strlen((const char *) buffer);
|
|
|
|
if (offset < (*bufferlength - 1))
|
|
|
|
buffer[offset] = (uint8_t) '@';
|
|
|
|
offset++;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
std::size_t buflen2 = *bufferlength - offset;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-05 10:40:53 -05:00
|
|
|
QString hostnameStr = QHostInfo::localHostName();
|
|
|
|
int hostnameSize = hostnameStr.size();
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-05 10:40:53 -05:00
|
|
|
strncpy((char * )(buffer + offset), hostnameStr.toStdString().c_str(), buflen2);
|
|
|
|
*bufferlength = offset + hostnameSize;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
if (*bufferlength > RTCP_SDES_MAXITEMLENGTH)
|
|
|
|
*bufferlength = RTCP_SDES_MAXITEMLENGTH;
|
2018-03-05 10:40:53 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
return 0;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
RTPRandom *RTPSession::GetRandomNumberGenerator(RTPRandom *r)
|
|
|
|
{
|
2018-03-04 19:17:19 -05:00
|
|
|
RTPRandom *rnew = 0;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
if (r == 0)
|
|
|
|
{
|
|
|
|
rnew = RTPRandom::CreateDefaultRandomNumberGenerator();
|
|
|
|
deletertprnd = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rnew = r;
|
|
|
|
deletertprnd = false;
|
|
|
|
}
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
return rnew;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
2018-02-28 07:31:44 -05:00
|
|
|
int RTPSession::SendRTPData(const void *data, std::size_t len)
|
2018-02-26 19:35:16 -05:00
|
|
|
{
|
2018-03-04 19:17:19 -05:00
|
|
|
if (!m_changeOutgoingData)
|
|
|
|
return rtptrans->SendRTPData(data, len);
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
void *pSendData = 0;
|
|
|
|
std::size_t sendLen = 0;
|
|
|
|
int status = 0;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
status = OnChangeRTPOrRTCPData(data, len, true, &pSendData, &sendLen);
|
|
|
|
if (status < 0)
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
if (pSendData)
|
|
|
|
{
|
|
|
|
status = rtptrans->SendRTPData(pSendData, sendLen);
|
|
|
|
OnSentRTPOrRTCPData(pSendData, sendLen, true);
|
|
|
|
}
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
2018-02-28 07:31:44 -05:00
|
|
|
int RTPSession::SendRTCPData(const void *data, std::size_t len)
|
2018-02-26 19:35:16 -05:00
|
|
|
{
|
2018-03-04 19:17:19 -05:00
|
|
|
if (!m_changeOutgoingData)
|
|
|
|
return rtptrans->SendRTCPData(data, len);
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
void *pSendData = 0;
|
|
|
|
std::size_t sendLen = 0;
|
|
|
|
int status = 0;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
status = OnChangeRTPOrRTCPData(data, len, false, &pSendData, &sendLen);
|
|
|
|
if (status < 0)
|
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
if (pSendData)
|
|
|
|
{
|
|
|
|
status = rtptrans->SendRTCPData(pSendData, sendLen);
|
|
|
|
OnSentRTPOrRTCPData(pSendData, sendLen, false);
|
|
|
|
}
|
2018-02-26 19:35:16 -05:00
|
|
|
|
2018-03-04 19:17:19 -05:00
|
|
|
return status;
|
2018-02-26 19:35:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
} // end namespace
|
|
|
|
|