b2b with media relay changes:

b2ab_caller_owns_connector.patch: 
 AmB2ABCallerSession owns the session connector. 
 Caller session waits for callee session to end before it ends itself.

early media support for B2ABSession.



git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1164 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 18 years ago
parent 352876aa9a
commit 330dc13a6a

@ -304,14 +304,15 @@ void CallBackDialog::process(AmEvent* ev)
// need this to pass credentials...
AmB2ABCalleeSession* CallBackDialog::createCalleeSession() {
CallBackCalleeDialog* sess = new CallBackCalleeDialog(getLocalTag(), cred);
CallBackCalleeDialog* sess = new CallBackCalleeDialog(getLocalTag(), connector, cred);
addAuthHandler(sess);
return sess;
}
CallBackCalleeDialog::CallBackCalleeDialog(const string& other_tag,
UACAuthCred* cred)
: AmB2ABCalleeSession(other_tag), cred(cred)
AmSessionAudioConnector* connector,
UACAuthCred* cred)
: AmB2ABCalleeSession(other_tag, connector), cred(cred)
{
// set configured playout type
rtp_str.setPlayoutType(CallBackFactory::m_PlayoutType);

@ -126,7 +126,9 @@ class CallBackCalleeDialog
{
UACAuthCred* cred;
public:
CallBackCalleeDialog(const string& other_tag, UACAuthCred* cred);
CallBackCalleeDialog(const string& other_tag,
AmSessionAudioConnector* connector,
UACAuthCred* cred);
~CallBackCalleeDialog();
UACAuthCred* getCredentials() { return cred; }
};

@ -98,9 +98,11 @@ b2b_connectDialog::~b2b_connectDialog()
void b2b_connectDialog::onInvite(const AmSipRequest& req)
{
// TODO: do reinvites get here? if so, don't set a timer then
// -> yes, they do.
if (dlg.getStatus() == AmSipDialog::Connected) {
// reinvites
AmB2ABCallerSession::onInvite(req);
return;
}
string app_param = getHeader(req.hdrs, PARAM_HDR);
@ -228,7 +230,9 @@ void b2b_connectDialog::onCancel()
AmB2ABCalleeSession* b2b_connectDialog::createCalleeSession()
{
b2b_connectCalleeSession* sess = new b2b_connectCalleeSession(getLocalTag(), user, password);
b2b_connectCalleeSession* sess = new b2b_connectCalleeSession(getLocalTag(),
connector,
user, password);
AmSessionEventHandlerFactory* uac_auth_f =
AmPlugIn::instance()->getFactory4Seh("uac_auth");
@ -250,10 +254,11 @@ AmB2ABCalleeSession* b2b_connectDialog::createCalleeSession()
}
b2b_connectCalleeSession::b2b_connectCalleeSession(const string& other_tag,
AmSessionAudioConnector* connector,
const string& user, const string& pwd)
: credentials("", user, pwd), // domain (realm) is unused in credentials
AmB2ABCalleeSession(other_tag) {
AmB2ABCalleeSession(other_tag, connector)
{
rtp_str.setPlayoutType(ADAPTIVE_PLAYOUT);
setDtmfDetectionEnabled(false);
}

@ -90,7 +90,9 @@ class b2b_connectCalleeSession
void onSipReply(const AmSipReply& reply);
public:
b2b_connectCalleeSession(const string& other_tag, const string& user, const string& pwd);
b2b_connectCalleeSession(const string& other_tag,
AmSessionAudioConnector* connector,
const string& user, const string& pwd);
~b2b_connectCalleeSession();
inline UACAuthCred* getCredentials();

@ -149,12 +149,13 @@ void JukecallSession::process(AmEvent* event)
}
AmB2ABCalleeSession* JukecallSession::createCalleeSession() {
AmB2ABCalleeSession* sess = new JukecalleeSession(getLocalTag());
AmB2ABCalleeSession* sess = new JukecalleeSession(getLocalTag(), connector);
return sess;
}
JukecalleeSession::JukecalleeSession(const string& other_tag)
: AmB2ABCalleeSession(other_tag)
JukecalleeSession::JukecalleeSession(const string& other_tag,
AmSessionAudioConnector* connector)
: AmB2ABCalleeSession(other_tag, connector)
{
setDtmfDetectionEnabled(false);
}

@ -85,7 +85,8 @@ class JukecalleeSession
auto_ptr<AmAudioFile> song;
public:
JukecalleeSession(const string& other_tag);
JukecalleeSession(const string& other_tag,
AmSessionAudioConnector* connector);
};
class JukeEvent : public AmEvent {

@ -167,7 +167,8 @@ void ServiceLineCallerDialog::onDtmf(int event, int duration)
}
AmB2ABCalleeSession* ServiceLineCallerDialog::createCalleeSession() {
ServiceLineCalleeDialog* sess = new ServiceLineCalleeDialog(getLocalTag());
ServiceLineCalleeDialog* sess =
new ServiceLineCalleeDialog(getLocalTag(), connector);
AmSessionEventHandlerFactory* uac_auth_f =
AmPlugIn::instance()->getFactory4Seh("uac_auth");
@ -190,8 +191,9 @@ AmB2ABCalleeSession* ServiceLineCallerDialog::createCalleeSession() {
ServiceLineCalleeDialog::~ServiceLineCalleeDialog() {
}
ServiceLineCalleeDialog::ServiceLineCalleeDialog(const string& other_tag)
: AmB2ABCalleeSession(other_tag),
ServiceLineCalleeDialog::ServiceLineCalleeDialog(const string& other_tag,
AmSessionAudioConnector* connector)
: AmB2ABCalleeSession(other_tag, connector),
cred(ServiceLineFactory::GWAuthrealm,
ServiceLineFactory::GWAuthuser,
ServiceLineFactory::GWAuthpwd)

@ -87,7 +87,8 @@ class ServiceLineCalleeDialog
UACAuthCred cred;
public:
ServiceLineCalleeDialog(const string& other_tag);
ServiceLineCalleeDialog(const string& other_tag,
AmSessionAudioConnector* connector);
~ServiceLineCalleeDialog();
UACAuthCred* getCredentials();
};

@ -45,8 +45,8 @@ void PySemsB2ABDialog::onSessionStart(const AmSipRequest& req)
}
AmB2ABCalleeSession* PySemsB2ABDialog::createCalleeSession() {
return new PySemsB2ABCalleeDialog(getLocalTag());
return new PySemsB2ABCalleeDialog(getLocalTag(),
connector);
}
void PySemsB2ABDialog::process(AmEvent* event)

@ -62,8 +62,9 @@ struct PySemsB2ABEvent: public B2ABEvent
class PySemsB2ABCalleeDialog : public AmB2ABCalleeSession
{
public:
PySemsB2ABCalleeDialog(const string& other_local_tag)
: AmB2ABCalleeSession(other_local_tag) { }
PySemsB2ABCalleeDialog(const string& other_local_tag,
AmSessionAudioConnector* connector)
: AmB2ABCalleeSession(other_local_tag, connector) { }
protected:
void onB2ABEvent(B2ABEvent* ev);

@ -1,11 +1,11 @@
TARGET = py_sems_lib.so
OFILES = sippy_sems_libcmodule.o sippy_sems_libPySemsB2ABEvent.o sippy_sems_libPySemsB2ABCalleeDialog.o sippy_sems_libAmB2ABCalleeSession.o sippy_sems_libPySemsB2ABDialog.o sippy_sems_libPySemsB2BDialog.o sippy_sems_libPySemsDialog.o sippy_sems_libAmAudioFile.o sippy_sems_libAmAudioEvent.o sippy_sems_libAmEvent.o sippy_sems_libAmSipDialog.o sippy_sems_libAmSipReply.o sippy_sems_libAmSipRequest.o sippy_sems_libstring.o
HFILES = sipAPIpy_sems_lib.h sippy_sems_libPySemsB2ABEvent.h sippy_sems_libPySemsB2ABCalleeDialog.h sippy_sems_libAmB2ABCalleeSession.h sippy_sems_libPySemsB2ABDialog.h sippy_sems_libPySemsB2BDialog.h sippy_sems_libPySemsDialog.h sippy_sems_libAmAudioFile.h sippy_sems_libAmAudioEvent.h sippy_sems_libAmEvent.h sippy_sems_libAmSipDialog.h sippy_sems_libAmSipReply.h sippy_sems_libAmSipRequest.h sippy_sems_libstring.h
OFILES = sippy_sems_libcmodule.o sippy_sems_libPySemsB2ABEvent.o sippy_sems_libPySemsB2ABCalleeDialog.o sippy_sems_libAmB2ABCalleeSession.o sippy_sems_libPySemsB2ABDialog.o sippy_sems_libAmSessionAudioConnector.o sippy_sems_libPySemsB2BDialog.o sippy_sems_libPySemsDialog.o sippy_sems_libAmAudioFile.o sippy_sems_libAmAudioEvent.o sippy_sems_libAmEvent.o sippy_sems_libAmSipDialog.o sippy_sems_libAmSipReply.o sippy_sems_libAmSipRequest.o sippy_sems_libstring.o
HFILES = sipAPIpy_sems_lib.h sippy_sems_libPySemsB2ABEvent.h sippy_sems_libPySemsB2ABCalleeDialog.h sippy_sems_libAmB2ABCalleeSession.h sippy_sems_libPySemsB2ABDialog.h sippy_sems_libAmSessionAudioConnector.h sippy_sems_libPySemsB2BDialog.h sippy_sems_libPySemsDialog.h sippy_sems_libAmAudioFile.h sippy_sems_libAmAudioEvent.h sippy_sems_libAmEvent.h sippy_sems_libAmSipDialog.h sippy_sems_libAmSipReply.h sippy_sems_libAmSipRequest.h sippy_sems_libstring.h
CC = gcc
CXX = g++
LINK = g++
CPPFLAGS = -I. -I$(COREPATH) -I/usr/include/python$(PY_VER)
CPPFLAGS = -I. -I$(COREPATH) -I/usr/include/python2.5
CFLAGS = -pipe -fPIC -O2 -w
CXXFLAGS = -Wall -Wno-reorder -g -pipe -fPIC -O2 -w
LFLAGS = -g -shared -Wl,--version-script=py_sems_lib.exp
@ -35,9 +35,9 @@ $(TARGET): $(OFILES)
$(OFILES): $(HFILES)
install: $(TARGET)
@test -d $(DESTDIR)/usr/lib/python$(PY_VER)/site-packages || mkdir -p $(DESTDIR)/usr/lib/python$(PY_VER)/site-packages
cp -f $(TARGET) $(DESTDIR)/usr/lib/python$(PY_VER)/site-packages/$(TARGET)
strip $(DESTDIR)/usr/lib/python$(PY_VER)/site-packages/$(TARGET)
@test -d $(DESTDIR)/usr/lib/python2.5/site-packages || mkdir -p $(DESTDIR)/usr/lib/python2.5/site-packages
cp -f $(TARGET) $(DESTDIR)/usr/lib/python2.5/site-packages/$(TARGET)
strip $(DESTDIR)/usr/lib/python2.5/site-packages/$(TARGET)
clean:
-rm -f $(TARGET)
@ -46,6 +46,7 @@ clean:
-rm -f sippy_sems_libPySemsB2ABCalleeDialog.o
-rm -f sippy_sems_libAmB2ABCalleeSession.o
-rm -f sippy_sems_libPySemsB2ABDialog.o
-rm -f sippy_sems_libAmSessionAudioConnector.o
-rm -f sippy_sems_libPySemsB2BDialog.o
-rm -f sippy_sems_libPySemsDialog.o
-rm -f sippy_sems_libAmAudioFile.o

@ -1,4 +1,23 @@
class AmSessionAudioConnector
{
%TypeHeaderCode
#include "../../../core/AmB2ABSession.h"
%End
public:
AmSessionAudioConnector();
~AmSessionAudioConnector();
void block();
void release();
void waitReleased();
private:
AmSessionAudioConnector(const AmSessionAudioConnector&);
};
class PySemsB2ABDialog
{
%TypeHeaderCode
@ -62,7 +81,7 @@ class AmB2ABCalleeSession
#include "../../../core/AmB2ABSession.h"
%End
public:
AmB2ABCalleeSession(const string& /*other_local_tag*/);
AmB2ABCalleeSession(const string& /*other_local_tag*/, AmSessionAudioConnector* );
void connectSession();
void disconnectSession();
@ -83,7 +102,7 @@ class PySemsB2ABCalleeDialog : AmB2ABCalleeSession
#include "../../../core/AmB2ABSession.h"
%End
public:
PySemsB2ABCalleeDialog(const string& /*other_local_tag*/);
PySemsB2ABCalleeDialog(const string& /*other_local_tag*/, AmSessionAudioConnector* /* connector */);
protected:
virtual void onPyB2ABEvent(PySemsB2ABEvent* /TransferBack/);

@ -1,3 +1,3 @@
target = py_sems_lib
sources = sippy_sems_libcmodule.cpp sippy_sems_libPySemsB2ABEvent.cpp sippy_sems_libPySemsB2ABCalleeDialog.cpp sippy_sems_libAmB2ABCalleeSession.cpp sippy_sems_libPySemsB2ABDialog.cpp sippy_sems_libPySemsB2BDialog.cpp sippy_sems_libPySemsDialog.cpp sippy_sems_libAmAudioFile.cpp sippy_sems_libAmAudioEvent.cpp sippy_sems_libAmEvent.cpp sippy_sems_libAmSipDialog.cpp sippy_sems_libAmSipReply.cpp sippy_sems_libAmSipRequest.cpp sippy_sems_libstring.cpp
headers = sipAPIpy_sems_lib.h sippy_sems_libPySemsB2ABEvent.h sippy_sems_libPySemsB2ABCalleeDialog.h sippy_sems_libAmB2ABCalleeSession.h sippy_sems_libPySemsB2ABDialog.h sippy_sems_libPySemsB2BDialog.h sippy_sems_libPySemsDialog.h sippy_sems_libAmAudioFile.h sippy_sems_libAmAudioEvent.h sippy_sems_libAmEvent.h sippy_sems_libAmSipDialog.h sippy_sems_libAmSipReply.h sippy_sems_libAmSipRequest.h sippy_sems_libstring.h
sources = sippy_sems_libcmodule.cpp sippy_sems_libPySemsB2ABEvent.cpp sippy_sems_libPySemsB2ABCalleeDialog.cpp sippy_sems_libAmB2ABCalleeSession.cpp sippy_sems_libPySemsB2ABDialog.cpp sippy_sems_libAmSessionAudioConnector.cpp sippy_sems_libPySemsB2BDialog.cpp sippy_sems_libPySemsDialog.cpp sippy_sems_libAmAudioFile.cpp sippy_sems_libAmAudioEvent.cpp sippy_sems_libAmEvent.cpp sippy_sems_libAmSipDialog.cpp sippy_sems_libAmSipReply.cpp sippy_sems_libAmSipRequest.cpp sippy_sems_libstring.cpp
headers = sipAPIpy_sems_lib.h sippy_sems_libPySemsB2ABEvent.h sippy_sems_libPySemsB2ABCalleeDialog.h sippy_sems_libAmB2ABCalleeSession.h sippy_sems_libPySemsB2ABDialog.h sippy_sems_libAmSessionAudioConnector.h sippy_sems_libPySemsB2BDialog.h sippy_sems_libPySemsDialog.h sippy_sems_libAmAudioFile.h sippy_sems_libAmAudioEvent.h sippy_sems_libAmEvent.h sippy_sems_libAmSipDialog.h sippy_sems_libAmSipReply.h sippy_sems_libAmSipRequest.h sippy_sems_libstring.h

@ -1,7 +1,7 @@
/*
* Internal module API header file.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#ifndef _py_sems_libAPI_H
@ -23,6 +23,7 @@
#define sipName_PySemsB2ABCalleeDialog sipNm_py_sems_lib_PySemsB2ABCalleeDialog
#define sipName_AmB2ABCalleeSession sipNm_py_sems_lib_AmB2ABCalleeSession
#define sipName_PySemsB2ABDialog sipNm_py_sems_lib_PySemsB2ABDialog
#define sipName_AmSessionAudioConnector sipNm_py_sems_lib_AmSessionAudioConnector
#define sipName_PySemsB2BDialog sipNm_py_sems_lib_PySemsB2BDialog
#define sipName_PySemsDialog sipNm_py_sems_lib_PySemsDialog
#define sipName_AmAudioFile sipNm_py_sems_lib_AmAudioFile
@ -124,6 +125,10 @@ extern char sipNm_py_sems_lib_disconnectSession[];
extern char sipNm_py_sems_lib_connectSession[];
extern char sipNm_py_sems_lib_connectCallee[];
extern char sipNm_py_sems_lib_PySemsB2ABDialog[];
extern char sipNm_py_sems_lib_waitReleased[];
extern char sipNm_py_sems_lib_release[];
extern char sipNm_py_sems_lib_block[];
extern char sipNm_py_sems_lib_AmSessionAudioConnector[];
extern char sipNm_py_sems_lib_PySemsB2BDialog[];
extern char sipNm_py_sems_lib_process[];
extern char sipNm_py_sems_lib_setInOut[];
@ -184,7 +189,6 @@ extern char sipNm_py_sems_lib_reason[];
extern char sipNm_py_sems_lib_code[];
extern char sipNm_py_sems_lib_AmSipReply[];
extern char sipNm_py_sems_lib_getHeader[];
extern char sipNm_py_sems_lib_key[];
extern char sipNm_py_sems_lib_next_hop[];
extern char sipNm_py_sems_lib_route[];
extern char sipNm_py_sems_lib_body[];

@ -1,7 +1,7 @@
/*
* Interface wrapper code.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#include "sipAPIpy_sems_lib.h"
@ -126,7 +126,7 @@ static void *forceConvertTo_AmAudioEvent(PyObject *valobj,int *iserrp)
/* Define this type's super-types. */
static sipEncodedClassDef supers_AmAudioEvent[] = {{7, 255, 1}};
static sipEncodedClassDef supers_AmAudioEvent[] = {{8, 255, 1}};
static sipEnumMemberDef enummembers_AmAudioEvent[] = {
{sipNm_py_sems_lib_cleared, AmAudioEvent::cleared, 1},

@ -1,7 +1,7 @@
/*
* Interface header file.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#ifndef _py_sems_libAmAudioEvent_h
@ -11,7 +11,7 @@
#include "../../../core/AmAudio.h"
#line 13 "sippy_sems_libAmAudioEvent.h"
#define sipClass_AmAudioEvent sipModuleAPI_py_sems_lib.em_types[8]
#define sipClass_AmAudioEvent sipModuleAPI_py_sems_lib.em_types[9]
#define sipCast_AmAudioEvent sipType_py_sems_lib_AmAudioEvent.td_cast
#define sipForceConvertTo_AmAudioEvent sipType_py_sems_lib_AmAudioEvent.td_fcto

@ -1,7 +1,7 @@
/*
* Interface wrapper code.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#include "sipAPIpy_sems_lib.h"

@ -1,7 +1,7 @@
/*
* Interface header file.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#ifndef _py_sems_libAmAudioFile_h
@ -11,7 +11,7 @@
#include "../../../core/AmAudioFile.h"
#line 13 "sippy_sems_libAmAudioFile.h"
#define sipClass_AmAudioFile sipModuleAPI_py_sems_lib.em_types[6]
#define sipClass_AmAudioFile sipModuleAPI_py_sems_lib.em_types[7]
#define sipCast_AmAudioFile sipType_py_sems_lib_AmAudioFile.td_cast
#define sipForceConvertTo_AmAudioFile sipType_py_sems_lib_AmAudioFile.td_fcto

@ -1,13 +1,14 @@
/*
* Interface wrapper code.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#include "sipAPIpy_sems_lib.h"
#include "sippy_sems_libAmB2ABCalleeSession.h"
#include "sippy_sems_libstring.h"
#include "sippy_sems_libAmSessionAudioConnector.h"
#include "sippy_sems_libAmB2ABCalleeSession.h"
#include "sippy_sems_libAmAudioFile.h"
@ -189,10 +190,11 @@ static void *init_AmB2ABCalleeSession(sipWrapper *,PyObject *sipArgs,sipWrapper
{
const string * a0;
int a0State = 0;
AmSessionAudioConnector * a1;
if (sipParseArgs(sipArgsParsed,sipArgs,"M1",sipMappedType_string,&a0,&a0State))
if (sipParseArgs(sipArgsParsed,sipArgs,"M1J@",sipMappedType_string,&a0,&a0State,sipClass_AmSessionAudioConnector,&a1))
{
sipCpp = new AmB2ABCalleeSession(*a0);
sipCpp = new AmB2ABCalleeSession(*a0,a1);
sipReleaseMappedType(const_cast<string *>(a0),sipMappedType_string,a0State);
}

@ -1,13 +1,13 @@
/*
* Interface header file.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#ifndef _py_sems_libAmB2ABCalleeSession_h
#define _py_sems_libAmB2ABCalleeSession_h
#line 62 "PySemsB2ABDialog.sip"
#line 81 "PySemsB2ABDialog.sip"
#include "../../../core/AmB2ABSession.h"
#line 13 "sippy_sems_libAmB2ABCalleeSession.h"

@ -1,7 +1,7 @@
/*
* Interface wrapper code.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#include "sipAPIpy_sems_lib.h"

@ -1,7 +1,7 @@
/*
* Interface header file.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#ifndef _py_sems_libAmEvent_h
@ -11,7 +11,7 @@
#include "../../../core/AmEvent.h"
#line 13 "sippy_sems_libAmEvent.h"
#define sipClass_AmEvent sipModuleAPI_py_sems_lib.em_types[7]
#define sipClass_AmEvent sipModuleAPI_py_sems_lib.em_types[8]
#define sipCast_AmEvent sipType_py_sems_lib_AmEvent.td_cast
#define sipForceConvertTo_AmEvent sipType_py_sems_lib_AmEvent.td_fcto

@ -1,7 +1,7 @@
/*
* Interface wrapper code.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#include "sipAPIpy_sems_lib.h"

@ -1,7 +1,7 @@
/*
* Interface header file.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#ifndef _py_sems_libAmSipDialog_h
@ -11,7 +11,7 @@
#include "../../../core/AmSipDialog.h"
#line 13 "sippy_sems_libAmSipDialog.h"
#define sipClass_AmSipDialog sipModuleAPI_py_sems_lib.em_types[9]
#define sipClass_AmSipDialog sipModuleAPI_py_sems_lib.em_types[10]
#define sipCast_AmSipDialog sipType_py_sems_lib_AmSipDialog.td_cast
#define sipForceConvertTo_AmSipDialog sipType_py_sems_lib_AmSipDialog.td_fcto

@ -1,7 +1,7 @@
/*
* Interface wrapper code.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#include "sipAPIpy_sems_lib.h"

@ -1,7 +1,7 @@
/*
* Interface header file.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#ifndef _py_sems_libAmSipReply_h
@ -11,7 +11,7 @@
#include "../../../core/AmSipMsg.h"
#line 13 "sippy_sems_libAmSipReply.h"
#define sipClass_AmSipReply sipModuleAPI_py_sems_lib.em_types[10]
#define sipClass_AmSipReply sipModuleAPI_py_sems_lib.em_types[11]
#define sipCast_AmSipReply sipType_py_sems_lib_AmSipReply.td_cast
#define sipForceConvertTo_AmSipReply sipType_py_sems_lib_AmSipReply.td_fcto

@ -1,7 +1,7 @@
/*
* Interface wrapper code.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#include "sipAPIpy_sems_lib.h"
@ -70,6 +70,7 @@ static void *init_AmSipRequest(sipWrapper *,PyObject *sipArgs,sipWrapper **,int
return sipCpp;
}
extern "C" {static PyObject *var_AmSipRequest_next_hop(PyObject *, PyObject *);}
static PyObject *var_AmSipRequest_next_hop(PyObject *sipSelf,PyObject *sipPy)
{

@ -1,7 +1,7 @@
/*
* Interface header file.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#ifndef _py_sems_libAmSipRequest_h
@ -11,7 +11,7 @@
#include "../../../core/AmSipMsg.h"
#line 13 "sippy_sems_libAmSipRequest.h"
#define sipClass_AmSipRequest sipModuleAPI_py_sems_lib.em_types[11]
#define sipClass_AmSipRequest sipModuleAPI_py_sems_lib.em_types[12]
#define sipCast_AmSipRequest sipType_py_sems_lib_AmSipRequest.td_cast
#define sipForceConvertTo_AmSipRequest sipType_py_sems_lib_AmSipRequest.td_fcto

@ -1,7 +1,7 @@
/*
* Interface wrapper code.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#include "sipAPIpy_sems_lib.h"
@ -9,14 +9,15 @@
#include "sippy_sems_libAmB2ABCalleeSession.h"
#include "sippy_sems_libstring.h"
#include "sippy_sems_libAmSessionAudioConnector.h"
#include "sippy_sems_libPySemsB2ABCalleeDialog.h"
#include "sippy_sems_libPySemsB2ABEvent.h"
#include "sippy_sems_libAmAudioFile.h"
sipPySemsB2ABCalleeDialog::sipPySemsB2ABCalleeDialog(const string& a0): PySemsB2ABCalleeDialog(a0), sipPySelf(0)
sipPySemsB2ABCalleeDialog::sipPySemsB2ABCalleeDialog(const string& a0,AmSessionAudioConnector *a1): PySemsB2ABCalleeDialog(a0,a1), sipPySelf(0)
{
sipTrace(SIP_TRACE_CTORS,"sipPySemsB2ABCalleeDialog::sipPySemsB2ABCalleeDialog(const string&) (this=0x%08x)\n",this);
sipTrace(SIP_TRACE_CTORS,"sipPySemsB2ABCalleeDialog::sipPySemsB2ABCalleeDialog(const string&,AmSessionAudioConnector *) (this=0x%08x)\n",this);
sipCommonCtor(sipPyMethods,1);
}
@ -135,10 +136,11 @@ static void *init_PySemsB2ABCalleeDialog(sipWrapper *sipSelf,PyObject *sipArgs,s
{
const string * a0;
int a0State = 0;
AmSessionAudioConnector * a1;
if (sipParseArgs(sipArgsParsed,sipArgs,"M1",sipMappedType_string,&a0,&a0State))
if (sipParseArgs(sipArgsParsed,sipArgs,"M1J@",sipMappedType_string,&a0,&a0State,sipClass_AmSessionAudioConnector,&a1))
{
sipCpp = new sipPySemsB2ABCalleeDialog(*a0);
sipCpp = new sipPySemsB2ABCalleeDialog(*a0,a1);
sipReleaseMappedType(const_cast<string *>(a0),sipMappedType_string,a0State);
}

@ -1,13 +1,13 @@
/*
* Interface header file.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#ifndef _py_sems_libPySemsB2ABCalleeDialog_h
#define _py_sems_libPySemsB2ABCalleeDialog_h
#line 82 "PySemsB2ABDialog.sip"
#line 101 "PySemsB2ABDialog.sip"
#include "../PySemsB2ABDialog.h"
#include "../../../core/AmB2ABSession.h"
#line 14 "sippy_sems_libPySemsB2ABCalleeDialog.h"
@ -22,7 +22,7 @@ extern sipTypeDef sipType_py_sems_lib_PySemsB2ABCalleeDialog;
class sipPySemsB2ABCalleeDialog : public PySemsB2ABCalleeDialog
{
public:
sipPySemsB2ABCalleeDialog(const string&);
sipPySemsB2ABCalleeDialog(const string&,AmSessionAudioConnector *);
virtual ~sipPySemsB2ABCalleeDialog();
/*

@ -1,7 +1,7 @@
/*
* Interface wrapper code.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#include "sipAPIpy_sems_lib.h"
@ -770,7 +770,7 @@ static void dealloc_PySemsB2ABDialog(sipWrapper *sipSelf)
if (sipIsPyOwned(sipSelf))
{
#line 17 "PySemsB2ABDialog.sip"
#line 36 "PySemsB2ABDialog.sip"
fprintf(stderr,"------------- dealloc_PySemsB2ABDialog ----------\n");
#line 776 "sippy_sems_libPySemsB2ABDialog.cpp"

@ -1,13 +1,13 @@
/*
* Interface header file.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#ifndef _py_sems_libPySemsB2ABDialog_h
#define _py_sems_libPySemsB2ABDialog_h
#line 5 "PySemsB2ABDialog.sip"
#line 24 "PySemsB2ABDialog.sip"
#include "../PySemsB2ABDialog.h"
#include "../../../core/AmB2ABSession.h"
#line 14 "sippy_sems_libPySemsB2ABDialog.h"

@ -1,7 +1,7 @@
/*
* Interface wrapper code.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#include "sipAPIpy_sems_lib.h"

@ -1,13 +1,13 @@
/*
* Interface header file.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#ifndef _py_sems_libPySemsB2ABEvent_h
#define _py_sems_libPySemsB2ABEvent_h
#line 98 "PySemsB2ABDialog.sip"
#line 117 "PySemsB2ABDialog.sip"
#include "../PySemsB2ABDialog.h"
#line 13 "sippy_sems_libPySemsB2ABEvent.h"

@ -1,7 +1,7 @@
/*
* Interface wrapper code.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#include "sipAPIpy_sems_lib.h"

@ -1,7 +1,7 @@
/*
* Interface header file.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#ifndef _py_sems_libPySemsB2BDialog_h
@ -11,7 +11,7 @@
#include "../PySemsB2BDialog.h"
#line 13 "sippy_sems_libPySemsB2BDialog.h"
#define sipClass_PySemsB2BDialog sipModuleAPI_py_sems_lib.em_types[4]
#define sipClass_PySemsB2BDialog sipModuleAPI_py_sems_lib.em_types[5]
#define sipCast_PySemsB2BDialog sipType_py_sems_lib_PySemsB2BDialog.td_cast
#define sipForceConvertTo_PySemsB2BDialog sipType_py_sems_lib_PySemsB2BDialog.td_fcto

@ -1,7 +1,7 @@
/*
* Interface wrapper code.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#include "sipAPIpy_sems_lib.h"

@ -1,7 +1,7 @@
/*
* Interface header file.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#ifndef _py_sems_libPySemsDialog_h
@ -11,7 +11,7 @@
#include "../PySemsDialog.h"
#line 13 "sippy_sems_libPySemsDialog.h"
#define sipClass_PySemsDialog sipModuleAPI_py_sems_lib.em_types[5]
#define sipClass_PySemsDialog sipModuleAPI_py_sems_lib.em_types[6]
#define sipCast_PySemsDialog sipType_py_sems_lib_PySemsDialog.td_cast
#define sipForceConvertTo_PySemsDialog sipType_py_sems_lib_PySemsDialog.td_fcto

@ -1,7 +1,7 @@
/*
* Module code.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#include "sipAPIpy_sems_lib.h"
@ -10,6 +10,7 @@
#include "sippy_sems_libPySemsB2ABCalleeDialog.h"
#include "sippy_sems_libAmB2ABCalleeSession.h"
#include "sippy_sems_libPySemsB2ABDialog.h"
#include "sippy_sems_libAmSessionAudioConnector.h"
#include "sippy_sems_libPySemsB2BDialog.h"
#include "sippy_sems_libPySemsDialog.h"
#include "sippy_sems_libAmAudioFile.h"
@ -35,6 +36,10 @@ char sipNm_py_sems_lib_disconnectSession[] = "disconnectSession";
char sipNm_py_sems_lib_connectSession[] = "connectSession";
char sipNm_py_sems_lib_connectCallee[] = "connectCallee";
char sipNm_py_sems_lib_PySemsB2ABDialog[] = "PySemsB2ABDialog";
char sipNm_py_sems_lib_waitReleased[] = "waitReleased";
char sipNm_py_sems_lib_release[] = "release";
char sipNm_py_sems_lib_block[] = "block";
char sipNm_py_sems_lib_AmSessionAudioConnector[] = "AmSessionAudioConnector";
char sipNm_py_sems_lib_PySemsB2BDialog[] = "PySemsB2BDialog";
char sipNm_py_sems_lib_process[] = "process";
char sipNm_py_sems_lib_setInOut[] = "setInOut";
@ -95,7 +100,6 @@ char sipNm_py_sems_lib_reason[] = "reason";
char sipNm_py_sems_lib_code[] = "code";
char sipNm_py_sems_lib_AmSipReply[] = "AmSipReply";
char sipNm_py_sems_lib_getHeader[] = "getHeader";
char sipNm_py_sems_lib_key[] = "key";
char sipNm_py_sems_lib_next_hop[] = "next_hop";
char sipNm_py_sems_lib_route[] = "route";
char sipNm_py_sems_lib_body[] = "body";
@ -306,7 +310,7 @@ static sipWrapperType *sipSubClass_AmEvent(void **sipCppRet)
else {
sipClass = sipClass_AmEvent;
}
#line 310 "sippy_sems_libcmodule.cpp"
#line 314 "sippy_sems_libcmodule.cpp"
return sipClass;
}
@ -321,6 +325,7 @@ static sipWrapperType *typesTable[] = {
(sipWrapperType *)(void *)&sipType_py_sems_lib_AmB2ABCalleeSession,
(sipWrapperType *)(void *)&sipType_py_sems_lib_PySemsB2ABCalleeDialog,
(sipWrapperType *)(void *)&sipType_py_sems_lib_PySemsB2ABDialog,
(sipWrapperType *)(void *)&sipType_py_sems_lib_AmSessionAudioConnector,
(sipWrapperType *)(void *)&sipType_py_sems_lib_PySemsB2BDialog,
(sipWrapperType *)(void *)&sipType_py_sems_lib_PySemsDialog,
(sipWrapperType *)(void *)&sipType_py_sems_lib_AmAudioFile,
@ -341,9 +346,9 @@ static sipMappedType *mappedTypesTable[] = {
/* Define each named enum in this module. */
static sipEnumDef enumTypesTable[] = {
{"py_sems_lib.AmAudioFile.OpenMode", NULL, 6, NULL},
{"py_sems_lib.AmAudioEvent.EventType", NULL, 8, NULL},
{"py_sems_lib.AmSipDialog.Status", NULL, 9, NULL},
{"py_sems_lib.AmAudioFile.OpenMode", NULL, 7, NULL},
{"py_sems_lib.AmAudioEvent.EventType", NULL, 9, NULL},
{"py_sems_lib.AmSipDialog.Status", NULL, 10, NULL},
};
@ -363,7 +368,7 @@ static sipVirtHandlerFunc virtHandlersTable[] = {
/* This defines the class sub-convertors that this module defines. */
static sipSubClassConvertorDef convertorsTable[] = {
{sipSubClass_AmEvent, {7, 255, 0}, NULL},
{sipSubClass_AmEvent, {8, 255, 0}, NULL},
{NULL, {0, 0, 0}, NULL}
};
@ -377,7 +382,7 @@ sipExportedModuleDef sipModuleAPI_py_sems_lib = {
0,
NULL,
NULL,
12,
13,
typesTable,
NULL,
mappedTypesTable,

@ -1,7 +1,7 @@
/*
* Interface wrapper code.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#include "sipAPIpy_sems_lib.h"

@ -1,7 +1,7 @@
/*
* Interface header file.
*
* Generated by SIP 4.5.2 (4.5.2) on Tue Oct 16 13:58:18 2007
* Generated by SIP 4.5.2 (4.5.2) on Mon Dec 8 15:20:56 2008
*/
#ifndef _py_sems_libstring_h

@ -33,15 +33,13 @@
#include <assert.h>
AmB2ABSession::AmB2ABSession()
: AmSession(),
connector(NULL)
: AmSession(), connector(NULL)
{
}
AmB2ABSession::AmB2ABSession(const string& other_local_tag)
: other_id(other_local_tag),
AmSession(),
connector(NULL)
AmSession()
{}
@ -91,22 +89,20 @@ void AmB2ABSession::relayEvent(AmEvent* ev)
void AmB2ABSession::connectSession()
{
if (!connector)
return;
connector->connectSession(this);
AmMediaProcessor::instance()->addSession(this, callgroup);
if (!connector) {
DBG("error - trying to connect session, but no connector!\n");
return;
}
connector->connectSession(this);
AmMediaProcessor::instance()->addSession(this, callgroup);
}
void AmB2ABSession::disconnectSession()
{
if (!connector)
return;
if (!connector->disconnectSession(this)){
delete connector;
connector = NULL;
}
if (!connector)
return;
connector->disconnectSession(this);
}
void AmB2ABSession::onBye(const AmSipRequest& req) {
@ -132,14 +128,26 @@ AmB2ABCallerSession::AmB2ABCallerSession()
: AmB2ABSession(),
callee_status(None)
{
// owned by us
connector = new AmSessionAudioConnector();
}
AmB2ABCallerSession::~AmB2ABCallerSession()
{ }
{
delete connector;
}
void AmB2ABCallerSession::onBeforeDestroy() {
DBG("Waiting for release from callee session...\n");
connector->waitReleased();
DBG("OK, got release from callee session.\n");
}
void AmB2ABCallerSession::terminateOtherLeg()
{
if (callee_status != None)
AmB2ABSession::terminateOtherLeg();
callee_status = None;
}
@ -151,10 +159,25 @@ void AmB2ABCallerSession::onB2ABEvent(B2ABEvent* ev)
callee_status = Connected;
DBG("ConnectAudio event received from other leg\n");
B2ABConnectAudioEvent* ca = dynamic_cast<B2ABConnectAudioEvent*>(ev);
assert(ca);
B2ABConnectAudioEvent* ca =
dynamic_cast<B2ABConnectAudioEvent*>(ev);
if (!ca)
return;
connectSession();
return;
} break;
case B2ABConnectEarlyAudio: {
callee_status = Early;
DBG("ConnectEarlyAudio event received from other leg\n");
B2ABConnectEarlyAudioEvent* ca =
dynamic_cast<B2ABConnectEarlyAudioEvent*>(ev);
if (!ca)
return;
connector = ca->connector;
connectSession();
return;
@ -190,8 +213,8 @@ void AmB2ABCallerSession::connectCallee(const string& remote_party,
B2ABConnectLegEvent* ev = new B2ABConnectLegEvent(remote_party,remote_uri,
local_party,local_uri,
getLocalTag(),
headers);
getLocalTag(), // callgroup
headers); // extra headers
relayEvent(ev);
callee_status = NoReply;
@ -228,15 +251,28 @@ void AmB2ABCallerSession::setupCalleeSession(AmB2ABCalleeSession* callee_session
AmB2ABCalleeSession* AmB2ABCallerSession::createCalleeSession()
{
return new AmB2ABCalleeSession(getLocalTag());
return new AmB2ABCalleeSession(getLocalTag(), connector);
}
AmB2ABCalleeSession::AmB2ABCalleeSession(const string& other_local_tag)
: AmB2ABSession(other_local_tag)
{ }
AmB2ABCalleeSession::AmB2ABCalleeSession(const string& other_local_tag,
AmSessionAudioConnector* callers_connector)
: AmB2ABSession(other_local_tag),
is_connected(false)
{
connector=callers_connector;
connector->block();
}
AmB2ABCalleeSession::~AmB2ABCalleeSession()
{ }
{
}
void AmB2ABCalleeSession::onBeforeDestroy() {
DBG("releasing caller session.\n");
connector->release();
// now caller session is released
}
void AmB2ABCalleeSession::onB2ABEvent(B2ABEvent* ev)
{
@ -251,11 +287,11 @@ void AmB2ABCalleeSession::onB2ABEvent(B2ABEvent* ev)
dlg.remote_party = co_ev->remote_party;
dlg.remote_uri = co_ev->remote_uri;
// set outbound proxy as next hop
if (!AmConfig::OutboundProxy.empty())
dlg.next_hop = AmConfig::OutboundProxy;
dlg.next_hop = AmConfig::OutboundProxy;
setCallgroup(co_ev->callgroup);
setNegotiateOnReply(true);
@ -284,12 +320,22 @@ void AmB2ABCalleeSession::onB2ABEvent(B2ABEvent* ev)
AmB2ABSession::onB2ABEvent(ev);
}
void AmB2ABCalleeSession::onEarlySessionStart(const AmSipReply& rep) {
DBG("onEarlySessionStart of callee session\n");
connectSession();
is_connected = true;
relayEvent(new B2ABConnectEarlyAudioEvent());
}
void AmB2ABCalleeSession::onSessionStart(const AmSipReply& rep) {
DBG("onSessionStart of callee session\n");
// connect our audio
connector = new AmSessionAudioConnector();
connectSession();
relayEvent(new B2ABConnectAudioEvent(connector));
if (!is_connected) {
is_connected = true;
DBG("call connectSession\n");
connectSession();
}
relayEvent(new B2ABConnectAudioEvent());
}
void AmB2ABCalleeSession::onSipReply(const AmSipReply& rep) {
@ -308,7 +354,6 @@ void AmB2ABCalleeSession::onSipReply(const AmSipReply& rep) {
}
}
// ----------------------- SessionAudioConnector -----------------
void AmSessionAudioConnector::connectSession(AmSession* sess)
@ -317,14 +362,24 @@ void AmSessionAudioConnector::connectSession(AmSession* sess)
tag_mut.lock();
if(!connected[0]){
if (connected[0] && tag_sess[0] == tag) {
// re-connect to position 0
sess->setInOut(&audio_connectors[0],&audio_connectors[1]);
} else if (connected[1] && tag_sess[1] == tag) {
// re-connect to position 1
sess->setInOut(&audio_connectors[1],&audio_connectors[0]);
} else if(!connected[0]){
// connect to empty position 0
connected[0] = true;
tag_sess[0] = tag;
tag_sess[0] = "";
tag_sess[0].append(tag);
sess->setInOut(&audio_connectors[0],&audio_connectors[1]);
}
else if(!connected[1]){
// connect to empty position 1
connected[1] = true;
tag_sess[1] = tag;
tag_sess[1] = "";
tag_sess[1].append(tag);
sess->setInOut(&audio_connectors[1],&audio_connectors[0]);
}
else {
@ -341,27 +396,42 @@ bool AmSessionAudioConnector::disconnectSession(AmSession* sess)
const string& tag = sess->getLocalTag();
tag_mut.lock();
if (tag_sess[0] == tag) {
if (connected[0] && (tag_sess[0] == tag)) {
tag_sess[0].clear();
connected[0] = false;
sess->setInOut(NULL, NULL);
res = connected[1];
} else if (tag_sess[1] == tag) {
} else if (connected[1] && (tag_sess[1] == tag)) {
tag_sess[1].clear();
connected[1] = false;
sess->setInOut(NULL, NULL);
res = connected[0];
} else {
ERROR("disconnecting from wrong AmSessionAudioConnector\n");
DBG("disconnecting from wrong AmSessionAudioConnector\n");
}
tag_mut.unlock();
return res;
}
/* mark as in use by not owning entity */
void AmSessionAudioConnector::block() {
released.set(false);
}
/* mark as released by not owning entity */
void AmSessionAudioConnector::release() {
released.set(true);
}
/* wait until released */
void AmSessionAudioConnector::waitReleased() {
released.wait_for();
}
// ----------------------- AudioDelayBridge -----------------
/** BRIDGE_DELAY is needed because of possible different packet sizes */
#define BRIDGE_DELAY 30 * SYSTEM_SAMPLERATE/1000 // 30ms
#define BRIDGE_DELAY 30 * SYSTEM_SAMPLERATE/1000 // 30ms
/* AudioBridge */
AmAudioDelayBridge::AmAudioDelayBridge()
@ -384,3 +454,5 @@ int AmAudioDelayBridge::read(unsigned int user_ts, unsigned int size) {
sarr.read(user_ts, (short*) ((unsigned char*) samples), size >> 1);
return size;
}

@ -24,9 +24,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/** @file AmB2ABSession.h */
#ifndef B2ABSession_H
#define B2ABSession_H
#ifndef _AM_B2ABSession_H
#define _AM_B2ABSession_H
#include "AmSession.h"
#include "AmSipDialog.h"
@ -35,11 +34,13 @@
#include <string>
using std::string;
class AmAudioDelayBridge;
#include <map>
class AmSessionAudioConnector;
enum { B2ABTerminateLeg,
B2ABConnectLeg,
B2ABConnectEarlyAudio,
B2ABConnectAudio,
B2ABConnectOtherLegFailed,
B2ABConnectOtherLegException,
@ -54,7 +55,6 @@ struct B2ABEvent: public AmEvent
{}
};
/** \brief event fired if B leg is ringing in b2ab session */
struct B2ABOtherLegRingingEvent: public B2ABEvent
{
B2ABOtherLegRingingEvent()
@ -65,12 +65,16 @@ struct B2ABOtherLegRingingEvent: public B2ABEvent
/** \brief trigger connecting the audio in B2AB session */
struct B2ABConnectAudioEvent: public B2ABEvent
{
AmSessionAudioConnector* connector;
bool first;
B2ABConnectAudioEvent()
: B2ABEvent(B2ABConnectAudio)
{}
};
B2ABConnectAudioEvent(AmSessionAudioConnector* connector)
: B2ABEvent(B2ABConnectAudio),
connector(connector)
/** \brief trigger connecting the audio in B2AB session */
struct B2ABConnectEarlyAudioEvent: public B2ABEvent
{
B2ABConnectEarlyAudioEvent()
: B2ABEvent(B2ABConnectEarlyAudio)
{}
};
@ -83,13 +87,13 @@ struct B2ABConnectLegEvent: public B2ABEvent
string local_uri;
string callgroup;
string headers;
B2ABConnectLegEvent(const string& remote_party,
const string& remote_uri,
const string& local_party,
const string& local_uri,
const string& callgroup,
const string& headers)
const string& headers = "")
: B2ABEvent(B2ABConnectLeg),
remote_party(remote_party),
remote_uri(remote_uri),
@ -135,8 +139,12 @@ class AmB2ABSession: public AmSession
{
protected:
/** local tag of the other leg */
string other_id;
/** reference to the audio connector - caution: not owned by callee dialog! */
AmSessionAudioConnector* connector;
/** Requests received for relaying */
std::map<int,AmSipRequest> recvd_req;
@ -165,9 +173,6 @@ class AmB2ABSession: public AmSession
/** @see AmEventQueue */
void process(AmEvent* event);
/** reference to the audio connector - caution: you may not delete this! */
AmSessionAudioConnector* connector;
public:
AmB2ABSession();
@ -177,7 +182,7 @@ class AmB2ABSession: public AmSession
void onBye(const AmSipRequest& req);
/** connect audio stream to the other session */
void connectSession();
virtual void connectSession();
/** reverse operation of connectSession */
void disconnectSession();
@ -193,6 +198,7 @@ class AmB2ABCallerSession: public AmB2ABSession
enum CalleeStatus {
None=0,
NoReply,
Early,
Ringing,
Connected
};
@ -205,6 +211,7 @@ class AmB2ABCallerSession: public AmB2ABSession
B2ABConnectLegEvent* ev);
protected:
virtual AmB2ABCalleeSession* createCalleeSession();
void relayEvent(AmEvent* ev);
@ -218,29 +225,38 @@ class AmB2ABCallerSession: public AmB2ABSession
const string& remote_uri,
const string& local_party,
const string& local_uri,
const string& headers="");
const string& headers = "");
// @see AmB2ABSession
void terminateOtherLeg();
protected:
void onB2ABEvent(B2ABEvent* ev);
void onBeforeDestroy();
};
/** \brief Callee leg of a B2AB session */
class AmB2ABCalleeSession: public AmB2ABSession
{
bool is_connected;
public:
AmB2ABCalleeSession(const string& other_local_tag);
AmB2ABCalleeSession(const string& other_local_tag,
AmSessionAudioConnector* callers_connector);
~AmB2ABCalleeSession();
void onEarlySessionStart(const AmSipReply& rep);
void onSessionStart(const AmSipReply& rep);
void onSipReply(const AmSipReply& rep);
protected:
void onB2ABEvent(B2ABEvent* ev);
void onBeforeDestroy();
AmCondition<bool>* released;
};
/**
* \brief \ref AmAudio that connects input and output with delay
*
@ -267,10 +283,13 @@ class AmSessionAudioConnector {
string tag_sess[2];
bool connected[2];
AmMutex tag_mut;
AmCondition<bool> released;
public:
/** create a connector, connect audio to sess */
AmSessionAudioConnector() {
AmSessionAudioConnector()
: released(true) {
connected[0] = false;
connected[1] = false;
}
@ -284,8 +303,20 @@ class AmSessionAudioConnector {
* @return whether connector is still connected after disconnect
*/
bool disconnectSession(AmSession* sess);
};
/** mark as in use by entity not owning it */
void block();
/** mark as released by entity not owning it */
void release();
/** wait until released by everyone */
void waitReleased();
};
#endif
// Local Variables:
// mode:C++
// End:

Loading…
Cancel
Save