fixes
authorSuper User <root@isdn.jolly.ten>
Sun, 6 Jan 2008 11:30:37 +0000 (12:30 +0100)
committerSuper User <root@isdn.jolly.ten>
Sun, 6 Jan 2008 11:30:37 +0000 (12:30 +0100)
trace of vbox
better beep after announcement
announcements without beep
recording of answering machine (vbox) works, as well as call recording.

modified:   README
modified:   action_vbox.cpp
modified:   port.cpp
modified:   port.h
modified:   todo.txt
modified:   vbox.cpp

README
action_vbox.cpp
port.cpp
port.h
todo.txt
vbox.cpp

diff --git a/README b/README
index 8aaf592..8c5098f 100644 (file)
--- a/README
+++ b/README
@@ -406,5 +406,8 @@ Changes in Version 0.3
 - Added origin flag to correctly process last_in and last_out call logging.
 - Tones and annoucements are not overwritten if exist, during installation.
 - Screening now also works for outgoing calls (to interface)
+- Fixed VBox, also added trace debugging.
+- Nice 'Beep' after the announcement.
+- Special announcement recording without beep.
+
 
-TODO: recording crashes!! (vbox, audio recording)
index d9f805a..49a91b5 100644 (file)
@@ -267,13 +267,13 @@ void EndpointAppPBX::action_dialing_vbox_play(void)
 
        if (e_vbox_state == VBOX_STATE_RECORD_RECORD)
        {
-               if (e_extdialing[0] == '1')
+               if (e_extdialing[0] == '1' || e_extdialing[0] == '0')
                {
                        PDEBUG(DEBUG_EPOINT, "EPOINT(%d) stopping recording of announcement.\n", ea_endpoint->ep_serial);
 
                        port = find_port_id(portlist->port_id);
                        if (port)
-                               port->close_record(6000); /* append beep */
+                               port->close_record((e_extdialing[0]=='1')?6000:0, 2000); /* append beep */
                        goto record_ask;
                }
                goto done;
@@ -326,8 +326,8 @@ void EndpointAppPBX::action_dialing_vbox_play(void)
                        port = find_port_id(portlist->port_id);
                        if (port)
                        {
-                               port->close_record(0); 
-                               port->open_record(CODEC_MONO, 1, 5000, e_ext.number, 0, "", 0); /* record announcement, skip the first 5000 samples */
+                               port->close_record(0,0); 
+                               port->open_record(CODEC_MONO, 1, 4000, e_ext.number, 0, "", 0); /* record announcement, skip the first 4000 samples */
                        }
                        e_vbox_state = VBOX_STATE_RECORD_RECORD;
                        if (e_ext.vbox_language)
index 02d8dc3..d254d0c 100644 (file)
--- a/port.cpp
+++ b/port.cpp
@@ -53,6 +53,7 @@ Functions:
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
+#include <math.h>
 #include "main.h"
 
 #define SHORT_MIN -32768
@@ -218,7 +219,7 @@ Port::~Port(void)
        struct message *message;
 
        if (p_record)
-               close_record(0);
+               close_record(0, 0);
 
        classuse--;
 
@@ -788,10 +789,9 @@ int Port::open_record(int type, int vbox, int skip, char *extension, int anon_ig
 /*
  * close the recoding file, put header in front and rename
  */
-void Port::close_record(int beep)
+void Port::close_record(int beep, int mute)
 {
-       static signed long beep_mono[] = {-10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000};
-       static unsigned char beep_8bit[] = {48, 208, 48, 208, 48, 208, 48, 208, 48, 208, 48, 208, 48, 208, 48, 208, 48, 208, 48, 208, 48, 208, 48, 208, 48, 208, 48, 208, 48, 208, 48, 208, 48, 208};
+       static signed short beep_mono[256];
        unsigned long size, wsize;
        struct fmt fmt;
        char filename[512], indexname[512];
@@ -849,41 +849,31 @@ void Port::close_record(int beep)
                i++;
        }
 
+       /* mute */
+       if (mute && p_record_type==CODEC_MONO)
+       {
+               i = p_record_length;
+               if (i > mute)
+                       i = mute;       
+               fseek(p_record, -(i<<1), SEEK_END);
+               p_record_length -= (i<<1);
+       }
        /* add beep to the end of recording */
-       if (beep)
-       switch(p_record_type)
+       if (beep && p_record_type==CODEC_MONO)
        {
-               case CODEC_MONO:
                i = 0;
-               while(i < beep)
+               while(i < 256)
                {
-                       fwrite(beep_mono, sizeof(beep_mono), 1, p_record);
-                       i += sizeof(beep_mono);
-                       p_record_length += sizeof(beep_mono);
-               }
-               break;
-               case CODEC_8BIT:
-               i = 0;
-               while(i < beep)
-               {
-                       fwrite(beep_8bit, sizeof(beep_8bit), 1, p_record);
-                       i += sizeof(beep_8bit);
-                       p_record_length += sizeof(beep_8bit);
+                       beep_mono[i] = (signed short)(sin((double)i / 5.688888888889 * 2.0 * 3.1415927) * 2000.0);
+                       i++;
                }
-               break;
-#if 0
-               case CODEC_LAW:
                i = 0;
                while(i < beep)
                {
-                       fwrite(beep_law, sizeof(beep_law), 1, p_record);
-                       i += sizeof(beep_law);
-                       p_record_length += sizeof(beep_law);
+                       fwrite(beep_mono, sizeof(beep_mono), 1, p_record);
+                       i += sizeof(beep_mono);
+                       p_record_length += sizeof(beep_mono);
                }
-               break;
-#endif
-               default:
-               PERROR("codec %d not supported for beep adding\n", p_record_type);
        }
 
        /* complete header */
diff --git a/port.h b/port.h
index d23ace0..8f9cc04 100644 (file)
--- a/port.h
+++ b/port.h
@@ -180,7 +180,7 @@ class Port
 
        /* recording */
        int open_record(int type, int mode, int skip, char *terminal, int anon_ignore, char *vbox_email, int vbox_email_file);
-       void close_record(int beep);
+       void close_record(int beep, int mute);
        void record(unsigned char *data, int length, int dir_fromup);
        FILE *p_record;                         /* recording fp: if not NULL, recording is enabled */
        int p_record_type;                      /* codec to use: RECORD_MONO, RECORD_STEREO, ... */
index 4ae6d1e..e6c7ddd 100644 (file)
--- a/todo.txt
+++ b/todo.txt
@@ -5,6 +5,8 @@ neue params zun aufbau eines externen/internen calls dokumentieren
 
 neuen partyline-param dokumentieren
 
+dokumentieren: aufzeichnung der ansage mit 0 ohne beep beenden
+
 make asterisk call implementation
 
 display message during nothing/play
index 9fde9fa..238a1da 100644 (file)
--- a/vbox.cpp
+++ b/vbox.cpp
@@ -55,6 +55,20 @@ VBoxPort::~VBoxPort()
 }
 
 
+static void vbox_trace_header(class VBoxPort *vbox, char *message, int direction)
+{
+       /* init trace with given values */
+       start_trace(0,
+                   NULL,
+                   vbox?numberrize_callerinfo(vbox->p_callerinfo.id, vbox->p_callerinfo.ntype):NULL,
+                   vbox?vbox->p_dialinginfo.id:NULL,
+                   direction,
+                   CATEGORY_CH,
+                   vbox?vbox->p_serial:0,
+                   message);
+}
+
+
 /*
  * handler of vbox
  */
@@ -82,6 +96,10 @@ int VBoxPort::handler(void)
                                message->param.disconnectinfo.cause = 16;
                                message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
                                message_put(message);
+                               vbox_trace_header(this, "RELEASE from VBox (recoding limit reached)", DIRECTION_IN);
+                               add_trace("cause", "value", "%d", message->param.disconnectinfo.cause);
+                               add_trace("cause", "location", "%d", message->param.disconnectinfo.location);
+                               end_trace();
                                /* remove epoint */
                                free_epointlist(p_epointlist);
                        }
