confbridge_manager.c File Reference

Confbridge manager events for stasis messages. More...

#include "asterisk.h"
#include "asterisk/channel.h"
#include "asterisk/bridge.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/stasis_bridges.h"
#include "asterisk/manager.h"
#include "asterisk/stasis_message_router.h"
#include "include/confbridge.h"

Include dependency graph for confbridge_manager.c:

Go to the source code of this file.

Functions

static void confbridge_end_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void confbridge_join_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void confbridge_leave_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void confbridge_mute_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void confbridge_publish_manager_event (struct stasis_message *message, const char *event, struct ast_str *extra_text)
static void confbridge_start_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void confbridge_start_record_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void confbridge_stop_record_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void confbridge_talking_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void confbridge_unmute_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message)
static int get_admin_header (struct ast_str **extra_text, struct stasis_message *message)
int manager_confbridge_init (void)
 register stasis message routers to handle manager events for confbridge messages
void manager_confbridge_shutdown (void)
 unregister stasis message routers to handle manager events for confbridge messages
 STASIS_MESSAGE_TYPE_DEFN (confbridge_talking_type)
 STASIS_MESSAGE_TYPE_DEFN (confbridge_unmute_type)
 STASIS_MESSAGE_TYPE_DEFN (confbridge_mute_type)
 STASIS_MESSAGE_TYPE_DEFN (confbridge_stop_record_type)
 STASIS_MESSAGE_TYPE_DEFN (confbridge_start_record_type)
 STASIS_MESSAGE_TYPE_DEFN (confbridge_leave_type)
 STASIS_MESSAGE_TYPE_DEFN (confbridge_join_type)
 STASIS_MESSAGE_TYPE_DEFN (confbridge_end_type)
 STASIS_MESSAGE_TYPE_DEFN (confbridge_start_type)

Variables

static struct
stasis_message_router
bridge_state_router
static struct
stasis_message_router
channel_state_router


Detailed Description

Confbridge manager events for stasis messages.

Author:
Jonathan Rose <jrose@digium.com>

Definition in file confbridge_manager.c.


Function Documentation

static void confbridge_end_cb ( void *  data,
struct stasis_subscription sub,
struct stasis_message message 
) [static]

Definition at line 279 of file confbridge_manager.c.

References confbridge_publish_manager_event(), and NULL.

Referenced by manager_confbridge_init().

00281 {
00282    confbridge_publish_manager_event(message, "ConfbridgeEnd", NULL);
00283 }

static void confbridge_join_cb ( void *  data,
struct stasis_subscription sub,
struct stasis_message message 
) [static]

Definition at line 296 of file confbridge_manager.c.

References ast_free, confbridge_publish_manager_event(), get_admin_header(), and NULL.

Referenced by manager_confbridge_init().

00298 {
00299    struct ast_str *extra_text = NULL;
00300 
00301    if (!get_admin_header(&extra_text, message)) {
00302       confbridge_publish_manager_event(message, "ConfbridgeJoin", extra_text);
00303    }
00304    ast_free(extra_text);
00305 }

static void confbridge_leave_cb ( void *  data,
struct stasis_subscription sub,
struct stasis_message message 
) [static]

Definition at line 285 of file confbridge_manager.c.

References ast_free, confbridge_publish_manager_event(), get_admin_header(), and NULL.

Referenced by manager_confbridge_init().

00287 {
00288    struct ast_str *extra_text = NULL;
00289 
00290    if (!get_admin_header(&extra_text, message)) {
00291       confbridge_publish_manager_event(message, "ConfbridgeLeave", extra_text);
00292    }
00293    ast_free(extra_text);
00294 }

static void confbridge_mute_cb ( void *  data,
struct stasis_subscription sub,
struct stasis_message message 
) [static]

Definition at line 319 of file confbridge_manager.c.

References ast_free, confbridge_publish_manager_event(), get_admin_header(), and NULL.

Referenced by manager_confbridge_init().

00321 {
00322    struct ast_str *extra_text = NULL;
00323 
00324    if (!get_admin_header(&extra_text, message)) {
00325       confbridge_publish_manager_event(message, "ConfbridgeMute", extra_text);
00326    }
00327    ast_free(extra_text);
00328 }

static void confbridge_publish_manager_event ( struct stasis_message message,
const char *  event,
struct ast_str extra_text 
) [static]

Definition at line 225 of file confbridge_manager.c.

