summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--anyrtpproxy/anyrtpproxy.cpp13
-rw-r--r--rtpSession.cpp30
-rw-r--r--rtpSession.h9
3 files changed, 48 insertions, 4 deletions
diff --git a/anyrtpproxy/anyrtpproxy.cpp b/anyrtpproxy/anyrtpproxy.cpp
index 951170a..cf5b69d 100644
--- a/anyrtpproxy/anyrtpproxy.cpp
+++ b/anyrtpproxy/anyrtpproxy.cpp
@@ -97,26 +97,33 @@ void* listener(void* p)
u_int16_t remote_port;
while(1) {
buf.setLength(MAX_PACKET_SIZE);
- u_int32_t len;
+ u_int32_t len=0;
if(param->dir_ == 1)
len = param->sock1_.recvFrom(buf.getBuf(), buf.getLength(), remote_addr, remote_port);
else if(param->dir_ == 2)
len = param->sock2_.recvFrom(buf.getBuf(), buf.getLength(), remote_addr, remote_port);
+ else break;
buf.setLength(len);
RtpSession& session = gRtpSessionTable.getSession(param->call_id_);
if(session.isDead())
break;
- //TODO: if weak? don't check but save the new(?) remote addr into list
if((param->dir_ == 1 && (remote_port != session.getRemotePort1() || remote_addr != session.getRemoteAddr1())) ||
(param->dir_ == 2 && (remote_port != session.getRemotePort2() || remote_addr != session.getRemoteAddr2())))
- continue;
+ {
+ //TODO: if weak? don't check but save the new(?) remote addr into list
+ continue;
+ }
if(param->dir_ == 1)
+ {
param->sock2_.sendTo(buf.getBuf(), buf.getLength(), session.getRemoteAddr2(), session.getRemotePort2());
+ }
else if(param->dir_ == 2)
+ {
param->sock1_.sendTo(buf.getBuf(), buf.getLength(), session.getRemoteAddr1(), session.getRemotePort1());
+ }
}
}
catch(std::exception &e)
diff --git a/rtpSession.cpp b/rtpSession.cpp
index 3dcc14b..a32049b 100644
--- a/rtpSession.cpp
+++ b/rtpSession.cpp
@@ -34,7 +34,7 @@
RtpSession::RtpSession(const std::string& call_id) : in_sync_(false), call_id_(call_id) , dead_(false), complete_(false),
local_addr_("") , local_port1_(0), local_port2_(0),
- remote_addr1_(""), remote_addr2_(""), remote_port1_(0), remote_port2_(0)
+ remote_addr1_(""), remote_addr2_(""), remote_port1_(0), remote_port2_(0),seen1_(false), seen2_(false)
{
}
@@ -83,6 +83,34 @@ RtpSession& RtpSession::setLocalAddr(std::string a)
return *this;
}
+bool RtpSession::getSeen1()
+{
+ Lock lock(mutex_);
+ return seen1_;
+}
+
+RtpSession& RtpSession::setSeen1()
+{
+ Lock lock(mutex_);
+ //in_sync_ = false;
+ seen1_ = true;
+ return *this;
+}
+
+bool RtpSession::getSeen2()
+{
+ Lock lock(mutex_);
+ return seen2_;
+}
+
+RtpSession& RtpSession::setSeen2()
+{
+ Lock lock(mutex_);
+ //in_sync_ = false;
+ seen2_ = true;
+ return *this;
+}
+
u_int16_t RtpSession::getLocalPort1()
{
Lock lock(mutex_);
diff --git a/rtpSession.h b/rtpSession.h
index c6c6542..16b0e5b 100644
--- a/rtpSession.h
+++ b/rtpSession.h
@@ -65,6 +65,12 @@ public:
std::string getRemoteAddr2();
RtpSession& setRemoteAddr2(std::string a);
+ RtpSession& setSeen1();
+ bool getSeen1();
+
+ RtpSession& setSeen2();
+ bool getSeen2();
+
private:
RtpSession(const RtpSession & src);
@@ -90,6 +96,8 @@ private:
ar & remote_port1_;
ar & remote_addr2_;
ar & remote_port2_;
+ ar & seen1_;
+ ar & seen2_;
if(old_local_port1 != local_port1_ || old_local_port2 != local_port2_ || old_local_addr != local_addr_)
reinit();
@@ -107,6 +115,7 @@ private:
u_int16_t local_port1_, local_port2_;
std::string remote_addr1_, remote_addr2_;
u_int16_t remote_port1_, remote_port2_;
+ bool seen1_,seen2_; //has at least 1 packet been recieved?
};