1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-12 11:26:11 -05:00

qrtplib: removed jthread

This commit is contained in:
f4exb 2018-02-27 01:43:41 +01:00
parent 30d019d39a
commit c15c8b79d9
20 changed files with 32 additions and 633 deletions

View File

@ -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

View File

@ -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;

View File

@ -54,10 +54,6 @@
#include "rtpkeyhashtable.h"
#include <list>
#ifdef RTP_SUPPORT_THREAD
#include <jthread/jmutex.h>
#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

View File

@ -42,17 +42,10 @@
#include <iostream>
#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;

View File

@ -43,10 +43,6 @@
#include "rtpabortdescriptors.h"
#include <list>
#ifdef RTP_SUPPORT_THREAD
#include <jthread/jmutex.h>
#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)

View File

@ -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 <time.h>
#include <iostream>
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

View File

@ -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 <jthread/jthread.h>
#include <jthread/jmutex.h>
#include <list>
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

View File

@ -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;
}

View File

@ -40,9 +40,6 @@
#include "rtpconfig.h"
#include "rtprandom.h"
#ifdef RTP_SUPPORT_THREAD
#include <jthread/jmutex.h>
#endif // RTP_SUPPORT_THREAD
#include <stdio.h>
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;
};

View File

@ -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;

View File

@ -51,10 +51,6 @@
#include "rtpmemoryobject.h"
#include <list>
#ifdef RTP_SUPPORT_THREAD
#include <jthread/jmutex.h>
#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<RTCPCompoundPacket *> 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;
}

View File

@ -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

View File

@ -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;

View File

@ -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) { }

View File

@ -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;

View File

@ -47,10 +47,6 @@
#include "rtpabortdescriptors.h"
#include <list>
#ifdef RTP_SUPPORT_THREAD
#include <jthread/jmutex.h>
#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

View File

@ -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;

View File

@ -47,10 +47,6 @@
#include "rtpabortdescriptors.h"
#include <list>
#ifdef RTP_SUPPORT_THREAD
#include <jthread/jmutex.h>
#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

View File

@ -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;

View File

@ -51,10 +51,6 @@
#include <string.h>
#include <list>
#ifdef RTP_SUPPORT_THREAD
#include <jthread/jmutex.h>
#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