RTS API Documentation  1.10.11
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-2020, 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  * Andrey Volk <andywolk@gmail.com>
31  *
32  * switch_core.h -- Core Library
33  *
34  */
35 /*! \file switch_core.h
36  \brief Core Library
37 
38  This module is the main core library and is the intended location of all fundamental operations.
39 */
40 
41 #ifndef SWITCH_CORE_H
42 #define SWITCH_CORE_H
43 
44 #include <switch.h>
45 
47 #define SWITCH_MAX_CORE_THREAD_SESSION_OBJS 128
48 #define SWITCH_MAX_STREAMS 128
50  uint32_t mms;
51  uint32_t ms;
52  uint32_t sec;
53  uint32_t min;
54  uint32_t hr;
55  uint32_t day;
56  uint32_t yr;
57 };
58 
60  char *app;
61  char *arg;
64 };
65 
66 typedef struct switch_thread_data_s {
68  void *obj;
69  int alloc;
70  int running;
73 
74 typedef struct switch_hold_record_s {
77  char *uuid;
80 
81 typedef struct device_uuid_node_s {
82  char *uuid;
92 
93 typedef struct switch_device_stats_s {
94  uint32_t total;
95  uint32_t total_in;
96  uint32_t total_out;
97  uint32_t offhook;
98  uint32_t offhook_in;
99  uint32_t offhook_out;
100  uint32_t active;
101  uint32_t active_in;
102  uint32_t active_out;
103  uint32_t held;
104  uint32_t held_in;
105  uint32_t held_out;
106  uint32_t unheld;
107  uint32_t unheld_in;
108  uint32_t unheld_out;
109  uint32_t hup;
110  uint32_t hup_in;
111  uint32_t hup_out;
112  uint32_t ringing;
113  uint32_t ringing_in;
114  uint32_t ringing_out;
115  uint32_t early;
116  uint32_t early_in;
117  uint32_t early_out;
118  uint32_t ring_wait;
120 
121 
122 typedef struct switch_device_record_s {
123  char *device_id;
124  char *uuid;
125  int refs;
142  void *user_data;
144 
146 
147 
148 #define DTLS_SRTP_FNAME "dtls-srtp"
149 #define MAX_FPLEN 64
150 #define MAX_FPSTRLEN 192
151 
152 typedef struct dtls_fp_s {
153  uint32_t len;
154  uint8_t data[MAX_FPLEN+1];
155  char *type;
156  char str[MAX_FPSTRLEN];
158 
159 typedef enum {
160  DTLS_TYPE_CLIENT = (1 << 0),
161  DTLS_TYPE_SERVER = (1 << 1),
162  DTLS_TYPE_RTP = (1 << 2),
163  DTLS_TYPE_RTCP = (1 << 3)
164 } dtls_type_t;
165 
166 typedef enum {
173 } dtls_state_t;
174 
175 #define MESSAGE_STAMP_FFL(_m) _m->_file = __FILE__; _m->_func = __SWITCH_FUNC__; _m->_line = __LINE__
176 
177 #define MESSAGE_STRING_ARG_MAX 10
178 /*! \brief A message object designed to allow unlike technologies to exchange data */
180  /*! uuid of the sender (for replies) */
181  char *from;
182  /*! enumeration of the type of message */
184 
185  /*! optional numeric arg */
187  /*! optional string arg */
188  const char *string_arg;
189  /*! optional string arg */
191  /*! optional arbitrary pointer arg */
192  void *pointer_arg;
193  /*! optional arbitrary pointer arg's size */
195 
196  /*! optional numeric reply */
198  /*! optional string reply */
200  /*! optional string reply */
202  /*! optional arbitrary pointer reply */
204  /*! optional arbitrary pointer reply's size */
206  /*! message flags */
208  const char *_file;
209  const char *_func;
210  int _line;
211  const char *string_array_arg[MESSAGE_STRING_ARG_MAX];
213 };
214 
215 /*! \brief A generic object to pass as a thread's session object to allow mutiple arguements and a pool */
217  /*! status of the thread */
218  int running;
219  /*! mutex */
221  /*! array of void pointers to pass mutiple data objects */
223  /*! a pointer to a memory pool if the thread has it's own pool */
226 };
227 
228 struct switch_core_session;
229 struct switch_core_runtime;
231 
232 
233 static inline void *switch_must_malloc(size_t _b)
234 {
235  void *m = malloc(_b);
236  switch_assert(m);
237  return m;
238 }
239 
240 static inline void *switch_must_realloc(void *_b, size_t _z)
241 {
242  void *m = realloc(_b, _z);
243  switch_assert(m);
244  return m;
245 }
246 
247 /*!
248  \defgroup core1 Core Library
249  \ingroup FREESWITCH
250  \{
251 */
252 
253 ///\defgroup mb1 Media Bugs
254 ///\ingroup core1
255 ///\{
256 
257 
258 SWITCH_DECLARE(void) switch_core_screen_size(int *x, int *y);
261 
264 
265 #define switch_core_session_get_name(_s) switch_channel_get_name(switch_core_session_get_channel(_s))
266 
268 
270  const char *function, switch_media_bug_exec_cb_t cb, void *user_data);
272 SWITCH_DECLARE(uint32_t) switch_core_media_bug_count(switch_core_session_t *orig_session, const char *function);
277 
278 /*!
279  \brief Add a media bug to the session
280  \param session the session to add the bug to
281  \param function user defined module/function/reason identifying this bug
282  \param target user defined identification of the target of the bug
283  \param callback a callback for events
284  \param user_data arbitrary user data
285  \param stop_time absolute time at which the bug is automatically removed (or 0)
286  \param flags flags to choose the stream
287  \param new_bug pointer to assign new bug to
288  \return SWITCH_STATUS_SUCCESS if the operation was a success
289 */
291  _In_ const char *function,
292  _In_ const char *target,
294  _In_opt_ void *user_data,
295  _In_ time_t stop_time, _In_ switch_media_bug_flag_t flags, _Out_ switch_media_bug_t **new_bug);
296 
297 /*!
298  \brief Pause a media bug on the session
299  \param session the session to pause the bug on sets CF_PAUSE_BUGS flag
300 */
302 
303 /*!
304  \brief Resume a media bug on the session
305  \param session the session to resume the bug on, clears CF_PAUSE_BUGS flag
306 */
308 
310 
311 /*!
312  \brief Obtain private data from a media bug
313  \param bug the bug to get the data from
314  \return the private data
315 */
317 
318 /*!
319  \brief Obtain a replace frame from a media bug
320  \param bug the bug to get the data from
321 */
323 
324 
327 
328 
330 
331 /*!
332  \brief Set a return replace frame
333  \param bug the bug to set the frame on
334  \param frame the frame to set
335 */
337 
338 /*!
339  \brief Obtain a replace frame from a media bug
340  \param bug the bug to get the data from
341 */
344 /*!
345  \brief Obtain the session from a media bug
346  \param bug the bug to get the data from
347 */
349 
352 
354 
355 /*!
356  \brief Test for the existance of a flag on an media bug
357  \param bug the object to test
358  \param flag the or'd list of flags to test
359  \return true value if the object has the flags defined
360 */
364 
365 /*!
366  \brief Set a return replace frame
367  \param bug the bug to set the frame on
368  \param frame the frame to set
369 */
371 
372 SWITCH_DECLARE(uint32_t) switch_core_cpu_count(void);
373 
374 /*!
375  \brief Remove a media bug from the session
376  \param session the session to remove the bug from
377  \param bug bug to remove
378  \return SWITCH_STATUS_SUCCESS if the operation was a success
379 */
380 
383 
384 /*!
385  \brief Remove media bug callback
386  \param bug bug to remove
387  \param callback callback to remove
388  \return SWITCH_STATUS_SUCCESS if the operation was a success
389 */
391 
392 /*!
393  \brief Close and destroy a media bug
394  \param bug bug to remove
395  \return SWITCH_STATUS_SUCCESS if the operation was a success
396 */
398 /*!
399  \brief Remove all media bugs from the session
400  \param session the session to remove the bugs from
401  \return SWITCH_STATUS_SUCCESS if the operation was a success
402 */
404 
405 #define switch_core_media_bug_remove_all(_s) switch_core_media_bug_remove_all_function(_s, NULL)
406 
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 SWITCH_STATUS_SUCCESS if the operation was a success
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 */
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 
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
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
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
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 
624  _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
625 
626 ///\defgroup memp Memory Pooling/Allocation
627 ///\ingroup core1
628 ///\{
629 /*!
630  \brief Create a new sub memory pool from the core's master pool
631  \return SWITCH_STATUS_SUCCESS on success
632 */
633 #define switch_core_new_memory_pool(p) switch_core_perform_new_memory_pool(p, __FILE__, __SWITCH_FUNC__, __LINE__)
634 
637  _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
638 /*!
639  \brief Returns a subpool back to the main pool
640  \return SWITCH_STATUS_SUCCESS on success
641 */
642 #define switch_core_destroy_memory_pool(p) switch_core_perform_destroy_memory_pool(p, __FILE__, __SWITCH_FUNC__, __LINE__)
643 
644 
647 
648 
649 /*!
650  \brief Start the session's state machine
651  \param session the session on which to start the state machine
652 */
654 
655 /*!
656  \brief determine if the session's state machine is running
657  \param session the session on which to check
658 */
661 
662 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);
663 
664 
665 /*!
666  \brief Allocate memory from the main pool with no intention of returning it
667  \param _memory the number of bytes to allocate
668  \return a void pointer to the allocated memory
669  \note this memory never goes out of scope until the core is destroyed
670 */
671 #define switch_core_permanent_alloc(_memory) switch_core_perform_permanent_alloc(_memory, __FILE__, __SWITCH_FUNC__, __LINE__)
672 
673 
675  _In_z_ const char *func, _In_ int line);
676 
677 /*!
678  \brief Allocate memory directly from a memory pool
679  \param _pool the memory pool to allocate from
680  \param _mem the number of bytes to allocate
681  \remark the memory returned has been memset to zero
682  \return a void pointer to the allocated memory
683 */
684 #define switch_core_alloc(_pool, _mem) switch_core_perform_alloc(_pool, _mem, __FILE__, __SWITCH_FUNC__, __LINE__)
685 
687  const char *func, int line);
688 
689 /*!
690  \brief Allocate memory from a session's pool
691  \param _session the session to request memory from
692  \param _memory the amount of memory to allocate
693  \return a void pointer to the newly allocated memory
694  \note the memory will be in scope as long as the session exists
695 */
696 #define switch_core_session_alloc(_session, _memory) switch_core_perform_session_alloc(_session, _memory, __FILE__, __SWITCH_FUNC__, __LINE__)
697 
698 
699 
700 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);
701 
702 /*!
703  \brief Copy a string using permanent memory allocation
704  \param _todup the string to duplicate
705  \return a pointer to the newly duplicated string
706 */
707 #define switch_core_permanent_strdup(_todup) switch_core_perform_permanent_strdup(_todup, __FILE__, __SWITCH_FUNC__, __LINE__)
708 
709 
710 SWITCH_DECLARE(char *) switch_core_perform_session_strdup(_In_ switch_core_session_t *session, _In_z_ const char *todup, _In_z_ const char *file,
711  _In_z_ const char *func, _In_ int line);
712 
713 /*!
714  \brief Copy a string using memory allocation from a session's pool
715  \param _session a session to use for allocation
716  \param _todup the string to duplicate
717  \return a pointer to the newly duplicated string
718 */
719 #define switch_core_session_strdup(_session, _todup) switch_core_perform_session_strdup(_session, _todup, __FILE__, __SWITCH_FUNC__, __LINE__)
720 
721 
722 SWITCH_DECLARE(char *) switch_core_perform_strdup(_In_ switch_memory_pool_t *pool, _In_z_ const char *todup, _In_z_ const char *file,
723  _In_z_ const char *func, _In_ int line);
724 SWITCH_DECLARE(char *) switch_core_perform_strndup(_In_ switch_memory_pool_t *pool, _In_z_ const char *todup, size_t len, _In_z_ const char *file,
725  _In_z_ const char *func, _In_ int line);
726 
727 /*!
728  \brief Copy a string using memory allocation from a given pool
729  \param _pool the pool to use for allocation
730  \param _todup the string to duplicate
731  \return a pointer to the newly duplicated string
732 */
733 #define switch_core_strdup(_pool, _todup) switch_core_perform_strdup(_pool, _todup, __FILE__, __SWITCH_FUNC__, __LINE__)
734 
735 #define switch_core_strndup(_pool, _todup, _len) switch_core_perform_strndup(_pool, _todup, _len, __FILE__, __SWITCH_FUNC__, __LINE__)
736 
737 /*!
738  \brief printf-style style printing routine. The data is output to a string allocated from the session
739  \param session a session to use for allocation
740  \param fmt The format of the string
741  \param ... The arguments to use while printing the data
742  \return The new string
743 */
745 
746 /*!
747  \brief printf-style style printing routine. The data is output to a string allocated from the session
748  \param session a session to use for allocation
749  \param fmt The format of the string
750  \param ap The arguments to use while printing the data
751  \return The new string
752 */
753 #ifndef SWIG
754 SWITCH_DECLARE(char *) switch_core_session_vsprintf(switch_core_session_t *session, const char *fmt, va_list ap);
755 #endif
756 
757 /*!
758  \brief printf-style style printing routine. The data is output to a string allocated from the pool
759  \param pool a pool to use for allocation
760  \param fmt The format of the string
761  \param ... The arguments to use while printing the data
762  \return The new string
763 */
765 
766 /*!
767  \brief printf-style style printing routine. The data is output to a string allocated from the pool
768  \param pool a pool to use for allocation
769  \param fmt The format of the string
770  \param ap The arguments to use while printing the data
771  \return The new string
772 */
773 #ifndef SWIG
775 #endif
776 
777 /*!
778  \brief Retrieve the memory pool from a session
779  \param session the session to retrieve the pool from
780  \return the session's pool
781  \note to be used sparingly
782 */
784 ///\}
785 
788 
789 ///\defgroup sessm Session Creation / Management
790 ///\ingroup core1
791 ///\{
792 /*!
793  \brief Allocate and return a new session from the core
794  \param endpoint_interface the endpoint interface the session is to be based on
795  \param pool the pool to use for the allocation (a new one will be used if NULL)
796  \return the newly created session
797 */
799  _In_ switch_call_direction_t direction,
800  switch_originate_flag_t originate_flags,
802  _In_opt_z_ const char *use_uuid);
803 #define switch_core_session_request(_ep, _d, _f, _p) switch_core_session_request_uuid(_ep, _d, _f, _p, NULL)
804 
806 
808 
810  _In_z_ const char *file, _In_z_ const char *func, _In_ int line);
811 
812 /*!
813  \brief Destroy a session and return the memory pool to the core
814  \param session pointer to a pointer of the session to destroy
815  \return
816 */
817 #define switch_core_session_destroy(session) switch_core_session_perform_destroy(session, __FILE__, __SWITCH_FUNC__, __LINE__)
818 
822 
823 /*!
824  \brief Provide the total number of sessions
825  \return the total number of allocated sessions
826 */
828 
830 
831 /*!
832  \brief Provide the current session_id
833  \return the total number of allocated sessions since core startup
834 */
837 
838 /*!
839  \brief Allocate and return a new session from the core based on a given endpoint module name
840  \param endpoint_name the name of the endpoint module
841  \param pool the pool to use
842  \return the newly created session
843 */
846 
847 /*!
848  \brief Launch the session thread (state machine) on a given session
849  \param session the session to activate the state machine on
850  \return SWITCH_STATUS_SUCCESS if the thread was launched
851 */
853 
854 
858 
859 /*!
860  \brief Retrieve a pointer to the channel object associated with a given session
861  \param session the session to retrieve from
862  \return a pointer to the channel object
863 */
865 
866 /*!
867  \brief Signal a session's state machine thread that a state change has occured
868 */
872 
873 /*!
874  \brief Retrieve the unique identifier from a session
875  \param session the session to retrieve the uuid from
876  \return a string representing the uuid
877 */
879 
880 /*!
881  \brief Retrieve the unique external identifier from a session
882  \param session the session to retrieve the uuid from
883  \return a string representing the uuid
884 */
886 
887 
888 /*!
889  \brief Sets the log level for a session
890  \param session the session to set the log level on
891  \return SWITCH_STATUS_SUCCESS
892 */
894 
895 
896 /*!
897  \brief Get the log level for a session
898  \param session the session to get the log level from
899  \return the log level
900 */
902 
913 
914 /*!
915  \brief Retrieve the unique identifier from the core
916  \return a string representing the uuid
917 */
919 
920 
921 SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_locate(const char *uuid_str, const char *file, const char *func, int line);
922 SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_force_locate(const char *uuid_str, const char *file, const char *func, int line);
923 
924 
925 /*!
926  \brief Locate a session based on it's uuid
927  \param uuid_str the unique id of the session you want to find
928  \return the session or NULL
929  \note if the session was located it will have a read lock obtained which will need to be released with switch_core_session_rwunlock()
930 */
931 
932 #define switch_core_session_locate(uuid_str) switch_core_session_perform_locate(uuid_str, __FILE__, __SWITCH_FUNC__, __LINE__)
933 
934 /*!
935  \brief Locate a session based on it's uuid even if the channel is not ready
936  \param uuid_str the unique id of the session you want to find
937  \return the session or NULL
938  \note if the session was located it will have a read lock obtained which will need to be released with switch_core_session_rwunlock()
939 */
940 
941 #define switch_core_session_force_locate(uuid_str) switch_core_session_perform_force_locate(uuid_str, __FILE__, __SWITCH_FUNC__, __LINE__)
942 
943 
944 /*!
945  \brief Retrieve a global variable from the core
946  \param varname the name of the variable
947  \return the value of the desired variable
948 */
949 SWITCH_DECLARE(char *) switch_core_get_variable(_In_z_ const char *varname);
950 SWITCH_DECLARE(char *) switch_core_get_variable_dup(_In_z_ const char *varname);
952 SWITCH_DECLARE(const char *) switch_core_get_hostname(void);
953 SWITCH_DECLARE(const char *) switch_core_get_switchname(void);
954 
956 
957 /*!
958  \brief Add a global variable to the core
959  \param varname the name of the variable
960  \param value the value of the variable
961  \ If \p value is NULL, then \p varname is deleted.
962 */
963 SWITCH_DECLARE(void) switch_core_set_variable(_In_z_ const char *varname, _In_opt_z_ const char *value);
965 
966 /*!
967  \brief Conditionally add a global variable to the core
968  \param varname the name of the variable
969  \param value the value of the variable
970  \param val2 the value of the variable to verify against
971  \ If the global did not exist and val2=="", add global with value, return true
972  \ If the global exists with the value of val2, replace it, return true
973  \ If the global exists with a value other than val2, return false
974 */
975 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);
976 
978 
979 /*!
980  \brief Hangup all sessions
981  \param cause the hangup cause to apply to the hungup channels
982 */
984 
985 typedef enum {
986  SHT_NONE = 0,
987  SHT_UNANSWERED = (1 << 0),
988  SHT_ANSWERED = (1 << 1)
990 
991 /*!
992  \brief Hangup all sessions which match a specific channel variable
993  \param var_name The variable name to look for
994  \param var_val The value to look for
995  \param cause the hangup cause to apply to the hungup channels
996 */
997 SWITCH_DECLARE(uint32_t) switch_core_session_hupall_matching_var_ans(_In_ const char *var_name, _In_ const char *var_val, _In_
1000 #define switch_core_session_hupall_matching_var(_vn, _vv, _c) switch_core_session_hupall_matching_var_ans(_vn, _vv, _c, SHT_UNANSWERED | SHT_ANSWERED)
1002 /*!
1003  \brief Hangup all sessions which match specific channel variable(s)
1004  \param var_name The variable name to look for
1005  \param var_val The value to look for
1006  \param cause the hangup cause to apply to the hungup channels
1007 */
1010 #define switch_core_session_hupall_matching_vars(_vs, _c) switch_core_session_hupall_matching_vars_ans(_vs, _c, SHT_UNANSWERED | SHT_ANSWERED)
1011 
1012 /*!
1013  \brief Hangup all sessions that belong to an endpoint
1014  \param endpoint_interface The endpoint interface
1015  \param cause the hangup cause to apply to the hungup channels
1016 */
1018 
1019 /*!
1020  \brief Get the session's partner (the session its bridged to)
1021  \param session The session we're searching with
1022  \param partner [out] The session's partner, or NULL if it wasnt found
1023  \return SWITCH_STATUS_SUCCESS or SWITCH_STATUS_FALSE if this session isn't bridged
1024 */
1026  const char *file, const char *func, int line);
1027 
1028 #define switch_core_session_get_partner(_session, _partner) switch_core_session_perform_get_partner(_session, _partner, __FILE__, __SWITCH_FUNC__, __LINE__)
1029 
1030 /*!
1031  \brief Send a message to another session using it's uuid
1032  \param uuid_str the unique id of the session you want to send a message to
1033  \param message the switch_core_session_message_t object to send
1034  \return the status returned by the message handler
1035 */
1037 
1038 /*!
1039  \brief Queue a message on a session
1040  \param session the session to queue the message to
1041  \param message the message to queue
1042  \return SWITCH_STATUS_SUCCESS if the message was queued
1043 */
1045 
1047 
1048 
1051 
1052 /*!
1053  \brief pass an indication message on a session
1054  \param session the session to pass the message across
1055  \param indication the indication message to pass
1056  \return SWITCH_STATUS_SUCCESS if the message was passed
1057 */
1060 
1061 /*!
1062  \brief Queue an indication message on a session
1063  \param session the session to queue the message to
1064  \param indication the indication message to queue
1065  \return SWITCH_STATUS_SUCCESS if the message was queued
1066 */
1069 
1070 /*!
1071  \brief DE-Queue an message on a given session
1072  \param session the session to de-queue the message on
1073  \param message the de-queued message
1074  \return SWITCH_STATUS_SUCCESS if the message was de-queued
1075 */
1077 
1078 /*!
1079  \brief Flush a message queue on a given session
1080  \param session the session to de-queue the message on
1081  \return SWITCH_STATUS_SUCCESS if the message was de-queued
1082 */
1084 
1085 /*!
1086  \brief Queue an event on another session using its uuid
1087  \param uuid_str the unique id of the session you want to send a message to
1088  \param event the event to send
1089  \return the status returned by the message handler
1090 */
1092 
1094 
1095 /*!
1096  \brief Execute an application on a session
1097  \param session the current session
1098  \param application_interface the interface of the application to execute
1099  \param arg application arguments
1100  \warning Has to be called from the session's thread
1101  \return the application's return value
1102 */
1104  _In_ const switch_application_interface_t *application_interface, _In_opt_z_ const char *arg);
1105 
1107 /*!
1108  \brief Execute an application on a session
1109  \param session the current session
1110  \param app the application's name
1111  \param arg application arguments
1112  \param flags pointer to a flags variable to set the applications flags to
1113  \return the application's return value
1114 */
1116  _In_ const char *app, _In_opt_z_ const char *arg, _Out_opt_ int32_t *flags);
1117 
1119 
1121 
1122 /*!
1123  \brief Execute an application on a session
1124  \param session the current session
1125  \param app the application's name
1126  \param arg application arguments
1127  \return the application's return value
1128 */
1129 #define switch_core_session_execute_application(_a, _b, _c) switch_core_session_execute_application_get_flags(_a, _b, _c, NULL)
1130 
1132 
1133 /*!
1134  \brief Run a dialplan and execute an extension
1135  \param session the current session
1136  \param exten the interface of the application to execute
1137  \param arg application arguments
1138  \note It does not change the channel back to CS_ROUTING, it manually calls the dialplan and executes the applications
1139  \warning Has to be called from the session's thread
1140  \return the application's return value
1141 */
1143  _In_z_ const char *exten,
1144  _In_opt_z_ const char *dialplan, _In_opt_z_ const char *context);
1145 
1146 /*!
1147  \brief Send an event to a session translating it to it's native message format
1148  \param session the session to receive the event
1149  \param event the event to receive
1150  \return the status returned by the handler
1151 */
1153 
1154 /*!
1155  \brief Retrieve private user data from a session
1156  \param session the session to retrieve from
1157  \return a pointer to the private data
1158 */
1160 #define switch_core_session_get_private(_s) switch_core_session_get_private_class(_s, SWITCH_PVT_PRIMARY)
1161 
1162 /*!
1163  \brief Add private user data to a session
1164  \param session the session to add used data to
1165  \param private_info the used data to add
1166  \return SWITCH_STATUS_SUCCESS if data is added
1167 */
1169 #define switch_core_session_set_private(_s, _p) switch_core_session_set_private_class(_s, _p, SWITCH_PVT_PRIMARY)
1170 
1171 /*!
1172  \brief Add a logical stream to a session
1173  \param session the session to add the stream to
1174  \param private_info an optional pointer to private data for the new stream
1175  \return the stream id of the new stream
1176 */
1178 
1179 /*!
1180  \brief Retreive a logical stream from a session
1181  \param session the session to add the stream to
1182  \param index the index to retrieve
1183  \return the stream
1184 */
1186 
1187 /*!
1188  \brief Determine the number of logical streams a session has
1189  \param session the session to query
1190  \return the total number of logical streams
1191 */
1193 
1195 
1196 /*!
1197  \brief Launch a thread designed to exist within the scope of a given session
1198  \param session a session to allocate the thread from
1199  \param func a function to execute in the thread
1200  \param obj an arguement
1201 */
1203  _In_ void *(*func) (switch_thread_t *, void *), _In_opt_ void *obj);
1204 
1205 /*!
1206  \brief Signal a thread using a thread session to terminate
1207  \param session the session to indicate to
1208 */
1210 
1211 /*!
1212  \brief Launch a service thread on a session to drop inbound data
1213  \param session the session the launch thread on
1214 */
1216 #define switch_core_service_session(_s) switch_core_service_session_av(_s, SWITCH_TRUE, SWITCH_FALSE)
1217 
1218 
1219 /*!
1220  \brief Request an outgoing session spawned from an existing session using a desired endpoing module
1221  \param session the originating session
1222  \param var_event switch_event_t containing paramaters
1223  \param endpoint_name the name of the module to use for the new session
1224  \param caller_profile the originator's caller profile
1225  \param new_session a NULL pointer to aim at the newly created session
1226  \param pool optional existing memory pool to donate to the session
1227  \param flags flags to use
1228  \return the cause code of the attempted call
1229 */
1231  _In_opt_ switch_event_t *var_event,
1232  _In_z_ const char *endpoint_name,
1233  _In_ switch_caller_profile_t *caller_profile,
1234  _Inout_ switch_core_session_t **new_session,
1236  switch_call_cause_t *cancel_cause);
1237 
1238 /*!
1239  \brief Receive a message on a given session
1240  \param session the session to receive the message from
1241  \param message the message to recieve
1242  \return the status returned by the message handler
1243 */
1246  const char *file, const char *func, int line);
1247 #define switch_core_session_receive_message(_session, _message) switch_core_session_perform_receive_message(_session, _message, \
1248  __FILE__, __SWITCH_FUNC__, __LINE__)
1249 
1250 /*!
1251  \brief Queue an event on a given session
1252  \param session the session to queue the message on
1253  \param event the event to queue
1254  \return the status returned by the message handler
1255 */
1257 
1258 
1259 /*!
1260  \brief Indicate the number of waiting events on a session
1261  \param session the session to check
1262  \return the number of events
1263 */
1265 
1266 /*
1267  Number of parsable messages waiting on the session.
1268  */
1270 
1271 /*!
1272  \brief DE-Queue an event on a given session
1273  \param session the session to de-queue the message on
1274  \param event the de-queued event
1275  \param force force the dequeue
1276  \return the SWITCH_STATUS_SUCCESS if the event was de-queued
1277 */
1279 
1280 /*!
1281  \brief Queue a private event on a given session
1282  \param session the session to queue the message on
1283  \param event the event to queue
1284  \param priority event has high priority
1285  \return the status returned by the message handler
1286 */
1288  switch_bool_t priority);
1289 
1290 
1291 /*!
1292  \brief Indicate the number of waiting private events on a session
1293  \param session the session to check
1294  \return the number of events
1295 */
1297 
1298 /*!
1299  \brief DE-Queue a private event on a given session
1300  \param session the session to de-queue the message on
1301  \param event the de-queued event
1302  \return the SWITCH_STATUS_SUCCESS if the event was de-queued
1303 */
1305 
1306 
1307 /*!
1308  \brief Flush the private event queue of a session
1309  \param session the session to flush
1310  \return SWITCH_STATUS_SUCCESS if the events have been flushed
1311 */
1313 
1314 
1315 /*!
1316  \brief Read a frame from a session
1317  \param session the session to read from
1318  \param frame a NULL pointer to a frame to aim at the newly read frame
1319  \param flags I/O flags to modify behavior (i.e. non blocking)
1320  \param stream_id which logical media channel to use
1321  \return SWITCH_STATUS_SUCCESS a the frame was read
1322 */
1324  int stream_id);
1325 
1328 
1329 /*!
1330  \brief Read a video frame from a session
1331  \param session the session to read from
1332  \param frame a NULL pointer to a frame to aim at the newly read frame
1333  \param flags I/O flags to modify behavior (i.e. non blocking)
1334  \param stream_id which logical media channel to use
1335  \return SWITCH_STATUS_SUCCESS a if the frame was read
1336 */
1338  int stream_id);
1339 /*!
1340  \brief Write a video frame to a session
1341  \param session the session to write to
1342  \param frame a pointer to a frame to write
1343  \param flags I/O flags to modify behavior (i.e. non blocking)
1344  \param stream_id which logical media channel to use
1345  \return SWITCH_STATUS_SUCCESS a if the frame was written
1346 */
1348  int stream_id);
1349 
1351  switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
1352 
1357 
1358 /*!
1359  \brief Reset the buffers and resampler on a session
1360  \param session the session to reset
1361  \param flush_dtmf flush all queued dtmf events too
1362 */
1364 
1365 /*!
1366  \brief Reset the buffers and resampler on a session, fail if can not lock codec mutexes
1367  \param session the session to reset
1368  \param flush_dtmf flush all queued dtmf events too
1369  \return SWITCH_STATUS_SUCCESS if the session was reset
1370 */
1372 
1373 /*!
1374  \brief Write a frame to a session
1375  \param session the session to write to
1376  \param frame the frame to write
1377  \param flags I/O flags to modify behavior (i.e. non blocking)
1378  \param stream_id which logical media channel to use
1379  \return SWITCH_STATUS_SUCCESS a the frame was written
1380 */
1382  int stream_id);
1383 
1384 
1386  const char *file, const char *func, int line, switch_signal_t sig);
1387 /*!
1388  \brief Send a signal to a channel
1389  \param session session to send signal to
1390  \param sig signal to send
1391  \return status returned by the session's signal handler
1392 */
1393 #define switch_core_session_kill_channel(session, sig) switch_core_session_perform_kill_channel(session, __FILE__, __SWITCH_FUNC__, __LINE__, sig)
1394 
1395 /*!
1396  \brief Send DTMF to a session
1397  \param session session to send DTMF to
1398  \param dtmf dtmf to send to the session
1399  \return SWITCH_STATUS_SUCCESS if the dtmf was written
1400 */
1402 /*!
1403  \brief Send DTMF to a session
1404  \param session session to send DTMF to
1405  \param dtmf_string string to send to the session
1406  \return SWITCH_STATUS_SUCCESS if the dtmf was written
1407 */
1409 
1410 /*!
1411  \brief RECV DTMF on a session
1412  \param session session to recv DTMF from
1413  \param dtmf string to recv from the session
1414  \return SWITCH_STATUS_SUCCESS if the dtmf is ok to queue
1415 */
1417 
1418 ///\}
1419 
1420 
1421 ///\defgroup hashf Hash Functions
1422 ///\ingroup core1
1423 ///\{
1424 /*!
1425  \brief Initialize a hash table
1426  \param hash a NULL pointer to a hash table to aim at the new hash
1427  \param pool the pool to use for the new hash
1428  \return SWITCH_STATUS_SUCCESS if the hash is created
1429 */
1431 #define switch_core_hash_init(_hash) switch_core_hash_init_case(_hash, SWITCH_TRUE)
1432 #define switch_core_hash_init_nocase(_hash) switch_core_hash_init_case(_hash, SWITCH_FALSE)
1433 
1434 
1435 /*!
1436  \brief Destroy an existing hash table
1437  \param hash the hash to destroy
1438  \return SWITCH_STATUS_SUCCESS if the hash is destroyed
1439 */
1441 
1442 /*!
1443  \brief Insert data into a hash with an auto-generated key based on the data pointer
1444  \param hash the hash to add data to
1445  \param data unique pointer to add
1446  \return SWITCH_STATUS_SUCCESS if the data is added
1447 */
1449 
1450 /*!
1451  \brief Insert data into a hash and set flags so the value is automatically freed on delete
1452  \param hash the hash to add data to
1453  \param key the name of the key to add the data to
1454  \param data the data to add
1455  \return SWITCH_STATUS_SUCCESS if the data is added
1456  \note the string key must be a constant or a dynamic string
1457 */
1459 
1460 /*!
1461  \brief Insert strdup(str) into a hash and set flags so the value is automatically freed on delete
1462  \param hash the hash to add str to
1463  \param key the name of the key to add the str to
1464  \param str string to strdup and add
1465  \return SWITCH_STATUS_SUCCESS if the data is added
1466  \note the string key must be a constant or a dynamic string
1467 */
1469 
1470 /*!
1471  \brief Insert data into a hash
1472  \param hash the hash to add data to
1473  \param key the name of the key to add the data to
1474  \param data the data to add
1475  \return SWITCH_STATUS_SUCCESS if the data is added
1476  \note the string key must be a constant or a dynamic string
1477 */
1479 #define switch_core_hash_insert(_h, _k, _d) switch_core_hash_insert_destructor(_h, _k, _d, NULL)
1480 
1481 /*!
1482  \brief Allocate memory and insert into a hash
1483  \param hash the hash to add data to
1484  \param key the name of the key to add the data to
1485  \param size the size in bytes to allocate
1486  \return pointer to the allocated memory
1487  \note the string key must be a constant or a dynamic string
1488 */
1490 #define switch_core_hash_insert_alloc(_h, _k, _s) switch_core_hash_insert_alloc_destructor(_h, _k, _s, NULL)
1491 
1492 /*!
1493  \brief Insert strdup(str) into a hash
1494  \param hash the hash to add str to
1495  \param key the name of the key to add the str to
1496  \param str string to strdup and add
1497  \return SWITCH_STATUS_SUCCESS if the data is added
1498  \note the string key must be a constant or a dynamic string
1499 */
1501 #define switch_core_hash_insert_dup(_h, _k, _d) switch_core_hash_insert_dup_destructor(_h, _k, _d, NULL)
1502 
1503 
1504 /*!
1505  \brief Insert data into a hash
1506  \param hash the hash to add data to
1507  \param key the name of the key to add the data to
1508  \param data the data to add
1509  \param mutex optional mutex to lock
1510  \return SWITCH_STATUS_SUCCESS if the data is added
1511  \note the string key must be a constant or a dynamic string
1512 */
1515 /*!
1516  \brief Retrieve data from a given hash
1517  \param hash the hash to retrieve from
1518  \param key the key to retrieve
1519  \param mutex optional rwlock to wrlock
1520  \return a pointer to the data held in the key
1521 */
1523 
1524 /*!
1525  \brief Delete data from a hash based on desired key
1526  \param hash the hash to delete from
1527  \param key the key from which to delete the data
1528  \return The value stored if the data is deleted otherwise NULL
1529 */
1531 
1532 /*!
1533  \brief Delete data from a hash based on desired key
1534  \param hash the hash to delete from
1535  \param key the key from which to delete the data
1536  \param mutex optional mutex to lock
1537  \return a pointer to the deleted data
1538 */
1540 
1541 /*!
1542  \brief Delete data from a hash based on desired key
1543  \param hash the hash to delete from
1544  \param key the key from which to delete the data
1545  \param mutex optional rwlock to wrlock
1546  \return a pointer to the deleted data
1547 */
1549 
1550 /*!
1551  \brief Delete data from a hash based on callback function
1552  \param hash the hash to delete from
1553  \param callback the function to call which returns SWITCH_TRUE to delete, SWITCH_FALSE to preserve
1554  \return SWITCH_STATUS_SUCCESS if any data is deleted
1555 */
1557 
1558 /*!
1559  \brief Retrieve data from a given hash
1560  \param hash the hash to retrieve from
1561  \param key the key to retrieve
1562  \return a pointer to the data held in the key
1563 */
1565 
1566 
1567 /*!
1568  \brief Retrieve data from a given hash
1569  \param hash the hash to retrieve from
1570  \param key the key to retrieve
1571  \param mutex optional mutex to lock
1572  \return a pointer to the data held in the key
1573 */
1575 
1576 /*!
1577  \brief Retrieve data from a given hash
1578  \param hash the hash to retrieve from
1579  \param key the key to retrieve
1580  \param mutex optional rwlock to rdlock
1581  \return a pointer to the data held in the key
1582 */
1584 
1585 /*!
1586  \brief Gets the first element of a hashtable
1587  \param deprecate_me [deprecated] NULL
1588  \param hash the hashtable to use
1589  \return The element, or NULL if it wasn't found
1590 */
1592 #define switch_core_hash_first(_h) switch_core_hash_first_iter(_h, NULL)
1593 
1594 /*!
1595  \brief tells if a hash is empty
1596  \param hash the hashtable
1597  \return TRUE or FALSE depending on if the hash is empty
1598 */
1600 
1601 /*!
1602  \brief Gets the next element of a hashtable
1603  \param hi The current element
1604  \return The next element, or NULL if there are no more
1605 */
1607 
1608 /*!
1609  \brief Gets the key and value of the current hash element
1610  \param hi The current element
1611  \param key [out] the key
1612  \param klen [out] the key's size
1613  \param val [out] the value
1614 */
1616  const void **key, _Out_opt_ switch_ssize_t *klen, _Out_ void **val);
1617 
1619 
1625 
1626 ///\}
1627 
1628 ///\defgroup timer Timer Functions
1629 ///\ingroup core1
1630 ///\{
1631 /*!
1632  \brief Request a timer handle using given time module
1633  \param timer a timer object to allocate to
1634  \param timer_name the name of the timer module to use
1635  \param interval desired interval
1636  \param samples the number of samples to increment on each cycle
1637  \param pool the memory pool to use for allocation
1638  \return
1639 */
1640 SWITCH_DECLARE(switch_status_t) switch_core_timer_init(switch_timer_t *timer, const char *timer_name, int interval, int samples,
1642 
1644 
1645 /*!
1646  \brief Wait for one cycle on an existing timer
1647  \param timer the timer to wait on
1648  \return the newest sample count
1649 */
1651 
1652 /*!
1653  \brief Step the timer one step
1654  \param timer the timer to wait on
1655  \return the newest sample count
1656 */
1658 
1660 
1661 /*!
1662  \brief Check if the current step has been exceeded
1663  \param timer the timer to wait on
1664  \param step increment timer if a tick was detected
1665  \return the newest sample count
1666 */
1668 
1669 /*!
1670  \brief Destroy an allocated timer
1671  \param timer timer to destroy
1672  \return SWITCH_STATUS_SUCCESS after destruction
1673 */
1675 ///\}
1676 
1677 ///\defgroup codecs Codec Functions
1678 ///\ingroup core1
1679 ///\{
1680 /*!
1681  \brief Initialize a codec handle
1682  \param codec the handle to initilize
1683  \param codec_name the name of the codec module to use
1684  \param fmtp codec parameters to send
1685  \param rate the desired rate (0 for any)
1686  \param ms the desired number of milliseconds (0 for any)
1687  \param channels the desired number of channels (0 for any)
1688  \param flags flags to alter behaviour
1689  \param codec_settings desired codec settings
1690  \param pool the memory pool to use
1691  \return SWITCH_STATUS_SUCCESS if the handle is allocated
1692 */
1693 #define switch_core_codec_init(_codec, _codec_name, _modname, _fmtp, _rate, _ms, _channels, _flags, _codec_settings, _pool) \
1694  switch_core_codec_init_with_bitrate(_codec, _codec_name, _modname, _fmtp, _rate, _ms, _channels, 0, _flags, _codec_settings, _pool)
1696  const char *codec_name,
1697  const char *fmtp,
1698  const char *modname,
1699  uint32_t rate,
1700  int ms,
1701  int channels,
1702  uint32_t bitrate,
1703  uint32_t flags,
1704  const switch_codec_settings_t *codec_settings,
1706 
1708  const switch_codec_settings_t *codec_settings, switch_memory_pool_t *pool);
1709 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);
1711 
1712 /*!
1713  \brief Encode data using a codec handle
1714  \param codec the codec handle to use
1715  \param other_codec the codec handle of the last codec used
1716  \param decoded_data the raw data
1717  \param decoded_data_len then length of the raw buffer
1718  \param decoded_rate the rate of the decoded data
1719  \param encoded_data the buffer to write the encoded data to
1720  \param encoded_data_len the size of the encoded_data buffer
1721  \param encoded_rate the new rate of the encoded data
1722  \param flag flags to exchange
1723  \return SWITCH_STATUS_SUCCESS if the data was encoded
1724  \note encoded_data_len will be rewritten to the in-use size of encoded_data
1725 */
1727  switch_codec_t *other_codec,
1728  void *decoded_data,
1729  uint32_t decoded_data_len,
1730  uint32_t decoded_rate,
1731  void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag);
1732 
1733 /*!
1734  \brief Decode data using a codec handle
1735  \param codec the codec handle to use
1736  \param other_codec the codec handle of the last codec used
1737  \param encoded_data the buffer to read the encoded data from
1738  \param encoded_data_len the size of the encoded_data buffer
1739  \param encoded_rate the rate of the encoded data
1740  \param decoded_data the raw data buffer
1741  \param decoded_data_len then length of the raw buffer
1742  \param decoded_rate the new rate of the decoded data
1743  \param flag flags to exchange
1744  \return SWITCH_STATUS_SUCCESS if the data was decoded
1745  \note decoded_data_len will be rewritten to the in-use size of decoded_data
1746 */
1748  switch_codec_t *other_codec,
1749  void *encoded_data,
1750  uint32_t encoded_data_len,
1751  uint32_t encoded_rate,
1752  void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag);
1753 
1754 /*!
1755  \brief Encode video data using a codec handle
1756  \param codec the codec handle to use
1757  \param frame the frame to encode
1758 */
1760 
1761 
1762 /*!
1763  \brief send control data using a codec handle
1764  \param codec the codec handle to use
1765  \param cmd the command to send
1766  \param ctype the type of the arguement
1767  \param cmd_data a void pointer to the data matching the passed type
1768  \param atype the type of the extra arguement
1769  \param cmd_arg a void pointer to the data matching the passed type
1770  \param rtype the type of the response if any
1771  \param ret_data a void pointer to a pointer of return data
1772  \return SWITCH_STATUS_SUCCESS if the command was received
1773 */
1777  void *cmd_data,
1779  void *cmd_arg,
1781  void **ret_data);
1782 
1783 /*!
1784  \brief Decode video data using a codec handle
1785  \param codec the codec handle to use
1786  \param frame the frame to be decoded
1787  \param img the new image in I420 format, allocated by the codec
1788  \param flag flags to exchange
1789  \return SWITCH_STATUS_SUCCESS if the data was decoded, and a non-NULL img
1790 */
1792 
1793 /*!
1794  \brief Destroy an initalized codec handle
1795  \param codec the codec handle to destroy
1796  \return SWITCH_STATUS_SUCCESS if the codec was destroyed
1797 */
1799 
1800 /*!
1801  \brief Assign the read codec to a given session
1802  \param session session to add the codec to
1803  \param codec the codec to add
1804  \return SWITCH_STATUS_SUCCESS if successful
1805 */
1807 
1808 /*!
1809  \brief Assign the original read codec to a given session. This is the read codec used by an endpoint.
1810  \param session session to add the codec to
1811  \param codec the codec to add
1812  \return SWITCH_STATUS_SUCCESS if successful
1813 */
1815 
1818 
1819 
1824 
1825 
1831 
1832 
1833 /*!
1834  \brief Retrieve the read codec from a given session
1835  \param session session to retrieve from
1836  \return a pointer to the codec
1837 */
1839 
1840 /*!
1841  \brief Retrieve the effevtive read codec from a given session
1842  \param session session to retrieve from
1843  \return a pointer to the codec
1844 */
1846 
1847 /*!
1848  \brief Assign the write codec to a given session
1849  \param session session to add the codec to
1850  \param codec the codec to add
1851  \return SWITCH_STATUS_SUCCESS if successful
1852 */
1854 
1855 /*!
1856  \brief Retrieve the write codec from a given session
1857  \param session session to retrieve from
1858  \return a pointer to the codec
1859 */
1861 
1862 /*!
1863  \brief Retrieve the effevtive write codec from a given session
1864  \param session session to retrieve from
1865  \return a pointer to the codec
1866 */
1868 
1869 /*!
1870  \brief Assign the video_read codec to a given session
1871  \param session session to add the codec to
1872  \param codec the codec to add
1873  \return SWITCH_STATUS_SUCCESS if successful
1874 */
1876 
1877 /*!
1878  \brief Retrieve the video_read codec from a given session
1879  \param session session to retrieve from
1880  \return a pointer to the codec
1881 */
1883 
1884 /*!
1885  \brief Assign the video_write codec to a given session
1886  \param session session to add the codec to
1887  \param codec the codec to add
1888  \return SWITCH_STATUS_SUCCESS if successful
1889 */
1891 
1892 /*!
1893  \brief Retrieve the video_write codec from a given session
1894  \param session session to retrieve from
1895  \return a pointer to the codec
1896 */
1898 
1899 ///\}
1900 ///\defgroup db Database Functions
1901 ///\ingroup core1
1902 ///\{
1903 /*!
1904  \brief Open a core db (SQLite) file
1905  \param filename the path to the db file to open
1906  \return the db handle
1907 */
1909 
1910 /*!
1911  \brief Open a core db (SQLite) in-memory
1912  \param uri to the db to open
1913  \return the db handle
1914 */
1916 
1917 /*!
1918  \brief Execute a sql stmt until it is accepted
1919  \param db the db handle
1920  \param sql the sql to execute
1921  \param retries the number of retries to use
1922  \return SWITCH_STATUS_SUCCESS if successful
1923 
1924 */
1928 
1929 
1930 
1931 /*!
1932  \brief perform a test query then perform a reactive query if the first one fails
1933  \param db the db handle
1934  \param test_sql the test sql
1935  \param drop_sql the drop sql
1936  \param reactive_sql the reactive sql
1937 */
1938 SWITCH_DECLARE(void) switch_core_db_test_reactive(switch_core_db_t *db, char *test_sql, char *drop_sql, char *reactive_sql);
1939 
1940 ///\}
1941 
1942 ///\defgroup Media File Functions
1943 ///\ingroup core1
1944 ///\{
1945 
1946 SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file, const char *func, int line,
1948  _In_opt_z_ const char *file_path,
1949  _In_ uint32_t channels,
1950  _In_ uint32_t rate, _In_ unsigned int flags, _In_opt_ switch_memory_pool_t *pool);
1951 
1952 /*!
1953  \brief Open a media file using file format modules
1954  \param _fh a file handle to use
1955  \param _file_path the path to the file
1956  \param _channels the number of channels
1957  \param _rate the sample rate
1958  \param _flags read/write flags
1959  \param _pool the pool to use (NULL for new pool)
1960  \return SWITCH_STATUS_SUCCESS if the file is opened
1961  \note the loadable module used is chosen based on the file extension
1962 */
1963 #define switch_core_file_open(_fh, _file_path, _channels, _rate, _flags, _pool) \
1964  switch_core_perform_file_open(__FILE__, __SWITCH_FUNC__, __LINE__, _fh, _file_path, _channels, _rate, _flags, _pool)
1965 
1966 /*!
1967  \brief Read media from a file handle
1968  \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)
1969  \param data the buffer to read the data to
1970  \param len the max size of the buffer
1971  \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes read if successful
1972 */
1974 
1975 /*!
1976  \brief Write media to a file handle
1977  \param fh the file handle to write to
1978  \param data the buffer to write
1979  \param len the amount of data to write from the buffer
1980  \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful
1981 */
1983 
1984 /*!
1985  \brief Write media to a file handle
1986  \param fh the file handle to write to
1987  \param data the buffer to write
1988  \param len the amount of data to write from the buffer
1989  \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful
1990 */
1993 
1994 /*!
1995  \brief Seek a position in a file
1996  \param fh the file handle to seek
1997  \param cur_pos the current position in the file
1998  \param samples the amount of samples to seek from the beginning of the file
1999  \param whence the indicator (see traditional seek)
2000  \return SWITCH_STATUS_SUCCESS with cur_pos adjusted to new position
2001 */
2002 SWITCH_DECLARE(switch_status_t) switch_core_file_seek(_In_ switch_file_handle_t *fh, unsigned int *cur_pos, int64_t samples, int whence);
2003 
2004 /*!
2005  \brief Set metadata to the desired string
2006  \param fh the file handle to set data to
2007  \param col the enum of the col name
2008  \param string the string to add
2009  \return SWITCH_STATUS_SUCCESS with cur_pos adjusted to new position
2010 */
2012 
2013 /*!
2014  \brief get metadata of the desired string
2015  \param fh the file handle to get data from
2016  \param col the enum of the col name
2017  \param string pointer to the string to fetch
2018  \return SWITCH_STATUS_SUCCESS with cur_pos adjusted to new position
2019 */
2021 
2022 /*!
2023  \brief Pre close an open file handle, then can get file size etc., no more wirte to the file
2024  \param fh the file handle to close
2025  \return SWITCH_STATUS_SUCCESS if the file handle was pre closed
2026 */
2028 
2029 /*!
2030  \brief Duplicates a file handle using another pool
2031  \param oldfh the file handle to duplicate
2032  \param newfh pointer to assign new file handle to
2033  \param pool the pool to use (NULL for new pool)
2034  \return SWITCH_STATUS_SUCCESS if the file handle was duplicated
2035 */
2036 
2038 
2039 /*!
2040  \brief Close an open file handle
2041  \param fh the file handle to close
2042  \return SWITCH_STATUS_SUCCESS if the file handle was closed
2043 */
2045 
2047 
2050 
2051 
2052 ///\}
2053 
2054 ///\defgroup speech ASR/TTS Functions
2055 ///\ingroup core1
2056 ///\{
2057 /*!
2058  \brief Open a speech handle
2059  \param sh a speech handle to use
2060  \param module_name the speech module to use
2061  \param voice_name the desired voice name
2062  \param rate the sampling rate
2063  \param interval the sampling interval
2064  \param flags tts flags
2065  \param pool the pool to use (NULL for new pool)
2066  \return SWITCH_STATUS_SUCCESS if the handle is opened
2067 */
2069  const char *module_name,
2070  const char *voice_name,
2071  _In_ unsigned int rate,
2072  _In_ unsigned int interval,
2073  _In_ unsigned int channels,
2075 /*!
2076  \brief Feed text to the TTS module
2077  \param sh the speech handle to feed
2078  \param text the buffer to write
2079  \param flags flags in/out for fine tuning
2080  \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful
2081 */
2083 
2084 /*!
2085  \brief Flush TTS audio on a given handle
2086  \param sh the speech handle
2087 */
2089 
2090 /*!
2091  \brief Set a text parameter on a TTS handle
2092  \param sh the speech handle
2093  \param param the parameter
2094  \param val the value
2095 */
2096 SWITCH_DECLARE(void) switch_core_speech_text_param_tts(switch_speech_handle_t *sh, char *param, const char *val);
2097 
2098 /*!
2099  \brief Set a numeric parameter on a TTS handle
2100  \param sh the speech handle
2101  \param param the parameter
2102  \param val the value
2103 */
2105 
2106 /*!
2107  \brief Set a float parameter on a TTS handle
2108  \param sh the speech handle
2109  \param param the parameter
2110  \param val the value
2111 */
2113 
2114 /*!
2115  \brief Read rendered audio from the TTS module
2116  \param sh the speech handle to read
2117  \param data the buffer to read to
2118  \param datalen the max size / written size of the data
2119  \param rate the rate of the read audio
2120  \param flags flags in/out for fine tuning
2121  \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful
2122 */
2124 /*!
2125  \brief Close an open speech handle
2126  \param sh the speech handle to close
2127  \param flags flags in/out for fine tuning
2128  \return SWITCH_STATUS_SUCCESS if the file handle was closed
2129 */
2131 
2132 
2133 /*!
2134  \brief Open an asr handle
2135  \param ah the asr handle to open
2136  \param module_name the name of the asr module
2137  \param codec the preferred codec
2138  \param rate the preferred rate
2139  \param dest the destination address
2140  \param flags flags to influence behaviour
2141  \param pool the pool to use (NULL for new pool)
2142  \return SWITCH_STATUS_SUCCESS if the asr handle was opened
2143 */
2145  const char *module_name,
2146  const char *codec, int rate, const char *dest, switch_asr_flag_t *flags, switch_memory_pool_t *pool);
2147 
2148 /*!
2149  \brief Close an asr handle
2150  \param ah the handle to close
2151  \param flags flags to influence behaviour
2152  \return SWITCH_STATUS_SUCCESS
2153 */
2155 
2156 /*!
2157  \brief Feed audio data to an asr handle
2158  \param ah the handle to feed data to
2159  \param data a pointer to the data
2160  \param len the size in bytes of the data
2161  \param flags flags to influence behaviour
2162  \return SWITCH_STATUS_SUCCESS
2163 */
2165 
2166 /*!
2167  \brief Feed DTMF to an asr handle
2168  \param ah the handle to feed data to
2169  \param dtmf a string of DTMF digits
2170  \param flags flags to influence behaviour
2171  \return SWITCH_STATUS_SUCCESS
2172 */
2174 
2175 /*!
2176  \brief Check an asr handle for results
2177  \param ah the handle to check
2178  \param flags flags to influence behaviour
2179  \return SWITCH_STATUS_SUCCESS
2180 */
2182 
2183 /*!
2184  \brief Get results from an asr handle
2185  \param ah the handle to get results from
2186  \param xmlstr a pointer to dynamically allocate an xml result string to
2187  \param flags flags to influence behaviour
2188  \return SWITCH_STATUS_SUCCESS
2189 */
2191 
2192 /*!
2193  \brief Get result headers from an asr handle
2194  \param ah the handle to get results from
2195  \param headers a pointer to dynamically allocate an switch_event_t result to
2196  \param flags flags to influence behaviour
2197  \return SWITCH_STATUS_SUCCESS
2198 */
2200 
2201 /*!
2202  \brief Load a grammar to an asr handle
2203  \param ah the handle to load to
2204  \param grammar the grammar text, file path, or URI
2205  \param name the grammar name
2206  \return SWITCH_STATUS_SUCCESS
2207 */
2209 
2210 /*!
2211  \brief Unload a grammar from an asr handle
2212  \param ah the handle to unload the grammar from
2213  \param name the name of the grammar to unload
2214  \return SWITCH_STATUS_SUCCESS
2215 */
2217 
2218 /*!
2219  \brief Enable a grammar from an asr handle
2220  \param ah the handle to enable the grammar from
2221  \param name the name of the grammar to enable
2222  \return SWITCH_STATUS_SUCCESS
2223 */
2225 
2226 /*!
2227  \brief Disable a grammar from an asr handle
2228  \param ah the handle to disable the grammar from
2229  \param name the name of the grammar to disable
2230  \return SWITCH_STATUS_SUCCESS
2231 */
2233 
2234 /*!
2235  \brief Disable all grammars from an asr handle
2236  \param ah the handle to disable the grammars from
2237  \return SWITCH_STATUS_SUCCESS
2238 */
2240 
2241 /*!
2242  \brief Pause detection on an asr handle
2243  \param ah the handle to pause
2244  \return SWITCH_STATUS_SUCCESS
2245 */
2247 
2248 /*!
2249  \brief Resume detection on an asr handle
2250  \param ah the handle to resume
2251  \return SWITCH_STATUS_SUCCESS
2252 */
2254 
2255 /*!
2256  \brief Start input timers on an asr handle
2257  \param ah the handle to start timers on
2258  \return SWITCH_STATUS_SUCCESS
2259 */
2261 
2262 /*!
2263  \brief Set a text parameter on an asr handle
2264  \param sh the asr handle
2265  \param param the parameter
2266  \param val the value
2267 */
2268 SWITCH_DECLARE(void) switch_core_asr_text_param(switch_asr_handle_t *ah, char *param, const char *val);
2269 
2270 /*!
2271  \brief Set a numeric parameter on an asr handle
2272  \param sh the asr handle
2273  \param param the parameter
2274  \param val the value
2275 */
2276 SWITCH_DECLARE(void) switch_core_asr_numeric_param(switch_asr_handle_t *ah, char *param, int val);
2277 
2278 /*!
2279  \brief Set a float parameter on an asr handle
2280  \param sh the asr handle
2281  \param param the parameter
2282  \param val the value
2283 */
2284 SWITCH_DECLARE(void) switch_core_asr_float_param(switch_asr_handle_t *ah, char *param, double val);
2285 
2286 ///\}
2287 
2288 
2289 ///\defgroup dir Directory Service Functions
2290 ///\ingroup core1
2291 ///\{
2292 /*!
2293  \brief Open a directory handle
2294  \param dh a directory handle to use
2295  \param module_name the directory module to use
2296  \param source the source of the db (ip, hostname, path etc)
2297  \param dsn the username or designation of the lookup
2298  \param passwd the password
2299  \param pool the pool to use (NULL for new pool)
2300  \return SWITCH_STATUS_SUCCESS if the handle is opened
2301 */
2303  char *module_name, char *source, char *dsn, char *passwd, switch_memory_pool_t *pool);
2304 
2305 /*!
2306  \brief Query a directory handle
2307  \param dh a directory handle to use
2308  \param base the base to query against
2309  \param query a string of filters or query data
2310  \return SWITCH_STATUS_SUCCESS if the query is successful
2311 */
2313 
2314 /*!
2315  \brief Obtain the next record in a lookup
2316  \param dh a directory handle to use
2317  \return SWITCH_STATUS_SUCCESS if another record exists
2318 */
2320 
2321 /*!
2322  \brief Obtain the next name/value pair in the current record
2323  \param dh a directory handle to use
2324  \param var a pointer to pointer of the name to fill in
2325  \param val a pointer to pointer of the value to fill in
2326  \return SWITCH_STATUS_SUCCESS if an item exists
2327 */
2329 
2330 /*!
2331  \brief Close an open directory handle
2332  \param dh a directory handle to close
2333  \return SWITCH_STATUS_SUCCESS if handle was closed
2334 */
2336 ///\}
2337 
2338 
2339 ///\defgroup misc Misc
2340 ///\ingroup core1
2341 ///\{
2342 /*!
2343  \brief Retrieve a FILE stream of a given text channel name
2344  \param channel text channel enumeration
2345  \return a FILE stream
2346 */
2348 
2349 /*!
2350  \brief Determines if the core is ready to take calls
2351  \return SWITCH_TRUE or SWITCH_FALSE
2352 */
2354 
2356 
2357 /*!
2358  \brief Determines if the core is ready to take inbound calls
2359  \return SWITCH_TRUE or SWITCH_FALSE
2360 */
2362 
2363 /*!
2364  \brief Determines if the core is ready to place outbound calls
2365  \return SWITCH_TRUE or SWITCH_FALSE
2366 */
2368 
2369 /*!
2370  \brief return core flags
2371  \return core flags
2372 */
2374 
2375 /*!
2376  \brief Execute a management operation.
2377  \param relative_oid the relative oid of the operation.
2378  \param action the action to perform.
2379  \param data input/output string.
2380  \param datalen size in bytes of data.
2381  \return SUCCESS on sucess.
2382 */
2384 
2385 /*!
2386  \brief Switch on the privilege awareness for the process and request required privileges
2387  \return 0 on success
2388 */
2389 
2391 
2392 /*!
2393  \brief Set the maximum priority the process can obtain
2394  \return 0 on success
2395 */
2396 
2397 SWITCH_DECLARE(int32_t) set_normal_priority(void);
2398 SWITCH_DECLARE(int32_t) set_auto_priority(void);
2399 SWITCH_DECLARE(int32_t) set_realtime_priority(void);
2400 SWITCH_DECLARE(int32_t) set_low_priority(void);
2401 
2402 /*!
2403  \brief Change user and/or group of the running process
2404  \param user name of the user to switch to (or NULL)
2405  \param group name of the group to switch to (or NULL)
2406  \return 0 on success, -1 otherwise
2407 
2408  Several possible combinations:
2409  - user only (group NULL): switch to user and his primary group (and supplementary groups, if supported)
2410  - user and group: switch to user and specified group (only)
2411  - group only (user NULL): switch group only
2412 */
2413 SWITCH_DECLARE(int32_t) change_user_group(const char *user, const char *group);
2414 
2415 /*!
2416  \brief Run endlessly until the system is shutdown
2417  \param bg divert console to the background
2418 */
2420 
2421 /*!
2422  \brief Set the output console to the desired file
2423  \param console the file path
2424 */
2426 
2427 /*!
2428  \brief Breakdown a number of milliseconds into various time spec
2429  \param total_ms a number of milliseconds
2430  \param duration an object to store the results
2431 */
2433 
2434 /*!
2435  \brief Number of microseconds the system has been up
2436  \return a number of microseconds
2437 */
2439 
2440 /*!
2441  \brief send a control message to the core
2442  \param cmd the command
2443  \param val the command arguement (if needed)
2444  \return 0 on success nonzero on error
2445 */
2447 
2448 /*!
2449  \brief Get the output console
2450  \return the FILE stream
2451 */
2453 
2454 #ifndef SWIG
2455 /*!
2456  \brief Launch a thread
2457 */
2459  void *obj, switch_memory_pool_t *pool);
2460 #endif
2461 
2462 /*!
2463  \brief Initiate Globals
2464 */
2466 
2467 /*!
2468  \brief Checks if 2 sessions are using the same endpoint module
2469  \param a the first session
2470  \param b the second session
2471  \return TRUE or FALSE
2472 */
2474 /*!
2475  \brief Checks if a session is using a specific endpoint
2476  \param session the session
2477  \param endpoint_interface interface of the endpoint to check
2478  \return TRUE or FALSE
2479 */
2481 
2483  switch_core_video_thread_callback_func_t func, void *user_data);
2484 
2486 
2488 SWITCH_DECLARE(const char *) switch_core_mime_ext2type(const char *ext);
2489 SWITCH_DECLARE(const char *) switch_core_mime_type2ext(const char *type);
2490 SWITCH_DECLARE(switch_status_t) switch_core_mime_add_type(const char *type, const char *ext);
2491 
2494 /*!
2495  \brief Get the current epoch time in microseconds
2496  \return the current epoch time in microseconds
2497 */
2506 SWITCH_DECLARE(void) switch_time_sync(void);
2507 /*!
2508  \brief Get the current epoch time
2509  \param [out] (optional) The current epoch time
2510  \return The current epoch time
2511 */
2512 SWITCH_DECLARE(time_t) switch_epoch_time_now(time_t *t);
2513 SWITCH_DECLARE(const char *) switch_lookup_timezone(const char *tz_name);
2514 SWITCH_DECLARE(switch_status_t) switch_strftime_tz(const char *tz, const char *format, char *date, size_t len, switch_time_t thetime);
2517 SWITCH_DECLARE(switch_bool_t) switch_check_network_list_ip_port_token(const char *ip_str, int port, const char *list_name, const char **token);
2518 SWITCH_DECLARE(switch_bool_t) switch_check_network_list_ip_token(const char *ip_str, const char *list_name, const char **token);
2519 #define switch_check_network_list_ip(_ip_str, _list_name) switch_check_network_list_ip_token(_ip_str, _list_name, NULL)
2521 SWITCH_DECLARE(void) switch_time_set_timerfd(int enable);
2526 SWITCH_DECLARE(uint32_t) switch_core_min_dtmf_duration(uint32_t duration);
2527 SWITCH_DECLARE(uint32_t) switch_core_max_dtmf_duration(uint32_t duration);
2528 SWITCH_DECLARE(double) switch_core_min_idle_cpu(double new_limit);
2529 SWITCH_DECLARE(double) switch_core_idle_cpu(void);
2530 SWITCH_DECLARE(uint32_t) switch_core_default_dtmf_duration(uint32_t duration);
2533 SWITCH_DECLARE(int) switch_system(const char *cmd, switch_bool_t wait);
2534 SWITCH_DECLARE(int) switch_stream_system(const char *cmd, switch_stream_handle_t *stream);
2536 SWITCH_DECLARE(void) switch_cond_next(void);
2537 SWITCH_DECLARE(switch_status_t) switch_core_chat_send_args(const char *dest_proto, const char *proto, const char *from, const char *to,
2538  const char *subject, const char *body, const char *type, const char *hint, switch_bool_t blocking);
2539 SWITCH_DECLARE(switch_status_t) switch_core_chat_send(const char *dest_proto, switch_event_t *message_event);
2540 SWITCH_DECLARE(switch_status_t) switch_core_chat_deliver(const char *dest_proto, switch_event_t **message_event);
2541 
2545 
2546 
2547 ///\}
2548 
2549 /*!
2550  \}
2551 */
2552 
2553 typedef int (*switch_core_db_event_callback_func_t) (void *pArg, switch_event_t *event);
2554 
2555 #define CACHE_DB_LEN 256
2556 typedef enum {
2557  CDF_INUSE = (1 << 0),
2558  CDF_PRUNE = (1 << 1),
2559  CDF_NONEXPIRING = (1 << 2)
2560 } cache_db_flag_t;
2561 
2562 typedef enum {
2567 
2568 typedef union {
2573 
2574 typedef struct {
2575  char *db_path;
2578 
2579 typedef struct {
2580  char *dsn;
2581  char *user;
2582  char *pass;
2584 
2585 typedef struct {
2586  const char *original_dsn;
2588  char prefix[16];
2592 
2593 typedef union {
2598 
2599 struct switch_cache_db_handle;
2601 
2602 static inline const char *switch_cache_db_type_name(switch_cache_db_handle_type_t type)
2603 {
2604  const char *type_str = "INVALID";
2605 
2606  switch (type) {
2608  {
2609  type_str = "DATABASE_INTERFACE";
2610  }
2611  break;
2612  case SCDB_TYPE_ODBC:
2613  {
2614  type_str = "ODBC";
2615  }
2616  break;
2617  case SCDB_TYPE_CORE_DB:
2618  {
2619  type_str = "CORE_DB";
2620  }
2621  break;
2622  }
2623 
2624  return type_str;
2625 }
2626 
2627 SWITCH_DECLARE(switch_cache_db_handle_type_t) switch_cache_db_get_type(switch_cache_db_handle_t *dbh);
2628 
2629 /*!
2630  \brief Returns the handle to the pool, immediately available for other
2631  threads to use.
2632  \param [in] The handle
2633 */
2635 /*!
2636  \brief Returns the handle to the pool, handle is NOT available to
2637  other threads until the allocating thread actually terminates.
2638  \param [in] The handle
2639 */
2641 /*!
2642  \brief Gets a new cached handle from the pool, potentially creating a new connection.
2643  The connection is bound to the thread until it (the thread) terminates unless
2644  you dismiss rather than release.
2645  \param [out] dbh The handle
2646  \param [in] type - ODBC or SQLLITE
2647  \param [in] connection_options (userid, password, etc)
2648 */
2650  switch_cache_db_handle_type_t type,
2651  switch_cache_db_connection_options_t *connection_options,
2652  const char *file, const char *func, int line);
2653 #define switch_cache_db_get_db_handle(_a, _b, _c) _switch_cache_db_get_db_handle(_a, _b, _c, __FILE__, __SWITCH_FUNC__, __LINE__)
2654 
2656  const char *file, const char *func, int line);
2658  const char *file, const char *func, int line);
2659 #define switch_cache_db_get_db_handle_dsn(_a, _b) _switch_cache_db_get_db_handle_dsn(_a, _b, __FILE__, __SWITCH_FUNC__, __LINE__)
2660 
2661 /*!
2662  \brief Executes the create schema sql
2663  \param [in] dbh The handle
2664  \param [in] sql - sql to run
2665  \param [out] err - Error if it exists
2666 */
2668 /*!
2669  \brief Executes the sql and returns the result as a string
2670  \param [in] dbh The handle
2671  \param [in] sql - sql to run
2672  \param [out] str - buffer for result
2673  \param [in] len - length of str buffer
2674  \param [out] err - Error if it exists
2675 */
2676 SWITCH_DECLARE(char *) switch_cache_db_execute_sql2str(switch_cache_db_handle_t *dbh, char *sql, char *str, size_t len, char **err);
2677 /*!
2678  \brief Executes the sql
2679  \param [in] dbh The handle
2680  \param [in] sql - sql to run
2681  \param [out] err - Error if it exists
2682 */
2684 /*!
2685  \brief Executes the sql and uses callback for row-by-row processing
2686  \param [in] dbh The handle
2687  \param [in] sql - sql to run
2688  \param [in] callback - function pointer to callback
2689  \param [in] pdata - data to pass to callback
2690  \param [out] err - Error if it exists
2691 */
2693  switch_core_db_callback_func_t callback, void *pdata, char **err);
2694 
2695 /*!
2696  \brief Executes the sql and uses callback for row-by-row processing
2697  \param [in] dbh The handle
2698  \param [in] sql - sql to run
2699  \param [in] callback - function pointer to callback
2700  \param [in] err_callback - function pointer to callback when error occurs
2701  \param [in] pdata - data to pass to callback
2702  \param [out] err - Error if it exists
2703 */
2707  void *pdata, char **err);
2708 
2709 /*!
2710  \brief Get the affected rows of the last performed query
2711  \param [in] dbh The handle
2712  \param [out] the number of affected rows
2713 */
2715 
2716 /*!
2717  \brief load an external extension to db
2718  \param [in] dbh The handle
2719  \param [out] the path to the extension
2720 */
2722 
2723 /*!
2724  \brief Provides some feedback as to the status of the db connection pool
2725  \param [in] stream stream for status
2726 */
2728 SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t ** dbh, const char *file, const char *func, int line);
2729 #define switch_core_db_handle(_a) _switch_core_db_handle(_a, __FILE__, __SWITCH_FUNC__, __LINE__)
2730 
2732  const char *test_sql, const char *drop_sql, const char *reactive_sql);
2734  const char *test_sql, const char *drop_sql, const char *reactive_sql, const char *row_size_limited_reactive_sql);
2737  const char *pre_trans_execute,
2738  const char *post_trans_execute,
2739  const char *inner_pre_trans_execute,
2740  const char *inner_post_trans_execute);
2741 #define switch_cache_db_persistant_execute_trans(_d, _s, _r) switch_cache_db_persistant_execute_trans_full(_d, _s, _r, NULL, NULL, NULL, NULL)
2742 
2744 
2745 /*!
2746 \brief Returns error if no suitable database interface found to serve core db dsn.
2747 */
2749 
2750 /*!
2751 \brief Returns error if no suitable database interface found for a dsn.
2752 */
2754 
2756 SWITCH_DECLARE(uint32_t) switch_core_debug_level(void);
2757 SWITCH_DECLARE(int32_t) switch_core_sps(void);
2758 SWITCH_DECLARE(int32_t) switch_core_sps_last(void);
2759 SWITCH_DECLARE(int32_t) switch_core_sps_peak(void);
2764 SWITCH_DECLARE(const char *) switch_core_banner(void);
2766 SWITCH_DECLARE(uint32_t) switch_default_ptime(const char *name, uint32_t number);
2767 SWITCH_DECLARE(uint32_t) switch_default_rate(const char *name, uint32_t number);
2768 SWITCH_DECLARE(uint32_t) switch_core_max_audio_channels(uint32_t limit);
2769 
2770 /*!
2771  \brief Add user registration
2772  \param [in] user
2773  \param [in] realm
2774  \param [in] token
2775  \param [in] url - a freeswitch dial string
2776  \param [in] expires
2777  \param [in] network_ip
2778  \param [in] network_port
2779  \param [in] network_proto - one of tls, tcp, udp
2780  \param [in] metadata - generic metadata supplied by module
2781  \param [out] err - Error if it exists
2782 */
2783 SWITCH_DECLARE(switch_status_t) switch_core_add_registration(const char *user, const char *realm, const char *token, const char *url, uint32_t expires,
2784  const char *network_ip, const char *network_port, const char *network_proto,
2785  const char *metadata);
2786 /*!
2787  \brief Delete user registration
2788  \param [in] user
2789  \param [in] realm
2790  \param [in] token
2791  \param [out] err - Error if it exists
2792 */
2793 SWITCH_DECLARE(switch_status_t) switch_core_del_registration(const char *user, const char *realm, const char *token);
2794 /*!
2795  \brief Expire user registrations
2796  \param [in] force delete all registrations
2797  \param [out] err - Error if it exists
2798 */
2800 
2801 /*!
2802  \brief Get RTP port range start value
2803  \param[in] void
2804  \param[out] RTP port range start value
2805 */
2807 
2808 /*!
2809  \brief Get RTP port range end value
2810  \param[in] void
2811  \param[out] RTP port range end value
2812 */
2814 
2820 SWITCH_DECLARE(void) switch_say_file(switch_say_file_handle_t *sh, const char *fmt, ...);
2822 SWITCH_DECLARE(void) switch_close_extra_files(int *keep, int keep_ttl);
2824 SWITCH_DECLARE(void) switch_os_yield(void);
2826 SWITCH_DECLARE(void) switch_core_gen_encoded_silence(unsigned char *data, const switch_codec_implementation_t *read_impl, switch_size_t len);
2827 
2828 SWITCH_DECLARE(switch_cache_db_handle_type_t) switch_core_dbtype(void);
2829 SWITCH_DECLARE(void) switch_core_sql_exec(const char *sql);
2830 SWITCH_DECLARE(int) switch_core_recovery_recover(const char *technology, const char *profile_name);
2833 SWITCH_DECLARE(void) switch_core_recovery_flush(const char *technology, const char *profile_name);
2834 
2837 
2844  uint32_t numq, const char *dsn, uint32_t max_trans,
2845  const char *pre_trans_execute,
2846  const char *post_trans_execute,
2847  const char *inner_pre_trans_execute,
2848  const char *inner_post_trans_execute);
2849 
2850 #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)
2851 
2855  const char *sql, switch_core_db_event_callback_func_t callback, void *pdata, char **err);
2856 
2859  void *pdata);
2863  void *pdata);
2864 
2867  void *pdata);
2871  void *pdata);
2872 
2873 SWITCH_DECLARE(pid_t) switch_fork(void);
2874 
2875 SWITCH_DECLARE(int) switch_core_gen_certs(const char *prefix);
2880 SWITCH_DECLARE(switch_status_t) _switch_core_session_request_video_refresh(switch_core_session_t *session, int force, const char *file, const char *func, int line);
2881 #define switch_core_session_request_video_refresh(_s) _switch_core_session_request_video_refresh(_s, 0, __FILE__, __SWITCH_FUNC__, __LINE__)
2882 #define switch_core_session_force_request_video_refresh(_s) _switch_core_session_request_video_refresh(_s, 1, __FILE__, __SWITCH_FUNC__, __LINE__)
2884 SWITCH_DECLARE(int) switch_system(const char *cmd, switch_bool_t wait);
2885 SWITCH_DECLARE(int) switch_stream_system_fork(const char *cmd, switch_stream_handle_t *stream);
2886 SWITCH_DECLARE(int) switch_stream_system(const char *cmd, switch_stream_handle_t *stream);
2887 
2888 SWITCH_DECLARE(int) switch_spawn(const char *cmd, switch_bool_t wait);
2889 SWITCH_DECLARE(int) switch_stream_spawn(const char *cmd, switch_bool_t shell, switch_bool_t wait, switch_stream_handle_t *stream);
2890 
2892 
2894 
2895 SWITCH_DECLARE(const char *)switch_version_major(void);
2896 SWITCH_DECLARE(const char *)switch_version_minor(void);
2897 SWITCH_DECLARE(const char *)switch_version_micro(void);
2898 
2899 SWITCH_DECLARE(const char *)switch_version_revision(void);
2901 SWITCH_DECLARE(const char *)switch_version_full(void);
2902 SWITCH_DECLARE(const char *)switch_version_full_human(void);
2903 
2905 
2907 
2909 
2911 #endif
2912 /* For Emacs:
2913  * Local Variables:
2914  * mode:c
2915  * indent-tabs-mode:t
2916  * tab-width:4
2917  * c-basic-offset:4
2918  * End:
2919  * For VIM:
2920  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
2921  */
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)
char * switch_core_perform_strndup(_In_ switch_memory_pool_t *pool, _In_z_ const char *todup, size_t len, _In_z_ const char *file, _In_z_ const char *func, _In_ int line)
switch_time_t stamp
Definition: switch_core.h:62
int32_t change_user_group(const char *user, const char *group)
Change user and/or group of the running process.
Definition: switch_core.c:1083
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:311
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.
switch_status_t switch_core_session_start_text_thread(switch_core_session_t *session)
switch_status_t switch_core_hash_insert_dup_destructor(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ const char *str, hashtable_destructor_t destructor)
Insert strdup(str) into a hash.
const char * switch_core_get_switchname(void)
Definition: switch_core.c:361
switch_status_t switch_core_speech_feed_tts(switch_speech_handle_t *sh, const char *text, switch_speech_flag_t *flags)
Feed text to the TTS module.
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:609
switch_xml_t xml_cdr
Definition: switch_core.h:83
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)
switch_status_t switch_core_session_set_external_id(_In_ switch_core_session_t *session, _In_z_ const char *use_external_id)
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)
switch_status_t switch_core_file_pre_close(_In_ switch_file_handle_t *fh)
Pre close an open file handle, then can get file size etc., no more wirte to the file.
void switch_close_extra_files(int *keep, int keep_ttl)
Definition: switch_core.c:3244
#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:1232
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:783
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:183
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:2552
void switch_core_session_passthru(switch_core_session_t *session, switch_media_type_t type, switch_bool_t on)
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 *const const double number
Definition: switch_cJSON.h:254
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:78
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.
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:190
uint32_t switch_core_sessions_per_second(_In_ uint32_t new_limit)
Set/Get Session Rate Limit.
switch_bool_t(* switch_hash_delete_callback_t)(_In_ const void *key, _In_ const void *val, _In_opt_ void *pData)
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:1792
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:3363
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:366
uint16_t switch_core_get_rtp_port_range_end_port(void)
Get RTP port range end value.
Definition: switch_core.c:3581
#define SWITCH_END_EXTERN_C
Definition: switch.h:43
switch_device_state_t state
Definition: switch_core.h:128
switch_mutex_t * mutex
Definition: switch_core.h:220
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:177
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:129
switch_cache_db_handle_type_t type
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:945
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:2594
switch_call_direction_t
Definition: switch_types.h:303
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:126
uint32_t switch_core_debug_level(void)
Definition: switch_core.c:2607
#define SWITCH_MAX_CORE_THREAD_SESSION_OBJS
Definition: switch_core.h:47
switch_bool_t switch_core_running(void)
Definition: switch_core.c:2993
void switch_core_session_unsched_heartbeat(switch_core_session_t *session)
cJSON *const to
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:258
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:437
switch_mutex_t * switch_core_session_get_mutex(switch_core_session_t *session)
Signal a session&#39;s state machine thread that a state change has occured.
switch_bool_t(* switch_media_bug_callback_t)(switch_media_bug_t *, void *, switch_abc_type_t)
switch_audio_col_t
Definition: switch_types.h:613
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.
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_database_available(char *dsn)
Returns error if no suitable database interface found for a dsn.
const cJSON *const b
Definition: switch_cJSON.h:243
void switch_core_media_bug_set_media_params(switch_media_bug_t *bug, switch_mm_t *mm)
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.
switch_status_t switch_core_get_stacksizes(switch_size_t *cur, switch_size_t *max)
Definition: switch_core.c:3512
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:131
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(* hashtable_destructor_t)(void *ptr)
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:87
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:633
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:3570
void switch_core_speech_float_param_tts(switch_speech_handle_t *sh, char *param, double val)
Set a float parameter on a TTS handle.
const char *const const char *const const cJSON *const value
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:677
switch_core_session_message_types_t
Possible types of messages for inter-session communication.
switch_digit_action_target_t
Definition: switch_types.h:283
switch_core_db_t * switch_core_db_open_in_memory(const char *uri)
Open a core db (SQLite) in-memory.
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:2602
switch_status_t switch_core_destroy(void)
Destroy the core.
Definition: switch_core.c:3020
static void * switch_must_malloc(size_t _b)
Definition: switch_core.h:233
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)
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_thread_pool_wait(switch_thread_data_t *td, int ms)
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_hash_insert_auto_free(switch_hash_t *hash, const char *key, const void *data)
Insert data into a hash and set flags so the value is automatically freed on delete.
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.
const char * switch_core_session_get_external_id(_In_ switch_core_session_t *session)
Retrieve the unique external identifier from a 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:985
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:79
switch_time_t active_start
Definition: switch_core.h:130
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:71
switch_mutex_t * mutex
Definition: switch_core.h:140
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:1055
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:1219
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_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:335
char const int const cJSON_bool format
Definition: switch_cJSON.h:153
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:348
A table of i/o routines that an endpoint interface can implement.
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)
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)
switch_status_t switch_core_file_handle_dup(switch_file_handle_t *oldfh, switch_file_handle_t **newfh, switch_memory_pool_t *pool)
Duplicates a file handle using another pool.
uint32_t switch_core_flag_t
Definition: switch_types.h:395
switch_sql_queue_manager_t * qm
switch_status_t switch_core_session_override_io_routines(switch_core_session_t *session, switch_io_routines_t *ior)
switch_hash_t * hash
Definition: switch_event.c:76
char * type
Definition: switch_core.h:155
switch_input_callback_function_t input_callback
Definition: switch_core.h:224
void switch_core_pool_stats(switch_stream_handle_t *stream)
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:3536
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_coredb_handle_t * core_db_dbh
Definition: switch_core.h:2569
switch_event_t * event
Definition: switch_core.h:84
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:179
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:1227
switch_memory_pool_t * pool
Definition: switch_core.h:225
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:139
switch_status_t switch_core_thread_set_cpu_affinity(int cpu)
Definition: switch_core.c:1763
switch_status_t switch_core_expire_registration(int force)
Expire user registrations.
switch_core_session_message_flag_t flags
Definition: switch_core.h:207
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_bool_t switch_check_network_list_ip_port_token(const char *ip_str, int port, const char *list_name, const char **token)
Definition: switch_core.c:1374
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 cJSON_bool fmt
Definition: switch_cJSON.h:150
uint32_t switch_core_max_dtmf_duration(uint32_t duration)
Definition: switch_core.c:1704
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&#39;s partner (the session its bridged to)
char * switch_core_get_domain(switch_bool_t dup)
Definition: switch_core.c:367
switch_video_read_flag_t
const char * switch_core_media_bug_get_text(switch_media_bug_t *bug)
switch_status_t switch_core_session_io_read_lock(switch_core_session_t *session)
switch_time_t ring_stop
Definition: switch_core.h:134
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.
void * switch_core_hash_insert_alloc_destructor(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ size_t size, hashtable_destructor_t destructor)
Allocate memory and insert into a hash.
int switch_system(const char *cmd, switch_bool_t wait)
Definition: switch_core.c:3342
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)
switch_status_t switch_core_hash_insert_dup_auto_free(switch_hash_t *hash, const char *key, const char *str)
Insert strdup(str) into a hash and set flags so the value is automatically freed on delete...
uint32_t switch_core_min_dtmf_duration(uint32_t duration)
Definition: switch_core.c:1744
int32_t set_auto_priority(void)
Definition: switch_core.c:1065
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:598
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:142
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:2556
switch_status_t switch_console_set_alias(const char *string)
switch_time_t on
Definition: switch_core.h:75
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:386
uint32_t switch_core_media_bug_prune(switch_core_session_t *session)
int32_t switch_core_sps_last(void)
Definition: switch_core.c:2617
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.
uint32_t switch_core_session_hupall_matching_vars_ans(_In_ switch_event_t *vars, _In_ switch_call_cause_t cause, switch_hup_type_t type)
Hangup all sessions which match specific channel variable(s)
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:495
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:135
void switch_time_set_matrix(switch_bool_t enable)
Definition: switch_time.c:360
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:2988
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_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:1322
switch_size_t string_reply_size
Definition: switch_core.h:201
int switch_max_file_desc(void)
Definition: switch_core.c:3228
void switch_core_session_hupall(_In_ switch_call_cause_t cause)
Hangup all sessions.
switch_cache_db_handle_type_t
Definition: switch_core.h:2562
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)
int switch_stream_spawn(const char *cmd, switch_bool_t shell, switch_bool_t wait, switch_stream_handle_t *stream)
Definition: switch_core.c:3372
switch_call_direction_t direction
Definition: switch_core.h:88
int index
Definition: switch_cJSON.h:160
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.
int switch_spawn(const char *cmd, switch_bool_t wait)
Definition: switch_core.c:3507
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:3130
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:67
int32_t set_normal_priority(void)
Set the maximum priority the process can obtain.
Definition: switch_core.c:1060
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)
switch_status_t _switch_cache_db_get_db_handle_dsn_ex(switch_cache_db_handle_t **dbh, const char *dsn, switch_bool_t make_module_no_unloadable, const char *file, const char *func, int line)
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_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_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:133
int32_t switch_core_sps(void)
Definition: switch_core.c:2612
static void * switch_must_realloc(void *_b, size_t _z)
Definition: switch_core.h:240
#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:1475
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.
const cJSON *const const cJSON_bool case_sensitive
Definition: switch_cJSON.h:243
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:397
uint32_t switch_core_max_audio_channels(uint32_t limit)
Definition: switch_core.c:2642
An abstraction of a data frame.
Definition: switch_frame.h:54
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&#39;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:286
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:2022
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:90
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 ...
int(* switch_core_db_callback_func_t)(void *pArg, int argc, char **argv, char **columnNames)
switch_size_t pointer_arg_size
Definition: switch_core.h:194
void switch_core_runtime_loop(int bg)
Run endlessly until the system is shutdown.
Definition: switch_core.c:1187
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:658
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:137
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:2570
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:150
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.
int32_t switch_core_sps_peak(void)
Definition: switch_core.c:2622
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)
switch_cache_db_odbc_options_t odbc_options
Definition: switch_core.h:2595
switch_database_interface_handle_t * database_interface_dbh
Definition: switch_core.h:2571
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:524
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_media_bug_get_media_params(switch_media_bug_t *bug, switch_mm_t *mm)
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:981
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.
int32_t switch_core_sessions_peak_fivemin(void)
Definition: switch_core.c:2637
switch_channel_callstate_t callstate
Definition: switch_core.h:85
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:159
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.
switch_status_t switch_core_hash_insert_pointer(switch_hash_t *hash, const void *data)
Insert data into a hash with an auto-generated key based on the data pointer.
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)
struct fspr_thread_mutex_t switch_mutex_t
Definition: switch_apr.h:314
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.
switch_bool_t switch_core_session_transcoding(switch_core_session_t *session_a, switch_core_session_t *session_b, switch_media_type_t type)
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:1379
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.
void *(SWITCH_THREAD_FUNC * switch_thread_start_t)(switch_thread_t *, void *)
Definition: switch_apr.h:950
unsigned int switch_core_session_running(_In_ switch_core_session_t *session)
determine if the session&#39;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.
char * ip
Definition: switch_msrp.c:60
void switch_core_session_run(_In_ switch_core_session_t *session)
Start the session&#39;s state machine.
uint32_t switch_core_default_dtmf_duration(uint32_t duration)
Definition: switch_core.c:1721
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_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_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:331
const char * switch_core_get_event_channel_key_separator(void)
Definition: switch_core.c:3592
switch_thread_rwlock_t * rwlock
Definition: switch_event.c:75
switch_size_t pointer_reply_size
Definition: switch_core.h:205
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:141
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.
const cJSON *const target
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:166
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:356
struct switch_device_record_s * parent
Definition: switch_core.h:89
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&#39;s native message format.
uint32_t len
Definition: switch_core.h:153
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
switch_bool_t switch_cache_db_test_reactive_ex(switch_cache_db_handle_t *db, const char *test_sql, const char *drop_sql, const char *reactive_sql, const char *row_size_limited_reactive_sql)
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.
void switch_time_calibrate_clock(void)
Definition: switch_time.c:208
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.
int(* switch_core_db_event_callback_func_t)(void *pArg, switch_event_t *event)
Definition: switch_core.h:2553
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.
int(* switch_core_db_err_callback_func_t)(void *pArg, const char *errmsg)
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_cache_db_database_interface_options_t database_interface_options
Definition: switch_core.h:2596
switch_bool_t switch_core_ready_outbound(void)
Determines if the core is ready to place outbound calls.
Definition: switch_core.c:3008
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)
const char * filename
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_status_t _switch_core_session_request_video_refresh(switch_core_session_t *session, int force, const char *file, const char *func, int line)
switch_time_t switch_mono_micro_time_now(void)
Definition: switch_time.c:316
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_video_thread_callback_func_t)(switch_core_session_t *session, switch_frame_t *frame, void *user_data)
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:138
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:342
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:344
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_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:373
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:1211
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:322
#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:1447
switch_status_t switch_sql_queue_manager_start(switch_sql_queue_manager_t *qm)
char * key
Definition: switch_msrp.c:64
A generic object to pass as a thread&#39;s session object to allow mutiple arguements and a pool...
Definition: switch_core.h:216
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)
void switch_cache_db_database_interface_flush_handles(switch_database_interface_t *database_interface)
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)
void(* switch_media_bug_exec_cb_t)(switch_media_bug_t *bug, void *user_data)
const char * switch_core_session_get_text_buffer(switch_core_session_t *session)
switch_status_t switch_core_session_try_reset(switch_core_session_t *session, switch_bool_t flush_dtmf, switch_bool_t reset_read_codec)
Reset the buffers and resampler on a session, fail if can not lock codec mutexes. ...
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:3118
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.
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:145
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:86
#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:127
FILE * switch_core_get_console(void)
Get the output console.
Definition: switch_core.c:253
struct fspr_pool_t switch_memory_pool_t
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:1452
const char *const name
Definition: switch_cJSON.h:250
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:2579
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:910
switch_time_t last_call_time
Definition: switch_core.h:132
switch_bool_t switch_core_check_dtls_pem(const char *file)
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:2406
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:1445
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:2651
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)
struct fspr_thread_t switch_thread_t
Definition: switch_apr.h:941
int switch_core_recovery_recover(const char *technology, const char *profile_name)
switch_status_t switch_core_media_bug_close(_Inout_ switch_media_bug_t **bug, switch_bool_t destroy)
Close and destroy a media bug.
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_database_interface_t * database_interface
Definition: switch_core.h:2589
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
struct fspr_thread_rwlock_t switch_thread_rwlock_t
Definition: switch_apr.h:436
void switch_core_asr_text_param(switch_asr_handle_t *ah, char *param, const char *val)
Set a text parameter on an asr handle.
int32_t switch_core_sps_peak_fivemin(void)
Definition: switch_core.c:2627
switch_bool_t switch_core_ready_inbound(void)
Determines if the core is ready to take inbound calls.
Definition: switch_core.c:3003
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:3282
Abstract interface to a database module.
switch_bool_t switch_core_ready(void)
Determines if the core is ready to take calls.
Definition: switch_core.c:2998
uint32_t switch_default_rate(const char *name, uint32_t number)
Definition: switch_core.c:2033
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:149
int32_t switch_core_sessions_peak(void)
Definition: switch_core.c:2632
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:2535
switch_time_t off
Definition: switch_core.h:76
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.
switch_status_t switch_core_check_core_db_dsn(void)
Returns error if no suitable database interface found to serve core db dsn.
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:261
switch_management_action_t
Definition: switch_types.h:481
The abstraction of a loadable module.
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:63
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:596
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.
uint32_t switch_core_session_stack_count(switch_core_session_t *session, int x)
#define SWITCH_BEGIN_EXTERN_C
Definition: switch.h:42
switch_time_t hold_stop
Definition: switch_core.h:136
switch_status_t switch_core_set_console(const char *console)
Set the output console to the desired file.
Definition: switch_core.c:243
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.