Ejemplo n.º 1
0
/**
 * Send rayo complete
 */
void rayo_component_send_complete_with_metadata_string(struct rayo_component *component, const char *reason, const char *reason_namespace, const char *meta, int child_of_complete)
{
	iks *meta_xml = NULL;
	iksparser *p = iks_dom_new(&meta_xml);
	if (iks_parse(p, meta, 0, 1) != IKS_OK) {
		/* unexpected ... */
		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "%s Failed to parse metadata for complete event: %s\n",
			RAYO_JID(component), meta);
		/* send without... */
		rayo_component_send_complete(component, reason, reason_namespace);
	} else {
		rayo_component_send_complete_with_metadata(component, reason, reason_namespace, meta_xml, child_of_complete);
	}
	if (meta_xml) {
		iks_delete(meta_xml);
	}
	iks_parser_delete(p);
}
Ejemplo n.º 2
0
/**
 * Notify completion of record component
 */
static void complete_record(struct rayo_component *component, const char *reason, const char *reason_namespace)
{
	switch_core_session_t *session = NULL;
	const char *uuid = component->parent->id;
	char *uri = switch_mprintf("file://%s", RECORD_COMPONENT(component)->local_file_path);
	iks *recording;
	switch_size_t file_size = 0;
/* TODO this doesn't work with HTTP */
#if 0
	switch_file_t *file;

	if (switch_file_open(&file, RECORD_COMPONENT(component)->local_file_path, SWITCH_FOPEN_READ, SWITCH_FPROT_UREAD, RAYO_POOL(component)) == SWITCH_STATUS_SUCCESS) {
		file_size = switch_file_get_size(file);
		switch_file_close(file);
	} else {
		switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_INFO, "Failed to open %s.\n", RECORD_COMPONENT(component)->local_file_path);
	}
#endif

	switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Recording %s done.\n", RECORD_COMPONENT(component)->local_file_path);

	if (RECORD_COMPONENT(component)->stop_beep && (session = switch_core_session_locate(uuid))) {
		switch_ivr_displace_session(session, RECORD_BEEP, 0, "");
		switch_core_session_rwunlock(session);
	}

	/* send complete event to client */
	recording = iks_new("recording");
	iks_insert_attrib(recording, "xmlns", RAYO_RECORD_COMPLETE_NS);
	iks_insert_attrib(recording, "uri", uri);
	iks_insert_attrib_printf(recording, "duration", "%i", RECORD_COMPONENT(component)->duration_ms);
	iks_insert_attrib_printf(recording, "size", "%"SWITCH_SIZE_T_FMT, file_size);
	rayo_component_send_complete_with_metadata(component, reason, reason_namespace, recording, 1);
	iks_delete(recording);

	RAYO_UNLOCK(component);

	switch_safe_free(uri);
}