sessions can be set onHold with AmSession::setOnHold, if you want a reinvite with on Hold, call AmSession::Reinvite after setOnHold

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@277 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 20 years ago
parent 4ddc7a6714
commit 4e6f4a917b

@ -121,6 +121,15 @@ void AmMediaProcessor::removeSession(AmSession* s) {
removeFromProcessor(s, RemoveSession);
}
/* FIXME: implement Call Group ts offsets for soft changing of
call groups
*/
void AmMediaProcessor::changeCallgroup(AmSession* s,
const string& new_callgroup) {
removeFromProcessor(s, SoftRemoveSession);
addSession(s, new_callgroup);
}
void AmMediaProcessor::removeFromProcessor(AmSession* s,
unsigned int r_type) {
DBG("AmMediaProcessor::removeSession\n");
@ -329,6 +338,16 @@ void AmMediaProcessorThread::process(AmEvent* e)
break;
case AmMediaProcessor::SoftRemoveSession:{
AmSession* s = sr->s;
set<AmSession*>::iterator s_it = sessions.find(s);
if(s_it != sessions.end()){
sessions.erase(s_it);
DBG("Session removed softly from the scheduler\n");
}
}
break;
default:
ERROR("AmMediaProcessorThread::process: unknown event id.");
break;

@ -101,11 +101,12 @@ class AmMediaProcessor
void removeFromProcessor(AmSession* s, unsigned int r_type);
public:
/**
* InsertSession : inserts the session to the processor
* RemoveSession : remove the session from the processor
* ClearSession : remove the session from processor and clear audio
* InsertSession : inserts the session to the processor
* RemoveSession : remove the session from the processor
* SoftRemoveSession : remove the session from the processor but leave it attached
* ClearSession : remove the session from processor and clear audio
*/
enum { InsertSession, RemoveSession, ClearSession };
enum { InsertSession, RemoveSession, SoftRemoveSession, ClearSession };
static AmMediaProcessor* instance();
@ -116,6 +117,9 @@ public:
void removeSession(AmSession* s);
/** Remove session s from processor and clear its audio */
void clearSession(AmSession* s);
/** Change the callgroup of a session (use with caution) */
void changeCallgroup(AmSession* s,
const string& new_callgroup);
};

@ -164,6 +164,9 @@ void AmRtpStream::setLocalPort()
int AmRtpStream::send( unsigned int ts, unsigned char* buffer, unsigned int size )
{
if ((mute) || (hold))
return 0;
if(!size)
return -1;
@ -270,6 +273,7 @@ AmRtpStream::AmRtpStream(AmSession* _s)
passive(false),
telephone_event_pt(NULL),
mute(false),
hold(false),
receiving(true)
{
@ -302,6 +306,9 @@ AmRtpStream::~AmRtpStream()
int AmRtpStream::getLocalPort()
{
if (hold)
return 0;
if(!l_port)
setLocalPort();
@ -377,6 +384,14 @@ void AmRtpStream::resume()
runcond.set(true);
}
void AmRtpStream::setOnHold(bool on_hold) {
mute = hold = on_hold;
}
bool AmRtpStream::getOnHold() {
return hold;
}
void AmRtpStream::icmpError()
{
if(!passive){

@ -141,6 +141,7 @@ public:
/** Mute */
bool mute;
bool hold;
bool begin_talk;
/** should we receive packets? if not -> drop */
@ -222,6 +223,12 @@ public:
*/
void resume();
/** set the RTP stream on hold (mute && port = 0) */
void setOnHold(bool on_hold);
/** get the RTP stream on hold */
bool getOnHold();
/**
* Report an ICMP error.
*/

@ -143,6 +143,11 @@ void AmSession::setCallgroup(const string& cg) {
callgroup = cg;
}
void AmSession::changeCallgroup(const string& cg) {
callgroup = cg;
AmMediaProcessor::instance()->changeCallgroup(this, cg);
}
void AmSession::addHandler(AmSessionEventHandler* sess_evh)
{
if (sess_evh != NULL)
@ -687,3 +692,13 @@ void AmSession::sendInvite()
sdp.genRequest(AmConfig::LocalIP,rtp_str.getLocalPort(),sdp_body);
dlg.invite("", "application/sdp", sdp_body);
}
void AmSession::setOnHold(bool hold)
{
lockAudio();
bool old_hold = rtp_str.getOnHold();
rtp_str.setOnHold(hold);
if (hold != old_hold)
sendReinvite();
unlockAudio();
}

@ -182,6 +182,11 @@ public:
void setCallgroup(const string& cg);
string getCallgroup() { return callgroup; }
/** This function removes the session from
* the media processor and adds it again.
*/
void changeCallgroup(const string& cg);
/**
* Accept the SDP proposal
* thus setting up audio stream
@ -263,6 +268,9 @@ public:
/** send an INVITE */
void sendInvite();
/** set the session on/off hold */
void setOnHold(bool hold);
/**
* Destroy the session.
* It causes the session to be erased from the active session list

Loading…
Cancel
Save