RTS API Documentation  1.10.11
switch_cpp.cpp
Go to the documentation of this file.
1 /*
2  * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
3  * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
4  *
5  * Version: MPL 1.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
18  *
19  * The Initial Developer of the Original Code is
20  * Anthony Minessale II <anthm@freeswitch.org>
21  * Portions created by the Initial Developer are Copyright (C)
22  * the Initial Developer. All Rights Reserved.
23  *
24  * Contributor(s):
25  *
26  * Anthony Minessale II <anthm@freeswitch.org>
27  *
28  *
29  * switch_cpp.cpp -- C++ wrapper
30  *
31  */
32 
33 #include <switch.h>
34 #include <switch_cpp.h>
35 
36 #ifdef _MSC_VER
37 #pragma warning(disable:4127 4003)
38 #endif
39 
40 static void event_handler(switch_event_t *event)
41 {
43  switch_event_t *dup;
44 
45  switch_event_dup(&dup, event);
46 
48  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot queue any more events.....\n");
50  }
51 
52 }
53 
54 SWITCH_DECLARE_CONSTRUCTOR EventConsumer::EventConsumer(const char *event_name, const char *subclass_name, int len)
55 {
56 
59  node_index = 0;
60  ready = 1;
61 
62  if (!zstr(event_name)) {
63  bind(event_name, subclass_name);
64  }
65 }
66 
67 SWITCH_DECLARE(int) EventConsumer::bind(const char *event_name, const char *subclass_name)
68 {
70 
71  if (!ready) {
72  return 0;
73  }
74 
75  if (switch_name_event(event_name, &event_id) != SWITCH_STATUS_SUCCESS) {
76  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't bind to %s, event not found\n", event_name);
77  return 0;
78  }
79 
80  if (zstr(subclass_name)) {
81  subclass_name = NULL;
82  }
83 
85  switch_event_bind_removable(__FILE__, event_id, subclass_name, event_handler, this, &enodes[node_index]) == SWITCH_STATUS_SUCCESS) {
86  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "bound to %s %s\n", event_name, switch_str_nil(subclass_name));
87  node_index++;
88  return 1;
89  }
90 
91  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot bind to %s %s\n", event_name, switch_str_nil(subclass_name));
92  return 0;
93 }
94 
95 
96 SWITCH_DECLARE(Event *) EventConsumer::pop(int block, int timeout)
97 {
98  void *pop = NULL;
99  Event *ret = NULL;
100  switch_event_t *event;
101  switch_status_t res;
102 
103  if (!ready) {
104  return NULL;
105  }
106 
107  if (block) {
108  if (timeout > 0) {
109  res = switch_queue_pop_timeout(events, &pop, (switch_interval_time_t) timeout * 1000); // millisec rather than microsec
110  } else {
111  res = switch_queue_pop(events, &pop);
112  }
113  } else {
114  res = switch_queue_trypop(events, &pop);
115  }
116 
117  (void)res;
118 
119  if ((event = (switch_event_t *) pop)) {
120  ret = new Event(event, 1);
121  }
122 
123  return ret;
124 }
125 
127 {
128 
129  uint32_t i;
130  void *pop;
131 
132  if (!ready) {
133  return;
134  }
135 
136  ready = 0;
137 
138  for (i = 0; i < node_index; i++) {
140  }
141 
142  node_index = 0;
143 
145 
147  switch_event_t *event = (switch_event_t *) pop;
148  switch_event_destroy(&event);
149  }
150 
151 
153 
154 }
155 
156 
157 SWITCH_DECLARE_CONSTRUCTOR EventConsumer::~EventConsumer()
158 {
159  cleanup();
160 }
161 
163  const char *name,
164  const char *greeting_sound,
165  const char *short_greeting_sound,
166  const char *invalid_sound,
167  const char *exit_sound,
168  const char *transfer_sound,
169  const char *confirm_macro,
170  const char *confirm_key,
171  const char *tts_engine,
172  const char *tts_voice,
173  int confirm_attempts,
174  int inter_timeout,
175  int digit_len,
176  int timeout,
177  int max_failures,
178  int max_timeouts)
179 {
180  menu = NULL;
183  if (zstr(name)) {
184  name = "no name";
185  }
186 
187  switch_ivr_menu_init(&menu, main ? main->menu : NULL, name, greeting_sound, short_greeting_sound, invalid_sound,
188  exit_sound, transfer_sound, confirm_macro, confirm_key, tts_engine, tts_voice, confirm_attempts, inter_timeout,
189  digit_len, timeout, max_failures, max_timeouts, pool);
190 
191 
192 }
193 
194 SWITCH_DECLARE_CONSTRUCTOR IVRMenu::~IVRMenu()
195 {
196  if (menu) {
198  }
200 }
201 
202 SWITCH_DECLARE(void) IVRMenu::bindAction(char *action, const char *arg, const char *bind)
203 {
205 
206  this_check_void();
207 
208  if (switch_ivr_menu_str2action(action, &ivr_action) == SWITCH_STATUS_SUCCESS) {
209  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "bind %s to %s(%s)\n", bind, action, arg);
210  switch_ivr_menu_bind_action(menu, ivr_action, arg, bind);
211  } else {
212  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid action %s\n", action);
213  }
214 }
215 
216 SWITCH_DECLARE(void) IVRMenu::execute(CoreSession *session, const char *name)
217 {
218  this_check_void();
219  switch_ivr_menu_execute(session->session, menu, (char *)name, NULL);
220 }
221 
223 {
224  if (s) {
225  session = s->session;
226  } else {
227  session = NULL;
228  }
229 }
230 
231 SWITCH_DECLARE_CONSTRUCTOR API::~API()
232 {
233  return;
234 }
235 
236 
237 SWITCH_DECLARE(const char *) API::execute(const char *cmd, const char *arg)
238 {
239  switch_stream_handle_t stream = { 0 };
240  this_check("");
241 
242  SWITCH_STANDARD_STREAM(stream);
243 
244  if (zstr(cmd)) {
245  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No application specified\n");
246  stream.write_function(&stream, "-ERR No application specified");
247  } else {
248  switch_api_execute(cmd, arg, session, &stream);
249  }
250 
251  return (char *) stream.data;
252 }
253 
254 
255 /* we have to do this as a string because swig and languages can't find an embedded way to pass a big int */
257 {
258  switch_time_t now = switch_micro_time_now() / 1000;
259  snprintf(time_buf, sizeof(time_buf), "%" SWITCH_TIME_T_FMT, now);
260  return time_buf;
261 }
262 
263 
264 
265 SWITCH_DECLARE(const char *) API::executeString(const char *cmd)
266 {
267  char *arg;
268  switch_stream_handle_t stream = { 0 };
269  char *mycmd = NULL;
270 
271  this_check("");
272 
273  SWITCH_STANDARD_STREAM(stream);
274 
275  if (zstr(cmd)) {
276  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No application specified\n");
277  stream.write_function(&stream, "-ERR No application specified");
278  } else {
279  mycmd = strdup(cmd);
280 
281  switch_assert(mycmd);
282 
283  if ((arg = strchr(mycmd, ' '))) {
284  *arg++ = '\0';
285  }
286 
287  switch_api_execute(mycmd, arg, session, &stream);
288  switch_safe_free(mycmd);
289  }
290 
291  return (char *) stream.data;
292 }
293 
294 SWITCH_DECLARE_CONSTRUCTOR Event::Event(const char *type, const char *subclass_name)
295 {
296  switch_event_types_t event_id;
297 
298  if (!strcasecmp(type, "json") && !zstr(subclass_name)) {
299  if (switch_event_create_json(&event, subclass_name) != SWITCH_STATUS_SUCCESS) {
300  return;
301  }
302 
303  event_id = event->event_id;
304 
305  } else {
306  if (switch_name_event(type, &event_id) != SWITCH_STATUS_SUCCESS) {
307  event_id = SWITCH_EVENT_MESSAGE;
308  }
309 
310  if (!zstr(subclass_name) && event_id != SWITCH_EVENT_CUSTOM) {
311  switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_WARNING, "Changing event type to custom because you specified a subclass name!\n");
312  event_id = SWITCH_EVENT_CUSTOM;
313  }
314 
315  if (switch_event_create_subclass(&event, event_id, subclass_name) != SWITCH_STATUS_SUCCESS) {
316  switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Failed to create event!\n");
317  event = NULL;
318  }
319  }
320 
321  serialized_string = NULL;
322  mine = 1;
323 }
324 
326 {
327  event = wrap_me;
328  mine = free_me;
329  serialized_string = NULL;
330 }
331 
332 SWITCH_DECLARE_CONSTRUCTOR Event::~Event()
333 {
334 
335  if (serialized_string) {
336  free(serialized_string);
337  }
338 
339  if (event && mine) {
340  switch_event_destroy(&event);
341  }
342 }
343 
344 SWITCH_DECLARE(int)Event::chat_execute(const char *app, const char *data)
345 {
346  return (int) switch_core_execute_chat_app(event, app, data);
347 }
348 
349 SWITCH_DECLARE(int)Event::chat_send(const char *dest_proto)
350 {
351  if (zstr(dest_proto)) {
352  dest_proto = switch_event_get_header(event, "dest_proto");
353  }
354 
355  return (int) switch_core_chat_send(dest_proto, event);
356 }
357 
358 SWITCH_DECLARE(const char *)Event::serialize(const char *format)
359 {
360  this_check("");
361 
362 
363  switch_safe_free(serialized_string);
364 
365  if (!event) {
366  return "";
367  }
368 
369  if (format && !strcasecmp(format, "xml")) {
370  switch_xml_t xml;
371  if ((xml = switch_event_xmlize(event, SWITCH_VA_NONE))) {
372  serialized_string = switch_xml_toxml(xml, SWITCH_FALSE);
373  switch_xml_free(xml);
374  return serialized_string;
375  } else {
376  return "";
377  }
378  } else if (format && !strcasecmp(format, "json")) {
379  switch_event_serialize_json(event, &serialized_string);
380  return serialized_string;
381  } else {
382  if (switch_event_serialize(event, &serialized_string, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
383  char *new_serialized_string = switch_mprintf("%s", serialized_string);
384  free(serialized_string);
385  serialized_string = new_serialized_string;
386  return serialized_string;
387  }
388  }
389 
390  return "";
391 
392 }
393 
395 {
396 
397  this_check(false);
398 
399  if (!mine) {
401  return false;
402  }
403 
404  if (event) {
405  switch_event_t *new_event;
406  if (switch_event_dup(&new_event, event) == SWITCH_STATUS_SUCCESS) {
407  if (switch_event_fire(&new_event) != SWITCH_STATUS_SUCCESS) {
408  switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Failed to fire the event!\n");
409  switch_event_destroy(&new_event);
410  return false;
411  }
412  return true;
413  } else {
414  switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Failed to dup the event!\n");
415  }
416  } else {
417  switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Trying to fire an event that does not exist!\n");
418  }
419  return false;
420 }
421 
423 {
424  this_check(false);
425 
426  if (event) {
427  switch_event_set_priority(event, priority);
428  return true;
429  } else {
430  switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Trying to setPriority an event that does not exist!\n");
431  }
432  return false;
433 }
434 
435 SWITCH_DECLARE(const char *)Event::getHeader(const char *header_name)
436 {
437  this_check("");
438 
439  if (zstr(header_name)) {
440  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Trying to getHeader an invalid header!\n");
441  return NULL;
442  }
443 
444  if (event) {
445  return switch_event_get_header(event, header_name);
446  } else {
447  switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Trying to getHeader an event that does not exist!\n");
448  }
449  return NULL;
450 }
451 
452 SWITCH_DECLARE(bool) Event::addHeader(const char *header_name, const char *value)
453 {
454  this_check(false);
455 
456  if (event) {
457  return switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, value) == SWITCH_STATUS_SUCCESS ? true : false;
458  } else {
459  switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Trying to addHeader an event that does not exist!\n");
460  }
461 
462  return false;
463 }
464 
465 SWITCH_DECLARE(bool) Event::delHeader(const char *header_name)
466 {
467  this_check(false);
468 
469  if (zstr(header_name)) {
470  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Trying to delHeader an invalid header!\n");
471  return false;
472  }
473 
474  if (event) {
475  return switch_event_del_header(event, header_name) == SWITCH_STATUS_SUCCESS ? true : false;
476  } else {
477  switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Trying to delHeader an event that does not exist!\n");
478  }
479 
480  return false;
481 }
482 
483 
485 {
486  this_check(false);
487 
488  if (event) {
489  return switch_event_add_body(event, "%s", value) == SWITCH_STATUS_SUCCESS ? true : false;
490  } else {
491  switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Trying to addBody an event that does not exist!\n");
492  }
493 
494  return false;
495 }
496 
498 {
499 
500  this_check((char *)"");
501 
502  if (event) {
503  return switch_event_get_body(event);
504  } else {
505  switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Trying to getBody an event that does not exist!\n");
506  }
507 
508  return NULL;
509 }
510 
511 SWITCH_DECLARE(const char *)Event::getType(void)
512 {
513  this_check("");
514 
515  if (event) {
516  return switch_event_name(event->event_id);
517  } else {
518  switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Trying to getType an event that does not exist!\n");
519  }
520 
521  return (char *) "invalid";
522 }
523 
525 {
526  this_check(false);
527 
528  if (!event) {
529  switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Trying to merge to an event that does not exist!\n");
530  return false;
531  }
532 
533  if (!to_merge || !to_merge->event) {
534  switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Trying to merge from an event that does not exist!\n");
535  return false;
536  }
537 
538  switch_event_merge(event, to_merge->event);
539 
540  return true;
541 }
542 
543 SWITCH_DECLARE_CONSTRUCTOR DTMF::DTMF(char idigit, uint32_t iduration)
544 {
545  digit = idigit;
546 
547  if (iduration == 0) {
548  iduration = SWITCH_DEFAULT_DTMF_DURATION;
549  }
550 
551  duration = iduration;
552 }
553 
555 {
556 
557 }
558 
559 
561 {
562  SWITCH_STANDARD_STREAM(mystream);
563  stream_p = &mystream;
564  mine = 1;
565 }
566 
568 {
569  stream_p = sp;
570  mine = 0;
571 }
572 
573 
574 SWITCH_DECLARE_CONSTRUCTOR Stream::~Stream()
575 {
576  if (mine) {
577  switch_safe_free(mystream.data);
578  }
579 }
580 
581 /* WARNING!! you are not encouraged to use this unless you understand the risk!!! */
582 SWITCH_DECLARE(const char *) Stream::read(int *len)
583 {
584  uint8_t *buff;
585 
586  this_check(NULL);
587 
588  if (!stream_p->read_function) return NULL;
589 
590  buff = stream_p->read_function(stream_p, len);
591 
592  if (!buff || *len <= 0) {
593  *len = 0;
594  return NULL;
595  }
596 
597  return (const char *)buff;
598 }
599 
600 SWITCH_DECLARE(void) Stream::write(const char *data)
601 {
602  this_check_void();
603  stream_p->write_function(stream_p, "%s", data);
604 }
605 
606 SWITCH_DECLARE(void) Stream::raw_write(const char *data, int len)
607 {
608  this_check_void();
609  stream_p->raw_write_function(stream_p, (uint8_t *)data, len);
610 }
611 
613 {
614  this_check("");
615 
616  return stream_p ? (const char *)stream_p->data : NULL;
617 }
618 
619 
621 {
622  init_vars();
623 }
624 
626 {
627  switch_channel_t *other_channel = NULL;
628 
629  init_vars();
630 
631  if (a_leg && a_leg->session) {
632  other_channel = switch_core_session_get_channel(a_leg->session);
633  }
634 
635  if (!strchr(nuuid, '/') && (session = switch_core_session_force_locate(nuuid))) {
636  uuid = strdup(nuuid);
637  channel = switch_core_session_get_channel(session);
638  allocated = 1;
639  } else {
641  if (switch_ivr_originate(a_leg ? a_leg->session : NULL, &session, &cause, nuuid, 60, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL, NULL)
643  channel = switch_core_session_get_channel(session);
644  allocated = 1;
645  switch_set_flag(this, S_HUP);
646  uuid = strdup(switch_core_session_get_uuid(session));
648  switch_channel_wait_for_state(channel, other_channel, CS_SOFT_EXECUTE);
649  }
650  }
651 }
652 
654 {
655  init_vars();
656 
657  if (new_session && switch_core_session_read_lock_hangup(new_session) == SWITCH_STATUS_SUCCESS) {
658  session = new_session;
659  channel = switch_core_session_get_channel(session);
660  allocated = 1;
661  uuid = strdup(switch_core_session_get_uuid(session));
662  }
663 }
664 
665 SWITCH_DECLARE_CONSTRUCTOR CoreSession::~CoreSession()
666 {
667  this_check_void();
668  if (allocated) destroy();
669 }
670 
672 {
673 
674  switch_xml_t cdr = NULL;
675 
676  this_check((char *)"");
677  sanity_check((char *)"");
678 
679  switch_safe_free(xml_cdr_text);
680 
681  if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) {
682  xml_cdr_text = switch_xml_toxml(cdr, SWITCH_FALSE);
683  switch_xml_free(cdr);
684  }
685 
686  return (char *) (xml_cdr_text ? xml_cdr_text : "");
687 }
688 
690 {
691  this_check_void();
693 
694  if (channel && e->event) {
696  }
697 }
698 
700 {
701  switch_status_t status;
702  this_check(-1);
703  sanity_check(-1);
704  status = switch_channel_answer(channel);
705  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
706 }
707 
708 
710 {
711  switch_status_t status;
712  status = switch_core_session_print(session, switch_str_nil(txt));
713  this_check(-1);
714  sanity_check(-1);
715  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
716 }
717 
718 SWITCH_DECLARE(int) CoreSession::insertFile(const char *file, const char *insert_file, int sample_point)
719 {
720  switch_status_t status;
721  this_check(-1);
722  sanity_check(-1);
723  status = switch_ivr_insert_file(session, file, insert_file, (switch_size_t)sample_point);
724  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
725 }
726 
728 {
729  switch_status_t status;
730  this_check(-1);
731  sanity_check(-1);
732  status = switch_channel_pre_answer(channel);
733  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
734 }
735 
737 {
739  this->begin_allow_threads();
740  if (switch_channel_down(channel)) {
742  }
743  this->end_allow_threads();
744 }
745 
746 SWITCH_DECLARE(void) CoreSession::hangup(const char *cause)
747 {
748  this_check_void();
750  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "CoreSession::hangup\n");
751  this->begin_allow_threads();
753  this->end_allow_threads();
754 }
755 
756 SWITCH_DECLARE(void) CoreSession::setPrivate(char *var, void *val)
757 {
758  this_check_void();
760  switch_channel_set_private(channel, var, val);
761 }
762 
764 {
765  this_check(NULL);
766  sanity_check(NULL);
767  return switch_channel_get_private(channel, var);
768 }
769 
770 SWITCH_DECLARE(void) CoreSession::setVariable(char *var, char *val)
771 {
772  this_check_void();
774  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "CoreSession::setVariable('%s', '%s')\n", var, val);
776 }
777 
779 {
780  this_check("");
781  sanity_check("");
782  return switch_channel_get_variable(channel, var);
783 }
784 
785 SWITCH_DECLARE(void) CoreSession::execute(const char *app, const char *data)
786 {
787  this_check_void();
789 
790  if (zstr(app)) {
791  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No application specified\n");
792  return;
793  }
794 
795  begin_allow_threads();
796  switch_core_session_execute_application(session, app, data);
797  end_allow_threads();
798 }
799 
800 SWITCH_DECLARE(void) CoreSession::setDTMFCallback(void *cbfunc, char *funcargs) {
801 
802  this_check_void();
804 
805  cb_state.funcargs = funcargs;
806  cb_state.function = cbfunc;
807 
808  args.buf = &cb_state;
809  args.buflen = sizeof(cb_state); // not sure what this is used for, copy mod_spidermonkey
810 
811  switch_channel_set_private(channel, "CoreSession", this);
812 
813  // we cannot set the actual callback to a python function, because
814  // the callback is a function pointer with a specific signature.
815  // so, set it to the following c function which will act as a proxy,
816  // finding the python callback in the args callback args structure
817  args.input_callback = dtmf_callback;
818  ap = &args;
819 
820 
821 }
822 
824 {
825  this_check_void();
827 
828  if (sendME->event) {
829  switch_event_t *new_event;
830  if (switch_event_dup(&new_event, sendME->event) == SWITCH_STATUS_SUCCESS) {
831  switch_core_session_receive_event(session, &new_event);
832  }
833  }
834 }
835 
837 {
838  switch_status_t status;
839 
840  this_check(-1);
841  sanity_check(-1);
842 
843  if (!tts_name) {
844  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No TTS engine specified\n");
845  return SWITCH_STATUS_FALSE;
846  }
847 
848  if (!voice_name) {
849  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No TTS voice specified\n");
850  return SWITCH_STATUS_FALSE;
851  }
852 
853 
854  begin_allow_threads();
855  status = switch_ivr_speak_text(session, tts_name, voice_name, text, ap);
856  end_allow_threads();
857  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
858 }
859 
860 SWITCH_DECLARE(void) CoreSession::set_tts_parms(char *tts_name_p, char *voice_name_p)
861 {
862  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "set_tts_parms is deprecated. Use set_tts_params.\n");
863  this_check_void();
865  switch_safe_free(tts_name);
866  switch_safe_free(voice_name);
867  tts_name = strdup(tts_name_p);
868  voice_name = strdup(voice_name_p);
869 }
870 
871 SWITCH_DECLARE(void) CoreSession::set_tts_params(char *tts_name_p, char *voice_name_p)
872 {
873  this_check_void();
875  switch_safe_free(tts_name);
876  switch_safe_free(voice_name);
877  tts_name = strdup(switch_str_nil(tts_name_p));
878  voice_name = strdup(switch_str_nil(voice_name_p));
879 }
880 
882  return collectDigits(0, abs_timeout);
883 }
884 
885 SWITCH_DECLARE(int) CoreSession::collectDigits(int digit_timeout, int abs_timeout) {
886  this_check(-1);
887  sanity_check(-1);
888  begin_allow_threads();
889  switch_ivr_collect_digits_callback(session, ap, digit_timeout, abs_timeout);
890  end_allow_threads();
891  return SWITCH_STATUS_SUCCESS;
892 }
893 
894 SWITCH_DECLARE(char *) CoreSession::getDigits(int maxdigits, char *terminators, int timeout)
895 {
896  return getDigits(maxdigits, terminators, timeout, 0);
897 }
898 
899 SWITCH_DECLARE(char *) CoreSession::getDigits(int maxdigits, char *terminators, int timeout, int interdigit)
900 {
901  return getDigits(maxdigits, terminators, timeout, interdigit, 0);
902 }
903 
905  char *terminators,
906  int timeout,
907  int interdigit,
908  int abstimeout)
909 {
910  this_check((char *)"");
911  sanity_check((char *)"");
912  begin_allow_threads();
913  char terminator;
914 
915  memset(dtmf_buf, 0, sizeof(dtmf_buf));
917  dtmf_buf,
918  sizeof(dtmf_buf),
919  maxdigits,
920  terminators,
921  &terminator,
922  (uint32_t) timeout, (uint32_t)interdigit, (uint32_t)abstimeout);
923 
924  /* Only log DTMF buffer if sensitive_dtmf channel variable not set to true */
926  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "getDigits dtmf_buf: %s\n", dtmf_buf);
927  }
928 
929  end_allow_threads();
930  return dtmf_buf;
931 }
932 
933 SWITCH_DECLARE(int) CoreSession::transfer(char *extension, char *dialplan, char *context)
934 {
935  switch_status_t status;
936  this_check(-1);
937  sanity_check(-1);
938  begin_allow_threads();
939  status = switch_ivr_session_transfer(session, extension, dialplan, context);
940  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "transfer result: %d\n", status);
941  end_allow_threads();
942  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
943 }
944 
945 
946 SWITCH_DECLARE(char *) CoreSession::read(int min_digits,
947  int max_digits,
948  const char *prompt_audio_file,
949  int timeout,
950  const char *valid_terminators,
951  int digit_timeout)
952 {
953  this_check((char *)"");
954  sanity_check((char *)"");
955  if (min_digits < 1) {
956  min_digits = 1;
957  }
958 
959  if (max_digits < 1) {
960  max_digits = 1;
961  }
962 
963  if (timeout < 1) {
964  timeout = 1;
965  }
966 
967  begin_allow_threads();
968  switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, NULL, dtmf_buf,
969  sizeof(dtmf_buf), timeout, valid_terminators, (uint32_t)digit_timeout);
970  end_allow_threads();
971 
972  return dtmf_buf;
973 }
974 
976  int max_digits,
977  int max_tries,
978  int timeout,
979  char *terminators,
980  char *audio_files,
981  char *bad_input_audio_files,
982  char *digits_regex,
983  const char *var_name,
984  int digit_timeout,
985  const char *transfer_on_failure)
986 {
987  sanity_check((char *)"");
988  this_check((char *)"");
989  begin_allow_threads();
990  memset(dtmf_buf, 0, sizeof(dtmf_buf));
992  (uint32_t) min_digits,
993  (uint32_t) max_digits,
994  (uint32_t) max_tries,
995  (uint32_t) timeout,
996  terminators,
997  audio_files,
998  bad_input_audio_files,
999  var_name,
1000  dtmf_buf,
1001  sizeof(dtmf_buf),
1002  digits_regex,
1003  (uint32_t) digit_timeout,
1004  transfer_on_failure);
1005 
1006  end_allow_threads();
1007  return dtmf_buf;
1008 }
1009 
1010 SWITCH_DECLARE(void) CoreSession::detectSpeech(char *arg0, char *arg1, char *arg2, char *arg3)
1011 {
1012  this_check_void();
1014 
1015  begin_allow_threads();
1016 
1017  if (!arg0) return;
1018 
1019  if (!strcasecmp(arg0, "grammar") && arg1 && arg2) {
1020  switch_ivr_detect_speech_load_grammar(session, arg1, arg2);
1021  } else if (!strcasecmp(arg0, "nogrammar") && arg1) {
1023  } else if (!strcasecmp(arg0, "grammaron") && arg1) {
1025  } else if (!strcasecmp(arg0, "grammaroff") && arg1) {
1027  } else if (!strcasecmp(arg0, "grammarsalloff")) {
1029  } else if (!strcasecmp(arg0, "init") && arg1 && arg2) {
1030  switch_ivr_detect_speech_init(session, arg1, arg2, NULL);
1031  } else if (!strcasecmp(arg0, "pause")) {
1033  } else if (!strcasecmp(arg0, "resume")) {
1035  } else if (!strcasecmp(arg0, "stop")) {
1037  } else if (!strcasecmp(arg0, "param") && arg1 && arg2) {
1038  switch_ivr_set_param_detect_speech(session, arg1, arg2);
1039  } else if (!strcasecmp(arg0, "start-input-timers")) {
1041  } else if (!strcasecmp(arg0, "start_input_timers")) {
1042  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "start_input_timers is deprecated, please use start-input-timers instead!\n");
1044  } else if (arg1 && arg2 && arg3) {
1045  switch_ivr_detect_speech(session, arg0, arg1, arg2, arg3, NULL);
1046  }
1047 
1048  end_allow_threads();
1049 }
1050 
1051 SWITCH_DECLARE(char *) CoreSession::playAndDetectSpeech(char *file, char *engine, char *grammar)
1052 {
1053  sanity_check((char *)"");
1054  this_check((char *)"");
1055  begin_allow_threads();
1056 
1057  char *result = NULL;
1058 
1059  switch_status_t status = switch_ivr_play_and_detect_speech(session, file, engine, grammar, &result, 0, ap);
1060  if (status == SWITCH_STATUS_SUCCESS) {
1061  // good
1062  } else if (status == SWITCH_STATUS_GENERR) {
1063  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "GRAMMAR ERROR\n");
1064  } else if (status == SWITCH_STATUS_NOT_INITALIZED) {
1065  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "ASR INIT ERROR\n");
1066  } else {
1067  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "ERROR status = %d\n", status);
1068  }
1069 
1070  end_allow_threads();
1071 
1072  return result ? strdup(result) : NULL; // remeber to free me
1073 }
1074 
1075 SWITCH_DECLARE(void) CoreSession::say(const char *tosay, const char *module_name, const char *say_type, const char *say_method, const char *say_gender)
1076 {
1077  this_check_void();
1079  if (!(tosay && module_name && say_type && say_method)) {
1080  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error! invalid args.\n");
1081  return;
1082  }
1083  begin_allow_threads();
1084  switch_ivr_say(session, tosay, module_name, say_type, say_method, say_gender, ap);
1085  end_allow_threads();
1086 }
1087 
1088 SWITCH_DECLARE(void) CoreSession::sayPhrase(const char *phrase_name, const char *phrase_data, const char *phrase_lang)
1089 {
1090  this_check_void();
1092 
1093  if (!(phrase_name)) {
1094  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error! invalid args.\n");
1095  return;
1096  }
1097 
1098  begin_allow_threads();
1099  switch_ivr_phrase_macro(session, phrase_name, phrase_data, phrase_lang, ap);
1100  end_allow_threads();
1101 }
1102 
1103 SWITCH_DECLARE(int) CoreSession::streamFile(char *file, int starting_sample_count) {
1104 
1105  switch_status_t status;
1106  //switch_file_handle_t fh = { 0 };
1107  const char *prebuf;
1108  switch_file_handle_t local_fh;
1109 
1110  this_check(-1);
1111  sanity_check(-1);
1112 
1113  memset(&local_fh, 0, sizeof(local_fh));
1114  fhp = &local_fh;
1115  local_fh.samples = starting_sample_count;
1116 
1117 
1118  if ((prebuf = switch_channel_get_variable(this->channel, "stream_prebuffer"))) {
1119  int maybe = atoi(prebuf);
1120  if (maybe > 0) {
1121  local_fh.prebuf = maybe;
1122  }
1123  }
1124 
1125  begin_allow_threads();
1126  status = switch_ivr_play_file(session, fhp, file, ap);
1127  end_allow_threads();
1128 
1129  fhp = NULL;
1130 
1131  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
1132 
1133 }
1134 
1135 SWITCH_DECLARE(int) CoreSession::sleep(int ms, int sync) {
1136 
1137  switch_status_t status;
1138 
1139  this_check(-1);
1140  sanity_check(-1);
1141 
1142  begin_allow_threads();
1143  status = switch_ivr_sleep(session, ms, (switch_bool_t) sync, ap);
1144  end_allow_threads();
1145 
1146  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
1147 
1148 }
1149 
1151 
1152  this_check(false);
1153 
1154  if (!session) {
1155  return false;
1156  }
1157  sanity_check(false);
1158 
1159  return switch_channel_ready(channel) != 0;
1160 }
1161 
1162 
1164 
1165  this_check(false);
1166 
1167  if (!session) {
1168  return false;
1169  }
1170  sanity_check(false);
1171 
1172  return (switch_channel_up(channel) && switch_channel_test_flag(channel, CF_BRIDGED));
1173 }
1174 
1176 
1177  this_check(false);
1178  sanity_check(false);
1179  return switch_channel_media_ready(channel) != 0;
1180 }
1181 
1183 
1184  this_check(false);
1185  sanity_check(false);
1186  return switch_channel_test_flag(channel, CF_ANSWERED) != 0;
1187 }
1188 
1190 {
1191  this_check_void();
1192 
1193  if (!allocated) {
1194  return;
1195  }
1196 
1197  allocated = 0;
1198 
1199  switch_safe_free(xml_cdr_text);
1200  switch_safe_free(uuid);
1201  switch_safe_free(tts_name);
1202  switch_safe_free(voice_name);
1203 
1204  if (session) {
1205  if (!channel) {
1206  channel = switch_core_session_get_channel(session);
1207  }
1208 
1209  if (channel) {
1211  "%s destroy/unlink session from object\n", switch_channel_get_name(channel));
1212  switch_channel_set_private(channel, "CoreSession", NULL);
1213  if (switch_channel_up(channel) && switch_test_flag(this, S_HUP) && !switch_channel_test_flag(channel, CF_TRANSFER)) {
1215  }
1216  }
1217 
1219  session = NULL;
1220  channel = NULL;
1221  }
1222 
1223  init_vars();
1224 
1225 }
1226 
1228 {
1229  this_check(NULL);
1230  return switch_channel_cause2str(cause);
1231 }
1232 
1234 {
1235  this_check(NULL);
1236 
1237  if (channel) {
1239  }
1240 
1241  return "ERROR";
1242 
1243 }
1244 
1245 SWITCH_DECLARE(int) CoreSession::originate(CoreSession *a_leg_session, char *dest, int timeout, switch_state_handler_table_t *handlers)
1246 {
1247 
1248  switch_core_session_t *aleg_core_session = NULL;
1249 
1250  this_check(0);
1251 
1253 
1254  if (a_leg_session != NULL) {
1255  aleg_core_session = a_leg_session->session;
1256  }
1257 
1258  // this session has no valid switch_core_session_t at this point, and therefore
1259  // no valid channel. since the threadstate is stored in the channel, and there
1260  // is none, if we try to call begin_alllow_threads it will fail miserably.
1261  // use the 'a leg session' to do the thread swapping stuff.
1262  if (a_leg_session) a_leg_session->begin_allow_threads();
1263 
1264  if (switch_ivr_originate(aleg_core_session,
1265  &session,
1266  &cause,
1267  dest,
1268  timeout,
1269  handlers,
1270  NULL,
1271  NULL,
1272  NULL,
1273  NULL,
1274  SOF_NONE,
1275  NULL,
1276  NULL) != SWITCH_STATUS_SUCCESS) {
1277  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error Creating Outgoing Channel! [%s]\n", dest);
1278  goto failed;
1279 
1280  }
1281 
1282  if (a_leg_session) a_leg_session->end_allow_threads();
1283  channel = switch_core_session_get_channel(session);
1284  allocated = 1;
1285  switch_safe_free(uuid);
1286  uuid = strdup(switch_core_session_get_uuid(session));
1288 
1289  return SWITCH_STATUS_SUCCESS;
1290 
1291  failed:
1292  if (a_leg_session) a_leg_session->end_allow_threads();
1293  return SWITCH_STATUS_FALSE;
1294 }
1295 
1296 SWITCH_DECLARE(int) CoreSession::recordFile(char *file_name, int time_limit, int silence_threshold, int silence_hits)
1297 {
1298  switch_status_t status;
1299  switch_file_handle_t local_fh;
1300 
1301  this_check(-1);
1302  sanity_check(-1);
1303 
1304  if (!file_name) return 0;
1305  memset(&local_fh, 0, sizeof(local_fh));
1306  fhp = &local_fh;
1307  local_fh.thresh = silence_threshold;
1308  local_fh.silence_hits = silence_hits;
1309 
1310  begin_allow_threads();
1311  status = switch_ivr_record_file(session, &local_fh, file_name, ap, time_limit);
1312  end_allow_threads();
1313 
1314  fhp = NULL;
1315 
1316  return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
1317 
1318 }
1319 
1321 {
1322  switch_event_t *event;
1323 
1324  this_check(-1);
1325  sanity_check(-1);
1326 
1327  if (!session) {
1328  return SWITCH_STATUS_FALSE;
1329  }
1330 
1332  switch_event_destroy(&event);
1333  }
1334  return SWITCH_STATUS_SUCCESS;
1335 }
1336 
1338 {
1339  this_check(-1);
1340  sanity_check(-1);
1342  return SWITCH_STATUS_SUCCESS;
1343 }
1344 
1346 {
1347  this_check(-1);
1348  sanity_check(-1);
1349 
1350  if (!session) {
1351  return SWITCH_STATUS_FALSE;
1352  }
1353  if (val) {
1354  switch_set_flag(this, S_HUP);
1355  } else {
1356  switch_clear_flag(this, S_HUP);
1357  }
1358  return SWITCH_STATUS_SUCCESS;
1359 }
1360 
1362 {
1363  this_check_void();
1365 
1366  switch_ivr_wait_for_answer(calling_session ? calling_session->session : NULL, session);
1367 
1368 }
1369 
1370 SWITCH_DECLARE(void) CoreSession::setHangupHook(void *hangup_func) {
1371 
1372  this_check_void();
1374 
1375  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "CoreSession::seHangupHook, hangup_func: %p\n", hangup_func);
1376  on_hangup = hangup_func;
1378 
1379  hook_state = switch_channel_get_state(channel);
1380  switch_channel_set_private(channel, "CoreSession", this);
1381  switch_core_event_hook_add_state_change(session, hanguphook);
1382 }
1383 
1384 SWITCH_DECLARE(void) CoreSession::consoleLog(char *level_str, char *msg)
1385 {
1387  if (level_str) {
1388  level = switch_log_str2level(level_str);
1389  if (level == SWITCH_LOG_INVALID) {
1390  level = SWITCH_LOG_DEBUG;
1391  }
1392  }
1393  switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), level, "%s", switch_str_nil(msg));
1394 }
1395 
1396 SWITCH_DECLARE(void) CoreSession::consoleLog2(char *level_str, char *file, char *func, int line, char *msg)
1397 {
1399  if (level_str) {
1400  level = switch_log_str2level(level_str);
1401  if (level == SWITCH_LOG_INVALID) {
1402  level = SWITCH_LOG_DEBUG;
1403  }
1404  }
1405  switch_log_printf(SWITCH_CHANNEL_ID_SESSION, file, func, line, (const char*)session,
1406  level, "%s", switch_str_nil(msg));
1407 }
1408 
1409 /* ---- methods not bound to CoreSession instance ---- */
1410 
1411 
1412 SWITCH_DECLARE(int) globalSetVariable(const char *var, const char *val, const char *val2)
1413 {
1414  if (zstr(val)) val = NULL;
1415  if (zstr(val2)) val2 = NULL;
1416 
1417  if (val2) {
1418  return switch_core_set_var_conditional(var, val, val2);
1419  } else {
1420  switch_core_set_variable(var, val);
1421  return SWITCH_STATUS_SUCCESS;
1422  }
1423 }
1424 
1425 SWITCH_DECLARE(void) setGlobalVariable(char *var_name, char *var_val)
1426 {
1427  switch_core_set_variable(var_name, var_val);
1428 }
1429 
1430 SWITCH_DECLARE(char *) getGlobalVariable(char *var_name)
1431 {
1432  return switch_core_get_variable_dup(var_name);
1433 }
1434 
1435 
1437 {
1438  return switch_core_running() ? true : false;
1439 }
1440 
1441 SWITCH_DECLARE(void) consoleLog(char *level_str, char *msg)
1442 {
1443  return console_log(level_str, msg);
1444 }
1445 
1446 SWITCH_DECLARE(void) consoleLog2(char *level_str, char *file, char *func, int line, char *msg)
1447 {
1448  return console_log2(level_str, file, func, line, msg);
1449 }
1450 
1452 {
1453  return console_clean_log(msg);
1454 }
1455 
1456 SWITCH_DECLARE(void) console_log(char *level_str, char *msg)
1457 {
1459  if (level_str) {
1460  level = switch_log_str2level(level_str);
1461  if (level == SWITCH_LOG_INVALID) {
1462  level = SWITCH_LOG_DEBUG;
1463  }
1464  }
1465 
1467 }
1468 
1469 SWITCH_DECLARE(void) console_log2(char *level_str, char *file, char *func, int line, char *msg)
1470 {
1472  if (level_str) {
1473  level = switch_log_str2level(level_str);
1474  if (level == SWITCH_LOG_INVALID) {
1475  level = SWITCH_LOG_DEBUG;
1476  }
1477  }
1478  switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, level, "%s", switch_str_nil(msg));
1479 }
1480 
1482 {
1484 }
1485 
1486 SWITCH_DECLARE(bool) email(char *to, char *from, char *headers, char *body, char *file, char *convert_cmd, char *convert_ext)
1487 {
1488  if (switch_simple_email(to, from, headers, body, file, convert_cmd, convert_ext) == SWITCH_TRUE) {
1489  return true;
1490  }
1491  return false;
1492 }
1493 
1494 SWITCH_DECLARE(void) switch_msleep(unsigned ms)
1495 {
1496  switch_sleep(ms * 1000);
1497  return;
1498 }
1499 
1500 SWITCH_DECLARE(void) bridge(CoreSession &session_a, CoreSession &session_b)
1501 {
1502  switch_input_callback_function_t dtmf_func = NULL;
1503  switch_input_args_t args;
1504  switch_channel_t *channel_a = NULL, *channel_b = NULL;
1505  const char *err = "Channels not ready\n";
1506 
1507  if (session_a.allocated && session_a.session && session_b.allocated && session_b.session) {
1508  channel_a = switch_core_session_get_channel(session_a.session);
1509  channel_b = switch_core_session_get_channel(session_b.session);
1510 
1511  if (switch_channel_ready(channel_a) && switch_channel_ready(channel_b)) {
1512  session_a.begin_allow_threads();
1514  switch_channel_pre_answer(channel_a);
1515  }
1516 
1517  if (switch_channel_ready(channel_a) && switch_channel_ready(channel_b)) {
1518  args = session_a.get_cb_args(); // get the cb_args data structure for session a
1519  dtmf_func = args.input_callback; // get the call back function
1520  err = NULL;
1521  switch_ivr_multi_threaded_bridge(session_a.session, session_b.session, dtmf_func, args.buf, args.buf);
1522  }
1523  session_a.end_allow_threads();
1524  }
1525  }
1526 
1527  if (err) {
1529  }
1530 
1531 
1532 }
1533 
1535 {
1536  if (session_hungup) {
1537  switch_channel_t *channel = switch_core_session_get_channel(session_hungup);
1538  CoreSession *coresession = NULL;
1540 
1541  if ((coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession"))) {
1542  if (coresession->hook_state != state) {
1543  coresession->cause = switch_channel_get_cause(channel);
1544  coresession->hook_state = state;
1545  coresession->check_hangup_hook();
1546  }
1547  }
1548 
1549  return SWITCH_STATUS_SUCCESS;
1550  } else {
1551  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "hangup hook called with null session, something is horribly wrong\n");
1552  return SWITCH_STATUS_FALSE;
1553  }
1554 }
1555 
1556 
1558  void *input,
1559  switch_input_type_t itype,
1560  void *buf,
1561  unsigned int buflen) {
1562 
1563  switch_channel_t *channel = switch_core_session_get_channel(session_cb);
1564  CoreSession *coresession = NULL;
1565 
1566  coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession");
1567 
1568  if (!coresession) {
1569  return SWITCH_STATUS_FALSE;
1570  }
1571 
1572  return coresession->run_dtmf_callback(input, itype);
1573 }
1574 
1575 
1577 {
1578 
1581 
1582  return switch_ivr_process_fh(session, result, fhp);
1583 }
1584 
1585 /* For Emacs:
1586  * Local Variables:
1587  * mode:c
1588  * indent-tabs-mode:t
1589  * tab-width:4
1590  * c-basic-offset:4
1591  * End:
1592  * For VIM:
1593  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
1594  */
int flushEvents()
flush any pending events
switch_status_t switch_event_serialize_json(switch_event_t *event, char **str)
void console_clean_log(char *msg)
void consoleCleanLog(char *msg)
switch_time_t switch_micro_time_now(void)
Get the current epoch time in microseconds.
Definition: switch_time.c:311
void switch_core_session_hangup_state(switch_core_session_t *session, switch_bool_t force)
switch_channel_state_t switch_channel_get_state(switch_channel_t *channel)
Get the current state of a channel in the state engine.
#define switch_event_fire(event)
Fire an event filling in most of the arguements with obvious values.
Definition: switch_event.h:413
#define switch_channel_hangup(channel, hangup_cause)
Hangup a channel flagging it&#39;s state machine to end.
void switch_xml_free(_In_opt_ switch_xml_t xml)
frees the memory allocated for an switch_xml structure
#define switch_channel_answer(channel)
Answer a channel (initiate/acknowledge a successful connection)
void set_tts_parms(char *tts_name, char *voice_name)
Definition: switch_cpp.cpp:860
switch_status_t hanguphook(switch_core_session_t *session_hungup)
the actual hangup hook called back by freeswitch core which in turn gets the session and calls the ap...
#define switch_core_new_memory_pool(p)
Create a new sub memory pool from the core&#39;s master pool.
Definition: switch_core.h:633
#define SWITCH_SENSITIVE_DTMF_VARIABLE
Definition: switch_types.h:146
switch_status_t switch_ivr_process_fh(switch_core_session_t *session, const char *cmd, switch_file_handle_t *fhp)
Definition: switch_ivr.c:4052
#define SWITCH_CHANNEL_SESSION_LOG(x)
#define switch_core_session_force_locate(uuid_str)
Locate a session based on it&#39;s uuid even if the channel is not ready.
Definition: switch_core.h:941
void execute(const char *app, const char *data=NULL)
Definition: switch_cpp.cpp:785
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
Definition: switch_utils.h:700
void hangup(const char *cause="normal_clearing")
Definition: switch_cpp.cpp:746
switch_status_t switch_event_bind_removable(const char *id, switch_event_types_t event, const char *subclass_name, switch_event_callback_t callback, void *user_data, switch_event_node_t **node)
Bind an event callback to a specific event.
DTMF(char idigit, uint32_t iduration=SWITCH_DEFAULT_DTMF_DURATION)
Definition: switch_cpp.cpp:543
void consoleLog2(char *level_str, char *file, char *func, int line, char *msg)
#define SWITCH_CHANNEL_LOG
switch_status_t switch_ivr_read(switch_core_session_t *session, uint32_t min_digits, uint32_t max_digits, const char *prompt_audio_file, const char *var_name, char *digit_buffer, switch_size_t digit_buffer_length, uint32_t timeout, const char *valid_terminators, uint32_t digit_timeout)
void setGlobalVariable(char *var_name, char *var_val)
#define switch_event_del_header(_e, _h)
Definition: switch_event.h:212
const char * execute(const char *command, const char *data=NULL)
Definition: switch_cpp.cpp:237
switch_status_t switch_play_and_get_digits(switch_core_session_t *session, uint32_t min_digits, uint32_t max_digits, uint32_t max_tries, uint32_t timeout, const char *valid_terminators, const char *audio_file, const char *bad_input_audio_file, const char *var_name, char *digit_buffer, uint32_t digit_buffer_length, const char *digits_regex, uint32_t digit_timeout, const char *transfer_on_failure)
Play a sound and gather digits with the number of retries specified if the user doesn&#39;t give digits i...
void raw_write(const char *data, int len)
Definition: switch_cpp.cpp:606
#define switch_channel_set_state(channel, state)
Set the current state of a channel.
switch_status_t switch_channel_set_private(switch_channel_t *channel, const char *key, const void *private_info)
Set private data on channel.
const char * switch_channel_cause2str(_In_ switch_call_cause_t cause)
return a cause string for a given cause
Stream(void)
Definition: switch_cpp.cpp:560
const char * hangupCause()
switch_status_t switch_ivr_sleep(switch_core_session_t *session, uint32_t ms, switch_bool_t sync, switch_input_args_t *args)
Wait for time to pass for a specified number of milliseconds.
Definition: switch_ivr.c:127
void switch_channel_flush_dtmf(_In_ switch_channel_t *channel)
EventConsumer(const char *event_name=NULL, const char *subclass_name="", int len=5000)
Definition: switch_cpp.cpp:54
switch_event_types_t
Built-in Events.
bool fire(void)
Definition: switch_cpp.cpp:394
void execute(CoreSession *session, const char *name)
Definition: switch_cpp.cpp:216
int insertFile(const char *file, const char *insert_file, int sample_point)
Definition: switch_cpp.cpp:718
switch_status_t switch_ivr_wait_for_answer(switch_core_session_t *session, switch_core_session_t *peer_session)
void switch_sleep(switch_interval_time_t t)
Definition: switch_time.c:640
switch_status_t switch_queue_pop_timeout(switch_queue_t *queue, void **data, switch_interval_time_t timeout)
Definition: switch_apr.c:1248
switch_status_t switch_ivr_collect_digits_callback(switch_core_session_t *session, switch_input_args_t *args, uint32_t digit_timeout, uint32_t abs_timeout)
Wait for DTMF digits calling a pluggable callback function when digits are collected.
Definition: switch_ivr.c:1225
#define switch_channel_up(_channel)
switch_bool_t switch_core_running(void)
Definition: switch_core.c:2993
void switch_channel_event_set_data(_In_ switch_channel_t *channel, _In_ switch_event_t *event)
Add information about a given channel to an event object.
cJSON *const to
switch_bool_t
Definition: switch_types.h:441
char * getTime(void)
Definition: switch_cpp.cpp:256
switch_status_t switch_name_event(const char *name, switch_event_types_t *type)
return the event id that matches a given event name
Definition: switch_event.c:438
switch_status_t switch_core_session_print(switch_core_session_t *session, const char *data)
switch_priority_t
Priority Indication.
char * playAndDetectSpeech(char *file, char *engine, char *grammar)
Play a file and detect speech See API docs switch_ivr_play_and_detect_speech(...) ...
switch_bool_t switch_core_set_var_conditional(_In_z_ const char *varname, _In_opt_z_ const char *value, _In_opt_z_ const char *val2)
Conditionally add a global variable to the core.
switch_status_t switch_api_execute(const char *cmd, const char *arg, switch_core_session_t *session, switch_stream_handle_t *stream)
Execute a registered API command.
int print(char *txt)
Definition: switch_cpp.cpp:709
switch_status_t switch_ivr_menu_bind_action(switch_ivr_menu_t *menu, switch_ivr_action_t ivr_action, const char *arg, const char *bind)
switch_ivr_menu_bind_action: Bind a keystroke to an action.
#define switch_core_destroy_memory_pool(p)
Returns a subpool back to the main pool.
Definition: switch_core.h:642
void console_log2(char *level_str, char *file, char *func, int line, char *msg)
Representation of an event.
Definition: switch_event.h:80
switch_status_t process_callback_result(char *result)
#define switch_channel_ready(_channel)
void switch_core_set_variable(_In_z_ const char *varname, _In_opt_z_ const char *value)
Add a global variable to the core.
switch_status_t switch_event_add_body(switch_event_t *event, const char *fmt,...) PRINTF_FUNCTION(2
Add a body to an event.
const char * getType(void)
Definition: switch_cpp.cpp:511
const char *const const char *const const cJSON *const value
switch_status_t switch_queue_trypop(switch_queue_t *queue, void **data)
Definition: switch_apr.c:1264
bool merge(Event *to_merge)
Definition: switch_cpp.cpp:524
const char * getState()
switch_status_t switch_event_set_priority(switch_event_t *event, switch_priority_t priority)
Set the priority of an event.
Definition: switch_event.c:789
#define this_check(x)
Definition: switch_cpp.h:12
#define switch_channel_media_ready(_channel)
virtual ~DTMF()
Definition: switch_cpp.cpp:554
switch_status_t switch_ivr_insert_file(switch_core_session_t *session, const char *file, const char *insert_file, switch_size_t sample_point)
Definition: switch_ivr.c:4173
int setAutoHangup(bool val)
virtual bool begin_allow_threads()=0
void setPrivate(char *var, void *val)
Definition: switch_cpp.cpp:756
void consoleLog2(char *level_str, char *file, char *func, int line, char *msg)
switch_status_t switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, const char *file, switch_input_args_t *args)
play a file from the disk to the session
A representation of an XML tree.
Definition: switch_xml.h:79
#define SWITCH_DEFAULT_DTMF_DURATION
Definition: switch_types.h:116
const char * switch_channel_state_name(_In_ switch_channel_state_t state)
Render the name of the provided state enum.
switch_status_t switch_queue_pop(switch_queue_t *queue, void **data)
Definition: switch_apr.c:1243
char const int const cJSON_bool format
Definition: switch_cJSON.h:153
void waitForAnswer(CoreSession *calling_session)
switch_status_t switch_event_dup(switch_event_t **event, switch_event_t *todup)
Duplicate an event.
#define switch_event_create_subclass(_e, _eid, _sn)
Definition: switch_event.h:153
int sleep(int ms, int sync=0)
switch_status_t switch_ivr_menu_execute(switch_core_session_t *session, switch_ivr_menu_t *stack, char *name, void *obj)
Execute a menu.
uint32_t switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag)
Test for presence of given flag on a given channel.
bool addBody(const char *value)
Definition: switch_cpp.cpp:484
switch_input_type_t
switch_core_session_t * session
Definition: switch_cpp.h:224
switch_status_t switch_ivr_speak_text(switch_core_session_t *session, const char *tts_name, const char *voice_name, const char *text, switch_input_args_t *args)
Speak given text with given tts engine.
bool bridged()
#define zstr(x)
Definition: switch_utils.h:314
void setVariable(char *var, char *val)
Definition: switch_cpp.cpp:770
void hangupState(void)
Definition: switch_cpp.cpp:736
int speak(char *text)
Definition: switch_cpp.cpp:836
switch_status_t switch_ivr_session_transfer(_In_ switch_core_session_t *session, const char *extension, const char *dialplan, const char *context)
Transfer an existing session to another location.
int flushDigits()
flush any pending digits
char * getDigits(int maxdigits, char *terminators, int timeout)
Definition: switch_cpp.cpp:894
switch_event_t * event
Definition: switch_cpp.h:161
#define switch_core_session_execute_application(_a, _b, _c)
Execute an application on a session.
Definition: switch_core.h:1129
_Ret_ switch_channel_t * switch_core_session_get_channel(_In_ switch_core_session_t *session)
Retrieve a pointer to the channel object associated with a given session.
int chat_execute(const char *app, const char *data=NULL)
Definition: switch_cpp.cpp:344
switch_status_t switch_core_chat_send(const char *dest_proto, switch_event_t *message_event)
#define switch_clear_flag(obj, flag)
Clear a flag on an arbitrary object while locked.
Definition: switch_utils.h:724
switch_event_node_t * enodes[SWITCH_EVENT_ALL+1]
Definition: switch_cpp.h:193
int main(int argc, char *argv[])
Definition: fs_encode.c:56
void switch_channel_wait_for_state(switch_channel_t *channel, switch_channel_t *other_channel, switch_channel_state_t want_state)
#define sanity_check(x)
Definition: switch_cpp.h:14
void sayPhrase(const char *phrase_name, const char *phrase_data="", const char *phrase_lang=NULL)
int64_t switch_time_t
Definition: switch_apr.h:188
switch_status_t switch_ivr_collect_digits_count(switch_core_session_t *session, char *buf, switch_size_t buflen, switch_size_t maxdigits, const char *terminators, char *terminator, uint32_t first_timeout, uint32_t digit_timeout, uint32_t abs_timeout)
Wait for specified number of DTMF digits, untile terminator is received or until the channel hangs up...
Definition: switch_ivr.c:1342
switch_byte_t switch_byte_t * buf
void bridge(CoreSession &session_a, CoreSession &session_b)
bridge the audio of session_b into session_a
switch_status_t switch_ivr_play_and_detect_speech(switch_core_session_t *session, const char *file, const char *mod_name, const char *grammar, char **result, uint32_t input_timeout, switch_input_args_t *args)
play a file to the session while doing speech recognition.
void setHangupHook(void *hangup_func)
Set the hangup callback function.
#define true
Definition: cJSON.c:61
switch_status_t switch_ivr_multi_threaded_bridge(_In_ switch_core_session_t *session, _In_ switch_core_session_t *peer_session, switch_input_callback_function_t dtmf_callback, void *session_data, void *peer_session_data)
Bridge Audio from one session to another.
void consoleLog(char *level_str, char *msg)
void switch_event_merge(switch_event_t *event, switch_event_t *tomerge)
bool mediaReady()
switch_log_level_t switch_log_str2level(_In_z_ const char *str)
Return the level number of the specified log level name.
char * switch_event_get_body(switch_event_t *event)
Retrieve the body value from an event.
Definition: switch_event.c:867
switch_status_t switch_ivr_stop_detect_speech(switch_core_session_t *session)
Stop background Speech detection on a session.
switch_status_t switch_ivr_pause_detect_speech(switch_core_session_t *session)
Pause background Speech detection on a session.
#define switch_channel_get_variable(_c, _v)
int streamFile(char *file, int starting_sample_count=0)
Play a file that resides on disk into the channel.
switch_status_t switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
Add a string header to an event.
int globalSetVariable(const char *var, const char *val, const char *val2)
void set_tts_params(char *tts_name, char *voice_name)
Definition: switch_cpp.cpp:871
const char * switch_event_name(switch_event_types_t event)
Render the name of an event id enumeration.
Definition: switch_event.c:430
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
Definition: switch_utils.h:885
switch_status_t dtmf_callback(switch_core_session_t *session_cb, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
switch_input_callback_function_t input_callback
switch_status_t(* switch_input_callback_function_t)(switch_core_session_t *session, void *input, switch_input_type_t input_type, void *buf, unsigned int buflen)
void sendEvent(Event *sendME)
Definition: switch_cpp.cpp:823
const char * getVariable(char *var)
Definition: switch_cpp.cpp:778
bool delHeader(const char *header_name)
Definition: switch_cpp.cpp:465
#define SWITCH_DECLARE_CONSTRUCTOR
#define SWITCH_TIME_T_FMT
Event * pop(int block=0, int timeout=0)
Definition: switch_cpp.cpp:96
IVRMenu(IVRMenu *main, const char *name, const char *greeting_sound, const char *short_greeting_sound, const char *invalid_sound, const char *exit_sound, const char *transfer_sound, const char *confirm_macro, const char *confirm_key, const char *tts_engine, const char *tts_voice, int confirm_attempts, int inter_timeout, int digit_len, int timeout, int max_failures, int max_timeouts)
Definition: switch_cpp.cpp:162
switch_call_cause_t switch_channel_str2cause(_In_ const char *str)
return a cause code for a given string
virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype)=0
#define SWITCH_CHANNEL_LOG_CLEAN
bool answered()
uintptr_t switch_size_t
switch_status_t switch_event_create_json(switch_event_t **event, const char *json)
switch_status_t switch_ivr_detect_speech_load_grammar(switch_core_session_t *session, const char *grammar, const char *name)
Load a grammar on a background speech detection handle.
virtual void destroy(void)
switch_byte_t switch_byte_t uint32_t buflen
int64_t switch_interval_time_t
Definition: switch_apr.h:191
switch_status_t switch_ivr_detect_speech_disable_grammar(switch_core_session_t *session, const char *name)
Disable a grammar on a background speech detection handle.
#define SWITCH_STANDARD_STREAM(s)
switch_status_t switch_ivr_detect_speech(switch_core_session_t *session, const char *mod_name, const char *grammar, const char *name, const char *dest, switch_asr_handle_t *ah)
Engage background Speech detection on a session.
switch_call_cause_t cause
Definition: switch_cpp.h:231
switch_channel_state_t hook_state
Definition: switch_cpp.h:230
uint32_t node_index
Definition: switch_cpp.h:194
switch_status_t switch_ivr_detect_speech_unload_grammar(switch_core_session_t *session, const char *name)
Unload a grammar on a background speech detection handle.
const char * serialize(const char *format=NULL)
Definition: switch_cpp.cpp:358
switch_status_t switch_ivr_resume_detect_speech(switch_core_session_t *session)
Resume background Speech detection on a session.
#define this_check_void()
Definition: switch_cpp.h:13
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
char * switch_core_session_get_uuid(_In_ switch_core_session_t *session)
Retrieve the unique identifier from a session.
switch_status_t switch_channel_set_variable_var_check(switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check)
#define sanity_check_noreturn
Definition: switch_cpp.h:15
switch_status_t switch_ivr_record_file(_In_ switch_core_session_t *session, _In_ switch_file_handle_t *fh, _In_z_ const char *file, _In_opt_ switch_input_args_t *args, _In_ uint32_t limit)
record a file from the session to a file
#define switch_str_nil(s)
Make a null string a blank string instead.
Definition: switch_utils.h:993
switch_status_t switch_ivr_originate(switch_core_session_t *session, switch_core_session_t **bleg, switch_call_cause_t *cause, const char *bridgeto, uint32_t timelimit_sec, const switch_state_handler_table_t *table, const char *cid_name_override, const char *cid_num_override, switch_caller_profile_t *caller_profile_override, switch_event_t *ovars, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause, switch_dial_handle_t *dh)
Make an outgoing call.
int recordFile(char *file_name, int time_limit=0, int silence_threshold=0, int silence_hits=0)
Record to a file.
void switch_msleep(unsigned ms)
#define SWITCH_DECLARE_NONSTD(type)
char * read(int min_digits, int max_digits, const char *prompt_audio_file, int timeout, const char *valid_terminators, int digit_timeout=0)
Definition: switch_cpp.cpp:946
static int switch_channel_var_true(switch_channel_t *channel, const char *variable)
Event(const char *type, const char *subclass_name=NULL)
Definition: switch_cpp.cpp:294
switch_channel_state_t
Channel States (these are the defaults, CS_SOFT_EXECUTE, CS_EXCHANGE_MEDIA, and CS_CONSUME_MEDIA are ...
bool email(char *to, char *from, char *headers, char *body, char *file, char *convert_cmd, char *convert_ext)
bool setPriority(switch_priority_t priority=SWITCH_PRIORITY_NORMAL)
Definition: switch_cpp.cpp:422
switch_status_t switch_ivr_menu_init(switch_ivr_menu_t **new_menu, switch_ivr_menu_t *main, const char *name, const char *greeting_sound, const char *short_greeting_sound, const char *invalid_sound, const char *exit_sound, const char *transfer_sound, const char *confirm_macro, const char *confirm_key, const char *tts_engine, const char *tts_voice, int confirm_attempts, int inter_timeout, int digit_len, int timeout, int max_failures, int max_timeouts, switch_memory_pool_t *pool)
Create a new menu object.
switch_stream_handle_write_function_t write_function
#define switch_channel_down(_channel)
switch_status_t
Common return values.
void * switch_channel_get_private(switch_channel_t *channel, const char *key)
Retrieve private from a given channel.
switch_ivr_menu_t * menu
Definition: switch_cpp.h:85
switch_status_t switch_core_session_read_lock_hangup(_In_ switch_core_session_t *session)
Acquire a read lock on the session.
void setDTMFCallback(void *cbfunc, char *funcargs)
set a DTMF callback function
Definition: switch_cpp.cpp:800
switch_status_t switch_core_session_dequeue_event(_In_ switch_core_session_t *session, _Out_ switch_event_t **event, switch_bool_t force)
DE-Queue an event on a given session.
char * getGlobalVariable(char *var_name)
switch_queue_t * events
Definition: switch_cpp.h:188
switch_status_t switch_core_session_receive_event(_In_ switch_core_session_t *session, _Inout_ switch_event_t **event)
Send an event to a session translating it to it&#39;s native message format.
switch_status_t switch_queue_interrupt_all(switch_queue_t *queue)
Definition: switch_apr.c:1269
switch_status_t switch_ivr_detect_speech_disable_all_grammars(switch_core_session_t *session)
Disable all grammars on a background speech detection handle.
static void event_handler(switch_event_t *event)
Definition: switch_cpp.cpp:40
const switch_input_args_t & get_cb_args() const
Get the callback function arguments associated with this session.
Definition: switch_cpp.h:400
Main Library Header.
void * getPrivate(char *var)
Definition: switch_cpp.cpp:763
int transfer(char *extension, char *dialplan=NULL, char *context=NULL)
Definition: switch_cpp.cpp:933
switch_ivr_action_t
Definition: switch_ivr.h:806
switch_status_t switch_ivr_set_param_detect_speech(switch_core_session_t *session, const char *name, const char *val)
#define SWITCH_DECLARE(type)
switch_bool_t switch_simple_email(const char *to, const char *from, const char *headers, const char *body, const char *file, const char *convert_cmd, const char *convert_ext)
#define switch_event_get_header(_e, _h)
Definition: switch_event.h:172
bool running(void)
switch_call_direction_t switch_channel_direction(switch_channel_t *channel)
switch_status_t switch_ivr_menu_str2action(const char *action_name, switch_ivr_action_t *action)
switch_status_t switch_core_execute_chat_app(switch_event_t *message, const char *app, const char *data)
switch_status_t switch_queue_trypush(switch_queue_t *queue, void *data)
Definition: switch_apr.c:1279
#define init_vars()
Definition: switch_cpp.h:16
virtual void check_hangup_hook()=0
Callback to the language specific hangup callback.
switch_status_t switch_ivr_detect_speech_enable_grammar(switch_core_session_t *session, const char *name)
Enable a grammar on a background speech detection handle.
const char * executeString(const char *command)
Definition: switch_cpp.cpp:265
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
Definition: switch_utils.h:693
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
#define SWITCH_VA_NONE
switch_status_t switch_ivr_detect_speech_init(switch_core_session_t *session, const char *mod_name, const char *dest, switch_asr_handle_t *ah)
Initialize background Speech detection on a session, so that parameters can be set, and grammars loaded. After calling this function, it is possible to call switch_ivr_set_param_detect_speech() to set recognition parameters. Calling switch_ivr_detect_speech_load_grammar() starts the speech recognition.
switch_memory_pool_t * pool
Definition: switch_cpp.h:185
bool addHeader(const char *header_name, const char *value)
Definition: switch_cpp.cpp:452
#define switch_ivr_phrase_macro(session, macro_name, data, lang, args)
Definition: switch_ivr.h:936
API(CoreSession *s=NULL)
Definition: switch_cpp.cpp:222
const char *const name
Definition: switch_cJSON.h:250
switch_status_t switch_queue_create(switch_queue_t **queue, unsigned int queue_capacity, switch_memory_pool_t *pool)
Definition: switch_apr.c:1233
void bindAction(char *action, const char *arg, const char *bind)
Definition: switch_cpp.cpp:202
void switch_event_destroy(switch_event_t **event)
Destroy an event.
char * getBody(void)
Definition: switch_cpp.cpp:497
const char * getHeader(const char *header_name)
Definition: switch_cpp.cpp:435
void * bind_user_data
Definition: switch_event.h:96
#define switch_assert(expr)
char * playAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, char *terminators, char *audio_files, char *bad_input_audio_files, char *digits_regex, const char *var_name=NULL, int digit_timeout=0, const char *transfer_on_failure=NULL)
Play a file into channel and collect dtmfs.
Definition: switch_cpp.cpp:975
const char * get_data(void)
Definition: switch_cpp.cpp:612
switch_status_t switch_ivr_say(switch_core_session_t *session, const char *tosay, const char *module_name, const char *say_type, const char *say_method, const char *say_gender, switch_input_args_t *args)
Definition: switch_ivr.c:3667
switch_status_t switch_ivr_generate_xml_cdr(switch_core_session_t *session, switch_xml_t *xml_cdr)
Generate an XML CDR report.
Definition: switch_ivr.c:2862
#define switch_channel_pre_answer(channel)
Indicate progress on a channel to attempt early media.
switch_status_t switch_event_serialize(switch_event_t *event, char **str, switch_bool_t encode)
char * switch_channel_get_name(switch_channel_t *channel)
Retrieve the name of a given channel.
SWITCH_BEGIN_EXTERN_C char * switch_mprintf(const char *zFormat,...)
void console_log(char *level_str, char *msg)
void detectSpeech(char *arg0, char *arg1=NULL, char *arg2=NULL, char *arg3=NULL)
memset(buf, 0, buflen)
int chat_send(const char *dest_proto=NULL)
Definition: switch_cpp.cpp:349
void setEventData(Event *e)
Definition: switch_cpp.cpp:689
int originate(CoreSession *a_leg_session, char *dest, int timeout=60, switch_state_handler_table_t *handlers=NULL)
Set attributes of caller data for purposes of outgoing calls.
switch_log_level_t
Log Level Enumeration.
virtual bool end_allow_threads()=0
switch_status_t switch_ivr_detect_speech_start_input_timers(switch_core_session_t *session)
Start input timers on a background speech detection handle.
char * switch_core_get_variable_dup(_In_z_ const char *varname)
int collectDigits(int abs_timeout)
Definition: switch_cpp.cpp:881
void consoleLog(char *level_str, char *msg)
switch_call_cause_t switch_channel_get_cause(_In_ switch_channel_t *channel)
return the cause code for a given channel
void say(const char *tosay, const char *module_name, const char *say_type, const char *say_method, const char *say_gender=NULL)
#define switch_xml_toxml(xml, prn_header)
Converts an switch_xml structure back to xml in html format. Returns a string of html data that \ mus...
Definition: switch_xml.h:224
void write(const char *data)
Definition: switch_cpp.cpp:600
const char * read(int *len)
Definition: switch_cpp.cpp:582
switch_status_t switch_ivr_menu_stack_free(switch_ivr_menu_t *stack)
free a stack of menu objects.
switch_xml_t switch_event_xmlize(switch_event_t *event, const char *fmt,...) PRINTF_FUNCTION(2
Render a XML representation of an event suitable for printing or network transport.
switch_status_t switch_event_unbind(switch_event_node_t **node)
Unbind a bound event consumer.
char * getXMLCDR()
Definition: switch_cpp.cpp:671
int bind(const char *event_name, const char *subclass_name="")
Definition: switch_cpp.cpp:67
int preAnswer()
Definition: switch_cpp.cpp:727