summaryrefslogtreecommitdiff
path: root/rtpSession.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rtpSession.cpp')
-rw-r--r--rtpSession.cpp57
1 files changed, 27 insertions, 30 deletions
diff --git a/rtpSession.cpp b/rtpSession.cpp
index ef48538..403f9b2 100644
--- a/rtpSession.cpp
+++ b/rtpSession.cpp
@@ -28,48 +28,31 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "PracticalSocket.h"
-
#include "rtpSession.h"
-RtpSession::RtpSession() : in_sync_(false), sock_(NULL), dead_(false), local_port_(0), local_addr_(""),
+RtpSession::RtpSession() : in_sync_(false), dead_(false), local_addr_(""), local_port1_(0), local_port2_(0),
remote_addr1_(""), remote_addr2_(""), remote_port1_(0), remote_port2_(0)
{
}
-RtpSession::~RtpSession()
-{
- if(sock_)
- delete reinterpret_cast<UDPSocket*>(sock_);
-}
-
void RtpSession::init()
{
Lock lock(mutex_);
- if(sock_ || !local_port_)
- return;
-
- sock_ = new UDPSocket(local_addr_, local_port_);
// TODO: start threads
}
-void RtpSession::reinitSock()
+void RtpSession::reinit()
{
- if(sock_)
- delete reinterpret_cast<UDPSocket*>(sock_);
- sock_ = NULL;
-
- if(!local_port_)
- return;
+ Lock lock(mutex_);
- sock_ = new UDPSocket(local_addr_, local_port_);
+// TODO: inform threads of reinit
}
bool RtpSession::isDead()
{
Lock lock(mutex_);
- return dead_;
+ return (dead_ && in_sync_);
}
bool RtpSession::isDead(bool d)
@@ -78,31 +61,45 @@ bool RtpSession::isDead(bool d)
return dead_ = d;
}
-u_int16_t RtpSession::getLocalPort()
+std::string RtpSession::getLocalAddr()
{
Lock lock(mutex_);
- return local_port_;
+ return local_addr_;
}
-RtpSession& RtpSession::setLocalPort(u_int16_t p)
+RtpSession& RtpSession::setLocalAddr(std::string a)
{
Lock lock(mutex_);
in_sync_ = false;
- local_port_ = p;
+ local_addr_ = a;
return *this;
}
-std::string RtpSession::getLocalAddr()
+u_int16_t RtpSession::getLocalPort1()
{
Lock lock(mutex_);
- return local_addr_;
+ return local_port1_;
}
-RtpSession& RtpSession::setLocalAddr(std::string a)
+RtpSession& RtpSession::setLocalPort1(u_int16_t p)
{
Lock lock(mutex_);
in_sync_ = false;
- local_addr_ = a;
+ local_port1_ = p;
+ return *this;
+}
+
+u_int16_t RtpSession::getLocalPort2()
+{
+ Lock lock(mutex_);
+ return local_port2_;
+}
+
+RtpSession& RtpSession::setLocalPort2(u_int16_t p)
+{
+ Lock lock(mutex_);
+ in_sync_ = false;
+ local_port2_ = p;
return *this;
}