References ast_assert, ast_free, ast_json_object_get(), ast_json_string_get(), ast_manager_build_bridge_state_string(), ast_manager_build_channel_state_string(), ast_str_buffer(), ast_bridge_blob::blob, ast_bridge_blob::bridge, ast_bridge_blob::channel, EVENT_FLAG_CALL, manager_event, NULL, RAII_VAR, S_COR, and stasis_message_data().

Referenced by confbridge_end_cb(), confbridge_join_cb(), confbridge_leave_cb(), confbridge_mute_cb(), confbridge_start_cb(), confbridge_start_record_cb(), confbridge_stop_record_cb(), confbridge_talking_cb(), and confbridge_unmute_cb().

00229 {
00230    struct ast_bridge_blob *blob = stasis_message_data(message);
00231    const char *conference_name;
00232    RAII_VAR(struct ast_str *, bridge_text, NULL, ast_free);
00233    RAII_VAR(struct ast_str *, channel_text, NULL, ast_free);
00234 
00235    ast_assert(blob != NULL);
00236    ast_assert(event != NULL);
00237 
00238    bridge_text = ast_manager_build_bridge_state_string(blob->bridge);
00239    if (!bridge_text) {
00240       return;
00241    }
00242 
00243    conference_name = ast_json_string_get(ast_json_object_get(blob->blob, "conference"));
00244    ast_assert(conference_name != NULL);
00245 
00246    if (blob->channel) {
00247       channel_text = ast_manager_build_channel_state_string(blob->channel);
00248    }
00249 
00250    manager_event(EVENT_FLAG_CALL, event,
00251       "Conference: %s\r\n"
00252       "%s"
00253       "%s"
00254       "%s",
00255       conference_name,
00256       ast_str_buffer(bridge_text),
00257       S_COR(channel_text, ast_str_buffer(channel_text), ""),
00258       S_COR(extra_text, ast_str_buffer(extra_text), ""));
00259 }

static void confbridge_start_cb ( void *  data,
struct stasis_subscription sub,
struct stasis_message message 
) [static]

Definition at line 273 of file confbridge_manager.c.

References confbridge_publish_manager_event(), and NULL.

Referenced by manager_confbridge_init().

00275 {
00276    confbridge_publish_manager_event(message, "ConfbridgeStart", NULL);
00277 }

static void confbridge_start_record_cb ( void *  data,
struct stasis_subscription sub,
struct stasis_message message 
) [static]

Definition at line 307 of file confbridge_manager.c.

References confbridge_publish_manager_event(), and NULL.

Referenced by manager_confbridge_init().

00309 {
00310    confbridge_publish_manager_event(message, "ConfbridgeRecord", NULL);
00311 }

static void confbridge_stop_record_cb ( void *  data,
struct stasis_subscription sub,
struct stasis_message message 
) [static]

Definition at line 313 of file confbridge_manager.c.

References confbridge_publish_manager_event(), and NULL.

Referenced by manager_confbridge_init().

00315 {
00316    confbridge_publish_manager_event(message, "ConfbridgeStopRecord", NULL);
00317 }

static void confbridge_talking_cb ( void *  data,
struct stasis_subscription sub,
struct stasis_message message 
) [static]

Definition at line 341 of file confbridge_manager.c.

References ast_free, ast_json_object_get(), ast_json_string_get(), ast_str_append_event_header(), ast_bridge_blob::blob, confbridge_publish_manager_event(), get_admin_header(), NULL, RAII_VAR, and stasis_message_data().

Referenced by manager_confbridge_init().

00343 {
00344    RAII_VAR(struct ast_str *, extra_text, NULL, ast_free);
00345    const struct ast_bridge_blob *blob = stasis_message_data(message);
00346    const char *talking_status = ast_json_string_get(ast_json_object_get(blob->blob, "talking_status"));
00347    if (!talking_status) {
00348       return;
00349    }
00350 
00351    ast_str_append_event_header(&extra_text, "TalkingStatus", talking_status);
00352    if (!extra_text) {
00353       return;
00354    }
00355 
00356    if (!get_admin_header(&extra_text, message)) {
00357       confbridge_publish_manager_event(message, "ConfbridgeTalking", extra_text);
00358    }
00359 }

static void confbridge_unmute_cb ( void *  data,
struct stasis_subscription sub,
struct stasis_message message 
) [static]

Definition at line 330 of file confbridge_manager.c.

References ast_free, confbridge_publish_manager_event(), get_admin_header(), and NULL.

