[server] / trunk / server / src / appwoomera.cxx Repository:
ViewVC logotype

Annotation of /trunk/server/src/appwoomera.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 74 - (view) (download)

1 : amartin 20 /*
2 :     * This file is part of the Dialogic Woomera Server project.
3 :     *
4 :     *
5 :     * Copyright (C) 2009 Dialogic Corporation
6 :     * All Rights Reserved
7 :     *
8 :     */
9 :    
10 :     /*!
11 : jtarlton 45 * \file appwoomera.cxx
12 : amartin 20 * \brief Woomera HMP server.
13 :     * \author John Tarlton <john.tarlton@dialogic.com>
14 :     * \author Antony Martin <antony.martin@dialogic.com>
15 :     * \version 0.1
16 :     */
17 :    
18 :    
19 :     /*----------------------------- Dependencies -------------------------------*/
20 :    
21 :     #include "logger.h"
22 : amartin 28 #include "getoption.h"
23 :     #include "dialogicmanager.h"
24 : amartin 20
25 :     #include <woomera.h>
26 :    
27 :     /*--------------------------------------------------------------------------*/
28 : amartin 66 DialogicManager* dm; //FIXME make singleton!
29 : amartin 20
30 :    
31 : jtarlton 54 /*
32 :     * ISDN protocol callback for Woomera messages.
33 : amartin 20 */
34 : jtarlton 54 woomera_server_response* protocol_message_handler( woomera_callctlr_command* msg,
35 :     void* prot_user_data )
36 : amartin 20 {
37 : jtarlton 54 switch ( msg->e )
38 :     {
39 :     case WOOMERA_CALLCTL_COMMAND_MAKE_CALL:
40 :     {
41 :     woomera_callctlr_command_make_call* callParms = &msg->m.make_call;
42 :     woomera_server_response* response = woomera_server_response_new(msg->connection_id);
43 : amartin 20
44 : jtarlton 54 // get number to dial
45 :     std::string remote_number;
46 :     if ( woomera_mime_includes(msg->common_mime, woomera_key_remote_url) != 0 )
47 :     {
48 :     remote_number = woomera_mime_get_string(msg->common_mime, woomera_key_remote_url);
49 :     }
50 :     else
51 :     {
52 :     remote_number = callParms->called_number;
53 :     }
54 : jtarlton 74 //FIXME CLI name and number + media
55 : amartin 66 dm->makeCall(msg->call_id, "1234", "local", remote_number);
56 : jtarlton 54
57 :     response->response = 200;
58 :     strcpy(response->args, "Call started");
59 :     return response;
60 :     }
61 :     break;
62 :    
63 :     case WOOMERA_CALLCTL_COMMAND_HANGUP_CALL:
64 :     {
65 :     // declare response
66 :     woomera_server_response* response = woomera_server_response_new(msg->connection_id);
67 : amartin 71 if ( !dm->hangup(msg->call_id) )
68 : jtarlton 54 {
69 :     response->response = 404;
70 :     strcpy(response->args, "Call not found");
71 :     }
72 : amartin 66 else
73 : jtarlton 54 {
74 :     response->response = 200;
75 :     strcpy(response->args, "Call cleared");
76 :     }
77 :     return response;
78 :     }
79 :     break;
80 :    
81 :     case WOOMERA_CALLCTL_COMMAND_ANSWER_CALL:
82 :     {
83 :     woomera_server_response * response = woomera_server_response_new(msg->connection_id);
84 : amartin 71 if ( !dm->answer(msg->call_id) )
85 : jtarlton 54 {
86 :     response->response = 404;
87 :     strcpy(response->args, "Call not found");
88 :     }
89 : amartin 66 else
90 : jtarlton 54 {
91 :     response->response = 200;
92 :     strcpy(response->args, "Call answered");
93 :     }
94 :     return response;
95 :     }
96 :     break;
97 :    
98 :     default:
99 :     break;
100 :     }
101 :     return 0;
102 : amartin 20 }
103 :    
104 :    
105 :     /*
106 : jtarlton 54 * ISDN protocol callback for Woomera media
107 : amartin 20 */
108 : jtarlton 54 int protocol_media_handler( void* user_data,
109 :     void* call_user_data,
110 :     const char* call_id,
111 :     unsigned session,
112 :     unsigned int cmd,
113 :     void* parm,
114 :     int parmlen )
115 : amartin 20 {
116 : jtarlton 54 switch ( cmd )
117 :     {
118 : amartin 55 case WOOMERA_MEDIA_CTL_READ_START:
119 : jtarlton 54 return 1;
120 :    
121 : amartin 55 case WOOMERA_MEDIA_CTL_READ_STOP:
122 : jtarlton 54 return 1;
123 :    
124 : amartin 55 case WOOMERA_MEDIA_CTL_READ:
125 : jtarlton 54 return 0;
126 :    
127 : amartin 55 case WOOMERA_MEDIA_CTL_WRITE_START:
128 : jtarlton 54 return 1;
129 :    
130 : amartin 55 case WOOMERA_MEDIA_CTL_WRITE_STOP:
131 : jtarlton 54 return 1;
132 :    
133 : amartin 55 case WOOMERA_MEDIA_CTL_WRITE:
134 : jtarlton 54 return 0;
135 :     }
136 : amartin 20 return 0;
137 :     }
138 :    
139 :    
140 : jtarlton 54
141 :    
142 : amartin 20 /*
143 :     * Protocol definition.
144 :     */
145 : jtarlton 54 static woomera_protocol_def isdn_protocol = {
146 : amartin 20 WOOMERA_PROTOCOL_READ_PUSH | WOOMERA_PROTOCOL_WRITE_PUSH,
147 : jtarlton 54 protocol_message_handler,
148 :     protocol_media_handler
149 : amartin 20 };
150 :    
151 :    
152 :     /*!
153 :     *
154 :     */
155 : amartin 21 void appwoomera_run(const GetOptions& opts)
156 : amartin 20 {
157 : amartin 21
158 :     LOGDEBUG("appwoomera_run()");
159 :    
160 :     /* Command line options
161 :     */
162 :     std::string opt_woomera_port = opts.getValue("woomera-port");
163 :     if ( opt_woomera_port.empty() )
164 :     {
165 :     opt_woomera_port = "42420";
166 :     }
167 :    
168 : amartin 28 /* intialise dialogic
169 :     */
170 : amartin 66 dm = new DialogicManager;
171 : amartin 28 dm->init();
172 :    
173 :    
174 : amartin 20 /* initialise woomera subsystem
175 :     */
176 :     woomera_init();
177 :     woomera_server* server = woomera_server_new();
178 :     woomera_callctlr* callctlr = woomera_callctlr_new(woomera_server_send_event, server);
179 : jtarlton 54 woomera_callctlr_add_protocol(callctlr, &isdn_protocol, "isdn", 0);
180 : amartin 20
181 :     /* create and run the server
182 :     */
183 :     woomera_server_attr * attr = woomera_server_attr_new();
184 :     attr->server = server;
185 :     attr->callctlr = callctlr;
186 : amartin 21 attr->port = atoi(opt_woomera_port.c_str());
187 : amartin 20 attr->timeout = 1000;
188 :     attr->callback = 0; /* function that checks apps own fdS, called by the server poll loop */
189 :     attr->user_data = 0;
190 :    
191 :     woomera_server_run(attr);
192 :    
193 :     /* exit
194 :     */
195 :     woomera_server_delete(server);
196 :     }
197 :    
198 :    
199 : jtarlton 41 /* vim:ts=4:set nu:
200 :     * EOF
201 : amartin 20 */

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.8