1 /*
2 * Copyright (C) 2006 ipteo GmbH
3 *
4 * This file is part of SEMS, a free SIP media server.
5 *
6 * SEMS is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * For a license to use the sems software under conditions
12 * other than those described here, or to purchase support for this
13 * software, please contact iptel.org by e-mail at the following addresses:
14 * info@iptel.org
15 *
16 * SEMS is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26 #ifndef _JUKECALL_H_
27 #define _JUKECALL_H_
28
29 #include "AmB2ABSession.h"
30 #include "AmConfigReader.h"
31 #include "AmAudioFile.h"
32 #include "AmApi.h"
33
34 #include <string>
35 using std::string;
36
37 class JukecallFactory: public AmSessionFactory
38 {
39 public:
JukecallFactory(const string & _app_name)40 JukecallFactory(const string& _app_name);
41
42 int onLoad();
43
44 AmSession* onInvite(const AmSipRequest& req, const string& app_name,
45 const map<string,string>& app_params);
onLoad()46 };
47
48 class JukecallSession
49 : public AmB2ABCallerSession
50 {
51
52 public:
53 enum JukeLeg1_state {
onInvite(const AmSipRequest & req,const string & app_name,const map<string,string> & app_params)54 JC_none = 0,
55 JC_initial_announcement,
56 JC_connect,
57 JC_juke
58 };
59
60 private:
61 // our state
62 JukeLeg1_state state;
63 AmAudioFile initial_announcement;
64
65 unique_ptr<AmAudioFile> song;
JukecallSession()66
67 protected:
68 AmB2ABCalleeSession* createCalleeSession();
69
70 public:
~JukecallSession()71
72 JukecallSession();
73 ~JukecallSession();
74
onSessionStart()75 void onSessionStart();
76 void process(AmEvent* event);
77
78 void onDtmf(int event, int duration_msec);
79 };
80
81 class JukecalleeSession
82 : public AmB2ABCalleeSession {
83
84 void process(AmEvent* event);
85 unique_ptr<AmAudioFile> song;
86
87 public:
88 JukecalleeSession(const string& other_tag,
89 AmSessionAudioConnector* connector);
90 };
91
92 class JukeEvent : public AmEvent {
93 public:
94 JukeEvent(int key)
95 : AmEvent(key) {}
96 };
97
98 #endif
onDtmf(int event,int duration_msec)99 // Local Variables:
100 // mode:C++
101 // End:
102
103