Referenced by manager_confbridge_init().

00332 {
00333    struct ast_str *extra_text = NULL;
00334 
00335    if (!get_admin_header(&extra_text, message)) {
00336       confbridge_publish_manager_event(message, "ConfbridgeUnmute", extra_text);
00337    }
00338    ast_free(extra_text);
00339 }

static int get_admin_header ( struct ast_str **  extra_text,
struct stasis_message message 
) [static]

Definition at line 261 of file confbridge_manager.c.

References ast_json_is_true(), ast_json_object_get(), ast_str_append_event_header(), ast_bridge_blob::blob, S_COR, and stasis_message_data().

Referenced by confbridge_join_cb(), confbridge_leave_cb(), confbridge_mute_cb(), confbridge_talking_cb(), and confbridge_unmute_cb().

00262 {
00263    const struct ast_bridge_blob *blob = stasis_message_data(message);
00264    const struct ast_json *admin = ast_json_object_get(blob->blob, "admin");
00265    if (!admin) {
00266       return -1;
00267    }
00268 
00269    return ast_str_append_event_header(extra_text, "Admin",
00270       S_COR(ast_json_is_true(admin), "Yes", "No"));
00271 }

int manager_confbridge_init ( void   ) 

register stasis message routers to handle manager events for confbridge messages

Since:
12.0
Return values:
0 success
non-zero failure

Definition at line 393 of file confbridge_manager.c.

References ast_bridge_topic_all_cached(), ast_channel_topic_all_cached(), confbridge_end_cb(), confbridge_end_type(), confbridge_join_cb(), confbridge_join_type(), confbridge_leave_cb(), confbridge_leave_type(), confbridge_mute_cb(), confbridge_mute_type(), confbridge_start_cb(), confbridge_start_record_cb(), confbridge_start_record_type(), confbridge_start_type(), confbridge_stop_record_cb(), confbridge_stop_record_type(), confbridge_talking_cb(), confbridge_talking_type(), confbridge_unmute_cb(), confbridge_unmute_type(), manager_confbridge_shutdown(), NULL, stasis_message_router_add(), stasis_message_router_create(), and STASIS_MESSAGE_TYPE_INIT.

Referenced by load_module().

