]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-9543 #resolve [Add pre-exec state change hooks to core]
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 19 Sep 2016 21:35:16 +0000 (16:35 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 20 Sep 2016 15:57:45 +0000 (10:57 -0500)
src/include/switch_types.h
src/switch_core_state_machine.c

index 707ede43ac43db3ad6b2f479d5bcf5ee01fd54b7..cc8539085e6a853efcafa3d846280c3a6a0ee8a2 100644 (file)
@@ -2149,7 +2149,8 @@ typedef enum {
 } switch_session_ctl_t;
 
 typedef enum {
-       SSH_FLAG_STICKY = (1 << 0)
+       SSH_FLAG_STICKY = (1 << 0),
+       SSH_FLAG_PRE_EXEC = (1 << 1)
 } switch_state_handler_flag_t;
 
 #ifdef WIN32
index 9bbf6e67146265bd1b65d7f22a9f17750f312f87..a9c3e2321635cbd31d505921d1a93632f19c8f8f 100644 (file)
@@ -433,10 +433,48 @@ void switch_core_state_machine_init(switch_memory_pool_t *pool)
                }                                                                                                                               \
                switch_core_session_request_video_refresh(session);                             \
                switch_core_media_gen_key_frame(session);                                               \
-               if (!driver_state_handler->on_##__STATE || (driver_state_handler->on_##__STATE(session) == SWITCH_STATUS_SUCCESS \
-                                                                                                       )) {                            \
+               proceed = 1;                                                                                                    \
+               while (do_extra_handlers && (application_state_handler = switch_channel_get_state_handler(session->channel, index++)) != 0) { \
+                       if (!switch_test_flag(application_state_handler, SSH_FLAG_PRE_EXEC)) {\
+                               continue;                                                                                               \
+                       }                                                                                                                       \
+                       if (!application_state_handler->on_##__STATE                            \
+                               || (application_state_handler->on_##__STATE                             \
+                                       && application_state_handler->on_##__STATE(session) == SWITCH_STATUS_SUCCESS \
+                                       )) {                                                                                            \
+                               proceed++;                                                                                              \
+                               continue;                                                                                               \
+                       } else {                                                                                                        \
+                               proceed = 0;                                                                                    \
+                               break;                                                                                                  \
+                       }                                                                                                                       \
+               }                                                                                                                               \
+               index = 0;                                                                                                              \
+               if (!proceed) global_proceed = 0;                                                               \
+               proceed = 1;                                                                                                    \
+               while (do_extra_handlers && proceed && (application_state_handler = switch_core_get_state_handler(index++)) != 0) { \
+                       if (!switch_test_flag(application_state_handler, SSH_FLAG_PRE_EXEC)) { \
+                               continue;                                                                                               \
+                       }                                                                                                                       \
+                       if (!application_state_handler->on_##__STATE ||                         \
+                               (application_state_handler->on_##__STATE &&                             \
+                                application_state_handler->on_##__STATE(session) == SWITCH_STATUS_SUCCESS \
+                                )) {                                                                                                   \
+                               proceed++;                                                                                              \
+                               continue;                                                                                               \
+                       } else {                                                                                                        \
+                               proceed = 0;                                                                                    \
+                               break;                                                                                                  \
+                       }                                                                                                                       \
+               }                                                                                                                               \
+               index = 0;                                                                                                              \
+               if (!proceed) global_proceed = 0;                                                               \
+               if (!driver_state_handler->on_##__STATE || (driver_state_handler->on_##__STATE(session) == SWITCH_STATUS_SUCCESS )) { \
                        while (do_extra_handlers && (application_state_handler = switch_channel_get_state_handler(session->channel, index++)) != 0) { \
-                               if (!application_state_handler || !application_state_handler->on_##__STATE \
+                               if (switch_test_flag(application_state_handler, SSH_FLAG_PRE_EXEC)) { \
+                                       continue;                                                                                       \
+                               }                                                                                                               \
+                               if (!application_state_handler->on_##__STATE                    \
                                        || (application_state_handler->on_##__STATE                     \
                                                && application_state_handler->on_##__STATE(session) == SWITCH_STATUS_SUCCESS \
                                                )) {                                                                                    \
@@ -451,7 +489,10 @@ void switch_core_state_machine_init(switch_memory_pool_t *pool)
                        if (!proceed) global_proceed = 0;                                                       \
                        proceed = 1;                                                                                            \
                        while (do_extra_handlers && proceed && (application_state_handler = switch_core_get_state_handler(index++)) != 0) { \
-                               if (!application_state_handler || !application_state_handler->on_##__STATE || \
+                               if (switch_test_flag(application_state_handler, SSH_FLAG_PRE_EXEC)) { \
+                                       continue;                                                                                       \
+                               }                                                                                                               \
+                               if (!application_state_handler->on_##__STATE || \
                                        (application_state_handler->on_##__STATE &&                     \
                                         application_state_handler->on_##__STATE(session) == SWITCH_STATUS_SUCCESS \
                                         )) {                                                                                           \