mod_rayo: reworked internal messaging- all messages sent by JID only

This commit is contained in:
Chris Rienzo 2013-06-24 14:51:54 -04:00
parent 911948c87a
commit 0f0f278124
7 changed files with 380 additions and 400 deletions

File diff suppressed because it is too large Load Diff

View File

@ -42,6 +42,14 @@
#define RAYO_CALL_NS RAYO_BASE "call:" RAYO_VERSION #define RAYO_CALL_NS RAYO_BASE "call:" RAYO_VERSION
#define RAYO_MIXER_NS RAYO_BASE "mixer:" RAYO_VERSION #define RAYO_MIXER_NS RAYO_BASE "mixer:" RAYO_VERSION
#define RAT_CALL "CALL"
#define RAT_COMPONENT "COMPONENT"
#define RAT_CALL_COMPONENT RAT_COMPONENT"_CALL"
#define RAT_MIXER "MIXER"
#define RAT_MIXER_COMPONENT RAT_COMPONENT"_MIXER"
#define RAT_SERVER "SERVER"
#define RAT_PEER_SERVER "PEER_SERVER"
#define RAT_CLIENT "CLIENT"
/* these are support punchblock.. undefine once punchblock is fixed */ /* these are support punchblock.. undefine once punchblock is fixed */
#define RAYO_UUID_IN_REF_URI #define RAYO_UUID_IN_REF_URI
@ -56,30 +64,21 @@ struct rayo_component;
*/ */
struct rayo_message { struct rayo_message {
iks *payload; iks *payload;
char *from_jid;
char *from_type;
char *from_subtype;
int is_reply;
}; };
typedef void (* rayo_actor_cleanup_fn)(struct rayo_actor *); typedef void (* rayo_actor_cleanup_fn)(struct rayo_actor *);
typedef void (* rayo_actor_send_fn)(struct rayo_actor *, struct rayo_actor *, struct rayo_message *, const char *file, int line); typedef void (* rayo_actor_send_fn)(struct rayo_actor *, struct rayo_message *, const char *file, int line);
/**
* Type of actor
*/
enum rayo_actor_type {
RAT_PEER_SERVER,
RAT_CLIENT,
RAT_SERVER,
RAT_CALL,
RAT_MIXER,
RAT_CALL_COMPONENT,
RAT_MIXER_COMPONENT
};
/** /**
* A rayo actor - this is an entity that can be controlled by a rayo client * A rayo actor - this is an entity that can be controlled by a rayo client
*/ */
struct rayo_actor { struct rayo_actor {
/** Type of actor */ /** Type of actor */
enum rayo_actor_type type; char *type;
/** Sub-type of actor */ /** Sub-type of actor */
char *subtype; char *subtype;
/** domain part of JID */ /** domain part of JID */
@ -102,6 +101,8 @@ struct rayo_actor {
rayo_actor_send_fn send_fn; rayo_actor_send_fn send_fn;
/** optional cleanup */ /** optional cleanup */
rayo_actor_cleanup_fn cleanup_fn; rayo_actor_cleanup_fn cleanup_fn;
/** incoming message queue */
switch_queue_t *msg_queue;
}; };
/** /**
@ -125,16 +126,19 @@ struct rayo_component {
#define RAYO_CALL(x) ((struct rayo_call *)x) #define RAYO_CALL(x) ((struct rayo_call *)x)
#define RAYO_MIXER(x) ((struct rayo_mixer *)x) #define RAYO_MIXER(x) ((struct rayo_mixer *)x)
extern struct rayo_message *rayo_message_create(iks *xml); extern struct rayo_message *rayo_message_create(struct rayo_actor *from, iks *xml, int dup, int reply);
extern struct rayo_message *rayo_message_create_dup(iks *xml);
extern void rayo_message_destroy(struct rayo_message *msg); extern void rayo_message_destroy(struct rayo_message *msg);
extern iks *rayo_message_remove_payload(struct rayo_message *msg); extern iks *rayo_message_remove_payload(struct rayo_message *msg);
#define RAYO_MESSAGE_CREATE(from, msg) rayo_message_create(RAYO_ACTOR(from), msg, 0, 0)
#define RAYO_MESSAGE_CREATE_DUP(from, msg) rayo_message_create(RAYO_ACTOR(from), msg, 1, 0)
#define RAYO_REPLY_CREATE(from, msg) rayo_message_create(RAYO_ACTOR(from), msg, 0, 1)
#define RAYO_REPLY_CREATE_DUP(from, msg) rayo_message_create(RAYO_ACTOR(from), msg, 1, 1)
extern struct rayo_actor *rayo_actor_locate(const char *jid, const char *file, int line); extern struct rayo_actor *rayo_actor_locate(const char *jid, const char *file, int line);
extern struct rayo_actor *rayo_actor_locate_by_id(const char *id, const char *file, int line); extern struct rayo_actor *rayo_actor_locate_by_id(const char *id, const char *file, int line);
extern int rayo_actor_seq_next(struct rayo_actor *actor); extern int rayo_actor_seq_next(struct rayo_actor *actor);
extern void rayo_actor_send(struct rayo_actor *from, struct rayo_actor *to, struct rayo_message *msg, const char *file, int line); extern void rayo_actor_send(const char *jid, struct rayo_message *msg, const char *file, int line);
extern void rayo_actor_send_by_jid(struct rayo_actor *from, const char *jid, struct rayo_message *msg, const char *file, int line);
extern void rayo_actor_rdlock(struct rayo_actor *actor, const char *file, int line); extern void rayo_actor_rdlock(struct rayo_actor *actor, const char *file, int line);
extern void rayo_actor_unlock(struct rayo_actor *actor, const char *file, int line); extern void rayo_actor_unlock(struct rayo_actor *actor, const char *file, int line);
extern void rayo_actor_destroy(struct rayo_actor *actor, const char *file, int line); extern void rayo_actor_destroy(struct rayo_actor *actor, const char *file, int line);
@ -150,19 +154,18 @@ extern void rayo_actor_destroy(struct rayo_actor *actor, const char *file, int l
#define RAYO_UNLOCK(x) rayo_actor_unlock(RAYO_ACTOR(x), __FILE__, __LINE__) #define RAYO_UNLOCK(x) rayo_actor_unlock(RAYO_ACTOR(x), __FILE__, __LINE__)
#define RAYO_DESTROY(x) rayo_actor_destroy(RAYO_ACTOR(x), __FILE__, __LINE__) #define RAYO_DESTROY(x) rayo_actor_destroy(RAYO_ACTOR(x), __FILE__, __LINE__)
#define RAYO_SEQ_NEXT(x) rayo_actor_seq_next(RAYO_ACTOR(x)) #define RAYO_SEQ_NEXT(x) rayo_actor_seq_next(RAYO_ACTOR(x))
#define RAYO_SEND(from, to, msg) rayo_actor_send(RAYO_ACTOR(from), RAYO_ACTOR(to), msg, __FILE__, __LINE__) #define RAYO_SEND(to, msg) rayo_actor_send(to, msg, __FILE__, __LINE__)
#define RAYO_SEND_BY_JID(from, jid, msg) rayo_actor_send_by_jid(RAYO_ACTOR(from), jid, msg, __FILE__, __LINE__)
extern const char *rayo_call_get_dcp_jid(struct rayo_call *call); extern const char *rayo_call_get_dcp_jid(struct rayo_call *call);
#define rayo_mixer_get_name(mixer) RAYO_ID(mixer) #define rayo_mixer_get_name(mixer) RAYO_ID(mixer)
#define rayo_component_init(component, pool, type, id, parent, client_jid) _rayo_component_init(component, pool, type, id, parent, client_jid, __FILE__, __LINE__) #define rayo_component_init(component, pool, type, subtype, id, parent, client_jid) _rayo_component_init(component, pool, type, subtype, id, parent, client_jid, __FILE__, __LINE__)
extern struct rayo_component *_rayo_component_init(struct rayo_component *component, switch_memory_pool_t *pool, const char *type, const char *id, struct rayo_actor *parent, const char *client_jid, const char *file, int line); extern struct rayo_component *_rayo_component_init(struct rayo_component *component, switch_memory_pool_t *pool, const char *type, const char *subtype, const char *id, struct rayo_actor *parent, const char *client_jid, const char *file, int line);
typedef iks *(*rayo_actor_xmpp_handler)(struct rayo_actor *, struct rayo_actor *, iks *, void *); typedef iks *(*rayo_actor_xmpp_handler)(struct rayo_actor *, struct rayo_message *, void *);
extern void rayo_actor_command_handler_add(enum rayo_actor_type type, const char *subtype, const char *name, rayo_actor_xmpp_handler fn); extern void rayo_actor_command_handler_add(const char *type, const char *subtype, const char *name, rayo_actor_xmpp_handler fn);
extern void rayo_actor_event_handler_add(enum rayo_actor_type from_type, const char *from_subtype, enum rayo_actor_type to_type, const char *to_subtype, const char *name, rayo_actor_xmpp_handler fn); extern void rayo_actor_event_handler_add(const char *from_type, const char *from_subtype, const char *to_type, const char *to_subtype, const char *name, rayo_actor_xmpp_handler fn);
#endif #endif

View File

@ -40,7 +40,7 @@
struct rayo_component *rayo_component_locate(const char *id, const char *file, int line) struct rayo_component *rayo_component_locate(const char *id, const char *file, int line)
{ {
struct rayo_actor *actor = rayo_actor_locate_by_id(id, file, line); struct rayo_actor *actor = rayo_actor_locate_by_id(id, file, line);
if (actor && (actor->type == RAT_MIXER_COMPONENT || actor->type == RAT_CALL_COMPONENT)) { if (actor && !strncmp(RAT_COMPONENT, actor->type, strlen(RAT_COMPONENT))) {
return RAYO_COMPONENT(actor); return RAYO_COMPONENT(actor);
} else if (actor) { } else if (actor) {
RAYO_UNLOCK(actor); RAYO_UNLOCK(actor);
@ -63,7 +63,7 @@ void rayo_component_send_start(struct rayo_component *component, iks *iq)
#else #else
iks_insert_attrib_printf(ref, "uri", "xmpp:%s", RAYO_JID(component)); iks_insert_attrib_printf(ref, "uri", "xmpp:%s", RAYO_JID(component));
#endif #endif
RAYO_SEND_BY_JID(component, iks_find_attrib(response, "to"), rayo_message_create(response)); RAYO_SEND(iks_find_attrib(response, "to"), RAYO_REPLY_CREATE(component, response));
} }
/** /**
@ -116,7 +116,7 @@ iks *rayo_component_create_complete_event(struct rayo_component *component, cons
*/ */
void rayo_component_send_complete_event(struct rayo_component *component, iks *response) void rayo_component_send_complete_event(struct rayo_component *component, iks *response)
{ {
RAYO_SEND_BY_JID(component, iks_find_attrib(response, "to"), rayo_message_create(response)); RAYO_SEND(iks_find_attrib(response, "to"), RAYO_REPLY_CREATE(component, response));
RAYO_UNLOCK(component); RAYO_UNLOCK(component);
RAYO_DESTROY(component); RAYO_DESTROY(component);
} }

View File

@ -187,7 +187,7 @@ static void send_barge_event(struct rayo_component *component)
iks_insert_attrib(event, "to", component->client_jid); iks_insert_attrib(event, "to", component->client_jid);
x = iks_insert(event, "start-of-input"); x = iks_insert(event, "start-of-input");
iks_insert_attrib(x, "xmlns", RAYO_INPUT_NS); iks_insert_attrib(x, "xmlns", RAYO_INPUT_NS);
RAYO_SEND_BY_JID(component, component->client_jid, rayo_message_create(event)); RAYO_SEND(component->client_jid, RAYO_REPLY_CREATE(component, event));
} }
/** /**
@ -466,8 +466,9 @@ static iks *start_call_input(struct input_component *component, switch_core_sess
/** /**
* Start execution of input component * Start execution of input component
*/ */
static iks *start_call_input_component(struct rayo_actor *client, struct rayo_actor *call, iks *iq, void *session_data) static iks *start_call_input_component(struct rayo_actor *call, struct rayo_message *msg, void *session_data)
{ {
iks *iq = msg->payload;
switch_core_session_t *session = (switch_core_session_t *)session_data; switch_core_session_t *session = (switch_core_session_t *)session_data;
char *component_id = switch_mprintf("%s-input", switch_core_session_get_uuid(session)); char *component_id = switch_mprintf("%s-input", switch_core_session_get_uuid(session));
switch_memory_pool_t *pool = NULL; switch_memory_pool_t *pool = NULL;
@ -482,7 +483,7 @@ static iks *start_call_input_component(struct rayo_actor *client, struct rayo_ac
/* create component */ /* create component */
switch_core_new_memory_pool(&pool); switch_core_new_memory_pool(&pool);
input_component = switch_core_alloc(pool, sizeof(*input_component)); input_component = switch_core_alloc(pool, sizeof(*input_component));
rayo_component_init(RAYO_COMPONENT(input_component), pool, "input", component_id, call, iks_find_attrib(iq, "from")); rayo_component_init(RAYO_COMPONENT(input_component), pool, RAT_CALL_COMPONENT, "input", component_id, call, iks_find_attrib(iq, "from"));
switch_safe_free(component_id); switch_safe_free(component_id);
/* start input */ /* start input */
@ -492,8 +493,9 @@ static iks *start_call_input_component(struct rayo_actor *client, struct rayo_ac
/** /**
* Stop execution of input component * Stop execution of input component
*/ */
static iks *stop_call_input_component(struct rayo_actor *client, struct rayo_actor *component, iks *iq, void *data) static iks *stop_call_input_component(struct rayo_actor *component, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
struct input_component *input_component = INPUT_COMPONENT(component); struct input_component *input_component = INPUT_COMPONENT(component);
if (input_component && !input_component->stop) { if (input_component && !input_component->stop) {
@ -518,8 +520,9 @@ static iks *stop_call_input_component(struct rayo_actor *client, struct rayo_act
/** /**
* Start input component timers * Start input component timers
*/ */
static iks *start_timers_call_input_component(struct rayo_actor *client, struct rayo_actor *component, iks *iq, void *data) static iks *start_timers_call_input_component(struct rayo_actor *component, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
struct input_component *input_component = INPUT_COMPONENT(component); struct input_component *input_component = INPUT_COMPONENT(component);
if (input_component) { if (input_component) {
switch_core_session_t *session = switch_core_session_locate(RAYO_COMPONENT(component)->parent->id); switch_core_session_t *session = switch_core_session_locate(RAYO_COMPONENT(component)->parent->id);

View File

@ -57,14 +57,14 @@ struct output_component {
/** /**
* Create new output component * Create new output component
*/ */
static struct rayo_component *create_output_component(struct rayo_actor *actor, iks *output, const char *client_jid) static struct rayo_component *create_output_component(struct rayo_actor *actor, const char *type, iks *output, const char *client_jid)
{ {
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
struct output_component *output_component = NULL; struct output_component *output_component = NULL;
switch_core_new_memory_pool(&pool); switch_core_new_memory_pool(&pool);
output_component = switch_core_alloc(pool, sizeof(*output_component)); output_component = switch_core_alloc(pool, sizeof(*output_component));
rayo_component_init((struct rayo_component *)output_component, pool, "output", NULL, actor, client_jid); rayo_component_init((struct rayo_component *)output_component, pool, type, "output", NULL, actor, client_jid);
output_component->document = iks_copy(output); output_component->document = iks_copy(output);
output_component->repeat_interval = iks_find_int_attrib(output, "repeat-interval"); output_component->repeat_interval = iks_find_int_attrib(output, "repeat-interval");
@ -120,8 +120,9 @@ static iks *start_call_output(struct rayo_component *component, switch_core_sess
/** /**
* Start execution of call output component * Start execution of call output component
*/ */
static iks *start_call_output_component(struct rayo_actor *client, struct rayo_actor *call, iks *iq, void *session_data) static iks *start_call_output_component(struct rayo_actor *call, struct rayo_message *msg, void *session_data)
{ {
iks *iq = msg->payload;
switch_core_session_t *session = (switch_core_session_t *)session_data; switch_core_session_t *session = (switch_core_session_t *)session_data;
struct rayo_component *output_component = NULL; struct rayo_component *output_component = NULL;
iks *output = iks_find(iq, "output"); iks *output = iks_find(iq, "output");
@ -131,15 +132,16 @@ static iks *start_call_output_component(struct rayo_actor *client, struct rayo_a
return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST); return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST);
} }
output_component = create_output_component(call, output, iks_find_attrib(iq, "from")); output_component = create_output_component(call, RAT_CALL_COMPONENT, output, iks_find_attrib(iq, "from"));
return start_call_output(output_component, session, output, iq); return start_call_output(output_component, session, output, iq);
} }
/** /**
* Start execution of mixer output component * Start execution of mixer output component
*/ */
static iks *start_mixer_output_component(struct rayo_actor *client, struct rayo_actor *mixer, iks *iq, void *data) static iks *start_mixer_output_component(struct rayo_actor *mixer, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
struct rayo_component *component = NULL; struct rayo_component *component = NULL;
iks *output = iks_find(iq, "output"); iks *output = iks_find(iq, "output");
switch_stream_handle_t stream = { 0 }; switch_stream_handle_t stream = { 0 };
@ -149,7 +151,7 @@ static iks *start_mixer_output_component(struct rayo_actor *client, struct rayo_
return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST); return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST);
} }
component = create_output_component(mixer, output, iks_find_attrib(iq, "from")); component = create_output_component(mixer, RAT_MIXER_COMPONENT, output, iks_find_attrib(iq, "from"));
/* build conference command */ /* build conference command */
SWITCH_STANDARD_STREAM(stream); SWITCH_STANDARD_STREAM(stream);
@ -174,8 +176,9 @@ static iks *start_mixer_output_component(struct rayo_actor *client, struct rayo_
/** /**
* Stop execution of output component * Stop execution of output component
*/ */
static iks *stop_output_component(struct rayo_actor *client, struct rayo_actor *component, iks *iq, void *data) static iks *stop_output_component(struct rayo_actor *component, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
switch_stream_handle_t stream = { 0 }; switch_stream_handle_t stream = { 0 };
char *command = switch_mprintf("%s stop", RAYO_JID(component)); char *command = switch_mprintf("%s stop", RAYO_JID(component));
SWITCH_STANDARD_STREAM(stream); SWITCH_STANDARD_STREAM(stream);
@ -190,8 +193,9 @@ static iks *stop_output_component(struct rayo_actor *client, struct rayo_actor *
/** /**
* Pause execution of output component * Pause execution of output component
*/ */
static iks *pause_output_component(struct rayo_actor *client, struct rayo_actor *component, iks *iq, void *data) static iks *pause_output_component(struct rayo_actor *component, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
switch_stream_handle_t stream = { 0 }; switch_stream_handle_t stream = { 0 };
char *command = switch_mprintf("%s pause", RAYO_JID(component)); char *command = switch_mprintf("%s pause", RAYO_JID(component));
SWITCH_STANDARD_STREAM(stream); SWITCH_STANDARD_STREAM(stream);
@ -205,8 +209,9 @@ static iks *pause_output_component(struct rayo_actor *client, struct rayo_actor
/** /**
* Resume execution of output component * Resume execution of output component
*/ */
static iks *resume_output_component(struct rayo_actor *client, struct rayo_actor *component, iks *iq, void *data) static iks *resume_output_component(struct rayo_actor *component, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
switch_stream_handle_t stream = { 0 }; switch_stream_handle_t stream = { 0 };
char *command = switch_mprintf("%s resume", RAYO_JID(component)); char *command = switch_mprintf("%s resume", RAYO_JID(component));
SWITCH_STANDARD_STREAM(stream); SWITCH_STANDARD_STREAM(stream);
@ -220,8 +225,9 @@ static iks *resume_output_component(struct rayo_actor *client, struct rayo_actor
/** /**
* Speed up execution of output component * Speed up execution of output component
*/ */
static iks *speed_up_output_component(struct rayo_actor *client, struct rayo_actor *component, iks *iq, void *data) static iks *speed_up_output_component(struct rayo_actor *component, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
switch_stream_handle_t stream = { 0 }; switch_stream_handle_t stream = { 0 };
char *command = switch_mprintf("%s speed:+", RAYO_JID(component)); char *command = switch_mprintf("%s speed:+", RAYO_JID(component));
SWITCH_STANDARD_STREAM(stream); SWITCH_STANDARD_STREAM(stream);
@ -235,8 +241,9 @@ static iks *speed_up_output_component(struct rayo_actor *client, struct rayo_act
/** /**
* Slow down execution of output component * Slow down execution of output component
*/ */
static iks *speed_down_output_component(struct rayo_actor *client, struct rayo_actor *component, iks *iq, void *data) static iks *speed_down_output_component(struct rayo_actor *component, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
switch_stream_handle_t stream = { 0 }; switch_stream_handle_t stream = { 0 };
char *command = switch_mprintf("%s speed:-", RAYO_JID(component)); char *command = switch_mprintf("%s speed:-", RAYO_JID(component));
SWITCH_STANDARD_STREAM(stream); SWITCH_STANDARD_STREAM(stream);
@ -250,8 +257,9 @@ static iks *speed_down_output_component(struct rayo_actor *client, struct rayo_a
/** /**
* Increase volume of output component * Increase volume of output component
*/ */
static iks *volume_up_output_component(struct rayo_actor *client, struct rayo_actor *component, iks *iq, void *data) static iks *volume_up_output_component(struct rayo_actor *component, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
switch_stream_handle_t stream = { 0 }; switch_stream_handle_t stream = { 0 };
char *command = switch_mprintf("%s volume:+", RAYO_JID(component)); char *command = switch_mprintf("%s volume:+", RAYO_JID(component));
SWITCH_STANDARD_STREAM(stream); SWITCH_STANDARD_STREAM(stream);
@ -265,8 +273,9 @@ static iks *volume_up_output_component(struct rayo_actor *client, struct rayo_ac
/** /**
* Lower volume of output component * Lower volume of output component
*/ */
static iks *volume_down_output_component(struct rayo_actor *client, struct rayo_actor *component, iks *iq, void *data) static iks *volume_down_output_component(struct rayo_actor *component, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
switch_stream_handle_t stream = { 0 }; switch_stream_handle_t stream = { 0 };
char *command = switch_mprintf("%s volume:-", RAYO_JID(component)); char *command = switch_mprintf("%s volume:-", RAYO_JID(component));
SWITCH_STANDARD_STREAM(stream); SWITCH_STANDARD_STREAM(stream);
@ -280,8 +289,9 @@ static iks *volume_down_output_component(struct rayo_actor *client, struct rayo_
/** /**
* Seek output component * Seek output component
*/ */
static iks *seek_output_component(struct rayo_actor *client, struct rayo_actor *component, iks *iq, void *data) static iks *seek_output_component(struct rayo_actor *component, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
iks *seek = iks_find(iq, "seek"); iks *seek = iks_find(iq, "seek");
if (VALIDATE_RAYO_OUTPUT_SEEK(seek)) { if (VALIDATE_RAYO_OUTPUT_SEEK(seek)) {

View File

@ -62,8 +62,8 @@ struct prompt_component {
enum prompt_component_state state; enum prompt_component_state state;
iks *iq; iks *iq;
iks *complete; iks *complete;
struct rayo_actor *input; const char *input_jid;
struct rayo_actor *output; const char *output_jid;
}; };
#define PROMPT_COMPONENT(x) ((struct prompt_component *)x) #define PROMPT_COMPONENT(x) ((struct prompt_component *)x)
@ -89,17 +89,17 @@ static const char *prompt_component_state_to_string(enum prompt_component_state
/** /**
* Send stop to component * Send stop to component
*/ */
static void rayo_component_send_stop(struct rayo_actor *from, struct rayo_actor *to) static void rayo_component_send_stop(struct rayo_actor *from, const char *to)
{ {
iks *stop = iks_new("iq"); iks *stop = iks_new("iq");
iks *x; iks *x;
iks_insert_attrib(stop, "from", RAYO_JID(from)); iks_insert_attrib(stop, "from", RAYO_JID(from));
iks_insert_attrib(stop, "to", RAYO_JID(to)); iks_insert_attrib(stop, "to", to);
iks_insert_attrib(stop, "type", "set"); iks_insert_attrib(stop, "type", "set");
iks_insert_attrib_printf(stop, "id", "mod_rayo-%d", RAYO_SEQ_NEXT(from)); iks_insert_attrib_printf(stop, "id", "mod_rayo-%d", RAYO_SEQ_NEXT(from));
x = iks_insert(stop, "stop"); x = iks_insert(stop, "stop");
iks_insert_attrib(x, "xmlns", RAYO_EXT_NS); iks_insert_attrib(x, "xmlns", RAYO_EXT_NS);
RAYO_SEND(from, to, rayo_message_create(stop)); RAYO_SEND(to, RAYO_MESSAGE_CREATE(from, stop));
} }
/** /**
@ -118,7 +118,7 @@ static void start_input(struct prompt_component *prompt, int start_timers, int b
iks_insert_attrib(input, "start-timers", start_timers ? "true" : "false"); iks_insert_attrib(input, "start-timers", start_timers ? "true" : "false");
iks_insert_attrib(input, "barge-event", barge_event ? "true" : "false"); iks_insert_attrib(input, "barge-event", barge_event ? "true" : "false");
iks_insert_node(iq, input); iks_insert_node(iq, input);
RAYO_SEND(prompt, RAYO_COMPONENT(prompt)->parent, rayo_message_create(iq)); RAYO_SEND(RAYO_JID(RAYO_COMPONENT(prompt)->parent), RAYO_MESSAGE_CREATE(prompt, iq));
} }
/** /**
@ -129,33 +129,31 @@ static void start_input_timers(struct prompt_component *prompt)
iks *x; iks *x;
iks *iq = iks_new("iq"); iks *iq = iks_new("iq");
iks_insert_attrib(iq, "from", RAYO_JID(prompt)); iks_insert_attrib(iq, "from", RAYO_JID(prompt));
iks_insert_attrib(iq, "to", RAYO_JID(prompt->input)); iks_insert_attrib(iq, "to", prompt->input_jid);
iks_insert_attrib(iq, "type", "set"); iks_insert_attrib(iq, "type", "set");
iks_insert_attrib_printf(iq, "id", "mod_rayo-%d", RAYO_SEQ_NEXT(prompt)); iks_insert_attrib_printf(iq, "id", "mod_rayo-%d", RAYO_SEQ_NEXT(prompt));
x = iks_insert(iq, "start-timers"); x = iks_insert(iq, "start-timers");
iks_insert_attrib(x, "xmlns", RAYO_INPUT_NS); iks_insert_attrib(x, "xmlns", RAYO_INPUT_NS);
RAYO_SEND(prompt, prompt->input, rayo_message_create(iq)); RAYO_SEND(prompt->input_jid, RAYO_MESSAGE_CREATE(prompt, iq));
} }
/** /**
* Handle start of output. * Handle start of output.
*/ */
static iks *prompt_component_handle_output_start(struct rayo_actor *output, struct rayo_actor *prompt, iks *iq, void *data) static iks *prompt_component_handle_output_start(struct rayo_actor *prompt, struct rayo_message *msg, void *data)
{ {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) output start\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) output start\n",
RAYO_JID(prompt), prompt_component_state_to_string(PROMPT_COMPONENT(prompt)->state)); RAYO_JID(prompt), prompt_component_state_to_string(PROMPT_COMPONENT(prompt)->state));
switch (PROMPT_COMPONENT(prompt)->state) { switch (PROMPT_COMPONENT(prompt)->state) {
case PCS_START_OUTPUT: case PCS_START_OUTPUT:
PROMPT_COMPONENT(prompt)->output = output; PROMPT_COMPONENT(prompt)->output_jid = switch_core_strdup(RAYO_POOL(prompt), msg->from_jid);
RAYO_RDLOCK(output);
PROMPT_COMPONENT(prompt)->state = PCS_OUTPUT; PROMPT_COMPONENT(prompt)->state = PCS_OUTPUT;
/* send ref to client */ /* send ref to client */
rayo_component_send_start(RAYO_COMPONENT(prompt), PROMPT_COMPONENT(prompt)->iq); rayo_component_send_start(RAYO_COMPONENT(prompt), PROMPT_COMPONENT(prompt)->iq);
break; break;
case PCS_START_OUTPUT_BARGE: case PCS_START_OUTPUT_BARGE:
PROMPT_COMPONENT(prompt)->output = output; PROMPT_COMPONENT(prompt)->output_jid = switch_core_strdup(RAYO_POOL(prompt), msg->from_jid);
RAYO_RDLOCK(output);
PROMPT_COMPONENT(prompt)->state = PCS_START_INPUT_OUTPUT; PROMPT_COMPONENT(prompt)->state = PCS_START_INPUT_OUTPUT;
/* start input without timers and with barge events */ /* start input without timers and with barge events */
start_input(PROMPT_COMPONENT(prompt), 0, 1); start_input(PROMPT_COMPONENT(prompt), 0, 1);
@ -179,28 +177,25 @@ static iks *prompt_component_handle_output_start(struct rayo_actor *output, stru
/** /**
* Handle start of input. * Handle start of input.
*/ */
static iks *prompt_component_handle_input_start(struct rayo_actor *input, struct rayo_actor *prompt, iks *iq, void *data) static iks *prompt_component_handle_input_start(struct rayo_actor *prompt, struct rayo_message *msg, void *data)
{ {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) input start\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) input start\n",
RAYO_JID(prompt), prompt_component_state_to_string(PROMPT_COMPONENT(prompt)->state)); RAYO_JID(prompt), prompt_component_state_to_string(PROMPT_COMPONENT(prompt)->state));
switch (PROMPT_COMPONENT(prompt)->state) { switch (PROMPT_COMPONENT(prompt)->state) {
case PCS_START_INPUT: case PCS_START_INPUT:
PROMPT_COMPONENT(prompt)->input = input; PROMPT_COMPONENT(prompt)->input_jid = switch_core_strdup(RAYO_POOL(prompt), msg->from_jid);
RAYO_RDLOCK(input);
PROMPT_COMPONENT(prompt)->state = PCS_INPUT; PROMPT_COMPONENT(prompt)->state = PCS_INPUT;
break; break;
case PCS_START_INPUT_OUTPUT: case PCS_START_INPUT_OUTPUT:
PROMPT_COMPONENT(prompt)->input = input; PROMPT_COMPONENT(prompt)->input_jid = switch_core_strdup(RAYO_POOL(prompt), msg->from_jid);
RAYO_RDLOCK(input);
PROMPT_COMPONENT(prompt)->state = PCS_INPUT_OUTPUT; PROMPT_COMPONENT(prompt)->state = PCS_INPUT_OUTPUT;
/* send ref to client */ /* send ref to client */
rayo_component_send_start(RAYO_COMPONENT(prompt), PROMPT_COMPONENT(prompt)->iq); rayo_component_send_start(RAYO_COMPONENT(prompt), PROMPT_COMPONENT(prompt)->iq);
iks_delete(PROMPT_COMPONENT(prompt)->iq); iks_delete(PROMPT_COMPONENT(prompt)->iq);
break; break;
case PCS_START_INPUT_TIMERS: case PCS_START_INPUT_TIMERS:
PROMPT_COMPONENT(prompt)->input = input; PROMPT_COMPONENT(prompt)->input_jid = switch_core_strdup(RAYO_POOL(prompt), msg->from_jid);
RAYO_RDLOCK(input);
PROMPT_COMPONENT(prompt)->state = PCS_INPUT; PROMPT_COMPONENT(prompt)->state = PCS_INPUT;
/* send ref to client */ /* send ref to client */
rayo_component_send_start(RAYO_COMPONENT(prompt), PROMPT_COMPONENT(prompt)->iq); rayo_component_send_start(RAYO_COMPONENT(prompt), PROMPT_COMPONENT(prompt)->iq);
@ -209,9 +204,8 @@ static iks *prompt_component_handle_input_start(struct rayo_actor *input, struct
break; break;
case PCS_DONE: case PCS_DONE:
/* stopped by client */ /* stopped by client */
PROMPT_COMPONENT(prompt)->input = input; PROMPT_COMPONENT(prompt)->input_jid = switch_core_strdup(RAYO_POOL(prompt), msg->from_jid);
RAYO_RDLOCK(input); rayo_component_send_stop(prompt, msg->from_jid);
rayo_component_send_stop(prompt, input);
break; break;
case PCS_START_OUTPUT: case PCS_START_OUTPUT:
case PCS_START_OUTPUT_BARGE: case PCS_START_OUTPUT_BARGE:
@ -229,14 +223,15 @@ static iks *prompt_component_handle_input_start(struct rayo_actor *input, struct
/** /**
* Handle start of input/output. * Handle start of input/output.
*/ */
static iks *prompt_component_handle_io_start(struct rayo_actor *component, struct rayo_actor *prompt, iks *iq, void *data) static iks *prompt_component_handle_io_start(struct rayo_actor *prompt, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s, got <ref> from %s: %s\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s, got <ref> from %s: %s\n",
RAYO_JID(prompt), RAYO_JID(component), iks_string(iks_stack(iq), iq)); RAYO_JID(prompt), msg->from_jid, iks_string(iks_stack(iq), iq));
if (!strcmp("input", component->subtype)) { if (!strcmp("input", msg->from_subtype)) {
return prompt_component_handle_input_start(component, prompt, iq, data); return prompt_component_handle_input_start(prompt, msg, data);
} else if (!strcmp("output", component->subtype)) { } else if (!strcmp("output", msg->from_subtype)) {
return prompt_component_handle_output_start(component, prompt, iq, data); return prompt_component_handle_output_start(prompt, msg, data);
} }
return NULL; return NULL;
} }
@ -244,7 +239,7 @@ static iks *prompt_component_handle_io_start(struct rayo_actor *component, struc
/** /**
* Handle barge event * Handle barge event
*/ */
static iks *prompt_component_handle_input_start_timers_error(struct rayo_actor *input, struct rayo_actor *prompt, iks *iq, void *data) static iks *prompt_component_handle_input_start_timers_error(struct rayo_actor *prompt, struct rayo_message *msg, void *data)
{ {
/* this is only expected if input component is gone */ /* this is only expected if input component is gone */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) start timers error\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) start timers error\n",
@ -256,8 +251,9 @@ static iks *prompt_component_handle_input_start_timers_error(struct rayo_actor *
/** /**
* Handle input failure. * Handle input failure.
*/ */
static iks *prompt_component_handle_input_error(struct rayo_actor *input, struct rayo_actor *prompt, iks *iq, void *data) static iks *prompt_component_handle_input_error(struct rayo_actor *prompt, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
iks *error = iks_find(iq, "error"); iks *error = iks_find(iq, "error");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) input error\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) input error\n",
@ -282,7 +278,7 @@ static iks *prompt_component_handle_input_error(struct rayo_actor *input, struct
iks_insert_node(iq, iks_copy_within(error, iks_stack(iq))); iks_insert_node(iq, iks_copy_within(error, iks_stack(iq)));
PROMPT_COMPONENT(prompt)->complete = iq; PROMPT_COMPONENT(prompt)->complete = iq;
rayo_component_send_stop(prompt, PROMPT_COMPONENT(prompt)->output); rayo_component_send_stop(prompt, PROMPT_COMPONENT(prompt)->output_jid);
break; break;
case PCS_START_OUTPUT: case PCS_START_OUTPUT:
case PCS_START_OUTPUT_BARGE: case PCS_START_OUTPUT_BARGE:
@ -302,8 +298,9 @@ static iks *prompt_component_handle_input_error(struct rayo_actor *input, struct
/** /**
* Handle output failure. * Handle output failure.
*/ */
static iks *prompt_component_handle_output_error(struct rayo_actor *output, struct rayo_actor *prompt, iks *iq, void *data) static iks *prompt_component_handle_output_error(struct rayo_actor *prompt, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
iks *error = iks_find(iq, "error"); iks *error = iks_find(iq, "error");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) output error\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) output error\n",
@ -320,7 +317,7 @@ static iks *prompt_component_handle_output_error(struct rayo_actor *output, stru
iks_insert_attrib(iq, "from", RAYO_JID(RAYO_COMPONENT(prompt)->parent)); iks_insert_attrib(iq, "from", RAYO_JID(RAYO_COMPONENT(prompt)->parent));
iks_insert_attrib(iq, "to", RAYO_COMPONENT(prompt)->client_jid); iks_insert_attrib(iq, "to", RAYO_COMPONENT(prompt)->client_jid);
iks_insert_node(iq, iks_copy_within(error, iks_stack(iq))); iks_insert_node(iq, iks_copy_within(error, iks_stack(iq)));
RAYO_SEND_BY_JID(prompt, RAYO_COMPONENT(prompt)->client_jid, rayo_message_create(iq)); RAYO_SEND(RAYO_COMPONENT(prompt)->client_jid, RAYO_REPLY_CREATE(prompt, iq));
/* done */ /* done */
RAYO_UNLOCK(prompt); RAYO_UNLOCK(prompt);
@ -346,17 +343,18 @@ static iks *prompt_component_handle_output_error(struct rayo_actor *output, stru
/** /**
* Handle barge event * Handle barge event
*/ */
static iks *prompt_component_handle_input_barge(struct rayo_actor *input, struct rayo_actor *prompt, iks *presence, void *data) static iks *prompt_component_handle_input_barge(struct rayo_actor *prompt, struct rayo_message *msg, void *data)
{ {
iks *presence = msg->payload;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) input barge\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) input barge\n",
RAYO_JID(prompt), prompt_component_state_to_string(PROMPT_COMPONENT(prompt)->state)); RAYO_JID(prompt), prompt_component_state_to_string(PROMPT_COMPONENT(prompt)->state));
switch (PROMPT_COMPONENT(prompt)->state) { switch (PROMPT_COMPONENT(prompt)->state) {
case PCS_INPUT_OUTPUT: case PCS_INPUT_OUTPUT:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s, got <start-of-input> from %s: %s\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s, got <start-of-input> from %s: %s\n",
RAYO_JID(prompt), RAYO_JID(input), iks_string(iks_stack(presence), presence)); RAYO_JID(prompt), msg->from_jid, iks_string(iks_stack(presence), presence));
PROMPT_COMPONENT(prompt)->state = PCS_STOP_OUTPUT; PROMPT_COMPONENT(prompt)->state = PCS_STOP_OUTPUT;
rayo_component_send_stop(prompt, PROMPT_COMPONENT(prompt)->output); rayo_component_send_stop(prompt, PROMPT_COMPONENT(prompt)->output_jid);
break; break;
case PCS_STOP_OUTPUT: case PCS_STOP_OUTPUT:
case PCS_INPUT: case PCS_INPUT:
@ -379,8 +377,9 @@ static iks *prompt_component_handle_input_barge(struct rayo_actor *input, struct
/** /**
* Handle completion event * Handle completion event
*/ */
static iks *prompt_component_handle_input_complete(struct rayo_actor *input, struct rayo_actor *prompt, iks *presence, void *data) static iks *prompt_component_handle_input_complete(struct rayo_actor *prompt, struct rayo_message *msg, void *data)
{ {
iks *presence = msg->payload;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) input complete\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) input complete\n",
RAYO_JID(prompt), prompt_component_state_to_string(PROMPT_COMPONENT(prompt)->state)); RAYO_JID(prompt), prompt_component_state_to_string(PROMPT_COMPONENT(prompt)->state));
@ -391,8 +390,7 @@ static iks *prompt_component_handle_input_complete(struct rayo_actor *input, str
iks_insert_attrib(presence, "from", RAYO_JID(prompt)); iks_insert_attrib(presence, "from", RAYO_JID(prompt));
iks_insert_attrib(presence, "to", RAYO_COMPONENT(prompt)->client_jid); iks_insert_attrib(presence, "to", RAYO_COMPONENT(prompt)->client_jid);
PROMPT_COMPONENT(prompt)->complete = presence; PROMPT_COMPONENT(prompt)->complete = presence;
rayo_component_send_stop(prompt, PROMPT_COMPONENT(prompt)->output); rayo_component_send_stop(prompt, PROMPT_COMPONENT(prompt)->output_jid);
RAYO_UNLOCK(input);
break; break;
case PCS_STOP_OUTPUT: case PCS_STOP_OUTPUT:
PROMPT_COMPONENT(prompt)->state = PCS_DONE_STOP_OUTPUT; PROMPT_COMPONENT(prompt)->state = PCS_DONE_STOP_OUTPUT;
@ -400,7 +398,6 @@ static iks *prompt_component_handle_input_complete(struct rayo_actor *input, str
iks_insert_attrib(presence, "from", RAYO_JID(prompt)); iks_insert_attrib(presence, "from", RAYO_JID(prompt));
iks_insert_attrib(presence, "to", RAYO_COMPONENT(prompt)->client_jid); iks_insert_attrib(presence, "to", RAYO_COMPONENT(prompt)->client_jid);
PROMPT_COMPONENT(prompt)->complete = presence; PROMPT_COMPONENT(prompt)->complete = presence;
RAYO_UNLOCK(input);
break; break;
case PCS_INPUT: case PCS_INPUT:
PROMPT_COMPONENT(prompt)->state = PCS_DONE; PROMPT_COMPONENT(prompt)->state = PCS_DONE;
@ -410,7 +407,6 @@ static iks *prompt_component_handle_input_complete(struct rayo_actor *input, str
iks_insert_attrib(presence, "from", RAYO_JID(prompt)); iks_insert_attrib(presence, "from", RAYO_JID(prompt));
iks_insert_attrib(presence, "to", RAYO_COMPONENT(prompt)->client_jid); iks_insert_attrib(presence, "to", RAYO_COMPONENT(prompt)->client_jid);
rayo_component_send_complete_event(RAYO_COMPONENT(prompt), presence); rayo_component_send_complete_event(RAYO_COMPONENT(prompt), presence);
RAYO_UNLOCK(input);
break; break;
case PCS_OUTPUT: case PCS_OUTPUT:
case PCS_START_OUTPUT: case PCS_START_OUTPUT:
@ -429,7 +425,7 @@ static iks *prompt_component_handle_input_complete(struct rayo_actor *input, str
/** /**
* Handle completion event * Handle completion event
*/ */
static iks *prompt_component_handle_output_complete(struct rayo_actor *output, struct rayo_actor *prompt, iks *presence, void *data) static iks *prompt_component_handle_output_complete(struct rayo_actor *prompt, struct rayo_message *msg, void *data)
{ {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) output complete\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) output complete\n",
RAYO_JID(prompt), prompt_component_state_to_string(PROMPT_COMPONENT(prompt)->state)); RAYO_JID(prompt), prompt_component_state_to_string(PROMPT_COMPONENT(prompt)->state));
@ -437,30 +433,25 @@ static iks *prompt_component_handle_output_complete(struct rayo_actor *output, s
switch (PROMPT_COMPONENT(prompt)->state) { switch (PROMPT_COMPONENT(prompt)->state) {
case PCS_OUTPUT: case PCS_OUTPUT:
PROMPT_COMPONENT(prompt)->state = PCS_START_INPUT; PROMPT_COMPONENT(prompt)->state = PCS_START_INPUT;
RAYO_UNLOCK(output);
/* start input with timers enabled and barge events disabled */ /* start input with timers enabled and barge events disabled */
start_input(PROMPT_COMPONENT(prompt), 1, 0); start_input(PROMPT_COMPONENT(prompt), 1, 0);
iks_delete(PROMPT_COMPONENT(prompt)->iq); iks_delete(PROMPT_COMPONENT(prompt)->iq);
break; break;
case PCS_START_INPUT_OUTPUT: case PCS_START_INPUT_OUTPUT:
PROMPT_COMPONENT(prompt)->state = PCS_INPUT; PROMPT_COMPONENT(prompt)->state = PCS_INPUT;
RAYO_UNLOCK(output);
break; break;
case PCS_INPUT_OUTPUT: case PCS_INPUT_OUTPUT:
PROMPT_COMPONENT(prompt)->state = PCS_INPUT; PROMPT_COMPONENT(prompt)->state = PCS_INPUT;
RAYO_UNLOCK(output);
start_input_timers(PROMPT_COMPONENT(prompt)); start_input_timers(PROMPT_COMPONENT(prompt));
break; break;
case PCS_STOP_OUTPUT: case PCS_STOP_OUTPUT:
PROMPT_COMPONENT(prompt)->state = PCS_INPUT; PROMPT_COMPONENT(prompt)->state = PCS_INPUT;
RAYO_UNLOCK(output);
start_input_timers(PROMPT_COMPONENT(prompt)); start_input_timers(PROMPT_COMPONENT(prompt));
break; break;
case PCS_DONE_STOP_OUTPUT: case PCS_DONE_STOP_OUTPUT:
if (PROMPT_COMPONENT(prompt)->complete) { if (PROMPT_COMPONENT(prompt)->complete) {
rayo_component_send_complete_event(RAYO_COMPONENT(prompt), PROMPT_COMPONENT(prompt)->complete); rayo_component_send_complete_event(RAYO_COMPONENT(prompt), PROMPT_COMPONENT(prompt)->complete);
} }
RAYO_UNLOCK(output);
break; break;
case PCS_INPUT: case PCS_INPUT:
case PCS_START_OUTPUT: case PCS_START_OUTPUT:
@ -478,8 +469,9 @@ static iks *prompt_component_handle_output_complete(struct rayo_actor *output, s
/** /**
* Start execution of prompt component * Start execution of prompt component
*/ */
static iks *start_call_prompt_component(struct rayo_actor *client, struct rayo_actor *call, iks *iq, void *session_data) static iks *start_call_prompt_component(struct rayo_actor *call, struct rayo_message *msg, void *session_data)
{ {
iks *iq = msg->payload;
switch_core_session_t *session = (switch_core_session_t *)session_data; switch_core_session_t *session = (switch_core_session_t *)session_data;
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
struct prompt_component *prompt_component = NULL; struct prompt_component *prompt_component = NULL;
@ -508,7 +500,7 @@ static iks *start_call_prompt_component(struct rayo_actor *client, struct rayo_a
/* create prompt component, linked to call */ /* create prompt component, linked to call */
switch_core_new_memory_pool(&pool); switch_core_new_memory_pool(&pool);
prompt_component = switch_core_alloc(pool, sizeof(*prompt_component)); prompt_component = switch_core_alloc(pool, sizeof(*prompt_component));
rayo_component_init(RAYO_COMPONENT(prompt_component), pool, "prompt", NULL, call, iks_find_attrib(iq, "from")); rayo_component_init(RAYO_COMPONENT(prompt_component), pool, RAT_CALL_COMPONENT, "prompt", NULL, call, iks_find_attrib(iq, "from"));
prompt_component->iq = iks_copy(iq); prompt_component->iq = iks_copy(iq);
/* start output */ /* start output */
@ -524,7 +516,7 @@ static iks *start_call_prompt_component(struct rayo_actor *client, struct rayo_a
iks_insert_attrib(cmd, "type", "set"); iks_insert_attrib(cmd, "type", "set");
output = iks_copy_within(output, iks_stack(cmd)); output = iks_copy_within(output, iks_stack(cmd));
iks_insert_node(cmd, output); iks_insert_node(cmd, output);
RAYO_SEND(prompt_component, call, rayo_message_create(cmd)); RAYO_SEND(RAYO_JID(call), RAYO_MESSAGE_CREATE(prompt_component, cmd));
return NULL; return NULL;
} }
@ -532,8 +524,9 @@ static iks *start_call_prompt_component(struct rayo_actor *client, struct rayo_a
/** /**
* Stop execution of prompt component * Stop execution of prompt component
*/ */
static iks *stop_call_prompt_component(struct rayo_actor *client, struct rayo_actor *prompt, iks *iq, void *data) static iks *stop_call_prompt_component(struct rayo_actor *prompt, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
iks *reply = NULL; iks *reply = NULL;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) stop prompt\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) stop prompt\n",
RAYO_JID(prompt), prompt_component_state_to_string(PROMPT_COMPONENT(prompt)->state)); RAYO_JID(prompt), prompt_component_state_to_string(PROMPT_COMPONENT(prompt)->state));
@ -543,13 +536,13 @@ static iks *stop_call_prompt_component(struct rayo_actor *client, struct rayo_ac
/* input hasn't started yet */ /* input hasn't started yet */
PROMPT_COMPONENT(prompt)->state = PCS_DONE_STOP_OUTPUT; PROMPT_COMPONENT(prompt)->state = PCS_DONE_STOP_OUTPUT;
PROMPT_COMPONENT(prompt)->complete = rayo_component_create_complete_event(RAYO_COMPONENT(prompt), COMPONENT_COMPLETE_STOP); PROMPT_COMPONENT(prompt)->complete = rayo_component_create_complete_event(RAYO_COMPONENT(prompt), COMPONENT_COMPLETE_STOP);
rayo_component_send_stop(prompt, PROMPT_COMPONENT(prompt)->output); rayo_component_send_stop(prompt, PROMPT_COMPONENT(prompt)->output_jid);
break; break;
case PCS_INPUT_OUTPUT: case PCS_INPUT_OUTPUT:
case PCS_INPUT: case PCS_INPUT:
case PCS_STOP_OUTPUT: case PCS_STOP_OUTPUT:
/* stopping input will trigger completion */ /* stopping input will trigger completion */
rayo_component_send_stop(prompt, PROMPT_COMPONENT(prompt)->input); rayo_component_send_stop(prompt, PROMPT_COMPONENT(prompt)->input_jid);
break; break;
case PCS_START_INPUT: case PCS_START_INPUT:
/* stop input as soon as it starts */ /* stop input as soon as it starts */
@ -577,8 +570,9 @@ static iks *stop_call_prompt_component(struct rayo_actor *client, struct rayo_ac
/** /**
* Pass output component command * Pass output component command
*/ */
static iks *forward_output_component_request(struct rayo_actor *client, struct rayo_actor *prompt, iks *iq, void *data) static iks *forward_output_component_request(struct rayo_actor *prompt, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) %s prompt\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) %s prompt\n",
RAYO_JID(prompt), prompt_component_state_to_string(PROMPT_COMPONENT(prompt)->state), iks_name(iks_first_tag(iq))); RAYO_JID(prompt), prompt_component_state_to_string(PROMPT_COMPONENT(prompt)->state), iks_name(iks_first_tag(iq)));
@ -588,8 +582,8 @@ static iks *forward_output_component_request(struct rayo_actor *client, struct r
case PCS_INPUT_OUTPUT: { case PCS_INPUT_OUTPUT: {
/* forward request to output component */ /* forward request to output component */
iks_insert_attrib(iq, "from", RAYO_JID(prompt)); iks_insert_attrib(iq, "from", RAYO_JID(prompt));
iks_insert_attrib(iq, "to", RAYO_JID(PROMPT_COMPONENT(prompt)->output)); iks_insert_attrib(iq, "to", RAYO_JID(PROMPT_COMPONENT(prompt)->output_jid));
RAYO_SEND(prompt, PROMPT_COMPONENT(prompt)->output, rayo_message_create_dup(iq)); RAYO_SEND(PROMPT_COMPONENT(prompt)->output_jid, RAYO_MESSAGE_CREATE_DUP(prompt, iq));
return NULL; return NULL;
} }
case PCS_START_INPUT_TIMERS: case PCS_START_INPUT_TIMERS:

View File

@ -144,7 +144,7 @@ static void on_call_record_stop_event(switch_event_t *event)
/** /**
* Create a record component * Create a record component
*/ */
static struct rayo_component *record_component_create(struct rayo_actor *actor, const char *client_jid, iks *record) static struct rayo_component *record_component_create(struct rayo_actor *actor, const char *type, const char *client_jid, iks *record)
{ {
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
struct record_component *record_component = NULL; struct record_component *record_component = NULL;
@ -171,7 +171,7 @@ static struct rayo_component *record_component_create(struct rayo_actor *actor,
switch_core_new_memory_pool(&pool); switch_core_new_memory_pool(&pool);
record_component = switch_core_alloc(pool, sizeof(*record_component)); record_component = switch_core_alloc(pool, sizeof(*record_component));
rayo_component_init(RAYO_COMPONENT(record_component), pool, "record", fs_file_path, actor, client_jid); rayo_component_init(RAYO_COMPONENT(record_component), pool, type, "record", fs_file_path, actor, client_jid);
record_component->max_duration = iks_find_int_attrib(record, "max-duration"); record_component->max_duration = iks_find_int_attrib(record, "max-duration");
record_component->initial_timeout = iks_find_int_attrib(record, "initial-timeout"); record_component->initial_timeout = iks_find_int_attrib(record, "initial-timeout");
record_component->final_timeout = iks_find_int_attrib(record, "final-timeout"); record_component->final_timeout = iks_find_int_attrib(record, "final-timeout");
@ -259,13 +259,14 @@ static int start_call_record(switch_core_session_t *session, struct rayo_compone
/** /**
* Start execution of call record component * Start execution of call record component
*/ */
static iks *start_call_record_component(struct rayo_actor *client, struct rayo_actor *call, iks *iq, void *session_data) static iks *start_call_record_component(struct rayo_actor *call, struct rayo_message *msg, void *session_data)
{ {
iks *iq = msg->payload;
switch_core_session_t *session = (switch_core_session_t *)session_data; switch_core_session_t *session = (switch_core_session_t *)session_data;
struct rayo_component *component = NULL; struct rayo_component *component = NULL;
iks *record = iks_find(iq, "record"); iks *record = iks_find(iq, "record");
component = record_component_create(call, iks_find_attrib(iq, "from"), record); component = record_component_create(call, RAT_CALL_COMPONENT, iks_find_attrib(iq, "from"), record);
if (!component) { if (!component) {
return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST); return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST);
} }
@ -284,8 +285,9 @@ static iks *start_call_record_component(struct rayo_actor *client, struct rayo_a
/** /**
* Stop execution of record component * Stop execution of record component
*/ */
static iks *stop_call_record_component(struct rayo_actor *client, struct rayo_actor *component, iks *iq, void *data) static iks *stop_call_record_component(struct rayo_actor *component, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
switch_core_session_t *session = switch_core_session_locate(RAYO_COMPONENT(component)->parent->id); switch_core_session_t *session = switch_core_session_locate(RAYO_COMPONENT(component)->parent->id);
if (session) { if (session) {
RECORD_COMPONENT(component)->stop = 1; RECORD_COMPONENT(component)->stop = 1;
@ -298,8 +300,9 @@ static iks *stop_call_record_component(struct rayo_actor *client, struct rayo_ac
/** /**
* Pause execution of record component * Pause execution of record component
*/ */
static iks *pause_record_component(struct rayo_actor *client, struct rayo_actor *component, iks *iq, void *data) static iks *pause_record_component(struct rayo_actor *component, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
struct record_component *record = RECORD_COMPONENT(component); struct record_component *record = RECORD_COMPONENT(component);
switch_stream_handle_t stream = { 0 }; switch_stream_handle_t stream = { 0 };
char *command = switch_mprintf("%s pause", record->local_file_path); char *command = switch_mprintf("%s pause", record->local_file_path);
@ -319,8 +322,9 @@ static iks *pause_record_component(struct rayo_actor *client, struct rayo_actor
/** /**
* Resume execution of record component * Resume execution of record component
*/ */
static iks *resume_record_component(struct rayo_actor *client, struct rayo_actor *component, iks *iq, void *data) static iks *resume_record_component(struct rayo_actor *component, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
struct record_component *record = RECORD_COMPONENT(component); struct record_component *record = RECORD_COMPONENT(component);
switch_stream_handle_t stream = { 0 }; switch_stream_handle_t stream = { 0 };
char *command = switch_mprintf("%s resume", record->local_file_path); char *command = switch_mprintf("%s resume", record->local_file_path);
@ -381,12 +385,13 @@ static int start_mixer_record(struct rayo_component *component)
/** /**
* Start execution of mixer record component * Start execution of mixer record component
*/ */
static iks *start_mixer_record_component(struct rayo_actor *client, struct rayo_actor *mixer, iks *iq, void *data) static iks *start_mixer_record_component(struct rayo_actor *mixer, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
struct rayo_component *component = NULL; struct rayo_component *component = NULL;
iks *record = iks_find(iq, "record"); iks *record = iks_find(iq, "record");
component = record_component_create(mixer, iks_find_attrib(iq, "from"), record); component = record_component_create(mixer, RAT_MIXER_COMPONENT, iks_find_attrib(iq, "from"), record);
if (!component) { if (!component) {
return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST); return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST);
} }
@ -412,8 +417,9 @@ static iks *start_mixer_record_component(struct rayo_actor *client, struct rayo_
/** /**
* Stop execution of record component * Stop execution of record component
*/ */
static iks *stop_mixer_record_component(struct rayo_actor *client, struct rayo_actor *component, iks *iq, void *data) static iks *stop_mixer_record_component(struct rayo_actor *component, struct rayo_message *msg, void *data)
{ {
iks *iq = msg->payload;
char *args; char *args;
switch_stream_handle_t stream = { 0 }; switch_stream_handle_t stream = { 0 };
SWITCH_STANDARD_STREAM(stream); SWITCH_STANDARD_STREAM(stream);