summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOthmar Gsenger <otti@anytun.org>2008-03-08 18:39:15 +0000
committerOthmar Gsenger <otti@anytun.org>2008-03-08 18:39:15 +0000
commitb9ae5e0ed6e4238c7410265ed5530931d4552f7d (patch)
tree79f0f1fffb5120931d834987ec4bbb04c9a4660d
parentadded RtpSessionTable (diff)
added SyncRtpCommand
-rw-r--r--Makefile7
-rw-r--r--anyrtpproxy/Makefile21
-rw-r--r--anyrtpproxy/anyrtpproxy.cpp12
-rw-r--r--options.h4
-rw-r--r--rtpSession.cpp4
-rw-r--r--rtpSession.h5
-rw-r--r--rtpSessionTable.h6
-rw-r--r--syncCommand.cpp12
-rw-r--r--syncCommand.h9
9 files changed, 48 insertions, 32 deletions
diff --git a/Makefile b/Makefile
index 9ca8206..609e2fb 100644
--- a/Makefile
+++ b/Makefile
@@ -50,6 +50,7 @@ OBJS = tunDevice.o \
syncBuffer.o \
syncCommand.o \
syncRouteCommand.o \
+ syncRtpCommand.o \
syncConnectionCommand.o \
plainPacket.o \
encryptedPacket.o \
@@ -96,6 +97,9 @@ ANYCTROBJS = log.o \
signalController.o \
connectionList.o \
connectionParam.o \
+ rtpSessionTable.o \
+ rtpSession.o \
+ syncRtpCommand.o \
anyctrOptions.o \
router.o \
routingTable.o \
@@ -195,6 +199,9 @@ syncCommand.o: syncCommand.cpp syncCommand.h
syncRouteCommand.o: syncRouteCommand.cpp syncRouteCommand.h
$(C++) $(CCFLAGS) $< -c
+syncRtpCommand.o: syncRtpCommand.cpp syncRtpCommand.h
+ $(C++) $(CCFLAGS) $< -c
+
syncConnectionCommand.o: syncConnectionCommand.cpp syncConnectionCommand.h
$(C++) $(CCFLAGS) $< -c
diff --git a/anyrtpproxy/Makefile b/anyrtpproxy/Makefile
index 9bb23d4..f4486b1 100644
--- a/anyrtpproxy/Makefile
+++ b/anyrtpproxy/Makefile
@@ -6,11 +6,12 @@ LD = g++
LDFLAGS = -g -Wall -O2 -lpthread
OBJS = anyrtpproxy.o \
- signalController.o \
- PracticalSocket.o \
- log.o \
- buffer.o \
+ ../signalController.o \
+ ../PracticalSocket.o \
+ ../log.o \
+ ../buffer.o \
../rtpSessionTable.o \
+ ../rtpSession.o \
options.o
EXECUTABLE = anyrtpproxy
@@ -20,18 +21,6 @@ all: $(EXECUTABLE)
anyrtpproxy: $(OBJS)
$(LD) $(OBJS) -o $@ $(LDFLAGS)
-signalController.o: ../signalController.cpp ../signalController.h
- $(C++) $(CCFLAGS) $< -c
-
-PracticalSocket.o: ../PracticalSocket.cpp ../PracticalSocket.h
- $(C++) $(CCFLAGS) $< -c
-
-log.o: ../log.cpp ../log.h
- $(C++) $(CCFLAGS) $< -c
-
-buffer.o: ../buffer.cpp ../buffer.h
- $(C++) $(CCFLAGS) $< -c
-
options.o: options.cpp options.h
$(C++) $(CCFLAGS) $< -c
diff --git a/anyrtpproxy/anyrtpproxy.cpp b/anyrtpproxy/anyrtpproxy.cpp
index 9079994..3b0c488 100644
--- a/anyrtpproxy/anyrtpproxy.cpp
+++ b/anyrtpproxy/anyrtpproxy.cpp
@@ -35,8 +35,8 @@ public:
private:
Mutex mutex;
- std::map<ControlHost, std::pair<UDPSocket*, pthread_t>> control_hosts_;
-}
+ std::map<ControlHost, std::pair<UDPSocket*, pthread_t> > control_hosts_;
+};
void* sender(void* dont_use_me)
{
@@ -50,10 +50,10 @@ void* sender(void* dont_use_me)
u_int16_t remote_port;
while(1) {
buf.setLength(MAX_PACKET_SIZE);
- u_int32_t len = control_sock_.recvFrom(buf.getBuf(), buf.getLength(), remote_host, remote_port);
+ u_int32_t len = control_sock.recvFrom(buf.getBuf(), buf.getLength(), remote_host, remote_port);
buf.setLength(len);
- param->control_.setHost(remote_host, remote_port);
+//TODO????//TODO????//TODO????//TODO????//TODO????//TODO????//TODO???? control.setHost(remote_host, remote_port);
// SenderThreadParam receiverParam = {control_host, control_sock, sock, gOpt.getRemoteHosts().front()};
// pthread_t receiverThread;
@@ -62,8 +62,8 @@ void* sender(void* dont_use_me)
HostList::const_iterator it = remote_host_list.begin();
- for(;it != remote_host_list.end(); it++)
- param->sock_.sendTo(buf.getBuf(), buf.getLength(), it->addr_, it->port_);
+// for(;it != remote_host_list.end(); it++)
+// param->sock_.sendTo(buf.getBuf(), buf.getLength(), it->addr_, it->port_);
}
}
catch(std::exception &e)
diff --git a/options.h b/options.h
index 0d7748a..598250e 100644
--- a/options.h
+++ b/options.h
@@ -107,7 +107,7 @@ private:
void operator=(const Options &l);
static Options* inst;
- static Mutex instMutex;
+ static ::Mutex instMutex;
class instanceCleaner {
public: ~instanceCleaner() {
if(Options::inst != 0)
@@ -116,7 +116,7 @@ private:
};
friend class instanceCleaner;
- Mutex mutex;
+ ::Mutex mutex;
ConnectToList connect_to_;
std::string progname_;
diff --git a/rtpSession.cpp b/rtpSession.cpp
index cb8700a..6933917 100644
--- a/rtpSession.cpp
+++ b/rtpSession.cpp
@@ -30,10 +30,10 @@
#include "rtpSession.h"
-RtpSession::RtpSession() : mutex_()
+RtpSession::RtpSession()
{
}
-RtpSession::RtpSession(const RtpSession & src) : mutex_()
+RtpSession::RtpSession(const RtpSession & src)
{
}
diff --git a/rtpSession.h b/rtpSession.h
index cf1577f..218843c 100644
--- a/rtpSession.h
+++ b/rtpSession.h
@@ -31,7 +31,6 @@
#ifndef _RTPSESSION_H_
#define _RTPSESSION_H_
-#include "options.h"
#include "threadUtils.hpp"
#include <boost/archive/text_oarchive.hpp>
@@ -45,12 +44,12 @@ public:
private:
//TODO: check if this is ok
- Mutex mutex_;
+ //Mutex mutex_;
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
- Lock lock(mutex_);
+ //Lock lock(mutex_);
}
};
diff --git a/rtpSessionTable.h b/rtpSessionTable.h
index f127801..5b14082 100644
--- a/rtpSessionTable.h
+++ b/rtpSessionTable.h
@@ -49,14 +49,14 @@ public:
//u_int16_t getRoute(const NetworkAddress &);
bool empty();
void clear();
- Mutex& getMutex();
+ ::Mutex& getMutex();
RtpSession& getOrNewSessionUnlocked(const std::string & addr);
uint16_t getCountUnlocked();
RtpSessionMap::iterator getBeginUnlocked();
RtpSessionMap::iterator getEndUnlocked();
private:
- static Mutex instMutex;
+ static ::Mutex instMutex;
static RtpSessionTable* inst;
class instanceCleaner {
public: ~instanceCleaner() {
@@ -67,7 +67,7 @@ private:
RtpSessionTable(const RtpSessionTable &s);
void operator=(const RtpSessionTable &s);
RtpSessionMap map_;
- Mutex mutex_;
+ ::Mutex mutex_;
};
extern RtpSessionTable& gRtpSessionTable;
diff --git a/syncCommand.cpp b/syncCommand.cpp
index 3385478..a36f1d5 100644
--- a/syncCommand.cpp
+++ b/syncCommand.cpp
@@ -4,18 +4,28 @@ SyncCommand::SyncCommand(ConnectionList & cl )
{
scc_ = new SyncConnectionCommand(cl);
src_ = new SyncRouteCommand();
+ srtpc_ = new SyncRtpCommand();
}
SyncCommand::SyncCommand(ConnectionList & cl, u_int16_t mux )
{
scc_ = new SyncConnectionCommand(cl,mux);
src_=NULL;
+ srtpc_=NULL;
}
SyncCommand::SyncCommand(NetworkPrefix np )
{
scc_ = NULL;
src_ = new SyncRouteCommand(np);
+ srtpc_=NULL;
+}
+
+SyncCommand::SyncCommand(const std::string & callid )
+{
+ scc_ = NULL;
+ src_ = NULL;
+ srtpc_= new SyncRtpCommand(callid);
}
SyncCommand::~SyncCommand()
@@ -24,4 +34,6 @@ SyncCommand::~SyncCommand()
delete scc_;
if (src_)
delete src_;
+ if (srtpc_)
+ delete srtpc_;
}
diff --git a/syncCommand.h b/syncCommand.h
index db82153..2672960 100644
--- a/syncCommand.h
+++ b/syncCommand.h
@@ -7,6 +7,7 @@
#include "threadUtils.hpp"
#include "syncConnectionCommand.h"
#include "syncRouteCommand.h"
+#include "syncRtpCommand.h"
#include "networkPrefix.h"
#include <string>
@@ -15,6 +16,7 @@ class SyncCommand
public:
SyncCommand(ConnectionList & cl );
SyncCommand(ConnectionList & cl ,u_int16_t mux);
+ SyncCommand(const std::string &);
SyncCommand(NetworkPrefix);
~SyncCommand();
@@ -22,6 +24,7 @@ private:
SyncCommand(const SyncCommand &);
SyncConnectionCommand * scc_;
SyncRouteCommand * src_;
+ SyncRtpCommand * srtpc_;
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
@@ -35,12 +38,18 @@ private:
{
syncstr = "route";
}
+ if ( src_)
+ {
+ syncstr = "rtp";
+ }
ar & syncstr;
// std::cout << "syncstr received " <<syncstr << std::endl;
if (syncstr == "connection")
ar & *scc_;
if (syncstr == "route")
ar & *src_;
+ if (syncstr == "rtp")
+ ar & *srtpc_;
// std::cout << "syncstr done " <<syncstr << std::endl;
}
};