FreeSWITCH API Documentation  1.7.0
switch_core_pvt.h
Go to the documentation of this file.
1 /*
2  * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
3  * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org>
4  *
5  * Version: MPL 1.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
18  *
19  * The Initial Developer of the Original Code is
20  * Anthony Minessale II <anthm@freeswitch.org>
21  * Portions created by the Initial Developer are Copyright (C)
22  * the Initial Developer. All Rights Reserved.
23  *
24  * Contributor(s):
25  *
26  * Anthony Minessale II <anthm@freeswitch.org>
27  *
28  *
29  * switch_core.h -- Core Library Private Data (not to be installed into the system)
30  * If the last line didn't make sense, stop reading this file, go away!,
31  * this file does not exist!!!!
32  *
33  */
34 #define SPANDSP_NO_TIFF 1
35 #include "spandsp.h"
36 #include "switch_profile.h"
37 
38 #ifndef WIN32
39 #include <switch_private.h>
40 #endif
41 
42 /* for apr_pool_create and apr_pool_destroy */
43 /* functions only used in this file so not exposed */
44 #include <apr_pools.h>
45 
46 /* for apr_hash_make, apr_hash_pool_get, apr_hash_set */
47 /* functions only used in this file so not exposed */
48 #include <apr_hash.h>
49 
50 /* for apr_pvsprintf */
51 /* function only used in this file so not exposed */
52 #include <apr_strings.h>
53 
54 /* for apr_initialize and apr_terminate */
55 /* function only used in this file so not exposed */
56 #include <apr_general.h>
57 
58 #include <apr_portable.h>
59 
60 #ifdef HAVE_MLOCKALL
61 #include <sys/mman.h>
62 #endif
63 
64 #ifdef HAVE_NETDB_H
65 #include <netdb.h>
66 #endif
67 
68 #ifndef WIN32
69 /* setuid, setgid */
70 #include <unistd.h>
71 
72 /* getgrnam, getpwnam */
73 #include <pwd.h>
74 #include <grp.h>
75 
76 #ifdef HAVE_SYS_RESOURCE_H
77 #include <sys/resource.h>
78 #endif
79 #endif
80 
81 /* #define DEBUG_ALLOC */
82 #define DO_EVENTS
83 
84 #define SWITCH_EVENT_QUEUE_LEN 256
85 #define SWITCH_MESSAGE_QUEUE_LEN 256
86 
87 #define SWITCH_BUFFER_BLOCK_FRAMES 25
88 #define SWITCH_BUFFER_START_FRAMES 50
89 
90 typedef enum {
91  SSF_NONE = 0,
92  SSF_DESTROYED = (1 << 0),
93  SSF_WARN_TRANSCODE = (1 << 1),
94  SSF_HANGUP = (1 << 2),
95  SSF_THREAD_STARTED = (1 << 3),
96  SSF_THREAD_RUNNING = (1 << 4),
97  SSF_READ_TRANSCODE = (1 << 5),
98  SSF_WRITE_TRANSCODE = (1 << 6),
101  SSF_DESTROYABLE = (1 << 9),
104 
113 
121 
127 
130 
139 
142 
145 
156  uint32_t stack_count;
157 
163 
169 
170  /* video frame.data being trated differently than audio, allocate a dynamic data buffer if necessary*/
173  // switch_frame_t video_enc_write_frame;
174 
177  // switch_frame_t video_enc_read_frame;
178 
181  uint32_t track_duration;
182  uint32_t track_id;
184  uint32_t soft_lock;
186  plc_state_t *plc;
187 
189  uint32_t decoder_errors;
193 };
194 
208  void *user_data;
209  uint32_t flags;
210  uint8_t ready;
213  time_t stop_time;
215  char *function;
216  char *target;
232 };
233 
234 typedef enum {
238 
242  int64_t offset;
250  FILE *console;
251  uint8_t running;
253  uint32_t flags;
260  uint32_t sps_total;
261  int32_t sps;
262  int32_t sps_last;
263  int32_t sps_peak;
265  int32_t sessions_peak;
268  char *mailer_app;
274  char dummy_data[5];
276  char *odbc_dsn;
277  char *dbname;
278  uint32_t debug_level;
279  uint32_t runlevel;
280  uint32_t tipping_point;
283  int32_t timer_affinity;
285  double profile_time;
288  char hostname[256];
289  char *switchname;
291  uint32_t max_db_handles;
294  uint32_t time_sync;
301 };
302 
303 extern struct switch_runtime runtime;
304 
305 
309  uint32_t session_count;
310  uint32_t session_limit;
315  int running;
316  int busy;
317 };
318 
320 
321 
322 
324 void switch_core_sqldb_stop(void);
326 void switch_core_session_uninit(void);
329 void switch_core_memory_stop(void);
struct apr_queue_t switch_queue_t
Definition: switch_apr.h:590
switch_frame_t * write_replace_frame_out
switch_memory_pool_t * switch_core_memory_init(void)
#define SWITCH_MAX_STREAMS
Definition: switch_core.h:47
uint32_t min_dtmf_duration
char * core_db_inner_post_trans_execute
switch_audio_resampler_t * write_resampler
switch_frame_t dummy_cng_frame
switch_codec_implementation_t read_impl
Image Descriptor.
Definition: switch_image.h:88
switch_queue_t * event_queue
switch_thread_rwlock_t * bug_rwlock
switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_t manage)
switch_thread_id_t thread_id
switch_frame_t * read_replace_frame_in
switch_time_t initiated
uint8_t raw_read_buf[SWITCH_RECOMMENDED_BUFFER_SIZE]
const switch_state_handler_table_t * state_handlers[SWITCH_MAX_STATE_HANDLERS]
Abstraction of an module endpoint interface This is the glue between the abstract idea of a "channel"...
switch_mutex_t * codec_write_mutex
switch_session_flag_t flags
switch_frame_t enc_read_frame
int32_t timer_affinity
switch_status_t(* switch_core_video_thread_callback_func_t)(switch_core_session_t *session, switch_frame_t *frame, void *user_data)
switch_queue_t * thread_queue
switch_buffer_t * raw_write_buffer
char * core_db_post_trans_execute
#define SWITCH_RECOMMENDED_BUFFER_SIZE
Definition: switch_types.h:557
void switch_core_memory_stop(void)
uint32_t record_pre_buffer_count
switch_mutex_t * codec_read_mutex
switch_bool_t
Definition: switch_types.h:405
switch_buffer_t * video_raw_read_buffer
switch_codec_t * video_read_codec
switch_memory_pool_t * pool
switch_codec_t * read_codec
Representation of an event.
Definition: switch_event.h:80
switch_codec_t * real_read_codec
void * streams[SWITCH_MAX_STREAMS]
void switch_core_session_init(switch_memory_pool_t *pool)
switch_queue_t * read_video_queue
switch_thread_rwlock_t * global_var_rwlock
switch_core_session_t * session
switch_codec_implementation_t video_read_impl
switch_codec_t * video_write_codec
switch_event_t * global_vars
switch_buffer_t * raw_write_buffer
switch_codec_implementation_t video_write_impl
char hostname[256]
switch_codec_implementation_t read_impl
switch_mutex_t * throttle_mutex
switch_bool_t(* switch_media_bug_callback_t)(switch_media_bug_t *, void *, switch_abc_type_t)
switch_queue_t * signal_data_queue
#define SWITCH_MAX_STATE_HANDLERS
Definition: switch_types.h:559
struct switch_runtime runtime
Definition: switch_core.c:64
uint32_t microseconds_per_tick
struct apr_thread_cond_t switch_thread_cond_t
Definition: switch_apr.h:463
switch_thread_cond_t * cond
switch_media_bug_callback_t callback
switch_media_handle_t * media_handle
switch_queue_t * write_video_queue
switch_io_event_hooks_t event_hooks
switch_mutex_t * read_mutex
switch_codec_implementation_t write_impl
switch_hash_t * ptimes
switch_queue_t * private_event_queue
switch_dbtype_t odbc_dbtype
int64_t switch_time_t
Definition: switch_apr.h:188
void * private_info[SWITCH_CORE_SESSION_MAX_PRIVATES]
int32_t sessions_peak_fivemin
switch_codec_implementation_t real_read_impl
switch_bool_t colorize_console
switch_channel_t * channel
switch_audio_resampler_t * read_resampler
switch_mutex_t * frame_read_mutex
switch_frame_t * ping_frame
switch_mutex_t * video_codec_write_mutex
uint8_t enc_write_buf[SWITCH_RECOMMENDED_BUFFER_SIZE]
void switch_core_session_uninit(void)
switch_thread_t * video_bug_thread
switch_queue_t * spy_video_queue[2]
switch_dbtype_t
switch_thread_t * thread
switch_codec_t * write_codec
switch_frame_t * write_replace_frame_in
struct apr_thread_rwlock_t switch_thread_rwlock_t
Definition: switch_apr.h:436
switch_image_t * spy_img[2]
switch_media_bug_t * bugs
switch_bool_t manage
switch_mutex_t * resample_mutex
switch_queue_t * message_queue
switch_hash_t * mime_type_exts
switch_buffer_t * video_raw_write_buffer
An abstraction of a data frame.
Definition: switch_frame.h:43
uintptr_t switch_size_t
switch_thread_cond_t * cond
uint32_t db_handle_timeout
switch_frame_t * video_ping_frame
struct switch_media_bug * next
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH+1]
switch_thread_rwlock_t * io_rwlock
pthread_t switch_thread_id_t
Definition: switch_apr.h:51
switch_mutex_t * session_hash_mutex
switch_buffer_t * raw_read_buffer
switch_memory_pool_t * memory_pool
switch_mutex_t * global_mutex
#define SWITCH_CORE_SESSION_MAX_PRIVATES
Definition: switch_types.h:232
switch_codec_t bug_codec
switch_frame_t raw_read_frame
switch_codec_implementation_t write_impl
switch_hash_t * mime_types
An audio resampling handle.
switch_core_video_thread_callback_func_t video_read_callback
uint32_t max_dtmf_duration
switch_frame_t * native_write_frame
switch_mutex_t * video_codec_read_mutex
switch_queue_t * private_event_queue_pri
switch_time_t timestamp
struct apr_thread_mutex_t switch_mutex_t
Definition: switch_apr.h:314
switch_memory_pool_t * pool
switch_status_t
Common return values.
uint8_t enc_read_buf[SWITCH_RECOMMENDED_BUFFER_SIZE]
switch_vid_spy_fmt_t
switch_hash_t * session_table
void switch_core_sqldb_stop(void)
uint32_t record_frame_size
switch_frame_t video_raw_read_frame
struct apr_thread_t switch_thread_t
Definition: switch_apr.h:941
switch_log_level_t hard_log_level
uint32_t default_dtmf_duration
struct switch_session_manager session_manager
uint32_t tipping_point
int32_t sps_peak_fivemin
switch_frame_t enc_write_frame
switch_frame_t video_raw_write_frame
uint32_t max_db_handles
int16_t tmp[SWITCH_RECOMMENDED_BUFFER_SIZE]
char * core_db_pre_trans_execute
uint32_t port_alloc_flags
switch_mutex_t * mutex
switch_ivr_dmachine_t * dmachine[2]
switch_mutex_t * uuid_mutex
struct apr_pool_t switch_memory_pool_t
switch_session_flag_t
switch_memory_pool_t * memory_pool
A table of settings and callbacks that define a paticular implementation of a codec.
switch_endpoint_interface_t * endpoint_interface
uint32_t debug_level
switch_codec_t * real_write_codec
switch_log_level_t loglevel
uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE]
uint8_t raw_write_buf[SWITCH_RECOMMENDED_BUFFER_SIZE]
uint32_t cpu_idle_smoothing_depth
switch_vid_spy_fmt_t spy_fmt
char * core_db_inner_pre_trans_execute
switch_slin_data_t * sdata
switch_thread_id_t thread_id
switch_buffer_t * raw_read_buffer
switch_frame_t * read_replace_frame_out
typedefSWITCH_BEGIN_EXTERN_C struct switch_io_event_hooks switch_io_event_hooks_t
switch_mutex_t * mutex
switch_frame_t raw_write_frame
void switch_core_state_machine_init(switch_memory_pool_t *pool)
switch_mutex_t * write_mutex
switch_frame_t * read_demux_frame
switch_thread_rwlock_t * rwlock
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH+1]
switch_frame_t * native_read_frame
uint32_t record_pre_buffer_max
switch_app_log_t * app_log
switch_log_level_t
Log Level Enumeration.
switch_profile_timer_t * profile_timer
#define SWITCH_UUID_FORMATTED_LENGTH
Definition: switch_apr.h:545
switch_time_t reference