[Freeswitch-dev] mod_conference tracking

João Mesquita jmesquita at freeswitch.org
Mon Dec 27 07:31:59 MSK 2010

I decided, for now, to take the short way out. That is, use ESL to track the
events on the conference.

One problem that emerged while doing so was how to find unique instances of
a certain conference. To make it clearer, let me make an example.

Conference 123 is created on Sep 20, 2011 and has 20 members.

Same conference 123 is created on Sep 21, 2011 but now with 10 members.

Besides the obvious time difference, there was a problem identifying that
the conferences are unique in memory in FreeSWITCH, more accurately, the
same conference_obj. I came up with the idea then of adding one member to
the struct. That member is a uuid for that conference and it is added to all
events spit out by the module, so we know which conference is which

Since this patch adds stuff to the struct, I didn't want to just commit
without approval, so I would like to kindly ask one of the core devs to take
a look at it and give me the green light to commit it, if that's the case.
Sorry for posting it here, but Jira has been out for most of the weekend. I
will get it in there if it gets back online and this email has not been
responded yet.

The patch is attached.

Thank you,
João Mesquita

2010/12/25 João Mesquita <jmesquita at freeswitch.org>

> Hello you all. I hope you are all having a good holiday.
> I have been looking for the best way of tracking conference usage for
> reporting purposes (basically answering the question: what happened and when
> on conference nº X?) and I thought of the following alternatives that I
> would like to discuss with you.
> 1. Using ESL and the CUSTOM events to keep track of what happened when (I
> guess that's the most widely used)
> 2. Creating a new entry on switch_caller_profile, that would be filled by
> the mod_conference module anytime something changes on the conference.
> Something similar to what the origination_caller_profile does but that would
> be manipulated by the mod_conference. This option could neatly integrate
> with the xml cdrs but would mess a little more on the core. Not sure it is
> desirable.
> 3. Make mod_conference spit it's own XML for each conference created so
> that we know what happens and can link offline to other cdr entities.
> Or, maybe I am completely dumb and trying to do something that it is not
> supposed to be done or forgetting some resource that is already available.
> João Mesquita
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-dev/attachments/20101227/7ed08807/attachment.html 
-------------- next part --------------
diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c
index fa1f12c..22d3b40 100644
--- a/src/mod/applications/mod_conference/mod_conference.c
+++ b/src/mod/applications/mod_conference/mod_conference.c
@@ -287,6 +287,7 @@ typedef struct conference_obj {
 	uint32_t avg_itt;
 	uint32_t avg_tally;
 	switch_time_t run_time;
+	switch_uuid_t uuid;
 } conference_obj_t;
 /* Relationship with another member */
@@ -435,11 +436,14 @@ static switch_status_t conference_add_event_member_data(conference_member_t *mem
 static switch_status_t conference_add_event_data(conference_obj_t *conference, switch_event_t *event)
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
+	switch_uuid_format(uuid_str, &(conference->uuid));
 	switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Conference-Name", conference->name);
 	switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Conference-Size", "%u", conference->count);
 	switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Conference-Profile-Name", conference->profile_name);
+	switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Conference-Unique-ID", uuid_str);
 	return status;
@@ -2779,6 +2783,12 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Recording of %s Stopped\n", rec->path);
+	if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+		conference_add_event_data(conference, event);
+		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "stop-recording");
+		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Path", rec->path);
+		switch_event_fire(&event);
+	}
 	if (rec->pool) {
 		switch_memory_pool_t *pool = rec->pool;
@@ -6315,6 +6325,9 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m
 		conference->verbose_events = 1;
+	/* Create the conference unique identifier */
+	switch_uuid_get(&(conference->uuid));
 	/* Activate the conference mutex for exclusivity */
 	switch_mutex_init(&conference->mutex, SWITCH_MUTEX_NESTED, conference->pool);
 	switch_mutex_init(&conference->flag_mutex, SWITCH_MUTEX_NESTED, conference->pool);

More information about the FreeSWITCH-dev mailing list