diff --git a/qrtplib/CMakeLists.txt b/qrtplib/CMakeLists.txt index 60c020a04..60ff3cf98 100644 --- a/qrtplib/CMakeLists.txt +++ b/qrtplib/CMakeLists.txt @@ -30,7 +30,6 @@ set (qrtplib_HEADERS rtpmemoryobject.h rtppacket.h rtppacketbuilder.h - rtppollthread.h rtprandom.h rtprandomrand48.h rtprandomrands.h @@ -80,7 +79,6 @@ set(qrtplib_SOURCES rtplibraryversion.cpp rtppacket.cpp rtppacketbuilder.cpp - rtppollthread.cpp rtprandom.cpp rtprandomrand48.cpp rtprandomrands.cpp diff --git a/qrtplib/extratransmitters/rtpfaketransmitter.cpp b/qrtplib/extratransmitters/rtpfaketransmitter.cpp index 6346792c1..b2e590aca 100644 --- a/qrtplib/extratransmitters/rtpfaketransmitter.cpp +++ b/qrtplib/extratransmitters/rtpfaketransmitter.cpp @@ -75,17 +75,10 @@ mreq.imr_interface.s_addr = htonl(bindIP);\ status = setsockopt(socket,IPPROTO_IP,type,(const char *)&mreq,sizeof(struct ip_mreq));\ }*/ -#ifdef RTP_SUPPORT_THREAD - #define MAINMUTEX_LOCK { if (threadsafe) mainmutex.Lock(); } - #define MAINMUTEX_UNLOCK { if (threadsafe) mainmutex.Unlock(); } - #define WAITMUTEX_LOCK { if (threadsafe) waitmutex.Lock(); } - #define WAITMUTEX_UNLOCK { if (threadsafe) waitmutex.Unlock(); } -#else - #define MAINMUTEX_LOCK - #define MAINMUTEX_UNLOCK - #define WAITMUTEX_LOCK - #define WAITMUTEX_UNLOCK -#endif // RTP_SUPPORT_THREAD +#define MAINMUTEX_LOCK +#define MAINMUTEX_UNLOCK +#define WAITMUTEX_LOCK +#define WAITMUTEX_UNLOCK namespace qrtplib { @@ -110,23 +103,8 @@ int RTPFakeTransmitter::Init(bool tsafe) if (tsafe) return ERR_RTP_NOTHREADSUPPORT; -#ifdef RTP_SUPPORT_THREAD - threadsafe = tsafe; - if (threadsafe) - { - int status; - - status = mainmutex.Init(); - if (status < 0) - return ERR_RTP_FAKETRANS_CANTINITMUTEX; - status = waitmutex.Init(); - if (status < 0) - return ERR_RTP_FAKETRANS_CANTINITMUTEX; - } -#else if (tsafe) return ERR_RTP_NOTHREADSUPPORT; -#endif // RTP_SUPPORT_THREAD init = true; return 0; diff --git a/qrtplib/extratransmitters/rtpfaketransmitter.h b/qrtplib/extratransmitters/rtpfaketransmitter.h index 6238cad2b..629ec3612 100644 --- a/qrtplib/extratransmitters/rtpfaketransmitter.h +++ b/qrtplib/extratransmitters/rtpfaketransmitter.h @@ -54,10 +54,6 @@ #include "rtpkeyhashtable.h" #include -#ifdef RTP_SUPPORT_THREAD - #include -#endif // RTP_SUPPORT_THREAD - #define RTPFAKETRANS_HASHSIZE 8317 #define RTPFAKETRANS_DEFAULTPORTBASE 5000 @@ -232,10 +228,6 @@ private: int CreateAbortDescriptors(); void DestroyAbortDescriptors(); void AbortWaitInternal(); -#ifdef RTP_SUPPORT_THREAD - jthread::JMutex mainmutex,waitmutex; - int threadsafe; -#endif // RTP_SUPPORT_THREAD }; } // end namespace diff --git a/qrtplib/rtpexternaltransmitter.cpp b/qrtplib/rtpexternaltransmitter.cpp index 1cd2ed791..9d7016f97 100644 --- a/qrtplib/rtpexternaltransmitter.cpp +++ b/qrtplib/rtpexternaltransmitter.cpp @@ -42,17 +42,10 @@ #include -#ifdef RTP_SUPPORT_THREAD - #define MAINMUTEX_LOCK { if (threadsafe) mainmutex.Lock(); } - #define MAINMUTEX_UNLOCK { if (threadsafe) mainmutex.Unlock(); } - #define WAITMUTEX_LOCK { if (threadsafe) waitmutex.Lock(); } - #define WAITMUTEX_UNLOCK { if (threadsafe) waitmutex.Unlock(); } -#else - #define MAINMUTEX_LOCK - #define MAINMUTEX_UNLOCK - #define WAITMUTEX_LOCK - #define WAITMUTEX_UNLOCK -#endif // RTP_SUPPORT_THREAD +#define MAINMUTEX_LOCK +#define MAINMUTEX_UNLOCK +#define WAITMUTEX_LOCK +#define WAITMUTEX_UNLOCK namespace qrtplib { @@ -73,23 +66,8 @@ int RTPExternalTransmitter::Init(bool tsafe) if (init) return ERR_RTP_EXTERNALTRANS_ALREADYINIT; -#ifdef RTP_SUPPORT_THREAD - threadsafe = tsafe; - if (threadsafe) - { - int status; - - status = mainmutex.Init(); - if (status < 0) - return ERR_RTP_EXTERNALTRANS_CANTINITMUTEX; - status = waitmutex.Init(); - if (status < 0) - return ERR_RTP_EXTERNALTRANS_CANTINITMUTEX; - } -#else if (tsafe) return ERR_RTP_NOTHREADSUPPORT; -#endif // RTP_SUPPORT_THREAD init = true; return 0; diff --git a/qrtplib/rtpexternaltransmitter.h b/qrtplib/rtpexternaltransmitter.h index 72574a129..cad0ff9b3 100644 --- a/qrtplib/rtpexternaltransmitter.h +++ b/qrtplib/rtpexternaltransmitter.h @@ -43,10 +43,6 @@ #include "rtpabortdescriptors.h" #include -#ifdef RTP_SUPPORT_THREAD - #include -#endif // RTP_SUPPORT_THREAD - namespace qrtplib { @@ -203,10 +199,6 @@ private: RTPAbortDescriptors m_abortDesc; int m_abortCount; -#ifdef RTP_SUPPORT_THREAD - jthread::JMutex mainmutex,waitmutex; - int threadsafe; -#endif // RTP_SUPPORT_THREAD }; inline void RTPExternalPacketInjecter::InjectRTP(const void *data, size_t len, const RTPAddress &a) diff --git a/qrtplib/rtppollthread.cpp b/qrtplib/rtppollthread.cpp deleted file mode 100644 index 76defe99b..000000000 --- a/qrtplib/rtppollthread.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* - - This file is a part of JRTPLIB - Copyright (c) 1999-2017 Jori Liesenborgs - - Contact: jori.liesenborgs@gmail.com - - 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). - - 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: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - 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. - -*/ - -#include "rtppollthread.h" - -#ifdef RTP_SUPPORT_THREAD - -#include "rtpsession.h" -#include "rtcpscheduler.h" -#include "rtperrors.h" -#include "rtprawpacket.h" -#include -#include - -namespace qrtplib -{ - -RTPPollThread::RTPPollThread(RTPSession &session,RTCPScheduler &sched):rtpsession(session),rtcpsched(sched) -{ - stop = false; - transmitter = 0; - timeinit.Dummy(); -} - -RTPPollThread::~RTPPollThread() -{ - Stop(); -} - -int RTPPollThread::Start(RTPTransmitter *trans) -{ - if (JThread::IsRunning()) - return ERR_RTP_POLLTHREAD_ALREADYRUNNING; - - transmitter = trans; - if (!stopmutex.IsInitialized()) - { - if (stopmutex.Init() < 0) - return ERR_RTP_POLLTHREAD_CANTINITMUTEX; - } - stop = false; - if (JThread::Start() < 0) - return ERR_RTP_POLLTHREAD_CANTSTARTTHREAD; - return 0; -} - -void RTPPollThread::Stop() -{ - if (!IsRunning()) - return; - - stopmutex.Lock(); - stop = true; - stopmutex.Unlock(); - - if (transmitter) - transmitter->AbortWait(); - - RTPTime thetime = RTPTime::CurrentTime(); - bool done = false; - - while (JThread::IsRunning() && !done) - { - // wait max 5 sec - RTPTime curtime = RTPTime::CurrentTime(); - if ((curtime.GetDouble()-thetime.GetDouble()) > 5.0) - done = true; - RTPTime::Wait(RTPTime(0,10000)); - } - - if (JThread::IsRunning()) - { - std::cerr << "RTPPollThread: Warning! Having to kill thread!" << std::endl; - JThread::Kill(); - } - stop = false; - transmitter = 0; -} - -void *RTPPollThread::Thread() -{ - JThread::ThreadStarted(); - - bool stopthread; - - stopmutex.Lock(); - stopthread = stop; - stopmutex.Unlock(); - - rtpsession.OnPollThreadStart(stopthread); - - while (!stopthread) - { - int status; - - rtpsession.schedmutex.Lock(); - rtpsession.sourcesmutex.Lock(); - - RTPTime rtcpdelay = rtcpsched.GetTransmissionDelay(); - - rtpsession.sourcesmutex.Unlock(); - rtpsession.schedmutex.Unlock(); - - if ((status = transmitter->WaitForIncomingData(rtcpdelay)) < 0) - { - stopthread = true; - rtpsession.OnPollThreadError(status); - } - else - { - if ((status = transmitter->Poll()) < 0) - { - stopthread = true; - rtpsession.OnPollThreadError(status); - } - else - { - if ((status = rtpsession.ProcessPolledData()) < 0) - { - stopthread = true; - rtpsession.OnPollThreadError(status); - } - else - { - rtpsession.OnPollThreadStep(); - stopmutex.Lock(); - stopthread = stop; - stopmutex.Unlock(); - } - } - } - } - - rtpsession.OnPollThreadStop(); - - return 0; -} - -} // end namespace - -#endif // RTP_SUPPORT_THREAD - diff --git a/qrtplib/rtppollthread.h b/qrtplib/rtppollthread.h deleted file mode 100644 index 3864e15dd..000000000 --- a/qrtplib/rtppollthread.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - - This file is a part of JRTPLIB - Copyright (c) 1999-2017 Jori Liesenborgs - - Contact: jori.liesenborgs@gmail.com - - 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). - - 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: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - 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. - -*/ - -/** - * \file rtppollthread.h - */ - -#ifndef RTPPOLLTHREAD_H - -#define RTPPOLLTHREAD_H - -#include "rtpconfig.h" - -#ifdef RTP_SUPPORT_THREAD - -#include "rtptransmitter.h" - -#include -#include -#include - -namespace qrtplib -{ - -class RTPSession; -class RTCPScheduler; - -class JRTPLIB_IMPORTEXPORT RTPPollThread : private jthread::JThread -{ -public: - RTPPollThread(RTPSession &session,RTCPScheduler &rtcpsched); - ~RTPPollThread(); - int Start(RTPTransmitter *trans); - void Stop(); -private: - void *Thread(); - - bool stop; - jthread::JMutex stopmutex; - RTPTransmitter *transmitter; - - RTPSession &rtpsession; - RTCPScheduler &rtcpsched; -}; - -} // end namespace - -#endif // RTP_SUPPORT_THREAD - -#endif // RTPPOLLTHREAD_H diff --git a/qrtplib/rtprandomrand48.cpp b/qrtplib/rtprandomrand48.cpp index 0def976a2..43795718e 100644 --- a/qrtplib/rtprandomrand48.cpp +++ b/qrtplib/rtprandomrand48.cpp @@ -51,9 +51,6 @@ RTPRandomRand48::~RTPRandomRand48() void RTPRandomRand48::SetSeed(uint32_t seed) { -#ifdef RTP_SUPPORT_THREAD - mutex.Init(); // TODO: check error! -#endif // RTP_SUPPORT_THREAD #ifdef RTP_HAVE_VSUINT64SUFFIX state = ((uint64_t)seed) << 16 | 0x330Eui64; @@ -78,9 +75,6 @@ uint16_t RTPRandomRand48::GetRandom16() uint32_t RTPRandomRand48::GetRandom32() { -#ifdef RTP_SUPPORT_THREAD - mutex.Lock(); -#endif // RTP_SUPPORT_THREAD #ifdef RTP_HAVE_VSUINT64SUFFIX state = ((0x5DEECE66Dui64*state) + 0xBui64)&0x0000ffffffffffffui64; @@ -92,17 +86,11 @@ uint32_t RTPRandomRand48::GetRandom32() uint32_t x = (uint32_t)((state>>16)&0xffffffffULL); #endif // RTP_HAVE_VSUINT64SUFFIX -#ifdef RTP_SUPPORT_THREAD - mutex.Unlock(); -#endif // RTP_SUPPORT_THREAD return x; } double RTPRandomRand48::GetRandomDouble() { -#ifdef RTP_SUPPORT_THREAD - mutex.Lock(); -#endif // RTP_SUPPORT_THREAD #ifdef RTP_HAVE_VSUINT64SUFFIX state = ((0x5DEECE66Dui64*state) + 0xBui64)&0x0000ffffffffffffui64; @@ -114,9 +102,6 @@ double RTPRandomRand48::GetRandomDouble() int64_t x = (int64_t)state; #endif // RTP_HAVE_VSUINT64SUFFIX -#ifdef RTP_SUPPORT_THREAD - mutex.Unlock(); -#endif // RTP_SUPPORT_THREAD double y = 3.552713678800500929355621337890625e-15 * (double)x; return y; } diff --git a/qrtplib/rtprandomrand48.h b/qrtplib/rtprandomrand48.h index ef9c61790..36e9a83bc 100644 --- a/qrtplib/rtprandomrand48.h +++ b/qrtplib/rtprandomrand48.h @@ -40,9 +40,6 @@ #include "rtpconfig.h" #include "rtprandom.h" -#ifdef RTP_SUPPORT_THREAD - #include -#endif // RTP_SUPPORT_THREAD #include namespace qrtplib @@ -63,9 +60,6 @@ public: private: void SetSeed(uint32_t seed); -#ifdef RTP_SUPPORT_THREAD - jthread::JMutex mutex; -#endif // RTP_SUPPORT_THREAD uint64_t state; }; diff --git a/qrtplib/rtpsession.cpp b/qrtplib/rtpsession.cpp index f5ee7bee2..d5dabde2b 100644 --- a/qrtplib/rtpsession.cpp +++ b/qrtplib/rtpsession.cpp @@ -32,7 +32,6 @@ #include "rtpsession.h" #include "rtperrors.h" -#include "rtppollthread.h" #include "rtpudpv4transmitter.h" #include "rtpudpv6transmitter.h" #include "rtptcptransmitter.h" @@ -58,25 +57,14 @@ #endif // WIN32 -#ifdef RTP_SUPPORT_THREAD - #define SOURCES_LOCK { if (needthreadsafety) sourcesmutex.Lock(); } - #define SOURCES_UNLOCK { if (needthreadsafety) sourcesmutex.Unlock(); } - #define BUILDER_LOCK { if (needthreadsafety) buildermutex.Lock(); } - #define BUILDER_UNLOCK { if (needthreadsafety) buildermutex.Unlock(); } - #define SCHED_LOCK { if (needthreadsafety) schedmutex.Lock(); } - #define SCHED_UNLOCK { if (needthreadsafety) schedmutex.Unlock(); } - #define PACKSENT_LOCK { if (needthreadsafety) packsentmutex.Lock(); } - #define PACKSENT_UNLOCK { if (needthreadsafety) packsentmutex.Unlock(); } -#else - #define SOURCES_LOCK - #define SOURCES_UNLOCK - #define BUILDER_LOCK - #define BUILDER_UNLOCK - #define SCHED_LOCK - #define SCHED_UNLOCK - #define PACKSENT_LOCK - #define PACKSENT_UNLOCK -#endif // RTP_SUPPORT_THREAD +#define SOURCES_LOCK +#define SOURCES_UNLOCK +#define BUILDER_LOCK +#define BUILDER_UNLOCK +#define SCHED_LOCK +#define SCHED_UNLOCK +#define PACKSENT_LOCK +#define PACKSENT_UNLOCK namespace qrtplib { @@ -330,82 +318,6 @@ int RTPSession::InternalCreate(const RTPSessionParams &sessparams) // Do thread stuff if necessary -#ifdef RTP_SUPPORT_THREAD - pollthread = 0; - if (usingpollthread) - { - if (!sourcesmutex.IsInitialized()) - { - if (sourcesmutex.Init() < 0) - { - if (deletetransmitter) - RTPDelete(rtptrans,GetMemoryManager()); - packetbuilder.Destroy(); - sources.Clear(); - rtcpbuilder.Destroy(); - return ERR_RTP_SESSION_CANTINITMUTEX; - } - } - if (!buildermutex.IsInitialized()) - { - if (buildermutex.Init() < 0) - { - if (deletetransmitter) - RTPDelete(rtptrans,GetMemoryManager()); - packetbuilder.Destroy(); - sources.Clear(); - rtcpbuilder.Destroy(); - return ERR_RTP_SESSION_CANTINITMUTEX; - } - } - if (!schedmutex.IsInitialized()) - { - if (schedmutex.Init() < 0) - { - if (deletetransmitter) - RTPDelete(rtptrans,GetMemoryManager()); - packetbuilder.Destroy(); - sources.Clear(); - rtcpbuilder.Destroy(); - return ERR_RTP_SESSION_CANTINITMUTEX; - } - } - if (!packsentmutex.IsInitialized()) - { - if (packsentmutex.Init() < 0) - { - if (deletetransmitter) - RTPDelete(rtptrans,GetMemoryManager()); - packetbuilder.Destroy(); - sources.Clear(); - rtcpbuilder.Destroy(); - return ERR_RTP_SESSION_CANTINITMUTEX; - } - } - - pollthread = RTPNew(GetMemoryManager(),RTPMEM_TYPE_CLASS_RTPPOLLTHREAD) RTPPollThread(*this,rtcpsched); - if (pollthread == 0) - { - if (deletetransmitter) - RTPDelete(rtptrans,GetMemoryManager()); - packetbuilder.Destroy(); - sources.Clear(); - rtcpbuilder.Destroy(); - return ERR_RTP_OUTOFMEM; - } - if ((status = pollthread->Start(rtptrans)) < 0) - { - if (deletetransmitter) - RTPDelete(rtptrans,GetMemoryManager()); - RTPDelete(pollthread,GetMemoryManager()); - packetbuilder.Destroy(); - sources.Clear(); - rtcpbuilder.Destroy(); - return status; - } - } -#endif // RTP_SUPPORT_THREAD - created = true; return 0; } @@ -416,11 +328,6 @@ void RTPSession::Destroy() if (!created) return; -#ifdef RTP_SUPPORT_THREAD - if (pollthread) - RTPDelete(pollthread,GetMemoryManager()); -#endif // RTP_SUPPORT_THREAD - if (deletetransmitter) RTPDelete(rtptrans,GetMemoryManager()); packetbuilder.Destroy(); @@ -445,11 +352,6 @@ void RTPSession::BYEDestroy(const RTPTime &maxwaittime,const void *reason,size_t // first, stop the thread so we have full control over all components -#ifdef RTP_SUPPORT_THREAD - if (pollthread) - RTPDelete(pollthread,GetMemoryManager()); -#endif // RTP_SUPPORT_THREAD - RTPTime stoptime = RTPTime::CurrentTime(); stoptime += maxwaittime; diff --git a/qrtplib/rtpsession.h b/qrtplib/rtpsession.h index a60b2241e..7766003e0 100644 --- a/qrtplib/rtpsession.h +++ b/qrtplib/rtpsession.h @@ -51,10 +51,6 @@ #include "rtpmemoryobject.h" #include -#ifdef RTP_SUPPORT_THREAD - #include -#endif // RTP_SUPPORT_THREAD - namespace qrtplib { @@ -532,28 +528,6 @@ protected: /** Is called when an RTCP compound packet has just been sent (useful to inspect outgoing RTCP data). */ virtual void OnSendRTCPCompoundPacket(RTCPCompoundPacket *pack); -#ifdef RTP_SUPPORT_THREAD - /** Is called when error \c errcode was detected in the poll thread. */ - virtual void OnPollThreadError(int errcode); - - /** Is called each time the poll thread loops. - * Is called each time the poll thread loops. This happens when incoming data was - * detected or when it's time to send an RTCP compound packet. - */ - virtual void OnPollThreadStep(); - - /** Is called when the poll thread is started. - * Is called when the poll thread is started. This happens just before entering the - * thread main loop. - * \param stop This can be used to stop the thread immediately without entering the loop. - */ - virtual void OnPollThreadStart(bool &stop); - - /** Is called when the poll thread is going to stop. - * Is called when the poll thread is going to stop. This happens just before termitating the thread. - */ - virtual void OnPollThreadStop(); -#endif // RTP_SUPPORT_THREAD /** If this is set to true, outgoing data will be passed through RTPSession::OnChangeRTPOrRTCPData * and RTPSession::OnSentRTPOrRTCPData, allowing you to modify the data (e.g. to encrypt it). */ @@ -636,12 +610,6 @@ private: std::list byepackets; -#ifdef RTP_SUPPORT_THREAD - RTPPollThread *pollthread; - jthread::JMutex sourcesmutex,buildermutex,schedmutex,packsentmutex; - - friend class RTPPollThread; -#endif // RTP_SUPPORT_THREAD friend class RTPSessionSources; friend class RTCPSessionPacketBuilder; }; @@ -670,13 +638,6 @@ inline void RTPSession::OnRTCPSDESPrivateItem(RTPSourceData *, const void *, siz inline void RTPSession::OnBYEPacket(RTPSourceData *) { } inline void RTPSession::OnSendRTCPCompoundPacket(RTCPCompoundPacket *) { } -#ifdef RTP_SUPPORT_THREAD -inline void RTPSession::OnPollThreadError(int) { } -inline void RTPSession::OnPollThreadStep() { } -inline void RTPSession::OnPollThreadStart(bool &) { } -inline void RTPSession::OnPollThreadStop() { } -#endif // RTP_SUPPORT_THREAD - inline int RTPSession::OnChangeRTPOrRTCPData(const void *, size_t, bool, void **, size_t *) { return ERR_RTP_RTPSESSION_CHANGEREQUESTEDBUTNOTIMPLEMENTED; } diff --git a/qrtplib/rtpsessionparams.cpp b/qrtplib/rtpsessionparams.cpp index fac2f8e7c..d8cb21da3 100644 --- a/qrtplib/rtpsessionparams.cpp +++ b/qrtplib/rtpsessionparams.cpp @@ -40,13 +40,8 @@ namespace qrtplib RTPSessionParams::RTPSessionParams() : mininterval(0,0) { -#ifdef RTP_SUPPORT_THREAD - usepollthread = true; - m_needThreadSafety = true; -#else usepollthread = false; m_needThreadSafety = false; -#endif // RTP_SUPPORT_THREAD maxpacksize = RTP_DEFAULTPACKETSIZE; receivemode = RTPTransmitter::AcceptAll; acceptown = false; @@ -76,24 +71,14 @@ RTPSessionParams::RTPSessionParams() : mininterval(0,0) int RTPSessionParams::SetUsePollThread(bool usethread) { -#ifndef RTP_SUPPORT_THREAD JRTPLIB_UNUSED(usethread); return ERR_RTP_NOTHREADSUPPORT; -#else - usepollthread = usethread; - return 0; -#endif // RTP_SUPPORT_THREAD } int RTPSessionParams::SetNeedThreadSafety(bool s) { -#ifndef RTP_SUPPORT_THREAD JRTPLIB_UNUSED(s); return ERR_RTP_NOTHREADSUPPORT; -#else - m_needThreadSafety = s; - return 0; -#endif // RTP_SUPPORT_THREAD } } // end namespace diff --git a/qrtplib/rtptcptransmitter.cpp b/qrtplib/rtptcptransmitter.cpp index cc256558c..9bb3f33ee 100644 --- a/qrtplib/rtptcptransmitter.cpp +++ b/qrtplib/rtptcptransmitter.cpp @@ -49,17 +49,10 @@ using namespace std; #define RTPTCPTRANS_MAXPACKSIZE 65535 -#ifdef RTP_SUPPORT_THREAD - #define MAINMUTEX_LOCK { if (m_threadsafe) m_mainMutex.Lock(); } - #define MAINMUTEX_UNLOCK { if (m_threadsafe) m_mainMutex.Unlock(); } - #define WAITMUTEX_LOCK { if (m_threadsafe) m_waitMutex.Lock(); } - #define WAITMUTEX_UNLOCK { if (m_threadsafe) m_waitMutex.Unlock(); } -#else - #define MAINMUTEX_LOCK - #define MAINMUTEX_UNLOCK - #define WAITMUTEX_LOCK - #define WAITMUTEX_UNLOCK -#endif // RTP_SUPPORT_THREAD +#define MAINMUTEX_LOCK +#define MAINMUTEX_UNLOCK +#define WAITMUTEX_LOCK +#define WAITMUTEX_UNLOCK namespace qrtplib { @@ -80,23 +73,8 @@ int RTPTCPTransmitter::Init(bool tsafe) if (m_init) return ERR_RTP_TCPTRANS_ALREADYINIT; -#ifdef RTP_SUPPORT_THREAD - m_threadsafe = tsafe; - if (m_threadsafe) - { - int status; - - status = m_mainMutex.Init(); - if (status < 0) - return ERR_RTP_TCPTRANS_CANTINITMUTEX; - status = m_waitMutex.Init(); - if (status < 0) - return ERR_RTP_TCPTRANS_CANTINITMUTEX; - } -#else if (tsafe) return ERR_RTP_NOTHREADSUPPORT; -#endif // RTP_SUPPORT_THREAD m_maxPackSize = RTPTCPTRANS_MAXPACKSIZE; m_init = true; diff --git a/qrtplib/rtptcptransmitter.h b/qrtplib/rtptcptransmitter.h index ad1b0662f..092ab37d2 100644 --- a/qrtplib/rtptcptransmitter.h +++ b/qrtplib/rtptcptransmitter.h @@ -192,10 +192,6 @@ private: RTPAbortDescriptors m_abortDesc; RTPAbortDescriptors *m_pAbortDesc; // in case an external one was specified -#ifdef RTP_SUPPORT_THREAD - jthread::JMutex m_mainMutex, m_waitMutex; - bool m_threadsafe; -#endif // RTP_SUPPORT_THREAD }; inline void RTPTCPTransmitter::OnSendError(SocketType) { } diff --git a/qrtplib/rtpudpv4transmitter.cpp b/qrtplib/rtpudpv4transmitter.cpp index c4bbbd8a2..f2eae3e01 100644 --- a/qrtplib/rtpudpv4transmitter.cpp +++ b/qrtplib/rtpudpv4transmitter.cpp @@ -59,17 +59,10 @@ using namespace std; mreq.imr_interface.s_addr = htonl(mcastifaceIP);\ status = setsockopt(socket,IPPROTO_IP,type,(const char *)&mreq,sizeof(struct ip_mreq));\ } -#ifdef RTP_SUPPORT_THREAD - #define MAINMUTEX_LOCK { if (threadsafe) mainmutex.Lock(); } - #define MAINMUTEX_UNLOCK { if (threadsafe) mainmutex.Unlock(); } - #define WAITMUTEX_LOCK { if (threadsafe) waitmutex.Lock(); } - #define WAITMUTEX_UNLOCK { if (threadsafe) waitmutex.Unlock(); } -#else - #define MAINMUTEX_LOCK - #define MAINMUTEX_UNLOCK - #define WAITMUTEX_LOCK - #define WAITMUTEX_UNLOCK -#endif // RTP_SUPPORT_THREAD +#define MAINMUTEX_LOCK +#define MAINMUTEX_UNLOCK +#define WAITMUTEX_LOCK +#define WAITMUTEX_UNLOCK #define CLOSESOCKETS do { \ if (closesocketswhendone) \ @@ -104,23 +97,8 @@ int RTPUDPv4Transmitter::Init(bool tsafe) if (init) return ERR_RTP_UDPV4TRANS_ALREADYINIT; -#ifdef RTP_SUPPORT_THREAD - threadsafe = tsafe; - if (threadsafe) - { - int status; - - status = mainmutex.Init(); - if (status < 0) - return ERR_RTP_UDPV4TRANS_CANTINITMUTEX; - status = waitmutex.Init(); - if (status < 0) - return ERR_RTP_UDPV4TRANS_CANTINITMUTEX; - } -#else if (tsafe) return ERR_RTP_NOTHREADSUPPORT; -#endif // RTP_SUPPORT_THREAD init = true; return 0; diff --git a/qrtplib/rtpudpv4transmitter.h b/qrtplib/rtpudpv4transmitter.h index 32f6c103d..cc7b0a542 100644 --- a/qrtplib/rtpudpv4transmitter.h +++ b/qrtplib/rtpudpv4transmitter.h @@ -47,10 +47,6 @@ #include "rtpabortdescriptors.h" #include -#ifdef RTP_SUPPORT_THREAD - #include -#endif // RTP_SUPPORT_THREAD - #define RTPUDPV4TRANS_HASHSIZE 8317 #define RTPUDPV4TRANS_DEFAULTPORTBASE 5000 @@ -355,10 +351,6 @@ private: RTPAbortDescriptors m_abortDesc; RTPAbortDescriptors *m_pAbortDesc; // in case an external one was specified -#ifdef RTP_SUPPORT_THREAD - jthread::JMutex mainmutex,waitmutex; - int threadsafe; -#endif // RTP_SUPPORT_THREAD }; } // end namespace diff --git a/qrtplib/rtpudpv4transmitternobind.cpp b/qrtplib/rtpudpv4transmitternobind.cpp index d9632ada9..ae4d9e48d 100644 --- a/qrtplib/rtpudpv4transmitternobind.cpp +++ b/qrtplib/rtpudpv4transmitternobind.cpp @@ -59,17 +59,10 @@ using namespace std; mreq.imr_interface.s_addr = htonl(mcastifaceIP);\ status = setsockopt(socket,IPPROTO_IP,type,(const char *)&mreq,sizeof(struct ip_mreq));\ } -#ifdef RTP_SUPPORT_THREAD - #define MAINMUTEX_LOCK { if (threadsafe) mainmutex.Lock(); } - #define MAINMUTEX_UNLOCK { if (threadsafe) mainmutex.Unlock(); } - #define WAITMUTEX_LOCK { if (threadsafe) waitmutex.Lock(); } - #define WAITMUTEX_UNLOCK { if (threadsafe) waitmutex.Unlock(); } -#else - #define MAINMUTEX_LOCK - #define MAINMUTEX_UNLOCK - #define WAITMUTEX_LOCK - #define WAITMUTEX_UNLOCK -#endif // RTP_SUPPORT_THREAD +#define MAINMUTEX_LOCK +#define MAINMUTEX_UNLOCK +#define WAITMUTEX_LOCK +#define WAITMUTEX_UNLOCK #define CLOSESOCKETS do { \ if (closesocketswhendone) \ @@ -120,23 +113,8 @@ int RTPUDPv4TransmitterNoBind::Init(bool tsafe) if (init) return ERR_RTP_UDPV4TRANS_ALREADYINIT; -#ifdef RTP_SUPPORT_THREAD - threadsafe = tsafe; - if (threadsafe) - { - int status; - - status = mainmutex.Init(); - if (status < 0) - return ERR_RTP_UDPV4TRANS_CANTINITMUTEX; - status = waitmutex.Init(); - if (status < 0) - return ERR_RTP_UDPV4TRANS_CANTINITMUTEX; - } -#else if (tsafe) return ERR_RTP_NOTHREADSUPPORT; -#endif // RTP_SUPPORT_THREAD init = true; return 0; diff --git a/qrtplib/rtpudpv4transmitternobind.h b/qrtplib/rtpudpv4transmitternobind.h index 23aaa2918..1c3d425d6 100644 --- a/qrtplib/rtpudpv4transmitternobind.h +++ b/qrtplib/rtpudpv4transmitternobind.h @@ -47,10 +47,6 @@ #include "rtpabortdescriptors.h" #include -#ifdef RTP_SUPPORT_THREAD - #include -#endif // RTP_SUPPORT_THREAD - #define RTPUDPV4TRANSNOBIND_HASHSIZE 8317 #define RTPUDPV4TRANSNOBIND_DEFAULTPORTBASE 5000 @@ -359,10 +355,6 @@ private: RTPAbortDescriptors m_abortDesc; RTPAbortDescriptors *m_pAbortDesc; // in case an external one was specified -#ifdef RTP_SUPPORT_THREAD - jthread::JMutex mainmutex,waitmutex; - int threadsafe; -#endif // RTP_SUPPORT_THREAD }; } // end namespace diff --git a/qrtplib/rtpudpv6transmitter.cpp b/qrtplib/rtpudpv6transmitter.cpp index 848589739..3caccfc3b 100644 --- a/qrtplib/rtpudpv6transmitter.cpp +++ b/qrtplib/rtpudpv6transmitter.cpp @@ -60,17 +60,10 @@ mreq.ipv6mr_interface = mcastifidx;\ status = setsockopt(socket,IPPROTO_IPV6,type,(const char *)&mreq,sizeof(struct ipv6_mreq));\ } -#ifdef RTP_SUPPORT_THREAD - #define MAINMUTEX_LOCK { if (threadsafe) mainmutex.Lock(); } - #define MAINMUTEX_UNLOCK { if (threadsafe) mainmutex.Unlock(); } - #define WAITMUTEX_LOCK { if (threadsafe) waitmutex.Lock(); } - #define WAITMUTEX_UNLOCK { if (threadsafe) waitmutex.Unlock(); } -#else - #define MAINMUTEX_LOCK - #define MAINMUTEX_UNLOCK - #define WAITMUTEX_LOCK - #define WAITMUTEX_UNLOCK -#endif // RTP_SUPPORT_THREAD +#define MAINMUTEX_LOCK +#define MAINMUTEX_UNLOCK +#define WAITMUTEX_LOCK +#define WAITMUTEX_UNLOCK inline bool operator==(const in6_addr &ip1,const in6_addr &ip2) { @@ -101,23 +94,8 @@ int RTPUDPv6Transmitter::Init(bool tsafe) if (init) return ERR_RTP_UDPV6TRANS_ALREADYINIT; -#ifdef RTP_SUPPORT_THREAD - threadsafe = tsafe; - if (threadsafe) - { - int status; - - status = mainmutex.Init(); - if (status < 0) - return ERR_RTP_UDPV6TRANS_CANTINITMUTEX; - status = waitmutex.Init(); - if (status < 0) - return ERR_RTP_UDPV6TRANS_CANTINITMUTEX; - } -#else if (tsafe) return ERR_RTP_NOTHREADSUPPORT; -#endif // RTP_SUPPORT_THREAD init = true; return 0; diff --git a/qrtplib/rtpudpv6transmitter.h b/qrtplib/rtpudpv6transmitter.h index 2a582035c..16fe6f9ef 100644 --- a/qrtplib/rtpudpv6transmitter.h +++ b/qrtplib/rtpudpv6transmitter.h @@ -51,10 +51,6 @@ #include #include -#ifdef RTP_SUPPORT_THREAD - #include -#endif // RTP_SUPPORT_THREAD - #define RTPUDPV6TRANS_HASHSIZE 8317 #define RTPUDPV6TRANS_DEFAULTPORTBASE 5000 @@ -316,10 +312,6 @@ private: RTPAbortDescriptors m_abortDesc; RTPAbortDescriptors *m_pAbortDesc; -#ifdef RTP_SUPPORT_THREAD - jthread::JMutex mainmutex,waitmutex; - int threadsafe; -#endif // RTP_SUPPORT_THREAD }; } // end namespace