FreeSWITCH API Documentation  1.7.0
switch_core.h
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  * Luke Dashjr <luke@openmethods.com> (OpenMethods, LLC)
28  * Joseph Sullivan <jossulli@amazon.com>
29  * Emmanuel Schmidbauer <eschmidbauer@gmail.com>
30  *
31  * switch_core.h -- Core Library
32  *
33  */
34 /*! \file switch_core.h
35  \brief Core Library
36 
37  This module is the main core library and is the intended location of all fundamental operations.
38 */
39 
40 #ifndef SWITCH_CORE_H
41 #define SWITCH_CORE_H
42 
43 #include <switch.h>
44 
46 #define SWITCH_MAX_CORE_THREAD_SESSION_OBJS 128
47 #define SWITCH_MAX_STREAMS 128
49  uint32_t mms;
50  uint32_t ms;
51  uint32_t sec;
52  uint32_t min;
53  uint32_t hr;
54  uint32_t day;
55  uint32_t yr;
56 };
57 
59  char *app;
60  char *arg;
63 };
64 
65 typedef struct switch_thread_data_s {
67  void *obj;
68  int alloc;
71 
72 typedef struct switch_hold_record_s {
75  char *uuid;
78 
79 typedef struct device_uuid_node_s {
80  char *uuid;
90 
91 typedef struct switch_device_stats_s {
92  uint32_t total;
93  uint32_t total_in;
94  uint32_t total_out;
95  uint32_t offhook;
96  uint32_t offhook_in;
97  uint32_t offhook_out;
98  uint32_t active;
99  uint32_t active_in;
100  uint32_t active_out;
101  uint32_t held;
102  uint32_t held_in;
103  uint32_t held_out;
104  uint32_t unheld;
105  uint32_t unheld_in;
106  uint32_t unheld_out;
107  uint32_t hup;
108  uint32_t hup_in;
109  uint32_t hup_out;
110  uint32_t ringing;
111  uint32_t ringing_in;
112  uint32_t ringing_out;
113  uint32_t early;
114  uint32_t early_in;
115  uint32_t early_out;
116  uint32_t ring_wait;
118 
119 
120 typedef struct switch_device_record_s {
121  char *device_id;
122  char *uuid;
123  int refs;
140  void *user_data;
142 
144 
145 
146 #define DTLS_SRTP_FNAME "dtls-srtp"
147 #define MAX_FPLEN 64
148 #define MAX_FPSTRLEN 192
149 
150 typedef struct dtls_fp_s {
151  uint32_t len;
152  uint8_t data[MAX_FPLEN+1];
153  char *type;
156 
157 typedef enum {
158  DTLS_TYPE_CLIENT = (1 << 0),
159  DTLS_TYPE_SERVER = (1 << 1),
160  DTLS_TYPE_RTP = (1 << 2),
161  DTLS_TYPE_RTCP = (1 << 3)
162 } dtls_type_t;
163 
164 typedef enum {
171 } dtls_state_t;
172 
173 #define MESSAGE_STAMP_FFL(_m) _m->_file = __FILE__; _m->_func = __SWITCH_FUNC__; _m->_line = __LINE__
174 
175 #define MESSAGE_STRING_ARG_MAX 10
176 /*! \brief A message object designed to allow unlike technologies to exchange data */
178  /*! uuid of the sender (for replies) */
179  char *from;
180  /*! enumeration of the type of message */
182 
183  /*! optional numeric arg */
185  /*! optional string arg */
186  const char *string_arg;
187  /*! optional string arg */
189  /*! optional arbitrary pointer arg */
190  void *pointer_arg;
191  /*! optional arbitrary pointer arg's size */
193 
194  /*! optional numeric reply */
196  /*! optional string reply */
198  /*! optional string reply */
200  /*! optional arbitrary pointer reply */
202  /*! optional arbitrary pointer reply's size */
204  /*! message flags */
206  const char *_file;
207  const char *_func;
208  int _line;
211 };
212 
213 /*! \brief A generic object to pass as a thread's session object to allow mutiple arguements and a pool */
215  /*! status of the thread */
216  int running;
217  /*! mutex */
219  /*! array of void pointers to pass mutiple data objects */
221  /*! a pointer to a memory pool if the thread has it's own pool */
224 };
225 
226 struct switch_core_session;
227 struct switch_core_runtime;
229 
230 
231 static inline void *switch_must_malloc(size_t _b)
232 {
233  void *m = malloc(_b);
234  switch_assert(m);
235  return m;
236 }
237 
238 static inline void *switch_must_realloc(void *_b, size_t _z)
239 {
240  void *m = realloc(_b, _z);
241  switch_assert(m);
242  return m;
243 }
244 
245 static inline char *switch_must_strdup(const char *_s)
246 {
247  char *s = strdup(_s);
248  switch_assert(s);
249  return s;
250 }
251 
252 
253 /*!
254  \defgroup core1 Core Library
255  \ingroup FREESWITCH
256  \{
257 */
258 
259 ///\defgroup mb1 Media Bugs
260 ///\ingroup core1
261 ///\{
262 
263 
264 SWITCH_DECLARE(void) switch_core_screen_size(int *x, int *y);
267 
270 
271 #define switch_core_session_get_name(_s) switch_channel_get_name(switch_core_session_get_channel(_s))
272 
274 
276  const char *function, switch_media_bug_exec_cb_t cb, void *user_data);
278 SWITCH_DECLARE(uint32_t) switch_core_media_bug_count(switch_core_session_t *orig_session, const char *function);
283 
284 /*!
285  \brief Add a media bug to the session
286  \param session the session to add the bug to
287  \param callback a callback for events
288  \param user_data arbitrary user data
289  \param stop_time absolute time at which the bug is automatically removed (or 0)
290  \param flags flags to choose the stream
291  \param new_bug pointer to assign new bug to
292  \return SWITCH_STATUS_SUCCESS if the operation was a success
293 */
295  _In_ const char *function,
296  _In_ const char *target,
298  _In_opt_ void *user_data,
299  _In_ time_t stop_time, _In_ switch_media_bug_flag_t flags, _Out_ switch_media_bug_t **new_bug);
300 
301 /*!
302  \brief Pause a media bug on the session
303  \param session the session to pause the bug on sets CF_PAUSE_BUGS flag
304 */
306 
307 /*!
308  \brief Resume a media bug on the session
309  \param session the session to resume the bug on, clears CF_PAUSE_BUGS flag
310 */
312 
314 
315 /*!
316  \brief Obtain private data from a media bug
317  \param bug the bug to get the data from
318  \return the private data
319 */
321 
322 /*!
323  \brief Obtain a replace frame from a media bug
324  \param bug the bug to get the data from
325 */
327 
328 
331 
332 
334 
335 /*!
336  \brief Set a return replace frame
337  \param bug the bug to set the frame on
338  \param frame the frame to set
339 */
341 
342 /*!
343  \brief Obtain a replace frame from a media bug
344  \param bug the bug to get the data from
345 */
348 /*!
349  \brief Obtain the session from a media bug
350  \param bug the bug to get the data from
351 */
353 
354 /*!
355  \brief Test for the existance of a flag on an media bug
356  \param bug the object to test
357  \param flag the or'd list of flags to test
358  \return true value if the object has the flags defined
359 */
363 
364 /*!
365  \brief Set a return replace frame
366  \param bug the bug to set the frame on
367  \param frame the frame to set
368 */
370 
371 SWITCH_DECLARE(uint32_t) switch_core_cpu_count(void);
372 
373 /*!
374  \brief Remove a media bug from the session
375  \param session the session to remove the bug from
376  \param bug bug to remove
377  \return SWITCH_STATUS_SUCCESS if the operation was a success
378 */
379 
382 
383 /*!
384  \brief Remove media bug callback
385  \param bug bug to remove
386  \param callback callback to remove
387  \return SWITCH_STATUS_SUCCESS if the operation was a success
388 */
390 
391 /*!
392  \brief Close and destroy a media bug
393  \param bug bug to remove
394  \return SWITCH_STATUS_SUCCESS if the operation was a success
395 */
397 /*!
398  \brief Remove all media bugs from the session
399  \param session the session to remove the bugs from
400  \return SWITCH_STATUS_SUCCESS if the operation was a success
401 */
403 
404 #define switch_core_media_bug_remove_all(_s) switch_core_media_bug_remove_all_function(_s, NULL)
405 
408 
410  switch_media_bug_callback_t callback, void * (*user_data_dup_func) (switch_core_session_t *, void *));
411 
412 
413 /*!
414  \brief Read a frame from the bug
415  \param bug the bug to read from
416  \param frame the frame to write the data to
417  \return the amount of data
418 */
420 
421 /*!
422  \brief Flush the read and write buffers for the bug
423  \param bug the bug to flush the read and write buffers on
424 */
426 
427 /*!
428  \brief Flush the read/write buffers for all media bugs on the session
429  \param session the session to flush the read/write buffers for all media bugs on the session
430 */
431 SWITCH_DECLARE(switch_status_t) switch_core_media_bug_flush_all(_In_ switch_core_session_t *session);
432 
434 
435 ///\}
436 
437 ///\defgroup pa1 Port Allocation
438 ///\ingroup core1
439 ///\{
440 
441 /*!
442  \brief Initilize the port allocator
443  \param start the starting port
444  \param end the ending port
445  \param flags flags to change allocator behaviour (e.g. only even/odd portnumbers)
446  \param new_allocator new pointer for the return value
447  \return SWITCH_STATUS_SUCCESS if the operation was a success
448 */
453 
454 /*!
455  \brief Get a port from the port allocator
456  \param alloc the allocator object
457  \param port_ptr a pointer to the port
458  \return SUCCESS
459 */
461 
462 /*!
463  \brief Return unused port to the port allocator
464  \param alloc the allocator object
465  \param port the port
466  \return SUCCESS
467 */
469 
470 /*!
471  \brief destroythe port allocator
472  \param alloc the allocator object
473 */
475 ///\}
476 
477 
479 
480 ///\defgroup ss Startup/Shutdown
481 ///\ingroup core1
482 ///\{
483 /*!
484  \brief Initilize the core
485  \param console optional FILE stream for output
486  \param flags core flags
487  \param err a pointer to set any errors to
488  \note to be called at application startup
489 */
491 
492 /*!
493  \brief Initilize the core and load modules
494  \param console optional FILE stream for output
495  \param flags core flags
496  \param err a pointer to set any errors to
497  \note to be called at application startup instead of switch_core_init. Includes module loading.
498 */
500 
501 /*!
502  \brief Set/Get Session Limit
503  \param new_limit new value (if > 0)
504  \return the current session limit
505 */
506 SWITCH_DECLARE(uint32_t) switch_core_session_limit(_In_ uint32_t new_limit);
507 
508 /*!
509  \brief Set/Get Session Rate Limit
510  \param new_limit new value (if > 0)
511  \return the current session rate limit
512 */
513 SWITCH_DECLARE(uint32_t) switch_core_sessions_per_second(_In_ uint32_t new_limit);
514 
515 /*!
516  \brief Destroy the core
517  \note to be called at application shutdown
518 */
520 ///\}
521 
522 
523 ///\defgroup rwl Read/Write Locking
524 ///\ingroup core1
525 ///\{
526 
527 
528 SWITCH_DECLARE(switch_status_t) switch_core_session_io_read_lock(switch_core_session_t *session);
529 SWITCH_DECLARE(switch_status_t) switch_core_session_io_write_lock(switch_core_session_t *session);
530 SWITCH_DECLARE(switch_status_t) switch_core_session_io_rwunlock(switch_core_session_t *session);
531 
532 #ifdef SWITCH_DEBUG_RWLOCKS
533 SWITCH_DECLARE(switch_status_t) switch_core_session_perform_read_lock(_In_ switch_core_session_t *session, const char *file, const char *func, int line);
534 #endif
535 
536 /*!
537  \brief Acquire a read lock on the session
538  \param session the session to acquire from
539  \return success if it is safe to read from the session
540 */
541 #ifdef SWITCH_DEBUG_RWLOCKS
542 #define switch_core_session_read_lock(session) switch_core_session_perform_read_lock(session, __FILE__, __SWITCH_FUNC__, __LINE__)
543 #else
544 SWITCH_DECLARE(switch_status_t) switch_core_session_read_lock(_In_ switch_core_session_t *session);
545 #endif
546 
547 
548 #ifdef SWITCH_DEBUG_RWLOCKS
549 SWITCH_DECLARE(switch_status_t) switch_core_session_perform_read_lock_hangup(_In_ switch_core_session_t *session, const char *file, const char *func,
550  int line);
551 #endif
552 
553 /*!
554  \brief Acquire a read lock on the session
555  \param session the session to acquire from
556  \return success if it is safe to read from the session
557 */
558 #ifdef SWITCH_DEBUG_RWLOCKS
559 #define switch_core_session_read_lock_hangup(session) switch_core_session_perform_read_lock_hangup(session, __FILE__, __SWITCH_FUNC__, __LINE__)
560 #else
562 #endif
563 
564 
565 #ifdef SWITCH_DEBUG_RWLOCKS
566 SWITCH_DECLARE(void) switch_core_session_perform_write_lock(_In_ switch_core_session_t *session, const char *file, const char *func, int line);
567 #endif
568 
569 /*!
570  \brief Acquire a write lock on the session
571  \param session the session to acquire from
572 */
573 #ifdef SWITCH_DEBUG_RWLOCKS
574 #define switch_core_session_write_lock(session) switch_core_session_perform_write_lock(session, __FILE__, __SWITCH_FUNC__, __LINE__)
575 #else
576 SWITCH_DECLARE(void) switch_core_session_write_lock(_In_ switch_core_session_t *session);
577 #endif
578 
579 #ifdef SWITCH_DEBUG_RWLOCKS
580 SWITCH_DECLARE(void) switch_core_session_perform_rwunlock(_In_ switch_core_session_t *session, const char *file, const char *func, int line);
581 #endif
582 
583 /*!
584  \brief Unlock a read or write lock on as given session
585  \param session the session
586 */
587 #ifdef SWITCH_DEBUG_RWLOCKS
588 #define switch_core_session_rwunlock(session) switch_core_session_perform_rwunlock(session, __FILE__, __SWITCH_FUNC__, __LINE__)
589 #else
590 SWITCH_DECLARE(void) switch_core_session_rwunlock(_In_ switch_core_session_t *session);
591 #endif
592 
593 ///\}
594 
595 ///\defgroup sh State Handlers
596 ///\ingroup core1
597 ///\{
598 /*!
599  \brief Add a global state handler
600  \param state_handler a state handler to add
601  \return the current index/priority of this handler
602 */
604 
605 /*!
606  \brief Remove a global state handler
607  \param state_handler the state handler to remove
608 */
610 
611 /*!
612  \brief Access a state handler
613  \param index the desired index to access
614  \return the desired state handler table or NULL when it does not exist.
615 */
617 ///\}
618 
620 
622  _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
623 
624 ///\defgroup memp Memory Pooling/Allocation
625 ///\ingroup core1
626 ///\{
627 /*!
628  \brief Create a new sub memory pool from the core's master pool
629  \return SWITCH_STATUS_SUCCESS on success
630 */
631 #define switch_core_new_memory_pool(p) switch_core_perform_new_memory_pool(p, __FILE__, __SWITCH_FUNC__, __LINE__)
632 
635  _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
636 /*!
637  \brief Returns a subpool back to the main pool
638  \return SWITCH_STATUS_SUCCESS on success
639 */
640 #define switch_core_destroy_memory_pool(p) switch_core_perform_destroy_memory_pool(p, __FILE__, __SWITCH_FUNC__, __LINE__)
641 
642 
643 SWITCH_DECLARE(void) switch_core_memory_pool_set_data(switch_memory_pool_t *pool, const char *key, void *data);
645 
646 
647 /*!
648  \brief Start the session's state machine
649  \param session the session on which to start the state machine
650 */
651 SWITCH_DECLARE(void) switch_core_session_run(_In_ switch_core_session_t *session);
652 
653 /*!
654  \brief determine if the session's state machine is running
655  \param session the session on which to check
656 */
657 SWITCH_DECLARE(unsigned int) switch_core_session_running(_In_ switch_core_session_t *session);
658 SWITCH_DECLARE(unsigned int) switch_core_session_started(_In_ switch_core_session_t *session);
659 
660 SWITCH_DECLARE(void *) switch_core_perform_permanent_alloc(_In_ switch_size_t memory, _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
661 
662 
663 /*!
664  \brief Allocate memory from the main pool with no intention of returning it
665  \param _memory the number of bytes to allocate
666  \return a void pointer to the allocated memory
667  \note this memory never goes out of scope until the core is destroyed
668 */
669 #define switch_core_permanent_alloc(_memory) switch_core_perform_permanent_alloc(_memory, __FILE__, __SWITCH_FUNC__, __LINE__)
670 
671 
673  _In_z_ const char *func, _In_ int line);
674 
675 /*!
676  \brief Allocate memory directly from a memory pool
677  \param _pool the memory pool to allocate from
678  \param _mem the number of bytes to allocate
679  \remark the memory returned has been memset to zero
680  \return a void pointer to the allocated memory
681 */
682 #define switch_core_alloc(_pool, _mem) switch_core_perform_alloc(_pool, _mem, __FILE__, __SWITCH_FUNC__, __LINE__)
683 
684  _Ret_ SWITCH_DECLARE(void *) switch_core_perform_session_alloc(_In_ switch_core_session_t *session, _In_ switch_size_t memory, const char *file,
685  const char *func, int line);
686 
687 /*!
688  \brief Allocate memory from a session's pool
689  \param _session the session to request memory from
690  \param _memory the amount of memory to allocate
691  \return a void pointer to the newly allocated memory
692  \note the memory will be in scope as long as the session exists
693 */
694 #define switch_core_session_alloc(_session, _memory) switch_core_perform_session_alloc(_session, _memory, __FILE__, __SWITCH_FUNC__, __LINE__)
695 
696 
697 
698 SWITCH_DECLARE(char *) switch_core_perform_permanent_strdup(_In_z_ const char *todup, _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
699 
700 /*!
701  \brief Copy a string using permanent memory allocation
702  \param _todup the string to duplicate
703  \return a pointer to the newly duplicated string
704 */
705 #define switch_core_permanent_strdup(_todup) switch_core_perform_permanent_strdup(_todup, __FILE__, __SWITCH_FUNC__, __LINE__)
706 
707 
708 SWITCH_DECLARE(char *) switch_core_perform_session_strdup(_In_ switch_core_session_t *session, _In_z_ const char *todup, _In_z_ const char *file,
709  _In_z_ const char *func, _In_ int line);
710 
711 /*!
712  \brief Copy a string using memory allocation from a session's pool
713  \param _session a session to use for allocation
714  \param _todup the string to duplicate
715  \return a pointer to the newly duplicated string
716 */
717 #define switch_core_session_strdup(_session, _todup) switch_core_perform_session_strdup(_session, _todup, __FILE__, __SWITCH_FUNC__, __LINE__)
718 
719 
720 SWITCH_DECLARE(char *) switch_core_perform_strdup(_In_ switch_memory_pool_t *pool, _In_z_ const char *todup, _In_z_ const char *file,
721  _In_z_ const char *func, _In_ int line);
722 
723 /*!
724  \brief Copy a string using memory allocation from a given pool
725  \param _pool the pool to use for allocation
726  \param _todup the string to duplicate
727  \return a pointer to the newly duplicated string
728 */
729 #define switch_core_strdup(_pool, _todup) switch_core_perform_strdup(_pool, _todup, __FILE__, __SWITCH_FUNC__, __LINE__)
730 
731 /*!
732  \brief printf-style style printing routine. The data is output to a string allocated from the session
733  \param session a session to use for allocation
734  \param fmt The format of the string
735  \param ... The arguments to use while printing the data
736  \return The new string
737 */
738 SWITCH_DECLARE(char *) switch_core_session_sprintf(_In_ switch_core_session_t *session, _In_z_ _Printf_format_string_ const char *fmt, ...);
739 
740 /*!
741  \brief printf-style style printing routine. The data is output to a string allocated from the session
742  \param session a session to use for allocation
743  \param fmt The format of the string
744  \param ap The arguments to use while printing the data
745  \return The new string
746 */
747 #ifndef SWIG
748 SWITCH_DECLARE(char *) switch_core_session_vsprintf(switch_core_session_t *session, const char *fmt, va_list ap);
749 #endif
750 
751 /*!
752  \brief printf-style style printing routine. The data is output to a string allocated from the pool
753  \param pool a pool to use for allocation
754  \param fmt The format of the string
755  \param ... The arguments to use while printing the data
756  \return The new string
757 */
759 
760 /*!
761  \brief printf-style style printing routine. The data is output to a string allocated from the pool
762  \param pool a pool to use for allocation
763  \param fmt The format of the string
764  \param ap The arguments to use while printing the data
765  \return The new string
766 */
767 #ifndef SWIG
768 SWITCH_DECLARE(char *) switch_core_vsprintf(switch_memory_pool_t *pool, _In_z_ _Printf_format_string_ const char *fmt, va_list ap);
769 #endif
770 
771 /*!
772  \brief Retrieve the memory pool from a session
773  \param session the session to retrieve the pool from
774  \return the session's pool
775  \note to be used sparingly
776 */
777 SWITCH_DECLARE(switch_memory_pool_t *) switch_core_session_get_pool(_In_ switch_core_session_t *session);
778 ///\}
779 
780 SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_xml(switch_endpoint_interface_t *endpoint_interface,
781  switch_memory_pool_t **pool, switch_xml_t xml);
782 
783 ///\defgroup sessm Session Creation / Management
784 ///\ingroup core1
785 ///\{
786 /*!
787  \brief Allocate and return a new session from the core
788  \param endpoint_interface the endpoint interface the session is to be based on
789  \param pool the pool to use for the allocation (a new one will be used if NULL)
790  \return the newly created session
791 */
792 SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(_In_ switch_endpoint_interface_t *endpoint_interface,
793  _In_ switch_call_direction_t direction,
794  switch_originate_flag_t originate_flags,
796  _In_opt_z_ const char *use_uuid);
797 #define switch_core_session_request(_ep, _d, _f, _p) switch_core_session_request_uuid(_ep, _d, _f, _p, NULL)
798 
799 SWITCH_DECLARE(switch_status_t) switch_core_session_set_uuid(_In_ switch_core_session_t *session, _In_z_ const char *use_uuid);
800 
801 SWITCH_DECLARE(void) switch_core_session_perform_destroy(_Inout_ switch_core_session_t **session,
802  _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
803 
804 /*!
805  \brief Destroy a session and return the memory pool to the core
806  \param session pointer to a pointer of the session to destroy
807  \return
808 */
809 #define switch_core_session_destroy(session) switch_core_session_perform_destroy(session, __FILE__, __SWITCH_FUNC__, __LINE__)
810 
811 SWITCH_DECLARE(void) switch_core_session_destroy_state(switch_core_session_t *session);
812 SWITCH_DECLARE(void) switch_core_session_reporting_state(switch_core_session_t *session);
813 SWITCH_DECLARE(void) switch_core_session_hangup_state(switch_core_session_t *session, switch_bool_t force);
814 
815 /*!
816  \brief Provide the total number of sessions
817  \return the total number of allocated sessions
818 */
820 
821 SWITCH_DECLARE(switch_size_t) switch_core_session_get_id(_In_ switch_core_session_t *session);
822 
823 /*!
824  \brief Provide the current session_id
825  \return the total number of allocated sessions since core startup
826 */
829 
830 /*!
831  \brief Allocate and return a new session from the core based on a given endpoint module name
832  \param endpoint_name the name of the endpoint module
833  \param pool the pool to use
834  \return the newly created session
835 */
836 SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(_In_z_ const char *endpoint_name,
838 
839 /*!
840  \brief Launch the session thread (state machine) on a given session
841  \param session the session to activate the state machine on
842  \return SWITCH_STATUS_SUCCESS if the thread was launched
843 */
845 
846 
849 
850 /*!
851  \brief Retrieve a pointer to the channel object associated with a given session
852  \param session the session to retrieve from
853  \return a pointer to the channel object
854 */
855  _Ret_ SWITCH_DECLARE(switch_channel_t *) switch_core_session_get_channel(_In_ switch_core_session_t *session);
856 
857 /*!
858  \brief Signal a session's state machine thread that a state change has occured
859 */
860 SWITCH_DECLARE(switch_mutex_t *) switch_core_session_get_mutex(switch_core_session_t *session);
862 SWITCH_DECLARE(void) switch_core_session_signal_state_change(_In_ switch_core_session_t *session);
863 
864 /*!
865  \brief Retrieve the unique identifier from a session
866  \param session the session to retrieve the uuid from
867  \return a string representing the uuid
868 */
869 SWITCH_DECLARE(char *) switch_core_session_get_uuid(_In_ switch_core_session_t *session);
870 
871 
872 /*!
873  \brief Sets the log level for a session
874  \param session the session to set the log level on
875  \return SWITCH_STATUS_SUCCESS
876 */
877 SWITCH_DECLARE(switch_status_t) switch_core_session_set_loglevel(switch_core_session_t *session, switch_log_level_t loglevel);
878 
879 
880 /*!
881  \brief Get the log level for a session
882  \param session the session to get the log level from
883  \return the log level
884 */
886 
887 SWITCH_DECLARE(switch_jb_t *) switch_core_session_get_jb(switch_core_session_t *session, switch_media_type_t type);
888 SWITCH_DECLARE(void) switch_core_session_soft_lock(switch_core_session_t *session, uint32_t sec);
889 SWITCH_DECLARE(void) switch_core_session_soft_unlock(switch_core_session_t *session);
890 SWITCH_DECLARE(void) switch_core_session_set_dmachine(switch_core_session_t *session, switch_ivr_dmachine_t *dmachine, switch_digit_action_target_t target);
896 SWITCH_DECLARE(void) switch_core_session_raw_read(switch_core_session_t *session);
897 
898 /*!
899  \brief Retrieve the unique identifier from the core
900  \return a string representing the uuid
901 */
903 
904 
905 SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_locate(const char *uuid_str, const char *file, const char *func, int line);
906 SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_force_locate(const char *uuid_str, const char *file, const char *func, int line);
907 
908 
909 /*!
910  \brief Locate a session based on it's uuid
911  \param uuid_str the unique id of the session you want to find
912  \return the session or NULL
913  \note if the session was located it will have a read lock obtained which will need to be released with switch_core_session_rwunlock()
914 */
915 
916 #define switch_core_session_locate(uuid_str) switch_core_session_perform_locate(uuid_str, __FILE__, __SWITCH_FUNC__, __LINE__)
917 
918 /*!
919  \brief Locate a session based on it's uuid even if the channel is not ready
920  \param uuid_str the unique id of the session you want to find
921  \return the session or NULL
922  \note if the session was located it will have a read lock obtained which will need to be released with switch_core_session_rwunlock()
923 */
924 
925 #define switch_core_session_force_locate(uuid_str) switch_core_session_perform_force_locate(uuid_str, __FILE__, __SWITCH_FUNC__, __LINE__)
926 
927 
928 /*!
929  \brief Retrieve a global variable from the core
930  \param varname the name of the variable
931  \return the value of the desired variable
932 */
933 SWITCH_DECLARE(char *) switch_core_get_variable(_In_z_ const char *varname);
934 SWITCH_DECLARE(char *) switch_core_get_variable_dup(_In_z_ const char *varname);
935 SWITCH_DECLARE(char *) switch_core_get_variable_pdup(_In_z_ const char *varname, switch_memory_pool_t *pool);
936 SWITCH_DECLARE(const char *) switch_core_get_hostname(void);
937 SWITCH_DECLARE(const char *) switch_core_get_switchname(void);
938 
940 
941 /*!
942  \brief Add a global variable to the core
943  \param varname the name of the variable
944  \param value the value of the variable
945  \ If \p value is NULL, then \p varname is deleted.
946 */
947 SWITCH_DECLARE(void) switch_core_set_variable(_In_z_ const char *varname, _In_opt_z_ const char *value);
949 
950 /*!
951  \brief Conditionally add a global variable to the core
952  \param varname the name of the variable
953  \param value the value of the variable
954  \param val2 the value of the variable to verify against
955  \ If the global did not exist and val2=="", add global with value, return true
956  \ If the global exists with the value of val2, replace it, return true
957  \ If the global exists with a value other than val2, return false
958 */
959 SWITCH_DECLARE(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);
960 
962 
963 /*!
964  \brief Hangup all sessions
965  \param cause the hangup cause to apply to the hungup channels
966 */
968 
969 typedef enum {
970  SHT_NONE = 0,
971  SHT_UNANSWERED = (1 << 0),
972  SHT_ANSWERED = (1 << 1)
974 
975 /*!
976  \brief Hangup all sessions which match a specific channel variable
977  \param var_name The variable name to look for
978  \param var_val The value to look for
979  \param cause the hangup cause to apply to the hungup channels
980 */
981 SWITCH_DECLARE(uint32_t) switch_core_session_hupall_matching_var_ans(_In_ const char *var_name, _In_ const char *var_val, _In_
984 #define switch_core_session_hupall_matching_var(_vn, _vv, _c) switch_core_session_hupall_matching_var_ans(_vn, _vv, _c, SHT_UNANSWERED | SHT_ANSWERED)
986 /*!
987  \brief Hangup all sessions that belong to an endpoint
988  \param endpoint_interface The endpoint interface
989  \param cause the hangup cause to apply to the hungup channels
990 */
992 
993 /*!
994  \brief Get the session's partner (the session its bridged to)
995  \param session The session we're searching with
996  \param partner [out] The session's partner, or NULL if it wasnt found
997  \return SWITCH_STATUS_SUCCESS or SWITCH_STATUS_FALSE if this session isn't bridged
998 */
999 SWITCH_DECLARE(switch_status_t) switch_core_session_perform_get_partner(switch_core_session_t *session, switch_core_session_t **partner,
1000  const char *file, const char *func, int line);
1001 
1002 #define switch_core_session_get_partner(_session, _partner) switch_core_session_perform_get_partner(_session, _partner, __FILE__, __SWITCH_FUNC__, __LINE__)
1003 
1004 /*!
1005  \brief Send a message to another session using it's uuid
1006  \param uuid_str the unique id of the session you want to send a message to
1007  \param message the switch_core_session_message_t object to send
1008  \return the status returned by the message handler
1009 */
1011 
1012 /*!
1013  \brief Queue a message on a session
1014  \param session the session to queue the message to
1015  \param message the message to queue
1016  \return SWITCH_STATUS_SUCCESS if the message was queued
1017 */
1019 
1021 
1022 
1023 SWITCH_DECLARE(switch_status_t) switch_core_session_queue_signal_data(switch_core_session_t *session, void *signal_data);
1024 SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_signal_data(switch_core_session_t *session, void **signal_data);
1025 
1026 /*!
1027  \brief pass an indication message on a session
1028  \param session the session to pass the message across
1029  \param indication the indication message to pass
1030  \return SWITCH_STATUS_SUCCESS if the message was passed
1031 */
1034 
1035 /*!
1036  \brief Queue an indication message on a session
1037  \param session the session to queue the message to
1038  \param indication the indication message to queue
1039  \return SWITCH_STATUS_SUCCESS if the message was queued
1040 */
1043 
1044 /*!
1045  \brief DE-Queue an message on a given session
1046  \param session the session to de-queue the message on
1047  \param message the de-queued message
1048  \return SWITCH_STATUS_SUCCESS if the message was de-queued
1049 */
1051 
1052 /*!
1053  \brief Flush a message queue on a given session
1054  \param session the session to de-queue the message on
1055  \return SWITCH_STATUS_SUCCESS if the message was de-queued
1056 */
1057 SWITCH_DECLARE(switch_status_t) switch_core_session_flush_message(_In_ switch_core_session_t *session);
1058 
1059 /*!
1060  \brief Queue an event on another session using its uuid
1061  \param uuid_str the unique id of the session you want to send a message to
1062  \param event the event to send
1063  \return the status returned by the message handler
1064 */
1066 
1067 SWITCH_DECLARE(switch_app_log_t *) switch_core_session_get_app_log(_In_ switch_core_session_t *session);
1068 
1069 /*!
1070  \brief Execute an application on a session
1071  \param session the current session
1072  \param application_interface the interface of the application to execute
1073  \param arg application arguments
1074  \warning Has to be called from the session's thread
1075  \return the application's return value
1076 */
1077 SWITCH_DECLARE(switch_status_t) switch_core_session_exec(_In_ switch_core_session_t *session,
1078  _In_ const switch_application_interface_t *application_interface, _In_opt_z_ const char *arg);
1079 
1080 SWITCH_DECLARE(void) switch_core_session_video_reset(switch_core_session_t *session);
1081 /*!
1082  \brief Execute an application on a session
1083  \param session the current session
1084  \param app the application's name
1085  \param arg application arguments
1086  \param flags pointer to a flags variable to set the applications flags to
1087  \return the application's return value
1088 */
1090  _In_ const char *app, _In_opt_z_ const char *arg, _Out_opt_ int32_t *flags);
1091 
1092 SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application_async(switch_core_session_t *session, const char *app, const char *arg);
1093 
1094 SWITCH_DECLARE(switch_status_t) switch_core_session_get_app_flags(const char *app, int32_t *flags);
1095 
1096 /*!
1097  \brief Execute an application on a session
1098  \param session the current session
1099  \param app the application's name
1100  \param arg application arguments
1101  \return the application's return value
1102 */
1103 #define switch_core_session_execute_application(_a, _b, _c) switch_core_session_execute_application_get_flags(_a, _b, _c, NULL)
1104 
1105 /*!
1106  \brief Run a dialplan and execute an extension
1107  \param session the current session
1108  \param exten the interface of the application to execute
1109  \param arg application arguments
1110  \note It does not change the channel back to CS_ROUTING, it manually calls the dialplan and executes the applications
1111  \warning Has to be called from the session's thread
1112  \return the application's return value
1113 */
1115  _In_z_ const char *exten,
1116  _In_opt_z_ const char *dialplan, _In_opt_z_ const char *context);
1117 
1118 /*!
1119  \brief Send an event to a session translating it to it's native message format
1120  \param session the session to receive the event
1121  \param event the event to receive
1122  \return the status returned by the handler
1123 */
1125 
1126 /*!
1127  \brief Retrieve private user data from a session
1128  \param session the session to retrieve from
1129  \return a pointer to the private data
1130 */
1131 SWITCH_DECLARE(void *) switch_core_session_get_private_class(_In_ switch_core_session_t *session, _In_ switch_pvt_class_t index);
1132 #define switch_core_session_get_private(_s) switch_core_session_get_private_class(_s, SWITCH_PVT_PRIMARY)
1133 
1134 /*!
1135  \brief Add private user data to a session
1136  \param session the session to add used data to
1137  \param private_info the used data to add
1138  \return SWITCH_STATUS_SUCCESS if data is added
1139 */
1140 SWITCH_DECLARE(switch_status_t) switch_core_session_set_private_class(_In_ switch_core_session_t *session, _In_ void *private_info, _In_ switch_pvt_class_t index);
1141 #define switch_core_session_set_private(_s, _p) switch_core_session_set_private_class(_s, _p, SWITCH_PVT_PRIMARY)
1142 
1143 /*!
1144  \brief Add a logical stream to a session
1145  \param session the session to add the stream to
1146  \param private_info an optional pointer to private data for the new stream
1147  \return the stream id of the new stream
1148 */
1149 SWITCH_DECLARE(int) switch_core_session_add_stream(_In_ switch_core_session_t *session, _In_opt_ void *private_info);
1150 
1151 /*!
1152  \brief Retreive a logical stream from a session
1153  \param session the session to add the stream to
1154  \param index the index to retrieve
1155  \return the stream
1156 */
1157 SWITCH_DECLARE(void *) switch_core_session_get_stream(_In_ switch_core_session_t *session, _In_ int index);
1158 
1159 /*!
1160  \brief Determine the number of logical streams a session has
1161  \param session the session to query
1162  \return the total number of logical streams
1163 */
1164 SWITCH_DECLARE(int) switch_core_session_get_stream_count(_In_ switch_core_session_t *session);
1165 
1166 /*!
1167  \brief Launch a thread designed to exist within the scope of a given session
1168  \param session a session to allocate the thread from
1169  \param func a function to execute in the thread
1170  \param obj an arguement
1171 */
1172 SWITCH_DECLARE(void) switch_core_session_launch_thread(_In_ switch_core_session_t *session,
1173  _In_ void *(*func) (switch_thread_t *, void *), _In_opt_ void *obj);
1174 
1175 /*!
1176  \brief Signal a thread using a thread session to terminate
1177  \param session the session to indicate to
1178 */
1179 SWITCH_DECLARE(void) switch_core_thread_session_end(_In_ switch_core_session_t *session);
1180 
1181 /*!
1182  \brief Launch a service thread on a session to drop inbound data
1183  \param session the session the launch thread on
1184 */
1185 SWITCH_DECLARE(void) switch_core_service_session_av(_In_ switch_core_session_t *session, switch_bool_t audio, switch_bool_t video);
1186 #define switch_core_service_session(_s) switch_core_service_session_av(_s, SWITCH_TRUE, SWITCH_FALSE)
1187 
1188 
1189 /*!
1190  \brief Request an outgoing session spawned from an existing session using a desired endpoing module
1191  \param session the originating session
1192  \param var_event switch_event_t containing paramaters
1193  \param endpoint_name the name of the module to use for the new session
1194  \param caller_profile the originator's caller profile
1195  \param new_session a NULL pointer to aim at the newly created session
1196  \param pool optional existing memory pool to donate to the session
1197  \param flags flags to use
1198  \return the cause code of the attempted call
1199 */
1201  _In_opt_ switch_event_t *var_event,
1202  _In_z_ const char *endpoint_name,
1203  _In_ switch_caller_profile_t *caller_profile,
1204  _Inout_ switch_core_session_t **new_session,
1206  switch_call_cause_t *cancel_cause);
1207 
1208 /*!
1209  \brief Receive a message on a given session
1210  \param session the session to receive the message from
1211  \param message the message to recieve
1212  \return the status returned by the message handler
1213 */
1216  const char *file, const char *func, int line);
1217 #define switch_core_session_receive_message(_session, _message) switch_core_session_perform_receive_message(_session, _message, \
1218  __FILE__, __SWITCH_FUNC__, __LINE__)
1219 
1220 /*!
1221  \brief Queue an event on a given session
1222  \param session the session to queue the message on
1223  \param event the event to queue
1224  \return the status returned by the message handler
1225 */
1227 
1228 
1229 /*!
1230  \brief Indicate the number of waiting events on a session
1231  \param session the session to check
1232  \return the number of events
1233 */
1234 SWITCH_DECLARE(uint32_t) switch_core_session_event_count(_In_ switch_core_session_t *session);
1235 
1236 /*
1237  Number of parsable messages waiting on the session.
1238  */
1239 SWITCH_DECLARE(uint32_t) switch_core_session_messages_waiting(switch_core_session_t *session);
1240 
1241 /*!
1242  \brief DE-Queue an event on a given session
1243  \param session the session to de-queue the message on
1244  \param event the de-queued event
1245  \param force force the dequeue
1246  \return the SWITCH_STATUS_SUCCESS if the event was de-queued
1247 */
1249 
1250 /*!
1251  \brief Queue a private event on a given session
1252  \param session the session to queue the message on
1253  \param event the event to queue
1254  \param priority event has high priority
1255  \return the status returned by the message handler
1256 */
1258  switch_bool_t priority);
1259 
1260 
1261 /*!
1262  \brief Indicate the number of waiting private events on a session
1263  \param session the session to check
1264  \return the number of events
1265 */
1266 SWITCH_DECLARE(uint32_t) switch_core_session_private_event_count(_In_ switch_core_session_t *session);
1267 
1268 /*!
1269  \brief DE-Queue a private event on a given session
1270  \param session the session to de-queue the message on
1271  \param event the de-queued event
1272  \return the SWITCH_STATUS_SUCCESS if the event was de-queued
1273 */
1275 
1276 
1277 /*!
1278  \brief Flush the private event queue of a session
1279  \param session the session to flush
1280  \return SWITCH_STATUS_SUCCESS if the events have been flushed
1281 */
1282 SWITCH_DECLARE(uint32_t) switch_core_session_flush_private_events(switch_core_session_t *session);
1283 
1284 
1285 /*!
1286  \brief Read a frame from a session
1287  \param session the session to read from
1288  \param frame a NULL pointer to a frame to aim at the newly read frame
1289  \param flags I/O flags to modify behavior (i.e. non blocking)
1290  \param stream_id which logical media channel to use
1291  \return SWITCH_STATUS_SUCCESS a the frame was read
1292 */
1294  int stream_id);
1295 
1296 /*!
1297  \brief Read a video frame from a session
1298  \param session the session to read from
1299  \param frame a NULL pointer to a frame to aim at the newly read frame
1300  \param flags I/O flags to modify behavior (i.e. non blocking)
1301  \param stream_id which logical media channel to use
1302  \return SWITCH_STATUS_SUCCESS a if the frame was read
1303 */
1305  int stream_id);
1306 /*!
1307  \brief Write a video frame to a session
1308  \param session the session to write to
1309  \param frame a pointer to a frame to write
1310  \param flags I/O flags to modify behavior (i.e. non blocking)
1311  \param stream_id which logical media channel to use
1312  \return SWITCH_STATUS_SUCCESS a if the frame was written
1313 */
1315  int stream_id);
1316 
1318  switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
1319 
1324 
1325 /*!
1326  \brief Reset the buffers and resampler on a session
1327  \param session the session to reset
1328  \param flush_dtmf flush all queued dtmf events too
1329 */
1330 SWITCH_DECLARE(void) switch_core_session_reset(_In_ switch_core_session_t *session, switch_bool_t flush_dtmf, switch_bool_t reset_read_codec);
1331 
1332 /*!
1333  \brief Write a frame to a session
1334  \param session the session to write to
1335  \param frame the frame to write
1336  \param flags I/O flags to modify behavior (i.e. non blocking)
1337  \param stream_id which logical media channel to use
1338  \return SWITCH_STATUS_SUCCESS a the frame was written
1339 */
1341  int stream_id);
1342 
1343 
1345  const char *file, const char *func, int line, switch_signal_t sig);
1346 /*!
1347  \brief Send a signal to a channel
1348  \param session session to send signal to
1349  \param sig signal to send
1350  \return status returned by the session's signal handler
1351 */
1352 #define switch_core_session_kill_channel(session, sig) switch_core_session_perform_kill_channel(session, __FILE__, __SWITCH_FUNC__, __LINE__, sig)
1353 
1354 /*!
1355  \brief Send DTMF to a session
1356  \param session session to send DTMF to
1357  \param dtmf dtmf to send to the session
1358  \return SWITCH_STATUS_SUCCESS if the dtmf was written
1359 */
1360 SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf(_In_ switch_core_session_t *session, const switch_dtmf_t *dtmf);
1361 /*!
1362  \brief Send DTMF to a session
1363  \param session session to send DTMF to
1364  \param dtmf_string string to send to the session
1365  \return SWITCH_STATUS_SUCCESS if the dtmf was written
1366 */
1367 SWITCH_DECLARE(switch_status_t) switch_core_session_send_dtmf_string(switch_core_session_t *session, const char *dtmf_string);
1368 
1369 /*!
1370  \brief RECV DTMF on a session
1371  \param session session to recv DTMF from
1372  \param dtmf string to recv from the session
1373  \return SWITCH_STATUS_SUCCESS if the dtmf is ok to queue
1374 */
1375 SWITCH_DECLARE(switch_status_t) switch_core_session_recv_dtmf(_In_ switch_core_session_t *session, const switch_dtmf_t *dtmf);
1376 
1377 ///\}
1378 
1379 
1380 ///\defgroup hashf Hash Functions
1381 ///\ingroup core1
1382 ///\{
1383 /*!
1384  \brief Initialize a hash table
1385  \param hash a NULL pointer to a hash table to aim at the new hash
1386  \param pool the pool to use for the new hash
1387  \return SWITCH_STATUS_SUCCESS if the hash is created
1388 */
1390 #define switch_core_hash_init(_hash) switch_core_hash_init_case(_hash, SWITCH_TRUE)
1391 #define switch_core_hash_init_nocase(_hash) switch_core_hash_init_case(_hash, SWITCH_FALSE)
1392 
1393 
1394 /*!
1395  \brief Destroy an existing hash table
1396  \param hash the hash to destroy
1397  \return SWITCH_STATUS_SUCCESS if the hash is destroyed
1398 */
1400 
1401 /*!
1402  \brief Insert data into a hash
1403  \param hash the hash to add data to
1404  \param key the name of the key to add the data to
1405  \param data the data to add
1406  \return SWITCH_STATUS_SUCCESS if the data is added
1407  \note the string key must be a constant or a dynamic string
1408 */
1410 #define switch_core_hash_insert(_h, _k, _d) switch_core_hash_insert_destructor(_h, _k, _d, NULL)
1411 
1412 
1413 /*!
1414  \brief Insert data into a hash
1415  \param hash the hash to add data to
1416  \param key the name of the key to add the data to
1417  \param data the data to add
1418  \param mutex optional mutex to lock
1419  \return SWITCH_STATUS_SUCCESS if the data is added
1420  \note the string key must be a constant or a dynamic string
1421 */
1424 /*!
1425  \brief Retrieve data from a given hash
1426  \param hash the hash to retrieve from
1427  \param key the key to retrieve
1428  \param mutex optional rwlock to wrlock
1429  \return a pointer to the data held in the key
1430 */
1432 
1433 /*!
1434  \brief Delete data from a hash based on desired key
1435  \param hash the hash to delete from
1436  \param key the key from which to delete the data
1437  \return The value stored if the data is deleted otherwise NULL
1438 */
1439 SWITCH_DECLARE(void *) switch_core_hash_delete(_In_ switch_hash_t *hash, _In_z_ const char *key);
1440 
1441 /*!
1442  \brief Delete data from a hash based on desired key
1443  \param hash the hash to delete from
1444  \param key the key from which to delete the data
1445  \param mutex optional mutex to lock
1446  \return a pointer to the deleted data
1447 */
1449 
1450 /*!
1451  \brief Delete data from a hash based on desired key
1452  \param hash the hash to delete from
1453  \param key the key from which to delete the data
1454  \param mutex optional rwlock to wrlock
1455  \return a pointer to the deleted data
1456 */
1458 
1459 /*!
1460  \brief Delete data from a hash based on callback function
1461  \param hash the hash to delete from
1462  \param callback the function to call which returns SWITCH_TRUE to delete, SWITCH_FALSE to preserve
1463  \return SWITCH_STATUS_SUCCESS if any data is deleted
1464 */
1466 
1467 /*!
1468  \brief Retrieve data from a given hash
1469  \param hash the hash to retrieve from
1470  \param key the key to retrieve
1471  \return a pointer to the data held in the key
1472 */
1473 SWITCH_DECLARE(void *) switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key);
1474 
1475 
1476 /*!
1477  \brief Retrieve data from a given hash
1478  \param hash the hash to retrieve from
1479  \param key the key to retrieve
1480  \param mutex optional mutex to lock
1481  \return a pointer to the data held in the key
1482 */
1484 
1485 /*!
1486  \brief Retrieve data from a given hash
1487  \param hash the hash to retrieve from
1488  \param key the key to retrieve
1489  \param mutex optional rwlock to rdlock
1490  \return a pointer to the data held in the key
1491 */
1493 
1494 /*!
1495  \brief Gets the first element of a hashtable
1496  \param deprecate_me [deprecated] NULL
1497  \param hash the hashtable to use
1498  \return The element, or NULL if it wasn't found
1499 */
1501 #define switch_core_hash_first(_h) switch_core_hash_first_iter(_h, NULL)
1502 
1503 /*!
1504  \brief tells if a hash is empty
1505  \param hash the hashtable
1506  \return TRUE or FALSE depending on if the hash is empty
1507 */
1509 
1510 /*!
1511  \brief Gets the next element of a hashtable
1512  \param hi The current element
1513  \return The next element, or NULL if there are no more
1514 */
1516 
1517 /*!
1518  \brief Gets the key and value of the current hash element
1519  \param hi The current element
1520  \param key [out] the key
1521  \param klen [out] the key's size
1522  \param val [out] the value
1523 */
1525  const void **key, _Out_opt_ switch_ssize_t *klen, _Out_ void **val);
1526 
1528 
1531 SWITCH_DECLARE(switch_status_t) switch_core_inthash_insert(switch_inthash_t *hash, uint32_t key, const void *data);
1532 SWITCH_DECLARE(void *) switch_core_inthash_delete(switch_inthash_t *hash, uint32_t key);
1533 SWITCH_DECLARE(void *) switch_core_inthash_find(switch_inthash_t *hash, uint32_t key);
1534 
1535 ///\}
1536 
1537 ///\defgroup timer Timer Functions
1538 ///\ingroup core1
1539 ///\{
1540 /*!
1541  \brief Request a timer handle using given time module
1542  \param timer a timer object to allocate to
1543  \param timer_name the name of the timer module to use
1544  \param interval desired interval
1545  \param samples the number of samples to increment on each cycle
1546  \param pool the memory pool to use for allocation
1547  \return
1548 */
1549 SWITCH_DECLARE(switch_status_t) switch_core_timer_init(switch_timer_t *timer, const char *timer_name, int interval, int samples,
1550  switch_memory_pool_t *pool);
1551 
1553 
1554 /*!
1555  \brief Wait for one cycle on an existing timer
1556  \param timer the timer to wait on
1557  \return the newest sample count
1558 */
1560 
1561 /*!
1562  \brief Step the timer one step
1563  \param timer the timer to wait on
1564  \return the newest sample count
1565 */
1567 
1569 
1570 /*!
1571  \brief Check if the current step has been exceeded
1572  \param timer the timer to wait on
1573  \param step increment timer if a tick was detected
1574  \return the newest sample count
1575 */
1577 
1578 /*!
1579  \brief Destroy an allocated timer
1580  \param timer timer to destroy
1581  \return SWITCH_STATUS_SUCCESS after destruction
1582 */
1584 ///\}
1585 
1586 ///\defgroup codecs Codec Functions
1587 ///\ingroup core1
1588 ///\{
1589 /*!
1590  \brief Initialize a codec handle
1591  \param codec the handle to initilize
1592  \param codec_name the name of the codec module to use
1593  \param fmtp codec parameters to send
1594  \param rate the desired rate (0 for any)
1595  \param ms the desired number of milliseconds (0 for any)
1596  \param channels the desired number of channels (0 for any)
1597  \param flags flags to alter behaviour
1598  \param codec_settings desired codec settings
1599  \param pool the memory pool to use
1600  \return SWITCH_STATUS_SUCCESS if the handle is allocated
1601 */
1602 #define switch_core_codec_init(_codec, _codec_name, _modname, _fmtp, _rate, _ms, _channels, _flags, _codec_settings, _pool) \
1603  switch_core_codec_init_with_bitrate(_codec, _codec_name, _modname, _fmtp, _rate, _ms, _channels, 0, _flags, _codec_settings, _pool)
1605  const char *codec_name,
1606  const char *fmtp,
1607  const char *modname,
1608  uint32_t rate,
1609  int ms,
1610  int channels,
1611  uint32_t bitrate,
1612  uint32_t flags,
1613  const switch_codec_settings_t *codec_settings,
1614  switch_memory_pool_t *pool);
1615 
1617  const switch_codec_settings_t *codec_settings, switch_memory_pool_t *pool);
1618 SWITCH_DECLARE(switch_status_t) switch_core_codec_parse_fmtp(const char *codec_name, const char *fmtp, uint32_t rate, switch_codec_fmtp_t *codec_fmtp);
1620 
1621 /*!
1622  \brief Encode data using a codec handle
1623  \param codec the codec handle to use
1624  \param other_codec the codec handle of the last codec used
1625  \param decoded_data the raw data
1626  \param decoded_data_len then length of the raw buffer
1627  \param decoded_rate the rate of the decoded data
1628  \param encoded_data the buffer to write the encoded data to
1629  \param encoded_data_len the size of the encoded_data buffer
1630  \param encoded_rate the new rate of the encoded data
1631  \param flag flags to exchange
1632  \return SWITCH_STATUS_SUCCESS if the data was encoded
1633  \note encoded_data_len will be rewritten to the in-use size of encoded_data
1634 */
1636  switch_codec_t *other_codec,
1637  void *decoded_data,
1638  uint32_t decoded_data_len,
1639  uint32_t decoded_rate,
1640  void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag);
1641 
1642 /*!
1643  \brief Decode data using a codec handle
1644  \param codec the codec handle to use
1645  \param other_codec the codec handle of the last codec used
1646  \param encoded_data the buffer to read the encoded data from
1647  \param encoded_data_len the size of the encoded_data buffer
1648  \param encoded_rate the rate of the encoded data
1649  \param decoded_data the raw data buffer
1650  \param decoded_data_len then length of the raw buffer
1651  \param decoded_rate the new rate of the decoded data
1652  \param flag flags to exchange
1653  \return SWITCH_STATUS_SUCCESS if the data was decoded
1654  \note decoded_data_len will be rewritten to the in-use size of decoded_data
1655 */
1657  switch_codec_t *other_codec,
1658  void *encoded_data,
1659  uint32_t encoded_data_len,
1660  uint32_t encoded_rate,
1661  void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag);
1662 
1663 /*!
1664  \brief Encode video data using a codec handle
1665  \param codec the codec handle to use
1666  \param frame the frame to encode
1667 */
1669 
1670 
1671 /*!
1672  \brief send control data using a codec handle
1673  \param codec the codec handle to use
1674  \param cmd the command to send
1675  \param ctype the type of the arguement
1676  \param cmd_data a void pointer to the data matching the passed type
1677  \param atype the type of the extra arguement
1678  \param cmd_arg a void pointer to the data matching the passed type
1679  \param rtype the type of the response if any
1680  \param ret_data a void pointer to a pointer of return data
1681  \return SWITCH_STATUS_SUCCESS if the command was received
1682 */
1686  void *cmd_data,
1688  void *cmd_arg,
1690  void **ret_data);
1691 
1692 /*!
1693  \brief Decode video data using a codec handle
1694  \param codec the codec handle to use
1695  \param frame the frame to be decoded
1696  \param img the new image in I420 format, allocated by the codec
1697  \param flag flags to exchange
1698  \return SWITCH_STATUS_SUCCESS if the data was decoded, and a non-NULL img
1699 */
1701 
1702 /*!
1703  \brief Destroy an initalized codec handle
1704  \param codec the codec handle to destroy
1705  \return SWITCH_STATUS_SUCCESS if the codec was destroyed
1706 */
1708 
1709 /*!
1710  \brief Assign the read codec to a given session
1711  \param session session to add the codec to
1712  \param codec the codec to add
1713  \return SWITCH_STATUS_SUCCESS if successful
1714 */
1716 
1717 /*!
1718  \brief Assign the original read codec to a given session. This is the read codec used by an endpoint.
1719  \param session session to add the codec to
1720  \param codec the codec to add
1721  \return SWITCH_STATUS_SUCCESS if successful
1722 */
1724 
1725 SWITCH_DECLARE(void) switch_core_session_unset_read_codec(_In_ switch_core_session_t *session);
1726 SWITCH_DECLARE(void) switch_core_session_unset_write_codec(_In_ switch_core_session_t *session);
1727 
1728 
1729 SWITCH_DECLARE(void) switch_core_session_lock_codec_write(_In_ switch_core_session_t *session);
1730 SWITCH_DECLARE(void) switch_core_session_unlock_codec_write(_In_ switch_core_session_t *session);
1731 SWITCH_DECLARE(void) switch_core_session_lock_codec_read(_In_ switch_core_session_t *session);
1732 SWITCH_DECLARE(void) switch_core_session_unlock_codec_read(_In_ switch_core_session_t *session);
1733 
1734 
1740 
1741 
1742 /*!
1743  \brief Retrieve the read codec from a given session
1744  \param session session to retrieve from
1745  \return a pointer to the codec
1746 */
1747 SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_read_codec(_In_ switch_core_session_t *session);
1748 
1749 /*!
1750  \brief Retrieve the effevtive read codec from a given session
1751  \param session session to retrieve from
1752  \return a pointer to the codec
1753 */
1755 
1756 /*!
1757  \brief Assign the write codec to a given session
1758  \param session session to add the codec to
1759  \param codec the codec to add
1760  \return SWITCH_STATUS_SUCCESS if successful
1761 */
1763 
1764 /*!
1765  \brief Retrieve the write codec from a given session
1766  \param session session to retrieve from
1767  \return a pointer to the codec
1768 */
1769 SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_write_codec(_In_ switch_core_session_t *session);
1770 
1771 /*!
1772  \brief Retrieve the effevtive write codec from a given session
1773  \param session session to retrieve from
1774  \return a pointer to the codec
1775 */
1777 
1778 /*!
1779  \brief Assign the video_read codec to a given session
1780  \param session session to add the codec to
1781  \param codec the codec to add
1782  \return SWITCH_STATUS_SUCCESS if successful
1783 */
1785 
1786 /*!
1787  \brief Retrieve the video_read codec from a given session
1788  \param session session to retrieve from
1789  \return a pointer to the codec
1790 */
1792 
1793 /*!
1794  \brief Assign the video_write codec to a given session
1795  \param session session to add the codec to
1796  \param codec the codec to add
1797  \return SWITCH_STATUS_SUCCESS if successful
1798 */
1800 
1801 /*!
1802  \brief Retrieve the video_write codec from a given session
1803  \param session session to retrieve from
1804  \return a pointer to the codec
1805 */
1807 
1808 ///\}
1809 ///\defgroup db Database Functions
1810 ///\ingroup core1
1811 ///\{
1812 /*!
1813  \brief Open a core db (SQLite) file
1814  \param filename the path to the db file to open
1815  \return the db handle
1816 */
1818 
1819 /*!
1820  \brief Execute a sql stmt until it is accepted
1821  \param db the db handle
1822  \param sql the sql to execute
1823  \param retries the number of retries to use
1824  \return SWITCH_STATUS_SUCCESS if successful
1825 
1826 */
1830 
1831 
1832 
1833 /*!
1834  \brief perform a test query then perform a reactive query if the first one fails
1835  \param db the db handle
1836  \param test_sql the test sql
1837  \param drop_sql the drop sql
1838  \param reactive_sql the reactive sql
1839 */
1840 SWITCH_DECLARE(void) switch_core_db_test_reactive(switch_core_db_t *db, char *test_sql, char *drop_sql, char *reactive_sql);
1841 
1842 ///\}
1843 
1844 ///\defgroup Media File Functions
1845 ///\ingroup core1
1846 ///\{
1847 
1848 SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file, const char *func, int line,
1850  _In_opt_z_ const char *file_path,
1851  _In_ uint32_t channels,
1852  _In_ uint32_t rate, _In_ unsigned int flags, _In_opt_ switch_memory_pool_t *pool);
1853 
1854 /*!
1855  \brief Open a media file using file format modules
1856  \param _fh a file handle to use
1857  \param _file_path the path to the file
1858  \param _channels the number of channels
1859  \param _rate the sample rate
1860  \param _flags read/write flags
1861  \param _pool the pool to use (NULL for new pool)
1862  \return SWITCH_STATUS_SUCCESS if the file is opened
1863  \note the loadable module used is chosen based on the file extension
1864 */
1865 #define switch_core_file_open(_fh, _file_path, _channels, _rate, _flags, _pool) \
1866  switch_core_perform_file_open(__FILE__, __SWITCH_FUNC__, __LINE__, _fh, _file_path, _channels, _rate, _flags, _pool)
1867 
1868 /*!
1869  \brief Read media from a file handle
1870  \param fh the file handle to read from (must be initilized by you memset all 0 for read, fill in channels and rate for write)
1871  \param data the buffer to read the data to
1872  \param len the max size of the buffer
1873  \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes read if successful
1874 */
1876 
1877 /*!
1878  \brief Write media to a file handle
1879  \param fh the file handle to write to
1880  \param data the buffer to write
1881  \param len the amount of data to write from the buffer
1882  \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful
1883 */
1885 
1886 /*!
1887  \brief Write media to a file handle
1888  \param fh the file handle to write to
1889  \param data the buffer to write
1890  \param len the amount of data to write from the buffer
1891  \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful
1892 */
1895 
1896 /*!
1897  \brief Seek a position in a file
1898  \param fh the file handle to seek
1899  \param cur_pos the current position in the file
1900  \param samples the amount of samples to seek from the beginning of the file
1901  \param whence the indicator (see traditional seek)
1902  \return SWITCH_STATUS_SUCCESS with cur_pos adjusted to new position
1903 */
1904 SWITCH_DECLARE(switch_status_t) switch_core_file_seek(_In_ switch_file_handle_t *fh, unsigned int *cur_pos, int64_t samples, int whence);
1905 
1906 /*!
1907  \brief Set metadata to the desired string
1908  \param fh the file handle to set data to
1909  \param col the enum of the col name
1910  \param string the string to add
1911  \return SWITCH_STATUS_SUCCESS with cur_pos adjusted to new position
1912 */
1914 
1915 /*!
1916  \brief get metadata of the desired string
1917  \param fh the file handle to get data from
1918  \param col the enum of the col name
1919  \param string pointer to the string to fetch
1920  \return SWITCH_STATUS_SUCCESS with cur_pos adjusted to new position
1921 */
1923 
1924 
1925 /*!
1926  \brief Close an open file handle
1927  \param fh the file handle to close
1928  \return SWITCH_STATUS_SUCCESS if the file handle was closed
1929 */
1931 
1933 
1936 
1937 
1938 ///\}
1939 
1940 ///\defgroup speech ASR/TTS Functions
1941 ///\ingroup core1
1942 ///\{
1943 /*!
1944  \brief Open a speech handle
1945  \param sh a speech handle to use
1946  \param module_name the speech module to use
1947  \param voice_name the desired voice name
1948  \param rate the sampling rate
1949  \param interval the sampling interval
1950  \param flags tts flags
1951  \param pool the pool to use (NULL for new pool)
1952  \return SWITCH_STATUS_SUCCESS if the handle is opened
1953 */
1955  const char *module_name,
1956  const char *voice_name,
1957  _In_ unsigned int rate,
1958  _In_ unsigned int interval,
1959  _In_ unsigned int channels,
1961 /*!
1962  \brief Feed text to the TTS module
1963  \param sh the speech handle to feed
1964  \param text the buffer to write
1965  \param flags flags in/out for fine tuning
1966  \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful
1967 */
1969 
1970 /*!
1971  \brief Flush TTS audio on a given handle
1972  \param sh the speech handle
1973 */
1975 
1976 /*!
1977  \brief Set a text parameter on a TTS handle
1978  \param sh the speech handle
1979  \param param the parameter
1980  \param val the value
1981 */
1982 SWITCH_DECLARE(void) switch_core_speech_text_param_tts(switch_speech_handle_t *sh, char *param, const char *val);
1983 
1984 /*!
1985  \brief Set a numeric parameter on a TTS handle
1986  \param sh the speech handle
1987  \param param the parameter
1988  \param val the value
1989 */
1991 
1992 /*!
1993  \brief Set a float parameter on a TTS handle
1994  \param sh the speech handle
1995  \param param the parameter
1996  \param val the value
1997 */
1999 
2000 /*!
2001  \brief Read rendered audio from the TTS module
2002  \param sh the speech handle to read
2003  \param data the buffer to read to
2004  \param datalen the max size / written size of the data
2005  \param rate the rate of the read audio
2006  \param flags flags in/out for fine tuning
2007  \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful
2008 */
2010 /*!
2011  \brief Close an open speech handle
2012  \param sh the speech handle to close
2013  \param flags flags in/out for fine tuning
2014  \return SWITCH_STATUS_SUCCESS if the file handle was closed
2015 */
2017 
2018 
2019 /*!
2020  \brief Open an asr handle
2021  \param ah the asr handle to open
2022  \param module_name the name of the asr module
2023  \param codec the preferred codec
2024  \param rate the preferred rate
2025  \param dest the destination address
2026  \param flags flags to influence behaviour
2027  \param pool the pool to use (NULL for new pool)
2028  \return SWITCH_STATUS_SUCCESS if the asr handle was opened
2029 */
2031  const char *module_name,
2032  const char *codec, int rate, const char *dest, switch_asr_flag_t *flags, switch_memory_pool_t *pool);
2033 
2034 /*!
2035  \brief Close an asr handle
2036  \param ah the handle to close
2037  \param flags flags to influence behaviour
2038  \return SWITCH_STATUS_SUCCESS
2039 */
2041 
2042 /*!
2043  \brief Feed audio data to an asr handle
2044  \param ah the handle to feed data to
2045  \param data a pointer to the data
2046  \param len the size in bytes of the data
2047  \param flags flags to influence behaviour
2048  \return SWITCH_STATUS_SUCCESS
2049 */
2051 
2052 /*!
2053  \brief Feed DTMF to an asr handle
2054  \param ah the handle to feed data to
2055  \param dtmf a string of DTMF digits
2056  \param flags flags to influence behaviour
2057  \return SWITCH_STATUS_SUCCESS
2058 */
2060 
2061 /*!
2062  \brief Check an asr handle for results
2063  \param ah the handle to check
2064  \param flags flags to influence behaviour
2065  \return SWITCH_STATUS_SUCCESS
2066 */
2068 
2069 /*!
2070  \brief Get results from an asr handle
2071  \param ah the handle to get results from
2072  \param xmlstr a pointer to dynamically allocate an xml result string to
2073  \param flags flags to influence behaviour
2074  \return SWITCH_STATUS_SUCCESS
2075 */
2077 
2078 /*!
2079  \brief Get result headers from an asr handle
2080  \param ah the handle to get results from
2081  \param headers a pointer to dynamically allocate an switch_event_t result to
2082  \param flags flags to influence behaviour
2083  \return SWITCH_STATUS_SUCCESS
2084 */
2086 
2087 /*!
2088  \brief Load a grammar to an asr handle
2089  \param ah the handle to load to
2090  \param grammar the grammar text, file path, or URI
2091  \param name the grammar name
2092  \return SWITCH_STATUS_SUCCESS
2093 */
2094 SWITCH_DECLARE(switch_status_t) switch_core_asr_load_grammar(switch_asr_handle_t *ah, const char *grammar, const char *name);
2095 
2096 /*!
2097  \brief Unload a grammar from an asr handle
2098  \param ah the handle to unload the grammar from
2099  \param name the name of the grammar to unload
2100  \return SWITCH_STATUS_SUCCESS
2101 */
2103 
2104 /*!
2105  \brief Enable a grammar from an asr handle
2106  \param ah the handle to enable the grammar from
2107  \param name the name of the grammar to enable
2108  \return SWITCH_STATUS_SUCCESS
2109 */
2111 
2112 /*!
2113  \brief Disable a grammar from an asr handle
2114  \param ah the handle to disable the grammar from
2115  \param name the name of the grammar to disable
2116  \return SWITCH_STATUS_SUCCESS
2117 */
2119 
2120 /*!
2121  \brief Disable all grammars from an asr handle
2122  \param ah the handle to disable the grammars from
2123  \return SWITCH_STATUS_SUCCESS
2124 */
2126 
2127 /*!
2128  \brief Pause detection on an asr handle
2129  \param ah the handle to pause
2130  \return SWITCH_STATUS_SUCCESS
2131 */
2133 
2134 /*!
2135  \brief Resume detection on an asr handle
2136  \param ah the handle to resume
2137  \return SWITCH_STATUS_SUCCESS
2138 */
2140 
2141 /*!
2142  \brief Start input timers on an asr handle
2143  \param ah the handle to start timers on
2144  \return SWITCH_STATUS_SUCCESS
2145 */
2147 
2148 /*!
2149  \brief Set a text parameter on an asr handle
2150  \param sh the asr handle
2151  \param param the parameter
2152  \param val the value
2153 */
2154 SWITCH_DECLARE(void) switch_core_asr_text_param(switch_asr_handle_t *ah, char *param, const char *val);
2155 
2156 /*!
2157  \brief Set a numeric parameter on an asr handle
2158  \param sh the asr handle
2159  \param param the parameter
2160  \param val the value
2161 */
2162 SWITCH_DECLARE(void) switch_core_asr_numeric_param(switch_asr_handle_t *ah, char *param, int val);
2163 
2164 /*!
2165  \brief Set a float parameter on an asr handle
2166  \param sh the asr handle
2167  \param param the parameter
2168  \param val the value
2169 */
2170 SWITCH_DECLARE(void) switch_core_asr_float_param(switch_asr_handle_t *ah, char *param, double val);
2171 
2172 ///\}
2173 
2174 
2175 ///\defgroup dir Directory Service Functions
2176 ///\ingroup core1
2177 ///\{
2178 /*!
2179  \brief Open a directory handle
2180  \param dh a directory handle to use
2181  \param module_name the directory module to use
2182  \param source the source of the db (ip, hostname, path etc)
2183  \param dsn the username or designation of the lookup
2184  \param passwd the password
2185  \param pool the pool to use (NULL for new pool)
2186  \return SWITCH_STATUS_SUCCESS if the handle is opened
2187 */
2189  char *module_name, char *source, char *dsn, char *passwd, switch_memory_pool_t *pool);
2190 
2191 /*!
2192  \brief Query a directory handle
2193  \param dh a directory handle to use
2194  \param base the base to query against
2195  \param query a string of filters or query data
2196  \return SWITCH_STATUS_SUCCESS if the query is successful
2197 */
2199 
2200 /*!
2201  \brief Obtain the next record in a lookup
2202  \param dh a directory handle to use
2203  \return SWITCH_STATUS_SUCCESS if another record exists
2204 */
2206 
2207 /*!
2208  \brief Obtain the next name/value pair in the current record
2209  \param dh a directory handle to use
2210  \param var a pointer to pointer of the name to fill in
2211  \param val a pointer to pointer of the value to fill in
2212  \return SWITCH_STATUS_SUCCESS if an item exists
2213 */
2215 
2216 /*!
2217  \brief Close an open directory handle
2218  \param dh a directory handle to close
2219  \return SWITCH_STATUS_SUCCESS if handle was closed
2220 */
2222 ///\}
2223 
2224 
2225 ///\defgroup misc Misc
2226 ///\ingroup core1
2227 ///\{
2228 /*!
2229  \brief Retrieve a FILE stream of a given text channel name
2230  \param channel text channel enumeration
2231  \return a FILE stream
2232 */
2234 
2235 /*!
2236  \brief Determines if the core is ready to take calls
2237  \return SWITCH_TRUE or SWITCH_FALSE
2238 */
2240 
2242 
2243 /*!
2244  \brief Determines if the core is ready to take inbound calls
2245  \return SWITCH_TRUE or SWITCH_FALSE
2246 */
2248 
2249 /*!
2250  \brief Determines if the core is ready to place outbound calls
2251  \return SWITCH_TRUE or SWITCH_FALSE
2252 */
2254 
2255 /*!
2256  \brief return core flags
2257  \return core flags
2258 */
2260 
2261 /*!
2262  \brief Execute a management operation.
2263  \param relative_oid the relative oid of the operation.
2264  \param action the action to perform.
2265  \param data input/output string.
2266  \param datalen size in bytes of data.
2267  \return SUCCESS on sucess.
2268 */
2270 
2271 /*!
2272  \brief Switch on the privilege awareness for the process and request required privileges
2273  \return 0 on success
2274 */
2275 
2277 
2278 /*!
2279  \brief Set the maximum priority the process can obtain
2280  \return 0 on success
2281 */
2282 
2283 SWITCH_DECLARE(int32_t) set_normal_priority(void);
2284 SWITCH_DECLARE(int32_t) set_auto_priority(void);
2285 SWITCH_DECLARE(int32_t) set_realtime_priority(void);
2286 SWITCH_DECLARE(int32_t) set_low_priority(void);
2287 
2288 /*!
2289  \brief Change user and/or group of the running process
2290  \param user name of the user to switch to (or NULL)
2291  \param group name of the group to switch to (or NULL)
2292  \return 0 on success, -1 otherwise
2293 
2294  Several possible combinations:
2295  - user only (group NULL): switch to user and his primary group (and supplementary groups, if supported)
2296  - user and group: switch to user and specified group (only)
2297  - group only (user NULL): switch group only
2298 */
2299 SWITCH_DECLARE(int32_t) change_user_group(const char *user, const char *group);
2300 
2301 /*!
2302  \brief Run endlessly until the system is shutdown
2303  \param bg divert console to the background
2304 */
2306 
2307 /*!
2308  \brief Set the output console to the desired file
2309  \param console the file path
2310 */
2312 
2313 /*!
2314  \brief Breakdown a number of milliseconds into various time spec
2315  \param total_ms a number of milliseconds
2316  \param duration an object to store the results
2317 */
2319 
2320 /*!
2321  \brief Number of microseconds the system has been up
2322  \return a number of microseconds
2323 */
2325 
2326 /*!
2327  \brief send a control message to the core
2328  \param cmd the command
2329  \param val the command arguement (if needed)
2330  \return 0 on success nonzero on error
2331 */
2333 
2334 /*!
2335  \brief Get the output console
2336  \return the FILE stream
2337 */
2339 
2340 #ifndef SWIG
2341 /*!
2342  \brief Launch a thread
2343 */
2344 SWITCH_DECLARE(switch_thread_t *) switch_core_launch_thread(void *(SWITCH_THREAD_FUNC * func) (switch_thread_t *, void *),
2345  void *obj, switch_memory_pool_t *pool);
2346 #endif
2347 
2348 /*!
2349  \brief Initiate Globals
2350 */
2352 
2353 /*!
2354  \brief Checks if 2 sessions are using the same endpoint module
2355  \param a the first session
2356  \param b the second session
2357  \return TRUE or FALSE
2358 */
2359 SWITCH_DECLARE(uint8_t) switch_core_session_compare(switch_core_session_t *a, switch_core_session_t *b);
2360 /*!
2361  \brief Checks if a session is using a specific endpoint
2362  \param session the session
2363  \param endpoint_interface interface of the endpoint to check
2364  \return TRUE or FALSE
2365 */
2366 SWITCH_DECLARE(uint8_t) switch_core_session_check_interface(switch_core_session_t *session, const switch_endpoint_interface_t *endpoint_interface);
2367 
2369  switch_core_video_thread_callback_func_t func, void *user_data);
2370 
2372 
2374 SWITCH_DECLARE(const char *) switch_core_mime_ext2type(const char *ext);
2375 SWITCH_DECLARE(const char *) switch_core_mime_type2ext(const char *type);
2376 SWITCH_DECLARE(switch_status_t) switch_core_mime_add_type(const char *type, const char *ext);
2377 
2380 /*!
2381  \brief Get the current epoch time in microseconds
2382  \return the current epoch time in microseconds
2383 */
2392 SWITCH_DECLARE(void) switch_time_sync(void);
2393 /*!
2394  \brief Get the current epoch time
2395  \param [out] (optional) The current epoch time
2396  \return The current epoch time
2397 */
2398 SWITCH_DECLARE(time_t) switch_epoch_time_now(time_t *t);
2399 SWITCH_DECLARE(const char *) switch_lookup_timezone(const char *tz_name);
2400 SWITCH_DECLARE(switch_status_t) switch_strftime_tz(const char *tz, const char *format, char *date, size_t len, switch_time_t thetime);
2403 SWITCH_DECLARE(switch_bool_t) switch_check_network_list_ip_token(const char *ip_str, const char *list_name, const char **token);
2404 #define switch_check_network_list_ip(_ip_str, _list_name) switch_check_network_list_ip_token(_ip_str, _list_name, NULL)
2406 SWITCH_DECLARE(void) switch_time_set_timerfd(int enable);
2411 SWITCH_DECLARE(uint32_t) switch_core_min_dtmf_duration(uint32_t duration);
2412 SWITCH_DECLARE(uint32_t) switch_core_max_dtmf_duration(uint32_t duration);
2413 SWITCH_DECLARE(double) switch_core_min_idle_cpu(double new_limit);
2414 SWITCH_DECLARE(double) switch_core_idle_cpu(void);
2415 SWITCH_DECLARE(uint32_t) switch_core_default_dtmf_duration(uint32_t duration);
2418 SWITCH_DECLARE(int) switch_system(const char *cmd, switch_bool_t wait);
2419 SWITCH_DECLARE(int) switch_stream_system(const char *cmd, switch_stream_handle_t *stream);
2421 SWITCH_DECLARE(void) switch_cond_next(void);
2422 SWITCH_DECLARE(switch_status_t) switch_core_chat_send_args(const char *dest_proto, const char *proto, const char *from, const char *to,
2423  const char *subject, const char *body, const char *type, const char *hint, switch_bool_t blocking);
2424 SWITCH_DECLARE(switch_status_t) switch_core_chat_send(const char *dest_proto, switch_event_t *message_event);
2425 SWITCH_DECLARE(switch_status_t) switch_core_chat_deliver(const char *dest_proto, switch_event_t **message_event);
2426 
2427 SWITCH_DECLARE(switch_status_t) switch_ivr_preprocess_session(switch_core_session_t *session, const char *cmds);
2430 
2431 
2432 ///\}
2433 
2434 /*!
2435  \}
2436 */
2437 
2438 typedef int (*switch_core_db_event_callback_func_t) (void *pArg, switch_event_t *event);
2439 
2440 #define CACHE_DB_LEN 256
2441 typedef enum {
2442  CDF_INUSE = (1 << 0),
2443  CDF_PRUNE = (1 << 1)
2444 } cache_db_flag_t;
2445 
2446 typedef enum {
2451 
2452 typedef union {
2457 
2458 typedef struct {
2459  char *db_path;
2461 
2462 typedef struct {
2463  char *dsn;
2464  char *user;
2465  char *pass;
2467 
2468 typedef struct {
2469  char *dsn;
2471 
2472 typedef union {
2477 
2478 struct switch_cache_db_handle;
2480 
2482 {
2483  const char *type_str = "INVALID";
2484 
2485  switch (type) {
2486  case SCDB_TYPE_PGSQL:
2487  {
2488  type_str = "PGSQL";
2489  }
2490  break;
2491  case SCDB_TYPE_ODBC:
2492  {
2493  type_str = "ODBC";
2494  }
2495  break;
2496  case SCDB_TYPE_CORE_DB:
2497  {
2498  type_str = "CORE_DB";
2499  }
2500  break;
2501  }
2502 
2503  return type_str;
2504 }
2505 
2507 
2508 /*!
2509  \brief Returns the handle to the pool, immediately available for other
2510  threads to use.
2511  \param [in] The handle
2512 */
2514 /*!
2515  \brief Returns the handle to the pool, handle is NOT available to
2516  other threads until the allocating thread actually terminates.
2517  \param [in] The handle
2518 */
2520 /*!
2521  \brief Gets a new cached handle from the pool, potentially creating a new connection.
2522  The connection is bound to the thread until it (the thread) terminates unless
2523  you dismiss rather than release.
2524  \param [out] dbh The handle
2525  \param [in] type - ODBC or SQLLITE
2526  \param [in] connection_options (userid, password, etc)
2527 */
2530  switch_cache_db_connection_options_t *connection_options,
2531  const char *file, const char *func, int line);
2532 #define switch_cache_db_get_db_handle(_a, _b, _c) _switch_cache_db_get_db_handle(_a, _b, _c, __FILE__, __SWITCH_FUNC__, __LINE__)
2533 
2535  const char *file, const char *func, int line);
2536 #define switch_cache_db_get_db_handle_dsn(_a, _b) _switch_cache_db_get_db_handle_dsn(_a, _b, __FILE__, __SWITCH_FUNC__, __LINE__)
2537 
2538 /*!
2539  \brief Executes the create schema sql
2540  \param [in] dbh The handle
2541  \param [in] sql - sql to run
2542  \param [out] err - Error if it exists
2543 */
2545 /*!
2546  \brief Executes the sql and returns the result as a string
2547  \param [in] dbh The handle
2548  \param [in] sql - sql to run
2549  \param [out] str - buffer for result
2550  \param [in] len - length of str buffer
2551  \param [out] err - Error if it exists
2552 */
2553 SWITCH_DECLARE(char *) switch_cache_db_execute_sql2str(switch_cache_db_handle_t *dbh, char *sql, char *str, size_t len, char **err);
2554 /*!
2555  \brief Executes the sql
2556  \param [in] dbh The handle
2557  \param [in] sql - sql to run
2558  \param [out] err - Error if it exists
2559 */
2561 /*!
2562  \brief Executes the sql and uses callback for row-by-row processing
2563  \param [in] dbh The handle
2564  \param [in] sql - sql to run
2565  \param [in] callback - function pointer to callback
2566  \param [in] pdata - data to pass to callback
2567  \param [out] err - Error if it exists
2568 */
2570  switch_core_db_callback_func_t callback, void *pdata, char **err);
2571 
2572 /*!
2573  \brief Executes the sql and uses callback for row-by-row processing
2574  \param [in] dbh The handle
2575  \param [in] sql - sql to run
2576  \param [in] callback - function pointer to callback
2577  \param [in] err_callback - function pointer to callback when error occurs
2578  \param [in] pdata - data to pass to callback
2579  \param [out] err - Error if it exists
2580 */
2584  void *pdata, char **err);
2585 
2586 /*!
2587  \brief Get the affected rows of the last performed query
2588  \param [in] dbh The handle
2589  \param [out] the number of affected rows
2590 */
2592 
2593 /*!
2594  \brief load an external extension to db
2595  \param [in] dbh The handle
2596  \param [out] the path to the extension
2597 */
2599 
2600 /*!
2601  \brief Provides some feedback as to the status of the db connection pool
2602  \param [in] stream stream for status
2603 */
2605 SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t ** dbh, const char *file, const char *func, int line);
2606 #define switch_core_db_handle(_a) _switch_core_db_handle(_a, __FILE__, __SWITCH_FUNC__, __LINE__)
2607 
2609  const char *test_sql, const char *drop_sql, const char *reactive_sql);
2612  const char *pre_trans_execute,
2613  const char *post_trans_execute,
2614  const char *inner_pre_trans_execute,
2615  const char *inner_post_trans_execute);
2616 #define switch_cache_db_persistant_execute_trans(_d, _s, _r) switch_cache_db_persistant_execute_trans_full(_d, _s, _r, NULL, NULL, NULL, NULL)
2617 
2619 SWITCH_DECLARE(uint32_t) switch_core_debug_level(void);
2621 SWITCH_DECLARE(const char *) switch_core_banner(void);
2622 SWITCH_DECLARE(switch_bool_t) switch_core_session_in_thread(switch_core_session_t *session);
2623 SWITCH_DECLARE(uint32_t) switch_default_ptime(const char *name, uint32_t number);
2624 SWITCH_DECLARE(uint32_t) switch_default_rate(const char *name, uint32_t number);
2625 
2626 /*!
2627  \brief Add user registration
2628  \param [in] user
2629  \param [in] realm
2630  \param [in] token
2631  \param [in] url - a freeswitch dial string
2632  \param [in] expires
2633  \param [in] network_ip
2634  \param [in] network_port
2635  \param [in] network_proto - one of tls, tcp, udp
2636  \param [in] metadata - generic metadata supplied by module
2637  \param [out] err - Error if it exists
2638 */
2639 SWITCH_DECLARE(switch_status_t) switch_core_add_registration(const char *user, const char *realm, const char *token, const char *url, uint32_t expires,
2640  const char *network_ip, const char *network_port, const char *network_proto,
2641  const char *metadata);
2642 /*!
2643  \brief Delete user registration
2644  \param [in] user
2645  \param [in] realm
2646  \param [in] token
2647  \param [out] err - Error if it exists
2648 */
2649 SWITCH_DECLARE(switch_status_t) switch_core_del_registration(const char *user, const char *realm, const char *token);
2650 /*!
2651  \brief Expire user registrations
2652  \param [in] force delete all registrations
2653  \param [out] err - Error if it exists
2654 */
2656 
2657 /*!
2658  \brief Get RTP port range start value
2659  \param[in] void
2660  \param[out] RTP port range start value
2661 */
2663 
2664 /*!
2665  \brief Get RTP port range end value
2666  \param[in] void
2667  \param[out] RTP port range end value
2668 */
2670 
2676 SWITCH_DECLARE(void) switch_say_file(switch_say_file_handle_t *sh, const char *fmt, ...);
2678 SWITCH_DECLARE(void) switch_close_extra_files(int *keep, int keep_ttl);
2680 SWITCH_DECLARE(void) switch_os_yield(void);
2682 SWITCH_DECLARE(void) switch_core_gen_encoded_silence(unsigned char *data, const switch_codec_implementation_t *read_impl, switch_size_t len);
2683 
2685 SWITCH_DECLARE(void) switch_core_sql_exec(const char *sql);
2686 SWITCH_DECLARE(int) switch_core_recovery_recover(const char *technology, const char *profile_name);
2687 SWITCH_DECLARE(void) switch_core_recovery_untrack(switch_core_session_t *session, switch_bool_t force);
2688 SWITCH_DECLARE(void) switch_core_recovery_track(switch_core_session_t *session);
2689 SWITCH_DECLARE(void) switch_core_recovery_flush(const char *technology, const char *profile_name);
2690 
2693 
2700  uint32_t numq, const char *dsn, uint32_t max_trans,
2701  const char *pre_trans_execute,
2702  const char *post_trans_execute,
2703  const char *inner_pre_trans_execute,
2704  const char *inner_post_trans_execute);
2705 
2706 #define switch_sql_queue_manager_init(_q, _n, _d, _m, _p1, _p2, _ip1, _ip2) switch_sql_queue_manager_init_name(__FILE__, _q, _n, _d, _m, _p1, _p2, _ip1, _ip2)
2707 
2711  const char *sql, switch_core_db_event_callback_func_t callback, void *pdata, char **err);
2712 
2715  void *pdata);
2719  void *pdata);
2720 
2723  void *pdata);
2727  void *pdata);
2728 
2729 SWITCH_DECLARE(pid_t) switch_fork(void);
2730 
2731 SWITCH_DECLARE(int) switch_core_gen_certs(const char *prefix);
2737 SWITCH_DECLARE(int) switch_system(const char *cmd, switch_bool_t wait);
2738 SWITCH_DECLARE(int) switch_stream_system_fork(const char *cmd, switch_stream_handle_t *stream);
2739 SWITCH_DECLARE(int) switch_stream_system(const char *cmd, switch_stream_handle_t *stream);
2740 
2741 SWITCH_DECLARE(switch_call_direction_t) switch_ice_direction(switch_core_session_t *session);
2743 
2744 SWITCH_DECLARE(const char *)switch_version_major(void);
2745 SWITCH_DECLARE(const char *)switch_version_minor(void);
2746 SWITCH_DECLARE(const char *)switch_version_micro(void);
2747 
2748 SWITCH_DECLARE(const char *)switch_version_revision(void);
2750 SWITCH_DECLARE(const char *)switch_version_full(void);
2751 SWITCH_DECLARE(const char *)switch_version_full_human(void);
2752 
2754 
2756 #endif
2757 /* For Emacs:
2758  * Local Variables:
2759  * mode:c
2760  * indent-tabs-mode:t
2761  * tab-width:4
2762  * c-basic-offset:4
2763  * End:
2764  * For VIM:
2765  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
2766  */
switch_status_t switch_sql_queue_manager_destroy(switch_sql_queue_manager_t **qmp)
switch_status_t switch_core_codec_decode_video(switch_codec_t *codec, switch_frame_t *frame)
Decode video data using a codec handle.
switch_console_callback_match_t * switch_core_session_findall(void)
switch_time_t stamp
Definition: switch_core.h:61
int32_t change_user_group(const char *user, const char *group)
Change user and/or group of the running process.
Definition: switch_core.c:1070
switch_status_t switch_core_speech_read_tts(switch_speech_handle_t *sh, void *data, switch_size_t *datalen, switch_speech_flag_t *flags)
Read rendered audio from the TTS module.
switch_frame_t * switch_core_media_bug_get_video_ping_frame(switch_media_bug_t *bug)
switch_time_t switch_micro_time_now(void)
Get the current epoch time in microseconds.
Definition: switch_time.c:310
void switch_core_session_hangup_state(switch_core_session_t *session, switch_bool_t force)
void * switch_core_hash_find_locked(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_ switch_mutex_t *mutex)
Retrieve data from a given hash.
const char * switch_core_get_switchname(void)
Definition: switch_core.c:349
switch_status_t switch_console_set_complete(const char *string)
void switch_core_thread_session_end(_In_ switch_core_session_t *session)
Signal a thread using a thread session to terminate.
void switch_time_sync(void)
Definition: switch_time.c:589
switch_xml_t xml_cdr
Definition: switch_core.h:81
switch_status_t switch_ivr_dmachine_set_terminators(switch_ivr_dmachine_t *dmachine, const char *terminators)
switch_status_t switch_core_session_io_write_lock(switch_core_session_t *session)
void switch_core_session_set_dmachine(switch_core_session_t *session, switch_ivr_dmachine_t *dmachine, switch_digit_action_target_t target)
A module interface to implement an application.
switch_status_t switch_cache_db_execute_sql_event_callback(switch_cache_db_handle_t *dbh, const char *sql, switch_core_db_event_callback_func_t callback, void *pdata, char **err)
void switch_close_extra_files(int *keep, int keep_ttl)
Definition: switch_core.c:3096
#define _Printf_format_string_
switch_status_t switch_core_asr_start_input_timers(switch_asr_handle_t *ah)
Start input timers on an asr handle.
switch_status_t switch_core_mime_add_type(const char *type, const char *ext)
Definition: switch_core.c:1220
void switch_sql_queue_manager_execute_sql_event_callback_err(switch_sql_queue_manager_t *qm, const char *sql, switch_core_db_event_callback_func_t callback, switch_core_db_err_callback_func_t err_callback, void *pdata)
char * switch_core_session_sprintf(_In_ switch_core_session_t *session, _In_z_ _Printf_format_string_ const char *fmt,...)
printf-style style printing routine. The data is output to a string allocated from the session ...
switch_status_t switch_core_codec_parse_fmtp(const char *codec_name, const char *fmtp, uint32_t rate, switch_codec_fmtp_t *codec_fmtp)
int switch_sql_queue_manager_size(switch_sql_queue_manager_t *qm, uint32_t index)
Image Descriptor.
Definition: switch_image.h:88
void switch_core_memory_reclaim_logger(void)
Definition: switch_log.c:544
void switch_core_session_reporting_state(switch_core_session_t *session)
Call Specific Data.
Definition: switch_caller.h:73
switch_status_t switch_core_port_allocator_free_port(_In_ switch_core_port_allocator_t *alloc, _In_ switch_port_t port)
Return unused port to the port allocator.
switch_status_t switch_core_inthash_init(switch_inthash_t **hash)
#define SWITCH_THREAD_FUNC
switch_text_channel_t
A target to write log/debug info to.
switch_status_t switch_core_timer_init(switch_timer_t *timer, const char *timer_name, int interval, int samples, switch_memory_pool_t *pool)
Request a timer handle using given time module.
switch_core_session_message_types_t message_id
Definition: switch_core.h:181
switch_status_t switch_core_session_set_codec_slin(switch_core_session_t *session, switch_slin_data_t *data)
void switch_core_session_reset(_In_ switch_core_session_t *session, switch_bool_t flush_dtmf, switch_bool_t reset_read_codec)
Reset the buffers and resampler on a session.
switch_status_t switch_core_asr_disable_all_grammars(switch_asr_handle_t *ah)
Disable all grammars from an asr handle.
switch_time_t switch_core_uptime(void)
Number of microseconds the system has been up.
Definition: switch_core.c:2467
switch_status_t switch_core_hash_destroy(_Inout_ switch_hash_t **hash)
Destroy an existing hash table.
void switch_core_asr_float_param(switch_asr_handle_t *ah, char *param, double val)
Set a float parameter on an asr handle.
const char * switch_version_minor(void)
void * switch_core_hash_find(_In_ switch_hash_t *hash, _In_z_ const char *key)
Retrieve data from a given hash.
struct switch_hold_record_s * next
Definition: switch_core.h:76
void switch_core_session_signal_state_change(_In_ switch_core_session_t *session)
struct switch_odbc_handle switch_odbc_handle_t
char * switch_core_vsprintf(switch_memory_pool_t *pool, _In_z_ _Printf_format_string_ const char *fmt, va_list ap)
printf-style style printing routine. The data is output to a string allocated from the pool ...
switch_status_t switch_core_asr_get_result_headers(switch_asr_handle_t *ah, switch_event_t **headers, switch_asr_flag_t *flags)
Get result headers from an asr handle.
void(* switch_media_bug_exec_cb_t)(switch_media_bug_t *bug, void *user_data)
switch_status_t switch_core_directory_query(switch_directory_handle_t *dh, char *base, char *query)
Query a directory handle.
Abstraction of an module endpoint interface This is the glue between the abstract idea of a "channel"...
void * switch_core_media_bug_get_user_data(_In_ switch_media_bug_t *bug)
Obtain private data from a media bug.
switch_size_t string_arg_size
Definition: switch_core.h:188
uint32_t switch_core_sessions_per_second(_In_ uint32_t new_limit)
Set/Get Session Rate Limit.
void switch_core_media_bug_flush(_In_ switch_media_bug_t *bug)
Flush the read and write buffers for the bug.
int switch_core_test_flag(int flag)
Definition: switch_core.c:1800
switch_status_t switch_core_session_set_video_read_callback(switch_core_session_t *session, switch_core_video_thread_callback_func_t func, void *user_data)
const char * switch_version_full(void)
uint32_t switch_io_flag_t
int switch_stream_system_fork(const char *cmd, switch_stream_handle_t *stream)
Definition: switch_core.c:3206
switch_frame_t * switch_core_media_bug_get_native_read_frame(switch_media_bug_t *bug)
void switch_time_set_nanosleep(switch_bool_t enable)
Definition: switch_time.c:365
switch_status_t(* switch_core_video_thread_callback_func_t)(switch_core_session_t *session, switch_frame_t *frame, void *user_data)
uint16_t switch_core_get_rtp_port_range_end_port(void)
Get RTP port range end value.
Definition: switch_core.c:3295
#define SWITCH_END_EXTERN_C
Definition: switch.h:43
switch_device_state_t state
Definition: switch_core.h:126
switch_mutex_t * mutex
Definition: switch_core.h:218
void switch_core_media_bug_set_write_replace_frame(_In_ switch_media_bug_t *bug, _In_ switch_frame_t *frame)
Set a return replace frame.
#define MESSAGE_STRING_ARG_MAX
Definition: switch_core.h:175
switch_status_t switch_core_file_read_video(switch_file_handle_t *fh, switch_frame_t *frame, switch_video_read_flag_t flags)
switch_device_state_t last_state
Definition: switch_core.h:127
switch_status_t switch_core_init(_In_ switch_core_flag_t flags, _In_ switch_bool_t console, _Out_ const char **err)
Initilize the core.
char * switch_core_perform_strdup(_In_ switch_memory_pool_t *pool, _In_z_ const char *todup, _In_z_ const char *file, _In_z_ const char *func, _In_ int line)
switch_status_t switch_core_session_perform_kill_channel(_In_ switch_core_session_t *session, const char *file, const char *func, int line, switch_signal_t sig)
char * switch_core_get_variable_pdup(_In_z_ const char *varname, switch_memory_pool_t *pool)
int32_t set_low_priority(void)
Definition: switch_core.c:932
switch_status_t switch_core_del_registration(const char *user, const char *realm, const char *token)
Delete user registration.
switch_status_t switch_core_session_set_video_read_codec(_In_ switch_core_session_t *session, switch_codec_t *codec)
Assign the video_read codec to a given session.
switch_cache_db_core_db_options_t core_db_options
Definition: switch_core.h:2473
switch_call_direction_t
Definition: switch_types.h:293
uint32_t switch_speech_flag_t
void switch_core_session_perform_destroy(_Inout_ switch_core_session_t **session, _In_z_ const char *file, _In_z_ const char *func, _In_ int line)
switch_device_stats_t stats
Definition: switch_core.h:124
uint32_t switch_core_debug_level(void)
Definition: switch_core.c:2522
#define SWITCH_MAX_CORE_THREAD_SESSION_OBJS
Definition: switch_core.h:46
switch_bool_t switch_core_running(void)
Definition: switch_core.c:2857
void switch_core_session_unsched_heartbeat(switch_core_session_t *session)
switch_status_t switch_core_session_perform_receive_message(_In_ switch_core_session_t *session, _In_ switch_core_session_message_t *message, const char *file, const char *func, int line)
Receive a message on a given session.
const char * switch_version_major(void)
switch_pvt_class_t
Definition: switch_types.h:248
void switch_core_remove_state_handler(_In_ const switch_state_handler_table_t *state_handler)
Remove a global state handler.
switch_codec_t * switch_core_session_get_video_read_codec(_In_ switch_core_session_t *session)
Retrieve the video_read codec from a given session.
switch_bool_t
Definition: switch_types.h:405
switch_mutex_t * switch_core_session_get_mutex(switch_core_session_t *session)
Signal a session's state machine thread that a state change has occured.
switch_audio_col_t
Definition: switch_types.h:578
switch_status_t switch_core_asr_open(switch_asr_handle_t *ah, const char *module_name, const char *codec, int rate, const char *dest, switch_asr_flag_t *flags, switch_memory_pool_t *pool)
Open an asr handle.
void(* switch_device_state_function_t)(switch_core_session_t *session, switch_channel_callstate_t callstate, switch_device_record_t *drec)
Definition: switch_core.h:143
switch_status_t switch_core_session_set_read_codec(_In_ switch_core_session_t *session, switch_codec_t *codec)
Assign the read codec to a given session.
switch_status_t switch_core_codec_encode(switch_codec_t *codec, switch_codec_t *other_codec, void *decoded_data, uint32_t decoded_data_len, uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
Encode data using a codec handle.
struct switch_pgsql_handle switch_pgsql_handle_t
switch_status_t switch_core_get_stacksizes(switch_size_t *cur, switch_size_t *max)
Definition: switch_core.c:3249
switch_status_t switch_core_asr_get_results(switch_asr_handle_t *ah, char **xmlstr, switch_asr_flag_t *flags)
Get results from an asr handle.
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_core_file_command(switch_file_handle_t *fh, switch_file_command_t command)
switch_status_t switch_core_file_set_string(_In_ switch_file_handle_t *fh, switch_audio_col_t col, const char *string)
Set metadata to the desired string.
switch_status_t switch_core_session_set_read_impl(switch_core_session_t *session, const switch_codec_implementation_t *impp)
switch_time_t active_stop
Definition: switch_core.h:129
uint8_t switch_core_session_check_interface(switch_core_session_t *session, const switch_endpoint_interface_t *endpoint_interface)
Checks if a session is using a specific endpoint.
switch_status_t switch_cache_db_execute_sql(switch_cache_db_handle_t *dbh, char *sql, char **err)
Executes the sql.
switch_status_t switch_core_session_set_video_write_codec(_In_ switch_core_session_t *session, switch_codec_t *codec)
Assign the video_write codec to a given session.
void * switch_core_session_get_stream(_In_ switch_core_session_t *session, _In_ int index)
Retreive a logical stream from a session.
switch_status_t _switch_core_db_handle(switch_cache_db_handle_t **dbh, const char *file, const char *func, int line)
Open the default system database.
switch_status_t switch_sql_queue_manager_init_name(const char *name, switch_sql_queue_manager_t **qmp, uint32_t numq, const char *dsn, uint32_t max_trans, const char *pre_trans_execute, const char *post_trans_execute, const char *inner_pre_trans_execute, const char *inner_post_trans_execute)
int switch_core_session_sync_clock(void)
void switch_core_session_raw_read(switch_core_session_t *session)
switch_status_t switch_core_media_bug_flush_all(_In_ switch_core_session_t *session)
Flush the read/write buffers for all media bugs on the session.
void switch_core_autobind_cpu(void)
switch_status_t switch_core_asr_feed_dtmf(switch_asr_handle_t *ah, const switch_dtmf_t *dtmf, switch_asr_flag_t *flags)
Feed DTMF to an asr handle.
void * switch_core_session_get_private_class(_In_ switch_core_session_t *session, _In_ switch_pvt_class_t index)
Retrieve private user data from a session.
switch_memory_pool_t * pool
void switch_ivr_dmachine_set_target(switch_ivr_dmachine_t *dmachine, switch_digit_action_target_t target)
void switch_core_media_bug_inuse(switch_media_bug_t *bug, switch_size_t *readp, switch_size_t *writep)
switch_status_t switch_core_file_get_string(_In_ switch_file_handle_t *fh, switch_audio_col_t col, const char **string)
get metadata of the desired string
switch_status_t switch_core_session_read_video_frame(_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
Read a video frame from a session.
Representation of an event.
Definition: switch_event.h:80
switch_core_session_t * switch_core_session_request_by_name(_In_z_ const char *endpoint_name, _In_ switch_call_direction_t direction, _Inout_ switch_memory_pool_t **pool)
Allocate and return a new session from the core based on a given endpoint module name.
switch_status_t switch_core_media_bug_set_pre_buffer_framecount(switch_media_bug_t *bug, uint32_t framecount)
switch_status_t switch_core_file_close(_In_ switch_file_handle_t *fh)
Close an open file handle.
int switch_core_session_get_stream_count(_In_ switch_core_session_t *session)
Determine the number of logical streams a session has.
switch_caller_profile_t * hup_profile
Definition: switch_core.h:85
void switch_core_set_variable(_In_z_ const char *varname, _In_opt_z_ const char *value)
Add a global variable to the core.
void * switch_core_inthash_find(switch_inthash_t *hash, uint32_t key)
void * switch_core_memory_pool_get_data(switch_memory_pool_t *pool, const char *key)
void switch_core_set_globals(void)
Initiate Globals.
Definition: switch_core.c:620
switch_core_session_t * switch_core_session_request_xml(switch_endpoint_interface_t *endpoint_interface, switch_memory_pool_t **pool, switch_xml_t xml)
void switch_media_bug_set_spy_fmt(switch_media_bug_t *bug, switch_vid_spy_fmt_t spy_fmt)
void switch_sql_queue_manager_pause(switch_sql_queue_manager_t *qm, switch_bool_t flush)
switch_status_t switch_say_file_handle_create(switch_say_file_handle_t **sh, const char *ext, switch_event_t **var_event)
uint16_t switch_core_get_rtp_port_range_start_port(void)
Get RTP port range start value.
Definition: switch_core.c:3284
void switch_core_speech_float_param_tts(switch_speech_handle_t *sh, char *param, double val)
Set a float parameter on a TTS handle.
switch_status_t switch_core_session_read_lock(_In_ switch_core_session_t *session)
Acquire a read lock on the session.
void switch_core_session_free_message(switch_core_session_message_t **message)
void switch_cond_yield(switch_interval_time_t t)
Definition: switch_time.c:657
switch_core_session_message_types_t
Possible types of messages for inter-session communication.
switch_digit_action_target_t
Definition: switch_types.h:273
switch_status_t switch_core_speech_feed_tts(switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags)
Feed text to the TTS module.
uint32_t switch_core_media_bug_count(switch_core_session_t *orig_session, const char *function)
switch_status_t switch_core_media_bug_remove_all_function(_In_ switch_core_session_t *session, const char *function)
Remove all media bugs from the session.
switch_status_t switch_core_file_seek(_In_ switch_file_handle_t *fh, unsigned int *cur_pos, int64_t samples, int whence)
Seek a position in a file.
static const char * switch_cache_db_type_name(switch_cache_db_handle_type_t type)
Definition: switch_core.h:2481
switch_status_t switch_core_destroy(void)
Destroy the core.
Definition: switch_core.c:2877
static void * switch_must_malloc(size_t _b)
Definition: switch_core.h:231
switch_status_t switch_core_perform_file_open(const char *file, const char *func, int line, _In_ switch_file_handle_t *fh, _In_opt_z_ const char *file_path, _In_ uint32_t channels, _In_ uint32_t rate, _In_ unsigned int flags, _In_opt_ switch_memory_pool_t *pool)
char str[MAX_FPSTRLEN]
Definition: switch_core.h:154
switch_core_session_t * switch_core_media_bug_get_session(_In_ switch_media_bug_t *bug)
Obtain the session from a media bug.
struct switch_hold_record_s switch_hold_record_t
switch_status_t switch_core_session_video_read_callback(switch_core_session_t *session, switch_frame_t *frame)
switch_status_t switch_core_session_exec(_In_ switch_core_session_t *session, _In_ const switch_application_interface_t *application_interface, _In_opt_z_ const char *arg)
Execute an application on a session.
switch_status_t switch_core_session_get_real_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
switch_status_t switch_core_timer_step(switch_timer_t *timer)
Step the timer one step.
switch_status_t switch_core_codec_decode(switch_codec_t *codec, switch_codec_t *other_codec, void *encoded_data, uint32_t encoded_data_len, uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
Decode data using a codec handle.
void switch_core_session_lock_codec_read(_In_ switch_core_session_t *session)
switch_status_t switch_core_asr_feed(switch_asr_handle_t *ah, void *data, unsigned int len, switch_asr_flag_t *flags)
Feed audio data to an asr handle.
void switch_core_media_bug_pause(switch_core_session_t *session)
Pause a media bug on the session.
switch_status_t switch_core_hash_delete_multi(_In_ switch_hash_t *hash, _In_ switch_hash_delete_callback_t callback, _In_opt_ void *pData)
Delete data from a hash based on callback function.
#define _Out_opt_ptrdiff_cap_(x)
switch_hup_type_t
Definition: switch_core.h:969
uint32_t switch_core_media_bug_set_flag(_In_ switch_media_bug_t *bug, _In_ uint32_t flag)
A representation of an XML tree.
Definition: switch_xml.h:76
switch_time_t active_start
Definition: switch_core.h:128
switch_call_cause_t switch_core_session_outgoing_channel(_In_opt_ switch_core_session_t *session, _In_opt_ switch_event_t *var_event, _In_z_ const char *endpoint_name, _In_ switch_caller_profile_t *caller_profile, _Inout_ switch_core_session_t **new_session, _Inout_ switch_memory_pool_t **pool, _In_ switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
Request an outgoing session spawned from an existing session using a desired endpoing module...
switch_status_t switch_core_codec_destroy(switch_codec_t *codec)
Destroy an initalized codec handle.
switch_memory_pool_t * pool
Definition: switch_core.h:69
switch_mutex_t * mutex
Definition: switch_core.h:138
const char * string_array_arg[MESSAGE_STRING_ARG_MAX]
Definition: switch_core.h:209
void switch_core_speech_numeric_param_tts(switch_speech_handle_t *sh, char *param, int val)
Set a numeric parameter on a TTS handle.
uint32_t switch_core_cpu_count(void)
Definition: switch_core.c:1042
switch_status_t switch_core_db_persistant_execute(switch_core_db_t *db, char *sql, uint32_t retries)
Execute a sql stmt until it is accepted.
switch_status_t switch_core_file_read(_In_ switch_file_handle_t *fh, void *data, switch_size_t *len)
Read media from a file handle.
const char * switch_core_mime_type2ext(const char *type)
Definition: switch_core.c:1207
void switch_core_media_bug_set_read_replace_frame(_In_ switch_media_bug_t *bug, _In_ switch_frame_t *frame)
Set a return replace frame.
switch_status_t switch_core_session_queue_message(_In_ switch_core_session_t *session, _In_ switch_core_session_message_t *message)
Queue a message on a session.
switch_bool_t(* switch_media_bug_callback_t)(switch_media_bug_t *, void *, switch_abc_type_t)
switch_status_t switch_core_timer_check(switch_timer_t *timer, switch_bool_t step)
Check if the current step has been exceeded.
uint32_t switch_originate_flag_t
Definition: switch_types.h:325
switch_status_t switch_core_media_bug_transfer_recordings(switch_core_session_t *orig_session, switch_core_session_t *new_session)
switch_status_t _switch_cache_db_get_db_handle(switch_cache_db_handle_t **dbh, switch_cache_db_handle_type_t type, switch_cache_db_connection_options_t *connection_options, const char *file, const char *func, int line)
Gets a new cached handle from the pool, potentially creating a new connection. The connection is boun...
switch_status_t switch_core_media_bug_patch_spy_frame(switch_media_bug_t *bug, switch_image_t *img, switch_rw_t rw)
void switch_core_speech_text_param_tts(switch_speech_handle_t *sh, char *param, const char *val)
Set a text parameter on a TTS handle.
void switch_time_set_timerfd(int enable)
Definition: switch_time.c:347
pack cur
Abstract handler to a timer module.
switch_status_t switch_core_session_execute_application_async(switch_core_session_t *session, const char *app, const char *arg)
int(* switch_core_db_callback_func_t)(void *pArg, int argc, char **argv, char **columnNames)
switch_status_t switch_core_media_bug_enumerate(switch_core_session_t *session, switch_stream_handle_t *stream)
switch_status_t switch_core_media_bug_add(_In_ switch_core_session_t *session, _In_ const char *function, _In_ const char *target, _In_ switch_media_bug_callback_t callback, _In_opt_ void *user_data, _In_ time_t stop_time, _In_ switch_media_bug_flag_t flags, _Out_ switch_media_bug_t **new_bug)
Add a media bug to the session.
int switch_core_cert_verify(dtls_fingerprint_t *fp)
switch_status_t switch_sql_queue_manager_push_confirm(switch_sql_queue_manager_t *qm, const char *sql, uint32_t pos, switch_bool_t dup)
switch_status_t switch_core_perform_destroy_memory_pool(_Inout_ switch_memory_pool_t **pool, _In_z_ const char *file, _In_z_ const char *func, _In_ int line)
uint32_t switch_core_flag_t
Definition: switch_types.h:376
switch_sql_queue_manager_t * qm
switch_hash_t * hash
Definition: switch_event.c:74
char * type
Definition: switch_core.h:153
switch_input_callback_function_t input_callback
Definition: switch_core.h:222
void switch_core_session_soft_lock(switch_core_session_t *session, uint32_t sec)
switch_status_t switch_core_session_read_frame(_In_ switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
Read a frame from a session.
int switch_stream_system(const char *cmd, switch_stream_handle_t *stream)
Definition: switch_core.c:3273
struct switch_device_stats_s switch_device_stats_t
switch_status_t switch_core_asr_load_grammar(switch_asr_handle_t *ah, const char *grammar, const char *name)
Load a grammar to an asr handle.
switch_event_t * event
Definition: switch_core.h:82
switch_codec_t * switch_core_session_get_write_codec(_In_ switch_core_session_t *session)
Retrieve the write codec from a given session.
A message object designed to allow unlike technologies to exchange data.
Definition: switch_core.h:177
uint32_t switch_core_session_message_flag_t
switch_console_callback_match_t * switch_core_session_findall_matching_var(const char *var_name, const char *var_val)
switch_status_t switch_core_asr_pause(switch_asr_handle_t *ah)
Pause detection on an asr handle.
switch_hash_index_t * switch_core_mime_index(void)
Definition: switch_core.c:1215
switch_memory_pool_t * pool
Definition: switch_core.h:223
switch_status_t switch_core_session_get_video_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
switch_status_t switch_cache_db_execute_sql_callback(switch_cache_db_handle_t *dbh, const char *sql, switch_core_db_callback_func_t callback, void *pdata, char **err)
Executes the sql and uses callback for row-by-row processing.
switch_status_t switch_core_session_set_uuid(_In_ switch_core_session_t *session, _In_z_ const char *use_uuid)
struct device_uuid_node_s * uuid_tail
Definition: switch_core.h:137
switch_status_t switch_core_thread_set_cpu_affinity(int cpu)
Definition: switch_core.c:1723
switch_status_t switch_core_expire_registration(int force)
Expire user registrations.
switch_core_session_message_flag_t flags
Definition: switch_core.h:205
void switch_core_session_unset_write_codec(_In_ switch_core_session_t *session)
switch_codec_t * switch_core_session_get_read_codec(_In_ switch_core_session_t *session)
Retrieve the read codec from a given session.
switch_status_t switch_core_session_queue_indication(_In_ switch_core_session_t *session, _In_ switch_core_session_message_types_t indication)
Queue an indication message on a session.
switch_size_t switch_core_session_id(void)
Provide the current session_id.
int(* switch_core_db_event_callback_func_t)(void *pArg, switch_event_t *event)
Definition: switch_core.h:2438
uint32_t switch_core_max_dtmf_duration(uint32_t duration)
Definition: switch_core.c:1664
switch_status_t switch_core_session_perform_get_partner(switch_core_session_t *session, switch_core_session_t **partner, const char *file, const char *func, int line)
Get the session's partner (the session its bridged to)
char * switch_core_get_domain(switch_bool_t dup)
Definition: switch_core.c:355
switch_video_read_flag_t
switch_status_t switch_core_session_io_read_lock(switch_core_session_t *session)
switch_time_t ring_stop
Definition: switch_core.h:132
int(* switch_core_db_err_callback_func_t)(void *pArg, const char *errmsg)
switch_status_t switch_core_codec_reset(switch_codec_t *codec)
switch_status_t switch_core_session_write_frame(_In_ switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
Write a frame to a session.
int switch_system(const char *cmd, switch_bool_t wait)
Definition: switch_core.c:3194
void switch_core_dump_variables(_In_ switch_stream_handle_t *stream)
void switch_say_file_handle_destroy(switch_say_file_handle_t **sh)
switch_status_t switch_core_session_get_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
void switch_cache_db_release_db_handle(switch_cache_db_handle_t **dbh)
Returns the handle to the pool, handle is NOT available to other threads until the allocating thread ...
_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.
switch_codec_control_command_t
switch_status_t switch_core_inthash_destroy(switch_inthash_t **hash)
void switch_core_recovery_track(switch_core_session_t *session)
uint8_t switch_core_session_compare(switch_core_session_t *a, switch_core_session_t *b)
Checks if 2 sessions are using the same endpoint module.
switch_status_t switch_core_session_io_rwunlock(switch_core_session_t *session)
switch_size_t switch_core_session_get_id(_In_ switch_core_session_t *session)
switch_status_t switch_core_chat_send(const char *dest_proto, switch_event_t *message_event)
int switch_core_cert_gen_fingerprint(const char *prefix, dtls_fingerprint_t *fp)
uint32_t switch_core_min_dtmf_duration(uint32_t duration)
Definition: switch_core.c:1704
int32_t set_auto_priority(void)
Definition: switch_core.c:1052
switch_frame_t * switch_core_media_bug_get_read_replace_frame(_In_ switch_media_bug_t *bug)
Obtain a replace frame from a media bug.
switch_status_t switch_core_media_bug_pop(switch_core_session_t *orig_session, const char *function, switch_media_bug_t **pop)
void switch_core_session_enable_heartbeat(switch_core_session_t *session, uint32_t seconds)
#define _Out_opt_
switch_status_t switch_core_session_get_app_flags(const char *app, int32_t *flags)
switch_status_t switch_core_speech_close(switch_speech_handle_t *sh, switch_speech_flag_t *flags)
Close an open speech handle.
switch_rw_t
Definition: switch_types.h:565
switch_codec_control_type_t
int64_t switch_time_t
Definition: switch_apr.h:188
double switch_core_idle_cpu(void)
switch_status_t switch_core_directory_next(switch_directory_handle_t *dh)
Obtain the next record in a lookup.
switch_status_t switch_core_media_bug_transfer_callback(switch_core_session_t *orig_session, switch_core_session_t *new_session, switch_media_bug_callback_t callback, void *(*user_data_dup_func)(switch_core_session_t *, void *))
void switch_os_yield(void)
Definition: switch_time.c:141
switch_status_t switch_core_session_execute_application_get_flags(_In_ switch_core_session_t *session, _In_ const char *app, _In_opt_z_ const char *arg, _Out_opt_ int32_t *flags)
Execute an application on a session.
cache_db_flag_t
Definition: switch_core.h:2441
switch_status_t switch_console_set_alias(const char *string)
switch_time_t on
Definition: switch_core.h:73
switch_core_session_t * switch_core_session_request_uuid(_In_ switch_endpoint_interface_t *endpoint_interface, _In_ switch_call_direction_t direction, switch_originate_flag_t originate_flags, _Inout_opt_ switch_memory_pool_t **pool, _In_opt_z_ const char *use_uuid)
Allocate and return a new session from the core.
struct switch_thread_data_s switch_thread_data_t
switch_status_t switch_core_get_variables(switch_event_t **event)
Definition: switch_core.c:374
uint32_t switch_core_media_bug_prune(switch_core_session_t *session)
switch_status_t _switch_cache_db_get_db_handle_dsn(switch_cache_db_handle_t **dbh, const char *dsn, const char *file, const char *func, int line)
switch_status_t switch_core_asr_close(switch_asr_handle_t *ah, switch_asr_flag_t *flags)
Close an asr handle.
switch_status_t switch_core_init_and_modload(_In_ switch_core_flag_t flags, _In_ switch_bool_t console, _Out_ const char **err)
Initilize the core and load modules.
switch_status_t switch_core_session_thread_pool_launch(switch_core_session_t *session)
switch_status_t switch_core_session_execute_exten(_In_ switch_core_session_t *session, _In_z_ const char *exten, _In_opt_z_ const char *dialplan, _In_opt_z_ const char *context)
Run a dialplan and execute an extension.
switch_status_t switch_core_hash_insert_locked(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ const void *data, _In_opt_ switch_mutex_t *mutex)
Insert data into a hash.
char * switch_core_get_uuid(void)
Retrieve the unique identifier from the core.
Definition: switch_core.c:482
switch_core_session_t * switch_core_session_perform_force_locate(const char *uuid_str, const char *file, const char *func, int line)
switch_status_t switch_core_port_allocator_request_port(_In_ switch_core_port_allocator_t *alloc, _Out_ switch_port_t *port_ptr)
Get a port from the port allocator.
void switch_core_recovery_untrack(switch_core_session_t *session, switch_bool_t force)
void * switch_core_inthash_delete(switch_inthash_t *hash, uint32_t key)
void switch_core_session_disable_heartbeat(switch_core_session_t *session)
switch_time_t hold_start
Definition: switch_core.h:133
void switch_time_set_matrix(switch_bool_t enable)
Definition: switch_time.c:359
void switch_core_asr_numeric_param(switch_asr_handle_t *ah, char *param, int val)
Set a numeric parameter on an asr handle.
switch_core_session_t * switch_core_session_perform_locate(const char *uuid_str, const char *file, const char *func, int line)
switch_core_flag_t switch_core_flags(void)
return core flags
Definition: switch_core.c:2852
void switch_core_hash_this_val(switch_hash_index_t *hi, void *val)
char * switch_core_perform_permanent_strdup(_In_z_ const char *todup, _In_z_ const char *file, _In_z_ const char *func, _In_ int line)
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)
switch_status_t switch_core_session_set_video_read_impl(switch_core_session_t *session, const switch_codec_implementation_t *impp)
switch_status_t switch_core_session_dequeue_signal_data(switch_core_session_t *session, void **signal_data)
void switch_core_setrlimits(void)
Definition: switch_core.c:1314
switch_size_t string_reply_size
Definition: switch_core.h:199
int switch_max_file_desc(void)
Definition: switch_core.c:3080
void switch_core_session_hupall(_In_ switch_call_cause_t cause)
Hangup all sessions.
switch_cache_db_handle_type_t
Definition: switch_core.h:2446
intptr_t switch_ssize_t
switch_frame_t * switch_core_media_bug_get_write_replace_frame(_In_ switch_media_bug_t *bug)
Obtain a replace frame from a media bug.
switch_status_t switch_core_session_send_dtmf(_In_ switch_core_session_t *session, const switch_dtmf_t *dtmf)
Send DTMF to a session.
switch_status_t switch_core_media_bug_push_spy_frame(switch_media_bug_t *bug, switch_frame_t *frame, switch_rw_t rw)
switch_status_t switch_core_session_set_video_write_impl(switch_core_session_t *session, const switch_codec_implementation_t *impp)
switch_call_direction_t direction
Definition: switch_core.h:86
switch_session_ctl_t
switch_codec_t * switch_core_session_get_effective_read_codec(_In_ switch_core_session_t *session)
Retrieve the effevtive read codec from a given session.
switch_status_t switch_core_media_bug_remove_callback(switch_core_session_t *session, switch_media_bug_callback_t callback)
Remove media bug callback.
switch_status_t switch_core_directory_close(switch_directory_handle_t *dh)
Close an open directory handle.
uint32_t switch_core_session_messages_waiting(switch_core_session_t *session)
void switch_core_memory_reclaim_all(void)
Definition: switch_core.c:2982
void switch_core_port_allocator_destroy(_Inout_ switch_core_port_allocator_t **alloc)
destroythe port allocator
switch_status_t switch_core_hash_insert_destructor(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ const void *data, hashtable_destructor_t destructor)
Insert data into a hash.
void switch_core_session_sched_heartbeat(switch_core_session_t *session, uint32_t seconds)
switch_status_t switch_core_inthash_insert(switch_inthash_t *hash, uint32_t key, const void *data)
switch_thread_start_t func
Definition: switch_core.h:66
int32_t set_normal_priority(void)
Set the maximum priority the process can obtain.
Definition: switch_core.c:1047
switch_status_t switch_core_add_registration(const char *user, const char *realm, const char *token, const char *url, uint32_t expires, const char *network_ip, const char *network_port, const char *network_proto, const char *metadata)
Add user registration.
switch_status_t switch_ivr_preprocess_session(switch_core_session_t *session, const char *cmds)
struct apr_thread_rwlock_t switch_thread_rwlock_t
Definition: switch_apr.h:436
uint32_t switch_core_session_flush_private_events(switch_core_session_t *session)
Flush the private event queue of a session.
switch_status_t switch_core_codec_copy(switch_codec_t *codec, switch_codec_t *new_codec, const switch_codec_settings_t *codec_settings, switch_memory_pool_t *pool)
void switch_core_session_debug_pool(switch_stream_handle_t *stream)
void switch_core_service_session_av(_In_ switch_core_session_t *session, switch_bool_t audio, switch_bool_t video)
Launch a service thread on a session to drop inbound data.
void switch_sql_queue_manager_execute_sql_event_callback(switch_sql_queue_manager_t *qm, const char *sql, switch_core_db_event_callback_func_t callback, void *pdata)
switch_status_t switch_core_session_dequeue_private_event(_In_ switch_core_session_t *session, _Out_ switch_event_t **event)
DE-Queue a private event on a given session.
switch_status_t switch_core_hash_insert_wrlock(switch_hash_t *hash, const char *key, const void *data, switch_thread_rwlock_t *rwlock)
Retrieve data from a given hash.
void switch_core_sqldb_resume(void)
switch_time_t ring_start
Definition: switch_core.h:131
static void * switch_must_realloc(void *_b, size_t _z)
Definition: switch_core.h:238
#define _In_opt_
void switch_core_db_test_reactive(switch_core_db_t *db, char *test_sql, char *drop_sql, char *reactive_sql)
perform a test query then perform a reactive query if the first one fails
uint32_t switch_core_media_bug_clear_flag(_In_ switch_media_bug_t *bug, _In_ uint32_t flag)
switch_status_t switch_strftime_tz(const char *tz, const char *format, char *date, size_t len, switch_time_t thetime)
Definition: switch_time.c:1458
switch_status_t switch_core_directory_open(switch_directory_handle_t *dh, char *module_name, char *source, char *dsn, char *passwd, switch_memory_pool_t *pool)
Open a directory handle.
int switch_cache_db_load_extension(switch_cache_db_handle_t *dbh, const char *extension)
load an external extension to db
switch_status_t switch_core_session_recv_dtmf(_In_ switch_core_session_t *session, const switch_dtmf_t *dtmf)
RECV DTMF on a session.
void switch_core_hash_this(_In_ switch_hash_index_t *hi, _Out_opt_ptrdiff_cap_(klen) const void **key, _Out_opt_ switch_ssize_t *klen, _Out_ void **val)
Gets the key and value of the current hash element.
switch_module_interface_name_t
Definition: switch_types.h:378
An abstraction of a data frame.
Definition: switch_frame.h:43
switch_status_t switch_core_asr_disable_grammar(switch_asr_handle_t *ah, const char *name)
Disable a grammar from an asr handle.
uintptr_t switch_size_t
switch_status_t switch_core_session_message_send(_In_z_ const char *uuid_str, _In_ switch_core_session_message_t *message)
Send a message to another session using it's uuid.
char * switch_cache_db_execute_sql2str(switch_cache_db_handle_t *dbh, char *sql, char *str, size_t len, char **err)
Executes the sql and returns the result as a string.
switch_status_t switch_cache_db_persistant_execute_trans_full(switch_cache_db_handle_t *dbh, char *sql, uint32_t retries, const char *pre_trans_execute, const char *post_trans_execute, const char *inner_pre_trans_execute, const char *inner_post_trans_execute)
switch_hash_index_t * switch_core_hash_next(_In_ switch_hash_index_t **hi)
Gets the next element of a hashtable.
FILE * switch_core_data_channel(switch_text_channel_t channel)
Retrieve a FILE stream of a given text channel name.
Definition: switch_core.c:263
uint8_t data[MAX_FPLEN+1]
Definition: switch_core.h:152
switch_status_t switch_core_media_bug_read(_In_ switch_media_bug_t *bug, _In_ switch_frame_t *frame, switch_bool_t fill)
Read a frame from the bug.
uint16_t switch_port_t
uint32_t switch_default_ptime(const char *name, uint32_t number)
Definition: switch_core.c:2026
uint32_t switch_asr_flag_t
switch_status_t switch_core_media_bug_remove(_In_ switch_core_session_t *session, _Inout_ switch_media_bug_t **bug)
Remove a media bug from the session.
int switch_core_cert_expand_fingerprint(dtls_fingerprint_t *fp, const char *str)
switch_codec_t * switch_core_session_get_video_write_codec(_In_ switch_core_session_t *session)
Retrieve the video_write codec from a given session.
struct device_uuid_node_s * next
Definition: switch_core.h:88
switch_vid_spy_fmt_t switch_media_bug_parse_spy_fmt(const char *name)
char * switch_core_session_vsprintf(switch_core_session_t *session, const char *fmt, va_list ap)
printf-style style printing routine. The data is output to a string allocated from the session ...
switch_size_t pointer_arg_size
Definition: switch_core.h:192
void switch_core_runtime_loop(int bg)
Run endlessly until the system is shutdown.
Definition: switch_core.c:1174
int switch_core_session_add_stream(_In_ switch_core_session_t *session, _In_opt_ void *private_info)
Add a logical stream to a session.
switch_status_t switch_core_session_send_and_request_video_refresh(switch_core_session_t *session)
void switch_cond_next(void)
Definition: switch_time.c:638
int64_t switch_interval_time_t
Definition: switch_apr.h:191
switch_size_t switch_core_session_id_dec(void)
switch_time_t call_start
Definition: switch_core.h:135
switch_status_t switch_core_session_get_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
switch_odbc_handle_t * odbc_dbh
Definition: switch_core.h:2454
char * switch_core_get_variable(_In_z_ const char *varname)
Retrieve a global variable from the core.
#define _In_z_
switch_channel_callstate_t
uint32_t switch_core_session_count(void)
Provide the total number of sessions.
#define MAX_FPSTRLEN
Definition: switch_core.h:148
double switch_core_min_idle_cpu(double new_limit)
switch_status_t switch_core_session_queue_event(_In_ switch_core_session_t *session, _Inout_ switch_event_t **event)
Queue an event on a given session.
switch_call_cause_t
switch_status_t switch_core_timer_destroy(switch_timer_t *timer)
Destroy an allocated timer.
switch_status_t switch_core_db_persistant_execute_trans(switch_core_db_t *db, char *sql, uint32_t retries)
void * objs[SWITCH_MAX_CORE_THREAD_SESSION_OBJS]
Definition: switch_core.h:220
switch_cache_db_odbc_options_t odbc_options
Definition: switch_core.h:2474
void switch_sql_queue_manager_execute_sql_callback(switch_sql_queue_manager_t *qm, const char *sql, switch_core_db_callback_func_t callback, void *pdata)
void * switch_core_hash_delete(_In_ switch_hash_t *hash, _In_z_ const char *key)
Delete data from a hash based on desired key.
void switch_core_memory_reclaim_events(void)
Definition: switch_event.c:499
switch_status_t switch_cache_db_persistant_execute(switch_cache_db_handle_t *dbh, const char *sql, uint32_t retries)
switch_device_state_t
void switch_core_session_rwunlock(_In_ switch_core_session_t *session)
Unlock a read or write lock on as given session.
int32_t set_realtime_priority(void)
Definition: switch_core.c:968
void switch_core_session_video_reset(switch_core_session_t *session)
char * switch_core_session_get_uuid(_In_ switch_core_session_t *session)
Retrieve the unique identifier from a session.
switch_channel_callstate_t callstate
Definition: switch_core.h:83
switch_mutex_t * mutex
#define _Out_
switch_cache_db_handle_t * dbh
switch_status_t switch_core_codec_encode_video(switch_codec_t *codec, switch_frame_t *frame)
Encode video data using a codec handle.
dtls_type_t
Definition: switch_core.h:157
const char * switch_version_full_human(void)
void switch_core_speech_flush_tts(switch_speech_handle_t *sh)
Flush TTS audio on a given handle.
void * switch_core_perform_alloc(_In_ switch_memory_pool_t *pool, _In_ switch_size_t memory, _In_z_ const char *file, _In_z_ const char *func, _In_ int line)
switch_status_t switch_core_session_flush_message(_In_ switch_core_session_t *session)
Flush a message queue on a given session.
void switch_core_sqldb_pause(void)
switch_status_t switch_core_timer_next(switch_timer_t *timer)
Wait for one cycle on an existing timer.
void switch_cache_db_flush_handles(void)
void switch_core_sql_exec(const char *sql)
#define _Inout_opt_
const char * switch_lookup_timezone(const char *tz_name)
Definition: switch_time.c:1361
switch_status_t switch_core_codec_init_with_bitrate(switch_codec_t *codec, const char *codec_name, const char *fmtp, const char *modname, uint32_t rate, int ms, int channels, uint32_t bitrate, uint32_t flags, const switch_codec_settings_t *codec_settings, switch_memory_pool_t *pool)
uint32_t switch_core_session_hupall_matching_var_ans(_In_ const char *var_name, _In_ const char *var_val, _In_ switch_call_cause_t cause, switch_hup_type_t type)
Hangup all sessions which match a specific channel variable.
int switch_core_add_state_handler(_In_ const switch_state_handler_table_t *state_handler)
Add a global state handler.
unsigned int switch_core_session_running(_In_ switch_core_session_t *session)
determine if the session's state machine is running
switch_status_t switch_core_session_write_video_frame(_In_ switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
Write a video frame to a session.
static char * switch_must_strdup(const char *_s)
Definition: switch_core.h:245
void switch_core_session_run(_In_ switch_core_session_t *session)
Start the session's state machine.
uint32_t switch_core_default_dtmf_duration(uint32_t duration)
Definition: switch_core.c:1681
switch_digit_action_target_t switch_ivr_dmachine_get_target(switch_ivr_dmachine_t *dmachine)
uint32_t switch_core_session_limit(_In_ uint32_t new_limit)
Set/Get Session Limit.
switch_status_t switch_core_session_request_video_refresh(switch_core_session_t *session)
switch_status_t switch_core_session_event_send(_In_z_ const char *uuid_str, _Inout_ switch_event_t **event)
Queue an event on another session using its uuid.
switch_status_t switch_core_asr_check_results(switch_asr_handle_t *ah, switch_asr_flag_t *flags)
Check an asr handle for results.
switch_core_db_t * core_db_dbh
Definition: switch_core.h:2453
switch_status_t switch_core_session_pass_indication(_In_ switch_core_session_t *session, _In_ switch_core_session_message_types_t indication)
pass an indication message on a session
void switch_time_set_monotonic(switch_bool_t enable)
Definition: switch_time.c:330
struct apr_thread_mutex_t switch_mutex_t
Definition: switch_apr.h:314
switch_thread_rwlock_t * rwlock
Definition: switch_event.c:73
switch_size_t pointer_reply_size
Definition: switch_core.h:203
switch_status_t
Common return values.
switch_status_t switch_core_file_write(_In_ switch_file_handle_t *fh, void *data, switch_size_t *len)
Write media to a file handle.
switch_memory_pool_t * pool
Definition: switch_core.h:139
switch_pgsql_handle_t * pgsql_dbh
Definition: switch_core.h:2455
switch_codec_t * switch_core_session_get_effective_write_codec(_In_ switch_core_session_t *session)
Retrieve the effevtive write codec from a given session.
switch_status_t switch_core_session_queue_private_event(_In_ switch_core_session_t *session, _Inout_ switch_event_t **event, switch_bool_t priority)
Queue a private event on a given session.
switch_status_t switch_core_session_read_lock_hangup(_In_ switch_core_session_t *session)
Acquire a read lock on the session.
uint32_t switch_core_media_bug_patch_video(switch_core_session_t *orig_session, switch_frame_t *frame)
dtls_state_t
Definition: switch_core.h:164
const switch_state_handler_table_t * switch_core_get_state_handler(_In_ int index)
Access a state handler.
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.
switch_status_t switch_core_session_set_private_class(_In_ switch_core_session_t *session, _In_ void *private_info, _In_ switch_pvt_class_t index)
Add private user data to a session.
void switch_core_session_write_lock(_In_ switch_core_session_t *session)
Acquire a write lock on the session.
switch_status_t switch_core_session_write_encoded_video_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
switch_cache_db_handle_type_t switch_cache_db_get_type(switch_cache_db_handle_t *dbh)
void switch_core_session_lock_codec_write(_In_ switch_core_session_t *session)
const char * switch_core_get_hostname(void)
Definition: switch_core.c:344
struct switch_device_record_s * parent
Definition: switch_core.h:87
switch_status_t switch_core_directory_next_pair(switch_directory_handle_t *dh, char **var, char **val)
Obtain the next name/value pair in the current record.
void switch_cache_db_dismiss_db_handle(switch_cache_db_handle_t **dbh)
Returns the handle to the pool, immediately available for other threads to use.
switch_file_command_t
switch_thread_t * switch_core_launch_thread(void *(SWITCH_THREAD_FUNC *func)(switch_thread_t *, void *), void *obj, switch_memory_pool_t *pool)
Launch a thread.
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's native message format.
uint32_t len
Definition: switch_core.h:151
int switch_cache_db_affected_rows(switch_cache_db_handle_t *dbh)
Get the affected rows of the last performed query.
struct sqlite3 switch_core_db_t
#define _Inout_
switch_vid_spy_fmt_t
void *SWITCH_THREAD_FUNC * switch_thread_start_t(switch_thread_t *, void *)
Definition: switch_apr.h:950
switch_status_t switch_core_chat_send_args(const char *dest_proto, const char *proto, const char *from, const char *to, const char *subject, const char *body, const char *type, const char *hint, switch_bool_t blocking)
void switch_core_memory_pool_set_data(switch_memory_pool_t *pool, const char *key, void *data)
switch_loadable_module_interface_t * switch_loadable_module_create_module_interface(switch_memory_pool_t *pool, const char *name)
_Ret_ void * switch_core_perform_session_alloc(_In_ switch_core_session_t *session, _In_ switch_size_t memory, const char *file, const char *func, int line)
switch_status_t switch_core_hash_init_case(_Out_ switch_hash_t **hash, switch_bool_t case_sensitive)
Initialize a hash table.
struct apr_thread_t switch_thread_t
Definition: switch_apr.h:941
switch_cache_db_pgsql_options_t pgsql_options
Definition: switch_core.h:2475
void switch_time_calibrate_clock(void)
Definition: switch_time.c:207
switch_status_t switch_core_media_bug_close(_Inout_ switch_media_bug_t **bug)
Close and destroy a media bug.
Main Library Header.
switch_ivr_dmachine_t * switch_core_session_get_dmachine(switch_core_session_t *session, switch_digit_action_target_t target)
struct dtls_fp_s dtls_fingerprint_t
uint32_t switch_core_session_event_count(_In_ switch_core_session_t *session)
Indicate the number of waiting events on a session.
void * switch_core_hash_delete_locked(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ switch_mutex_t *mutex)
Delete data from a hash based on desired key.
switch_status_t switch_core_speech_open(_In_ switch_speech_handle_t *sh, const char *module_name, const char *voice_name, _In_ unsigned int rate, _In_ unsigned int interval, _In_ unsigned int channels, switch_speech_flag_t *flags, _In_opt_ switch_memory_pool_t *pool)
Open a speech handle.
switch_bool_t switch_core_ready_outbound(void)
Determines if the core is ready to place outbound calls.
Definition: switch_core.c:2872
void switch_core_recovery_flush(const char *technology, const char *profile_name)
switch_status_t switch_core_asr_resume(switch_asr_handle_t *ah)
Resume detection on an asr handle.
#define SWITCH_DECLARE(type)
uint32_t switch_core_session_private_event_count(_In_ switch_core_session_t *session)
Indicate the number of waiting private events on a session.
void switch_core_media_bug_resume(switch_core_session_t *session)
Resume a media bug on the session.
switch_status_t switch_core_session_dequeue_message(_In_ switch_core_session_t *session, _Out_ switch_core_session_message_t **message)
DE-Queue an message on a given session.
switch_time_t switch_mono_micro_time_now(void)
Definition: switch_time.c:315
void switch_cache_db_status(switch_stream_handle_t *stream)
Provides some feedback as to the status of the db connection pool.
switch_status_t switch_sql_queue_manager_push(switch_sql_queue_manager_t *qm, const char *sql, uint32_t pos, switch_bool_t dup)
switch_status_t switch_core_session_send_dtmf_string(switch_core_session_t *session, const char *dtmf_string)
Send DTMF to a session.
switch_status_t switch_core_file_truncate(switch_file_handle_t *fh, int64_t offset)
switch_bool_t switch_core_file_has_video(switch_file_handle_t *fh, switch_bool_t CHECK_OPEN)
switch_status_t switch_core_session_wake_session_thread(_In_ switch_core_session_t *session)
switch_signal_t
Signals to send to channels.
struct device_uuid_node_s * uuid_list
Definition: switch_core.h:136
switch_app_log_t * switch_core_session_get_app_log(_In_ switch_core_session_t *session)
void switch_time_set_use_system_time(switch_bool_t enable)
Definition: switch_time.c:341
void switch_core_media_bug_set_read_demux_frame(_In_ switch_media_bug_t *bug, _In_ switch_frame_t *frame)
uint32_t switch_port_flag_t
Definition: switch_types.h:334
char * switch_core_perform_session_strdup(_In_ switch_core_session_t *session, _In_z_ const char *todup, _In_z_ const char *file, _In_z_ const char *func, _In_ int line)
switch_call_direction_t switch_ice_direction(switch_core_session_t *session)
switch_status_t switch_sql_queue_manager_stop(switch_sql_queue_manager_t *qm)
switch_cache_db_handle_type_t switch_core_dbtype(void)
void switch_core_memory_pool_tag(switch_memory_pool_t *pool, const char *tag)
void switch_core_session_hupall_endpoint(const switch_endpoint_interface_t *endpoint_interface, switch_call_cause_t cause)
Hangup all sessions that belong to an endpoint.
switch_status_t switch_cache_db_create_schema(switch_cache_db_handle_t *dbh, char *sql, char **err)
Executes the create schema sql.
void switch_time_set_cond_yield(switch_bool_t enable)
Definition: switch_time.c:372
char * switch_say_file_handle_get_path(switch_say_file_handle_t *sh)
const char * switch_core_mime_ext2type(const char *ext)
Definition: switch_core.c:1199
void switch_core_session_soft_unlock(switch_core_session_t *session)
time_t switch_epoch_time_now(time_t *t)
Get the current epoch time.
Definition: switch_time.c:321
switch_bool_t(* switch_hash_delete_callback_t)(_In_ const void *key, _In_ const void *val, _In_opt_ void *pData)
#define _Ret_
switch_status_t switch_core_session_set_write_codec(_In_ switch_core_session_t *session, switch_codec_t *codec)
Assign the write codec to a given session.
switch_bool_t switch_check_network_list_ip_token(const char *ip_str, const char *list_name, const char **token)
Definition: switch_core.c:1366
switch_status_t switch_sql_queue_manager_start(switch_sql_queue_manager_t *qm)
A generic object to pass as a thread's session object to allow mutiple arguements and a pool...
Definition: switch_core.h:214
void * switch_core_perform_permanent_alloc(_In_ switch_size_t memory, _In_z_ const char *file, _In_z_ const char *func, _In_ int line)
switch_status_t switch_core_chat_deliver(const char *dest_proto, switch_event_t **message_event)
struct apr_pool_t switch_memory_pool_t
switch_status_t switch_core_asr_enable_grammar(switch_asr_handle_t *ah, const char *name)
Enable a grammar from an asr handle.
switch_status_t switch_core_perform_new_memory_pool(_Out_ switch_memory_pool_t **pool, _In_z_ const char *file, _In_z_ const char *func, _In_ int line)
switch_bool_t switch_cache_db_test_reactive(switch_cache_db_handle_t *db, const char *test_sql, const char *drop_sql, const char *reactive_sql)
Performs test_sql and if it fails performs drop_sql and reactive_sql.
void switch_core_gen_encoded_silence(unsigned char *data, const switch_codec_implementation_t *read_impl, switch_size_t len)
char * switch_say_file_handle_get_variable(switch_say_file_handle_t *sh, const char *var)
switch_status_t switch_core_management_exec(char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen)
Execute a management operation.
Definition: switch_core.c:2970
void switch_core_session_unset_read_codec(_In_ switch_core_session_t *session)
void switch_sql_queue_manager_execute_sql_callback_err(switch_sql_queue_manager_t *qm, const char *sql, switch_core_db_callback_func_t callback, switch_core_db_err_callback_func_t err_callback, void *pdata)
A table of settings and callbacks that define a paticular implementation of a codec.
unsigned int switch_core_session_started(_In_ switch_core_session_t *session)
void switch_core_session_unlock_codec_write(_In_ switch_core_session_t *session)
switch_hold_record_t * hold_record
Definition: switch_core.h:84
#define _In_opt_z_
switch_status_t switch_core_file_write_video(_In_ switch_file_handle_t *fh, switch_frame_t *frame)
Write media to a file handle.
uint32_t switch_media_bug_flag_t
switch_frame_t * switch_core_media_bug_get_native_write_frame(switch_media_bug_t *bug)
switch_device_stats_t last_stats
Definition: switch_core.h:125
FILE * switch_core_get_console(void)
Get the output console.
Definition: switch_core.c:230
uint32_t switch_core_media_bug_test_flag(_In_ switch_media_bug_t *bug, _In_ uint32_t flag)
Test for the existance of a flag on an media bug.
void switch_load_network_lists(switch_bool_t reload)
Definition: switch_core.c:1436
switch_status_t switch_core_session_queue_signal_data(switch_core_session_t *session, void *signal_data)
void switch_core_set_signal_handlers(void)
Definition: switch_core.c:2494
void switch_sql_queue_manager_resume(switch_sql_queue_manager_t *qm)
int32_t switch_core_set_process_privileges(void)
Switch on the privilege awareness for the process and request required privileges.
Definition: switch_core.c:897
switch_time_t last_call_time
Definition: switch_core.h:130
switch_bool_t switch_core_hash_empty(switch_hash_t *hash)
tells if a hash is empty
const char * switch_core_banner(void)
Definition: switch_core.c:2342
switch_status_t switch_core_session_get_video_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
void switch_core_memory_reclaim(void)
switch_status_t switch_time_exp_tz_name(const char *tz, switch_time_exp_t *tm, switch_time_t thetime)
Definition: switch_time.c:1427
int switch_core_gen_certs(const char *prefix)
switch_status_t switch_core_media_bug_exec_all(switch_core_session_t *orig_session, const char *function, switch_media_bug_exec_cb_t cb, void *user_data)
const char * switch_version_revision_human(void)
int32_t switch_core_session_ctl(switch_session_ctl_t cmd, void *val)
send a control message to the core
Definition: switch_core.c:2528
char * filename
switch_log_level_t switch_core_session_get_loglevel(switch_core_session_t *session)
Get the log level for a session.
void * switch_core_hash_delete_wrlock(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ switch_thread_rwlock_t *rwlock)
Delete data from a hash based on desired key.
char * switch_core_sprintf(_In_ switch_memory_pool_t *pool, _In_z_ _Printf_format_string_ const char *fmt,...)
printf-style style printing routine. The data is output to a string allocated from the pool ...
#define switch_assert(expr)
int switch_core_recovery_recover(const char *technology, const char *profile_name)
switch_status_t switch_core_asr_unload_grammar(switch_asr_handle_t *ah, const char *name)
Unload a grammar from an asr handle.
const char * switch_version_micro(void)
switch_status_t switch_core_session_set_loglevel(switch_core_session_t *session, switch_log_level_t loglevel)
Sets the log level for a session.
struct device_uuid_node_s switch_device_node_t
switch_core_db_t * switch_core_db_open_file(const char *filename)
Open a core db (SQLite) file.
struct switch_device_record_s switch_device_record_t
void switch_core_asr_text_param(switch_asr_handle_t *ah, char *param, const char *val)
Set a text parameter on an asr handle.
switch_bool_t switch_core_ready_inbound(void)
Determines if the core is ready to take inbound calls.
Definition: switch_core.c:2867
char * switch_say_file_handle_detach_path(switch_say_file_handle_t *sh)
switch_status_t switch_cache_db_execute_sql_callback_err(switch_cache_db_handle_t *dbh, const char *sql, switch_core_db_callback_func_t callback, switch_core_db_err_callback_func_t err_callback, void *pdata, char **err)
Executes the sql and uses callback for row-by-row processing.
pid_t switch_fork(void)
Definition: switch_core.c:3134
switch_bool_t switch_core_ready(void)
Determines if the core is ready to take calls.
Definition: switch_core.c:2862
uint32_t switch_default_rate(const char *name, uint32_t number)
Definition: switch_core.c:2037
void * switch_core_hash_find_rdlock(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_ switch_thread_rwlock_t *rwlock)
Retrieve data from a given hash.
switch_status_t switch_core_session_set_write_impl(switch_core_session_t *session, const switch_codec_implementation_t *impp)
#define MAX_FPLEN
Definition: switch_core.h:147
void switch_core_measure_time(switch_time_t total_ms, switch_core_time_duration_t *duration)
Breakdown a number of milliseconds into various time spec.
Definition: switch_core.c:2450
switch_time_t off
Definition: switch_core.h:74
switch_bool_t switch_core_session_in_thread(switch_core_session_t *session)
switch_memory_pool_t * switch_core_session_get_pool(_In_ switch_core_session_t *session)
Retrieve the memory pool from a session.
void switch_core_session_unlock_codec_read(_In_ switch_core_session_t *session)
switch_log_level_t
Log Level Enumeration.
void switch_core_session_destroy_state(switch_core_session_t *session)
void switch_core_screen_size(int *x, int *y)
Definition: switch_core.c:238
switch_management_action_t
Definition: switch_types.h:449
The abstraction of a loadable module.
void(* hashtable_destructor_t)(void *ptr)
const char * switch_version_revision(void)
char * switch_core_get_variable_dup(_In_z_ const char *varname)
struct switch_app_log * next
Definition: switch_core.h:62
void * switch_loadable_module_create_interface(switch_loadable_module_interface_t *mod, switch_module_interface_name_t iname)
switch_status_t switch_core_codec_control(switch_codec_t *codec, switch_codec_control_command_t cmd, switch_codec_control_type_t ctype, void *cmd_data, switch_codec_control_type_t atype, void *cmd_arg, switch_codec_control_type_t *rtype, void **ret_data)
send control data using a codec handle
switch_status_t switch_core_port_allocator_new(_In_ const char *ip, _In_ switch_port_t start, _In_ switch_port_t end, _In_ switch_port_flag_t flags, _Out_ switch_core_port_allocator_t **new_allocator)
Initilize the port allocator.
switch_status_t switch_core_session_set_real_read_codec(_In_ switch_core_session_t *session, switch_codec_t *codec)
Assign the original read codec to a given session. This is the read codec used by an endpoint...
switch_status_t switch_core_session_thread_launch(_In_ switch_core_session_t *session)
Launch the session thread (state machine) on a given session.
#define _In_
switch_status_t switch_core_timer_sync(switch_timer_t *timer)
switch_time_t switch_time_ref(void)
Definition: switch_time.c:576
switch_status_t switch_thread_pool_launch_thread(switch_thread_data_t **tdp)
void switch_core_session_launch_thread(_In_ switch_core_session_t *session, _In_ void *(*func)(switch_thread_t *, void *), _In_opt_ void *obj)
Launch a thread designed to exist within the scope of a given session.
#define SWITCH_BEGIN_EXTERN_C
Definition: switch.h:42
switch_time_t hold_stop
Definition: switch_core.h:134
switch_status_t switch_core_set_console(const char *console)
Set the output console to the desired file.
Definition: switch_core.c:220
void switch_say_file(switch_say_file_handle_t *sh, const char *fmt,...)
switch_jb_t * switch_core_session_get_jb(switch_core_session_t *session, switch_media_type_t type)
switch_media_type_t
switch_hash_index_t * switch_core_hash_first_iter(_In_ switch_hash_t *hash, switch_hash_index_t *hi)
Gets the first element of a hashtable.