fix indenting

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1176 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 18 years ago
parent 4144682f21
commit 09287e2a99

@ -40,32 +40,32 @@ EXPORT_SESSION_FACTORY(JukecallFactory,MOD_NAME);
#define JUKE_DIR "../apps/examples/jukecall/wav/"
JukecallFactory::JukecallFactory(const string& _app_name)
: AmSessionFactory(_app_name)
: AmSessionFactory(_app_name)
{
}
int JukecallFactory::onLoad()
{
// read configuration
// read configuration
DBG("JukecallFactory loaded.\n");
return 0;
DBG("JukecallFactory loaded.\n");
return 0;
}
AmSession* JukecallFactory::onInvite(const AmSipRequest& req)
{
if (req.user.length() <= 3) {
throw AmSession::Exception(403, "Need a number to call");
}
if (req.user.length() <= 3) {
throw AmSession::Exception(403, "Need a number to call");
}
JukecallSession* dlg = new JukecallSession();
JukecallSession* dlg = new JukecallSession();
return dlg;
return dlg;
}
JukecallSession::JukecallSession()
: AmB2ABCallerSession()
: AmB2ABCallerSession()
{
}
@ -75,116 +75,116 @@ JukecallSession::~JukecallSession()
void JukecallSession::onSessionStart(const AmSipRequest& req)
{
if (dlg.getStatus()==AmSipDialog::Connected) {
// reinvite
AmB2ABCallerSession::onSessionStart(req);
return;
}
if (dlg.getStatus()==AmSipDialog::Connected) {
// reinvite
AmB2ABCallerSession::onSessionStart(req);
return;
}
DBG("-----------------------------------------------------------------\n");
DBG("playing file\n");
DBG("-----------------------------------------------------------------\n");
DBG("playing file\n");
if(initial_announcement.open(INITIAL_ANNOUNCEMENT,AmAudioFile::Read)) {
dlg.bye();
throw string("CTConfDDialog::onSessionStart: Cannot open file '%s'\n", INITIAL_ANNOUNCEMENT);
}
if(initial_announcement.open(INITIAL_ANNOUNCEMENT,AmAudioFile::Read)) {
dlg.bye();
throw string("CTConfDDialog::onSessionStart: Cannot open file '%s'\n", INITIAL_ANNOUNCEMENT);
}
// set this as our output
setOutput(&initial_announcement);
// set this as our output
setOutput(&initial_announcement);
state = JC_initial_announcement;
state = JC_initial_announcement;
}
void JukecallSession::onDtmf(int event, int duration_msec) {
DBG("got DTMF %d\n", event);
DBG("got DTMF %d\n", event);
// no jukebox if other party is not connected
if (getCalleeStatus()!=AmB2ABCallerSession::Connected)
return;
// no jukebox if other party is not connected
if (getCalleeStatus()!=AmB2ABCallerSession::Connected)
return;
// no jukebox in the beginning and while playing
if (state != JC_connect)
return;
// no jukebox in the beginning and while playing
if (state != JC_connect)
return;
DBG("playing back file...\n");
DBG("playing back file...\n");
song.reset(new AmAudioFile());
if (song->open(JUKE_DIR+int2str(event)+".wav",AmAudioFile::Read)) {
ERROR("could not open file\n");
return;
}
setOutput(song.get());
state = JC_juke;
song.reset(new AmAudioFile());
if (song->open(JUKE_DIR+int2str(event)+".wav",AmAudioFile::Read)) {
ERROR("could not open file\n");
return;
}
setOutput(song.get());
state = JC_juke;
relayEvent(new JukeEvent(event));
relayEvent(new JukeEvent(event));
}
void JukecallSession::process(AmEvent* event)
{
AmAudioEvent* audio_event = dynamic_cast<AmAudioEvent*>(event);
if(audio_event && (audio_event->event_id == AmAudioEvent::cleared)){
switch(state) {
case JC_initial_announcement: {
state = JC_connect;
string callee = "sip:" + dlg.user.substr(3) + "@" + dlg.domain;
DBG("-------------------------- connecting %s ------------------------\n", callee.c_str());
connectCallee(callee, callee,
dlg.remote_party, dlg.remote_uri);
return;
} break;
case JC_juke: {
DBG("reconnecting audio\n");
connectSession();
state = JC_connect;
return;
}; break;
default: {
DBG("cleared in other state.\n");
return;
};
}
AmAudioEvent* audio_event = dynamic_cast<AmAudioEvent*>(event);
if(audio_event && (audio_event->event_id == AmAudioEvent::cleared)){
switch(state) {
case JC_initial_announcement: {
state = JC_connect;
string callee = "sip:" + dlg.user.substr(3) + "@" + dlg.domain;
DBG("-------------------------- connecting %s ------------------------\n", callee.c_str());
connectCallee(callee, callee,
dlg.remote_party, dlg.remote_uri);
return;
} break;
case JC_juke: {
DBG("reconnecting audio\n");
connectSession();
state = JC_connect;
return;
}; break;
default: {
DBG("cleared in other state.\n");
return;
};
}
}
AmB2ABCallerSession::process(event);
AmB2ABCallerSession::process(event);
}
AmB2ABCalleeSession* JukecallSession::createCalleeSession() {
AmB2ABCalleeSession* sess = new JukecalleeSession(getLocalTag(), connector);
return sess;
return sess;
}
JukecalleeSession::JukecalleeSession(const string& other_tag,
AmSessionAudioConnector* connector)
: AmB2ABCalleeSession(other_tag, connector)
{
setDtmfDetectionEnabled(false);
setDtmfDetectionEnabled(false);
}
void JukecalleeSession::process(AmEvent* event) {
JukeEvent* juke_event = dynamic_cast<JukeEvent*>(event);
if(juke_event) {
song.reset(new AmAudioFile());
if (song->open(JUKE_DIR+int2str(event->event_id)+".wav",AmAudioFile::Read)) {
ERROR("could not open file\n");
return;
}
setOutput(song.get());
return;
}
AmAudioEvent* audio_event = dynamic_cast<AmAudioEvent*>(event);
if(audio_event && (audio_event->event_id == AmAudioEvent::cleared)){
DBG("reconnecting audio\n");
connectSession();
return;
}
JukeEvent* juke_event = dynamic_cast<JukeEvent*>(event);
if(juke_event) {
song.reset(new AmAudioFile());
if (song->open(JUKE_DIR+int2str(event->event_id)+".wav",AmAudioFile::Read)) {
ERROR("could not open file\n");
return;
}
setOutput(song.get());
return;
}
AmAudioEvent* audio_event = dynamic_cast<AmAudioEvent*>(event);
if(audio_event && (audio_event->event_id == AmAudioEvent::cleared)){
DBG("reconnecting audio\n");
connectSession();
return;
}
AmB2ABCalleeSession::process(event);
AmB2ABCalleeSession::process(event);
}

@ -39,50 +39,50 @@ using std::string;
class JukecallFactory: public AmSessionFactory
{
public:
JukecallFactory(const string& _app_name);
JukecallFactory(const string& _app_name);
int onLoad();
int onLoad();
AmSession* onInvite(const AmSipRequest& req);
AmSession* onInvite(const AmSipRequest& req);
};
class JukecallSession
: public AmB2ABCallerSession
: public AmB2ABCallerSession
{
public:
enum JukeLeg1_state {
JC_initial_announcement = 0,
JC_connect,
JC_juke
};
enum JukeLeg1_state {
JC_initial_announcement = 0,
JC_connect,
JC_juke
};
private:
// our state
JukeLeg1_state state;
AmAudioFile initial_announcement;
// our state
JukeLeg1_state state;
AmAudioFile initial_announcement;
auto_ptr<AmAudioFile> song;
auto_ptr<AmAudioFile> song;
protected:
AmB2ABCalleeSession* createCalleeSession();
AmB2ABCalleeSession* createCalleeSession();
public:
JukecallSession();
~JukecallSession();
JukecallSession();
~JukecallSession();
void onSessionStart(const AmSipRequest& req);
void process(AmEvent* event);
void onSessionStart(const AmSipRequest& req);
void process(AmEvent* event);
void onDtmf(int event, int duration_msec);
void onDtmf(int event, int duration_msec);
};
class JukecalleeSession
: public AmB2ABCalleeSession {
: public AmB2ABCalleeSession {
void process(AmEvent* event);
auto_ptr<AmAudioFile> song;
void process(AmEvent* event);
auto_ptr<AmAudioFile> song;
public:
JukecalleeSession(const string& other_tag,
@ -91,8 +91,8 @@ public:
class JukeEvent : public AmEvent {
public:
JukeEvent(int key)
: AmEvent(key) {}
JukeEvent(int key)
: AmEvent(key) {}
};
#endif

Loading…
Cancel
Save