Module: sems Branch: sayer/offer_answer Commit: 72307a22406d608ad11b7e746f5e930f9c65053f URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=72307a22406d608ad11b7e746f5e930f9c65053f
Author: Stefan Sayer <[email protected]> Committer: Stefan Sayer <[email protected]> Date: Thu Oct 21 20:08:24 2010 +0200 renamed detached -> !processing_media, commented slight commenting and reorganization of order in AmSession API functions --- core/AmMediaProcessor.cpp | 6 ++-- core/AmSession.cpp | 14 +++++++-- core/AmSession.h | 63 +++++++++++++++++++++++++++++++----------- core/AmSessionContainer.cpp | 2 +- 4 files changed, 61 insertions(+), 24 deletions(-) diff --git a/core/AmMediaProcessor.cpp b/core/AmMediaProcessor.cpp index a52129b..1f1c2b7 100644 --- a/core/AmMediaProcessor.cpp +++ b/core/AmMediaProcessor.cpp @@ -83,7 +83,7 @@ AmMediaProcessor* AmMediaProcessor::instance() void AmMediaProcessor::addSession(AmSession* s, const string& callgroup) { - s->detached.set(false); + s->processing_media.set(true); // evaluate correct scheduler unsigned int sched_thread = 0; @@ -402,7 +402,7 @@ void AmMediaProcessorThread::process(AmEvent* e) set<AmSession*>::iterator s_it = sessions.find(s); if(s_it != sessions.end()){ sessions.erase(s_it); - s->detached.set(true); + s->processing_media.set(false); DBG("Session removed from the scheduler\n"); } } @@ -414,7 +414,7 @@ void AmMediaProcessorThread::process(AmEvent* e) if(s_it != sessions.end()){ sessions.erase(s_it); s->clearAudio(); - s->detached.set(true); + s->processing_media.set(false); DBG("Session removed from the scheduler\n"); } } diff --git a/core/AmSession.cpp b/core/AmSession.cpp index 36fa00c..ab060bb 100644 --- a/core/AmSession.cpp +++ b/core/AmSession.cpp @@ -60,7 +60,7 @@ AmMutex AmSession::session_num_mut; AmSession::AmSession() : AmEventQueue(this), dlg(this), - detached(true), + processing_media(false), sess_stopped(false), input(0), output(0), local_input(0), local_output(0), m_dtmfDetector(this), m_dtmfEventQueue(&m_dtmfDetector), @@ -109,6 +109,14 @@ void AmSession::changeCallgroup(const string& cg) { AmMediaProcessor::instance()->changeCallgroup(this, cg); } +void AmSession::startMediaProcessing() { + AmMediaProcessor::instance()->addSession(this, callgroup); +} + +void AmSession::stopMediaProcessing() { + AmMediaProcessor::instance()->removeSession(this); +} + void AmSession::addHandler(AmSessionEventHandler* sess_evh) { if (sess_evh != NULL) @@ -1003,7 +1011,7 @@ int AmSession::onSdpCompleted(const AmSdp& local_sdp, const AmSdp& remote_sdp) return -1; } - if(detached.get() && !getStopped()) { + if(!processing_media.get() && !getStopped()) { if(dlg.getStatus() == AmSipDialog::Connected) onSessionStart(); @@ -1011,7 +1019,7 @@ int AmSession::onSdpCompleted(const AmSdp& local_sdp, const AmSdp& remote_sdp) onEarlySessionStart(); if(input || output || local_input || local_output) { - AmMediaProcessor::instance()->addSession(this, callgroup); + startMediaProcessing(); } else { DBG("no audio input and output set. " diff --git a/core/AmSession.h b/core/AmSession.h index d5312f8..f82e0fc 100644 --- a/core/AmSession.h +++ b/core/AmSession.h @@ -143,7 +143,7 @@ private: AmCondition<bool> sess_stopped; - AmCondition<bool> detached; + AmCondition<bool> processing_media; static volatile unsigned int session_num; static AmMutex session_num_mut; @@ -225,6 +225,20 @@ public: */ void addHandler(AmSessionEventHandler*); + /* ---- media processing ---- */ + + /** start processing media - add to media processor */ + void startMediaProcessing(); + + /** stop processing media - remove from media processor */ + void stopMediaProcessing(); + + /** Is the session being processed in media processor? */ + bool getProcessingMedia() { return processing_media.get(); } + + /** Is the session detached from media processor? */ + bool getDetached() { return !processing_media.get(); } + /** * Set the call group for this call; calls in the same * group are processed by the same media processor thread. @@ -237,11 +251,16 @@ public: /** get the callgroup @return callgroup */ string getCallgroup(); - /** This function removes the session from - * the media processor and adds it again. + /** + * change the callgroup + * + * This function removes the session from + * the media processor and adds it again. */ void changeCallgroup(const string& cg); + /* ---- audio input and output ---- */ + /** * Lock audio input & output * (inclusive RTP stream) @@ -310,6 +329,8 @@ public: /** setter for rtp_str->receiving */ void setReceiving(bool receive) { RTPStream()->receiving = receive; } + /* ---- SIP dialog attributes ---- */ + /** Gets the Session's call ID */ const string& getCallID() const; @@ -328,6 +349,8 @@ public: /** Sets the URI for the session */ void setUri(const string& uri); + /* ---- RTP stream attributes ---- */ + /** Gets the current RTP payload */ const vector<SdpPayload*>& getPayloads(); @@ -340,6 +363,8 @@ public: /** get the payload provider for the session */ virtual AmPayloadProviderInterface* getPayloadProvider(); + /* ---- Call control ---- */ + /** refresh the session - re-INVITE or UPDATE*/ virtual bool refresh(); @@ -360,6 +385,8 @@ public: /** set the session on/off hold */ virtual void setOnHold(bool hold); + /* ---- Householding ---- */ + /** * Destroy the session. * It causes the session to be erased from the active session list @@ -382,18 +409,7 @@ public: */ bool getStopped() { return sess_stopped.get(); } - /** Is the session detached from media processor? */ - bool getDetached() { return detached.get(); } - - /** - * Creates a new Id which can be used within sessions. - */ - static string getNewId(); - - /** - * Gets the number of running sessions - */ - static unsigned int getSessionNum(); + /* ---- DTMF ---- */ /** * Entry point for DTMF events @@ -414,6 +430,8 @@ public: */ void sendDtmf(int event, unsigned int duration_ms); + /* ---- Event handlers ---- */ + /** DTMF event handler for apps to use*/ virtual void onDtmf(int event, int duration); @@ -465,14 +483,14 @@ public: * Warning: * Sems will NOT send any BYE on his own. */ - virtual void onSessionStart(){} + virtual void onSessionStart() {} /** * onEarlySessionStart will be called when * the media session is setup with the dialog * in Early state. */ - virtual void onEarlySessionStart(){} + virtual void onEarlySessionStart() {} /** * onRinging will be called after 180 is received. @@ -557,6 +575,17 @@ public: /** format session id for debugging */ string sid4dbg(); + + /** + * Creates a new Id which can be used within sessions. + */ + static string getNewId(); + + /** + * Gets the number of running sessions + */ + static unsigned int getSessionNum(); + }; inline AmRtpAudio* AmSession::RTPStream() { diff --git a/core/AmSessionContainer.cpp b/core/AmSessionContainer.cpp index a3d7a1e..05d94d8 100644 --- a/core/AmSessionContainer.cpp +++ b/core/AmSessionContainer.cpp @@ -86,7 +86,7 @@ bool AmSessionContainer::clean_sessions() { ds_mut.unlock(); - if(cur_session->is_stopped() && cur_session->detached.get()){ + if(cur_session->is_stopped() && !cur_session->getProcessingMedia()){ MONITORING_MARK_FINISHED(cur_session->getLocalTag().c_str()); _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
