[asterisk-commits] kmoore: branch kmoore/microfilm r397150 - in /team/kmoore/microfilm: include/...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Aug 20 12:07:52 CDT 2013
Author: kmoore
Date: Tue Aug 20 12:07:51 2013
New Revision: 397150
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=397150
Log:
Rip out the peer field
Modified:
team/kmoore/microfilm/include/asterisk/cel.h
team/kmoore/microfilm/main/cel.c
team/kmoore/microfilm/tests/test_cel.c
Modified: team/kmoore/microfilm/include/asterisk/cel.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/microfilm/include/asterisk/cel.h?view=diff&rev=397150&r1=397149&r2=397150
==============================================================================
--- team/kmoore/microfilm/include/asterisk/cel.h (original)
+++ team/kmoore/microfilm/include/asterisk/cel.h Tue Aug 20 12:07:51 2013
@@ -273,7 +273,6 @@
* \param userdefevname Custom name for the call event. (optional)
* \param extra An event-specific opaque JSON blob to be rendered and placed
* in the "CEL_EXTRA" information element of the call event. (optional)
- * \param peer_name The peer name to be placed into the event. (optional)
*
* \since 12
*
@@ -282,7 +281,7 @@
*/
struct ast_event *ast_cel_create_event(struct ast_channel_snapshot *snapshot,
enum ast_cel_event_type event_type, const char *userdefevname,
- struct ast_json *extra, const char *peer_name);
+ struct ast_json *extra);
/*!
* \brief CEL backend callback
Modified: team/kmoore/microfilm/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/microfilm/main/cel.c?view=diff&rev=397150&r1=397149&r2=397150
==============================================================================
--- team/kmoore/microfilm/main/cel.c (original)
+++ team/kmoore/microfilm/main/cel.c Tue Aug 20 12:07:51 2013
@@ -585,7 +585,7 @@
static int cel_linkedid_ref(const char *linkedid);
struct ast_event *ast_cel_create_event(struct ast_channel_snapshot *snapshot,
enum ast_cel_event_type event_type, const char *userdefevname,
- struct ast_json *extra, const char *peer_name)
+ struct ast_json *extra)
{
struct timeval eventtime = ast_tvnow();
RAII_VAR(char *, extra_txt, NULL, ast_json_free);
@@ -614,7 +614,7 @@
AST_EVENT_IE_CEL_LINKEDID, AST_EVENT_IE_PLTYPE_STR, snapshot->linkedid,
AST_EVENT_IE_CEL_USERFIELD, AST_EVENT_IE_PLTYPE_STR, snapshot->userfield,
AST_EVENT_IE_CEL_EXTRA, AST_EVENT_IE_PLTYPE_STR, S_OR(extra_txt, ""),
- AST_EVENT_IE_CEL_PEER, AST_EVENT_IE_PLTYPE_STR, S_OR(peer_name, ""),
+ AST_EVENT_IE_CEL_PEER, AST_EVENT_IE_PLTYPE_STR, "",
AST_EVENT_IE_END);
}
@@ -628,11 +628,10 @@
static int cel_report_event(struct ast_channel_snapshot *snapshot,
enum ast_cel_event_type event_type, const char *userdefevname,
- struct ast_json *extra, const char *peer2_name)
+ struct ast_json *extra)
{
struct ast_event *ev;
char *linkedid = ast_strdupa(snapshot->linkedid);
- const char *peer_name = peer2_name;
RAII_VAR(struct cel_config *, cfg, ao2_global_obj_ref(cel_configs), ao2_cleanup);
if (!cfg || !cfg->general) {
@@ -660,7 +659,7 @@
return 0;
}
- ev = ast_cel_create_event(snapshot, event_type, userdefevname, extra, peer_name);
+ ev = ast_cel_create_event(snapshot, event_type, userdefevname, extra);
if (!ev) {
return -1;
}
@@ -693,7 +692,7 @@
* before unreffing the channel we have a refcount of 3, we're done. Unlink and report. */
if (ao2_ref(lid, -1) == 3) {
ast_str_container_remove(linkedids, lid);
- cel_report_event(snapshot, AST_CEL_LINKEDID_END, NULL, NULL, NULL);
+ cel_report_event(snapshot, AST_CEL_LINKEDID_END, NULL, NULL);
}
ao2_ref(lid, -1);
}
@@ -929,13 +928,13 @@
int is_hungup, was_hungup;
if (!new_snapshot) {
- cel_report_event(old_snapshot, AST_CEL_CHANNEL_END, NULL, NULL, NULL);
+ cel_report_event(old_snapshot, AST_CEL_CHANNEL_END, NULL, NULL);
check_retire_linkedid(old_snapshot);
return;
}
if (!old_snapshot) {
- cel_report_event(new_snapshot, AST_CEL_CHANNEL_START, NULL, NULL, NULL);
+ cel_report_event(new_snapshot, AST_CEL_CHANNEL_START, NULL, NULL);
return;
}
@@ -953,12 +952,12 @@
"hangupcause", new_snapshot->hangupcause,
"hangupsource", new_snapshot->hangupsource,
"dialstatus", dialstatus);
- cel_report_event(new_snapshot, AST_CEL_HANGUP, NULL, extra, NULL);
+ cel_report_event(new_snapshot, AST_CEL_HANGUP, NULL, extra);
return;
}
if (old_snapshot->state != new_snapshot->state && new_snapshot->state == AST_STATE_UP) {
- cel_report_event(new_snapshot, AST_CEL_ANSWER, NULL, NULL, NULL);
+ cel_report_event(new_snapshot, AST_CEL_ANSWER, NULL, NULL);
return;
}
}
@@ -991,12 +990,12 @@
/* old snapshot has an application, end it */
if (old_snapshot && !ast_strlen_zero(old_snapshot->appl)) {
- cel_report_event(old_snapshot, AST_CEL_APP_END, NULL, NULL, NULL);
+ cel_report_event(old_snapshot, AST_CEL_APP_END, NULL, NULL);
}
/* new snapshot has an application, start it */
if (new_snapshot && !ast_strlen_zero(new_snapshot->appl)) {
- cel_report_event(new_snapshot, AST_CEL_APP_START, NULL, NULL, NULL);
+ cel_report_event(new_snapshot, AST_CEL_APP_START, NULL, NULL);
}
}
@@ -1075,7 +1074,7 @@
return;
}
- cel_report_event(chan_snapshot, AST_CEL_BRIDGE_ENTER, NULL, extra, NULL);
+ cel_report_event(chan_snapshot, AST_CEL_BRIDGE_ENTER, NULL, extra);
}
static void cel_bridge_leave_cb(
@@ -1097,7 +1096,7 @@
return;
}
- cel_report_event(chan_snapshot, AST_CEL_BRIDGE_EXIT, NULL, extra, NULL);
+ cel_report_event(chan_snapshot, AST_CEL_BRIDGE_EXIT, NULL, extra);
}
static void cel_parking_cb(
@@ -1115,7 +1114,7 @@
"parker_dial_string", parked_payload->parker_dial_string,
"parking_lot", parked_payload->parkinglot);
if (extra) {
- cel_report_event(parked_payload->parkee, AST_CEL_PARK_START, NULL, extra, NULL);
+ cel_report_event(parked_payload->parkee, AST_CEL_PARK_START, NULL, extra);
}
return;
case PARKED_CALL_TIMEOUT:
@@ -1137,7 +1136,7 @@
extra = ast_json_pack("{s: s}", "reason", reason);
if (extra) {
- cel_report_event(parked_payload->parkee, AST_CEL_PARK_END, NULL, extra, NULL);
+ cel_report_event(parked_payload->parkee, AST_CEL_PARK_END, NULL, extra);
}
}
@@ -1169,7 +1168,7 @@
extra = ast_json_pack("{s: s}", "forward", get_blob_variable(blob, "forward"));
if (extra) {
- cel_report_event(caller, AST_CEL_FORWARD, NULL, extra, NULL);
+ cel_report_event(caller, AST_CEL_FORWARD, NULL, extra);
}
}
@@ -1194,7 +1193,7 @@
{
const char *event = ast_json_string_get(ast_json_object_get(event_details, "event"));
struct ast_json *extra = ast_json_object_get(event_details, "extra");
- cel_report_event(obj->snapshot, event_type, event, extra, NULL);
+ cel_report_event(obj->snapshot, event_type, event, extra);
break;
}
default:
@@ -1232,7 +1231,7 @@
"bridge_id", bridge_snapshot->uniqueid);
if (extra) {
- cel_report_event(chan_snapshot, AST_CEL_BLINDTRANSFER, NULL, extra, NULL);
+ cel_report_event(chan_snapshot, AST_CEL_BLINDTRANSFER, NULL, extra);
}
}
@@ -1286,7 +1285,7 @@
}
break;
}
- cel_report_event(channel1, AST_CEL_ATTENDEDTRANSFER, NULL, extra, NULL);
+ cel_report_event(channel1, AST_CEL_ATTENDEDTRANSFER, NULL, extra);
}
static void cel_pickup_cb(
@@ -1297,12 +1296,18 @@
struct ast_multi_channel_blob *obj = stasis_message_data(message);
struct ast_channel_snapshot *channel = ast_multi_channel_blob_get_channel(obj, "channel");
struct ast_channel_snapshot *target = ast_multi_channel_blob_get_channel(obj, "target");
+ RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
if (!channel || !target) {
return;
}
- cel_report_event(target, AST_CEL_PICKUP, NULL, NULL, channel->name);
+ extra = ast_json_pack("{s: s}", "pickup_channel", channel->name);
+ if (!extra) {
+ return;
+ }
+
+ cel_report_event(target, AST_CEL_PICKUP, NULL, extra);
}
static void cel_local_cb(
@@ -1313,12 +1318,18 @@
struct ast_multi_channel_blob *obj = stasis_message_data(message);
struct ast_channel_snapshot *localone = ast_multi_channel_blob_get_channel(obj, "1");
struct ast_channel_snapshot *localtwo = ast_multi_channel_blob_get_channel(obj, "2");
+ RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
if (!localone || !localtwo) {
return;
}
- cel_report_event(localone, AST_CEL_LOCAL_OPTIMIZE, NULL, NULL, localtwo->name);
+ extra = ast_json_pack("{s: s}", "local_two", localtwo->name);
+ if (!extra) {
+ return;
+ }
+
+ cel_report_event(localone, AST_CEL_LOCAL_OPTIMIZE, NULL, extra);
}
static void ast_cel_engine_term(void)
Modified: team/kmoore/microfilm/tests/test_cel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/microfilm/tests/test_cel.c?view=diff&rev=397150&r1=397149&r2=397150
==============================================================================
--- team/kmoore/microfilm/tests/test_cel.c (original)
+++ team/kmoore/microfilm/tests/test_cel.c Tue Aug 20 12:07:51 2013
@@ -90,14 +90,14 @@
while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
}
-#define APPEND_EVENT(chan, ev_type, userevent, extra, peer) do { \
- if (append_expected_event(chan, ev_type, userevent, extra, peer)) { \
+#define APPEND_EVENT(chan, ev_type, userevent, extra) do { \
+ if (append_expected_event(chan, ev_type, userevent, extra)) { \
return AST_TEST_FAIL; \
} \
} while (0)
-#define APPEND_EVENT_SNAPSHOT(snapshot, ev_type, userevent, extra, peer) do { \
- if (append_expected_event_snapshot(snapshot, ev_type, userevent, extra, peer)) { \
+#define APPEND_EVENT_SNAPSHOT(snapshot, ev_type, userevent, extra) do { \
+ if (append_expected_event_snapshot(snapshot, ev_type, userevent, extra)) { \
return AST_TEST_FAIL; \
} \
} while (0)
@@ -118,14 +118,14 @@
RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
extra = ast_json_pack("{s: s}", "bridge_id", bridge->uniqueid); \
ast_test_validate(test, extra != NULL); \
- APPEND_EVENT(channel, AST_CEL_BRIDGE_EXIT, NULL, extra, NULL); \
+ APPEND_EVENT(channel, AST_CEL_BRIDGE_EXIT, NULL, extra); \
} while (0)
#define CONF_EXIT_SNAPSHOT(channel, bridge) do { \
RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
extra = ast_json_pack("{s: s}", "bridge_id", bridge->uniqueid); \
ast_test_validate(test, extra != NULL); \
- APPEND_EVENT_SNAPSHOT(channel, AST_CEL_BRIDGE_EXIT, NULL, extra, NULL); \
+ APPEND_EVENT_SNAPSHOT(channel, AST_CEL_BRIDGE_EXIT, NULL, extra); \
} while (0)
#define CONF_ENTER(channel, bridge) do { \
@@ -139,7 +139,7 @@
RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
extra = ast_json_pack("{s: s}", "bridge_id", bridge->uniqueid); \
ast_test_validate(test, extra != NULL); \
- APPEND_EVENT(channel, AST_CEL_BRIDGE_ENTER, NULL, extra, NULL); \
+ APPEND_EVENT(channel, AST_CEL_BRIDGE_ENTER, NULL, extra); \
} while (0)
#define BLINDTRANSFER_EVENT(channel, bridge, extension, context) do { \
@@ -149,7 +149,7 @@
"context", context, \
"bridge_id", bridge->uniqueid); \
ast_test_validate(test, extra != NULL); \
- APPEND_EVENT(channel, AST_CEL_BLINDTRANSFER, NULL, extra, NULL); \
+ APPEND_EVENT(channel, AST_CEL_BLINDTRANSFER, NULL, extra); \
} while (0)
#define ATTENDEDTRANSFER_BRIDGE(channel1, bridge1, channel2, bridge2) do { \
@@ -159,7 +159,7 @@
"channel2_name", ast_channel_name(channel2), \
"bridge2_id", bridge2->uniqueid); \
ast_test_validate(test, extra != NULL); \
- APPEND_EVENT(channel1, AST_CEL_ATTENDEDTRANSFER, NULL, extra, NULL); \
+ APPEND_EVENT(channel1, AST_CEL_ATTENDEDTRANSFER, NULL, extra); \
} while (0)
/*! \brief Alice's Caller ID */
@@ -177,25 +177,25 @@
/*! \brief Create a \ref test_cel_chan_tech for Alice. */
#define CREATE_ALICE_CHANNEL(channel_var, caller_id) do { \
(channel_var) = ast_channel_alloc(0, AST_STATE_DOWN, (caller_id)->id.number.str, (caller_id)->id.name.str, "100", "100", "default", NULL, 0, CHANNEL_TECH_NAME "/Alice"); \
- APPEND_EVENT(channel_var, AST_CEL_CHANNEL_START, NULL, NULL, NULL); \
+ APPEND_EVENT(channel_var, AST_CEL_CHANNEL_START, NULL, NULL); \
} while (0)
/*! \brief Create a \ref test_cel_chan_tech for Bob. */
#define CREATE_BOB_CHANNEL(channel_var, caller_id) do { \
(channel_var) = ast_channel_alloc(0, AST_STATE_DOWN, (caller_id)->id.number.str, (caller_id)->id.name.str, "200", "200", "default", NULL, 0, CHANNEL_TECH_NAME "/Bob"); \
- APPEND_EVENT(channel_var, AST_CEL_CHANNEL_START, NULL, NULL, NULL); \
+ APPEND_EVENT(channel_var, AST_CEL_CHANNEL_START, NULL, NULL); \
} while (0)
/*! \brief Create a \ref test_cel_chan_tech for Charlie. */
#define CREATE_CHARLIE_CHANNEL(channel_var, caller_id) do { \
(channel_var) = ast_channel_alloc(0, AST_STATE_DOWN, (caller_id)->id.number.str, (caller_id)->id.name.str, "300", "300", "default", NULL, 0, CHANNEL_TECH_NAME "/Charlie"); \
- APPEND_EVENT(channel_var, AST_CEL_CHANNEL_START, NULL, NULL, NULL); \
+ APPEND_EVENT(channel_var, AST_CEL_CHANNEL_START, NULL, NULL); \
} while (0)
/*! \brief Create a \ref test_cel_chan_tech for David. */
#define CREATE_DAVID_CHANNEL(channel_var, caller_id) do { \
(channel_var) = ast_channel_alloc(0, AST_STATE_DOWN, (caller_id)->id.number.str, (caller_id)->id.name.str, "400", "400", "default", NULL, 0, CHANNEL_TECH_NAME "/David"); \
- APPEND_EVENT(channel_var, AST_CEL_CHANNEL_START, NULL, NULL, NULL); \
+ APPEND_EVENT(channel_var, AST_CEL_CHANNEL_START, NULL, NULL); \
} while (0)
/*! \brief Emulate a channel entering into an application */
@@ -215,7 +215,7 @@
#define ANSWER_NO_APP(chan) do { \
ast_setstate(chan, AST_STATE_UP); \
- APPEND_EVENT(chan, AST_CEL_ANSWER, NULL, NULL, NULL); \
+ APPEND_EVENT(chan, AST_CEL_ANSWER, NULL, NULL); \
} while (0)
/*! \brief Hang up a test channel safely */
@@ -224,7 +224,7 @@
ao2_ref(channel, +1); \
ast_hangup((channel)); \
HANGUP_EVENT(channel, cause, dialstatus); \
- APPEND_EVENT(channel, AST_CEL_CHANNEL_END, NULL, NULL, NULL); \
+ APPEND_EVENT(channel, AST_CEL_CHANNEL_END, NULL, NULL); \
stasis_topic_wait(ast_channel_topic_all_cached()); \
ao2_cleanup(stasis_cache_get(ast_channel_cache(), \
ast_channel_snapshot_type(), ast_channel_uniqueid(channel))); \
@@ -239,7 +239,7 @@
"hangupsource", "", \
"dialstatus", dialstatus); \
ast_test_validate(test, extra != NULL); \
- APPEND_EVENT(channel, AST_CEL_HANGUP, NULL, extra, NULL); \
+ APPEND_EVENT(channel, AST_CEL_HANGUP, NULL, extra); \
} while (0)
static void mid_test_sync(void);
@@ -248,13 +248,13 @@
struct ast_channel *chan,
enum ast_cel_event_type type,
const char *userdefevname,
- struct ast_json *extra, const char *peer);
+ struct ast_json *extra);
static int append_expected_event_snapshot(
struct ast_channel_snapshot *snapshot,
enum ast_cel_event_type type,
const char *userdefevname,
- struct ast_json *extra, const char *peer);
+ struct ast_json *extra);
static int append_dummy_event(void);
@@ -620,7 +620,7 @@
#define EMULATE_DIAL(channel, dialstring) do { \
EMULATE_APP_DATA(channel, 1, "Dial", dialstring); \
- if (append_expected_event(channel, AST_CEL_APP_START, NULL, NULL, NULL)) { \
+ if (append_expected_event(channel, AST_CEL_APP_START, NULL, NULL)) { \
return AST_TEST_FAIL; \
} \
} while (0)
@@ -630,7 +630,7 @@
#define START_DIALED_FULL(caller, callee, number, name) do { \
callee = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, number, NULL, NULL, ast_channel_linkedid(caller), 0, CHANNEL_TECH_NAME "/" name); \
- if (append_expected_event(callee, AST_CEL_CHANNEL_START, NULL, NULL, NULL)) { \
+ if (append_expected_event(callee, AST_CEL_CHANNEL_START, NULL, NULL)) { \
return AST_TEST_FAIL; \
} \
ast_set_flag(ast_channel_flags(callee), AST_FLAG_OUTGOING); \
@@ -1410,8 +1410,13 @@
CREATE_CHARLIE_CHANNEL(chan_charlie, &charlie_caller);
{
+ RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
SCOPED_CHANNELLOCK(lock, chan_callee);
- APPEND_EVENT(chan_callee, AST_CEL_PICKUP, NULL, NULL, ast_channel_name(chan_charlie));
+
+ extra = ast_json_pack("{s: s}", "pickup_channel", ast_channel_name(chan_charlie));
+ ast_test_validate(test, extra != NULL);
+
+ APPEND_EVENT(chan_callee, AST_CEL_PICKUP, NULL, extra);
ast_test_validate(test, 0 == ast_do_pickup(chan_charlie, chan_callee));
}
@@ -1437,6 +1442,7 @@
RAII_VAR(struct ast_channel_snapshot *, bob_snapshot, NULL, ao2_cleanup);
RAII_VAR(struct stasis_message *, local_opt_begin, NULL, ao2_cleanup);
RAII_VAR(struct stasis_message *, local_opt_end, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref);
switch (cmd) {
case TEST_INIT:
@@ -1475,7 +1481,11 @@
stasis_publish(ast_channel_topic(chan_alice), local_opt_begin);
stasis_publish(ast_channel_topic(chan_alice), local_opt_end);
- APPEND_EVENT_SNAPSHOT(alice_snapshot, AST_CEL_LOCAL_OPTIMIZE, NULL, NULL, bob_snapshot->name);
+
+ extra = ast_json_pack("{s: s}", "local_two", bob_snapshot->name);
+ ast_test_validate(test, extra != NULL);
+
+ APPEND_EVENT_SNAPSHOT(alice_snapshot, AST_CEL_LOCAL_OPTIMIZE, NULL, extra);
HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "");
HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "");
@@ -1558,10 +1568,10 @@
struct ast_channel_snapshot *snapshot,
enum ast_cel_event_type type,
const char *userdefevname,
- struct ast_json *extra, const char *peer)
+ struct ast_json *extra)
{
RAII_VAR(struct ast_event *, ev, NULL, ast_free);
- ev = ast_cel_create_event(snapshot, type, userdefevname, extra, peer);
+ ev = ast_cel_create_event(snapshot, type, userdefevname, extra);
if (!ev) {
return -1;
}
@@ -1573,7 +1583,7 @@
struct ast_channel *chan,
enum ast_cel_event_type type,
const char *userdefevname,
- struct ast_json *extra, const char *peer)
+ struct ast_json *extra)
{
RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
snapshot = ast_channel_snapshot_create(chan);
@@ -1581,7 +1591,7 @@
return -1;
}
- return append_expected_event_snapshot(snapshot, type, userdefevname, extra, peer);
+ return append_expected_event_snapshot(snapshot, type, userdefevname, extra);
}
static void test_sub(struct ast_event *event)
More information about the asterisk-commits
mailing list