@@ -134,6 +152,8 @@ int VBoxPort::handler(void)
                                        message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_CONNECT);
                                        memcpy(&message->param.connectinfo, &p_connectinfo, sizeof(struct connect_info));
                                        message_put(message);
+                                       vbox_trace_header(this, "CONNECT from VBox (announcement is over)", DIRECTION_IN);
+                                       end_trace();
                                        new_state(PORT_STATE_CONNECT);
                                }
                        }
@@ -143,6 +163,8 @@ int VBoxPort::handler(void)
                        {
                                /* recording start */
                                open_record(p_vbox_ext.vbox_codec, 2, 0, p_vbox_ext.number, p_vbox_ext.anon_ignore, p_vbox_ext.vbox_email, p_vbox_ext.vbox_email_file);
+                               vbox_trace_header(this, "RECORDING (announcement is over)", DIRECTION_IN);
+                               end_trace();
                        } else // else!!
                        if (p_vbox_mode == VBOX_MODE_ANNOUNCEMENT)
                        {
@@ -151,6 +173,10 @@ int VBoxPort::handler(void)
                                message->param.disconnectinfo.cause = 16;
                                message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
                                message_put(message);
+                               vbox_trace_header(this, "RELEASE from VBox (after annoucement)", DIRECTION_IN);
+                               add_trace("cause", "value", "%d", message->param.disconnectinfo.cause);
+                               add_trace("cause", "location", "%d", message->param.disconnectinfo.location);
+                               end_trace();
                                /* recording is close during destruction */
                                delete this;
                                return(-1); /* must return because port is gone */
@@ -196,9 +222,11 @@ int VBoxPort::message_epoint(unsigned long epoint_id, int message_id, union para
                return(1);
 
                case MESSAGE_DISCONNECT: /* call has been disconnected */
-               PDEBUG(DEBUG_VBOX, "PORT(%s) vbox port with (caller id %s) received disconnect cause=%d\n", p_name, p_callerinfo.id, param->disconnectinfo.cause);
-
                new_state(PORT_STATE_OUT_DISCONNECT);
+               vbox_trace_header(this, "DISCONNECT to VBox", DIRECTION_OUT);
+               add_trace("cause", "value", "%d", param->disconnectinfo.cause);
+               add_trace("cause", "location", "%d", param->disconnectinfo.location);
+               end_trace();
 
                while(p_epointlist)
                {
@@ -206,6 +234,10 @@ int VBoxPort::message_epoint(unsigned long epoint_id, int message_id, union para
                        message->param.disconnectinfo.cause = CAUSE_NORMAL;
                        message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
                        message_put(message);
+                       vbox_trace_header(this, "RELEASE from VBox (after disconnect)", DIRECTION_IN);
+                       add_trace("cause", "value", "%d", message->param.disconnectinfo.cause);
+                       add_trace("cause", "location", "%d", message->param.disconnectinfo.location);
+                       end_trace();
                        /* remove epoint */
                        free_epointlist(p_epointlist);
                }
@@ -215,7 +247,10 @@ int VBoxPort::message_epoint(unsigned long epoint_id, int message_id, union para
                break;
 
                case MESSAGE_RELEASE: /* release vbox port */
-               PDEBUG(DEBUG_VBOX, "PORT(%s) vbox port with (caller id %s) received release\n", p_name, p_callerinfo.id);
+               vbox_trace_header(this, "RELEASE to VBox", DIRECTION_OUT);
+               add_trace("cause", "value", "%d", param->disconnectinfo.cause);
+               add_trace("cause", "location", "%d", param->disconnectinfo.location);
+               end_trace();
 
                /* we are done */
                /* recording is close during destruction */
@@ -238,7 +273,11 @@ int VBoxPort::message_epoint(unsigned long epoint_id, int message_id, union para
                {
                        SPRINT(filename, "%s/%s/%s/vbox/announcement", INSTALL_DATA, options.extensions_dir, p_vbox_ext.number);
                }
-               PDEBUG(DEBUG_VBOX, "PORT(%s) vbox port received setup from '%s' to '%s'\n", p_name, param->setup.callerinfo.id, param->setup.dialinginfo.id);
+               vbox_trace_header(this, "SETUP to VBox", DIRECTION_OUT);
+               add_trace("from", "id", "%s", param->setup.callerinfo.id);
+               add_trace("to", "box", "%s", param->setup.dialinginfo.id);
+               end_trace();
+               memcpy(&p_dialinginfo, &param->setup.dialinginfo, sizeof(p_dialinginfo));
                memcpy(&p_callerinfo, &param->setup.callerinfo, sizeof(p_callerinfo));
                memcpy(&p_redirinfo, &param->setup.redirinfo, sizeof(p_redirinfo));
                /* link relation */
@@ -262,12 +301,16 @@ int VBoxPort::message_epoint(unsigned long epoint_id, int message_id, union para
                        message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_CONNECT);
                        memcpy(&message->param.connectinfo, &p_connectinfo, sizeof(struct connect_info));
                        message_put(message);
+                       vbox_trace_header(this, "CONNECT from VBox (after setup)", DIRECTION_IN);
+                       end_trace();
                        new_state(PORT_STATE_CONNECT);
                } else 
                {
                        /* send alerting message */
                        message = message_create(p_serial, epoint_id, PORT_TO_EPOINT, MESSAGE_ALERTING);
                        message_put(message);
+                       vbox_trace_header(this, "ALERTING from VBox (play announcement before connect)", DIRECTION_IN);
+                       end_trace();
                        new_state(PORT_STATE_IN_ALERTING);
                }
 
@@ -276,14 +319,19 @@ int VBoxPort::message_epoint(unsigned long epoint_id, int message_id, union para
                {
                        fhuse++;
                } 
+               vbox_trace_header(this, "ANNOUNCEMENT", DIRECTION_OUT);
+               add_trace("file", "name", "%s", filename);
+               add_trace("file", "exists", "%s", (p_vbox_announce_fh>=0)?"yes":"no");
+               end_trace();
                /* start recording if desired */
                p_vbox_mode = p_vbox_ext.vbox_mode;
                p_vbox_record_limit = p_vbox_ext.vbox_time;
-               if (!p_vbox_announce_fh || p_vbox_mode==VBOX_MODE_PARALLEL)
+               if (p_vbox_announce_fh<0 || p_vbox_mode==VBOX_MODE_PARALLEL)
                {
-                       PDEBUG(DEBUG_VBOX, "PORT(%s) parallel mode OR no announcement found at: '%s' so we start recording now.\n", p_name, filename);
                        /* recording start */
                        open_record(p_vbox_ext.vbox_codec, 2, 0, p_vbox_ext.number, p_vbox_ext.anon_ignore, p_vbox_ext.vbox_email, p_vbox_ext.vbox_email_file);
+                       vbox_trace_header(this, "RECORDING", DIRECTION_IN);
+                       end_trace();
                }
                break;