00394 {
00395    STASIS_MESSAGE_TYPE_INIT(confbridge_start_type);
00396    STASIS_MESSAGE_TYPE_INIT(confbridge_end_type);
00397    STASIS_MESSAGE_TYPE_INIT(confbridge_join_type);
00398    STASIS_MESSAGE_TYPE_INIT(confbridge_leave_type);
00399    STASIS_MESSAGE_TYPE_INIT(confbridge_start_record_type);
00400    STASIS_MESSAGE_TYPE_INIT(confbridge_stop_record_type);
00401    STASIS_MESSAGE_TYPE_INIT(confbridge_mute_type);
00402    STASIS_MESSAGE_TYPE_INIT(confbridge_unmute_type);
00403    STASIS_MESSAGE_TYPE_INIT(confbridge_talking_type);
00404 
00405    bridge_state_router = stasis_message_router_create(
00406       ast_bridge_topic_all_cached());
00407 
00408    if (!bridge_state_router) {
00409       return -1;
00410    }
00411 
00412    if (stasis_message_router_add(bridge_state_router,
00413          confbridge_start_type(),
00414          confbridge_start_cb,
00415          NULL)) {
00416       manager_confbridge_shutdown();
00417       return -1;
00418    }
00419    if (stasis_message_router_add(bridge_state_router,
00420          confbridge_end_type(),
00421          confbridge_end_cb,
00422          NULL)) {
00423       manager_confbridge_shutdown();
00424       return -1;
00425    }
00426    if (stasis_message_router_add(bridge_state_router,
00427          confbridge_join_type(),
00428          confbridge_join_cb,
00429          NULL)) {
00430       manager_confbridge_shutdown();
00431       return -1;
00432    }
00433    if (stasis_message_router_add(bridge_state_router,
00434          confbridge_leave_type(),
00435          confbridge_leave_cb,
00436          NULL)) {
00437       manager_confbridge_shutdown();
00438       return -1;
00439    }
00440    if (stasis_message_router_add(bridge_state_router,
00441          confbridge_start_record_type(),
00442          confbridge_start_record_cb,
00443          NULL)) {
00444       manager_confbridge_shutdown();
00445       return -1;
00446    }
00447    if (stasis_message_router_add(bridge_state_router,
00448          confbridge_stop_record_type(),
00449          confbridge_stop_record_cb,
00450          NULL)) {
00451       manager_confbridge_shutdown();
00452       return -1;
00453    }
00454    if (stasis_message_router_add(bridge_state_router,
00455          confbridge_mute_type(),
00456          confbridge_mute_cb,
00457          NULL)) {
00458       manager_confbridge_shutdown();
00459       return -1;
00460    }
00461    if (stasis_message_router_add(bridge_state_router,
00462          confbridge_unmute_type(),
00463          confbridge_unmute_cb,
00464          NULL)) {
00465       manager_confbridge_shutdown();
00466       return -1;
00467    }
00468    if (stasis_message_router_add(bridge_state_router,
00469          confbridge_talking_type(),
00470          confbridge_talking_cb,
00471          NULL)) {
00472       manager_confbridge_shutdown();
00473       return -1;
00474    }
00475 
00476    channel_state_router = stasis_message_router_create(
00477       ast_channel_topic_all_cached());
00478 
00479    if (!channel_state_router) {
00480       manager_confbridge_shutdown();
00481       return -1;
00482    }
00483 
00484    if (stasis_message_router_add(channel_state_router,
00485          confbridge_start_type(),
00486          confbridge_start_cb,
00487          NULL)) {
00488       manager_confbridge_shutdown();
00489       return -1;
00490    }
00491    if (stasis_message_router_add(channel_state_router,
00492          confbridge_end_type(),
00493          confbridge_end_cb,
00494          NULL)) {
00495       manager_confbridge_shutdown();
00496       return -1;
00497    }
00498    if (stasis_message_router_add(channel_state_router,
00499          confbridge_join_type(),
00500          confbridge_join_cb,
00501          NULL)) {
00502       manager_confbridge_shutdown();
00503       return -1;
00504    }
00505    if (stasis_message_router_add(channel_state_router,
00506          confbridge_leave_type(),
00507          confbridge_leave_cb,
00508          NULL)) {
00509       manager_confbridge_shutdown();
00510       return -1;
00511    }
00512    if (stasis_message_router_add(channel_state_router,
00513          confbridge_start_record_type(),
00514          confbridge_start_record_cb,
00515          NULL)) {
00516       manager_confbridge_shutdown();
00517       return -1;
00518    }
00519    if (stasis_message_router_add(channel_state_router,
00520          confbridge_stop_record_type(),
00521          confbridge_stop_record_cb,
00522          NULL)) {
00523       manager_confbridge_shutdown();
00524       return -1;
00525    }
00526    if (stasis_message_router_add(channel_state_router,
00527          confbridge_mute_type(),
00528          confbridge_mute_cb,
00529          NULL)) {
00530       manager_confbridge_shutdown();
00531       return -1;
00532    }
00533    if (stasis_message_router_add(channel_state_router,
00534          confbridge_unmute_type(),
00535          confbridge_unmute_cb,
00536          NULL)) {
00537       manager_confbridge_shutdown();
00538       return -1;
00539    }
00540    if (stasis_message_router_add(channel_state_router,
00541          confbridge_talking_type(),
00542          confbridge_talking_cb,
00543          NULL)) {
00544       manager_confbridge_shutdown();
00545       return -1;
00546    }
00547 
00548    return 0;
00549 }

void manager_confbridge_shutdown ( void   ) 

STASIS_MESSAGE_TYPE_DEFN ( confbridge_talking_type   ) 

STASIS_MESSAGE_TYPE_DEFN ( confbridge_unmute_type   ) 

STASIS_MESSAGE_TYPE_DEFN ( confbridge_mute_type   ) 

STASIS_MESSAGE_TYPE_DEFN ( confbridge_stop_record_type   ) 

STASIS_MESSAGE_TYPE_DEFN ( confbridge_start_record_type   ) 

STASIS_MESSAGE_TYPE_DEFN ( confbridge_leave_type   ) 

STASIS_MESSAGE_TYPE_DEFN ( confbridge_join_type   ) 

STASIS_MESSAGE_TYPE_DEFN ( confbridge_end_type   ) 

STASIS_MESSAGE_TYPE_DEFN ( confbridge_start_type   ) 


Variable Documentation

Definition at line 222 of file confbridge_manager.c.

Definition at line 223 of file confbridge_manager.c.


Generated on Thu Apr 16 06:30:24 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6