| File: | src/mod/endpoints/mod_rtc/mod_rtc.c |
| Location: | line 238, column 3 |
| Description: | Value stored to 'status' is never read |
| 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 | * mod_rtc.c -- RTC Endpoint |
| 30 | * |
| 31 | */ |
| 32 | |
| 33 | /* Best viewed in a 160 x 60 VT100 Terminal or so the line below at least fits across your screen*/ |
| 34 | /*************************************************************************************************************************************************************/ |
| 35 | #include <switch.h> |
| 36 | |
| 37 | SWITCH_MODULE_LOAD_FUNCTION(mod_rtc_load)switch_status_t mod_rtc_load (switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool); |
| 38 | SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_rtc_shutdown)switch_status_t mod_rtc_shutdown (void); |
| 39 | SWITCH_MODULE_DEFINITION(mod_rtc, mod_rtc_load, mod_rtc_shutdown, NULL)static const char modname[] = "mod_rtc" ; __attribute__((visibility ("default"))) switch_loadable_module_function_table_t mod_rtc_module_interface = { 5, mod_rtc_load, mod_rtc_shutdown, ((void*)0), SMODF_NONE }; |
| 40 | |
| 41 | |
| 42 | switch_endpoint_interface_t *rtc_endpoint_interface; |
| 43 | |
| 44 | #define STRLEN15 15 |
| 45 | |
| 46 | static switch_status_t rtc_on_init(switch_core_session_t *session); |
| 47 | |
| 48 | static switch_status_t rtc_on_exchange_media(switch_core_session_t *session); |
| 49 | static switch_status_t rtc_on_soft_execute(switch_core_session_t *session); |
| 50 | static switch_call_cause_t rtc_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event, |
| 51 | switch_caller_profile_t *outbound_profile, switch_core_session_t **new_session, |
| 52 | switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause); |
| 53 | static switch_status_t rtc_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id); |
| 54 | static switch_status_t rtc_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id); |
| 55 | static switch_status_t rtc_read_video_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id); |
| 56 | static switch_status_t rtc_write_video_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id); |
| 57 | static switch_status_t rtc_kill_channel(switch_core_session_t *session, int sig); |
| 58 | |
| 59 | typedef struct { |
| 60 | switch_channel_t *channel; |
| 61 | switch_core_session_t *session; |
| 62 | switch_caller_profile_t *caller_profile; |
| 63 | switch_media_handle_t *media_handle; |
| 64 | switch_core_media_params_t mparams; |
| 65 | } private_object_t; |
| 66 | |
| 67 | static struct { |
| 68 | switch_memory_pool_t *pool; |
| 69 | switch_mutex_t *mutex; |
| 70 | int running; |
| 71 | } mod_rtc_globals; |
| 72 | |
| 73 | |
| 74 | /* BODY OF THE MODULE */ |
| 75 | /*************************************************************************************************************************************************************/ |
| 76 | |
| 77 | /* |
| 78 | State methods they get called when the state changes to the specific state |
| 79 | returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next |
| 80 | so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it. |
| 81 | */ |
| 82 | static switch_status_t rtc_on_init(switch_core_session_t *session) |
| 83 | { |
| 84 | return SWITCH_STATUS_SUCCESS; |
| 85 | } |
| 86 | |
| 87 | static switch_status_t rtc_on_routing(switch_core_session_t *session) |
| 88 | { |
| 89 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_rtc.c", (const char *)__func__ , 89, (const char*)(session), SWITCH_LOG_DEBUG, "%s RTC ROUTING\n", |
| 90 | switch_channel_get_name(switch_core_session_get_channel(session))); |
| 91 | |
| 92 | return SWITCH_STATUS_SUCCESS; |
| 93 | } |
| 94 | |
| 95 | |
| 96 | static switch_status_t rtc_on_reset(switch_core_session_t *session) |
| 97 | { |
| 98 | |
| 99 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_rtc.c", (const char *)__func__ , 99, (const char*)(session), SWITCH_LOG_DEBUG, "%s RTC RESET\n", |
| 100 | switch_channel_get_name(switch_core_session_get_channel(session))); |
| 101 | |
| 102 | |
| 103 | return SWITCH_STATUS_SUCCESS; |
| 104 | } |
| 105 | |
| 106 | |
| 107 | static switch_status_t rtc_on_hibernate(switch_core_session_t *session) |
| 108 | { |
| 109 | |
| 110 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_rtc.c", (const char *)__func__ , 110, (const char*)(session), SWITCH_LOG_DEBUG, "%s RTC HIBERNATE\n", |
| 111 | switch_channel_get_name(switch_core_session_get_channel(session))); |
| 112 | |
| 113 | |
| 114 | return SWITCH_STATUS_SUCCESS; |
| 115 | } |
| 116 | |
| 117 | static switch_status_t rtc_on_execute(switch_core_session_t *session) |
| 118 | { |
| 119 | |
| 120 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_rtc.c", (const char *)__func__ , 120, (const char*)(session), SWITCH_LOG_DEBUG, "%s RTC EXECUTE\n", |
| 121 | switch_channel_get_name(switch_core_session_get_channel(session))); |
| 122 | |
| 123 | return SWITCH_STATUS_SUCCESS; |
| 124 | } |
| 125 | |
| 126 | |
| 127 | switch_status_t rtc_on_destroy(switch_core_session_t *session) |
| 128 | { |
| 129 | switch_channel_t *channel = switch_core_session_get_channel(session); |
| 130 | |
| 131 | |
| 132 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_rtc.c", (const char *)__func__ , 132, (const char*)(session), SWITCH_LOG_DEBUG, "%s RTC DESTROY\n", switch_channel_get_name(channel)); |
| 133 | switch_media_handle_destroy(session); |
| 134 | |
| 135 | return SWITCH_STATUS_SUCCESS; |
| 136 | |
| 137 | } |
| 138 | |
| 139 | switch_status_t rtc_on_hangup(switch_core_session_t *session) |
| 140 | { |
| 141 | return SWITCH_STATUS_SUCCESS; |
| 142 | } |
| 143 | |
| 144 | static switch_status_t rtc_on_exchange_media(switch_core_session_t *session) |
| 145 | { |
| 146 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_rtc.c", (const char *)__func__ , 146, (const char*)(session), SWITCH_LOG_DEBUG, "RTC EXCHANGE_MEDIA\n"); |
| 147 | return SWITCH_STATUS_SUCCESS; |
| 148 | } |
| 149 | |
| 150 | static switch_status_t rtc_on_soft_execute(switch_core_session_t *session) |
| 151 | { |
| 152 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_rtc.c", (const char *)__func__ , 152, (const char*)(session), SWITCH_LOG_DEBUG, "RTC SOFT_EXECUTE\n"); |
| 153 | return SWITCH_STATUS_SUCCESS; |
| 154 | } |
| 155 | |
| 156 | |
| 157 | static switch_status_t rtc_read_video_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id) |
| 158 | { |
| 159 | return switch_core_media_read_frame(session, frame, flags, stream_id, SWITCH_MEDIA_TYPE_VIDEO); |
| 160 | } |
| 161 | |
| 162 | static switch_status_t rtc_write_video_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id) |
| 163 | { |
| 164 | private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session)switch_core_session_get_private_class(session, SWITCH_PVT_PRIMARY ); |
| 165 | switch_assert(tech_pvt != NULL)((tech_pvt != ((void*)0)) ? (void) (0) : __assert_fail ("tech_pvt != ((void*)0)" , "mod_rtc.c", 165, __PRETTY_FUNCTION__)); |
| 166 | |
| 167 | |
| 168 | if (SWITCH_STATUS_SUCCESS == switch_core_media_write_frame(session, frame, flags, stream_id, SWITCH_MEDIA_TYPE_VIDEO)) { |
| 169 | return SWITCH_STATUS_SUCCESS; |
| 170 | } |
| 171 | |
| 172 | return SWITCH_STATUS_FALSE; |
| 173 | } |
| 174 | |
| 175 | static switch_status_t rtc_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id) |
| 176 | { |
| 177 | switch_status_t status = SWITCH_STATUS_FALSE; |
| 178 | |
| 179 | status = switch_core_media_read_frame(session, frame, flags, stream_id, SWITCH_MEDIA_TYPE_AUDIO); |
| 180 | |
| 181 | return status; |
| 182 | } |
| 183 | |
| 184 | static switch_status_t rtc_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id) |
| 185 | { |
| 186 | switch_status_t status = SWITCH_STATUS_SUCCESS; |
| 187 | |
| 188 | status = switch_core_media_write_frame(session, frame, flags, stream_id, SWITCH_MEDIA_TYPE_AUDIO); |
| 189 | |
| 190 | return status; |
| 191 | } |
| 192 | |
| 193 | static switch_status_t rtc_kill_channel(switch_core_session_t *session, int sig) |
| 194 | { |
| 195 | private_object_t *tech_pvt = switch_core_session_get_private(session)switch_core_session_get_private_class(session, SWITCH_PVT_PRIMARY ); |
| 196 | |
| 197 | if (!tech_pvt) { |
| 198 | return SWITCH_STATUS_FALSE; |
| 199 | } |
| 200 | |
| 201 | switch (sig) { |
| 202 | case SWITCH_SIG_BREAK: |
| 203 | if (switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) { |
| 204 | switch_core_media_break(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO); |
| 205 | } |
| 206 | if (switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_VIDEO)) { |
| 207 | switch_core_media_break(tech_pvt->session, SWITCH_MEDIA_TYPE_VIDEO); |
| 208 | } |
| 209 | break; |
| 210 | case SWITCH_SIG_KILL: |
| 211 | default: |
| 212 | |
| 213 | if (switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO)) { |
| 214 | switch_core_media_kill_socket(tech_pvt->session, SWITCH_MEDIA_TYPE_AUDIO); |
| 215 | } |
| 216 | if (switch_core_media_ready(tech_pvt->session, SWITCH_MEDIA_TYPE_VIDEO)) { |
| 217 | switch_core_media_kill_socket(tech_pvt->session, SWITCH_MEDIA_TYPE_VIDEO); |
| 218 | } |
| 219 | break; |
| 220 | } |
| 221 | return SWITCH_STATUS_SUCCESS; |
| 222 | } |
| 223 | |
| 224 | |
| 225 | static switch_status_t rtc_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf) |
| 226 | { |
| 227 | return SWITCH_STATUS_SUCCESS; |
| 228 | } |
| 229 | |
| 230 | static switch_status_t rtc_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg) |
| 231 | { |
| 232 | switch_channel_t *channel = switch_core_session_get_channel(session); |
| 233 | private_object_t *tech_pvt = switch_core_session_get_private(session)switch_core_session_get_private_class(session, SWITCH_PVT_PRIMARY ); |
| 234 | switch_status_t status = SWITCH_STATUS_SUCCESS; |
| 235 | const char *var; |
| 236 | |
| 237 | if (switch_channel_down(channel)(switch_channel_check_signal(channel, SWITCH_TRUE) || switch_channel_get_state (channel) >= CS_HANGUP) || !tech_pvt) { |
| 238 | status = SWITCH_STATUS_FALSE; |
Value stored to 'status' is never read | |
| 239 | return SWITCH_STATUS_FALSE; |
| 240 | } |
| 241 | |
| 242 | /* ones that do not need to lock rtp mutex */ |
| 243 | switch (msg->message_id) { |
| 244 | |
| 245 | case SWITCH_MESSAGE_INDICATE_CLEAR_PROGRESS: |
| 246 | break; |
| 247 | case SWITCH_MESSAGE_INDICATE_ANSWER: |
| 248 | case SWITCH_MESSAGE_INDICATE_PROGRESS: |
| 249 | { |
| 250 | |
| 251 | if (((var = switch_channel_get_variable(channel, "rtp_secure_media")switch_channel_get_variable_dup(channel, "rtp_secure_media", SWITCH_TRUE , -1))) && |
| 252 | (switch_true(var) || switch_core_media_crypto_str2type(var) != CRYPTO_INVALID)) { |
| 253 | switch_channel_set_flag(tech_pvt->channel, CF_SECURE)switch_channel_set_flag_value(tech_pvt->channel, CF_SECURE , 1); |
| 254 | } |
| 255 | } |
| 256 | break; |
| 257 | |
| 258 | default: |
| 259 | break; |
| 260 | } |
| 261 | |
| 262 | |
| 263 | return status; |
| 264 | |
| 265 | } |
| 266 | |
| 267 | static switch_status_t rtc_receive_event(switch_core_session_t *session, switch_event_t *event) |
| 268 | { |
| 269 | return SWITCH_STATUS_SUCCESS; |
| 270 | } |
| 271 | |
| 272 | switch_io_routines_t rtc_io_routines = { |
| 273 | /*.outgoing_channel */ rtc_outgoing_channel, |
| 274 | /*.read_frame */ rtc_read_frame, |
| 275 | /*.write_frame */ rtc_write_frame, |
| 276 | /*.kill_channel */ rtc_kill_channel, |
| 277 | /*.send_dtmf */ rtc_send_dtmf, |
| 278 | /*.receive_message */ rtc_receive_message, |
| 279 | /*.receive_event */ rtc_receive_event, |
| 280 | /*.state_change */ NULL((void*)0), |
| 281 | /*.read_video_frame */ rtc_read_video_frame, |
| 282 | /*.write_video_frame */ rtc_write_video_frame, |
| 283 | /*.state_run*/ NULL((void*)0), |
| 284 | /*.get_jb*/ NULL((void*)0) |
| 285 | }; |
| 286 | |
| 287 | switch_state_handler_table_t rtc_event_handlers = { |
| 288 | /*.on_init */ rtc_on_init, |
| 289 | /*.on_routing */ rtc_on_routing, |
| 290 | /*.on_execute */ rtc_on_execute, |
| 291 | /*.on_hangup */ rtc_on_hangup, |
| 292 | /*.on_exchange_media */ rtc_on_exchange_media, |
| 293 | /*.on_soft_execute */ rtc_on_soft_execute, |
| 294 | /*.on_consume_media */ NULL((void*)0), |
| 295 | /*.on_hibernate */ rtc_on_hibernate, |
| 296 | /*.on_reset */ rtc_on_reset, |
| 297 | /*.on_park */ NULL((void*)0), |
| 298 | /*.on_reporting */ NULL((void*)0), |
| 299 | /*.on_destroy */ rtc_on_destroy |
| 300 | }; |
| 301 | |
| 302 | |
| 303 | void rtc_set_name(private_object_t *tech_pvt, const char *channame) |
| 304 | { |
| 305 | char name[256]; |
| 306 | |
| 307 | switch_snprintf(name, sizeof(name), "rtc/%s", channame); |
| 308 | switch_channel_set_name(tech_pvt->channel, name); |
| 309 | } |
| 310 | |
| 311 | |
| 312 | |
| 313 | void rtc_attach_private(switch_core_session_t *session, private_object_t *tech_pvt, const char *channame) |
| 314 | { |
| 315 | |
| 316 | switch_assert(session != NULL)((session != ((void*)0)) ? (void) (0) : __assert_fail ("session != ((void*)0)" , "mod_rtc.c", 316, __PRETTY_FUNCTION__)); |
| 317 | switch_assert(tech_pvt != NULL)((tech_pvt != ((void*)0)) ? (void) (0) : __assert_fail ("tech_pvt != ((void*)0)" , "mod_rtc.c", 317, __PRETTY_FUNCTION__)); |
| 318 | |
| 319 | switch_core_session_add_stream(session, NULL((void*)0)); |
| 320 | |
| 321 | tech_pvt->session = session; |
| 322 | tech_pvt->channel = switch_core_session_get_channel(session); |
| 323 | switch_core_media_check_dtmf_type(session); |
| 324 | switch_channel_set_cap(tech_pvt->channel, CC_JITTERBUFFER)switch_channel_set_cap_value(tech_pvt->channel, CC_JITTERBUFFER , 1); |
| 325 | switch_channel_set_cap(tech_pvt->channel, CC_FS_RTP)switch_channel_set_cap_value(tech_pvt->channel, CC_FS_RTP, 1); |
| 326 | switch_media_handle_create(&tech_pvt->media_handle, session, &tech_pvt->mparams); |
| 327 | switch_core_session_set_private(session, tech_pvt)switch_core_session_set_private_class(session, tech_pvt, SWITCH_PVT_PRIMARY ); |
| 328 | |
| 329 | if (channame) { |
| 330 | rtc_set_name(tech_pvt, channame); |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | |
| 335 | private_object_t *rtc_new_pvt(switch_core_session_t *session) |
| 336 | { |
| 337 | private_object_t *tech_pvt = (private_object_t *) switch_core_session_alloc(session, sizeof(private_object_t))switch_core_perform_session_alloc(session, sizeof(private_object_t ), "mod_rtc.c", (const char *)__func__, 337); |
| 338 | return tech_pvt; |
| 339 | } |
| 340 | |
| 341 | static switch_call_cause_t rtc_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event, |
| 342 | switch_caller_profile_t *outbound_profile, switch_core_session_t **new_session, |
| 343 | switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause) |
| 344 | { |
| 345 | switch_call_cause_t cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; |
| 346 | switch_core_session_t *nsession = NULL((void*)0); |
| 347 | switch_caller_profile_t *caller_profile = NULL((void*)0); |
| 348 | private_object_t *tech_pvt = NULL((void*)0); |
| 349 | switch_channel_t *nchannel; |
| 350 | const char *hval = NULL((void*)0); |
| 351 | |
| 352 | *new_session = NULL((void*)0); |
| 353 | |
| 354 | |
| 355 | if (!(nsession = switch_core_session_request_uuid(rtc_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, |
| 356 | flags, pool, switch_event_get_header(var_event, "origination_uuid")switch_event_get_header_idx(var_event, "origination_uuid", -1 )))) { |
| 357 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_rtc.c", (const char *)__func__, 357 , ((void*)0), SWITCH_LOG_CRIT, "Error Creating Session\n"); |
| 358 | goto error; |
| 359 | } |
| 360 | |
| 361 | tech_pvt = rtc_new_pvt(nsession); |
| 362 | |
| 363 | nchannel = switch_core_session_get_channel(nsession); |
| 364 | |
| 365 | if (outbound_profile) { |
| 366 | caller_profile = switch_caller_profile_clone(nsession, outbound_profile); |
| 367 | switch_channel_set_caller_profile(nchannel, caller_profile); |
| 368 | } |
| 369 | |
| 370 | if ((hval = switch_event_get_header(var_event, "media_webrtc")switch_event_get_header_idx(var_event, "media_webrtc", -1)) && switch_true(hval)) { |
| 371 | switch_channel_set_variable(nchannel, "rtc_secure_media", SWITCH_RTP_CRYPTO_KEY_80)switch_channel_set_variable_var_check(nchannel, "rtc_secure_media" , "AES_CM_128_HMAC_SHA1_80", SWITCH_TRUE); |
| 372 | } |
| 373 | |
| 374 | if ((hval = switch_event_get_header(var_event, "rtc_secure_media")switch_event_get_header_idx(var_event, "rtc_secure_media", -1 ))) { |
| 375 | switch_channel_set_variable(nchannel, "rtc_secure_media", hval)switch_channel_set_variable_var_check(nchannel, "rtc_secure_media" , hval, SWITCH_TRUE); |
| 376 | } |
| 377 | |
| 378 | rtc_attach_private(nsession, tech_pvt, NULL((void*)0)); |
| 379 | |
| 380 | |
| 381 | if (switch_channel_get_state(nchannel) == CS_NEW) { |
| 382 | switch_channel_set_state(nchannel, CS_INIT)switch_channel_perform_set_state(nchannel, "mod_rtc.c", (const char *)__func__, 382, CS_INIT); |
| 383 | } |
| 384 | |
| 385 | tech_pvt->caller_profile = caller_profile; |
| 386 | *new_session = nsession; |
| 387 | cause = SWITCH_CAUSE_SUCCESS; |
| 388 | |
| 389 | |
| 390 | if (session) { |
| 391 | switch_ivr_transfer_variable(session, nsession, "rtc_video_fmtp"); |
| 392 | } |
| 393 | |
| 394 | goto done; |
| 395 | |
| 396 | error: |
| 397 | |
| 398 | if (nsession) { |
| 399 | switch_core_session_destroy(&nsession)switch_core_session_perform_destroy(&nsession, "mod_rtc.c" , (const char *)__func__, 399); |
| 400 | } |
| 401 | |
| 402 | if (pool) { |
| 403 | *pool = NULL((void*)0); |
| 404 | } |
| 405 | |
| 406 | done: |
| 407 | |
| 408 | return cause; |
| 409 | } |
| 410 | |
| 411 | static int rtc_recover_callback(switch_core_session_t *session) |
| 412 | { |
| 413 | private_object_t *tech_pvt = rtc_new_pvt(session); |
| 414 | rtc_attach_private(session, tech_pvt, NULL((void*)0)); |
| 415 | |
| 416 | return 1; |
| 417 | } |
| 418 | |
| 419 | SWITCH_MODULE_LOAD_FUNCTION(mod_rtc_load)switch_status_t mod_rtc_load (switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) |
| 420 | { |
| 421 | memset(&mod_rtc_globals, 0, sizeof(mod_rtc_globals)); |
| 422 | mod_rtc_globals.pool = pool; |
| 423 | switch_mutex_init(&mod_rtc_globals.mutex, SWITCH_MUTEX_NESTED0x1, mod_rtc_globals.pool); |
| 424 | |
| 425 | switch_mutex_lock(mod_rtc_globals.mutex); |
| 426 | mod_rtc_globals.running = 1; |
| 427 | switch_mutex_unlock(mod_rtc_globals.mutex); |
| 428 | |
| 429 | /* connect my internal structure to the blank pointer passed to me */ |
| 430 | *module_interface = switch_loadable_module_create_module_interface(pool, modname); |
| 431 | |
| 432 | rtc_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE); |
| 433 | rtc_endpoint_interface->interface_name = "rtc"; |
| 434 | rtc_endpoint_interface->io_routines = &rtc_io_routines; |
| 435 | rtc_endpoint_interface->state_handler = &rtc_event_handlers; |
| 436 | rtc_endpoint_interface->recover_callback = rtc_recover_callback; |
| 437 | |
| 438 | /* indicate that the module should continue to be loaded */ |
| 439 | return SWITCH_STATUS_SUCCESS; |
| 440 | } |
| 441 | |
| 442 | SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_rtc_shutdown)switch_status_t mod_rtc_shutdown (void) |
| 443 | { |
| 444 | switch_mutex_lock(mod_rtc_globals.mutex); |
| 445 | if (mod_rtc_globals.running == 1) { |
| 446 | mod_rtc_globals.running = 0; |
| 447 | } |
| 448 | switch_mutex_unlock(mod_rtc_globals.mutex); |
| 449 | |
| 450 | return SWITCH_STATUS_SUCCESS; |
| 451 | } |
| 452 | |
| 453 | /* For Emacs: |
| 454 | * Local Variables: |
| 455 | * mode:c |
| 456 | * indent-tabs-mode:t |
| 457 | * tab-width:4 |
| 458 | * c-basic-offset:4 |
| 459 | * End: |
| 460 | * For VIM: |
| 461 | * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: |
| 462 | */ |
| 463 |